b2evolution PHP Cross Reference Blogging Systems

Source: /inc/regional/time.ctrl.php - 132 lines - 4390 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: time.ctrl.php 13 2011-10-24 23:42:53Z fplanque $

  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 Global Settings:

  40  $UserSettings->set( 'pref_glob_settings_tab', $ctrl );
  41  $UserSettings->set( 'pref_glob_regional_tab', $ctrl );
  42  $UserSettings->dbupdate();
  43  
  44  $AdminUI->set_path( 'options', 'regional', 'time' );
  45  
  46  param( 'action', 'string' );
  47  param( 'edit_locale', 'string' );
  48  param( 'loc_transinfo', 'integer', 0 );
  49  
  50  // Load all available locale defintions:

  51  locales_load_available_defs();
  52  
  53  switch( $action )
  54  {
  55      case 'update':
  56          // UPDATE regional settings

  57  
  58          // Check that this action request is not a CSRF hacked request:

  59          $Session->assert_received_crumb( 'time' );
  60  
  61          // Check permission:

  62          $current_User->check_perm( 'options', 'edit', true );
  63  
  64          param( 'newtime_difference', 'string', '' );
  65          $newtime_difference = trim($newtime_difference);
  66          if( $newtime_difference == '' )
  67          {
  68              $newtime_difference = 0;
  69          }
  70          if( strpos($newtime_difference, ':') !== false )
  71          { // hh:mm:ss format:
  72              $ntd = explode(':', $newtime_difference);
  73              if( count($ntd) > 3 )
  74              {
  75                  param_error( 'newtime_difference', T_('Invalid time format.') );
  76              }
  77              else
  78              {
  79                  $newtime_difference = $ntd[0]*3600 + ($ntd[1]*60);
  80  
  81                  if( count($ntd) == 3 )
  82                  { // add seconds:
  83                      $newtime_difference += $ntd[2];
  84                  }
  85              }
  86          }
  87          else
  88          { // just hours:
  89              $newtime_difference = $newtime_difference*3600;
  90          }
  91  
  92          $Settings->set( 'time_difference', $newtime_difference );
  93  
  94          if( ! $Messages->has_errors() )
  95          {
  96              locale_updateDB();
  97              $Settings->dbupdate();
  98              $Messages->add( T_('Time settings updated.'), 'success' );
  99              // Redirect so that a reload doesn't write to the DB twice:

 100              header_redirect( '?ctrl=time', 303 ); // Will EXIT

 101              // We have EXITed already at this point!!

 102          }
 103  
 104          break;
 105  
 106  }
 107  
 108  $AdminUI->breadcrumbpath_init( false );
 109  $AdminUI->breadcrumbpath_add( T_('System'), '?ctrl=system',
 110          T_('Global settings are shared between all blogs; see Blog settings for more granular settings.') );
 111  $AdminUI->breadcrumbpath_add( T_('Regional settings'), '?ctrl=locales' );
 112  $AdminUI->breadcrumbpath_add( T_('Time'), '?ctrl=time' );
 113  
 114  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)

 115  $AdminUI->disp_html_head();
 116  
 117  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)

 118  $AdminUI->disp_body_top();
 119  
 120  // Begin payload block:

 121  $AdminUI->disp_payload_begin();
 122  
 123  // Display VIEW:

 124  $AdminUI->disp_view( 'regional/views/_time.form.php' );
 125  
 126  // End payload block:

 127  $AdminUI->disp_payload_end();
 128  
 129  // Display body bottom, debug info and close </html>:

 130  $AdminUI->disp_global_footer();
 131  
 132  ?>

title

Description

title

Description

title

Description

title

title

Body