aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/themes.class.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2010-03-26 14:16:54 +0000
committerplegall <plg@piwigo.org>2010-03-26 14:16:54 +0000
commitb8a9773caf30db55f52e9562166054b0917dc990 (patch)
treed1967565dab6d621f066923dea03135eed9a0c86 /admin/include/themes.class.php
parent6d006303328909b111a9db1ac4199f0a993adb8b (diff)
feature 1514: make the "deactivate" action inactive if there is no active
theme left. bug fixed: when setting the default theme, make sure at least one user will be updated. git-svn-id: http://piwigo.org/svn/trunk@5382 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/include/themes.class.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/admin/include/themes.class.php b/admin/include/themes.class.php
index 86651f55f..524462306 100644
--- a/admin/include/themes.class.php
+++ b/admin/include/themes.class.php
@@ -117,6 +117,16 @@ INSERT INTO ".THEMES_TABLE."
break;
}
+ // you can't deactivate the last theme
+ if (count($this->db_themes_by_id) <= 1)
+ {
+ array_push(
+ $errors,
+ l10n('Impossible to deactivate this theme, you need at least one theme.')
+ );
+ break;
+ }
+
if ($theme_id == get_default_theme())
{
// find a random theme to replace
@@ -227,6 +237,8 @@ DELETE
function set_default_theme($theme_id)
{
+ global $conf;
+
// first we need to know which users are using the current default theme
$default_theme = get_default_theme();
@@ -236,7 +248,12 @@ SELECT
FROM '.USER_INFOS_TABLE.'
WHERE theme = "'.$default_theme.'"
;';
- $user_ids = array_from_query($query, 'user_id');
+ $user_ids = array_unique(
+ array_merge(
+ array_from_query($query, 'user_id'),
+ array($conf['guest_id'], $conf['default_user_id'])
+ )
+ );
// $user_ids can't be empty, at least the default user has the default
// theme