Changeset 5382


Ignore:
Timestamp:
03/26/10 15:16:54 (10 years ago)
Author:
plg
Message:

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.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/themes.class.php

    r5340 r5382  
    118118        } 
    119119 
     120        // you can't deactivate the last theme 
     121        if (count($this->db_themes_by_id) <= 1) 
     122        { 
     123          array_push( 
     124            $errors, 
     125            l10n('Impossible to deactivate this theme, you need at least one theme.') 
     126            ); 
     127          break; 
     128        } 
     129 
    120130        if ($theme_id == get_default_theme()) 
    121131        { 
     
    228238  function set_default_theme($theme_id) 
    229239  { 
     240    global $conf; 
     241     
    230242    // first we need to know which users are using the current default theme 
    231243    $default_theme = get_default_theme(); 
     
    237249  WHERE theme = "'.$default_theme.'" 
    238250;'; 
    239     $user_ids = array_from_query($query, 'user_id'); 
     251    $user_ids = array_unique( 
     252      array_merge( 
     253        array_from_query($query, 'user_id'), 
     254        array($conf['guest_id'], $conf['default_user_id']) 
     255        ) 
     256      ); 
    240257 
    241258    // $user_ids can't be empty, at least the default user has the default 
  • trunk/admin/themes/default/template/themes_installed.tpl

    r5284 r5382  
    1414    <div class="themeShot"><img src="{$theme.screenshot}"></div> 
    1515    <div class="themeActions"> 
     16 
     17{if $theme.deactivable} 
    1618      <a href="{$deactivate_baseurl}{$theme.id}" title="{'Forbid this theme to users'|@translate}">{'Deactivate'|@translate}</a> 
     19{else} 
     20      <span title="{$theme.deactivate_tooltip}">{'Deactivate'|@translate}</span> 
     21{/if} 
     22       
    1723{if not $theme.is_default} 
    1824      | <a href="{$set_default_baseurl}{$theme.id}" title="{'Set as default theme for unregistered and new users'|@translate}">{'Default'|@translate}</a> 
  • trunk/admin/themes_installed.php

    r5259 r5382  
    7878  if (in_array($theme_id, $db_theme_ids)) 
    7979  { 
     80    $fs_theme['deactivable'] = true; 
     81     
     82    if (count($db_theme_ids) <= 1) 
     83    { 
     84      $fs_theme['deactivable'] = false; 
     85      $fs_theme['deactivate_tooltip'] = l10n('Impossible to deactivate this theme, you need at least one theme.'); 
     86    } 
     87     
    8088    if ($theme_id == $default_theme) 
    8189    { 
  • trunk/language/en_UK/admin.lang.php

    r5381 r5382  
    759759$lang['None'] = 'None'; 
    760760$lang['Invert'] = 'Invert'; 
     761$lang['Impossible to deactivate this theme, you need at least one theme.'] = 'Impossible to deactivate this theme, you need at least one theme.'; 
    761762?> 
  • trunk/language/fr_FR/admin.lang.php

    r5381 r5382  
    764764$lang['None'] = 'Rien'; 
    765765$lang['Invert'] = 'Inverser'; 
     766$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é.'; 
    766767?> 
Note: See TracChangeset for help on using the changeset viewer.