Index: core/admin_templates/themes/themes_edit.tpl =================================================================== --- core/admin_templates/themes/themes_edit.tpl +++ core/admin_templates/themes/themes_edit.tpl @@ -57,9 +57,9 @@ <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="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="Enabled" title="la_fld_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/admin_templates/themes/themes_list.tpl =================================================================== --- core/admin_templates/themes/themes_list.tpl +++ core/admin_templates/themes/themes_list.tpl @@ -20,11 +20,6 @@ } ) ); a_toolbar.AddButton( new ToolBarButton('edit', '<inp2:m_phrase label="la_ToolTip_Edit" escape="1"/>::<inp2:m_phrase label="la_ShortToolTip_Edit" escape="1"/>', edit) ); - a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>', - function() { - std_delete_items('theme') - } ) ); - a_toolbar.AddButton( new ToolBarSeparator('sep1') ); @@ -56,7 +51,7 @@ <inp2:m_RenderElement name="grid" PrefixSpecial="theme" IdField="ThemeId" grid="Default"/> <script type="text/javascript"> - Grids['theme'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary') ); + Grids['theme'].SetDependantToolbarButtons( new Array('edit', 'setprimary') ); </script> <inp2:m_include t="incs/footer"/> \ No newline at end of file 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 Enabled = ' . ThemeConstants::STATUS_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', + 'ThemeConstants' => '/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', ), ), + 'ThemeConstants' => array( + 'type' => 1, + 'modifiers' => 0, + ), 'ThemesEventHandler' => array( 'type' => 1, 'modifiers' => 0, Index: core/install/english.lang =================================================================== --- core/install/english.lang +++ core/install/english.lang @@ -244,6 +244,7 @@ <PHRASE Label="la_DataGrid1" Module="Core" Type="1">RGF0YSBHcmlkcw==</PHRASE> <PHRASE Label="la_DataGrid2" Module="Core" Type="1">RGF0YSBHcmlkcyAy</PHRASE> <PHRASE Label="la_days" Module="Core" Type="1">ZGF5cw==</PHRASE> + <PHRASE Label="la_Deleted" Module="Core" Type="1">RGVsZXRlZA==</PHRASE> <PHRASE Label="la_Delete_Confirm" Module="Core" Type="1">QXJlIHlvdSBzdXJlIHlvdSB3YW50IHRvIGRlbGV0ZSB0aGUgaXRlbShzKT8gVGhpcyBhY3Rpb24gY2Fubm90IGJlIHVuZG9uZS4=</PHRASE> <PHRASE Label="la_Description_in-portal:advanced_view" Module="Core" Type="1">VGhpcyBzZWN0aW9uIGFsbG93cyB5b3UgdG8gbWFuYWdlIHNlY3Rpb25zIGFuZCBpdGVtcyBhY3Jvc3MgYWxsIHNlY3Rpb25z</PHRASE> <PHRASE Label="la_Description_in-portal:browse" Module="Core" Type="1">VGhpcyBzZWN0aW9uIGFsbG93cyB5b3UgdG8gYnJvd3NlIHRoZSBjYXRhbG9nIGFuZCBtYW5hZ2Ugc2VjdGlvbnMgYW5kIGl0ZW1z</PHRASE> @@ -326,6 +327,7 @@ <PHRASE Label="la_field_displayorder" Module="Core" Type="1">RGlzcGxheSBPcmRlcg==</PHRASE> <PHRASE Label="la_field_Priority" Module="Core" Type="1">T3JkZXI=</PHRASE> <PHRASE Label="la_fld_Action" Module="Core" Type="1" Column="QWN0aW9u">QWN0aW9u</PHRASE> + <PHRASE Label="la_fld_AddedOn" Module="Core" Type="1" Column="QWRkZWQgT24=">QWRkZWQgT24=</PHRASE> <PHRASE Label="la_fld_AddressLine1" Module="Core" Type="1" Column="QWRkcmVzcyBMaW5lIDE=">QWRkcmVzcyBMaW5lIDE=</PHRASE> <PHRASE Label="la_fld_AddressLine2" Module="Core" Type="1" Column="QWRkcmVzcyBMaW5lIDI=">QWRkcmVzcyBMaW5lIDI=</PHRASE> <PHRASE Label="la_fld_AdminEmail" Module="Core" Type="1">TWVzc2FnZXMgZnJvbSBTaXRlIEFkbWluIGFyZSBmcm9t</PHRASE> @@ -395,6 +397,7 @@ <PHRASE Label="la_fld_CustomTemplate" Module="Core" Type="1">DQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KRGV0YWlscyBUZW1wbGF0ZQ==</PHRASE> <PHRASE Label="la_fld_DateFormat" Module="Core" Type="1">RGF0ZSBGb3JtYXQ=</PHRASE> <PHRASE Label="la_fld_DecimalPoint" Module="Core" Type="1">RGVjaW1hbCBQb2ludA==</PHRASE> + <PHRASE Label="la_fld_DeletedOn" Module="Core" Type="1" Column="RGVsZXRlZCBPbg==">RGVsZXRlZCBPbg==</PHRASE> <PHRASE Label="la_fld_Description" Module="Core" Type="1" Column="RGVzY3JpcHRpb24=">RGVzY3JpcHRpb24=</PHRASE> <PHRASE Label="la_fld_DirectLinkEnabled" Module="Core" Type="1">QWNjZXNzIHdpdGggTGluaw==</PHRASE> <PHRASE Label="la_fld_Display" Module="Core" Type="1">RGlzcGxheQ==</PHRASE> 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 @@ -382,6 +382,8 @@ 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 StylesheetId (StylesheetId), Index: core/install/upgrades.sql =================================================================== --- core/install/upgrades.sql +++ core/install/upgrades.sql @@ -3058,3 +3058,11 @@ 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 + 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('Enabled') != ThemeConstants::STATUS_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 (Enabled = ' . ThemeConstants::STATUS_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 ThemeConstants + { + const STATUS_ACTIVE = 1; + const STATUS_DISABLED = 0; + const STATUS_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 Enabled = ' . ThemeConstants::STATUS_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 Enabled = ' . ThemeConstants::STATUS_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 Enabled = ' . ThemeConstants::STATUS_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.Enabled = ' . ThemeConstants::STATUS_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 Enabled = ' . ThemeConstants::STATUS_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.Enabled = ' . ThemeConstants::STATUS_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['Enabled'] == ThemeConstants::STATUS_DELETED ) { + $theme_info['Enabled'] = ThemeConstants::STATUS_DISABLED; + + $fields_hash = array( + 'Enabled' => ThemeConstants::STATUS_DISABLED, + 'DeletedOn' => null, + 'AddedOn' => time(), + ); + + $this->Conn->doUpdate($fields_hash, $table_name, $id_field . '=' . $theme_id); + } + + $theme_disabled = $theme_info['Enabled'] == ThemeConstants::STATUS_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, + 'Enabled' => ThemeConstants::STATUS_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 Enabled = ' . ThemeConstants::STATUS_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( + 'Enabled' => ThemeConstants::STATUS_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 (Enabled = ' . ThemeConstants::STATUS_ACTIVE . ')'; $theme_id = $this->Conn->GetOne($sql); } 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.Enabled = ' . ThemeConstants::STATUS_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 ), Index: core/units/themes/themes_config.php =================================================================== --- core/units/themes/themes_config.php +++ core/units/themes/themes_config.php @@ -1,6 +1,6 @@ <?php /** -* @version $Id$ +* @version $Id: themes_config.php 16124 2015-01-01 14:06:22Z alex $ * @package In-Portal * @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved. * @license GNU/GPL @@ -32,7 +32,7 @@ ), 'IDField' => 'ThemeId', - 'StatusField' => Array ('Enabled', 'PrimaryTheme'), + 'StatusField' => array('Enabled', 'PrimaryTheme'), 'PermSection' => Array ('main' => 'in-portal:configure_themes'), @@ -42,7 +42,7 @@ 'icon' => 'conf_themes', 'label' => 'la_tab_Themes', 'url' => Array ('t' => 'themes/themes_list', 'pass' => 'm'), - 'permissions' => Array ('view', 'add', 'edit', 'delete'), + 'permissions' => array('view', 'add', 'edit'), 'priority' => 5, 'type' => stTREE, ), @@ -59,7 +59,7 @@ 'themes_list' => Array ( 'prefixes' => Array ('theme_List'), 'format' => "!la_tab_Themes!", - 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'refresh', 'view', 'dbl-click'), + 'toolbar_buttons' => array('new_item', 'edit', 'setprimary', 'refresh', 'view', 'dbl-click'), ), 'themes_edit_general' => Array ( @@ -114,8 +114,8 @@ 'Enabled' => Array ( 'type' => 'int', 'formatter' => 'kOptionsFormatter', - 'options' => Array (0 => 'la_Disabled', 1 => 'la_Enabled'), - 'use_phrases' => 1, 'not_null' => 1, 'default' => 1, + 'options' => array(ThemeConstants::STATUS_DISABLED => 'la_Disabled', ThemeConstants::STATUS_ACTIVE => 'la_Enabled', ThemeConstants::STATUS_DELETED => 'la_Deleted'), + 'use_phrases' => 1, 'not_null' => 1, 'default' => ThemeConstants::STATUS_ACTIVE, ), 'Description' => Array ('type' => 'string', 'formatter' => 'kFormatter', 'using_fck' => 1, 'default' => null), 'PrimaryTheme' => Array ( @@ -139,6 +139,8 @@ 'not_null' => 1, 'default' => '' ), 'ImageResizeRules' => Array ('type' => 'string', 'default' => NULL), + 'AddedOn' => array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => '#NOW#'), + 'DeletedOn' => array('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => null), ), 'Grids' => Array ( @@ -158,7 +160,9 @@ // 'PrimaryTheme' => Array ( 'title' => 'column:la_fld_Primary', 'filter_block' => 'grid_options_filter'), 'LanguagePackInstalled' => Array ('title' => 'la_col_LanguagePackInstalled', 'filter_block' => 'grid_options_filter', 'width' => 200,), 'StylesheetFile' => array('filter_block' => 'grid_like_filter', 'width' => 150, 'hidden' => 1), + 'AddedOn' => array('filter_block' => 'grid_date_range_filter'), + 'DeletedOn' => array('filter_block' => 'grid_date_range_filter'), ), ), ), -); \ No newline at end of file +);