當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Utils_System::isVersionFormatValid方法代碼示例

本文整理匯總了PHP中CRM_Utils_System::isVersionFormatValid方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Utils_System::isVersionFormatValid方法的具體用法?PHP CRM_Utils_System::isVersionFormatValid怎麽用?PHP CRM_Utils_System::isVersionFormatValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Utils_System的用法示例。


在下文中一共展示了CRM_Utils_System::isVersionFormatValid方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: version

 /**
  * Return the running civicrm version.
  *
  * @return string
  *   civicrm version
  */
 public static function version()
 {
     static $version;
     if (!$version) {
         $verFile = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', '..', 'civicrm-version.php'));
         if (file_exists($verFile)) {
             require_once $verFile;
             if (function_exists('civicrmVersion')) {
                 $info = civicrmVersion();
                 $version = $info['version'];
             }
         } else {
             // svn installs don't have version.txt by default. In that case version.xml should help -
             $verFile = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', '..', 'xml', 'version.xml'));
             if (file_exists($verFile)) {
                 $str = file_get_contents($verFile);
                 $xmlObj = simplexml_load_string($str);
                 $version = (string) $xmlObj->version_no;
             }
         }
         // pattern check
         if (!CRM_Utils_System::isVersionFormatValid($version)) {
             CRM_Core_Error::fatal('Unknown codebase version.');
         }
     }
     return $version;
 }
開發者ID:rollox,項目名稱:civicrm-core,代碼行數:33,代碼來源:System.php

示例2: run

 function run()
 {
     // lets get around the time limit issue if possible for upgrades
     if (!ini_get('safe_mode')) {
         set_time_limit(0);
     }
     $latestVer = CRM_Utils_System::version();
     $currentVer = CRM_Core_BAO_Domain::version();
     if (!$currentVer) {
         CRM_Core_Error::fatal(ts('Version information missing in civicrm database.'));
     } else {
         if (stripos($currentVer, 'upgrade')) {
             CRM_Core_Error::fatal(ts('Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the upgrade process again.'));
         }
     }
     if (!$latestVer) {
         CRM_Core_Error::fatal(ts('Version information missing in civicrm codebase.'));
     }
     // hack to make past ver compatible /w new incremental upgrade process
     $convertVer = array('2.1' => '2.1.0', '2.2' => '2.2.alpha1', '2.2.alph' => '2.2.alpha3', '3.1.0' => '3.1.1');
     if (isset($convertVer[$currentVer])) {
         $currentVer = $convertVer[$currentVer];
     }
     // since version is suppose to be in valid format at this point, especially after conversion ($convertVer),
     // lets do a pattern check -
     if (!CRM_Utils_System::isVersionFormatValid($currentVer)) {
         CRM_Core_Error::fatal(ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.'));
     }
     // This could be removed in later rev
     if ($currentVer == '2.1.6') {
         $config =& CRM_Core_Config::singleton();
         // also cleanup the templates_c directory
         $config->cleanup(1, false);
         if ($config->userFramework !== 'Standalone') {
             // clean the session
             $session =& CRM_Core_Session::singleton();
             $session->reset(2);
         }
     }
     // end of hack
     CRM_Utils_System::setTitle(ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
     $upgrade =& new CRM_Upgrade_Form();
     $template =& CRM_Core_Smarty::singleton();
     $template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
     $template->assign('menuRebuildURL', CRM_Utils_System::url('civicrm/menu/rebuild', 'reset=1'));
     $template->assign('cancelURL', CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
     if (version_compare($currentVer, $latestVer) > 0) {
         // DB version number is higher than codebase being upgraded to. This is unexpected condition-fatal error.
         $dbToolsLink = CRM_Utils_System::docURL2("Database Troubleshooting Tools", true);
         $error = ts('Your database is marked with an unexpected version number: %1. The automated upgrade to version %2 can not be run - and the %2 codebase may not be compatible with your database state. You will need to determine the correct version corresponding to your current database state. The database tools utility at %3 may be helpful. You may want to revert to the codebase you were using prior to beginning this upgrade until you resolve this problem.', array(1 => $currentVer, 2 => $latestVer, 3 => $dbToolsLink));
         CRM_Core_Error::fatal($error);
     } else {
         if (version_compare($currentVer, $latestVer) == 0) {
             $message = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $latestVer));
             $template->assign('upgraded', true);
         } else {
             $message = ts('CiviCRM upgrade was successful.');
             $template->assign('currentVersion', $currentVer);
             $template->assign('newVersion', $latestVer);
             $template->assign('upgradeTitle', ts('Upgrade CiviCRM from v %1 To v %2', array(1 => $currentVer, 2 => $latestVer)));
             $template->assign('upgraded', false);
             if (CRM_Utils_Array::value('upgrade', $_POST)) {
                 $revisions = $upgrade->getRevisionSequence();
                 foreach ($revisions as $rev) {
                     // proceed only if $currentVer < $rev
                     if (version_compare($currentVer, $rev) < 0) {
                         // as soon as we start doing anything we append ".upgrade" to version.
                         // this also helps detect any partial upgrade issues
                         $upgrade->setVersion($rev . '.upgrade');
                         $phpFunctionName = 'upgrade_' . str_replace('.', '_', $rev);
                         if (is_callable(array($this, $phpFunctionName))) {
                             eval("\$this->{$phpFunctionName}('{$rev}');");
                         } else {
                             $upgrade->processSQL($rev);
                         }
                         // after an successful intermediate upgrade, set the complete version
                         $upgrade->setVersion($rev);
                     }
                 }
                 $upgrade->setVersion($latestVer);
                 $template->assign('upgraded', true);
                 // also cleanup the templates_c directory
                 $config =& CRM_Core_Config::singleton();
                 $config->cleanup(1, false);
                 // clear db caching
                 $config->clearDBCache();
                 // clean the session. Note: In case of standalone this makes the user logout.
                 // So skip this step for standalone.
                 if ($config->userFramework !== 'Standalone') {
                     $session =& CRM_Core_Session::singleton();
                     $session->reset(2);
                 }
             }
         }
     }
     $template->assign('message', $message);
     $content = $template->fetch('CRM/common/success.tpl');
     echo CRM_Utils_System::theme('page', $content, true, $this->_print, false, true);
 }
開發者ID:bhirsch,項目名稱:voipdev,代碼行數:99,代碼來源:Upgrade.php

示例3: isDBVersionValid

 static function isDBVersionValid(&$errorMessage)
 {
     require_once 'CRM/Core/BAO/Domain.php';
     $dbVersion = CRM_Core_BAO_Domain::version();
     if (!$dbVersion) {
         // if db.ver missing
         $errorMessage = ts('Version information found to be missing in database. You will need to determine the correct version corresponding to your current database state.');
         return false;
     } else {
         if (!CRM_Utils_System::isVersionFormatValid($dbVersion)) {
             $errorMessage = ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.');
             return false;
         } else {
             if (stripos($dbVersion, 'upgrade')) {
                 // if db.ver indicates a partially upgraded db
                 $upgradeUrl = CRM_Utils_System::url("civicrm/upgrade", "reset=1");
                 $errorMessage = ts('Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the <a href=\'%1\'>upgrade process</a> again.', array(1 => $upgradeUrl));
                 return false;
             } else {
                 $codeVersion = CRM_Utils_System::version();
                 // if db.ver < code.ver, time to upgrade
                 if (version_compare($dbVersion, $codeVersion) < 0) {
                     $upgradeUrl = CRM_Utils_System::url("civicrm/upgrade", "reset=1");
                     $errorMessage = ts('New codebase version detected. You might want to visit <a href=\'%1\'>upgrade screen</a> to upgrade the database.', array(1 => $upgradeUrl));
                     return false;
                 }
                 // if db.ver > code.ver, sth really wrong
                 if (version_compare($dbVersion, $codeVersion) > 0) {
                     $errorMessage = ts('Your database is marked with an unexpected version number: %1. The v%2 codebase may not be compatible with your database state. You will need to determine the correct version corresponding to your current database state. You may want to revert to the codebase you were using until you resolve this problem.', array(1 => $dbVersion, 2 => $codeVersion));
                     $errorMessage .= "<p>" . ts('OR if this is an svn install, you might want to fix version.txt file.') . "</p>";
                     return false;
                 }
             }
         }
     }
     // FIXME: there should be another check to make sure version is in valid format - X.Y.alpha_num
     return true;
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:38,代碼來源:System.php

示例4: checkDbVersion

 /**
  * Checks if CiviCRM database version is up-to-date
  * @return array
  */
 public function checkDbVersion()
 {
     $messages = array();
     $dbVersion = CRM_Core_BAO_Domain::version();
     $upgradeUrl = CRM_Utils_System::url("civicrm/upgrade", "reset=1");
     if (!$dbVersion) {
         // if db.ver missing
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Version information found to be missing in database. You will need to determine the correct version corresponding to your current database state.'), ts('Database Version Missing'), \Psr\Log\LogLevel::ERROR, 'fa-database');
     } elseif (!CRM_Utils_System::isVersionFormatValid($dbVersion)) {
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.'), ts('Database Version Invalid'), \Psr\Log\LogLevel::ERROR, 'fa-database');
     } elseif (stripos($dbVersion, 'upgrade')) {
         // if db.ver indicates a partially upgraded db
         $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Database check failed - the database looks to have been partially upgraded. You must reload the database with the backup and try the <a href=\'%1\'>upgrade process</a> again.', array(1 => $upgradeUrl)), ts('Database Partially Upgraded'), \Psr\Log\LogLevel::ALERT, 'fa-database');
     } else {
         $codeVersion = CRM_Utils_System::version();
         // if db.ver < code.ver, time to upgrade
         if (version_compare($dbVersion, $codeVersion) < 0) {
             $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('New codebase version detected. You must visit <a href=\'%1\'>upgrade screen</a> to upgrade the database.', array(1 => $upgradeUrl)), ts('Database Upgrade Required'), \Psr\Log\LogLevel::ALERT, 'fa-database');
         }
         // if db.ver > code.ver, sth really wrong
         if (version_compare($dbVersion, $codeVersion) > 0) {
             $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('Your database is marked with an unexpected version number: %1. The v%2 codebase may not be compatible with your database state.
         You will need to determine the correct version corresponding to your current database state. You may want to revert to the codebase
         you were using until you resolve this problem.<br/>OR if this is a manual install from git, you might want to fix civicrm-version.php file.', array(1 => $dbVersion, 2 => $codeVersion)), ts('Database In Unexpected Version'), \Psr\Log\LogLevel::ERROR, 'fa-database');
         }
     }
     return $messages;
 }
開發者ID:nyimbi,項目名稱:civicrm-core,代碼行數:32,代碼來源:Env.php

示例5: run

 function run()
 {
     // lets get around the time limit issue if possible for upgrades
     if (!ini_get('safe_mode')) {
         set_time_limit(0);
     }
     $latestVer = CRM_Utils_System::version();
     $currentVer = CRM_Core_BAO_Domain::version();
     if (!$currentVer) {
         CRM_Core_Error::fatal(ts('Version information missing in civicrm database.'));
     } else {
         if (stripos($currentVer, 'upgrade')) {
             CRM_Core_Error::fatal(ts('Database check failed - the database looks to have been partially upgraded. You may want to reload the database with the backup and try the upgrade process again.'));
         }
     }
     if (!$latestVer) {
         CRM_Core_Error::fatal(ts('Version information missing in civicrm codebase.'));
     }
     // hack to make past ver compatible /w new incremental upgrade process
     $convertVer = array('2.1' => '2.1.0', '2.2' => '2.2.alpha1', '2.2.alph' => '2.2.alpha3', '3.1.0' => '3.1.1');
     if (isset($convertVer[$currentVer])) {
         $currentVer = $convertVer[$currentVer];
     }
     // since version is suppose to be in valid format at this point, especially after conversion ($convertVer),
     // lets do a pattern check -
     if (!CRM_Utils_System::isVersionFormatValid($currentVer)) {
         CRM_Core_Error::fatal(ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.'));
     }
     // This could be removed in later rev
     if ($currentVer == '2.1.6') {
         $config = CRM_Core_Config::singleton();
         // also cleanup the templates_c directory
         $config->cleanup(1, false);
         if ($config->userFramework !== 'Standalone') {
             // clean the session
             $session = CRM_Core_Session::singleton();
             $session->reset(2);
         }
     }
     // end of hack
     CRM_Utils_System::setTitle(ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
     $upgrade = new CRM_Upgrade_Form();
     $template = CRM_Core_Smarty::singleton();
     $template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $latestVer)));
     $template->assign('menuRebuildURL', CRM_Utils_System::url('civicrm/menu/rebuild', 'reset=1'));
     $template->assign('cancelURL', CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
     if (version_compare($currentVer, $latestVer) > 0) {
         // DB version number is higher than codebase being upgraded to. This is unexpected condition-fatal error.
         $dbToolsLink = CRM_Utils_System::docURL2("Database Troubleshooting Tools", true);
         $error = ts('Your database is marked with an unexpected version number: %1. The automated upgrade to version %2 can not be run - and the %2 codebase may not be compatible with your database state. You will need to determine the correct version corresponding to your current database state. The database tools utility at %3 may be helpful. You may want to revert to the codebase you were using prior to beginning this upgrade until you resolve this problem.', array(1 => $currentVer, 2 => $latestVer, 3 => $dbToolsLink));
         CRM_Core_Error::fatal($error);
     } else {
         if (version_compare($currentVer, $latestVer) == 0) {
             $message = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $latestVer));
             $template->assign('upgraded', true);
         } else {
             $message = ts('CiviCRM upgrade was successful.');
             if ($latestVer == '3.2.alpha1') {
                 $message .= '<br />' . ts("We have reset the COUNTED flag to false for the event participant status 'Pending from incomplete transaction'. This change ensures that people who have a problem during registration can try again.");
             } else {
                 if ($latestVer == '3.2.beta3' && version_compare($currentVer, '3.1.alpha1') >= 0) {
                     require_once 'CRM/Contact/BAO/ContactType.php';
                     $subTypes = CRM_Contact_BAO_ContactType::subTypes();
                     if (is_array($subTypes) && !empty($subTypes)) {
                         $config = CRM_Core_Config::singleton();
                         $subTypeTemplates = array();
                         if (isset($config->customTemplateDir)) {
                             foreach ($subTypes as $key => $subTypeName) {
                                 $customContactSubTypeEdit = $config->customTemplateDir . "CRM/Contact/Form/Edit/" . $subTypeName . ".tpl";
                                 $customContactSubTypeView = $config->customTemplateDir . "CRM/Contact/Page/View/" . $subTypeName . ".tpl";
                                 if (file_exists($customContactSubTypeEdit) || file_exists($customContactSubTypeView)) {
                                     $subTypeTemplates[$subTypeName] = $subTypeName;
                                 }
                             }
                         }
                         foreach ($subTypes as $key => $subTypeName) {
                             $customContactSubTypeEdit = $config->templateDir . "CRM/Contact/Form/Edit/" . $subTypeName . ".tpl";
                             $customContactSubTypeView = $config->templateDir . "CRM/Contact/Page/View/" . $subTypeName . ".tpl";
                             if (file_exists($customContactSubTypeEdit) || file_exists($customContactSubTypeView)) {
                                 $subTypeTemplates[$subTypeName] = $subTypeName;
                             }
                         }
                         if (!empty($subTypeTemplates)) {
                             $subTypeTemplates = implode(',', $subTypeTemplates);
                             $message .= '<br />' . ts('You are using custom template for contact subtypes: %1.', array(1 => $subTypeTemplates)) . '<br />' . ts('You need to move these subtype templates to the SubType directory in %1 and %2 respectively.', array(1 => 'CRM/Contact/Form/Edit', 2 => 'CRM/Contact/Page/View'));
                         }
                     }
                 } else {
                     if ($latestVer == '3.2.beta4') {
                         $statuses = array('New', 'Current', 'Grace', 'Expired', 'Pending', 'Cancelled', 'Deceased');
                         $sql = "\nSELECT  count( id ) as statusCount \n  FROM  civicrm_membership_status \n WHERE  name IN ( '" . implode("' , '", $statuses) . "' ) ";
                         $count = CRM_Core_DAO::singleValueQuery($sql);
                         if ($count < count($statuses)) {
                             $message .= '<br />' . ts("One or more Membership Status Rules was disabled during the upgrade because it did not match a recognized status name. if custom membership status rules were added to this site - review the disabled statuses and re-enable any that are still needed (Administer > CiviMember > Membership Status Rules).");
                         }
                     }
                 }
             }
             $template->assign('currentVersion', $currentVer);
             $template->assign('newVersion', $latestVer);
//.........這裏部分代碼省略.........
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:101,代碼來源:Upgrade.php

示例6: checkCurrentVersion

 /**
  * Determine if $currentver already matches $latestVer
  *
  * @param $currentVer
  * @param $latestVer
  *
  * @return mixed, a string error message or boolean 'false' if OK
  */
 public function checkCurrentVersion($currentVer, $latestVer)
 {
     $error = FALSE;
     // since version is suppose to be in valid format at this point, especially after conversion ($convertVer),
     // lets do a pattern check -
     if (!CRM_Utils_System::isVersionFormatValid($currentVer)) {
         $error = ts('Database is marked with invalid version format. You may want to investigate this before you proceed further.');
     } elseif (version_compare($currentVer, $latestVer) != 0) {
         $error = ts('Your database is not configured for version %1', array(1 => $latestVer));
     }
     return $error;
 }
開發者ID:nganivet,項目名稱:civicrm-core,代碼行數:20,代碼來源:Form.php


注:本文中的CRM_Utils_System::isVersionFormatValid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。