/*!
Checks if the script is run on correct eZ Publish version.
517333
function validateVersion()
    {
        $versionValidated = false;
        $ezversion = eZPublishSDK::version();
        if ( $this->MinVersion !== false )
        {
            if ( $this->MaxVersion !== false )
            {
                if ( version_compare( $this->MinVersion, $ezversion , 'le' ) &&
                     version_compare( $this->MaxVersion, $ezversion , 'ge' ) )
                {
                    return true;
                }
                return false;
            }
            if ( version_compare( $this->MinVersion, $ezversion , 'le' ) )
            {
                return true;
            }
            return false;
        }
        else
        {
            if ( version_compare( $this->MaxVersion, $ezversion , 'ge' ) )
            {
                return true;
            }
            return false;
        }
    }
216299
private static void checkSurefireVersion(Object mojo) throws Exception {
        try {
            // Check version specific methods/fields.
            // mojo.getClass().getMethod(GET_RUN_ORDER);
            getField(SKIP_TESTS_FIELD, mojo);
            getField(FORK_MODE_FIELD, mojo);

            // We will always require the following.
            getField(ARGLINE_FIELD, mojo);
            getField(EXCLUDES_FIELD, mojo);
        } catch (NoSuchMethodException ex) {
            throwMojoExecutionException(mojo, "Unsupported surefire version.  An alternative is to use select/restore goals.", ex);
        }
    }
421413
protected static function checkVersion()
    {
        if (self::$checked === true) {
            return true;
        }

        $process = new \SystemProcess\SystemProcess('bzr');
        $process->nonZeroExitCodeException = true;
        $process->argument('--version')->execute();

        if (!preg_match('/\Bazaar \(bzr\) ([0-9.]*)/', $process->stdoutOutput, $match)) {
            throw new \RuntimeException('Could not determine Bazaar version.');
        }

        if (version_compare($match[1], '1.1', '<')) {
            throw new \RuntimeException('Bazaar is required in a minimum version of 1.1.');
        }

        $process = new \SystemProcess\SystemProcess('bzr');
        $process->nonZeroExitCodeException = true;
        $process->argument('plugins')->execute();

        if (strpos($process->stdoutOutput, 'xmloutput') === false) {
            throw new \RuntimeException('Missing required bazaar pluging "xmloutput".');
        }

        return self::$checked = true;
    }
1113159
protected function checkInstallScript()
    {
        $this->displayMsgNLInCli(' > Check install specific script :');

        //If no script to complete the install
        if (
            empty($this->sourceInstallScript)
            || $this->sourceInstallScript === false
        ) {
            $this->displayMsgInCli(' >> ');
            $this->displayMsgNLInCli(
                'No specific script declared. Pass',
                'yellow',
                'bold'
            );
            
            return;
        }

        //If the module ask a install script but not declare the name
        //Use the default name
        if ($this->sourceInstallScript === true) {
            $this->sourceInstallScript = 'runInstallModule.php';
        }
        
        $this->displayMsgInCli(' >> ');
        $this->displayMsgNLInCli(
            'Scripts find. Add to list to execute.',
            'yellow',
            'bold'
        );
    }
1279075
function validateCSSFile( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
    {
        $hasSiteFile = eZHTTPFile::canFetch( 'PackageSiteCSSFile' );
        $hasClassesFile = eZHTTPFile::canFetch( 'PackageClassesCSSFile' );

        $result = true;
        if ( !$hasSiteFile or !$hasClassesFile )
        {
            $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'CSS file' ),
                                  'description' => ezpI18n::tr( 'kernel/package', 'You must upload both CSS files' ) );
            return false;
        }

        $siteFile = eZHTTPFile::fetch( 'PackageSiteCSSFile' );
        $classesFile = eZHTTPFile::fetch( 'PackageClassesCSSFile' );
        if ( !preg_match( "#\.css$#", strtolower( $siteFile->attribute( 'original_filename' ) ) ) or
             !preg_match( "#\.css$#", strtolower( $classesFile->attribute( 'original_filename' ) ) ) )
        {
            $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'CSS file' ),
                                  'description' => ezpI18n::tr( 'kernel/package', 'File did not have a .css suffix, this is most likely not a CSS file' ) );
            $result = false;
        }
        return $result;
    }
836985
public function checkVersion()
    {
        if ($this->checkCacheVersion()) {
            return;
        }
        $this->syncAssets();
        $this->cache->flushAll();
        $this->updateAutoloader();
        $this->updateCacheVersion();
    }
1351185
public function validateVersion()
    {
        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
            $this->_logger->log('Invalid request method', Icepay_Api_Logger::ERROR);
            return false;
        }

        if ($this->generateChecksumForVersion() != $this->data->checksum) {
            $this->_logger->log('Checksum does not match', Icepay_Api_Logger::ERROR);
            return false;
        }

        return true;
    }
933255
def detect_version():
    """"""
    version_regex = re.compile(r'\(PostgreSQL\) (?P<major>\d)\.(?P<minor>\d)\.(?P<bugfix>\d)')
    pg_version = None
    with hide('running', 'stdout', 'stderr'):
        output = run('psql --version')
    match = version_regex.search(output)
    if match:
        result = match.groupdict()
        if 'major' in result and 'minor' in result:
            pg_version = u'%(major)s.%(minor)s' % result
    if not pg_version:
        abort(u"Error: Could not determine Postgres version of the server.")
    return pg_version
427536
function store( $publish = false )
    {
        if ( $publish )
        {
            $originalVersion = $this->attribute( 'version' );
            $this->setAttribute( 'version', eZPDFExport::VERSION_VALID );
        }
        $user = eZUser::currentUser();
        $this->setAttribute( 'modified', time() );
        $this->setAttribute( 'modifier_id', $user->attribute( 'contentobject_id' ) );

        $db = eZDB::instance();
        $db->begin();
        parent::store();
        if ( $publish )
        {
            $this->setAttribute( 'version', eZPDFExport::VERSION_DRAFT );
            $this->remove();
            $this->setAttribute( 'version', $originalVersion );
        }
        $db->commit();
    }
188060
def checkscript(self, content):
        
        if "VERSION" not in self.__capabilities:
            raise NotImplementedError(
                "server does not support CHECKSCRIPT command")
        content = tools.to_bytes(content)
        content = tools.to_bytes("{%d+}" % len(content)) + CRLF + content
        code, data = self.__send_command("CHECKSCRIPT", [content])
        if code == "OK":
            return True
        return False
699614
def versioned_script?
      return chunks.size == 1 &&
             chunks[0].pushdata? &&
             chunks[0].canonical? &&
             chunks[0].pushdata.bytesize > 2
    end
1004842
function validatePackageThumbnail( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
    {
        // If we don't have an image we continue as normal
        if ( !eZHTTPFile::canFetch( 'PackageThumbnail' ) )
            return true;

        if ( !self::httpFileIsImage( ezpI18n::tr( 'kernel/package', 'PackageThumbnail' ), $errorList ) )
        {
            return false;
        }

        $file = eZHTTPFile::fetch( 'PackageThumbnail' );

        $result = true;
        if ( $file )
        {
            $mimeData = eZMimeType::findByFileContents( $file->attribute( 'original_filename' ) );
            $dir = eZSys::storageDirectory() . '/temp';
            eZMimeType::changeDirectoryPath( $mimeData, $dir );
            $file->store( false, false, $mimeData );
            $persistentData['thumbnail'] = $mimeData;
        }
        return $result;
    }
868048
public function jobCheckNewExtensionVersion($data)
    {
        $config = $this->getConfig();

        if (!$config->get('adminNotifications') || !$config->get('adminNotificationsNewExtensionVersion')) {
            return true;
        }

        $pdo = $this->getEntityManager()->getPDO();

        $query = "
            SELECT id, name, version, check_version_url as url
            FROM extension
            WHERE deleted = 0
            AND is_installed = 1
            ORDER BY created_at
        ";

        $sth = $pdo->prepare($query);
        $sth->execute();

        $rowList = $sth->fetchAll(\PDO::FETCH_ASSOC);

        $latestReleases = [];
        foreach ($rowList as $row) {

            $url = !empty($row['url']) ? $row['url'] : null;
            $extensionName = $row['name'];

            $latestRelease = $this->getLatestRelease($url, [
                'name' => $extensionName,
            ]);

            if (!empty($latestRelease) && !isset($latestRelease['error'])) {
                $latestReleases[$extensionName] = $latestRelease;
            }
        }

        $latestExtensionVersions = $config->get('latestExtensionVersions', []);

        $save = false;
        foreach ($latestReleases as $extensionName => $extensionData) {

            if (empty($latestExtensionVersions[$extensionName])) {
                $latestExtensionVersions[$extensionName] = $extensionData['version'];
                $save = true;
                continue;
            }

            if ($latestExtensionVersions[$extensionName] != $extensionData['version']) {
                $latestExtensionVersions[$extensionName] = $extensionData['version'];

                if (!empty($extensionData['notes'])) {
                    //todo: create notification
                }

                $save = true;
                continue;
            }

            if (!empty($extensionData['notes'])) {
                //todo: find and modify notification
            }
        }

        if ($save) {
            $config->set('latestExtensionVersions', $latestExtensionVersions);
            $config->save();
        }

        return true;
    }
290700
public function onBeforeWrite()
    {
        parent::onBeforeWrite();

        // only operate on staging content for this extension; otherwise, you
        // need to publish the page to be able to set a 'future' publish...
        // while the same could be said for the unpublish, the 'publish' state
        // is the one that must be avoided so we allow setting the 'unpublish'
        // date for as-yet-not-published content.
        if (Versioned::get_stage() === Versioned::LIVE) {
            return;
        }

        /*
         * Without checking if there's actually a workflow in effect, simply saving
         * as draft, would clear the Scheduled Publish & Unpublish date fields, which we obviously
         * don't want during a workflow: These date fields should be treated as a content
         * change that also requires approval (where such an approval step exists).
         *
         * - Check to see if we've got 'desired' publish/unpublish date(s).
         * - Check if there's a workflow attached to this content
         * - Reset values if it's safe to do so
         */
        if (!$this->getIsWorkflowInEffect()) {
            $resetPublishOnDate = $this->owner->DesiredPublishDate && $this->owner->PublishOnDate;
            if ($resetPublishOnDate) {
                $this->owner->PublishOnDate = null;
            }

            $resetUnPublishOnDate = $this->owner->DesiredUnPublishDate && $this->owner->UnPublishOnDate;
            if ($resetUnPublishOnDate) {
                $this->owner->UnPublishOnDate = null;
            }
        }

        // Jobs can only be queued for records that already exist
        if (!$this->owner->ID) {
            return;
        }

        // Check requested dates of publish / unpublish, and whether the page should have already been unpublished
        $now = DBDatetime::now()->getTimestamp();
        $publishTime = $this->owner->dbObject('PublishOnDate')->getTimestamp();
        $unPublishTime = $this->owner->dbObject('UnPublishOnDate')->getTimestamp();

        // We should have a publish job if:
        // if no unpublish or publish time, then the Workflow Publish Action will publish without a job
        if ((!$unPublishTime && $publishTime) // the unpublish date is not set
            || (
                // unpublish date has not passed
                $unPublishTime > $now
                // publish date not set or happens before unpublish date
                && ($publishTime && ($publishTime < $unPublishTime))
            )
        ) {
            // Trigger time immediately if passed
            $this->ensurePublishJob($publishTime < $now ? null : $publishTime);
        } else {
            $this->clearPublishJob();
        }

        // We should have an unpublish job if:
        if ($unPublishTime // we have an unpublish date
            &&
            $publishTime < $unPublishTime // publish date is before to unpublish date
        ) {
            // Trigger time immediately if passed
            $this->ensureUnPublishJob($unPublishTime < $now ? null : $unPublishTime);
        } else {
            $this->clearUnPublishJob();
        }
    }
420847
final public static function checkFrameworkBuildVersion()
    {
        $f = json_decode(file_get_contents(__DIR__."/../../elements/config_files/core/framework.config.json"));

        if (!property_exists($f, 'installation')) {
            return (json_encode(array("code" => 500, "results" => "NOK", "fv" => "unknow",
                "msg" => "Property [installation] is undefined in framework.config.json file")));
        }

        if ($f->installation != null) {
            return (json_encode(array("code" => 500, "results" => "NOK", "fv" => "unknow",
                "msg" => "Cannot use iumio installer because you have already one app installed.")));
        }

        $v = $f->edition_version;
        $build = $f->edition_build;
        $e = $f->edition_fullname;
        $st = $f->edition_stage;

        if ($build >= self::$framework_build_accept) {
            $_SESSION['version'] = trim($v);
            return (json_encode(array("code" => 200, "results" => "OK", "fv" => trim($v), "edition" => $e,
                'stage' => $st)));
        } else {
            return (json_encode(array("code" => 500, "results" => "NOK", "fv" => trim($v),
                "msg" => "The version of iumio Framework is incompatible with iumio installer.
                 You must have at least version " . self::$framework_version_accept .
                    " of iumio Framework on your web server.")));
        }
    }
1197456
function hasConflicts( $editLanguage = false )
    {
        $object = $this->contentObject();
        if ( !$editLanguage )
            $editLanguage = $this->initialLanguageCode();

        // Get versions (with published or archived status)
        $versions = $object->versions( true, array( 'conditions' => array( 'status' => array( array( eZContentObjectVersion::STATUS_PUBLISHED, eZContentObjectVersion::STATUS_ARCHIVED ) ),
                                                                           'language_code' => $editLanguage ) ) );

        $conflictVersions = array();
        foreach ( array_keys( $versions ) as $key )
        {
            $version =& $versions[$key];
            if ( $version->attribute( 'modified' ) > $this->attribute( 'created' ) )
            {
                $conflictVersions[] = $version;
            }
        }
        if ( !count( $conflictVersions ) )
        {
            return false;
        }

        return $conflictVersions;
    }
1049206
function matchVersions() {
		var rl = regObjArr.length;
		if (rl > 0) {
			for (var i = 0; i < rl; i++) { // for each registered object element
				var id = regObjArr[i].id;
				var cb = regObjArr[i].callbackFn;
				var cbObj = {success:false, id:id};
				if (ua.pv[0] > 0) {
					var obj = getElementById(id);
					if (obj) {
						if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match!
							setVisibility(id, true);
							if (cb) {
								cbObj.success = true;
								cbObj.ref = getObjectById(id);
								cb(cbObj);
							}
						}
						else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported
							var att = {};
							att.data = regObjArr[i].expressInstall;
							att.width = obj.getAttribute("width") || "0";
							att.height = obj.getAttribute("height") || "0";
							if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); }
							if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); }
							// parse HTML object param element's name-value pairs
							var par = {};
							var p = obj.getElementsByTagName("param");
							var pl = p.length;
							for (var j = 0; j < pl; j++) {
								if (p[j].getAttribute("name").toLowerCase() != "movie") {
									par[p[j].getAttribute("name")] = p[j].getAttribute("value");
								}
							}
							showExpressInstall(att, par, id, cb);
						}
						else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF
							displayAltContent(obj);
							if (cb) { cb(cbObj); }
						}
					}
				}
				else {	// if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content)
					setVisibility(id, true);
					if (cb) {
						var o = getObjectById(id); // test whether there is an HTML object element or not
						if (o && typeof o.SetVariable != UNDEF) { 
							cbObj.success = true;
							cbObj.ref = o;
						}
						cb(cbObj);
					}
				}
			}
		}
	}