Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1046604
D12.id194.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jun 28, 8:58 PM
Size
13 KB
Mime Type
text/x-diff
Expires
Sun, Jun 29, 8:58 PM (4 h, 12 m)
Engine
blob
Format
Raw Data
Handle
676620
Attached To
D12: INP-1312 - Mark themes as deleted instead of actually deleting them
D12.id194.diff
View Options
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/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/english.lang
===================================================================
--- core/install/english.lang
+++ core/install/english.lang
@@ -243,6 +243,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>
@@ -393,6 +394,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
@@ -680,7 +680,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,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
@@ -3021,4 +3021,11 @@
ALTER TABLE SiteDomains
CHANGE SSLUrl SSLDomainName VARCHAR(255) NOT NULL DEFAULT '',
CHANGE SSLUrlUsesRegExp SSLDomainNameUsesRegExp TINYINT(4) NOT NULL DEFAULT '0';
-DELETE FROM UserPersistentSessionData WHERE VariableName = 'site-domain[Default]columns_.';
\ No newline at end of file
+DELETE FROM UserPersistentSessionData WHERE VariableName = 'site-domain[Default]columns_.';
+
+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';
Index: core/kernel/constants.php
===================================================================
--- core/kernel/constants.php
+++ core/kernel/constants.php
@@ -233,3 +233,10 @@
const STATUS_SKIPPED = 3;
}
+
+ class ThemeStatus
+ {
+ const ACTIVE = 1;
+ const DISABLED = 0;
+ const DELETED = 2;
+ }
Index: core/units/helpers/themes_helper.php
===================================================================
--- core/units/helpers/themes_helper.php
+++ core/units/helpers/themes_helper.php
@@ -69,7 +69,20 @@
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' => mktime(),
+ );
+
+ $this->Conn->doUpdate($fields_hash, $table_name, $id_field . '=' . $theme_id);
+ }
+
+ $theme_enabled = $theme_info['Status'];
}
else {
$theme_id = $theme_enabled = false;
@@ -102,7 +115,7 @@
$theme_info = Array (
'Name' => $theme_name,
- 'Enabled' => 0,
+ 'Status' => ThemeStatus::DISABLED,
'Description' => $theme_name,
'PrimaryTheme' => 0,
'CacheTimeout' => 3600, // not in use right now
@@ -596,13 +609,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' => mktime(),
+ );
- $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 +644,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/themes/themes_config.php
===================================================================
--- core/units/themes/themes_config.php
+++ core/units/themes/themes_config.php
@@ -32,7 +32,7 @@
),
'IDField' => 'ThemeId',
- 'StatusField' => Array ('Enabled', 'PrimaryTheme'),
+ 'StatusField' => array('Status', '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 (
@@ -111,11 +111,11 @@
'Fields' => Array (
'ThemeId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'Name' => Array ('type' => 'string', 'not_null' => 1, 'required' => 1, 'default' => ''),
- 'Enabled' => Array (
+ 'Status' => array(
'type' => 'int',
'formatter' => 'kOptionsFormatter',
- 'options' => Array (0 => 'la_Disabled', 1 => 'la_Enabled'),
- 'use_phrases' => 1, 'not_null' => 1, 'default' => 1,
+ 'options' => array(ThemeStatus::DISABLED => 'la_Disabled', ThemeStatus::ACTIVE => 'la_Enabled', ThemeStatus::DELETED => 'la_Deleted'),
+ 'use_phrases' => 1, 'not_null' => 1, 'default' => ThemeStatus::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 (
@@ -154,11 +156,13 @@
'ThemeId' => Array ('title' => 'column:la_fld_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter', 'width' => 50, ),
'Name' => Array ('filter_block' => 'grid_like_filter', 'width' => 200, ),
'Description' => Array ('filter_block' => 'grid_like_filter', 'width' => 250, ),
- 'Enabled' => Array ( 'title' => 'column:la_fld_Status', 'filter_block' => 'grid_options_filter', 'width' => 200, ),
+ 'Status' => array('filter_block' => 'grid_options_filter', 'width' => 200),
// '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
+);
Index: core/units/themes/themes_eh.php
===================================================================
--- core/units/themes/themes_eh.php
+++ core/units/themes/themes_eh.php
@@ -126,7 +126,7 @@
$sql = 'UPDATE '.$table_name.'
- SET PrimaryTheme = 1, Enabled = 1
+ SET PrimaryTheme = 1, Status = ' . ThemeStatus::ACTIVE . '
WHERE '. $config->getIDField() .' = '.$id;
$this->Conn->Query($sql);
}
@@ -191,7 +191,7 @@
$sql = 'SELECT COUNT(*)
FROM ' . $config->getTableName() . '
- WHERE ' . $config->getIDField() . ' IN (' . $ids . ') AND (Enabled = 1)';
+ WHERE ' . $config->getIDField() . ' IN (' . $ids . ') AND (Status = ' . ThemeStatus::ACTIVE . ')';
$enabled_themes = $this->Conn->GetOne($sql);
if ( $enabled_themes ) {
@@ -236,7 +236,7 @@
if ( in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser ) {
// "enabled" special or Front-End
- $object->addFilter('enabled_filter', '%1$s.Enabled = ' . STATUS_ACTIVE);
+ $object->addFilter('status_filter', '%1$s.Status = ' . ThemeStatus::ACTIVE);
}
// site domain theme picker
Event Timeline
Log In to Comment