plugins/admin/ThemeManager.php
changeset 976 50f8eb4f53e1
parent 801 eb8b23f11744
child 1081 745200a9cc2a
equal deleted inserted replaced
975:bff25c6113ae 976:50f8eb4f53e1
    14 
    14 
    15 function page_Admin_ThemeManager($force_no_json = false)
    15 function page_Admin_ThemeManager($force_no_json = false)
    16 {
    16 {
    17   global $db, $session, $paths, $template, $plugins; // Common objects
    17   global $db, $session, $paths, $template, $plugins; // Common objects
    18   global $lang;
    18   global $lang;
       
    19   global $cache;
       
    20   
    19   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
    21   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
    20   {
    22   {
    21     $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
    23     $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
    22     echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
    24     echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
    23     echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
    25     echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
   159 
   161 
   160 function ajaxServlet_Admin_ThemeManager(&$themes)
   162 function ajaxServlet_Admin_ThemeManager(&$themes)
   161 {
   163 {
   162   global $db, $session, $paths, $template, $plugins; // Common objects
   164   global $db, $session, $paths, $template, $plugins; // Common objects
   163   global $lang;
   165   global $lang;
       
   166   global $cache;
       
   167   
   164   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
   168   if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
   165   {
   169   {
   166     $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
   170     $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
   167     echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
   171     echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>';
   168     echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
   172     echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>';
   327       if ( $theme_data['make_default'] )
   331       if ( $theme_data['make_default'] )
   328       {
   332       {
   329         setConfig('theme_default', $theme_data['theme_id']);
   333         setConfig('theme_default', $theme_data['theme_id']);
   330       }
   334       }
   331       
   335       
       
   336       $cache->purge('themes');
       
   337       
   332       echo '<div class="info-box"><b>' . $lang->get('acptm_msg_save_success') . '</b>' . $warn_default . '</div>';
   338       echo '<div class="info-box"><b>' . $lang->get('acptm_msg_save_success') . '</b>' . $warn_default . '</div>';
   333       
   339       
   334       page_Admin_ThemeManager(true);
   340       page_Admin_ThemeManager(true);
   335       break;
   341       break;
   336     case 'install':
   342     case 'install':
   358       $q = $db->sql_query('INSERT INTO ' . table_prefix . "themes(theme_id, theme_name, default_style, enabled, group_list, group_policy)\n"
   364       $q = $db->sql_query('INSERT INTO ' . table_prefix . "themes(theme_id, theme_name, default_style, enabled, group_list, group_policy)\n"
   359                         . "  VALUES( '$theme_id', '$theme_name', '$default_style', 1, '[]', 'allow_all' );");
   365                         . "  VALUES( '$theme_id', '$theme_name', '$default_style', 1, '[]', 'allow_all' );");
   360       if ( !$q )
   366       if ( !$q )
   361         $db->die_json();
   367         $db->die_json();
   362       
   368       
       
   369       $cache->purge('themes');
       
   370       
   363       // The response isn't processed unless it's in JSON.
   371       // The response isn't processed unless it's in JSON.
   364       echo 'Roger that, over and out.';
   372       echo 'Roger that, over and out.';
   365       
   373       
   366       break;
   374       break;
   367     case 'uninstall':
   375     case 'uninstall':
   397       
   405       
   398       $q = $db->sql_query('DELETE FROM ' . table_prefix . "themes WHERE theme_id = '$theme_id';");
   406       $q = $db->sql_query('DELETE FROM ' . table_prefix . "themes WHERE theme_id = '$theme_id';");
   399       if ( !$q )
   407       if ( !$q )
   400         $db->die_json();
   408         $db->die_json();
   401       
   409       
       
   410       $cache->purge('themes');
       
   411       
   402       // Change all the users that were on that theme to the default
   412       // Change all the users that were on that theme to the default
   403       $default_style = $template->named_theme_list[$theme_default]['default_style'];
   413       $default_style = $template->named_theme_list[$theme_default]['default_style'];
   404       $default_style = preg_replace('/\.css$/', '', $default_style);
   414       $default_style = preg_replace('/\.css$/', '', $default_style);
   405       
   415       
   406       $theme_default = $db->escape($theme_default);
   416       $theme_default = $db->escape($theme_default);