Răsfoiți Sursa

#53 - version setting option

Alex Trofimov 12 ani în urmă
părinte
comite
d7f9adf40a

+ 1 - 1
inc/design.inc.php

@@ -100,7 +100,7 @@ function PopupBox($sName, $sTitle, $sContent, $isHiddenByDefault = false)
 
 function getVersionComment()
 {
-    $aVer = explode('.', getParam('sys_version'));
+    $aVer = explode('.', bx_get_ver());
 
     // version output made for debug possibilities.
     // randomizing made for security issues. do not change it...

+ 12 - 1
inc/utils.inc.php

@@ -1040,7 +1040,7 @@ function bx_replace_markers($mixed, $aMarkers)
 
 function bx_site_hash($sSalt = '', $isSkipVersion = false)
 {
-    return md5($sSalt . ($isSkipVersion ? '' : getParam('sys_version')) . BX_DOL_SECRET . BX_DOL_URL_ROOT);
+    return md5($sSalt . ($isSkipVersion ? '' : bx_get_ver()) . BX_DOL_SECRET . BX_DOL_URL_ROOT);
 }
 
 /**
@@ -1065,4 +1065,15 @@ function bx_trigger_error ($sMsg, $iNumLevelsBack = 0)
     trigger_error ($sMsg . $sMsgAdd, E_USER_ERROR);
 }
 
+/**
+ * Get dolphin version
+ */
+function bx_get_ver ()
+{
+    bx_import('BxDolDb');
+    $oDb = BxDolDb::getInstance();
+    $sQuery = $oDb->prepare("SELECT `version` FROM `sys_modules` WHERE `name` = 'system'");
+    return $oDb->fromMemory('getOne', $sQuery);
+}
+
 /** @} */

+ 1 - 1
install/sql/addon.sql

@@ -10,6 +10,6 @@ INSERT INTO `sys_profiles` (`account_id`, `type`, `content_id`, `status`) VALUES
 UPDATE `sys_options` SET `VALUE` = '{admin_email}' WHERE `Name` = 'site_email';
 UPDATE `sys_options` SET `VALUE` = '{site_title}' WHERE `Name` = 'site_title';
 UPDATE `sys_options` SET `VALUE` = '{site_email}' WHERE `Name` = 'site_email_notify';
-UPDATE `sys_options` SET `VALUE` = '{version}' WHERE `Name` = 'sys_version';
 UPDATE `sys_options` SET `VALUE` = '{time}' WHERE `Name` = 'sys_install_time';
 
+UPDATE `sys_modules` SET `version` = '{version}' WHERE `name` = 'system';

+ 1 - 2
install/sql/system.sql

@@ -213,7 +213,6 @@ INSERT INTO `sys_options_categories`(`type_id`, `name`, `caption`, `hidden`, `or
 SET @iCategoryId = LAST_INSERT_ID();
 
 INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
-(@iCategoryId, 'sys_version', '', '8', 'digit', '', '', '', 2),
 (@iCategoryId, 'sys_install_time', '', '0', 'digit', '', '', '', 3),
 
 (@iCategoryId, 'sys_site_logo', '', '0', 'digit', '', '', '', 20),
@@ -728,7 +727,7 @@ CREATE TABLE `sys_modules` (
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
 INSERT INTO `sys_modules` (`type`, `name`, `title`, `vendor`, `version`, `product_url`, `update_url`, `path`, `uri`, `class_prefix`, `db_prefix`, `lang_category`, `dependencies`, `date`, `enabled`) VALUES
-('module', 'system', 'System', 'BoonEx', @sSysVersion, '', '', '', 'system', 'Bx', 'sys_', 'System', '', 0, 1);
+('module', 'system', 'System', 'BoonEx', '8', '', '', '', 'system', 'Bx', 'sys_', 'System', '', 0, 1);
 
 
 CREATE TABLE `sys_modules_file_tracks` (

+ 1 - 6
studio/classes/BxDolStudioDashboard.php

@@ -35,15 +35,10 @@ class BxDolStudioDashboard extends BxTemplStudioPage
                         break;
 
                     $sVersionAvl = $aContent['value'];
-                    $sVersionCur = getParam('sys_version');
+                    $sVersionCur = bx_get_ver();
                     if(version_compare($sVersionCur, $sVersionAvl) == -1)
                         $aResult = array('version' => $sVersionAvl);
                     break;
-                /*
-                case 'action_name':
-                    $aResult = array();
-                    break;
-                */
             }
 
             if(!empty($aResult['message'])) {

+ 1 - 1
studio/classes/BxDolStudioInstaller.php

@@ -177,7 +177,7 @@ class BxDolStudioInstaller extends BxDolInstallerUtils
         if(isset($this->_aConfig['compatible_with']) && is_array($this->_aConfig['compatible_with']))
             foreach($this->_aConfig['compatible_with'] as $iKey => $sVersion) {
                 $sVersion = '/^' . str_replace(array('.', 'x'), array('\.', '[0-9]+'), $sVersion) . '$/is';
-                $bCompatible = $bCompatible || (preg_match($sVersion, getParam('sys_version')) > 0);
+                $bCompatible = $bCompatible || (preg_match($sVersion, bx_get_ver()) > 0);
             }
         if(!$bCompatible)
             return array(

+ 1 - 1
studio/classes/BxDolStudioTemplate.php

@@ -87,7 +87,7 @@ class BxDolStudioTemplate extends BxDolTemplate implements iBxDolSingleton
         $sRet = '';
         switch( $sKey ) {
             case 'version':
-                $sRet = getParam('sys_version');
+                $sRet = bx_get_ver();
                 break;
             case 'page_breadcrumb':
                 $sRet = $this->getPageBreadcrumb();

+ 1 - 1
studio/classes/BxDolStudioToolsAudit.php

@@ -312,7 +312,7 @@ class BxDolStudioToolsAudit extends BxDol
         else
             $sLatestDolphinVer = 'undefined';
 
-        $sDolphinVer = getParam('sys_version');
+        $sDolphinVer = bx_get_ver();
         $aMessage = array('type' => BX_DOL_AUDIT_OK);
         if (!version_compare($sDolphinVer, $sLatestDolphinVer, '>='))
             $aMessage = array('type' => BX_DOL_AUDIT_WARN, 'msg' => _t('_sys_audit_msg_version_is_outdated', $sLatestDolphinVer));

+ 1 - 1
studio/template/scripts/BxBaseStudioDashboard.php

@@ -67,7 +67,7 @@ class BxBaseStudioDashboard extends BxDolStudioDashboard
         $oTemplate->addJsTranslation('_adm_dbd_txt_dolphin_n_available');
         return $oTemplate->parseHtmlByName('dbd_versions.html', array(
             'domain' => getParam('site_title'),
-            'version' => getParam('sys_version'),
+            'version' => bx_get_ver(),
             'installed' => bx_time_js(getParam('sys_install_time')),
         ));
     }