X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FVersionCheck.php;h=4f69360970738bd46a53ed449bdf76e9ff23dedb;hb=9f7b401dfb7fa7cd52ecd4d8bcab3d7b1422ebd2;hp=c63bad04f37d733f3fb51ed434d54584f1421004;hpb=347185d7709adf00659d042b2fa98b93f03f2672;p=civicrm-core.git diff --git a/CRM/Utils/VersionCheck.php b/CRM/Utils/VersionCheck.php index c63bad04f3..4f69360970 100644 --- a/CRM/Utils/VersionCheck.php +++ b/CRM/Utils/VersionCheck.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -33,7 +33,7 @@ * */ class CRM_Utils_VersionCheck { - CONST + const PINGBACK_URL = 'http://latest.civicrm.org/stable.php?format=json', // timeout for when the connection or the server is slow CHECK_TIMEOUT = 5, @@ -49,7 +49,6 @@ class CRM_Utils_VersionCheck { * singleton pattern and cache the instance in this variable * * @var object - * @static */ static private $_singleton = NULL; @@ -87,7 +86,7 @@ class CRM_Utils_VersionCheck { * @var array */ protected $stats = array(); - + /** * Path to cache file * @@ -96,11 +95,9 @@ class CRM_Utils_VersionCheck { protected $cacheFile; /** - * Class constructor - * - * @access private + * Class constructor. */ - function __construct() { + public function __construct() { global $civicrm_root; $config = CRM_Core_Config::singleton(); @@ -108,7 +105,7 @@ class CRM_Utils_VersionCheck { $this->cacheFile = $config->uploadDir . self::CACHEFILE_NAME; if (file_exists($localFile)) { - require_once ($localFile); + require_once $localFile; } if (function_exists('civicrmVersion')) { $info = civicrmVersion(); @@ -133,14 +130,14 @@ class CRM_Utils_VersionCheck { } /** - * Static instance provider + * Static instance provider. * * Method providing static instance of CRM_Utils_VersionCheck, * as in Singleton pattern * * @return CRM_Utils_VersionCheck */ - static function &singleton() { + public static function &singleton() { if (!isset(self::$_singleton)) { self::$_singleton = new CRM_Utils_VersionCheck(); } @@ -148,7 +145,7 @@ class CRM_Utils_VersionCheck { } /** - * Finds the release info for a minor version + * Finds the release info for a minor version. * @param string $version * @return array|null */ @@ -185,7 +182,8 @@ class CRM_Utils_VersionCheck { foreach ($this->versionInfo as $majorVersion) { foreach ($majorVersion['releases'] as $release) { if (!empty($release['security']) && $release['date'] > $localVersionDate - && version_compare($this->localVersion, $release['version']) < 0) { + && version_compare($this->localVersion, $release['version']) < 0 + ) { if (!$this->ignoreDate || $this->ignoreDate < $release['date']) { return TRUE; } @@ -198,7 +196,7 @@ class CRM_Utils_VersionCheck { * Get the latest version number if it's newer than the local one * * @return string|null - * Returns version number of the latest release if it is greater than the local version + * Returns version number of the latest release if it is greater than the local version */ public function isNewerVersionAvailable() { $newerVersion = NULL; @@ -240,13 +238,13 @@ class CRM_Utils_VersionCheck { } /** - * Alert the site admin of new versions of CiviCRM + * Alert the site admin of new versions of CiviCRM. * Show the message once a day */ public function versionAlert() { $versionAlertSetting = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'versionAlert', NULL, 1); $securityAlertSetting = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'securityUpdateAlert', NULL, 3); - $settingsUrl = CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1', FALSE, NULL, FALSE, FALSE, TRUE); + $settingsUrl = CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1', FALSE, NULL, FALSE, FALSE, TRUE); if (CRM_Core_Permission::check('administer CiviCRM') && $securityAlertSetting > 1 && $this->isSecurityUpdateAvailable()) { $session = CRM_Core_Session::singleton(); if ($session->timer('version_alert', 24 * 60 * 60)) { @@ -257,7 +255,8 @@ class CRM_Utils_VersionCheck {
  • ' . ts('Suppress this message') . '
  • '; $session->setStatus($msg, ts('Security Alert'), 'alert'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Admin/Form/Setting/versionCheckOptions.js'); + CRM_Core_Resources::singleton() + ->addScriptFile('civicrm', 'templates/CRM/Admin/Form/Setting/versionCheckOptions.js'); } } elseif (CRM_Core_Permission::check('administer CiviCRM') && $versionAlertSetting > 1) { @@ -271,14 +270,15 @@ class CRM_Utils_VersionCheck {
  • ' . ts('Suppress this message') . '
  • '; $session->setStatus($msg, ts('Update Available'), 'info'); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Admin/Form/Setting/versionCheckOptions.js'); + CRM_Core_Resources::singleton() + ->addScriptFile('civicrm', 'templates/CRM/Admin/Form/Setting/versionCheckOptions.js'); } } } } /** - * Collect info about the site to be sent as pingback data + * Collect info about the site to be sent as pingback data. */ private function getSiteStats() { $config = CRM_Core_Config::singleton(); @@ -306,10 +306,10 @@ class CRM_Utils_VersionCheck { } /** - * Get active payment processor types + * Get active payment processor types. */ private function getPayProcStats() { - $dao = new CRM_Financial_DAO_PaymentProcessor; + $dao = new CRM_Financial_DAO_PaymentProcessor(); $dao->is_active = 1; $dao->find(); $ppTypes = array(); @@ -325,7 +325,7 @@ class CRM_Utils_VersionCheck { } /** - * Fetch counts from entity tables + * Fetch counts from entity tables. * Add info to the 'entities' array */ private function getEntityStats() { @@ -353,7 +353,7 @@ class CRM_Utils_VersionCheck { 'CRM_Pledge_DAO_PledgeBlock' => NULL, ); foreach ($tables as $daoName => $where) { - $dao = new $daoName; + $dao = new $daoName(); if ($where) { $dao->whereAdd($where); } @@ -435,7 +435,7 @@ class CRM_Utils_VersionCheck { } /** - * Save version info to file + * Save version info to file. * @param string $contents */ private function writeCacheFile($contents) {