Returns the idArchive if the archive is available in the database for the requested plugin.
Returns false if the archive needs to be processed.

@return array
970446
protected function loadExistingArchiveIdFromDb()
    {
        $noArchiveFound = array(false, false, false);

        // see isArchiveTemporary()
        $minDatetimeArchiveProcessedUTC = $this->getMinTimeArchiveProcessed();

        if ($this->isArchivingForcedToTrigger()) {
            return $noArchiveFound;
        }

        $idAndVisits = ArchiveSelector::getArchiveIdAndVisits($this->params, $minDatetimeArchiveProcessedUTC);

        if (!$idAndVisits) {
            return $noArchiveFound;
        }

        return $idAndVisits;
    }
1170409
public static function current_archived_stage()
    {
        $parts = explode('.', Versioned::get_reading_mode());
        if (sizeof($parts) === 3 && $parts[0] == 'Archive') {
            return $parts[2];
        }
        return static::DRAFT;
    }
1283575
public static function getSelectableDoneFlagValues()
    {
        $possibleValues = array(ArchiveWriter::DONE_OK, ArchiveWriter::DONE_OK_TEMPORARY);

        if (!Rules::isRequestAuthorizedToArchive()) {
            //If request is not authorized to archive then fetch also invalidated archives
            $possibleValues[] = ArchiveWriter::DONE_INVALIDATED;
        }

        return $possibleValues;
    }
198281
public function getArchiveDay()
    {
        $day = $this->request->param('Day');

        if (preg_match('/^[0-9]{1,2}$/', $day)) {
            if (checkdate($this->getArchiveMonth(), $day, $this->getArchiveYear())) {
                return (int) $day;
            }
        }

        return null;
    }
1079814
public function getWroteBlocks()
    {
        if (!is_dir($this->blocks)) {
            throw new RuntimeException("cannot obtain the blocks ({$this->blocks})");
        }
        $files = array_filter(array_map(function($file) {
            $basename = basename($file);
            if (!is_numeric($basename)) {
                return false;
            }
            return [
                'offset' => (int)$basename,
                'file' => $file,
                'size' => filesize($file)
            ];
        }, glob($this->blocks . "*")));

        uasort($files, function($a, $b) {
            return $a['offset'] - $b['offset'];
        });

        return $files;
    }
128897
public function getPluginsLoadedAndActivated()
    {
        if (is_null($this->pluginsLoadedAndActivated)) {
            $enabled = $this->getActivatedPlugins();

            if (empty($enabled)) {
                return array();
            }

            $plugins = $this->getLoadedPlugins();
            $enabled = array_combine($enabled, $enabled);
            $plugins = array_intersect_key($plugins, $enabled);

            $this->pluginsLoadedAndActivated = $plugins;
        }

        return $this->pluginsLoadedAndActivated;
    }
358852
public function isAvailable()
    {
        return \file_exists($this->cacheDir) && \is_dir($this->cacheDir) && \is_writable($this->cacheDir);
    }
1359792
public static function doesAnyPluginArchiveWithoutVisits()
    {
        $archivers = static::getPluginArchivers();

        foreach ($archivers as $pluginName => $archiverClass) {
            if ($archiverClass::shouldRunEvenWhenNoVisits()) {
                return true;
            }
        }

        return false;
    }
938700
public function actionClearTransforms()
    {
        $config = Plugin::$plugin->getSettings();
        $request = Craft::$app->getRequest();

        $key = $request->getParam('key', '');
        $setKey = $config->clearKey;

        if ($setKey === '' || $key != $setKey) {
            throw new \Exception('Unautorized key');
        }

        Plugin::$plugin->imager->deleteImageTransformCaches();

        return true;
    }
77514
protected function checkCacheVersion()
    {
        $fileName = $this->getVersionFileName();

        if (!file_exists($fileName)) {
            return false;
        }

        $version = md5($this->boltVersion);
        $cached = file_get_contents($fileName);

        if ($version === $cached) {
            return true;
        }
        $this->versionChange = true;

        return false;
    }
195024
public function getForDynamoDB()
    {
        if ($this->isArray()) {
            $value = array_map(function ($val) { return strval($val); }, $this->getValue());
        } else {
            $value = strval($this->getValue());
        }

        return array($this->getType() => $value);
    }
177996
protected function _get()
	{
		// get the apc key for the cache identifier
		$key = $this->_get_key();

		// fetch the cached data from the apc store
		$payload = apc_fetch($key);

		try
		{
			$this->unprep_contents($payload);
		}
		catch (\UnexpectedValueException $e)
		{
			return false;
		}

		return true;
	}
804545
public static function raiseMemoryLimitIfNecessary()
    {
        $memoryLimit = self::getMemoryLimitValue();
        if ($memoryLimit === false) {
            return false;
        }
        $minimumMemoryLimit = Config::getInstance()->General['minimum_memory_limit'];

        if (self::isArchivePhpTriggered()) {
            // core:archive command: no time limit, high memory limit
            self::setMaxExecutionTime(0);
            $minimumMemoryLimitWhenArchiving = Config::getInstance()->General['minimum_memory_limit_when_archiving'];
            if ($memoryLimit < $minimumMemoryLimitWhenArchiving) {
                return self::setMemoryLimit($minimumMemoryLimitWhenArchiving);
            }
            return false;
        }
        if ($memoryLimit < $minimumMemoryLimit) {
            return self::setMemoryLimit($minimumMemoryLimit);
        }
        return false;
    }
779927
public function getDepartment(){
	    if (!$this->access_token && !$this->checkAuth()) return false;
	    $result = $this->http_get(self::API_URL_PREFIX.self::DEPARTMENT_LIST_URL.'access_token='.$this->access_token);
	    if ($result)
	    {
	        $json = json_decode($result,true);
	        if (!$json || !empty($json['errcode'])) {
	            $this->errCode = $json['errcode'];
	            $this->errMsg = $json['errmsg'];
	            return false;
	        }
	        return $json;
	    }
	    return false;
	}
484132
public function readPluginsDirectory()
    {
        $result = array();
        foreach (self::getPluginsDirectories() as $pluginsDir) {
            $pluginsName = _glob($pluginsDir . '*', GLOB_ONLYDIR);
            if ($pluginsName != false) {
                foreach ($pluginsName as $path) {
                    if (self::pluginStructureLooksValid($path)) {
                        $result[] = basename($path);
                    }
                }
            }
        }

        sort($result);

        return $result;
    }
1029770
protected function _checkArchivers()
    {
        if (!function_exists('exec')) {
            $this->options['archivers'] = $this->options['archive'] = array();

            return;
        }
        $arcs = array(
            'create'  => array(),
            'extract' => array()
            );

        //exec('tar --version', $o, $ctar);
        $this->procExec('tar --version', $o, $ctar);

        if ($ctar == 0) {
            $arcs['create']['application/x-tar']  = array('cmd' => 'tar', 'argc' => '-cf', 'ext' => 'tar');
            $arcs['extract']['application/x-tar'] = array('cmd' => 'tar', 'argc' => '-xf', 'ext' => 'tar');
            //$test = exec('gzip --version', $o, $c);
            unset($o);
            $test = $this->procExec('gzip --version', $o, $c);

            if ($c == 0) {
                $arcs['create']['application/x-gzip']  = array('cmd' => 'tar', 'argc' => '-czf', 'ext' => 'tgz');
                $arcs['extract']['application/x-gzip'] = array('cmd' => 'tar', 'argc' => '-xzf', 'ext' => 'tgz');
            }
            unset($o);
            //$test = exec('bzip2 --version', $o, $c);
            $test = $this->procExec('bzip2 --version', $o, $c);
            if ($c == 0) {
                $arcs['create']['application/x-bzip2']  = array('cmd' => 'tar', 'argc' => '-cjf', 'ext' => 'tbz');
                $arcs['extract']['application/x-bzip2'] = array('cmd' => 'tar', 'argc' => '-xjf', 'ext' => 'tbz');
            }
        }
        unset($o);
        //exec('zip --version', $o, $c);
        $this->procExec('zip -v', $o, $c);
        if ($c == 0) {
            $arcs['create']['application/zip']  = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
        }
        unset($o);
        $this->procExec('unzip --help', $o, $c);
        if ($c == 0) {
            $arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '',  'ext' => 'zip');
        }
        unset($o);
        //exec('rar --version', $o, $c);
        $this->procExec('rar --version', $o, $c);
        if ($c == 0 || $c == 7) {
            $arcs['create']['application/x-rar']  = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
            $arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y',    'ext' => 'rar');
        } else {
            unset($o);
            //$test = exec('unrar', $o, $c);
            $test = $this->procExec('unrar', $o, $c);
            if ($c==0 || $c == 7) {
                $arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
            }
        }
        unset($o);
        //exec('7za --help', $o, $c);
        $this->procExec('7za --help', $o, $c);
        if ($c == 0) {
            $arcs['create']['application/x-7z-compressed']  = array('cmd' => '7za', 'argc' => 'a', 'ext' => '7z');
            $arcs['extract']['application/x-7z-compressed'] = array('cmd' => '7za', 'argc' => 'e -y', 'ext' => '7z');

            if (empty($arcs['create']['application/x-gzip'])) {
                $arcs['create']['application/x-gzip'] = array('cmd' => '7za', 'argc' => 'a -tgzip', 'ext' => 'tar.gz');
            }
            if (empty($arcs['extract']['application/x-gzip'])) {
                $arcs['extract']['application/x-gzip'] = array('cmd' => '7za', 'argc' => 'e -tgzip -y', 'ext' => 'tar.gz');
            }
            if (empty($arcs['create']['application/x-bzip2'])) {
                $arcs['create']['application/x-bzip2'] = array('cmd' => '7za', 'argc' => 'a -tbzip2', 'ext' => 'tar.bz');
            }
            if (empty($arcs['extract']['application/x-bzip2'])) {
                $arcs['extract']['application/x-bzip2'] = array('cmd' => '7za', 'argc' => 'a -tbzip2 -y', 'ext' => 'tar.bz');
            }
            if (empty($arcs['create']['application/zip'])) {
                $arcs['create']['application/zip'] = array('cmd' => '7za', 'argc' => 'a -tzip -l', 'ext' => 'zip');
            }
            if (empty($arcs['extract']['application/zip'])) {
                $arcs['extract']['application/zip'] = array('cmd' => '7za', 'argc' => 'e -tzip -y', 'ext' => 'zip');
            }
            if (empty($arcs['create']['application/x-tar'])) {
                $arcs['create']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'a -ttar -l', 'ext' => 'tar');
            }
            if (empty($arcs['extract']['application/x-tar'])) {
                $arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'e -ttar -y', 'ext' => 'tar');
            }
        }

        $this->archivers = $arcs;
    }
392775
public function getGranted()
    {
        $databoxes = [];

        /** @var \collection $collection */
        foreach ($this->acl->get_granted_base([\ACL::CANREPORT]) as $collection) {
            $sbas_id = $collection->get_sbas_id();
            if (!isset($databoxes[$sbas_id])) {
                $databoxes[$sbas_id] = [
                    'id' => $sbas_id,
                    'name' => $collection->get_databox()->get_viewname(),
                    'collections' => []
                ];
            }
            $databoxes[$sbas_id]['collections'][$collection->get_base_id()] = [
                'id' => $collection->get_base_id(),
                'coll_id' => $collection->get_coll_id(),
                'name' => $collection->get_name()
            ];
        }

        return ['databoxes' => $databoxes];
    }