b2evolution PHP Cross Reference Blogging Systems

Source: /inc/settings/settings.ctrl.php - 168 lines - 6075 bytes - Text - Print

Description: This file implements the UI controller for settings management.

   1  <?php
   2  /**
   3   * This file implements the UI controller for settings management.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  10   *
  11   * {@internal License choice
  12   * - If you have received this file as part of a package, please find the license.txt file in
  13   *   the same folder or the closest folder above for complete license terms.
  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15   *   then you must choose one of the following licenses before using the file:
  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18   * }}
  19   *
  20   * {@internal Open Source relicensing agreement:
  21   * Daniel HAHLER grants Francois PLANQUE the right to license
  22   * Daniel HAHLER's contributions to this file and the b2evolution project
  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24   * }}
  25   *
  26   * @package admin
  27   *
  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  29   * @author blueyed: Daniel HAHLER
  30   * @author fplanque: Francois PLANQUE
  31   *
  32   * @version $Id: settings.ctrl.php 6136 2014-03-08 07:59:48Z manuel $
  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  // Check minimum permission:
  37  $current_User->check_perm( 'options', 'view', true );
  38  
  39  // Memorize this as the last "tab" used in the Blog Settings:
  40  $UserSettings->set( 'pref_glob_settings_tab', $ctrl );
  41  $UserSettings->dbupdate();
  42  
  43  $AdminUI->set_path( 'options', 'general' );
  44  
  45  param( 'action', 'string' );
  46  
  47  switch( $action )
  48  {
  49      case 'update':
  50          // UPDATE general settings:
  51  
  52          // Check that this action request is not a CSRF hacked request:
  53          $Session->assert_received_crumb( 'globalsettings' );
  54  
  55          // Check permission:
  56          $current_User->check_perm( 'options', 'edit', true );
  57  
  58          // Lock system
  59          if( $current_User->check_perm( 'users', 'edit' ) )
  60          {
  61              $system_lock = param( 'system_lock', 'integer', 0 );
  62              if( $Settings->get( 'system_lock' ) && ( ! $system_lock ) && ( ! $Messages->has_errors() ) && ( 1 == $Messages->count() ) )
  63              { // System lock was turned off and there was no error, remove the warning about the system lock
  64                  $Messages->clear();
  65              }
  66              $Settings->set( 'system_lock', $system_lock );
  67          }
  68  
  69          // General cache
  70          $new_cache_status = param( 'general_cache_enabled', 'integer', 0 );
  71          if( ! $Messages->has_errors() )
  72          {
  73              load_funcs( 'collections/model/_blog.funcs.php' );
  74              $result = set_cache_enabled( 'general_cache_enabled', $new_cache_status, NULL, false );
  75              if( $result != NULL )
  76              { // general cache setting was changed
  77                  list( $status, $message ) = $result;
  78                  $Messages->add( $message, $status );
  79              }
  80          }
  81  
  82          // fp> Restore defaults has been removed because it's extra maintenance work and no real benefit to the user.
  83  
  84          // Online help
  85          param( 'webhelp_enabled', 'integer', 0 );
  86          $Settings->set( 'webhelp_enabled', $webhelp_enabled );
  87  
  88          // Hit & Session logs
  89          $Settings->set( 'log_public_hits', param( 'log_public_hits', 'integer', 0 ) );
  90          $Settings->set( 'log_admin_hits', param( 'log_admin_hits', 'integer', 0 ) );
  91          $Settings->set( 'log_spam_hits', param( 'log_spam_hits', 'integer', 0 ) );
  92  
  93          param( 'auto_prune_stats_mode', 'string', true );
  94          $Settings->set( 'auto_prune_stats_mode',  get_param('auto_prune_stats_mode') );
  95  
  96          // TODO: offer to set-up cron job if mode == 'cron' and to remove cron job if mode != 'cron'
  97  
  98          param( 'auto_prune_stats', 'integer', $Settings->get_default('auto_prune_stats'), false, false, true, false );
  99          $Settings->set( 'auto_prune_stats', get_param('auto_prune_stats') );
 100  
 101          if( ! $Messages->has_errors() )
 102          {
 103              $Settings->dbupdate();
 104              $Messages->add( T_('General settings updated.'), 'success' );
 105              // Redirect so that a reload doesn't write to the DB twice:
 106              header_redirect( '?ctrl=gensettings', 303 ); // Will EXIT
 107              // We have EXITed already at this point!!
 108          }
 109          break;
 110  
 111      case 'update_tools':
 112          // UPDATE general settings from tools:
 113  
 114          // Check that this action request is not a CSRF hacked request:
 115          $Session->assert_received_crumb( 'globalsettings' );
 116  
 117          // Check permission:
 118          $current_User->check_perm( 'options', 'edit', true );
 119  
 120          // Lock system
 121          if( $current_User->check_perm( 'users', 'edit' ) )
 122          {
 123              $system_lock = param( 'system_lock', 'integer', 0 );
 124              if( $Settings->get( 'system_lock' ) && ( ! $system_lock ) && ( ! $Messages->has_errors() ) && ( 1 == $Messages->count() ) )
 125              { // System lock was turned off and there was no error, remove the warning about the system lock
 126                  $Messages->clear();
 127              }
 128              $Settings->set( 'system_lock', $system_lock );
 129          }
 130  
 131          if( ! $Messages->has_errors() )
 132          {
 133              $Settings->dbupdate();
 134              $Messages->add( T_('General settings updated.'), 'success' );
 135          }
 136  
 137          // Redirect so that a reload doesn't write to the DB twice:
 138          header_redirect( '?ctrl=tools', 303 ); // Will EXIT
 139          // We have EXITed already at this point!!
 140          break;
 141  }
 142  
 143  
 144  $AdminUI->breadcrumbpath_init( false );
 145  $AdminUI->breadcrumbpath_add( T_('System'), '?ctrl=system',
 146          T_('Global settings are shared between all blogs; see Blog settings for more granular settings.') );
 147  $AdminUI->breadcrumbpath_add( T_('General'), '?ctrl=gensettings' );
 148  
 149  
 150  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
 151  $AdminUI->disp_html_head();
 152  
 153  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
 154  $AdminUI->disp_body_top();
 155  
 156  // Begin payload block:
 157  $AdminUI->disp_payload_begin();
 158  
 159  // Display VIEW:
 160  $AdminUI->disp_view( 'settings/views/_general.form.php' );
 161  
 162  // End payload block:
 163  $AdminUI->disp_payload_end();
 164  
 165  // Display body bottom, debug info and close </html>:
 166  $AdminUI->disp_global_footer();
 167  
 168  ?>

title

Description

title

Description

title

Description

title

title

Body