aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/include/themes.class.php19
-rw-r--r--admin/themes/default/template/themes_installed.tpl6
-rw-r--r--admin/themes_installed.php8
-rw-r--r--language/en_UK/admin.lang.php1
-rw-r--r--language/fr_FR/admin.lang.php1
5 files changed, 34 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
diff --git a/admin/themes/default/template/themes_installed.tpl b/admin/themes/default/template/themes_installed.tpl
index 28d4df66a..5bb18ae57 100644
--- a/admin/themes/default/template/themes_installed.tpl
+++ b/admin/themes/default/template/themes_installed.tpl
@@ -13,7 +13,13 @@
<div class="themeName">{$theme.name}{if $theme.is_default} <em>({'default'|@translate})</em>{/if}</div>
<div class="themeShot"><img src="{$theme.screenshot}"></div>
<div class="themeActions">
+
+{if $theme.deactivable}
<a href="{$deactivate_baseurl}{$theme.id}" title="{'Forbid this theme to users'|@translate}">{'Deactivate'|@translate}</a>
+{else}
+ <span title="{$theme.deactivate_tooltip}">{'Deactivate'|@translate}</span>
+{/if}
+
{if not $theme.is_default}
| <a href="{$set_default_baseurl}{$theme.id}" title="{'Set as default theme for unregistered and new users'|@translate}">{'Default'|@translate}</a>
{/if}
diff --git a/admin/themes_installed.php b/admin/themes_installed.php
index dda2ab6ed..7ef26ead7 100644
--- a/admin/themes_installed.php
+++ b/admin/themes_installed.php
@@ -77,6 +77,14 @@ foreach ($themes->fs_themes as $theme_id => $fs_theme)
if (in_array($theme_id, $db_theme_ids))
{
+ $fs_theme['deactivable'] = true;
+
+ if (count($db_theme_ids) <= 1)
+ {
+ $fs_theme['deactivable'] = false;
+ $fs_theme['deactivate_tooltip'] = l10n('Impossible to deactivate this theme, you need at least one theme.');
+ }
+
if ($theme_id == $default_theme)
{
$fs_theme['is_default'] = true;
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index b62343cc4..1ca66483a 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -758,4 +758,5 @@ $lang['Language has been successfully installed'] = 'Language has been successfu
$lang['Select:'] = 'Select:';
$lang['None'] = 'None';
$lang['Invert'] = 'Invert';
+$lang['Impossible to deactivate this theme, you need at least one theme.'] = 'Impossible to deactivate this theme, you need at least one theme.';
?>
diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php
index 3c8f7468d..4ffaa97f7 100644
--- a/language/fr_FR/admin.lang.php
+++ b/language/fr_FR/admin.lang.php
@@ -763,4 +763,5 @@ $lang['Allow user customization'] = "Permettre la personnalisation de l'affichag
$lang['Select:'] = 'Sélectionner:';
$lang['None'] = 'Rien';
$lang['Invert'] = 'Inverser';
+$lang['Impossible to deactivate this theme, you need at least one theme.'] = 'Impossible de désactiver ce thème, il doit rester au moins un thème activé.';
?>