Page MenuHomeIn-Portal Phabricator

D12.id726.diff
No OneTemporary

File Metadata

Created
Wed, Feb 26, 9:02 AM

D12.id726.diff

Index: core/admin_templates/themes/themes_edit.tpl
===================================================================
--- core/admin_templates/themes/themes_edit.tpl
+++ core/admin_templates/themes/themes_edit.tpl
@@ -55,11 +55,11 @@
<div id="scroll_container">
<table class="edit-form">
- <inp2:m_RenderElement name="subsection" prefix="theme" fields="ThemeId,Name,Description,Enabled,CacheTimeout,StylesheetId,PrimaryTheme" title="la_section_General"/>
+ <inp2:m_RenderElement name="subsection" prefix="theme" fields="ThemeId,Name,Description,Status,CacheTimeout,StylesheetId,PrimaryTheme" title="la_section_General"/>
<inp2:m_RenderElement name="inp_id_label" prefix="theme" field="ThemeId" title="la_fld_Id"/>
- <inp2:m_RenderElement name="inp_edit_box" prefix="theme" field="Name" title="la_fld_Name"/>
+ <inp2:m_RenderElement name="inp_label" prefix="theme" field="Name" title="la_fld_Name"/>
<inp2:m_RenderElement name="inp_edit_textarea" prefix="theme" field="Description" title="la_fld_Description" cols="25" rows="3"/>
- <inp2:m_RenderElement name="inp_edit_checkbox" prefix="theme" field="Enabled" title="la_fld_Enabled"/>
+ <inp2:m_RenderElement name="inp_edit_radio" prefix="theme" field="Status"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="theme" field="CacheTimeout" title="la_prompt_lang_cache_timeout"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="theme" field="StylesheetFile"/>
@@ -69,6 +69,8 @@
</inp2:m_if>
##-->
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="theme" field="PrimaryTheme" title="la_fld_Primary"/>
+ <inp2:m_RenderElement name="inp_label" prefix="theme" field="AddedOn"/>
+ <inp2:m_RenderElement name="inp_label" prefix="theme" field="DeletedOn"/>
<inp2:m_RenderElement name="inp_edit_filler"/>
</table>
</div>
Index: core/install.php
===================================================================
--- core/install.php
+++ core/install.php
@@ -909,7 +909,7 @@
$theme_id_field = $theme_config->getIDField();
$sql = 'UPDATE ' . $theme_table . '
- SET Enabled = 1, PrimaryTheme = 1
+ SET Status = ' . ThemeStatus::ACTIVE . ', PrimaryTheme = 1
WHERE ' . $theme_id_field . ' = ' . $theme_id;
$this->Conn->Query($sql);
Index: core/install/cache/class_structure.php
===================================================================
--- core/install/cache/class_structure.php
+++ core/install/cache/class_structure.php
@@ -188,6 +188,7 @@
'TemplatesCache' => '/core/kernel/nparser/template_cache.php',
'ThemeFileEventHandler' => '/core/units/theme_files/theme_file_eh.php',
'ThemeItem' => '/core/units/themes/theme_item.php',
+ 'ThemeStatus' => '/core/kernel/constants.php',
'ThemesEventHandler' => '/core/units/themes/themes_eh.php',
'ThemesTagProcessor' => '/core/units/themes/themes_tag_processor.php',
'ThesaurusEventHandler' => '/core/units/thesaurus/thesaurus_eh.php',
@@ -1544,6 +1545,10 @@
0 => 'kDBItem',
),
),
+ 'ThemeStatus' => array(
+ 'type' => 1,
+ 'modifiers' => 0,
+ ),
'ThemesEventHandler' => array(
'type' => 1,
'modifiers' => 0,
Index: core/install/install_data.sql
===================================================================
--- core/install/install_data.sql
+++ core/install/install_data.sql
@@ -681,7 +681,6 @@
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_themes.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_themes.add', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_themes.edit', 11, 1, 1, 0);
-INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_themes.delete', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_styles.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_styles.add', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_styles.edit', 11, 1, 1, 0);
Index: core/install/install_schema.sql
===================================================================
--- core/install/install_schema.sql
+++ core/install/install_schema.sql
@@ -373,7 +373,7 @@
CREATE TABLE Themes (
ThemeId int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(40) NOT NULL DEFAULT '',
- Enabled int(11) NOT NULL DEFAULT '1',
+ Status int(11) NOT NULL DEFAULT '1',
Description varchar(255) DEFAULT NULL,
PrimaryTheme int(11) NOT NULL DEFAULT '0',
CacheTimeout int(11) NOT NULL DEFAULT '0',
@@ -382,8 +382,10 @@
TemplateAliases text,
StylesheetFile varchar(255) NOT NULL DEFAULT '',
ImageResizeRules text,
+ AddedOn int(11) DEFAULT NULL,
+ DeletedOn int(11) DEFAULT NULL,
PRIMARY KEY (ThemeId),
- KEY Enabled (Enabled),
+ KEY Status (Status),
KEY StylesheetId (StylesheetId),
KEY PrimaryTheme (PrimaryTheme),
KEY LanguagePackInstalled (LanguagePackInstalled)
Index: core/install/upgrades.sql
===================================================================
--- core/install/upgrades.sql
+++ core/install/upgrades.sql
@@ -3052,3 +3052,12 @@
UPDATE PromoBlocks SET ScheduleToDate = ScheduleToDate + 86399 WHERE DATE_FORMAT(FROM_UNIXTIME(ScheduleTodate), "%H%i") = "0000";
DELETE FROM LanguageLabels WHERE PhraseKey = "LA_FLD_SCHEDULEDATE";
+
+ALTER TABLE Themes
+ CHANGE Enabled Status INT(11) NOT NULL DEFAULT 1,
+ ADD AddedOn int(11) DEFAULT NULL,
+ ADD DeletedOn int(11) DEFAULT NULL;
+
+DELETE FROM Permissions WHERE Permission = 'in-portal:configure_themes.delete';
+DELETE FROM UserPersistentSessionData WHERE VariableName = 'theme[Default]columns_.';
+UPDATE Themes SET AddedOn = UNIX_TIMESTAMP();
Index: core/kernel/application.php
===================================================================
--- core/kernel/application.php
+++ core/kernel/application.php
@@ -525,7 +525,7 @@
/** @var ThemeItem $theme */
$theme = $this->recallObject('theme.current');
- if ( !$theme->isLoaded() || !$theme->GetDBField('Enabled') ) {
+ if ( !$theme->isLoaded() || $theme->GetDBField('Status') != ThemeStatus::ACTIVE ) {
return false;
}
@@ -612,7 +612,7 @@
$sql = 'SELECT ' . $theme_config->getIDField() . '
FROM ' . $theme_config->getTableName() . '
- WHERE (PrimaryTheme = 1) AND (Enabled = 1)';
+ WHERE (PrimaryTheme = 1) AND (Status = ' . ThemeStatus::ACTIVE . ')';
$theme_id = $this->Conn->GetOne($sql);
if ( $theme_id !== false ) {
Index: core/kernel/constants.php
===================================================================
--- core/kernel/constants.php
+++ core/kernel/constants.php
@@ -235,3 +235,10 @@
const STATUS_SKIPPED = 3;
}
+
+ class ThemeStatus
+ {
+ const ACTIVE = 1;
+ const DISABLED = 0;
+ const DELETED = 2;
+ }
Index: core/kernel/managers/rewrite_url_processor.php
===================================================================
--- core/kernel/managers/rewrite_url_processor.php
+++ core/kernel/managers/rewrite_url_processor.php
@@ -634,7 +634,7 @@
$sql = 'SELECT ThemeId, IF(LOWER(Name) = ' . $this->Conn->qstr($url_part) . ', 2, PrimaryTheme) AS SortKey, TemplateAliases
FROM ' . TABLE_PREFIX . 'Themes
- WHERE Enabled = 1
+ WHERE Status = ' . ThemeStatus::ACTIVE . '
ORDER BY SortKey DESC';
$theme_info = $this->Conn->GetRow($sql);
Index: core/kernel/nparser/compiler.php
===================================================================
--- core/kernel/nparser/compiler.php
+++ core/kernel/nparser/compiler.php
@@ -92,7 +92,7 @@
// find Front-End templates (from enabled themes only)
$sql = 'SELECT Name
FROM ' . $this->Application->getUnitConfig('theme')->getTableName() . '
- WHERE Enabled = 1';
+ WHERE Status = ' . ThemeStatus::ACTIVE;
$themes = $this->Conn->GetCol($sql);
$options = Array ();
@@ -139,4 +139,4 @@
}
}
-}
\ No newline at end of file
+}
Index: core/units/admin/admin_events_handler.php
===================================================================
--- core/units/admin/admin_events_handler.php
+++ core/units/admin/admin_events_handler.php
@@ -1160,7 +1160,7 @@
// rules from all enabled themes
$sql = 'SELECT ImageResizeRules
FROM ' . $this->Application->getUnitConfig('theme')->getTableName() . '
- WHERE Enabled = 1';
+ WHERE Status = ' . ThemeStatus::ACTIVE;
$mass_resizer->addRules($this->Conn->GetCol($sql));
$mass_resizer->run();
Index: core/units/categories/categories_config.php
===================================================================
--- core/units/categories/categories_config.php
+++ core/units/categories/categories_config.php
@@ -354,7 +354,7 @@
IF(tf.TemplateAlias <> "", tf.TemplateAlias, CONCAT(FilePath, "/", TRIM(TRAILING ".tpl" FROM FileName))) AS Value
FROM ' . TABLE_PREFIX . 'ThemeFiles AS tf
LEFT JOIN ' . TABLE_PREFIX . 'Themes AS t ON t.ThemeId = tf.ThemeId
- WHERE (t.Enabled = 1) AND (tf.FileName NOT LIKE "%%.elm.tpl") AND (tf.FileName NOT LIKE "%%.des.tpl") AND (tf.FilePath = "/designs")
+ WHERE (t.Status = ' . ThemeStatus::ACTIVE . ') AND (tf.FileName NOT LIKE "%%.elm.tpl") AND (tf.FileName NOT LIKE "%%.des.tpl") AND (tf.FilePath = "/designs")
ORDER BY tf.Description ASC, tf.FileName ASC',
'option_key_field' => 'Value', 'option_title_field' => 'Title',
'error_msgs' => Array (
Index: core/units/categories/categories_event_handler.php
===================================================================
--- core/units/categories/categories_event_handler.php
+++ core/units/categories/categories_event_handler.php
@@ -2119,7 +2119,7 @@
$sql = 'SELECT Name, ' . $id_field . '
FROM ' . $table_name . '
- WHERE Enabled = 1';
+ WHERE Status = ' . ThemeStatus::ACTIVE;
$themes = $this->Conn->GetCol($sql, $id_field);
}
@@ -2363,7 +2363,7 @@
$sql = 'SELECT t.ThemeId, CONCAT( tf.FilePath, \'/\', tf.FileName ) AS Path, tf.FileMetaInfo
FROM ' . TABLE_PREFIX . 'ThemeFiles AS tf
LEFT JOIN ' . TABLE_PREFIX . 'Themes AS t ON t.ThemeId = tf.ThemeId
- WHERE t.Enabled = 1 AND tf.FileType = 1
+ WHERE t.Status = ' . ThemeStatus::ACTIVE . ' AND tf.FileType = 1
AND (
SELECT COUNT(CategoryId)
FROM ' . TABLE_PREFIX . 'Categories c
Index: core/units/helpers/themes_helper.php
===================================================================
--- core/units/helpers/themes_helper.php
+++ core/units/helpers/themes_helper.php
@@ -69,18 +69,32 @@
if ($theme_info) {
$theme_id = $theme_info[$id_field];
- $theme_enabled = $theme_info['Enabled'];
+
+ if ( $theme_info['Status'] == ThemeStatus::DELETED ) {
+ $theme_info['Status'] = ThemeStatus::DISABLED;
+
+ $fields_hash = array(
+ 'Status' => ThemeStatus::DISABLED,
+ 'DeletedOn' => null,
+ 'AddedOn' => time(),
+ );
+
+ $this->Conn->doUpdate($fields_hash, $table_name, $id_field . '=' . $theme_id);
+ }
+
+ $theme_disabled = $theme_info['Status'] == ThemeStatus::DISABLED;
}
else {
- $theme_id = $theme_enabled = false;
+ $theme_id = false;
+ $theme_disabled = true;
}
$this->themeFiles = Array ();
$theme_path = $this->themesFolder . '/' . $theme_name;
- if ($theme_id) {
- if (!$theme_enabled) {
- // don't process existing theme files, that are disabled
+ if ( $theme_id ) {
+ if ( $theme_disabled ) {
+ // Don't process existing theme files, that are disabled.
return $theme_id;
}
@@ -102,7 +116,8 @@
$theme_info = Array (
'Name' => $theme_name,
- 'Enabled' => 0,
+ 'Status' => ThemeStatus::DISABLED,
+ 'AddedOn' => time(),
'Description' => $theme_name,
'PrimaryTheme' => 0,
'CacheTimeout' => 3600, // not in use right now
@@ -114,8 +129,8 @@
$this->Conn->doInsert($theme_info, $table_name);
$theme_id = $this->Conn->getInsertID();
- if (!$theme_enabled) {
- // don't process newly created theme files, because they are disabled
+ if ( $theme_disabled ) {
+ // Don't process newly created theme files, because they are disabled.
return $theme_id;
}
}
@@ -554,7 +569,7 @@
// 1. only one theme found -> enable it and make primary
/*if (count($themes_found) == 1) {
$sql = 'UPDATE ' . $table_name . '
- SET Enabled = 1, PrimaryTheme = 1
+ SET Status = ' . ThemeStatus::ACTIVE . ', PrimaryTheme = 1
WHERE ' . $id_field . ' = ' . current($themes_found);
$this->Conn->Query($sql);
}*/
@@ -596,13 +611,16 @@
$config = $this->Application->getUnitConfig('theme');
$id_field = $config->getIDField();
- $sql = 'DELETE FROM '. $config->getTableName() .'
- WHERE '.$id_field.' IN ('.implode(',', $theme_ids).')';
- $this->Conn->Query($sql);
+ $fields_hash = array(
+ 'Status' => ThemeStatus::DELETED,
+ 'DeletedOn' => time(),
+ );
- $sql = 'DELETE FROM '.TABLE_PREFIX.'ThemeFiles
- WHERE '.$id_field.' IN ('.implode(',', $theme_ids).')';
- $this->Conn->Query($sql);
+ $this->Conn->doUpdate(
+ $fields_hash,
+ $config->getTableName(),
+ $id_field . ' IN (' . implode(',', $theme_ids) . ')'
+ );
}
/**
@@ -628,7 +646,7 @@
$sql = 'SELECT ' . $config->getIDField() . '
FROM ' . $config->getTableName() . '
- WHERE (PrimaryTheme = 1) AND (Enabled = 1)';
+ WHERE (PrimaryTheme = 1) AND (Status = ' . ThemeStatus::ACTIVE . ')';
$theme_id = $this->Conn->GetOne($sql);
}
Index: core/units/site_domains/site_domains_config.php
===================================================================
--- core/units/site_domains/site_domains_config.php
+++ core/units/site_domains/site_domains_config.php
@@ -123,12 +123,12 @@
),
'PrimaryThemeId' => Array (
'type' => 'int',
- 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Themes WHERE Enabled = 1 ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Themes WHERE Status = ' . ThemeStatus::ACTIVE . ' ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
'not_null' => 1, 'default' => 0
),
'Themes' => Array (
'type' => 'string', 'max_len' => 255,
- 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Themes WHERE Enabled = 1 ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Themes WHERE Status = ' . ThemeStatus::ACTIVE . ' ORDER BY Name ASC', 'option_key_field' => 'ThemeId', 'option_title_field' => 'Name',
'not_null' => 1, 'default' => ''
),
'DomainIPRange' => Array ('type' => 'string', 'default' => NULL),
Index: core/units/structure/structure_config.php
===================================================================
--- core/units/structure/structure_config.php
+++ core/units/structure/structure_config.php
@@ -166,7 +166,7 @@
CONCAT(FilePath, "/", TRIM(TRAILING ".tpl" FROM FileName)) AS Value
FROM ' . TABLE_PREFIX . 'ThemeFiles AS tf
LEFT JOIN ' . TABLE_PREFIX . 'Themes AS t ON t.ThemeId = tf.ThemeId
- WHERE (t.Enabled = 1) AND (tf.FileName NOT LIKE "%%.elm.tpl") AND (tf.FileName NOT LIKE "%%.des.tpl") AND (tf.FilePath = "/designs")',
+ WHERE (t.Status = ' . ThemeStatus::ACTIVE . ') AND (tf.FileName NOT LIKE "%%.elm.tpl") AND (tf.FileName NOT LIKE "%%.des.tpl") AND (tf.FilePath = "/designs")',
'option_key_field' => 'Value', 'option_title_field' => 'Title',
'not_null' => 1, 'default' => CATEGORY_TEMPLATE_INHERIT
),

Event Timeline