Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Wed, Feb 5, 7:42 AM

in-portal

Index: branches/5.2.x/core/units/helpers/user_helper.php
===================================================================
--- branches/5.2.x/core/units/helpers/user_helper.php (revision 15175)
+++ branches/5.2.x/core/units/helpers/user_helper.php (revision 15176)
@@ -1,598 +1,605 @@
<?php
/**
* @version $Id$
* @package In-Portal
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class UserHelper extends kHelper {
/**
* Event to be used during login processings
*
* @var kEvent
*/
var $event = null;
/**
* Performs user login and returns the result
*
* @param string $username
* @param string $password
* @param bool $dry_run
* @param bool $remember_login
* @param string $remember_login_cookie
* @return int
*/
function loginUser($username, $password, $dry_run = false, $remember_login = false, $remember_login_cookie = '')
{
if (!isset($this->event)) {
$this->event = new kEvent('u:OnLogin');
}
if (!$password && !$remember_login_cookie) {
return LoginResult::INVALID_PASSWORD;
}
$object =& $this->getUserObject();
// process "Save Username" checkbox
if ($this->Application->isAdmin) {
$save_username = $this->Application->GetVar('cb_save_username') ? $username : '';
$this->Application->Session->SetCookie('save_username', $save_username, strtotime('+1 year'));
// cookie will be set on next refresh, but refresh won't occur if
// login error present, so duplicate cookie in kHTTPQuery
$this->Application->SetVar('save_username', $save_username);
}
// logging in "root" (admin only)
$super_admin = ($username == 'super-root') && $this->verifySuperAdmin();
if ($this->Application->isAdmin && ($username == 'root') || ($super_admin && $username == 'super-root')) {
$root_password = $this->Application->ConfigValue('RootPass');
$password_formatter = $this->Application->recallObject('kPasswordFormatter');
/* @var $password_formatter kPasswordFormatter */
if ($root_password != $password_formatter->EncryptPassword($password, 'b38')) {
return LoginResult::INVALID_PASSWORD;
}
$user_id = USER_ROOT;
$object->Clear($user_id);
$object->SetDBField('Username', 'root');
if (!$dry_run) {
$this->loginUserById($user_id, $remember_login_cookie);
if ($super_admin) {
$this->Application->StoreVar('super_admin', 1);
}
// reset counters
$this->Application->resetCounters('UserSessions');
$this->_processLoginRedirect('root', $password);
$this->_processInterfaceLanguage();
}
return LoginResult::OK;
}
$user_id = $this->getUserId($username, $password, $remember_login_cookie);
if ($user_id) {
$object->Load($user_id);
if (!$this->checkBanRules($object)) {
return LoginResult::BANNED;
}
if ($object->GetDBField('Status') == STATUS_ACTIVE) {
if ( !$this->checkLoginPermission() ) {
return LoginResult::NO_PERMISSION;
}
if (!$dry_run) {
$this->loginUserById($user_id, $remember_login_cookie);
if ($remember_login) {
// remember username & password when "Remember Login" checkbox us checked (when user is using login form on Front-End)
$this->Application->Session->SetCookie('remember_login', $username . '|' . md5($password), strtotime('+1 month'));
}
if (!$remember_login_cookie) {
// reset counters
$this->Application->resetCounters('UserSessions');
$this->_processLoginRedirect($username, $password);
$this->_processInterfaceLanguage();
}
}
return LoginResult::OK;
}
else {
$pending_template = $this->Application->GetVar('pending_disabled_template');
if ($pending_template !== false && !$dry_run) {
// when user found, but it's not yet approved redirect hit to notification template
$this->event->redirect = $pending_template;
return LoginResult::OK;
}
else {
// when no notification template given return an error
return LoginResult::INVALID_PASSWORD;
}
}
}
if (!$dry_run) {
$this->event->SetRedirectParam('pass', 'all');
// $this->event->SetRedirectParam('pass_category', 1); // to test
}
return LoginResult::INVALID_PASSWORD;
}
/**
* Login user by it's id
*
* @param int $user_id
* @param bool $remember_login_cookie
*/
function loginUserById($user_id, $remember_login_cookie = false)
{
$object =& $this->getUserObject();
$this->Application->StoreVar('user_id', $user_id);
$this->Application->SetVar('u.current_id', $user_id);
$this->Application->Session->SetField('PortalUserId', $user_id);
if ($user_id != USER_ROOT) {
$groups = $this->Application->RecallVar('UserGroups');
$this->Application->Session->SetField('GroupId', reset( explode(',', $groups) ));
$this->Application->Session->SetField('GroupList', $groups);
$this->Application->Session->SetField('TimeZone', $object->GetDBField('TimeZone'));
}
$this->Application->LoadPersistentVars();
if (!$remember_login_cookie) {
// don't change last login time when auto-login is used
$this_login = (int)$this->Application->RecallPersistentVar('ThisLogin');
$this->Application->StorePersistentVar('LastLogin', $this_login);
$this->Application->StorePersistentVar('ThisLogin', adodb_mktime());
}
$this->Application->HandleEvent(new kEvent('u:OnAfterLogin'));
}
/**
* Checks login permission
*
* @return bool
*/
function checkLoginPermission()
{
$object =& $this->getUserObject();
$ip_restrictions = $object->GetDBField('IPRestrictions');
if ( $ip_restrictions && !$this->Application->isDebugMode() && !kUtil::ipMatch($ip_restrictions, "\n") ) {
return false;
}
$groups = $object->getMembershipGroups(true);
if ( !$groups ) {
$groups = Array ();
}
$default_group = $this->getUserTypeGroup();
if ( $default_group !== false ) {
array_push($groups, $default_group);
}
// store groups, because kApplication::CheckPermission will use them!
array_push($groups, $this->Application->ConfigValue('User_LoggedInGroup'));
$groups = array_unique($groups);
$this->Application->StoreVar('UserGroups', implode(',', $groups), true); // true for optional
return $this->Application->CheckPermission($this->Application->isAdmin ? 'ADMIN' : 'LOGIN', 1);
}
/**
* Returns default user group for it's type
*
* @return bool|string
* @access protected
*/
protected function getUserTypeGroup()
{
$group_id = false;
$object =& $this->getUserObject();
if ( $object->GetDBField('UserType') == UserType::USER ) {
$group_id = $this->Application->ConfigValue('User_NewGroup');
}
elseif ( $object->GetDBField('UserType') == UserType::ADMIN ) {
$group_id = $this->Application->ConfigValue('User_AdminGroup');
}
$ip_restrictions = $this->getGroupsWithIPRestrictions();
if ( !isset($ip_restrictions[$group_id]) || kUtil::ipMatch($ip_restrictions[$group_id], "\n") ) {
return $group_id;
}
return false;
}
/**
* Returns groups with IP restrictions
*
* @return Array
* @access public
*/
public function getGroupsWithIPRestrictions()
{
static $cache = null;
if ( $this->Application->isDebugMode() ) {
return Array ();
}
if ( !isset($cache) ) {
$sql = 'SELECT IPRestrictions, GroupId
FROM ' . TABLE_PREFIX . 'UserGroups
WHERE IPRestrictions IS NOT NULL';
$cache = $this->Conn->GetCol($sql, 'GroupId');
}
return $cache;
}
/**
* Performs user logout
*
*/
function logoutUser()
{
if (!isset($this->event)) {
$this->event = new kEvent('u:OnLogout');
}
$sync_manager = $this->Application->recallObject('UsersSyncronizeManager', null, Array(), Array ('InPortalSyncronize'));
/* @var $sync_manager UsersSyncronizeManager */
$sync_manager->performAction('LogoutUser');
$this->Application->HandleEvent(new kEvent('u:OnBeforeLogout'));
$user_id = USER_GUEST;
$this->Application->SetVar('u.current_id', $user_id);
$object = $this->Application->recallObject('u.current', null, Array('skip_autoload' => true));
/* @var $object UsersItem */
$object->Load($user_id);
$this->Application->DestroySession();
$this->Application->StoreVar('user_id', $user_id, true);
$this->Application->Session->SetField('PortalUserId', $user_id);
$group_list = $this->Application->ConfigValue('User_GuestGroup') . ',' . $this->Application->ConfigValue('User_LoggedInGroup');
$this->Application->StoreVar('UserGroups', $group_list, true);
$this->Application->Session->SetField('GroupList', $group_list);
if ($this->Application->ConfigValue('UseJSRedirect')) {
$this->event->SetRedirectParam('js_redirect', 1);
}
$this->Application->resetCounters('UserSessions');
$this->Application->Session->SetCookie('remember_login', '', strtotime('-1 hour'));
// don't pass user prefix on logout, since resulting url will have broken "env"
$this->event->SetRedirectParam('pass', MOD_REWRITE ? 'm' : 'all');
}
/**
* Returns user id based on given criteria
*
* @param string $username
* @param string $password
* @param string $remember_login_cookie
* @return int
*/
function getUserId($username, $password, $remember_login_cookie)
{
$password = md5($password);
if ($remember_login_cookie) {
list ($username, $password) = explode('|', $remember_login_cookie); // 0 - username, 1 - md5(password)
}
$sql = 'SELECT PortalUserId
FROM ' . TABLE_PREFIX . 'Users
WHERE (Email = %1$s OR Username = %1$s) AND (Password = %2$s)';
return $this->Conn->GetOne( sprintf($sql, $this->Conn->qstr($username), $this->Conn->qstr($password) ) );
}
/**
* Process all required data and redirect logged-in user
*
* @param string $username
* @param string $password
*/
function _processLoginRedirect($username, $password)
{
// set next template
$next_template = $this->Application->GetVar('next_template');
if ($next_template) {
$this->event->redirect = $next_template;
}
// process IIS redirect
if ($this->Application->ConfigValue('UseJSRedirect')) {
$this->event->SetRedirectParam('js_redirect', 1);
}
// synchronize login
$sync_manager = $this->Application->recallObject('UsersSyncronizeManager', null, Array(), Array ('InPortalSyncronize'));
/* @var $sync_manager UsersSyncronizeManager */
$sync_manager->performAction('LoginUser', $username, $password);
}
/**
* Sets correct interface language after successful login, based on user settings
*
* @return void
* @access protected
*/
protected function _processInterfaceLanguage()
{
+ if ( defined('IS_INSTALL') && IS_INSTALL ) {
+ $this->event->SetRedirectParam('m_lang', 1); // data
+ $this->Application->Session->SetField('Language', 1); // interface
+
+ return;
+ }
+
$language_field = $this->Application->isAdmin ? 'AdminLanguage' : 'FrontLanguage';
$primary_language_field = $this->Application->isAdmin ? 'AdminInterfaceLang' : 'PrimaryLang';
$is_root = $this->Application->RecallVar('user_id') == USER_ROOT;
$object =& $this->getUserObject();
$user_language_id = $is_root ? $this->Application->RecallPersistentVar($language_field) : $object->GetDBField($language_field);
$sql = 'SELECT LanguageId, IF(LanguageId = ' . (int)$user_language_id . ', 2, ' . $primary_language_field . ') AS SortKey
FROM ' . TABLE_PREFIX . 'Languages
WHERE Enabled = 1
HAVING SortKey <> 0
ORDER BY SortKey DESC';
$language_info = $this->Conn->GetRow($sql);
$language_id = $language_info && $language_info['LanguageId'] ? $language_info['LanguageId'] : $user_language_id;
if ( $user_language_id != $language_id ) {
// first login OR language was deleted or disabled
if ( $is_root ) {
$this->Application->StorePersistentVar($language_field, $language_id);
}
else {
$object->SetDBField($language_field, $language_id);
$object->Update();
}
}
$this->event->SetRedirectParam('m_lang', $language_id); // data
$this->Application->Session->SetField('Language', $language_id); // interface
}
/**
* Checks that user is allowed to use super admin mode
*
* @return bool
*/
function verifySuperAdmin()
{
$sa_mode = kUtil::ipMatch(defined('SA_IP') ? SA_IP : '');
return $sa_mode || $this->Application->isDebugMode();
}
/**
* Returns user object, used during login processing
*
* @return UsersItem
* @access public
*/
public function &getUserObject()
{
$prefix_special = $this->Application->isAdmin ? 'u.current' : 'u'; // "u" used on front not to change theme
$object = $this->Application->recallObject($prefix_special, null, Array('skip_autoload' => true));
/* @var $object UsersItem */
return $object;
}
/**
* Checks, if given user fields matches at least one of defined ban rules
*
* @param kDBItem $object
* @return bool
*/
function checkBanRules(&$object)
{
$table = $this->Application->getUnitOption('ban-rule', 'TableName');
if (!$this->Conn->TableFound($table)) {
// when ban table not found -> assume user is ok by default
return true;
}
$sql = 'SELECT *
FROM ' . $table . '
WHERE ItemType = 6 AND Status = ' . STATUS_ACTIVE . '
ORDER BY Priority DESC';
$rules = $this->Conn->Query($sql);
$found = false;
foreach ($rules as $rule) {
$field = $rule['ItemField'];
$this_value = mb_strtolower( $object->GetDBField($field) );
$test_value = mb_strtolower( $rule['ItemValue'] );
switch ( $rule['ItemVerb'] ) {
case 1: // is
if ($this_value == $test_value) {
$found = true;
}
break;
case 2: // is not
if ($this_value != $test_value) {
$found = true;
}
break;
case 3: // contains
if ( strstr($this_value, $test_value) ) {
$found = true;
}
break;
case 4: // not contains
if ( !strstr($this_value, $test_value) ) {
$found = true;
}
break;
case 7: // exists
if ( strlen($this_value) > 0 ) {
$found = true;
}
break;
case 8: // unique
if ( $this->_checkValueExist($field, $this_value) ) {
$found = true;
}
break;
}
if ( $found ) {
// check ban rules, until one of them matches
if ( $rule['RuleType'] ) {
// invert rule type
$found = false;
}
break;
}
}
return !$found;
}
/**
* Checks if value is unique in Users table against the specified field
*
* @param string $field
* @param string $value
* @return string
*/
function _checkValueExist($field, $value)
{
$sql = 'SELECT *
FROM ' . $this->Application->getUnitOption('u', 'TableName') . '
WHERE '. $field .' = ' . $this->Conn->qstr($value);
return $this->Conn->GetOne($sql);
}
public function validateUserCode($user_code, $code_type, $expiration_timeout = null)
{
$expiration_timeouts = Array (
'forgot_password' => 'config:Users_AllowReset',
'activation' => 'config:UserEmailActivationTimeout',
'verify_email' => 'config:Users_AllowReset',
'custom' => '',
);
if ( !$user_code ) {
return 'code_is_not_valid';
}
$sql = 'SELECT PwRequestTime, PortalUserId
FROM ' . TABLE_PREFIX . 'Users
WHERE PwResetConfirm = ' . $this->Conn->qstr( trim($user_code) );
$user_info = $this->Conn->GetRow($sql);
if ( $user_info === false ) {
return 'code_is_not_valid';
}
$expiration_timeout = isset($expiration_timeout) ? $expiration_timeout : $expiration_timeouts[$code_type];
if ( preg_match('/^config:(.*)$/', $expiration_timeout, $regs) ) {
$expiration_timeout = $this->Application->ConfigValue( $regs[1] );
}
if ( $expiration_timeout && $user_info['PwRequestTime'] < strtotime('-' . $expiration_timeout . ' minutes') ) {
return 'code_expired';
}
return $user_info['PortalUserId'];
}
/**
* Restores user's email, returns error label, if error occurred
*
* @param string $hash
* @return string
* @access public
*/
public function restoreEmail($hash)
{
if ( !preg_match('/^[a-f0-9]{32}$/', $hash) ) {
return 'invalid_hash';
}
$sql = 'SELECT PortalUserId, PrevEmails
FROM ' . TABLE_PREFIX . 'Users
WHERE PrevEmails LIKE ' . $this->Conn->qstr('%' . $hash . '%');
$user_info = $this->Conn->GetRow($sql);
if ( $user_info === false ) {
return 'invalid_hash';
}
$prev_emails = $user_info['PrevEmails'];
$prev_emails = $prev_emails ? unserialize($prev_emails) : Array ();
if ( !isset($prev_emails[$hash]) ) {
return 'invalid_hash';
}
$email_to_restore = $prev_emails[$hash];
unset($prev_emails[$hash]);
$object = $this->Application->recallObject('u.email-restore', null, Array ('skip_autoload' => true));
/* @var $object UsersItem */
$object->Load($user_info['PortalUserId']);
$object->SetDBField('PrevEmails', serialize($prev_emails));
$object->SetDBField('Email', $email_to_restore);
$object->SetDBField('EmailVerified', 1);
return $object->Update() ? '' : 'restore_impossible';
}
}
Index: branches/5.2.x/core/install/prerequisites.php
===================================================================
--- branches/5.2.x/core/install/prerequisites.php (revision 15175)
+++ branches/5.2.x/core/install/prerequisites.php (revision 15176)
@@ -1,181 +1,197 @@
<?php
/**
* @version $Id$
* @package In-Portal
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
$prerequisite_class = 'InPortalPrerequisites';
/**
* Class, that holds all prerequisite scripts for "In-Portal" module
*
*/
class InPortalPrerequisites {
/**
* Install toolkit instance
*
* @var kInstallToolkit
*/
var $_toolkit = null;
/**
* Connection to database
*
* @var kDBConnection
* @access protected
*/
protected $Conn = null;
/**
+ * Version upgrade rules
+ *
+ * @var array
+ * @access private
+ */
+ private $upgradeRules = Array (
+ '5.0.0' => Array ('from' => '5.0.0-B1', 'to' => '5.1.0-B1'),
+ '5.1.0' => Array ('from' => '5.1.0-B1', 'to' => '5.2.0-B1'),
+ '5.2.0' => Array ('from' => '5.2.0-B1', 'to' => '5.3.0-B1'),
+ );
+
+ /**
* Sets common instance of installator toolkit
*
* @param kInstallToolkit $instance
*/
function setToolkit(&$instance)
{
$this->_toolkit =& $instance;
}
/**
* Checks minimal version, that could be upgradeable
*
* @return kDBConnection
*/
- function &getConnection()
+ function getConnection()
{
return $this->_toolkit->Conn;
}
/**
* Checks minimal version, that could be upgradeable
*
* @param Array $versions
* @param string $mode when called mode {install, upgrade, standalone)
* @return Array
*/
function CheckPrerequisites($versions, $mode)
{
$errors = Array ();
- if ($mode == 'upgrade') {
+ if ( $mode == 'upgrade' ) {
$sql = 'SELECT Version
FROM ' . TABLE_PREFIX . 'Modules
WHERE Name = "In-Portal"';
+ $inportal_version = $this->getConnection()->GetOne($sql);
- $conn =& $this->getConnection();
- $inportal_version = $conn->GetOne($sql);
-
- if ($inportal_version === false) {
- // only, when In-Portal was installed
+ if ( $inportal_version === false ) {
+ // only, when In-Portal was installed (below 4.3.x)
return $errors;
}
- $min_version = '4.3.1';
+ $min_version = '4.3.1'; // K4-based installator was created, that no longer maintained old upgrade scripts
+
+ if ( version_compare($inportal_version, $min_version, '<') ) {
+ $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version . ' first';
+ }
- $current_version = $this->_toolkit->ConvertModuleVersion($inportal_version);
- $needed_version = $this->_toolkit->ConvertModuleVersion($min_version);
- if ($current_version < $needed_version) {
- $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version;
+ // example: to upgrade to 5.1.0-B1 or more you at least need to have 5.0.0 installed
+ foreach ($this->upgradeRules as $min_version => $version_rules) {
+ if ( version_compare($versions[0], $version_rules['from'], '<') && version_compare($versions[1], $version_rules['to'], '>=') ) {
+ $errors[] = 'Please upgrade "In-Portal" to version ' . $min_version . ' first';
+ break;
+ }
}
}
return $errors;
}
/**
* Returns information about system requirements
*
* @return array
*/
function CheckSystemRequirements()
{
$ret = Array ();
$ret['php_version'] = version_compare(PHP_VERSION, '5.3.2', '>=');
$ret['url_rewriting'] = function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules());
$ret['memcache'] = class_exists('Memcache');
$ret['curl'] = function_exists('curl_init');
$ret['simplexml'] = function_exists('simplexml_load_string');
$ret['freetype'] = function_exists('imagettfbbox');
$ret['gd_version'] = $ret['jpeg'] = false;
if ( function_exists('gd_info') ) {
$gd_info = gd_info();
$gd_version = preg_replace('/[^\d.]/', '', $gd_info['GD Version']);
$ret['gd_version'] = version_compare($gd_version, '1.8', '>=');
$ret['jpeg'] = isset($gd_info['JPEG Support']) && $gd_info['JPEG Support'];
}
$ret['mysql'] = function_exists('mysql_connect');
$ret['json'] = function_exists('json_encode');
$output = shell_exec('java -version 2>&1');
$ret['java'] = stripos($output, 'java version') !== false;
$ret['memory_limit'] = $this->isPhpSettingChangeable('memory_limit', '33M');
$ret['date.timezone'] = ini_get('date.timezone') != '';
$ret['variables_order'] = strpos(ini_get('variables_order'), 'GPC') !== false;
$ret['output_buffering'] = ini_get('output_buffering') > 0;
return $ret;
}
/**
* Detects if setting of php.ini can be changed
*
* @param string $setting_name
* @param string $new_value
* @return bool
*/
protected function isPhpSettingChangeable($setting_name, $new_value)
{
$backup_value = ini_get($setting_name);
ini_set($setting_name, $new_value);
if ( ini_get($setting_name) != $backup_value ) {
ini_set($setting_name, $backup_value);
return true;
}
return false;
}
/**
* Returns information about DB requirements
*
* @return array
*/
function CheckDBRequirements()
{
// check PHP version 5.2+
$ret = Array();
$sql = 'SELECT VERSION()';
- $conn =& $this->getConnection();
+ $conn = $this->getConnection();
$db_version = preg_replace('/[^\d.]/', '', $conn->GetOne($sql));
$ret['version'] = version_compare($db_version, '5.0', '>=');
$sql = 'SHOW VARIABLES LIKE "max_allowed_packet"';
$db_variables = $conn->Query($sql, 'Variable_name');
$ret['packet_size'] = $db_variables['max_allowed_packet']['Value'] >= 1048576;
return $ret;
}
}
\ No newline at end of file
Index: branches/5.2.x/core/install/upgrades.php
===================================================================
--- branches/5.2.x/core/install/upgrades.php (revision 15175)
+++ branches/5.2.x/core/install/upgrades.php (revision 15176)
@@ -1,1943 +1,2025 @@
<?php
/**
* @version $Id$
* @package In-Portal
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
$upgrade_class = 'CoreUpgrades';
/**
* Class, that holds all upgrade scripts for "Core" module
*
*/
class CoreUpgrades extends kUpgradeHelper {
/**
+ * Tables, that were renamed during 5.2.0 version upgrade
+ *
+ * @var Array
+ * @access private
+ */
+ private $renamedTables = Array (
+ 'ban-rule' => Array ('from' => 'BanRules', 'to' => 'UserBanRules'),
+ 'conf' => Array ('from' => 'ConfigurationValues', 'to' => 'SystemSettings'),
+ 'c' => Array ('from' => 'Category', 'to' => 'Categories'),
+ 'cf' => Array ('from' => 'CustomField', 'to' => 'CustomFields'),
+ 'draft' => Array ('from' => 'Drafts', 'to' => 'FormSubmissionReplyDrafts'),
+ 'emailevents' => Array ('from' => 'Events', 'to' => 'EmailEvents'),
+ 'fav' => Array ('from' => 'Favorites', 'to' => 'UserFavorites'),
+ 'img' => Array ('from' => 'Images', 'to' => 'CatalogImages'),
+ '#file' => Array ('from' => 'ItemFiles', 'to' => 'CatalogFiles'),
+ 'rev' => Array ('from' => 'ItemReview', 'to' => 'CatalogReviews'),
+ 'lang' => Array ('from' => 'Language', 'to' => 'Languages'),
+ 'permission-type' => Array ('from' => 'PermissionConfig', 'to' => 'CategoryPermissionsConfig'),
+ 'phrases' => Array ('from' => 'Phrase', 'to' => 'LanguageLabels'),
+ 'g' => Array ('from' => 'PortalGroup', 'to' => 'UserGroups'),
+ 'user-profile' => Array ('from' => 'PersistantSessionData', 'to' => 'UserPersistentSessionData'),
+ 'u' => Array ('from' => 'PortalUser', 'to' => 'Users'),
+ 'u-cdata' => Array ('from' => 'PortalUserCustomData', 'to' => 'UserCustomData'),
+ 'search' => Array ('from' => 'RelatedSearches', 'to' => 'CategoryRelatedSearches'),
+ 'rel' => Array ('from' => 'Relationship', 'to' => 'CatalogRelationships'),
+ 'search-log' => Array ('from' => 'SearchLog', 'to' => 'SearchLogs'),
+ 'skin' => Array ('from' => 'Skins', 'to' => 'AdminSkins'),
+ 'submission-log' => Array ('from' => 'SubmissionLog', 'to' => 'FormSubmissionReplies'),
+ 'theme' => Array ('from' => 'Theme', 'to' => 'Themes'),
+ 'ug' => Array ('from' => 'UserGroup', 'to' => 'UserGroupRelations'),
+ 'visits' => Array ('from' => 'Visits', 'to' => 'UserVisits'),
+ 'session-log' => Array ('from' => 'SessionLogs', 'to' => 'UserSessionLogs'),
+ );
+
+ /**
* Changes table structure, where multilingual fields of TEXT type are present
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_4_1_0($mode)
{
if ($mode == 'before') {
// don't user after, because In-Portal calls this method too
$this->_toolkit->SaveConfig();
}
if ($mode == 'after') {
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
/* @var $ml_helper kMultiLanguageHelper */
$this->Application->UnitConfigReader->iterateConfigs(Array (&$this, 'updateTextFields'), $ml_helper->getLanguages());
}
}
/**
* Moves ReplacementTags functionality from EmailMessage to Events table
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_4_1_1($mode)
{
if ($mode == 'after') {
$sql = 'SELECT ReplacementTags, EventId
FROM '.TABLE_PREFIX.'EmailMessage
WHERE (ReplacementTags IS NOT NULL) AND (ReplacementTags <> "") AND (LanguageId = 1)';
$replacement_tags = $this->Conn->GetCol($sql, 'EventId');
foreach ($replacement_tags as $event_id => $replacement_tag) {
$sql = 'UPDATE '.TABLE_PREFIX.'Events
SET ReplacementTags = '.$this->Conn->qstr($replacement_tag).'
WHERE EventId = '.$event_id;
$this->Conn->Query($sql);
}
// drop moved field from source table
$sql = 'ALTER TABLE '.TABLE_PREFIX.'EmailMessage
DROP `ReplacementTags`';
$this->Conn->Query($sql);
}
}
/**
* Callback function, that makes all ml fields of text type null with same default value
*
* @param string $prefix
* @param Array $config_data
* @param Array $languages
* @return bool
*/
function updateTextFields($prefix, &$config_data, $languages)
{
if (!isset($config_data['TableName']) || !isset($config_data['Fields'])) {
// invalid config found or prefix not found
return false;
}
$table_name = $config_data['TableName'];
$table_structure = $this->Conn->Query('DESCRIBE '.$table_name, 'Field');
if (!$table_structure) {
// table not found
return false;
}
$sqls = Array ();
foreach ($config_data['Fields'] as $field => $options) {
if (isset($options['formatter']) && $options['formatter'] == 'kMultiLanguage' && !isset($options['master_field'])) {
// update all l<lang_id>_<field_name> fields (new format)
foreach ($languages as $language_id) {
$ml_field = 'l'.$language_id.'_'.$field;
if ($table_structure[$ml_field]['Type'] == 'text') {
$sqls[] = 'CHANGE '.$ml_field.' '.$ml_field.' TEXT NULL DEFAULT NULL';
}
}
// update <field_name> if found (old format)
if (isset($table_structure[$field]) && $table_structure[$field]['Type'] == 'text') {
$sqls[] = 'CHANGE '.$field.' '.$field.' TEXT NULL DEFAULT NULL';
}
}
}
if ($sqls) {
$sql = 'ALTER TABLE '.$table_name.' '.implode(', ', $sqls);
$this->Conn->Query($sql);
}
return true;
}
/**
* Replaces In-Portal tags in Forgot Password related email events to K4 ones
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_4_2_0($mode)
{
if ($mode == 'after') {
// 1. get event ids based on their name and type combination
$event_names = Array (
'USER.PSWD_' . EmailEvent::EVENT_TYPE_ADMIN,
'USER.PSWD_' . EmailEvent::EVENT_TYPE_FRONTEND,
'USER.PSWDC_' . EmailEvent::EVENT_TYPE_FRONTEND,
);
$event_sql = Array ();
foreach ($event_names as $mixed_event) {
list ($event_name, $event_type) = explode('_', $mixed_event, 2);
$event_sql[] = 'Event = "'.$event_name.'" AND Type = '.$event_type;
}
$sql = 'SELECT EventId
FROM '.TABLE_PREFIX.'Events
WHERE ('.implode(') OR (', $event_sql).')';
$event_ids = implode(',', $this->Conn->GetCol($sql));
// 2. replace In-Portal tags to K4 tags
$replacements = Array (
'<inp:touser _Field="Password" />' => '<inp2:u_ForgottenPassword />',
'<inp:m_confirm_password_link />' => '<inp2:u_ConfirmPasswordLink no_amp="1"/>',
);
foreach ($replacements as $old_tag => $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.')';
$this->Conn->Query($sql);
}
}
}
/**
* Makes admin primary language same as front-end - not needed, done in SQL
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_4_2_1($mode)
{
}
function Upgrade_4_2_2($mode)
{
if ($mode == 'before') {
if ($this->Conn->GetOne('SELECT LanguageId FROM '.TABLE_PREFIX.'Language WHERE PrimaryLang = 1')) return ;
$this->Conn->Query('UPDATE '.TABLE_PREFIX.'Language SET PrimaryLang = 1 ORDER BY LanguageId LIMIT 1');
}
}
/**
* Adds index to "dob" field in "PortalUser" table when it's missing
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_4_3_1($mode)
{
if ($mode == 'after') {
$sql = 'DESCRIBE ' . TABLE_PREFIX . 'PortalUser';
$structure = $this->Conn->Query($sql);
foreach ($structure as $field_info) {
if ($field_info['Field'] == 'dob') {
if (!$field_info['Key']) {
$sql = 'ALTER TABLE ' . TABLE_PREFIX . 'PortalUser
ADD INDEX (dob)';
$this->Conn->Query($sql);
}
break;
}
}
}
}
/**
* Removes duplicate phrases, update file paths in database
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_4_3_9($mode)
{
// 1. find In-Portal old <inp: tags
$sql = 'SELECT EmailMessageId
FROM '.TABLE_PREFIX.'EmailMessage
WHERE Template LIKE \'%<inp:%\'';
$event_ids = implode(',', $this->Conn->GetCol($sql));
// 2. replace In-Portal old <inp: tags to K4 tags
$replacements = Array (
'<inp:m_category_field _Field="Name" _StripHTML="1"' => '<inp2:c_Field name="Name"',
'<inp:touser _Field="password"' => '<inp2:u_Field name="Password_plain"',
'<inp:touser _Field="UserName"' => '<inp2:u_Field name="Login"',
'<inp:touser _Field="' => '<inp2:u_Field name="',
'<inp:m_page_title' => '<inp2:m_BaseUrl',
'<inp:m_theme_url _page="current"' => '<inp2:m_BaseUrl',
'<inp:topic _field="text"' => '<inp2:bb-post_Field name="PostingText"',
'<inp:topic _field="link" _Template="inbulletin/post_list"' => '<inp2:bb_TopicLink template="__default__"',
);
if ($event_ids) {
foreach ($replacements as $old_tag => $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.')';
$this->Conn->Query($sql);
}
}
if ($mode == 'after') {
$this->_insertInPortalData();
$this->_moveDatabaseFolders();
// in case, when In-Portal module is enabled -> turn AdvancedUserManagement on too
if ($this->Application->findModule('Name', 'In-Portal')) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'ConfigurationValues
SET VariableValue = 1
WHERE VariableName = "AdvancedUserManagement"';
$this->Conn->Query($sql);
}
}
if ($mode == 'languagepack') {
$this->_removeDuplicatePhrases();
}
}
function _insertInPortalData()
{
$data = Array (
'ConfigurationAdmin' => Array (
'UniqueField' => 'VariableName',
'Records' => Array (
'AllowDeleteRootCats' => "('AllowDeleteRootCats', 'la_Text_General', 'la_AllowDeleteRootCats', 'checkbox', NULL , NULL , 10.09, 0, 0)",
'Catalog_PreselectModuleTab' => "('Catalog_PreselectModuleTab', 'la_Text_General', 'la_config_CatalogPreselectModuleTab', 'checkbox', NULL, NULL, 10.10, 0, 1)",
'RecycleBinFolder' => "('RecycleBinFolder', 'la_Text_General', 'la_config_RecycleBinFolder', 'text', NULL , NULL , 10.11, 0, 0)",
'AdvancedUserManagement' => "('AdvancedUserManagement', 'la_Text_General', 'la_prompt_AdvancedUserManagement', 'checkbox', NULL, NULL, '10.011', 0, 1)",
),
),
'ConfigurationValues' => Array (
'UniqueField' => 'VariableName',
'Records' => Array (
'AdvancedUserManagement' => "(DEFAULT, 'AdvancedUserManagement', 0, 'In-Portal:Users', 'in-portal:configure_users')",
),
),
'ItemTypes' => Array (
'UniqueField' => 'ItemType',
'Records' => Array (
'1' => "(1, 'In-Portal', 'c', 'Category', 'Name', 'CreatedById', NULL, NULL, 'la_ItemTab_Categories', 1, 'admin/category/addcategory.php', 'clsCategory', 'Category')",
'6' => "(6, 'In-Portal', 'u', 'PortalUser', 'Login', 'PortalUserId', NULL, NULL, '', 0, '', 'clsPortalUser', 'User')",
),
),
'PermissionConfig' => Array (
'UniqueField' => 'PermissionName',
'Records' => Array (
'CATEGORY.ADD' => "(DEFAULT, 'CATEGORY.ADD', 'lu_PermName_Category.Add_desc', 'lu_PermName_Category.Add_error', 'In-Portal')",
'CATEGORY.DELETE' => "(DEFAULT, 'CATEGORY.DELETE', 'lu_PermName_Category.Delete_desc', 'lu_PermName_Category.Delete_error', 'In-Portal')",
'CATEGORY.ADD.PENDING' => "(DEFAULT, 'CATEGORY.ADD.PENDING', 'lu_PermName_Category.AddPending_desc', 'lu_PermName_Category.AddPending_error', 'In-Portal')",
'CATEGORY.MODIFY' => "(DEFAULT, 'CATEGORY.MODIFY', 'lu_PermName_Category.Modify_desc', 'lu_PermName_Category.Modify_error', 'In-Portal')",
'ADMIN' => "(DEFAULT, 'ADMIN', 'lu_PermName_Admin_desc', 'lu_PermName_Admin_error', 'Admin')",
'LOGIN' => "(DEFAULT, 'LOGIN', 'lu_PermName_Login_desc', 'lu_PermName_Admin_error', 'Front')",
'DEBUG.ITEM' => "(DEFAULT, 'DEBUG.ITEM', 'lu_PermName_Debug.Item_desc', '', 'Admin')",
'DEBUG.LIST' => "(DEFAULT, 'DEBUG.LIST', 'lu_PermName_Debug.List_desc', '', 'Admin')",
'DEBUG.INFO' => "(DEFAULT, 'DEBUG.INFO', 'lu_PermName_Debug.Info_desc', '', 'Admin')",
'PROFILE.MODIFY' => "(DEFAULT, 'PROFILE.MODIFY', 'lu_PermName_Profile.Modify_desc', '', 'Admin')",
'SHOWLANG' => "(DEFAULT, 'SHOWLANG', 'lu_PermName_ShowLang_desc', '', 'Admin')",
'FAVORITES' => "(DEFAULT, 'FAVORITES', 'lu_PermName_favorites_desc', 'lu_PermName_favorites_error', 'In-Portal')",
'SYSTEM_ACCESS.READONLY' => "(DEFAULT, 'SYSTEM_ACCESS.READONLY', 'la_PermName_SystemAccess.ReadOnly_desc', 'la_PermName_SystemAccess.ReadOnly_error', 'Admin')",
),
),
'Permissions' => Array (
'UniqueField' => 'Permission;GroupId;Type;CatId',
'Records' => Array (
'LOGIN;12;1;0' => "(DEFAULT, 'LOGIN', 12, 1, 1, 0)",
'in-portal:site.view;11;1;0' => "(DEFAULT, 'in-portal:site.view', 11, 1, 1, 0)",
'in-portal:browse.view;11;1;0' => "(DEFAULT, 'in-portal:browse.view', 11, 1, 1, 0)",
'in-portal:advanced_view.view;11;1;0' => "(DEFAULT, 'in-portal:advanced_view.view', 11, 1, 1, 0)",
'in-portal:reviews.view;11;1;0' => "(DEFAULT, 'in-portal:reviews.view', 11, 1, 1, 0)",
'in-portal:configure_categories.view;11;1;0' => "(DEFAULT, 'in-portal:configure_categories.view', 11, 1, 1, 0)",
'in-portal:configure_categories.edit;11;1;0' => "(DEFAULT, 'in-portal:configure_categories.edit', 11, 1, 1, 0)",
'in-portal:configuration_search.view;11;1;0' => "(DEFAULT, 'in-portal:configuration_search.view', 11, 1, 1, 0)",
'in-portal:configuration_search.edit;11;1;0' => "(DEFAULT, 'in-portal:configuration_search.edit', 11, 1, 1, 0)",
'in-portal:configuration_email.view;11;1;0' => "(DEFAULT, 'in-portal:configuration_email.view', 11, 1, 1, 0)",
'in-portal:configuration_email.edit;11;1;0' => "(DEFAULT, 'in-portal:configuration_email.edit', 11, 1, 1, 0)",
'in-portal:configuration_custom.view;11;1;0' => "(DEFAULT, 'in-portal:configuration_custom.view', 11, 1, 1, 0)",
'in-portal:configuration_custom.add;11;1;0' => "(DEFAULT, 'in-portal:configuration_custom.add', 11, 1, 1, 0)",
'in-portal:configuration_custom.edit;11;1;0' => "(DEFAULT, 'in-portal:configuration_custom.edit', 11, 1, 1, 0)",
'in-portal:configuration_custom.delete;11;1;0' => "(DEFAULT, 'in-portal:configuration_custom.delete', 11, 1, 1, 0)",
'in-portal:users.view;11;1;0' => "(DEFAULT, 'in-portal:users.view', 11, 1, 1, 0)",
'in-portal:user_list.advanced:ban;11;1;0' => "(DEFAULT, 'in-portal:user_list.advanced:ban', 11, 1, 1, 0)",
'in-portal:user_list.advanced:send_email;11;1;0' => "(DEFAULT, 'in-portal:user_list.advanced:send_email', 11, 1, 1, 0)",
'in-portal:user_groups.view;11;1;0' => "(DEFAULT, 'in-portal:user_groups.view', 11, 1, 1, 0)",
'in-portal:user_groups.add;11;1;0' => "(DEFAULT, 'in-portal:user_groups.add', 11, 1, 1, 0)",
'in-portal:user_groups.edit;11;1;0' => "(DEFAULT, 'in-portal:user_groups.edit', 11, 1, 1, 0)",
'in-portal:user_groups.delete;11;1;0' => "(DEFAULT, 'in-portal:user_groups.delete', 11, 1, 1, 0)",
'in-portal:user_groups.advanced:send_email;11;1;0' => "(DEFAULT, 'in-portal:user_groups.advanced:send_email', 11, 1, 1, 0)",
'in-portal:user_groups.advanced:manage_permissions;11;1;0' => "(DEFAULT, 'in-portal:user_groups.advanced:manage_permissions', 11, 1, 1, 0)",
'in-portal:configure_users.view;11;1;0' => "(DEFAULT, 'in-portal:configure_users.view', 11, 1, 1, 0)",
'in-portal:configure_users.edit;11;1;0' => "(DEFAULT, 'in-portal:configure_users.edit', 11, 1, 1, 0)",
'in-portal:user_email.view;11;1;0' => "(DEFAULT, 'in-portal:user_email.view', 11, 1, 1, 0)",
'in-portal:user_email.edit;11;1;0' => "(DEFAULT, 'in-portal:user_email.edit', 11, 1, 1, 0)",
'in-portal:user_custom.view;11;1;0' => "(DEFAULT, 'in-portal:user_custom.view', 11, 1, 1, 0)",
'in-portal:user_custom.add;11;1;0' => "(DEFAULT, 'in-portal:user_custom.add', 11, 1, 1, 0)",
'in-portal:user_custom.edit;11;1;0' => "(DEFAULT, 'in-portal:user_custom.edit', 11, 1, 1, 0)",
'in-portal:user_custom.delete;11;1;0' => "(DEFAULT, 'in-portal:user_custom.delete', 11, 1, 1, 0)",
'in-portal:user_banlist.view;11;1;0' => "(DEFAULT, 'in-portal:user_banlist.view', 11, 1, 1, 0)",
'in-portal:user_banlist.add;11;1;0' => "(DEFAULT, 'in-portal:user_banlist.add', 11, 1, 1, 0)",
'in-portal:user_banlist.edit;11;1;0' => "(DEFAULT, 'in-portal:user_banlist.edit', 11, 1, 1, 0)",
'in-portal:user_banlist.delete;11;1;0' => "(DEFAULT, 'in-portal:user_banlist.delete', 11, 1, 1, 0)",
'in-portal:reports.view;11;1;0' => "(DEFAULT, 'in-portal:reports.view', 11, 1, 1, 0)",
'in-portal:log_summary.view;11;1;0' => "(DEFAULT, 'in-portal:log_summary.view', 11, 1, 1, 0)",
'in-portal:searchlog.view;11;1;0' => "(DEFAULT, 'in-portal:searchlog.view', 11, 1, 1, 0)",
'in-portal:searchlog.delete;11;1;0' => "(DEFAULT, 'in-portal:searchlog.delete', 11, 1, 1, 0)",
'in-portal:sessionlog.view;11;1;0' => "(DEFAULT, 'in-portal:sessionlog.view', 11, 1, 1, 0)",
'in-portal:sessionlog.delete;11;1;0' => "(DEFAULT, 'in-portal:sessionlog.delete', 11, 1, 1, 0)",
'in-portal:emaillog.view;11;1;0' => "(DEFAULT, 'in-portal:emaillog.view', 11, 1, 1, 0)",
'in-portal:emaillog.delete;11;1;0' => "(DEFAULT, 'in-portal:emaillog.delete', 11, 1, 1, 0)",
'in-portal:visits.view;11;1;0' => "(DEFAULT, 'in-portal:visits.view', 11, 1, 1, 0)",
'in-portal:visits.delete;11;1;0' => "(DEFAULT, 'in-portal:visits.delete', 11, 1, 1, 0)",
'in-portal:configure_general.view;11;1;0' => "(DEFAULT, 'in-portal:configure_general.view', 11, 1, 1, 0)",
'in-portal:configure_general.edit;11;1;0' => "(DEFAULT, 'in-portal:configure_general.edit', 11, 1, 1, 0)",
'in-portal:modules.view;11;1;0' => "(DEFAULT, 'in-portal:modules.view', 11, 1, 1, 0)",
'in-portal:mod_status.view;11;1;0' => "(DEFAULT, 'in-portal:mod_status.view', 11, 1, 1, 0)",
'in-portal:mod_status.edit;11;1;0' => "(DEFAULT, 'in-portal:mod_status.edit', 11, 1, 1, 0)",
'in-portal:mod_status.advanced:approve;11;1;0' => "(DEFAULT, 'in-portal:mod_status.advanced:approve', 11, 1, 1, 0)",
'in-portal:mod_status.advanced:decline;11;1;0' => "(DEFAULT, 'in-portal:mod_status.advanced:decline', 11, 1, 1, 0)",
'in-portal:addmodule.view;11;1;0' => "(DEFAULT, 'in-portal:addmodule.view', 11, 1, 1, 0)",
'in-portal:addmodule.add;11;1;0' => "(DEFAULT, 'in-portal:addmodule.add', 11, 1, 1, 0)",
'in-portal:addmodule.edit;11;1;0' => "(DEFAULT, 'in-portal:addmodule.edit', 11, 1, 1, 0)",
'in-portal:tag_library.view;11;1;0' => "(DEFAULT, 'in-portal:tag_library.view', 11, 1, 1, 0)",
'in-portal:configure_themes.view;11;1;0' => "(DEFAULT, 'in-portal:configure_themes.view', 11, 1, 1, 0)",
'in-portal:configure_themes.add;11;1;0' => "(DEFAULT, 'in-portal:configure_themes.add', 11, 1, 1, 0)",
'in-portal:configure_themes.edit;11;1;0' => "(DEFAULT, 'in-portal:configure_themes.edit', 11, 1, 1, 0)",
'in-portal:configure_themes.delete;11;1;0' => "(DEFAULT, 'in-portal:configure_themes.delete', 11, 1, 1, 0)",
'in-portal:configure_styles.view;11;1;0' => "(DEFAULT, 'in-portal:configure_styles.view', 11, 1, 1, 0)",
'in-portal:configure_styles.add;11;1;0' => "(DEFAULT, 'in-portal:configure_styles.add', 11, 1, 1, 0)",
'in-portal:configure_styles.edit;11;1;0' => "(DEFAULT, 'in-portal:configure_styles.edit', 11, 1, 1, 0)",
'in-portal:configure_styles.delete;11;1;0' => "(DEFAULT, 'in-portal:configure_styles.delete', 11, 1, 1, 0)",
'in-portal:configure_lang.advanced:set_primary;11;1;0' => "(DEFAULT, 'in-portal:configure_lang.advanced:set_primary', 11, 1, 1, 0)",
'in-portal:configure_lang.advanced:import;11;1;0' => "(DEFAULT, 'in-portal:configure_lang.advanced:import', 11, 1, 1, 0)",
'in-portal:configure_lang.advanced:export;11;1;0' => "(DEFAULT, 'in-portal:configure_lang.advanced:export', 11, 1, 1, 0)",
'in-portal:tools.view;11;1;0' => "(DEFAULT, 'in-portal:tools.view', 11, 1, 1, 0)",
'in-portal:backup.view;11;1;0' => "(DEFAULT, 'in-portal:backup.view', 11, 1, 1, 0)",
'in-portal:restore.view;11;1;0' => "(DEFAULT, 'in-portal:restore.view', 11, 1, 1, 0)",
'in-portal:export.view;11;1;0' => "(DEFAULT, 'in-portal:export.view', 11, 1, 1, 0)",
'in-portal:main_import.view;11;1;0' => "(DEFAULT, 'in-portal:main_import.view', 11, 1, 1, 0)",
'in-portal:sql_query.view;11;1;0' => "(DEFAULT, 'in-portal:sql_query.view', 11, 1, 1, 0)",
'in-portal:sql_query.edit;11;1;0' => "(DEFAULT, 'in-portal:sql_query.edit', 11, 1, 1, 0)",
'in-portal:server_info.view;11;1;0' => "(DEFAULT, 'in-portal:server_info.view', 11, 1, 1, 0)",
'in-portal:help.view;11;1;0' => "(DEFAULT, 'in-portal:help.view', 11, 1, 1, 0)",
),
),
'SearchConfig' => Array (
'UniqueField' => 'TableName;FieldName;ModuleName',
'Records' => Array (
'Category;NewItem;In-Portal' => "('Category', 'NewItem', 0, 1, 'lu_fielddesc_category_newitem', 'lu_field_newitem', 'In-Portal', 'la_text_category', 18, DEFAULT, 0, 'boolean', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;PopItem;In-Portal' => "('Category', 'PopItem', 0, 1, 'lu_fielddesc_category_popitem', 'lu_field_popitem', 'In-Portal', 'la_text_category', 19, DEFAULT, 0, 'boolean', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;HotItem;In-Portal' => "('Category', 'HotItem', 0, 1, 'lu_fielddesc_category_hotitem', 'lu_field_hotitem', 'In-Portal', 'la_text_category', 17, DEFAULT, 0, 'boolean', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;MetaDescription;In-Portal' => "('Category', 'MetaDescription', 0, 1, 'lu_fielddesc_category_metadescription', 'lu_field_metadescription', 'In-Portal', 'la_text_category', 16, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;ParentPath;In-Portal' => "('Category', 'ParentPath', 0, 1, 'lu_fielddesc_category_parentpath', 'lu_field_parentpath', 'In-Portal', 'la_text_category', 15, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;ResourceId;In-Portal' => "('Category', 'ResourceId', 0, 1, 'lu_fielddesc_category_resourceid', 'lu_field_resourceid', 'In-Portal', 'la_text_category', 14, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;CreatedById;In-Portal' => "('Category', 'CreatedById', 0, 1, 'lu_fielddesc_category_createdbyid', 'lu_field_createdbyid', 'In-Portal', 'la_text_category', 13, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;CachedNavbar;In-Portal' => "('Category', 'CachedNavbar', 0, 1, 'lu_fielddesc_category_cachednavbar', 'lu_field_cachednavbar', 'In-Portal', 'la_text_category', 12, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;CachedDescendantCatsQty;In-Portal' => "('Category', 'CachedDescendantCatsQty', 0, 1, 'lu_fielddesc_category_cacheddescendantcatsqty', 'lu_field_cacheddescendantcatsqty', 'In-Portal', 'la_text_category', 11, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;MetaKeywords;In-Portal' => "('Category', 'MetaKeywords', 0, 1, 'lu_fielddesc_category_metakeywords', 'lu_field_metakeywords', 'In-Portal', 'la_text_category', 10, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;Priority;In-Portal' => "('Category', 'Priority', 0, 1, 'lu_fielddesc_category_priority', 'lu_field_priority', 'In-Portal', 'la_text_category', 9, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;Status;In-Portal' => "('Category', 'Status', 0, 1, 'lu_fielddesc_category_status', 'lu_field_status', 'In-Portal', 'la_text_category', 7, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;EditorsPick;In-Portal' => "('Category', 'EditorsPick', 0, 1, 'lu_fielddesc_category_editorspick', 'lu_field_editorspick', 'In-Portal', 'la_text_category', 6, DEFAULT, 0, 'boolean', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;CreatedOn;In-Portal' => "('Category', 'CreatedOn', 0, 1, 'lu_fielddesc_category_createdon', 'lu_field_createdon', 'In-Portal', 'la_text_category', 5, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;Description;In-Portal' => "('Category', 'Description', 1, 1, 'lu_fielddesc_category_description', 'lu_field_description', 'In-Portal', 'la_text_category', 4, DEFAULT, 2, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;Name;In-Portal' => "('Category', 'Name', 1, 1, 'lu_fielddesc_category_name', 'lu_field_name', 'In-Portal', 'la_text_category', 3, DEFAULT, 2, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;ParentId;In-Portal' => "('Category', 'ParentId', 0, 1, 'lu_fielddesc_category_parentid', 'lu_field_parentid', 'In-Portal', 'la_text_category', 2, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;CategoryId;In-Portal' => "('Category', 'CategoryId', 0, 1, 'lu_fielddesc_category_categoryid', 'lu_field_categoryid', 'In-Portal', 'la_text_category', 0, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;Modified;In-Portal' => "('Category', 'Modified', 0, 1, 'lu_fielddesc_category_modified', 'lu_field_modified', 'In-Portal', 'la_text_category', 20, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'Category;ModifiedById;In-Portal' => "('Category', 'ModifiedById', 0, 1, 'lu_fielddesc_category_modifiedbyid', 'lu_field_modifiedbyid', 'In-Portal', 'la_text_category', 21, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;PortalUserId;In-Portal' => "('PortalUser', 'PortalUserId', -1, 0, 'lu_fielddesc_user_portaluserid', 'lu_field_portaluserid', 'In-Portal', 'la_text_user', 0, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;Login;In-Portal' => "('PortalUser', 'Login', -1, 0, 'lu_fielddesc_user_login', 'lu_field_login', 'In-Portal', 'la_text_user', 1, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;Password;In-Portal' => "('PortalUser', 'Password', -1, 0, 'lu_fielddesc_user_password', 'lu_field_password', 'In-Portal', 'la_text_user', 2, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;tz;In-Portal' => "('PortalUser', 'tz', -1, 0, 'lu_fielddesc_user_tz', 'lu_field_tz', 'In-Portal', 'la_text_user', 17, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;dob;In-Portal' => "('PortalUser', 'dob', -1, 0, 'lu_fielddesc_user_dob', 'lu_field_dob', 'In-Portal', 'la_text_user', 16, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;Modified;In-Portal' => "('PortalUser', 'Modified', -1, 0, 'lu_fielddesc_user_modified', 'lu_field_modified', 'In-Portal', 'la_text_user', 15, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;Status;In-Portal' => "('PortalUser', 'Status', -1, 0, 'lu_fielddesc_user_status', 'lu_field_status', 'In-Portal', 'la_text_user', 14, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;ResourceId;In-Portal' => "('PortalUser', 'ResourceId', -1, 0, 'lu_fielddesc_user_resourceid', 'lu_field_resourceid', 'In-Portal', 'la_text_user', 13, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;Country;In-Portal' => "('PortalUser', 'Country', -1, 0, 'lu_fielddesc_user_country', 'lu_field_country', 'In-Portal', 'la_text_user', 12, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;Zip;In-Portal' => "('PortalUser', 'Zip', -1, 0, 'lu_fielddesc_user_zip', 'lu_field_zip', 'In-Portal', 'la_text_user', 11, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;State;In-Portal' => "('PortalUser', 'State', -1, 0, 'lu_fielddesc_user_state', 'lu_field_state', 'In-Portal', 'la_text_user', 10, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;City;In-Portal' => "('PortalUser', 'City', -1, 0, 'lu_fielddesc_user_city', 'lu_field_city', 'In-Portal', 'la_text_user', 9, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;Street;In-Portal' => "('PortalUser', 'Street', -1, 0, 'lu_fielddesc_user_street', 'lu_field_street', 'In-Portal', 'la_text_user', 8, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;Phone;In-Portal' => "('PortalUser', 'Phone', -1, 0, 'lu_fielddesc_user_phone', 'lu_field_phone', 'In-Portal', 'la_text_user', 7, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;CreatedOn;In-Portal' => "('PortalUser', 'CreatedOn', -1, 0, 'lu_fielddesc_user_createdon', 'lu_field_createdon', 'In-Portal', 'la_text_user', 6, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;Email;In-Portal' => "('PortalUser', 'Email', -1, 0, 'lu_fielddesc_user_email', 'lu_field_email', 'In-Portal', 'la_text_user', 5, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;LastName;In-Portal' => "('PortalUser', 'LastName', -1, 0, 'lu_fielddesc_user_lastname', 'lu_field_lastname', 'In-Portal', 'la_text_user', 4, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
'PortalUser;FirstName;In-Portal' => "('PortalUser', 'FirstName', -1, 0, 'lu_fielddesc_user_firstname', 'lu_field_firstname', 'In-Portal', 'la_text_user', 3, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL)",
),
),
'StatItem' => Array (
'UniqueField' => 'Module;ListLabel',
'Records' => Array (
'In-Portal;la_prompt_ActiveCategories' => "(DEFAULT, 'In-Portal', 'SELECT count(*) FROM <%prefix%>Category WHERE Status=1 ', NULL, 'la_prompt_ActiveCategories', '0', '1')",
'In-Portal;la_prompt_ActiveUsers' => "(DEFAULT, 'In-Portal', 'SELECT count(*) FROM <%prefix%>PortalUser WHERE Status=1 ', NULL, 'la_prompt_ActiveUsers', '0', '1')",
'In-Portal;la_prompt_CurrentSessions' => "(DEFAULT, 'In-Portal', 'SELECT count(*) FROM <%prefix%>UserSession', NULL, 'la_prompt_CurrentSessions', '0', '1')",
'In-Portal;la_prompt_TotalCategories' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) as CategoryCount FROM <%prefix%>Category', NULL, 'la_prompt_TotalCategories', 0, 2)",
'In-Portal;la_prompt_ActiveCategories' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS ActiveCategories FROM <%prefix%>Category WHERE Status = 1', NULL, 'la_prompt_ActiveCategories', 0, 2)",
'In-Portal;la_prompt_PendingCategories' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS PendingCategories FROM <%prefix%>Category WHERE Status = 2', NULL, 'la_prompt_PendingCategories', 0, 2)",
'In-Portal;la_prompt_DisabledCategories' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS DisabledCategories FROM <%prefix%>Category WHERE Status = 0', NULL, 'la_prompt_DisabledCategories', 0, 2)",
'In-Portal;la_prompt_NewCategories' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS NewCategories FROM <%prefix%>Category WHERE (NewItem = 1) OR ( (UNIX_TIMESTAMP() - CreatedOn) <= <%m:config name=\"Category_DaysNew\"%>*86400 AND (NewItem = 2) )', NULL, 'la_prompt_NewCategories', 0, 2)",
'In-Portal;la_prompt_CategoryEditorsPick' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) FROM <%prefix%>Category WHERE EditorsPick = 1', NULL, 'la_prompt_CategoryEditorsPick', 0, 2)",
'In-Portal;la_prompt_NewestCategoryDate' => "(DEFAULT, 'In-Portal', 'SELECT <%m:post_format field=\"MAX(CreatedOn)\" type=\"date\"%> FROM <%prefix%>Category', NULL, 'la_prompt_NewestCategoryDate', 0, 2)",
'In-Portal;la_prompt_LastCategoryUpdate' => "(DEFAULT, 'In-Portal', 'SELECT <%m:post_format field=\"MAX(Modified)\" type=\"date\"%> FROM <%prefix%>Category', NULL, 'la_prompt_LastCategoryUpdate', 0, 2)",
'In-Portal;la_prompt_TopicsUsers' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS TotalUsers FROM <%prefix%>PortalUser', NULL, 'la_prompt_TopicsUsers', 0, 2)",
'In-Portal;la_prompt_UsersActive' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS ActiveUsers FROM <%prefix%>PortalUser WHERE Status = 1', NULL, 'la_prompt_UsersActive', 0, 2)",
'In-Portal;la_prompt_UsersPending' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS PendingUsers FROM <%prefix%>PortalUser WHERE Status = 2', NULL, 'la_prompt_UsersPending', 0, 2)",
'In-Portal;la_prompt_UsersDisabled' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS DisabledUsers FROM <%prefix%>PortalUser WHERE Status = 0', NULL, 'la_prompt_UsersDisabled', 0, 2)",
'In-Portal;la_prompt_NewestUserDate' => "(DEFAULT, 'In-Portal', 'SELECT <%m:post_format field=\"MAX(CreatedOn)\" type=\"date\"%> FROM <%prefix%>PortalUser', NULL, 'la_prompt_NewestUserDate', 0, 2)",
'In-Portal;la_prompt_UsersUniqueCountries' => "(DEFAULT, 'In-Portal', 'SELECT COUNT( DISTINCT LOWER( Country ) ) FROM <%prefix%>PortalUser WHERE LENGTH(Country) > 0', NULL, 'la_prompt_UsersUniqueCountries', 0, 2)",
'In-Portal;la_prompt_UsersUniqueStates' => "(DEFAULT, 'In-Portal', 'SELECT COUNT( DISTINCT LOWER( State ) ) FROM <%prefix%>PortalUser WHERE LENGTH(State) > 0', NULL, 'la_prompt_UsersUniqueStates', 0, 2)",
'In-Portal;la_prompt_TotalUserGroups' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS TotalUserGroups FROM <%prefix%>PortalGroup', NULL, 'la_prompt_TotalUserGroups', 0, 2)",
'In-Portal;la_prompt_BannedUsers' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS BannedUsers FROM <%prefix%>PortalUser WHERE IsBanned = 1', NULL, 'la_prompt_BannedUsers', 0, 2)",
'In-Portal;la_prompt_NonExpiredSessions' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS NonExipedSessions FROM <%prefix%>UserSession WHERE Status = 1', NULL, 'la_prompt_NonExpiredSessions', 0, 2)",
'In-Portal;la_prompt_ThemeCount' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS ThemeCount FROM <%prefix%>Theme', NULL, 'la_prompt_ThemeCount', 0, 2)",
'In-Portal;la_prompt_RegionsCount' => "(DEFAULT, 'In-Portal', 'SELECT COUNT(*) AS RegionsCount FROM <%prefix%>Language', NULL, 'la_prompt_RegionsCount', 0, 2)",
'In-Portal;la_prompt_TablesCount' => "(DEFAULT, 'In-Portal', '<%m:sql_action sql=\"SHOW+TABLES\" action=\"COUNT\" field=\"*\"%>', NULL, 'la_prompt_TablesCount', 0, 2)",
'In-Portal;la_prompt_RecordsCount' => "(DEFAULT, 'In-Portal', '<%m:sql_action sql=\"SHOW+TABLE+STATUS\" action=\"SUM\" field=\"Rows\"%>', NULL, 'la_prompt_RecordsCount', 0, 2)",
'In-Portal;la_prompt_SystemFileSize' => "(DEFAULT, 'In-Portal', '<%m:custom_action sql=\"empty\" action=\"SysFileSize\"%>', NULL, 'la_prompt_SystemFileSize', 0, 2)",
'In-Portal;la_prompt_DataSize' => "(DEFAULT, 'In-Portal', '<%m:sql_action sql=\"SHOW+TABLE+STATUS\" action=\"SUM\" format_as=\"file\" field=\"Data_length\"%>', NULL, 'la_prompt_DataSize', 0, 2)",
),
),
'StylesheetSelectors' => Array (
'UniqueField' => 'SelectorId',
'Records' => Array (
'169' => "(169, 8, 'Calendar''s selected days', '.calendar tbody .selected', 'a:0:{}', '', 1, 'font-weight: bold;\\\r\\nbackground-color: #9ED7ED;\\r\\nborder: 1px solid #83B2C5;', 0)",
'118' => "(118, 8, 'Data grid row', 'td.block-data-row', 'a:0:{}', '', 2, 'border-bottom: 1px solid #cccccc;', 48)",
'81' => "(81, 8, '\"More\" link', 'a.link-more', 'a:0:{}', '', 2, 'text-decoration: underline;', 64)",
'88' => "(88, 8, 'Block data, separated rows', 'td.block-data-grid', 'a:0:{}', '', 2, 'border: 1px solid #cccccc;', 48)",
'42' => "(42, 8, 'Block Header', 'td.block-header', 'a:4:{s:5:\"color\";s:16:\"rgb(0, 159, 240)\";s:9:\"font-size\";s:4:\"20px\";s:11:\"font-weight\";s:6:\"normal\";s:7:\"padding\";s:3:\"5px\";}', 'Block Header', 1, 'font-family: Verdana, Helvetica, sans-serif;', 0)",
'76' => "(76, 8, 'Navigation bar menu', 'tr.head-nav td', 'a:0:{}', '', 1, 'vertical-align: middle;', 0)",
'48' => "(48, 8, 'Block data', 'td.block-data', 'a:2:{s:9:\"font-size\";s:5:\"12px;\";s:7:\"padding\";s:3:\"5px\";}', '', 1, '', 0)",
'78' => "(78, 8, 'Body main style', 'body', 'a:0:{}', '', 1, 'padding: 0px; \\r\\nbackground-color: #ffffff; \\r\\nfont-family: arial, verdana, helvetica; \\r\\nfont-size: small;\\r\\nwidth: auto;\\r\\nmargin: 0px;', 0)",
'58' => "(58, 8, 'Main table', 'table.main-table', 'a:0:{}', '', 1, 'width: 770px;\\r\\nmargin: 0px;\\r\\n/*table-layout: fixed;*/', 0)",
'79' => "(79, 8, 'Block: header of data block', 'span.block-data-grid-header', 'a:0:{}', '', 1, 'font-family: Arial, Helvetica, sans-serif;\\r\\ncolor: #009DF6;\\r\\nfont-size: 12px;\\r\\nfont-weight: bold;\\r\\nbackground-color: #E6EEFF;\\r\\npadding: 6px;\\r\\nwhite-space: nowrap;', 0)",
'64' => "(64, 8, 'Link', 'a', 'a:0:{}', '', 1, '', 0)",
'46' => "(46, 8, 'Product title link', 'a.link-product1', 'a:0:{}', 'Product title link', 1, 'color: #62A1DE;\\r\\nfont-size: 14px;\\r\\nfont-weight: bold;\\r\\nline-height: 20px;\\r\\npadding-bottom: 10px;', 0)",
'75' => "(75, 8, 'Copy of Main path link', 'table.main-path td a:hover', 'a:0:{}', '', 1, 'color: #ffffff;', 0)",
'160' => "(160, 8, 'Current item in navigation bar', '.checkout-step-current', 'a:0:{}', '', 1, 'color: #A20303;\\r\\nfont-weight: bold;', 0)",
'51' => "(51, 8, 'Right block data', 'td.right-block-data', 'a:1:{s:9:\"font-size\";s:4:\"11px\";}', '', 2, 'padding: 7px;\\r\\nbackground: #e3edf6 url(\"/in-commerce4/themes/default/img/bgr_login.jpg\") repeat-y scroll left top;\\r\\nborder-bottom: 1px solid #64a1df;', 48)",
'67' => "(67, 8, 'Pagination bar: text', 'table.block-pagination td', 'a:3:{s:5:\"color\";s:7:\"#8B898B\";s:9:\"font-size\";s:4:\"12px\";s:11:\"font-weight\";s:6:\"normal\";}', '', 1, '', 0)",
'45' => "(45, 8, 'Category link', 'a.subcat', 'a:0:{}', 'Category link', 1, 'color: #2069A4', 0)",
'68' => "(68, 8, 'Pagination bar: link', 'table.block-pagination td a', 'a:3:{s:5:\"color\";s:7:\"#8B898B\";s:9:\"font-size\";s:5:\"12px;\";s:11:\"font-weight\";s:6:\"normal\";}', '', 1, '', 0)",
'69' => "(69, 8, 'Product description in product list', '.product-list-description', 'a:2:{s:5:\"color\";s:7:\"#8B898B\";s:9:\"font-size\";s:4:\"12px\";}', '', 1, '', 0)",
'73' => "(73, 8, 'Main path link', 'table.main-path td a', 'a:0:{}', '', 1, 'color: #d5e231;', 0)",
'83' => "(83, 8, 'Product title link in list (shopping cart)', 'a.link-product-cart', 'a:0:{}', 'Product title link', 1, 'color: #18559C;\\r\\nfont-size: 12px;\\r\\nfont-weight: bold;\\r\\ntext-decoration: none;\\r\\n\\r\\n', 0)",
'72' => "(72, 8, 'Main path block text', 'table.main-path td', 'a:0:{}', '', 1, 'color: #ffffff;\\r\\nfont-size: 10px;\\r\\nfont-weight: normal;\\r\\npadding: 1px;\\r\\n', 0)",
'61' => "(61, 8, 'Block: header of data table', 'td.block-data-grid-header', 'a:6:{s:4:\"font\";s:28:\"Arial, Helvetica, sans-serif\";s:5:\"color\";s:7:\"#009DF6\";s:9:\"font-size\";s:4:\"12px\";s:11:\"font-weight\";s:4:\"bold\";s:16:\"background-color\";s:7:\"#E6EEFF\";s:7:\"padding\";s:3:\"6px\";}', '', 1, 'white-space: nowrap;\\r\\npadding-left: 10px;\\r\\n/*\\r\\nbackground-image: url(/in-commerce4/themes/default/img/bullet1.gif);\\r\\nbackground-position: 10px 12px;\\r\\nbackground-repeat: no-repeat;\\r\\n*/', 0)",
'65' => "(65, 8, 'Link in product list additional row', 'td.product-list-additional a', 'a:1:{s:5:\"color\";s:7:\"#8B898B\";}', '', 2, '', 64)",
'55' => "(55, 8, 'Main table, left column', 'td.main-column-left', 'a:0:{}', '', 1, 'width:180px;\\r\\nborder: 1px solid #62A1DE;\\r\\nborder-top: 0px;', 0)",
'70' => "(70, 8, 'Product title link in list (category)', 'a.link-product-category', 'a:0:{}', 'Product title link', 1, 'color: #18559C;\\r\\nfont-size: 12px;\\r\\nfont-weight: bold;\\r\\ntext-decoration: none;\\r\\n\\r\\n', 0)",
'66' => "(66, 8, 'Pagination bar block', 'table.block-pagination', 'a:0:{}', '', 1, '', 0)",
'49' => "(49, 8, 'Bulleted list inside block', 'td.block-data ul li', 'a:0:{}', '', 1, ' list-style-image: url(/in-commerce4/themes/default/img/bullet2.gif);\\r\\n margin-bottom: 10px;\\r\\n font-size: 11px;', 0)",
'87' => "(87, 8, 'Cart item input form element', 'td.cart-item-atributes input', 'a:0:{}', '', 1, 'border: 1px solid #7BB2E6;', 0)",
'119' => "(119, 8, 'Data grid row header', 'td.block-data-row-hdr', 'a:0:{}', 'Used in order preview', 2, 'background-color: #eeeeee;\\r\\nborder-bottom: 1px solid #dddddd;\\r\\nborder-top: 1px solid #cccccc;\\r\\nfont-weight: bold;', 48)",
'82' => "(82, 8, '\"More\" link image', 'a.link-more img', 'a:0:{}', '', 2, 'text-decoration: none;\\r\\npadding-left: 5px;', 64)",
'63' => "(63, 8, 'Additional info under product description in list', 'td.product-list-additional', 'a:5:{s:5:\"color\";s:7:\"#8B898B\";s:9:\"font-size\";s:4:\"11px\";s:11:\"font-weight\";s:6:\"normal\";s:10:\"border-top\";s:18:\"1px dashed #8B898B\";s:13:\"border-bottom\";s:18:\"1px dashed #8B898B\";}', '', 2, '', 48)",
'43' => "(43, 8, 'Block', 'table.block', 'a:2:{s:16:\"background-color\";s:7:\"#E3EEF9\";s:6:\"border\";s:17:\"1px solid #64A1DF\";}', 'Block', 1, 'border: 0; \\r\\nmargin-bottom: 1px;\\r\\nwidth: 100%;', 0)",
'84' => "(84, 8, 'Cart item cell', 'td.cart-item', 'a:0:{}', '', 1, 'background-color: #F6FAFF;\\r\\nborder-left: 1px solid #ffffff;\\r\\nborder-bottom: 1px solid #ffffff;\\r\\npadding: 4px;', 0)",
'57' => "(57, 8, 'Main table, right column', 'td.main-column-right', 'a:0:{}', '', 1, 'width:220px;\\r\\nborder: 1px solid #62A1DE;\\r\\nborder-top: 0px;', 0)",
'161' => "(161, 8, 'Block for sub categories', 'td.block-data-subcats', 'a:0:{}', '', 2, ' background: #FFFFFF\\r\\nurl(/in-commerce4/themes/default/in-commerce/img/bgr_categories.jpg);\\r\\n background-repeat: no-repeat;\\r\\n background-position: top right;\\r\\nborder-bottom: 5px solid #DEEAFF;\\r\\npadding-left: 10px;', 48)",
'77' => "(77, 8, 'Left block header', 'td.left-block-header', 'a:0:{}', '', 2, 'font-family : verdana, helvetica, sans-serif;\\r\\ncolor : #ffffff;\\r\\nfont-size : 12px;\\r\\nfont-weight : bold;\\r\\ntext-decoration : none;\\r\\nbackground-color: #64a1df;\\r\\npadding: 5px;\\r\\npadding-left: 7px;', 42)",
'80' => "(80, 8, 'Right block data - text', 'td.right-block-data td', 'a:1:{s:9:\"font-size\";s:5:\"11px;\";}', '', 2, '', 48)",
'53' => "(53, 8, 'Right block header', 'td.right-block-header', 'a:0:{}', '', 2, 'font-family : verdana, helvetica, sans-serif;\\r\\ncolor : #ffffff;\\r\\nfont-size : 12px;\\r\\nfont-weight : bold;\\r\\ntext-decoration : none;\\r\\nbackground-color: #64a1df;\\r\\npadding: 5px;\\r\\npadding-left: 7px;', 42)",
'85' => "(85, 8, 'Cart item cell with attributes', 'td.cart-item-attributes', 'a:0:{}', '', 1, 'background-color: #E6EEFF;\\r\\nborder-left: 1px solid #ffffff;\\r\\nborder-bottom: 1px solid #ffffff;\\r\\npadding: 4px;\\r\\ntext-align: center;\\r\\nvertical-align: middle;\\r\\nfont-size: 12px;\\r\\nfont-weight: normal;', 0)",
'86' => "(86, 8, 'Cart item cell with name', 'td.cart-item-name', 'a:0:{}', '', 1, 'background-color: #F6FAFF;\\r\\nborder-left: 1px solid #ffffff;\\r\\nborder-bottom: 1px solid #ffffff;\\r\\npadding: 3px;', 0)",
'47' => "(47, 8, 'Block content of featured product', 'td.featured-block-data', 'a:0:{}', '', 1, 'font-family: Arial,Helvetica,sans-serif;\\r\\nfont-size: 12px;', 0)",
'56' => "(56, 8, 'Main table, middle column', 'td.main-column-center', 'a:0:{}', '', 1, '\\r\\n', 0)",
'50' => "(50, 8, 'Product title link in list', 'a.link-product2', 'a:0:{}', 'Product title link', 1, 'color: #62A1DE;\\r\\nfont-size: 12px;\\r\\nfont-weight: bold;\\r\\ntext-decoration: none;\\r\\n\\r\\n', 0)",
'71' => "(71, 8, 'Main path block', 'table.main-path', 'a:0:{}', '', 1, 'background: #61b0ec url(\"/in-commerce4/themes/default/img/bgr_path.jpg\") repeat-y scroll left top;\\r\\nwidth: 100%;\\r\\nmargin-bottom: 1px;\\r\\nmargin-right: 1px; \\r\\nmargin-left: 1px;', 0)",
'62' => "(62, 8, 'Block: columns header for data table', 'table.block-no-border th', 'a:6:{s:4:\"font\";s:28:\"Arial, Helvetica, sans-serif\";s:5:\"color\";s:7:\"#18559C\";s:9:\"font-size\";s:4:\"11px\";s:11:\"font-weight\";s:4:\"bold\";s:16:\"background-color\";s:7:\"#B4D2EE\";s:7:\"padding\";s:3:\"6px\";}', '', 1, 'text-align: left;', 0)",
'59' => "(59, 8, 'Block without border', 'table.block-no-border', 'a:0:{}', '', 1, 'border: 0px; \\r\\nmargin-bottom: 10px;\\r\\nwidth: 100%;', 0)",
'74' => "(74, 8, 'Main path language selector cell', 'td.main-path-language', 'a:0:{}', '', 1, 'vertical-align: middle;\\r\\ntext-align: right;\\r\\npadding-right: 6px;', 0)",
'171' => "(171, 8, 'Calendar''s highlighted day', '.calendar tbody .hilite', 'a:0:{}', '', 1, 'background-color: #f6f6f6;\\r\\nborder: 1px solid #83B2C5 !important;', 0)",
'175' => "(175, 8, 'Calendar''s days', '.calendar tbody .day', 'a:0:{}', '', 1, 'text-align: right;\\r\\npadding: 2px 4px 2px 2px;\\r\\nwidth: 2em;\\r\\nborder: 1px solid #fefefe;', 0)",
'170' => "(170, 8, 'Calendar''s weekends', '.calendar .weekend', 'a:0:{}', '', 1, 'color: #990000;', 0)",
'173' => "(173, 8, 'Calendar''s control buttons', '.calendar .calendar_button', 'a:0:{}', '', 1, 'color: black;\\r\\nfont-size: 12px;\\r\\nbackground-color: #eeeeee;', 0)",
'174' => "(174, 8, 'Calendar''s day names', '.calendar thead .name', 'a:0:{}', '', 1, 'background-color: #DEEEF6;\\r\\nborder-bottom: 1px solid #000000;', 0)",
'172' => "(172, 8, 'Calendar''s top and bottom titles', '.calendar .title', 'a:0:{}', '', 1, 'color: #FFFFFF;\\r\\nbackground-color: #62A1DE;\\r\\nborder: 1px solid #107DC5;\\r\\nborder-top: 0px;\\r\\npadding: 1px;', 0)",
'60' => "(60, 8, 'Block header for featured product', 'td.featured-block-header', 'a:0:{}', '', 2, '\\r\\n', 42)",
'54' => "(54, 8, 'Right block', 'table.right-block', 'a:0:{}', '', 2, 'background-color: #E3EEF9;\\r\\nborder: 0px;\\r\\nwidth: 100%;', 43)",
'44' => "(44, 8, 'Block content', 'td.block-data-big', 'a:0:{}', 'Block content', 1, ' background: #DEEEF6\\r\\nurl(/in-commerce4/themes/default/img/menu_bg.gif);\\r\\n background-repeat: no-repeat;\\r\\n background-position: top right;\\r\\n', 0)",
),
),
'Stylesheets' => Array (
'UniqueField' => 'StylesheetId',
'Records' => Array (
'8' => "(8, 'Default', 'In-Portal Default Theme', '', 1124952555, 1)",
),
),
'Counters' => Array (
'UniqueField' => 'Name',
'Records' => Array (
'members_count' => "(DEFAULT, 'members_count', 'SELECT COUNT(*) FROM <%PREFIX%>PortalUser WHERE Status = 1', NULL , NULL , '3600', '0', '|PortalUser|')",
'members_online' => "(DEFAULT, 'members_online', 'SELECT COUNT(*) FROM <%PREFIX%>UserSession WHERE PortalUserId > 0', NULL , NULL , '3600', '0', '|UserSession|')",
'guests_online' => "(DEFAULT, 'guests_online', 'SELECT COUNT(*) FROM <%PREFIX%>UserSession WHERE PortalUserId <= 0', NULL , NULL , '3600', '0', '|UserSession|')",
'users_online' => "(DEFAULT, 'users_online', 'SELECT COUNT(*) FROM <%PREFIX%>UserSession', NULL , NULL , '3600', '0', '|UserSession|')",
),
),
);
// check & insert if not found defined before data
foreach ($data as $table_name => $table_info) {
$unique_fields = explode(';', $table_info['UniqueField']);
foreach ($table_info['Records'] as $unique_value => $insert_sql) {
$unique_values = explode(';', $unique_value);
$where_clause = Array ();
foreach ($unique_fields as $field_index => $unique_field) {
$where_clause[] = $unique_field . ' = ' . $this->Conn->qstr($unique_values[$field_index]);
}
$sql = 'SELECT ' . implode(', ', $unique_fields) . '
FROM ' . TABLE_PREFIX . $table_name . '
WHERE (' . implode(') AND (', $where_clause) . ')';
$found = $this->Conn->GetRow($sql);
if ($found) {
$found = implode(';', $found);
}
if ($found != $unique_value) {
$this->Conn->Query('INSERT INTO ' . TABLE_PREFIX . $table_name . ' VALUES ' . $insert_sql);
}
}
}
}
/**
* Removes duplicate phrases per language basis (created during proj-base and in-portal shared installation)
*
*/
function _removeDuplicatePhrases()
{
$id_field = $this->Application->getUnitOption('phrases', 'IDField');
$table_name = $this->Application->getUnitOption('phrases', 'TableName');
$sql = 'SELECT LanguageId, Phrase, MIN(LastChanged) AS LastChanged, COUNT(*) AS DupeCount
FROM ' . $table_name . '
GROUP BY LanguageId, Phrase
HAVING COUNT(*) > 1';
$duplicate_phrases = $this->Conn->Query($sql);
foreach ($duplicate_phrases as $phrase_record) {
// 1. keep phrase, that was added first, because it is selected in PhrasesCache::LoadPhraseByLabel
$where_clause = Array (
'LanguageId = ' . $phrase_record['LanguageId'],
'Phrase = ' . $this->Conn->qstr($phrase_record['Phrase']),
'LastChanged' . ' = ' . $phrase_record['LastChanged'],
);
$sql = 'SELECT ' . $id_field . '
FROM ' . $table_name . '
WHERE (' . implode(') AND (', $where_clause) . ')';
$phrase_id = $this->Conn->GetOne($sql);
// 2. delete all other duplicates
$where_clause = Array (
'LanguageId = ' . $phrase_record['LanguageId'],
'Phrase = ' . $this->Conn->qstr($phrase_record['Phrase']),
$id_field . ' <> ' . $phrase_id,
);
$sql = 'DELETE FROM ' . $table_name . '
WHERE (' . implode(') AND (', $where_clause) . ')';
$this->Conn->Query($sql);
}
}
function _moveDatabaseFolders()
{
// Tables: PageContent, Images
if ($this->Conn->TableFound('PageContent', true)) {
// 1. replaces "/kernel/user_files/" references in content blocks
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
/* @var $ml_helper kMultiLanguageHelper */
$languages = $ml_helper->getLanguages();
$replace_sql = '%1$s = REPLACE(%1$s, "/kernel/user_files/", "/system/user_files/")';
$update_sqls = Array ();
foreach ($languages as $language_id) {
$update_sqls[] = sprintf($replace_sql, 'l' . $language_id . '_Content');
}
if ($update_sqls) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'PageContent
SET ' . implode(', ', $update_sqls);
$this->Conn->Query($sql);
}
}
// 2. replace path of images uploaded via "Images" tab of category items
$this->_replaceImageFolder('/kernel/images/', '/system/images/');
// 3. replace path of images uploaded via "Images" tab of category items (when badly formatted)
$this->_replaceImageFolder('kernel/images/', 'system/images/');
// 4. replace images uploaded via "In-Bulletin -> Emoticons" section
$this->_replaceImageFolder('in-bulletin/images/emoticons/', 'system/images/emoticons/');
// 5. update backup path in config
$this->_toolkit->saveConfigValues(
Array (
'Backup_Path' => FULL_PATH . '/system/backupdata'
)
);
}
/**
* Replaces mentions of "/kernel/images" folder in Images table
*
* @param string $from
* @param string $to
*/
function _replaceImageFolder($from, $to)
{
$replace_sql = '%1$s = REPLACE(%1$s, "' . $from . '", "' . $to . '")';
$sql = 'UPDATE ' . TABLE_PREFIX . 'Images
SET ' . sprintf($replace_sql, 'ThumbPath') . ', ' . sprintf($replace_sql, 'LocalPath');
$this->Conn->Query($sql);
}
/**
* Update colors in skin (only if they were not changed manually)
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_5_0_0($mode)
{
if ($mode == 'before') {
$this->_removeDuplicatePhrases(); // because In-Commerce & In-Link share some phrases with Proj-CMS
$this->_createProjCMSTables();
$this->_addMissingConfigurationVariables();
}
if ($mode == 'after') {
$this->_fixSkinColors();
$this->_restructureCatalog();
$this->_sortImages();
// $this->_sortConfigurationVariables('In-Portal', 'in-portal:configure_general');
// $this->_sortConfigurationVariables('In-Portal', 'in-portal:configure_advanced');
}
}
function _sortConfigurationVariables($module, $section)
{
$sql = 'SELECT ca.heading, cv.VariableName
FROM ' . TABLE_PREFIX . 'ConfigurationAdmin ca
LEFT JOIN ' . TABLE_PREFIX . 'ConfigurationValues cv USING(VariableName)
WHERE (cv.ModuleOwner = ' . $this->Conn->qstr($module) . ') AND (cv.Section = ' . $this->Conn->qstr($section) . ')
ORDER BY ca.DisplayOrder asc, ca.GroupDisplayOrder asc';
$variables = $this->Conn->GetCol($sql, 'VariableName');
if (!$variables) {
return ;
}
$variables = $this->_groupRecords($variables);
$group_number = 0;
$variable_order = 1;
$prev_heading = '';
foreach ($variables as $variable_name => $variable_heading) {
if ($prev_heading != $variable_heading) {
$group_number++;
$variable_order = 1;
}
$sql = 'UPDATE ' . TABLE_PREFIX . 'ConfigurationAdmin
SET DisplayOrder = ' . $this->Conn->qstr($group_number * 10 + $variable_order / 100) . '
WHERE VariableName = ' . $this->Conn->qstr($variable_name);
$this->Conn->Query($sql);
$variable_order++;
$prev_heading = $variable_heading;
}
}
/**
* Group list records by header, saves internal order in group
*
* @param Array $variables
* @return Array
*/
function _groupRecords($variables)
{
$sorted = Array();
foreach ($variables as $variable_name => $variable_heading) {
$sorted[$variable_heading][] = $variable_name;
}
$variables = Array();
foreach ($sorted as $heading => $heading_records) {
foreach ($heading_records as $variable_name) {
$variables[$variable_name] = $heading;
}
}
return $variables;
}
/**
* Returns module root category
*
* @param string $module_name
* @param string $module_prefix
* @return int
*/
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
FROM ' . TABLE_PREFIX . 'Modules
WHERE LOWER(Name) = ' . $this->Conn->qstr( strtolower($module_name) );
$root_category = $this->Conn->GetOne($sql);
// 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;
}
/**
* Move all categories (except "Content") from "Home" to "Content" category and hide them from menu
*
*/
function _restructureCatalog()
{
$root_category = $this->_getRootCategory('Core', 'adm');
$sql = 'SELECT CategoryId
FROM ' . TABLE_PREFIX . 'Category
WHERE ParentId = 0 AND CategoryId <> ' . $root_category;
$top_categories = $this->Conn->GetCol($sql);
if ($top_categories) {
// hide all categories located outside "Content" category from menu
$sql = 'UPDATE ' . TABLE_PREFIX . 'Category
SET IsMenu = 0
WHERE (ParentPath LIKE "|' . implode('|%") OR (ParentPath LIKE "|', $top_categories) . '|%")';
$this->Conn->Query($sql);
// move all top level categories under "Content" category and make them visible in menu
$sql = 'UPDATE ' . TABLE_PREFIX . 'Category
SET IsMenu = 1, ParentId = ' . $root_category . '
WHERE ParentId = 0 AND CategoryId <> ' . $root_category;
$this->Conn->Query($sql);
}
// make sure, that all categories have valid value for Priority field
$priority_helper = $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
$event = new kEvent('c:OnListBuild');
// update all categories, because they are all under "Content" category now
$sql = 'SELECT CategoryId
FROM ' . TABLE_PREFIX . 'Category';
$categories = $this->Conn->GetCol($sql);
foreach ($categories as $category_id) {
$priority_helper->recalculatePriorities($event, 'ParentId = ' . $category_id);
}
// create initial theme structure in Category table
$this->_toolkit->rebuildThemes();
// make sure, that all system templates have ThemeId set (only possible during platform project upgrade)
$sql = 'SELECT ThemeId
FROM ' . TABLE_PREFIX . 'Theme
WHERE PrimaryTheme = 1';
$primary_theme_id = $this->Conn->GetOne($sql);
if ($primary_theme_id) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'Category
SET ThemeId = ' . $primary_theme_id . '
WHERE IsSystem = 1 AND ThemeId = 0';
$this->Conn->Query($sql);
}
}
/**
* Changes skin colors to match new ones (only in case, when they match default values)
*
*/
function _fixSkinColors()
{
$skin = $this->Application->recallObject('skin', null, Array ('skip_autoload' => 1));
/* @var $skin kDBItem */
$skin->Load(1, 'IsPrimary');
if ($skin->isLoaded()) {
$skin_options = unserialize( $skin->GetDBField('Options') );
$changes = Array (
// 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;
foreach ($changes as $option_name => $change) {
list ($change_from, $change_to) = $change;
$can_change = $can_change && ($change_from == $skin_options[$option_name]['Value']);
if ($can_change) {
$skin_options[$option_name]['Value'] = $change_to;
}
}
if ($can_change) {
$skin->SetDBField('Options', serialize($skin_options));
$skin->Update();
$skin_helper = $this->Application->recallObject('SkinHelper');
/* @var $skin_helper SkinHelper */
$skin_file = $skin_helper->getSkinPath();
if (file_exists($skin_file)) {
unlink($skin_file);
}
}
}
}
/**
* 1. Set root category not to generate filename automatically and hide it from catalog
* 2. Hide root category of In-Edit and set it's fields
*
* @param int $category_id
*/
function _resetRootCategory($category_id)
{
$fields_hash = Array (
'l1_Name' => 'Content', 'Filename' => 'Content', 'AutomaticFilename' => 0,
'l1_Description' => 'Content', 'Status' => 4,
);
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Category', 'CategoryId = ' . $category_id);
}
function _createProjCMSTables()
{
// 0. make sure, that Content category exists
$root_category = $this->_getRootCategory('Proj-CMS', 'st');
if ($root_category) {
// proj-cms module found -> remove it
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Modules
WHERE Name = "Proj-CMS"';
$this->Conn->Query($sql);
unset($this->Application->ModuleInfo['Proj-CMS']);
$this->_resetRootCategory($root_category);
// unhide all structure categories
$sql = 'UPDATE ' . TABLE_PREFIX . 'Category
SET Status = 1
WHERE (Status = 4) AND (CategoryId <> ' . $root_category . ')';
$this->Conn->Query($sql);
} else {
$root_category = $this->_getRootCategory('In-Edit', 'cms');
if ($root_category) {
// in-edit module found -> remove it
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Modules
WHERE Name = "In-Edit"';
$this->Conn->Query($sql);
unset($this->Application->ModuleInfo['In-Edit']);
$this->_resetRootCategory($root_category);
}
}
if (!$root_category) {
// create "Content" category when Proj-CMS/In-Edit module was not installed before
// use direct sql here, because category table structure doesn't yet match table structure in object
$fields_hash = Array (
'l1_Name' => 'Content', 'Filename' => 'Content', 'AutomaticFilename' => 0,
'l1_Description' => 'Content', 'Status' => 4,
);
$this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'Category');
$root_category = $this->Conn->getInsertID();
}
$this->_toolkit->deleteCache();
$this->_toolkit->SetModuleRootCategory('Core', $root_category);
// 1. process "Category" table
$structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'Category', 'Field');
if (!array_key_exists('Template', $structure)) {
// fields from "Pages" table were not added to "Category" table (like before "Proj-CMS" module install)
$sql = "ALTER TABLE " . TABLE_PREFIX . "Category
ADD COLUMN Template varchar(255) default NULL,
ADD COLUMN l1_Title varchar(255) default '',
ADD COLUMN l2_Title varchar(255) default '',
ADD COLUMN l3_Title varchar(255) default '',
ADD COLUMN l4_Title varchar(255) default '',
ADD COLUMN l5_Title varchar(255) default '',
ADD COLUMN l1_MenuTitle varchar(255) NOT NULL default '',
ADD COLUMN l2_MenuTitle varchar(255) NOT NULL default '',
ADD COLUMN l3_MenuTitle varchar(255) NOT NULL default '',
ADD COLUMN l4_MenuTitle varchar(255) NOT NULL default '',
ADD COLUMN l5_MenuTitle varchar(255) NOT NULL default '',
ADD COLUMN MetaTitle text,
ADD COLUMN IndexTools text,
ADD COLUMN IsIndex tinyint(1) NOT NULL default '0',
ADD COLUMN IsMenu TINYINT(4) NOT NULL DEFAULT '1',
ADD COLUMN IsSystem tinyint(4) NOT NULL default '0',
ADD COLUMN FormId int(11) default NULL,
ADD COLUMN FormSubmittedTemplate varchar(255) default NULL,
ADD COLUMN l1_Translated tinyint(4) NOT NULL default '0',
ADD COLUMN l2_Translated tinyint(4) NOT NULL default '0',
ADD COLUMN l3_Translated tinyint(4) NOT NULL default '0',
ADD COLUMN l4_Translated tinyint(4) NOT NULL default '0',
ADD COLUMN l5_Translated tinyint(4) NOT NULL default '0',
ADD COLUMN FriendlyURL varchar(255) NOT NULL default '',
ADD INDEX IsIndex (IsIndex),
ADD INDEX l1_Translated (l1_Translated),
ADD INDEX l2_Translated (l2_Translated),
ADD INDEX l3_Translated (l3_Translated),
ADD INDEX l4_Translated (l4_Translated),
ADD INDEX l5_Translated (l5_Translated)";
$this->Conn->Query($sql);
}
if (array_key_exists('Path', $structure)) {
$sql = 'ALTER TABLE ' . TABLE_PREFIX . 'Category
DROP Path';
$this->Conn->Query($sql);
}
// 2. process "PageContent" table
if ($this->Conn->TableFound(TABLE_PREFIX . 'PageContent', true)) {
$structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'PageContent', 'Field');
if (!array_key_exists('l1_Translated', $structure)) {
$sql = "ALTER TABLE " . TABLE_PREFIX . "PageContent
ADD COLUMN l1_Translated tinyint(4) NOT NULL default '0',
ADD COLUMN l2_Translated tinyint(4) NOT NULL default '0',
ADD COLUMN l3_Translated tinyint(4) NOT NULL default '0',
ADD COLUMN l4_Translated tinyint(4) NOT NULL default '0',
ADD COLUMN l5_Translated tinyint(4) NOT NULL default '0'";
$this->Conn->Query($sql);
}
}
// 3. process "FormFields" table
if ($this->Conn->TableFound(TABLE_PREFIX . 'FormFields', true)) {
$structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'FormFields', 'Field');
if (!$structure['FormId']['Key']) {
$sql = "ALTER TABLE " . TABLE_PREFIX . "FormFields
CHANGE Validation Validation TINYINT NOT NULL DEFAULT '0',
ADD INDEX FormId (FormId),
ADD INDEX Priority (Priority),
ADD INDEX IsSystem (IsSystem),
ADD INDEX DisplayInGrid (DisplayInGrid)";
$this->Conn->Query($sql);
}
}
else {
$this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:forms.view', 11, 1, 1, 0)");
$this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:forms.add', 11, 1, 1, 0)");
$this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:forms.edit', 11, 1, 1, 0)");
$this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:forms.delete', 11, 1, 1, 0)");
}
// 4. process "FormSubmissions" table
if ($this->Conn->TableFound(TABLE_PREFIX . 'FormSubmissions', true)) {
$structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'FormSubmissions', 'Field');
if (!$structure['SubmissionTime']['Key']) {
$sql = "ALTER TABLE " . TABLE_PREFIX . "FormSubmissions
ADD INDEX SubmissionTime (SubmissionTime)";
$this->Conn->Query($sql);
}
}
else {
$this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:submissions.view', 11, 1, 1, 0)");
}
// 5. add missing event
$sql = 'SELECT EventId
FROM ' . TABLE_PREFIX . 'Events
WHERE (Event = "FORM.SUBMITTED") AND (Type = 1)';
$event_id = $this->Conn->GetOne($sql);
if (!$event_id) {
$sql = "INSERT INTO " . TABLE_PREFIX . "Events VALUES (DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, 'Core:Category', 'la_event_FormSubmitted', 1)";
$this->Conn->Query($sql);
}
$sql = 'SELECT EventId
FROM ' . TABLE_PREFIX . 'Events
WHERE (Event = "FORM.SUBMITTED") AND (Type = 0)';
$event_id = $this->Conn->GetOne($sql);
if (!$event_id) {
$sql = "INSERT INTO " . TABLE_PREFIX . "Events VALUES (DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, 'Core:Category', 'la_event_FormSubmitted', 0)";
$this->Conn->Query($sql);
}
}
function _addMissingConfigurationVariables()
{
$variables = Array (
'cms_DefaultDesign' => Array (
"INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('cms_DefaultDesign', 'la_Text_General', 'la_prompt_DefaultDesignTemplate', 'text', NULL, NULL, 10.15, 0, 0)",
"INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'cms_DefaultDesign', '/platform/designs/general', 'In-Portal', 'in-portal:configure_categories')",
),
'Require_AdminSSL' => Array (
"INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('Require_AdminSSL', 'la_Text_Website', 'la_config_RequireSSLAdmin', 'checkbox', '', '', 10.105, 0, 1)",
"INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'Require_AdminSSL', '', 'In-Portal', 'in-portal:configure_advanced')",
),
'UsePopups' => Array (
"INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('UsePopups', 'la_Text_Website', 'la_config_UsePopups', 'radio', '', '1=la_Yes,0=la_No', 10.221, 0, 0)",
"INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'UsePopups', '1', 'In-Portal', 'in-portal:configure_advanced')",
),
'UseDoubleSorting' => Array (
"INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('UseDoubleSorting', 'la_Text_Website', 'la_config_UseDoubleSorting', 'radio', '', '1=la_Yes,0=la_No', 10.222, 0, 0)",
"INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'UseDoubleSorting', '0', 'In-Portal', 'in-portal:configure_advanced')",
),
'MenuFrameWidth' => Array (
"INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('MenuFrameWidth', 'la_title_General', 'la_prompt_MenuFrameWidth', 'text', NULL, NULL, 10.31, 0, 0)",
"INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'MenuFrameWidth', 200, 'In-Portal', 'in-portal:configure_advanced')",
),
'DefaultSettingsUserId' => Array (
"INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('DefaultSettingsUserId', 'la_title_General', 'la_prompt_DefaultUserId', 'text', NULL, NULL, '10.06', '0', '0')",
"INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'DefaultSettingsUserId', -1, 'In-Portal:Users', 'in-portal:configure_users')",
),
);
foreach ($variables as $variable_name => $variable_sqls) {
$sql = 'SELECT VariableId
FROM ' . TABLE_PREFIX . 'ConfigurationValues
WHERE VariableName = ' . $this->Conn->qstr($variable_name);
$variable_id = $this->Conn->GetOne($sql);
if ($variable_id) {
continue;
}
foreach ($variable_sqls as $variable_sql) {
$this->Conn->Query($variable_sql);
}
}
}
/**
* Sort images in database (update Priority field)
*
*/
function _sortImages()
{
$sql = 'SELECT *
FROM ' . TABLE_PREFIX . 'Images
ORDER BY ResourceId ASC , DefaultImg DESC , ImageId ASC';
$images = $this->Conn->Query($sql);
$priority = 0;
$last_resource_id = false;
foreach ($images as $image) {
if ($image['ResourceId'] != $last_resource_id) {
// each item have own priorities among it's images
$priority = 0;
$last_resource_id = $image['ResourceId'];
}
if (!$image['DefaultImg']) {
$priority--;
}
$sql = 'UPDATE ' . TABLE_PREFIX . 'Images
SET Priority = ' . $priority . '
WHERE ImageId = ' . $image['ImageId'];
$this->Conn->Query($sql);
}
}
/**
* Update to 5.0.1
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_5_0_1($mode)
{
if ($mode == 'after') {
// delete old events
$events_to_delete = Array ('CATEGORY.MODIFY', 'CATEGORY.DELETE');
$sql = 'SELECT EventId
FROM ' . TABLE_PREFIX . 'Events
WHERE Event IN ("' . implode('","', $events_to_delete) . '")';
$event_ids = $this->Conn->GetCol($sql);
if ($event_ids) {
$this->_deleteEvents($event_ids);
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Phrase
WHERE Phrase IN ("la_event_category.modify", "la_event_category.delete")';
$this->Conn->Query($sql);
}
// partially delete events
$sql = 'SELECT EventId
FROM ' . TABLE_PREFIX . 'Events
WHERE (Event IN ("CATEGORY.APPROVE", "CATEGORY.DENY")) AND (Type = ' . EmailEvent::EVENT_TYPE_ADMIN . ')';
$event_ids = $this->Conn->GetCol($sql);
if ($event_ids) {
$this->_deleteEvents($event_ids);
}
}
}
function _deleteEvents($ids)
{
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'EmailMessage
WHERE EventId IN (' . implode(',', $ids) . ')';
$this->Conn->Query($sql);
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Events
WHERE EventId IN (' . implode(',', $ids) . ')';
$this->Conn->Query($sql);
}
/**
* Update to 5.0.2-B2; Transforms IsIndex field values to SymLinkCategoryId field
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_5_0_2_B2($mode)
{
// 0 - Regular, 1 - Category Index, 2 - Container
if ($mode == 'before') {
// fix "Content" category
$fields_hash = Array (
'CreatedById' => USER_ROOT,
'CreatedOn' => time(),
'ResourceId' => $this->Application->NextResourceId(),
);
$category_id = $this->Application->findModule('Name', 'Core', 'RootCat');
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Category', 'CategoryId = ' . $category_id);
// get all categories, marked as category index
$sql = 'SELECT ParentPath, CategoryId
FROM ' . TABLE_PREFIX . 'Category
WHERE IsIndex = 1';
$category_indexes = $this->Conn->GetCol($sql, 'CategoryId');
foreach ($category_indexes as $category_id => $parent_path) {
$parent_path = explode('|', substr($parent_path, 1, -1));
// set symlink to $category_id for each category, marked as container in given category path
$sql = 'SELECT CategoryId
FROM ' . TABLE_PREFIX . 'Category
WHERE CategoryId IN (' . implode(',', $parent_path) . ') AND (IsIndex = 2)';
$category_containers = $this->Conn->GetCol($sql);
if ($category_containers) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'Category
SET SymLinkCategoryId = ' . $category_id . '
WHERE CategoryId IN (' . implode(',', $category_containers) . ')';
$this->Conn->Query($sql);
}
}
}
if ($mode == 'after') {
// scan theme to fill Theme.TemplateAliases and ThemeFiles.TemplateAlias fields
$this->_toolkit->rebuildThemes();
$sql = 'SELECT TemplateAliases, ThemeId
FROM ' . TABLE_PREFIX . 'Theme
WHERE (Enabled = 1) AND (TemplateAliases <> "")';
$template_aliases = $this->Conn->GetCol($sql, 'ThemeId');
$all_template_aliases = Array (); // reversed alias (from real template to alias)
foreach ($template_aliases as $theme_id => $theme_template_aliases) {
$theme_template_aliases = unserialize($theme_template_aliases);
if (!$theme_template_aliases) {
continue;
}
$all_template_aliases = array_merge($all_template_aliases, array_flip($theme_template_aliases));
}
$default_design_replaced = false;
$default_design = trim($this->Application->ConfigValue('cms_DefaultDesign'), '/');
foreach ($all_template_aliases as $from_template => $to_alias) {
// replace default design in configuration variable (when matches alias)
if ($from_template == $default_design) {
// specific alias matched
$sql = 'UPDATE ' . TABLE_PREFIX . 'ConfigurationValues
SET VariableValue = ' . $this->Conn->qstr($to_alias) . '
WHERE VariableName = "cms_DefaultDesign"';
$this->Conn->Query($sql);
$default_design_replaced = true;
}
// replace Category.Template and Category.CachedTemplate fields (when matches alias)
$sql = 'UPDATE ' . TABLE_PREFIX . 'Category
SET Template = ' . $this->Conn->qstr($to_alias) . '
WHERE Template IN (' . $this->Conn->qstr('/' . $from_template) . ',' . $this->Conn->qstr($from_template) . ')';
$this->Conn->Query($sql);
$sql = 'UPDATE ' . TABLE_PREFIX . 'Category
SET CachedTemplate = ' . $this->Conn->qstr($to_alias) . '
WHERE CachedTemplate IN (' . $this->Conn->qstr('/' . $from_template) . ',' . $this->Conn->qstr($from_template) . ')';
$this->Conn->Query($sql);
}
if (!$default_design_replaced) {
// in case if current default design template doesn't
// match any of aliases, then set it to #default_design#
$sql = 'UPDATE ' . TABLE_PREFIX . 'ConfigurationValues
SET VariableValue = "#default_design#"
WHERE VariableName = "cms_DefaultDesign"';
$this->Conn->Query($sql);
}
// replace data in category custom fields used for category item template storage
$rewrite_processor = $this->Application->recallObject('kRewriteUrlProcessor');
/* @var $rewrite_processor kRewriteUrlProcessor */
foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
$custom_field_id = $rewrite_processor->getItemTemplateCustomField($module_info['Var']);
if (!$custom_field_id) {
continue;
}
foreach ($all_template_aliases as $from_template => $to_alias) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'CategoryCustomData
SET l1_cust_' . $custom_field_id . ' = ' . $this->Conn->qstr($to_alias) . '
WHERE l1_cust_' . $custom_field_id . ' = ' . $this->Conn->qstr($from_template);
$this->Conn->Query($sql);
}
}
}
}
/**
* Update to 5.0.3-B2; Moves CATEGORY.* permission from module root categories to Content category
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_5_0_3_B2($mode)
{
if ($mode == 'before') {
// get permissions
$sql = 'SELECT PermissionName
FROM ' . TABLE_PREFIX . 'PermissionConfig
WHERE PermissionName LIKE "CATEGORY.%"';
$permission_names = $this->Conn->GetCol($sql);
// get groups
$sql = 'SELECT GroupId
FROM ' . TABLE_PREFIX . 'PortalGroup';
$user_groups = $this->Conn->GetCol($sql);
$user_group_count = count($user_groups);
// get module root categories
$sql = 'SELECT RootCat
FROM ' . TABLE_PREFIX . 'Modules';
$module_categories = $this->Conn->GetCol($sql);
$module_categories[] = 0;
$module_categories = implode(',', array_unique($module_categories));
$permissions = $delete_permission_ids = Array ();
foreach ($permission_names as $permission_name) {
foreach ($user_groups as $group_id) {
$sql = 'SELECT PermissionId
FROM ' . TABLE_PREFIX . 'Permissions
WHERE (Permission = ' . $this->Conn->qstr($permission_name) . ') AND (PermissionValue = 1) AND (GroupId = ' . $group_id . ') AND (`Type` = 0) AND (CatId IN (' . $module_categories . '))';
$permission_ids = $this->Conn->GetCol($sql);
if ($permission_ids) {
if (!array_key_exists($permission_name, $permissions)) {
$permissions[$permission_name] = Array ();
}
$permissions[$permission_name][] = $group_id;
$delete_permission_ids = array_merge($delete_permission_ids, $permission_ids);
}
}
}
if ($delete_permission_ids) {
// here we can delete some of permissions that will be added later
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Permissions
WHERE PermissionId IN (' . implode(',', $delete_permission_ids) . ')';
$this->Conn->Query($sql);
}
$home_category = $this->Application->findModule('Name', 'Core', 'RootCat');
foreach ($permissions as $permission_name => $permission_groups) {
// optimize a bit
$has_everyone = in_array(15, $permission_groups);
if ($has_everyone || (!$has_everyone && count($permission_groups) == $user_group_count - 1)) {
// has permission for "Everyone" group OR allowed in all groups except "Everyone" group
// so remove all other explicitly allowed permissions
$permission_groups = Array (15);
}
foreach ($permission_groups as $group_id) {
$fields_hash = Array (
'Permission' => $permission_name,
'GroupId' => $group_id,
'PermissionValue' => 1,
'Type' => 0, // category-based permission,
'CatId' => $home_category,
);
$this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'Permissions');
}
}
$updater = $this->Application->makeClass('kPermCacheUpdater');
/* @var $updater kPermCacheUpdater */
$updater->OneStepRun();
}
}
/**
* Update to 5.1.0-B1; Makes email message fields multilingual
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_5_1_0_B1($mode)
{
- if ($mode == 'before') {
+ if ( $mode == 'before' ) {
+ $this->_renameTables('from');
+
// migrate email events
$table_structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'Events', 'Field');
if (!array_key_exists('Headers', $table_structure)) {
$sql = 'ALTER TABLE ' . TABLE_PREFIX . 'Events
ADD `Headers` TEXT NULL AFTER `ReplacementTags`,
ADD `MessageType` VARCHAR(4) NOT NULL default "text" AFTER `Headers`';
$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');
$languages = $ml_helper->getLanguages();
if ($this->Conn->TableFound(TABLE_PREFIX . 'EmailMessage', true)) {
$email_message_helper = $this->Application->recallObject('EmailMessageHelper');
/* @var $email_message_helper EmailMessageHelper */
foreach ($languages as $language_id) {
$sql = 'SELECT EmailMessageId, Template, EventId
FROM ' . TABLE_PREFIX . 'EmailMessage
WHERE LanguageId = ' . $language_id;
$translations = $this->Conn->Query($sql, 'EventId');
foreach ($translations as $event_id => $translation_data) {
$parsed = $email_message_helper->parseTemplate($translation_data['Template']);
$fields_hash = Array (
'l' . $language_id . '_Subject' => $parsed['Subject'],
'l' . $language_id . '_Body' => $parsed['Body'],
);
if ($parsed['Headers']) {
$fields_hash['Headers'] = $parsed['Headers'];
}
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Events', 'EventId = ' . $event_id);
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'EmailMessage
WHERE EmailMessageId = ' . $translation_data['EmailMessageId'];
$this->Conn->Query($sql);
}
}
}
// migrate phrases
$temp_table = $this->Application->GetTempName(TABLE_PREFIX . 'Phrase');
$sqls = Array (
'DROP TABLE IF EXISTS ' . $temp_table,
'CREATE TABLE ' . $temp_table . ' LIKE ' . TABLE_PREFIX . 'Phrase',
'ALTER TABLE ' . $temp_table . ' DROP LanguageId, DROP Translation',
'ALTER IGNORE TABLE ' . $temp_table . ' DROP INDEX LanguageId_2',
'ALTER TABLE ' . $temp_table . ' DROP PhraseId',
'ALTER TABLE ' . $temp_table . ' ADD PhraseId INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST',
);
foreach ($sqls as $sql) {
$this->Conn->Query($sql);
}
$already_added = Array ();
$primary_language_id = $this->Application->GetDefaultLanguageId();
foreach ($languages as $language_id) {
$sql = 'SELECT Phrase, PhraseKey, Translation AS l' . $language_id . '_Translation, PhraseType, LastChanged, LastChangeIP, Module
FROM ' . TABLE_PREFIX . 'Phrase
WHERE LanguageId = ' . $language_id;
$phrases = $this->Conn->Query($sql, 'Phrase');
foreach ($phrases as $phrase => $fields_hash) {
if (array_key_exists($phrase, $already_added)) {
$this->Conn->doUpdate($fields_hash, $temp_table, 'PhraseId = ' . $already_added[$phrase]);
}
else {
$this->Conn->doInsert($fields_hash, $temp_table);
$already_added[$phrase] = $this->Conn->getInsertID();
}
}
// in case some phrases were found in this language, but not in primary language -> copy them
if ($language_id != $primary_language_id) {
$sql = 'UPDATE ' . $temp_table . '
SET l' . $primary_language_id . '_Translation = l' . $language_id . '_Translation
WHERE l' . $primary_language_id . '_Translation IS NULL';
$this->Conn->Query($sql);
}
}
$this->Conn->Query('DROP TABLE IF EXISTS ' . TABLE_PREFIX . 'Phrase');
$this->Conn->Query('RENAME TABLE ' . $temp_table . ' TO ' . TABLE_PREFIX . 'Phrase');
$this->_updateCountryStatesTable();
$this->_replaceConfigurationValueSeparator();
// save "config.php" in php format, not ini format as before
$this->_toolkit->SaveConfig();
}
if ($mode == 'after') {
$this->_transformEmailRecipients();
$this->_fixSkinColors();
}
}
/**
+ * Makes sure we rename tables to legacy names before doing other upgrades before 5.2.0-B1 upgrade
+ *
+ * @param string $name
+ * @param Array $arguments
+ */
+ public function __call($name, $arguments)
+ {
+ if ( substr($name, 0, 12) == 'Upgrade_5_1_' && $arguments[0] == 'before' ) {
+ $this->_renameTables('from');
+ }
+
+ if ( substr($name, 0, 13) == 'Upgrade_5_2_0' && $arguments[0] == 'before' ) {
+ $this->_renameTables('to');
+ }
+ }
+
+ /**
* Move country/state translations from Phrase to CountryStates table
*
*/
function _updateCountryStatesTable()
{
// refactor StdDestinations table
$sql = 'RENAME TABLE ' . TABLE_PREFIX . 'StdDestinations TO ' . TABLE_PREFIX . 'CountryStates';
$this->Conn->Query($sql);
$sql = 'ALTER TABLE ' . TABLE_PREFIX . 'CountryStates
CHANGE DestId CountryStateId INT(11) NOT NULL AUTO_INCREMENT,
CHANGE DestType Type INT(11) NOT NULL DEFAULT \'1\',
CHANGE DestParentId StateCountryId INT(11) NULL DEFAULT NULL,
CHANGE DestAbbr IsoCode CHAR(3) NOT NULL DEFAULT \'\',
CHANGE DestAbbr2 ShortIsoCode CHAR(2) NULL DEFAULT NULL,
DROP INDEX DestType,
DROP INDEX DestParentId,
ADD INDEX (`Type`),
ADD INDEX (StateCountryId)';
$this->Conn->Query($sql);
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
/* @var $ml_helper kMultiLanguageHelper */
$ml_helper->createFields('country-state');
$languages = $ml_helper->getLanguages();
foreach ($languages as $language_id) {
$sub_select = ' SELECT l' . $language_id . '_Translation
FROM ' . TABLE_PREFIX . 'Phrase
WHERE Phrase = DestName';
$sql = 'UPDATE ' . TABLE_PREFIX . 'CountryStates
SET l' . $language_id . '_Name = (' . $sub_select . ')';
$this->Conn->Query($sql);
}
$sql = 'ALTER TABLE ' . TABLE_PREFIX . 'CountryStates
DROP DestName';
$this->Conn->Query($sql);
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Phrase
WHERE Phrase LIKE ' . $this->Conn->qstr('la_country_%') . ' OR Phrase LIKE ' . $this->Conn->qstr('la_state_%');
$this->Conn->Query($sql);
}
/**
* Makes configuration values dropdowns use "||" as separator
*
*/
function _replaceConfigurationValueSeparator()
{
$custom_field_helper = $this->Application->recallObject('InpCustomFieldsHelper');
/* @var $custom_field_helper InpCustomFieldsHelper */
$sql = 'SELECT ValueList, VariableName
FROM ' . TABLE_PREFIX . 'ConfigurationAdmin
WHERE ValueList LIKE "%,%"';
$variables = $this->Conn->GetCol($sql, 'VariableName');
foreach ($variables as $variable_name => $value_list) {
$ret = Array ();
$options = $custom_field_helper->GetValuesHash($value_list, ',', false);
foreach ($options as $option_key => $option_title) {
if (substr($option_key, 0, 3) == 'SQL') {
$ret[] = $option_title;
}
else {
$ret[] = $option_key . '=' . $option_title;
}
}
$fields_hash = Array (
'ValueList' => implode(VALUE_LIST_SEPARATOR, $ret),
);
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'ConfigurationAdmin', 'VariableName = ' . $this->Conn->qstr($variable_name));
}
}
/**
* Transforms "FromUserId" into Sender* and Recipients columns
*
*/
function _transformEmailRecipients()
{
$sql = 'SELECT FromUserId, Type, EventId
FROM ' . TABLE_PREFIX . 'Events
WHERE FromUserId IS NOT NULL AND (FromUserId <> ' . USER_ROOT . ')';
$events = $this->Conn->Query($sql, 'EventId');
$minput_helper = $this->Application->recallObject('MInputHelper');
/* @var $minput_helper MInputHelper */
foreach ($events as $event_id => $event_data) {
$sql = 'SELECT Login
FROM ' . TABLE_PREFIX . 'PortalUser
WHERE PortalUserId = ' . $event_data['FromUserId'];
$username = $this->Conn->GetOne($sql);
if (!$username) {
continue;
}
if ($event_data['Type'] == EmailEvent::EVENT_TYPE_FRONTEND) {
// from user
$fields_hash = Array (
'CustomSender' => 1,
'SenderAddressType' => EmailEvent::ADDRESS_TYPE_USER,
'SenderAddress' => $username
);
}
if ($event_data['Type'] == EmailEvent::EVENT_TYPE_ADMIN) {
// to user
$records = Array (
Array (
'RecipientType' => EmailEvent::RECIPIENT_TYPE_TO,
'RecipientName' => '',
'RecipientAddressType' => EmailEvent::ADDRESS_TYPE_USER,
'RecipientAddress' => $username
)
);
$fields_hash = Array (
'CustomRecipient' => 1,
'Recipients' => $minput_helper->prepareMInputXML($records, array_keys( reset($records) ))
);
}
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Events', 'EventId = ' . $event_id);
}
$this->Conn->Query('ALTER TABLE ' . TABLE_PREFIX . 'Events DROP FromUserId');
}
/**
* Update to 5.1.0; Fixes refferer of form submissions
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_5_1_0($mode)
{
- if ($mode == 'after') {
+ if ( $mode == 'before' ) {
+ $this->_renameTables('from');
+ }
+
+ if ( $mode == 'after' ) {
$base_url = $this->Application->BaseURL();
$sql = 'UPDATE ' . TABLE_PREFIX . 'FormSubmissions
SET ReferrerURL = REPLACE(ReferrerURL, ' . $this->Conn->qstr($base_url) . ', "/")';
$this->Conn->Query($sql);
}
}
/**
* Update to 5.1.1-B1; Transforms DisplayToPublic logic
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_5_1_1_B1($mode)
{
+ if ( $mode == 'before' ) {
+ $this->_renameTables('from');
+ }
+
if ($mode == 'after') {
$this->processDisplayToPublic();
}
}
function processDisplayToPublic()
{
$profile_mapping = Array (
'pp_firstname' => 'FirstName',
'pp_lastname' => 'LastName',
'pp_dob' => 'dob',
'pp_email' => 'Email',
'pp_phone' => 'Phone',
'pp_street' => 'Street',
'pp_city' => 'City',
'pp_state' => 'State',
'pp_zip' => 'Zip',
'pp_country' => 'Country',
);
$fields = array_keys($profile_mapping);
$fields = $this->Conn->qstrArray($fields);
$where_clause = 'VariableName IN (' . implode(',', $fields) . ')';
// 1. get user, that have saved their profile at least once
$sql = 'SELECT DISTINCT PortalUserId
FROM ' . TABLE_PREFIX . 'PersistantSessionData
WHERE ' . $where_clause;
$users = $this->Conn->GetCol($sql);
foreach ($users as $user_id) {
// 2. convert to new format
$sql = 'SELECT VariableValue, VariableName
FROM ' . TABLE_PREFIX . 'PersistantSessionData
WHERE (PortalUserId = ' . $user_id . ') AND ' . $where_clause;
$user_variables = $this->Conn->GetCol($sql, 'VariableName');
// go through mapping to preserve variable order
$value = Array ();
foreach ($profile_mapping as $from_name => $to_name) {
if (array_key_exists($from_name, $user_variables) && $user_variables[$from_name]) {
$value[] = $to_name;
}
}
if ($value) {
$fields_hash = Array (
'DisplayToPublic' => '|' . implode('|', $value) . '|',
);
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'PortalUser', 'PortalUserId = ' . $user_id);
}
// 3. delete old style variables
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'PersistantSessionData
WHERE (PortalUserId = ' . $user_id . ') AND ' . $where_clause;
$this->Conn->Query($sql);
}
}
/**
* Update to 5.1.3; Merges column and field phrases
*
* @param string $mode when called mode {before, after)
*/
function Upgrade_5_1_3($mode)
{
- if ($mode != 'after') {
- return ;
+ if ( $mode == 'before' ) {
+ $this->_renameTables('from');
}
- $this->moveTranslation('LA_COL_', 'LA_FLD_', 'ColumnTranslation');
+ if ( $mode == 'after' ) {
+ $this->moveTranslation('LA_COL_', 'LA_FLD_', 'ColumnTranslation');
+ }
+ }
+
+ /**
+ * Makes sure table names match upgrade script
+ *
+ * @param string $key
+ * @return void
+ * @access private
+ */
+ private function _renameTables($key)
+ {
+ foreach ($this->renamedTables as $prefix => $table_info) {
+ $this->Application->setUnitOption($prefix, 'TableName', TABLE_PREFIX . $table_info[$key]);
+ }
}
/**
* Update to 5.2.0-B1; Transform list sortings storage
*
* @param string $mode when called mode {before, after)
*/
public function Upgrade_5_2_0_B1($mode)
{
- if ($mode == 'after') {
+ if ( $mode == 'before' ) {
+ $this->_renameTables('to');
+ }
+
+ if ( $mode == 'after' ) {
$this->transformSortings();
$this->moveTranslation('LA_COL_', 'LA_FLD_', 'ColumnTranslation'); // because of "la_col_ItemPrefix" phrase
$this->moveTranslation('LA_HINT_', 'LA_FLD_', 'HintTranslation');
$this->moveTranslation('LA_HINT_', 'LA_CONFIG_', 'HintTranslation');
$this->moveTranslation('LA_HINT_', 'LA_TITLE_', 'HintTranslation');
$this->createPageRevisions();
}
}
/**
* Transforms a way, how list sortings are stored
*
* @return void
*/
function transformSortings()
{
$sql = 'SELECT VariableName, PortalUserId
FROM ' . TABLE_PREFIX . 'UserPersistentSessionData
WHERE VariableName LIKE "%_Sort1.%"';
$sortings = $this->Conn->Query($sql);
foreach ($sortings AS $sorting) {
if ( !preg_match('/^(.*)_Sort1.(.*)$/', $sorting['VariableName'], $regs) ) {
continue;
}
$user_id = $sorting['PortalUserId'];
$prefix_special = $regs[1] . '_';
$view_name = '.' . $regs[2];
$old_variable_names = Array (
$prefix_special . 'Sort1' . $view_name, $prefix_special . 'Sort1_Dir' . $view_name,
$prefix_special . 'Sort2' . $view_name, $prefix_special . 'Sort2_Dir' . $view_name,
);
$old_variable_names = $this->Conn->qstrArray($old_variable_names);
$sql = 'SELECT VariableValue, VariableName
FROM ' . TABLE_PREFIX . 'UserPersistentSessionData
WHERE PortalUserId = ' . $user_id . ' AND VariableName IN (' . implode(',', $old_variable_names) . ')';
$sorting_data = $this->Conn->GetCol($sql, 'VariableName');
// prepare & save new sortings
$new_sorting = Array (
'Sort1' => $sorting_data[$prefix_special . 'Sort1' . $view_name],
'Sort1_Dir' => $sorting_data[$prefix_special . 'Sort1_Dir' . $view_name],
);
if ( isset($sorting_data[$prefix_special . 'Sort2' . $view_name]) ) {
$new_sorting['Sort2'] = $sorting_data[$prefix_special . 'Sort2' . $view_name];
$new_sorting['Sort2_Dir'] = $sorting_data[$prefix_special . 'Sort2_Dir' . $view_name];
}
$fields_hash = Array (
'PortalUserId' => $user_id,
'VariableName' => $prefix_special . 'Sortings' . $view_name,
'VariableValue' => serialize($new_sorting),
);
$this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'UserPersistentSessionData');
// delete sortings, that were already processed
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'UserPersistentSessionData
WHERE PortalUserId = ' . $user_id . ' AND VariableName IN (' . implode(',', $old_variable_names) . ')';
$this->Conn->Query($sql);
}
}
/**
* Merges several phrases into one (e.g. la_col_ + la_hint_ into designated columns of la_fld_ phrases)
*
* @param string $source_prefix
* @param string $target_prefix
* @param string $db_column
* @return void
* @access protected
*/
public function moveTranslation($source_prefix, $target_prefix, $db_column)
{
$source_phrases = $this->getPhrasesByMask($source_prefix . '%');
$target_phrases = $this->getPhrasesByMask($target_prefix . '%');
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
/* @var $ml_helper kMultiLanguageHelper */
$delete_ids = Array ();
$ml_helper->createFields('phrases');
$languages = $ml_helper->getLanguages();
$phrase_table = $this->Application->getUnitOption('phrases', 'TableName');
foreach ($source_phrases as $phrase_key => $phrase_info) {
$target_phrase_key = $target_prefix . substr($phrase_key, strlen($source_prefix));
if ( !isset($target_phrases[$target_phrase_key]) ) {
continue;
}
$fields_hash = Array ();
// copy column phrase main translation into field phrase column translation
foreach ($languages as $language_id) {
$fields_hash['l' . $language_id . '_' . $db_column] = $phrase_info['l' . $language_id . '_Translation'];
}
$delete_ids[] = $phrase_info['PhraseId'];
$this->Conn->doUpdate($fields_hash, $phrase_table, 'PhraseId = ' . $target_phrases[$target_phrase_key]['PhraseId']);
}
// delete all column phrases, that were absorbed by field phrases
if ( $delete_ids ) {
$sql = 'DELETE FROM ' . $phrase_table . '
WHERE PhraseId IN (' . implode(',', $delete_ids) . ')';
$this->Conn->Query($sql);
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'PhraseCache';
$this->Conn->Query($sql);
}
}
/**
* Returns phrases by mask
*
* @param string $mask
* @return Array
* @access protected
*/
protected function getPhrasesByMask($mask)
{
$sql = 'SELECT *
FROM ' . $this->Application->getUnitOption('phrases', 'TableName') . '
WHERE PhraseKey LIKE ' . $this->Conn->qstr($mask);
return $this->Conn->Query($sql, 'PhraseKey');
}
protected function createPageRevisions()
{
$sql = 'SELECT DISTINCT PageId
FROM ' . TABLE_PREFIX . 'PageContent';
$page_ids = $this->Conn->GetCol($sql);
foreach ($page_ids as $page_id) {
$fields_hash = Array (
'PageId' => $page_id,
'RevisionNumber' => 1,
'IsDraft' => 0,
'FromRevisionId' => 0,
'CreatedById' => USER_ROOT,
'CreatedOn' => adodb_mktime(),
'Status' => STATUS_ACTIVE,
);
$this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'PageRevisions');
$fields_hash = Array (
'RevisionId' => $this->Conn->getInsertID(),
);
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'PageContent', 'PageId = ' . $page_id);
}
}
}
\ No newline at end of file
Index: branches/5.2.x/core/install/install_toolkit.php
===================================================================
--- branches/5.2.x/core/install/install_toolkit.php (revision 15175)
+++ branches/5.2.x/core/install/install_toolkit.php (revision 15176)
@@ -1,1178 +1,1179 @@
<?php
/**
* @version $Id$
* @package In-Portal
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
/**
* Upgrade sqls are located using this mask
*
*/
define('UPGRADES_FILE', FULL_PATH.'/%sinstall/upgrades.%s');
/**
* Prerequisit check classes are located using this mask
*
*/
define('PREREQUISITE_FILE', FULL_PATH.'/%sinstall/prerequisites.php');
/**
* Format of version identificator in upgrade files (normal, beta, release candidate)
*
*/
define('VERSION_MARK', '# ===== v ([\d]+\.[\d]+\.[\d]+|[\d]+\.[\d]+\.[\d]+-B[\d]+|[\d]+\.[\d]+\.[\d]+-RC[\d]+) =====');
if (!defined('GET_LICENSE_URL')) {
/**
* Url used for retrieving user licenses from Intechnic licensing server
*
*/
define('GET_LICENSE_URL', 'http://www.in-portal.com/license.php');
}
/**
* Misc functions, that are required during installation, when
*
*/
class kInstallToolkit {
/**
* Reference to kApplication class object
*
* @var kApplication
*/
var $Application = null;
/**
* Connection to database
*
* @var kDBConnection
*/
var $Conn = null;
/**
* Path to config.php
*
* @var string
*/
var $INIFile = '';
/**
* Parsed data from config.php
*
* @var Array
*/
var $systemConfig = Array ();
/**
* Tells, that system config was changed
*
* @var bool
* @access public
*/
public $systemConfigChanged = false;
/**
* Path, used by system to store data on filesystem
*
* @var string
*/
var $defaultWritablePath = '';
/**
* Installator instance
*
* @var kInstallator
*/
var $_installator = null;
function kInstallToolkit()
{
$this->defaultWritablePath = DIRECTORY_SEPARATOR . 'system';
if ( class_exists('kApplication') ) {
// auto-setup in case of separate module install
$this->Application =& kApplication::Instance();
$this->Application->Init(); // needed for standalone module install
$this->Conn =& $this->Application->GetADODBConnection();
}
$this->INIFile = FULL_PATH . $this->defaultWritablePath . DIRECTORY_SEPARATOR . 'config.php';
$this->systemConfig = $this->ParseConfig(true);
}
/**
* Sets installator
*
* @param kInstallator $instance
*/
function setInstallator(&$instance)
{
$this->_installator =& $instance;
}
/**
* Checks prerequisities before module install or upgrade
*
* @param string $module_path
* @param string $versions
* @param string $mode upgrade mode = {install, standalone, upgrade}
* @return bool
*/
function CheckPrerequisites($module_path, $versions, $mode)
{
if ( !$versions ) {
return Array ();
}
$prerequisite_object =& $this->getPrerequisiteObject($module_path);
/* @var $prerequisite_object InPortalPrerequisites */
// some errors possible
return is_object($prerequisite_object) ? $prerequisite_object->CheckPrerequisites($versions, $mode) : Array ();
}
/**
* Call prerequisites method
*
* @param string $module_path
* @param string $method
* @return array
*/
function CallPrerequisitesMethod($module_path, $method)
{
$prerequisite_object =& $this->getPrerequisiteObject($module_path);
/* @var $prerequisite_object InPortalPrerequisites */
return is_object($prerequisite_object) ? $prerequisite_object->$method() : false;
}
/**
* Returns prerequisite object to be used for checks
*
* @param string $module_path
* @return kHelper
* @access protected
*/
protected function &getPrerequisiteObject($module_path)
{
static $prerequisite_classes = Array ();
$prerequisites_file = sprintf(PREREQUISITE_FILE, $module_path);
if ( !file_exists($prerequisites_file) ) {
$false = false;
return $false;
}
if ( !isset($prerequisite_classes[$module_path]) ) {
// save class name, because 2nd time
// (in after call $prerequisite_class variable will not be present)
include_once $prerequisites_file;
$prerequisite_classes[$module_path] = $prerequisite_class;
}
$prerequisite_object = new $prerequisite_classes[$module_path]();
/* @var $prerequisite_object InPortalPrerequisites */
if ( method_exists($prerequisite_object, 'setToolkit') ) {
$prerequisite_object->setToolkit($this);
}
return $prerequisite_object;
}
/**
* Processes one license, received from server
*
* @param string $file_data
*/
function processLicense($file_data)
{
$modules_helper = $this->Application->recallObject('ModulesHelper');
/* @var $modules_helper kModulesHelper */
$file_data = explode('Code==:', $file_data);
$file_data[0] = str_replace('In-Portal License File - do not edit!' . "\n", '', $file_data[0]);
$file_data = array_map('trim', $file_data);
if ($modules_helper->verifyLicense($file_data[0])) {
$this->setSystemConfig('Intechnic', 'License', $file_data[0]);
if (array_key_exists(1, $file_data)) {
$this->setSystemConfig('Intechnic', 'LicenseCode', $file_data[1]);
}
else {
$this->setSystemConfig('Intechnic', 'LicenseCode');
}
$this->SaveConfig();
}
else {
// invalid license received from licensing server
$this->_installator->errorMessage = 'Invalid License File';
}
}
/**
* Saves given configuration values to database
*
* @param Array $config
*/
function saveConfigValues($config)
{
foreach ($config as $config_var => $value) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'SystemSettings
SET VariableValue = ' . $this->Conn->qstr($value) . '
WHERE VariableName = ' . $this->Conn->qstr($config_var);
$this->Conn->Query($sql);
}
}
/**
* Sets module version to passed
*
* @param string $module_name
* @param string|bool $module_path
* @param string|bool $version
*/
function SetModuleVersion($module_name, $module_path = false, $version = false)
{
if ($version === false) {
if (!$module_path) {
throw new Exception('Module path must be given to "SetModuleVersion" method to auto-detect version');
return ;
}
$version = $this->GetMaxModuleVersion($module_path);
}
// get table prefix from config, because application may not be available here
$table_prefix = $this->getSystemConfig('Database', 'TablePrefix');
if ($module_name == 'kernel') {
$module_name = 'in-portal';
}
// don't use "adodb_mktime" here, because it's not yet included
$sql = 'UPDATE ' . $table_prefix . 'Modules
SET Version = "' . $version . '", BuildDate = ' . time() . '
WHERE LOWER(Name) = "' . strtolower($module_name) . '"';
$this->Conn->Query($sql);
}
/**
* Sets module root category to passed
*
* @param string $module_name
* @param int $category_id
*/
function SetModuleRootCategory($module_name, $category_id = 0)
{
// get table prefix from config, because application may not be available here
$table_prefix = $this->getSystemConfig('Database', 'TablePrefix');
if ($module_name == 'kernel') {
$module_name = 'in-portal';
}
$sql = 'UPDATE ' . $table_prefix . 'Modules
SET RootCat = ' . $category_id . '
WHERE LOWER(Name) = "' . strtolower($module_name) . '"';
$this->Conn->Query($sql);
}
/**
* Returns maximal version of given module by scanning it's upgrade scripts
*
* @param string $module_path
* @return string
*/
function GetMaxModuleVersion($module_path)
{
$module_path = rtrim(mb_strtolower($module_path), '/');
$upgrades_file = sprintf(UPGRADES_FILE, $module_path . '/', 'sql');
if (!file_exists($upgrades_file)) {
// no upgrade file
return '5.0.0';
}
$sqls = file_get_contents($upgrades_file);
$versions_found = preg_match_all('/'.VERSION_MARK.'/s', $sqls, $regs);
if (!$versions_found) {
// upgrades file doesn't contain version definitions
return '5.0.0';
}
return end($regs[1]);
}
/**
* Runs SQLs from file
*
* @param string $filename
* @param mixed $replace_from
* @param mixed $replace_to
*/
function RunSQL($filename, $replace_from = null, $replace_to = null)
{
if (!file_exists(FULL_PATH.$filename)) {
return ;
}
$sqls = file_get_contents(FULL_PATH.$filename);
if (!$this->RunSQLText($sqls, $replace_from, $replace_to)) {
if (is_object($this->_installator)) {
$this->_installator->Done();
}
else {
if (isset($this->Application)) {
$this->Application->Done();
}
exit;
}
}
}
/**
* Runs SQLs from string
*
* @param string $sqls
* @param mixed $replace_from
* @param mixed $replace_to
* @param int $start_from
* @return bool
*/
function RunSQLText(&$sqls, $replace_from = null, $replace_to = null, $start_from = 0)
{
$table_prefix = $this->getSystemConfig('Database', 'TablePrefix');
// add prefix to all tables
if (strlen($table_prefix) > 0) {
$replacements = Array ('INSERT INTO ', 'UPDATE ', 'ALTER TABLE ', 'DELETE FROM ', 'REPLACE INTO ');
foreach ($replacements as $replacement) {
$sqls = str_replace($replacement, $replacement . $table_prefix, $sqls);
}
}
$sqls = str_replace('CREATE TABLE ', 'CREATE TABLE IF NOT EXISTS ' . $table_prefix, $sqls);
$sqls = str_replace('DROP TABLE ', 'DROP TABLE IF EXISTS ' . $table_prefix, $sqls);
$sqls = str_replace('<%TABLE_PREFIX%>', $table_prefix, $sqls);
$primary_language = is_object($this->Application) ? $this->Application->GetDefaultLanguageId() : 1;
$sqls = str_replace('<%PRIMARY_LANGUAGE%>', $primary_language, $sqls);
if (isset($replace_from) && isset($replace_to)) {
// replace something additionally, e.g. module root category
$sqls = str_replace($replace_from, $replace_to, $sqls);
}
$sqls = str_replace("\r\n", "\n", $sqls); // convert to linux line endings
$no_comment_sqls = preg_replace("/#\s([^;]*?)\n/is", '', $sqls); // remove all comments "#" on new lines
if ($no_comment_sqls === null) {
// "ini.pcre.backtrack-limit" reached and error happened
$sqls = explode(";\n", $sqls . "\n"); // ensures that last sql won't have ";" in it
$sqls = array_map('trim', $sqls);
// remove all comments "#" on new lines (takes about 2 seconds for 53000 sqls)
$sqls = preg_replace("/#\s([^;]*?)/", '', $sqls);
}
else {
$sqls = explode(";\n", $no_comment_sqls . "\n"); // ensures that last sql won't have ";" in it
$sqls = array_map('trim', $sqls);
}
$sql_count = count($sqls);
$db_collation = $this->getSystemConfig('Database', 'DBCollation');
for ($i = $start_from; $i < $sql_count; $i++) {
$sql = $sqls[$i];
if (!$sql || (substr($sql, 0, 1) == '#')) {
continue; // usually last line
}
if (substr($sql, 0, 13) == 'CREATE TABLE ' && $db_collation) {
// it is CREATE TABLE statement -> add collation
$sql .= ' COLLATE \'' . $db_collation . '\'';
}
$this->Conn->Query($sql);
if ($this->Conn->getErrorCode() != 0) {
if (is_object($this->_installator)) {
$this->_installator->errorMessage = 'Error: ('.$this->Conn->getErrorCode().') '.$this->Conn->getErrorMsg().'<br /><br />Last Database Query:<br /><textarea cols="70" rows="10" readonly>'.htmlspecialchars($sql).'</textarea>';
$this->_installator->LastQueryNum = $i + 1;
}
return false;
}
}
return true;
}
/**
* Performs clean language import from given xml file
*
* @param string $lang_file
* @param bool $upgrade
* @todo Import for "core/install/english.lang" (322KB) takes 18 seconds to work on Windows
*/
function ImportLanguage($lang_file, $upgrade = false)
{
$lang_file = FULL_PATH.$lang_file.'.lang';
if (!file_exists($lang_file)) {
return ;
}
$language_import_helper = $this->Application->recallObject('LanguageImportHelper');
/* @var $language_import_helper LanguageImportHelper */
$language_import_helper->performImport($lang_file, '|0|1|2|', '', $upgrade ? LANG_SKIP_EXISTING : LANG_OVERWRITE_EXISTING);
}
/**
* Converts module version in format X.Y.Z[-BN/-RCM] to signle integer
*
* @param string $version
* @return int
*/
function ConvertModuleVersion($version)
{
if (preg_match('/(.*)-(B|RC)([\d]+)/', $version, $regs)) {
// -B<M> or RC-<N>
$parts = explode('.', $regs[1]);
$parts[] = $regs[2] == 'B' ? 1 : 2; // B reliases goes before RC releases
$parts[] = $regs[3];
}
else {
// releases without B/RC marks go after any B/RC releases
$parts = explode('.', $version . '.3.100');
}
$bin = '';
foreach ($parts as $part_index => $part) {
if ($part_index == 3) {
// version type only can be 1/2/3 (11 in binary form), so don't use padding at all
$pad_count = 2;
}
else {
$pad_count = 8;
}
$bin .= str_pad(decbin($part), $pad_count, '0', STR_PAD_LEFT);
}
return bindec($bin);
}
/**
* Returns themes, found in system
*
* @param bool $rebuild
* @return int
*/
function getThemes($rebuild = false)
{
if ($rebuild) {
$this->rebuildThemes();
}
$id_field = $this->Application->getUnitOption('theme', 'IDField');
$table_name = $this->Application->getUnitOption('theme', 'TableName');
$sql = 'SELECT Name, ' . $id_field . '
FROM ' . $table_name . '
ORDER BY Name ASC';
return $this->Conn->GetCol($sql, $id_field);
}
function ParseConfig($parse_section = false)
{
if (!file_exists($this->INIFile)) {
return Array ();
}
if (file_exists($this->INIFile) && !is_readable($this->INIFile)) {
die('Could Not Open Ini File');
}
$contents = file($this->INIFile);
if ($contents && $contents[0] == '<' . '?' . 'php die() ?' . ">\n") {
// format of "config.php" file before 5.1.0 version
array_shift($contents);
return $this->parseIniString(implode('', $contents), $parse_section);
}
$_CONFIG = Array ();
require($this->INIFile);
if ($parse_section) {
return $_CONFIG;
}
$ret = Array ();
foreach ($_CONFIG as $section => $section_variables) {
$ret = array_merge($ret, $section_variables);
}
return $ret;
}
/**
* Equivalent for "parse_ini_string" function available since PHP 5.3.0
*
* @param string $ini
* @param bool $process_sections
* @param int $scanner_mode
* @return Array
*/
function parseIniString($ini, $process_sections = false, $scanner_mode = null)
{
# Generate a temporary file.
$tempname = tempnam('/tmp', 'ini');
$fp = fopen($tempname, 'w');
fwrite($fp, $ini);
$ini = parse_ini_file($tempname, !empty($process_sections));
fclose($fp);
@unlink($tempname);
return $ini;
}
function SaveConfig($silent = false)
{
if (!is_writable($this->INIFile) && !is_writable(dirname($this->INIFile))) {
$error_msg = 'Cannot write to "' . $this->INIFile . '" file';
if ($silent) {
trigger_error($error_msg, E_USER_WARNING);
}
else {
throw new Exception($error_msg);
}
return ;
}
$fp = fopen($this->INIFile, 'w');
fwrite($fp, '<' . '?' . 'php' . "\n\n");
foreach ($this->systemConfig as $section_name => $section_data) {
foreach ($section_data as $key => $value) {
fwrite($fp, '$_CONFIG[\'' . $section_name . '\'][\'' . $key . '\'] = \'' . addslashes($value) . '\';' . "\n");
}
fwrite($fp, "\n");
}
fclose($fp);
$this->systemConfigChanged = false;
}
/**
* Sets value to system config (yet SaveConfig must be called to write it to file)
*
* @param string $section
* @param string $key
* @param string $value
*/
function setSystemConfig($section, $key, $value = null)
{
$this->systemConfigChanged = true;
if (isset($value)) {
if (!array_key_exists($section, $this->systemConfig)) {
// create section, when missing
$this->systemConfig[$section] = Array ();
}
// create key in section
$this->systemConfig[$section][$key] = $value;
return ;
}
unset($this->systemConfig[$section][$key]);
}
/**
* Returns information from system config
*
* @param string $section
* @param string $key
* @param mixed $default
* @return string|bool
*/
function getSystemConfig($section, $key, $default = false)
{
if ( !array_key_exists($section, $this->systemConfig) ) {
return $default;
}
if ( !array_key_exists($key, $this->systemConfig[$section]) ) {
return $default;
}
return $this->systemConfig[$section][$key] ? $this->systemConfig[$section][$key] : $default;
}
/**
* Checks if system config is present and is not empty
*
* @return bool
*/
function systemConfigFound()
{
return file_exists($this->INIFile) && $this->systemConfig;
}
/**
* Checks if given section is present in config
*
* @param string $section
* @return bool
*/
function sectionFound($section)
{
return array_key_exists($section, $this->systemConfig);
}
/**
* Returns formatted module name based on it's root folder
*
* @param string $module_folder
* @return string
*/
function getModuleName($module_folder)
{
return implode('-', array_map('ucfirst', explode('-', $module_folder)));
}
/**
* Returns information about module (based on "install/module_info.xml" file)
*
* @param string $module_name
* @return Array
*/
function getModuleInfo($module_name)
{
if ( $module_name == 'core' ) {
$info_file = FULL_PATH . '/' . $module_name . '/install/module_info.xml';
}
else {
$info_file = MODULES_PATH . '/' . $module_name . '/install/module_info.xml';
}
if ( !file_exists($info_file) ) {
return Array ();
}
$ret = Array ();
$module_info = simplexml_load_file($info_file);
if ( $module_info === false ) {
// non-valid xml file
return Array ();
}
foreach ($module_info as $node) {
/* @var $node SimpleXMLElement */
$ret[strtolower($node->getName())] = trim($node);
}
return $ret;
}
/**
* Returns nice module string to be used on install/upgrade screens
*
* @param string $module_name
* @param string $version_string
* @return string
*/
function getModuleString($module_name, $version_string)
{
// image (if exists) <description> (<name> <version>)
$ret = Array ();
$module_info = $this->getModuleInfo($module_name);
if (array_key_exists('name', $module_info) && $module_info['name']) {
$module_name = $module_info['name'];
}
else {
$module_name = $this->getModuleName($module_name);
}
if (array_key_exists('image', $module_info) && $module_info['image']) {
$image_src = $module_info['image'];
if (!preg_match('/^(http|https):\/\//', $image_src)) {
// local image -> make absolute url
$image_src = $this->Application->BaseURL() . $image_src;
}
$ret[] = '<img src="' . $image_src . '" alt="' . htmlspecialchars($module_name) . '" title="' . htmlspecialchars($module_name) . '" style="vertical-align:middle; margin: 3px 0 3px 5px"/>';
}
if (array_key_exists('description', $module_info) && $module_info['description']) {
$ret[] = $module_info['description'];
}
else {
$ret[] = $module_name;
}
$ret[] = '(' . $module_name . ' ' . $version_string . ')';
return implode(' ', $ret);
}
/**
* Creates module root category in "Home" category using given data and returns it
*
* @param string $name
* @param string $description
* @param string $category_template
* @param string $category_icon
* @return kDBItem
*/
function &createModuleCategory($name, $description, $category_template = null, $category_icon = null)
{
static $fields = null;
if ( !isset($fields) ) {
$ml_formatter = $this->Application->recallObject('kMultiLanguage');
/* @var $ml_formatter kMultiLanguage */
$fields['name'] = $ml_formatter->LangFieldName('Name');
$fields['description'] = $ml_formatter->LangFieldName('Description');
}
$category = $this->Application->recallObject('c', null, Array ('skip_autoload' => true));
/* @var $category kDBItem */
$category_fields = Array (
$fields['name'] => $name, 'Filename' => $name, 'AutomaticFilename' => 1,
$fields['description'] => $description, 'Status' => STATUS_ACTIVE, 'Priority' => -9999,
// prevents empty link to module category on spearate module install
'NamedParentPath' => 'Content/' . $name,
);
$category_fields['ParentId'] = $this->Application->getBaseCategory();
if ( isset($category_template) ) {
$category_fields['Template'] = $category_template;
$category_fields['CachedTemplate'] = $category_template;
}
if ( isset($category_icon) ) {
$category_fields['UseMenuIconUrl'] = 1;
$category_fields['MenuIconUrl'] = $category_icon;
}
$category->Clear();
$category->SetDBFieldsFromHash($category_fields);
$category->Create();
$priority_helper = $this->Application->recallObject('PriorityHelper');
/* @var $priority_helper kPriorityHelper */
$event = new kEvent('c:OnListBuild');
// ensure, that newly created category has proper value in Priority field
$priority_helper->recalculatePriorities($event, 'ParentId = ' . $category_fields['ParentId']);
// update Priority field in object, becase "CategoriesItem::Update" method will be called
// from "kInstallToolkit::setModuleItemTemplate" and otherwise will set 0 to Priority field
$sql = 'SELECT Priority
FROM ' . $category->TableName . '
WHERE ' . $category->IDField . ' = ' . $category->GetID();
$category->SetDBField('Priority', $this->Conn->GetOne($sql));
return $category;
}
/**
* Sets category item template into custom field for given prefix
*
* @param kDBItem $category
* @param string $prefix
* @param string $item_template
*/
function setModuleItemTemplate(&$category, $prefix, $item_template)
{
$this->Application->removeObject('c-cdata');
// recreate all fields, because custom fields are added during install script
$category->Configure();
$category->SetDBField('cust_' . $prefix .'_ItemTemplate', $item_template);
$category->Update();
}
/**
* Link custom field records with search config records + create custom field columns
*
* @param string $module_folder
* @param string $prefix
* @param int $item_type
*/
function linkCustomFields($module_folder, $prefix, $item_type)
{
$module_folder = strtolower($module_folder);
$module_name = $module_folder;
if ( $module_folder == 'kernel' ) {
$module_name = 'in-portal';
$module_folder = 'core';
}
$db =& $this->Application->GetADODBConnection();
$sql = 'SELECT FieldName, CustomFieldId
FROM ' . TABLE_PREFIX . 'CustomFields
WHERE Type = ' . $item_type . ' AND IsSystem = 0'; // config is not read here yet :( $this->Application->getUnitOption('p', 'ItemType');
$custom_fields = $db->GetCol($sql, 'CustomFieldId');
foreach ($custom_fields as $cf_id => $cf_name) {
$sql = 'UPDATE ' . TABLE_PREFIX . 'SearchConfig
SET CustomFieldId = ' . $cf_id . '
WHERE (TableName = "CustomFields") AND (LOWER(ModuleName) = "' . $module_name . '") AND (FieldName = ' . $db->qstr($cf_name) . ')';
$db->Query($sql);
}
$this->Application->refreshModuleInfo(); // this module configs are now processed
// because of configs was read only from installed before modules (in-portal), then reread configs
$this->Application->UnitConfigReader->scanModules(MODULES_PATH . DIRECTORY_SEPARATOR . $module_folder);
// create correct columns in CustomData table
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
/* @var $ml_helper kMultiLanguageHelper */
$ml_helper->createFields($prefix . '-cdata', true);
}
/**
* Deletes cache, useful after separate module install and installator last step
*
* @param bool $refresh_permissions
* @return void
*/
function deleteCache($refresh_permissions = false)
{
+ $this->Application->HandleEvent(new kEvent('adm:OnResetMemcache')); // not in DB = 100% invalidate
$this->Application->HandleEvent(new kEvent('adm:OnResetConfigsCache'));
$this->Application->HandleEvent(new kEvent('adm:OnResetSections'));
$this->Application->HandleEvent(new kEvent('c:OnResetCMSMenuCache'));
$this->Conn->Query('DELETE FROM ' . TABLE_PREFIX . 'CachedUrls');
if ( $refresh_permissions ) {
if ( $this->Application->ConfigValue('QuickCategoryPermissionRebuild') ) {
// refresh permission without progress bar
$updater = $this->Application->makeClass('kPermCacheUpdater');
/* @var $updater kPermCacheUpdater */
$updater->OneStepRun();
}
else {
// refresh permissions with ajax progress bar (when available)
$this->Application->setDBCache('ForcePermCacheUpdate', 1);
}
}
}
/**
* Deletes all temp tables (from active sessions too)
*
*/
function deleteEditTables()
{
$table_prefix = $this->getSystemConfig('Database', 'TablePrefix');
$tables = $this->Conn->GetCol('SHOW TABLES');
$mask_edit_table = '/' . $table_prefix . 'ses_(.*)_edit_(.*)/';
$mask_search_table = '/' . $table_prefix . 'ses_(.*?)_(.*)/';
foreach ($tables as $table) {
if ( preg_match($mask_edit_table, $table, $rets) || preg_match($mask_search_table, $table, $rets) ) {
$this->Conn->Query('DROP TABLE IF EXISTS ' . $table);
}
}
}
/**
* Perform redirect after separate module install
*
* @param string $module_folder
* @param bool $refresh_permissions
*/
function finalizeModuleInstall($module_folder, $refresh_permissions = false)
{
$this->SetModuleVersion(basename($module_folder), $module_folder);
if (!$this->Application->GetVar('redirect')) {
return ;
}
$themes_helper = $this->Application->recallObject('ThemesHelper');
/* @var $themes_helper kThemesHelper */
// use direct query, since module isn't yet in kApplication::ModuleInfo array
$sql = 'SELECT Name
FROM ' . TABLE_PREFIX . 'Modules
WHERE Path = ' . $this->Conn->qstr(rtrim($module_folder, '/') . '/');
$module_name = $this->Conn->GetOne($sql);
$themes_helper->synchronizeModule($module_name);
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
/* @var $ml_helper kMultiLanguageHelper */
$ml_helper->massCreateFields();
$this->deleteCache($refresh_permissions);
$url_params = Array (
'pass' => 'm', 'admin' => 1,
'RefreshTree' => 1, 'index_file' => 'index.php',
);
$this->Application->Redirect('modules/modules_list', $url_params);
}
/**
* Performs rebuild of themes
*
*/
function rebuildThemes()
{
$this->Application->HandleEvent(new kEvent('adm:OnRebuildThemes'));
}
/**
* Checks that file is writable by group or others
*
* @param string $file
* @return boolean
*/
function checkWritePermissions($file)
{
if (DIRECTORY_SEPARATOR == '\\') {
// windows doen't allow to check permissions (always returns null)
return null;
}
$permissions = fileperms($file);
return $permissions & 0x0010 || $permissions & 0x0002;
}
/**
* Upgrades primary skin to the latest version
*
* @param Array $module_info
* @return string|bool
*/
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 true;
}
$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 false;
}
$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 false;
}
$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;
}
/**
* Returns cache handlers, that are working
*
* @param string $current
* @return Array
*/
public function getWorkingCacheHandlers($current = null)
{
if ( !isset($current) ) {
$current = $this->getSystemConfig('Misc', 'CacheHandler');
}
$cache_handlers = Array (
'Fake' => 'None', 'Memcache' => 'Memcached', 'XCache' => 'XCache', 'Apc' => 'Alternative PHP Cache'
);
foreach ($cache_handlers AS $class_prefix => $title) {
$handler_class = $class_prefix . 'CacheHandler';
if ( !class_exists($handler_class) ) {
unset($cache_handlers[$class_prefix]);
}
else {
$handler = new $handler_class('localhost:11211');
/* @var $handler FakeCacheHandler */
if ( !$handler->isWorking() ) {
if ( $current == $class_prefix ) {
$cache_handlers[$class_prefix] .= ' (offline)';
}
else {
unset($cache_handlers[$class_prefix]);
}
}
}
}
return $cache_handlers;
}
/**
* Returns compression engines, that are working
*
* @param string $current
* @return Array
*/
public function getWorkingCompressionEngines($current = null)
{
if ( !isset($current) ) {
$current = $this->getSystemConfig('Misc', 'CompressionEngine');
}
$output = shell_exec('java -version 2>&1');
$compression_engines = Array ('' => 'None', 'yui' => 'YUICompressor (Java)', 'php' => 'PHP-based');
if ( stripos($output, 'java version') === false ) {
if ( $current == 'yui' ) {
$compression_engines['yui'] .= ' (offline)';
}
else {
unset($compression_engines['yui']);
}
}
return $compression_engines;
}
}
\ No newline at end of file

Event Timeline