Index: branches/5.1.x/core/install/steps_db.xml
===================================================================
diff -u -r13392 -r13780
--- branches/5.1.x/core/install/steps_db.xml (.../steps_db.xml) (revision 13392)
+++ branches/5.1.x/core/install/steps_db.xml (.../steps_db.xml) (revision 13780)
@@ -149,6 +149,9 @@
Select modules from the list, you need to update to the last downloaded version of In-Portal
]]>
+
+ Review Administrative Console skin upgrade log.]]>
+
In-Portal needs to connect to your Database Server. Please provide the database server type*,
host name (normally "localhost"), Database user name, and database Password. These fields are required
Index: branches/5.1.x/core/install/install_toolkit.php
===================================================================
diff -u -r13750 -r13780
--- branches/5.1.x/core/install/install_toolkit.php (.../install_toolkit.php) (revision 13750)
+++ branches/5.1.x/core/install/install_toolkit.php (.../install_toolkit.php) (revision 13780)
@@ -1,6 +1,6 @@
getSystemConfig('Database', 'TablePrefix');
@@ -818,6 +818,8 @@
$this->Application->HandleEvent($event, 'adm:OnResetConfigsCache');
$this->Application->HandleEvent($event, 'c:OnResetCMSMenuCache');
+ $this->Conn->Query('DELETE FROM ' . TABLE_PREFIX . 'CachedUrls');
+
if ($refresh_permissions) {
if ($this->Application->ConfigValue('QuickCategoryPermissionRebuild')) {
// refresh permission without progress bar
@@ -906,4 +908,129 @@
$permissions = fileperms($file);
return $permissions & 0x0010 || $permissions & 0x0002;
}
+
+ /**
+ * Upgrades primary skin to the latest version
+ *
+ * @param Array $module_info
+ * @return string
+ */
+ function upgradeSkin($module_info)
+ {
+ $upgrades_file = sprintf(UPGRADES_FILE, $module_info['Path'], 'css');
+ $data = file_get_contents($upgrades_file);
+
+ // get all versions with their positions in file
+ $versions = Array ();
+ preg_match_all('/(' . VERSION_MARK . ')/s', $data, $matches, PREG_SET_ORDER + PREG_OFFSET_CAPTURE);
+ $from_version_int = $this->ConvertModuleVersion($module_info['FromVersion']);
+
+ foreach ($matches as $index => $match) {
+ $version_int = $this->ConvertModuleVersion($match[2][0]);
+
+ if ($version_int < $from_version_int) {
+ // only process versions, that were released after currently used version
+ continue;
+ }
+
+ $start_pos = $match[0][1] + strlen($match[0][0]);
+ $end_pos = array_key_exists($index + 1, $matches) ? $matches[$index + 1][0][1] : mb_strlen($data);
+ $patch_data = str_replace("\r\n", "\n", substr($data, $start_pos, $end_pos - $start_pos));
+
+ $versions[] = Array (
+ 'Version' => $match[2][0],
+ // fixes trimmed leading spaces by modern text editor
+ 'Data' => ltrim( str_replace("\n\n", "\n \n", $patch_data) ),
+ );
+ }
+
+ if (!$versions) {
+ // not skin changes -> quit
+ return ;
+ }
+
+ $primary_skin =& $this->Application->recallObject('skin.primary', null, Array ('skip_autoload' => true));
+ /* @var $primary_skin kDBItem */
+
+ $primary_skin->Load(1, 'IsPrimary');
+
+ if (!$primary_skin->isLoaded()) {
+ // we always got primary skin, but just in case
+ return ;
+ }
+
+ $temp_handler =& $this->Application->recallObject('skin_TempHandler', 'kTempTablesHandler');
+ /* @var $temp_handler kTempTablesHandler */
+
+ // clone current skin
+ $cloned_ids = $temp_handler->CloneItems('skin', '', Array ($primary_skin->GetID()));
+
+ if (!$cloned_ids) {
+ // can't clone
+ return ;
+ }
+
+ $skin =& $this->Application->recallObject('skin.tmp', null, Array ('skip_autoload' => true));
+ /* @var $skin kDBItem */
+
+ $skin->Load( $cloned_ids[0] );
+
+ // save css to temp file (for patching)
+ $skin_file = tempnam('/tmp', 'skin_css_');
+ $fp = fopen($skin_file, 'w');
+ fwrite($fp, str_replace("\r\n", "\n", $skin->GetDBField('CSS')));
+ fclose($fp);
+
+ $output = Array ();
+ $patch_file = tempnam('/tmp', 'skin_patch_');
+
+ foreach ($versions as $version_info) {
+ // for each left version get it's patch and apply to temp file
+ $fp = fopen($patch_file, 'w');
+ fwrite($fp, $version_info['Data']);
+ fclose($fp);
+
+ $output[ $version_info['Version'] ] = shell_exec('patch ' . $skin_file . ' ' . $patch_file . ' 2>&1') . "\n";
+ }
+
+ // place temp file content into cloned skin
+ $skin->SetDBField('Name', 'Upgraded to ' . $module_info['ToVersion']);
+ $skin->SetDBField('CSS', file_get_contents($skin_file));
+ $skin->Update();
+
+ unlink($skin_file);
+ unlink($patch_file);
+
+ $has_errors = false;
+
+ foreach ($output as $version => $version_output) {
+ $version_errors = trim( preg_replace("/(^|\n)(patching file .*?|Hunk #.*?\.)(\n|$)/m", '', $version_output) );
+
+ if ($version_errors) {
+ $has_errors = true;
+ $output[$version] = trim( preg_replace("/(^|\n)(patching file .*?)(\n|$)/m", '', $output[$version]) );
+ }
+ else {
+ unset($output[$version]);
+ }
+ }
+
+ if (!$has_errors) {
+ // copy patched css back to primary skin
+ $primary_skin->SetDBField('CSS', $skin->GetDBField('CSS'));
+ $primary_skin->Update();
+
+ // delete temporary skin record
+ $temp_handler->DeleteItems('skin', '', Array ($skin->GetID()));
+
+ return true;
+ }
+
+ // put clean skin from new version
+ $skin->SetDBField('CSS', file_get_contents(FULL_PATH . '/core/admin_templates/incs/style_template.css'));
+ $skin->Update();
+
+ // return output in case of errors
+ return $output;
+ }
}
\ No newline at end of file
Index: branches/5.1.x/core/install/upgrades.php
===================================================================
diff -u -r13635 -r13780
--- branches/5.1.x/core/install/upgrades.php (.../upgrades.php) (revision 13635)
+++ branches/5.1.x/core/install/upgrades.php (.../upgrades.php) (revision 13780)
@@ -1,6 +1,6 @@
_toolkit =& $instance;
- }
-
- /**
* Changes table structure, where multilingual fields of TEXT type are present
*
* @param string $mode when called mode {before, after)
@@ -228,8 +211,8 @@
{
// 1. find In-Portal old Conn->GetCol($sql));
// 2. replace In-Portal old $new_tag) {
$sql = 'UPDATE '.TABLE_PREFIX.'EmailMessage
- SET Template = REPLACE(Template, '.$this->Conn->qstr($old_tag).', '.$this->Conn->qstr($new_tag).')
- WHERE EventId IN ('.$event_ids.')';
+ SET Template = REPLACE(Template, '.$this->Conn->qstr($old_tag).', '.$this->Conn->qstr($new_tag).')
+ WHERE EventId IN ('.$event_ids.')';
$this->Conn->Query($sql);
}
if ($mode == 'after') {
$this->_insertInPortalData();
- $this->_removeDuplicatePhrases();
$this->_moveDatabaseFolders();
// in case, when In-Portal module is enabled -> turn AdvancedUserManagement on too
@@ -264,6 +246,10 @@
$this->Conn->Query($sql);
}
}
+
+ if ($mode == 'languagepack') {
+ $this->_removeDuplicatePhrases();
+ }
}
function _insertInPortalData()
@@ -771,7 +757,7 @@
* @param string $module_name
* @return int
*/
- function _getRootCategory($module_name)
+ function _getRootCategory($module_name, $module_prefix)
{
// don't cache anything here (like in static variables), because database value is changed on the fly !!!
$sql = 'SELECT RootCat
@@ -782,6 +768,7 @@
// put to cache too, because CategoriesEventHandler::_prepareAutoPage uses kApplication::findModule
$this->Application->ModuleInfo[$module_name]['Name'] = $module_name;
$this->Application->ModuleInfo[$module_name]['RootCat'] = $root_category;
+ $this->Application->ModuleInfo[$module_name]['Var'] = $module_prefix;
return $root_category;
}
@@ -792,7 +779,7 @@
*/
function _restructureCatalog()
{
- $root_category = $this->_getRootCategory('Core');
+ $root_category = $this->_getRootCategory('Core', 'adm');
$sql = 'SELECT CategoryId
FROM ' . TABLE_PREFIX . 'Category
@@ -863,6 +850,13 @@
// option: from -> to
'HeadBgColor' => Array ('#1961B8', '#007BF4'),
'HeadBarColor' => Array ('#FFFFFF', '#000000'),
+
+ 'HeadColor' => Array ('#CCFF00', '#FFFFFF'),
+ 'TreeColor' => Array ('#006F99', '#000000'),
+ 'TreeHoverColor' => Array ('', '#009FF0'),
+ 'TreeHighHoverColor' => Array ('', '#FFFFFF'),
+ 'TreeHighBgColor' => Array ('#4A92CE', '#4A92CE'),
+ 'TreeBgColor' => Array ('#FFFFFF', '#DCECF6'),
);
$can_change = true;
@@ -909,7 +903,7 @@
function _createProjCMSTables()
{
// 0. make sure, that Content category exists
- $root_category = $this->_getRootCategory('Proj-CMS');
+ $root_category = $this->_getRootCategory('Proj-CMS', 'st');
if ($root_category) {
// proj-cms module found -> remove it
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Modules
@@ -925,7 +919,7 @@
WHERE (Status = 4) AND (CategoryId <> ' . $root_category . ')';
$this->Conn->Query($sql);
} else {
- $root_category = $this->_getRootCategory('In-Edit');
+ $root_category = $this->_getRootCategory('In-Edit', 'cms');
if ($root_category) {
// in-edit module found -> remove it
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Modules
@@ -1414,13 +1408,6 @@
function Upgrade_5_1_0_B1($mode)
{
if ($mode == 'before') {
- // create multilingual fields for phrases and email events
- $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
- /* @var $ml_helper kMultiLanguageHelper */
-
- $ml_helper->createFields('phrases');
- $ml_helper->createFields('emailevents');
-
// migrate email events
$table_structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'Events', 'Field');
@@ -1431,6 +1418,31 @@
$this->Conn->Query($sql);
}
+ // alter here, because kMultiLanguageHelper::createFields
+ // method, called after will expect that to be in database
+ $sql = 'ALTER TABLE ' . TABLE_PREFIX . 'Events
+ ADD AllowChangingSender TINYINT NOT NULL DEFAULT "0" AFTER MessageType ,
+ ADD CustomSender TINYINT NOT NULL DEFAULT "0" AFTER AllowChangingSender ,
+ ADD SenderName VARCHAR(255) NOT NULL DEFAULT "" AFTER CustomSender ,
+ ADD SenderAddressType TINYINT NOT NULL DEFAULT "0" AFTER SenderName ,
+ ADD SenderAddress VARCHAR(255) NOT NULL DEFAULT "" AFTER SenderAddressType ,
+ ADD AllowChangingRecipient TINYINT NOT NULL DEFAULT "0" AFTER SenderAddress ,
+ ADD CustomRecipient TINYINT NOT NULL DEFAULT "0" AFTER AllowChangingRecipient ,
+ ADD Recipients TEXT AFTER CustomRecipient,
+ ADD INDEX (AllowChangingSender),
+ ADD INDEX (CustomSender),
+ ADD INDEX (SenderAddressType),
+ ADD INDEX (AllowChangingRecipient),
+ ADD INDEX (CustomRecipient)';
+ $this->Conn->Query($sql);
+
+ // create multilingual fields for phrases and email events
+ $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
+ /* @var $ml_helper kMultiLanguageHelper */
+
+ $ml_helper->createFields('phrases');
+ $ml_helper->createFields('emailevents');
+
if ($this->Conn->TableFound(TABLE_PREFIX . 'EmailMessage')) {
$email_message_helper =& $this->Application->recallObject('EmailMessageHelper');
/* @var $email_message_helper EmailMessageHelper */
@@ -1526,6 +1538,7 @@
if ($mode == 'after') {
$this->_transformEmailRecipients();
+ $this->_fixSkinColors();
}
}
Index: branches/5.1.x/core/install/step_templates/skin_upgrade.tpl
===================================================================
diff -u
--- branches/5.1.x/core/install/step_templates/skin_upgrade.tpl (revision 0)
+++ branches/5.1.x/core/install/step_templates/skin_upgrade.tpl (revision 13780)
@@ -0,0 +1,24 @@
+
+
+ Automatic upgrade of Administrative Console Skin failed. You can verify patching log errors below.
+
+
+
+
+
+
+
+ You must manually merge skin, created during upgrade with your current
+ primary skin to ensure, that Administrative Console interface isn't broken.
+
+
+
+
Index: branches/5.1.x/core/kernel/application.php
===================================================================
diff -u -r13635 -r13780
--- branches/5.1.x/core/kernel/application.php (.../application.php) (revision 13635)
+++ branches/5.1.x/core/kernel/application.php (.../application.php) (revision 13780)
@@ -1,6 +1,6 @@
setCache($serial_name, (int)$this->getCache($serial_name) + 1);
}
- // delete cached mod-rewrite urls related to given prefix and id
- $delete_clause = isset($id) ? $prefix . ':' . $id : $prefix;
+ if (!defined('IS_INSTALL') || !IS_INSTALL) {
+ // delete cached mod-rewrite urls related to given prefix and id
+ $delete_clause = isset($id) ? $prefix . ':' . $id : $prefix;
- $sql = 'DELETE FROM ' . TABLE_PREFIX . 'CachedUrls
- WHERE Prefixes LIKE ' . $this->Conn->qstr('%|' . $delete_clause . '|%');
- $this->Conn->Query($sql);
+ $sql = 'DELETE FROM ' . TABLE_PREFIX . 'CachedUrls
+ WHERE Prefixes LIKE ' . $this->Conn->qstr('%|' . $delete_clause . '|%');
+ $this->Conn->Query($sql);
+ }
}
return $serial_name;
Index: branches/5.1.x/core/install/install_schema.sql
===================================================================
diff -u -r13635 -r13780
--- branches/5.1.x/core/install/install_schema.sql (.../install_schema.sql) (revision 13635)
+++ branches/5.1.x/core/install/install_schema.sql (.../install_schema.sql) (revision 13780)
@@ -188,6 +188,7 @@
);
CREATE TABLE Phrase (
+ PhraseId int(11) NOT NULL AUTO_INCREMENT,
Phrase varchar(255) NOT NULL DEFAULT '',
PhraseKey varchar(255) NOT NULL DEFAULT '',
l1_Translation text,
@@ -196,7 +197,6 @@
l4_Translation text,
l5_Translation text,
PhraseType int(11) NOT NULL DEFAULT '0',
- PhraseId int(11) NOT NULL AUTO_INCREMENT,
LastChanged int(10) unsigned DEFAULT NULL,
LastChangeIP varchar(15) NOT NULL DEFAULT '',
Module varchar(30) NOT NULL DEFAULT 'In-Portal',
Index: branches/5.1.x/core/install.php
===================================================================
diff -u -r13773 -r13780
--- branches/5.1.x/core/install.php (.../install.php) (revision 13773)
+++ branches/5.1.x/core/install.php (.../install.php) (revision 13780)
@@ -1,6 +1,6 @@
Array ('check_paths', 'clean_db', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish'),
'already_installed' => Array ('check_paths', 'install_setup'),
- 'upgrade' => Array ('check_paths', 'install_setup', 'upgrade_modules', 'security', 'finish'),
+ 'upgrade' => Array ('check_paths', 'install_setup', 'upgrade_modules', 'skin_upgrade', 'security', 'finish'),
'update_license' => Array ('check_paths', 'install_setup', 'select_license', /*'download_license',*/ 'select_domain', 'security', 'finish'),
'db_reconfig' => Array ('check_paths', 'install_setup', 'db_reconfig', 'security', 'finish'),
'fix_paths' => Array ('check_paths', 'install_setup', 'fix_paths', 'security', 'finish'),
@@ -128,6 +128,20 @@
var $LastQueryNum = 0;
/**
+ * Dependencies, that should be used in upgrade process
+ *
+ * @var Array
+ */
+ var $upgradeDepencies = Array ();
+
+ /**
+ * Log of upgrade - list of upgraded modules and their versions
+ *
+ * @var Array
+ */
+ var $upgradeLog = Array ();
+
+ /**
* Common tools required for installation process
*
* @var kInstallToolkit
@@ -312,6 +326,13 @@
}
break;
+ case 'skin_upgrade':
+ if ($this->Application->RecallVar('SkinUpgradeLog') === false) {
+ // no errors during skin upgrade -> skip this step
+ $this->currentStep = $this->GetNextStep();
+ }
+ break;
+
case 'install_setup':
$next_preset = $this->Application->GetVar('next_preset');
if ($next_preset !== false) {
@@ -838,51 +859,71 @@
case 'upgrade_modules':
// get installed modules from db and compare their versions to upgrade script
$modules = $this->Application->GetVar('modules');
+
if ($modules) {
$upgrade_data = $this->GetUpgradableModules();
+ $start_from_query = $this->Application->GetVar('start_from_query');
+ $this->upgradeDepencies = $this->getUpgradeDependencies($modules, $upgrade_data);
- $start_from_module = $this->GetVar('continue_from_module');
- $start_from_query = $this->GetVar('continue_from_query');
- if (!$start_from_query) $start_from_query = 0;
- foreach ($modules as $module_name) {
- if ($start_from_module && $module_name != $start_from_module) {
- continue;
+ if ($start_from_query !== false) {
+ $this->upgradeLog = unserialize( $this->Application->RecallVar('UpgradeLog') );
+ }
+ else {
+ $start_from_query = 0;
+ $this->upgradeLog = Array ('ModuleVersions' => Array ());
+
+ // remember each module version, before upgrade scripts are executed
+ foreach ($modules as $module_name) {
+ $module_info = $upgrade_data[$module_name];
+ $this->upgradeLog['ModuleVersions'][$module_name] = $module_info['FromVersion'];
}
- else {
- $start_from_module = false; //otherwise it will skip all modules after the one we start with!
- }
- $module_info = $upgrade_data[$module_name];
- $upgrades_file = sprintf(UPGRADES_FILE, $module_info['Path'], 'sql');
- $sqls = file_get_contents($upgrades_file);
- $version_mark = preg_replace('/(\(.*?\))/', $module_info['FromVersion'], VERSION_MARK);
+ $this->Application->RemoveVar('UpgradeLog');
+ }
- // get only sqls from next (relative to current) version to end of file
- $start_pos = strpos($sqls, $version_mark);
- $sqls = substr($sqls, $start_pos);
+ // 1. perform "php before", "sql", "php after" upgrades
+ foreach ($modules as $module_name) {
+ $module_info = $upgrade_data[$module_name];
- preg_match_all('/'.VERSION_MARK.'/s', $sqls, $regs);
+ /*echo '