b2evolution PHP Cross Reference Blogging Systems

Source: /inc/users/settings.ctrl.php - 150 lines - 5435 bytes - Text - Print

   1  <?php
   2  
   3  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
   4  
   5  global $demo_mode;
   6  
   7  $AdminUI->set_path( 'users', 'usersettings', 'usersettings' );
   8  
   9  $current_User->check_perm( 'users', 'view', true );
  10  
  11  param_action();
  12  
  13  switch ( $action )
  14  {
  15      case 'update':
  16          // Check that this action request is not a CSRF hacked request:
  17          $Session->assert_received_crumb( 'usersettings' );
  18  
  19          // Check permission:
  20          $current_User->check_perm( 'users', 'edit', true );
  21  
  22          // Session timeout
  23          $timeout_sessions = param_duration( 'timeout_sessions' );
  24  
  25          if( $timeout_sessions < $crumb_expires )
  26          { // lower than $crumb_expires: not allowed
  27              param_error( 'timeout_sessions', sprintf( T_( 'You cannot set a session timeout below %d minutes.' ), floor($crumb_expires/60) ) );
  28          }
  29          elseif( $timeout_sessions < 300 )
  30          { // lower than 5 minutes: not allowed
  31              param_error( 'timeout_sessions', sprintf( T_( 'You cannot set a session timeout below %d minutes.' ), 5 ) );
  32          }
  33          elseif( $timeout_sessions < 86400 )
  34          { // lower than 1 day: notice/warning
  35              $Messages->add( sprintf( T_( 'Warning: your session timeout is just %d minutes. Your users may have to re-login often!' ), floor($timeout_sessions/60) ), 'note' );
  36          }
  37          $Settings->set( 'timeout_sessions', $timeout_sessions );
  38  
  39          // Session timeout
  40          $timeout_online = param_duration( 'timeout_online' );
  41  
  42          if( $timeout_online < 300 )
  43          { // lower than 5 minutes: not allowed
  44              param_error( 'timeout_online', sprintf( T_( 'You cannot set an online/offline timeout below %d minutes.' ), 5 ) );
  45          }
  46          elseif( $timeout_online > 21600 )
  47          { // hihger than 6 hours: notice/warning
  48              $Messages->add( sprintf( T_( 'You cannot set an online/offline timeout above %d hours.' ), 6 ) );
  49          }
  50          $Settings->set( 'timeout_online', $timeout_online );
  51  
  52          // keep old allow_avatars setting value to check if we need to invalidate pagecaches
  53          $old_allow_avatars = $Settings->get( 'allow_avatars' );
  54  
  55          // UPDATE general settings:
  56          param( 'allow_avatars', 'integer', 0 );
  57          $Settings->set( 'allow_avatars', $allow_avatars );
  58  
  59          param( 'uset_min_picture_size', 'integer', 0 );
  60          param( 'uset_nickname_editing', 'string', 'edited-user' );
  61          param( 'uset_firstname_editing', 'string', 'edited-user' );
  62          param( 'uset_lastname_editing', 'string', 'edited-user' );
  63          param( 'uset_location_country', 'string', 'optional' );
  64          param( 'uset_location_region', 'string', 'optional' );
  65          param( 'uset_location_subregion', 'string', 'optional' );
  66          param( 'uset_location_city', 'string', 'optional' );
  67          param( 'uset_minimum_age', 'integer', 0 );
  68          if( $demo_mode )
  69          {
  70              $uset_multiple_sessions = 'always';
  71              $Messages->add( 'Demo mode requires multiple sessions setting to be set to always.', 'note' );
  72          }
  73          else
  74          {
  75              param( 'uset_multiple_sessions', 'string', 'default-no' );
  76          }
  77          param( 'uset_emails_msgform', 'string', 'adminset' );
  78  
  79          if( $uset_location_city == 'required' )
  80          {    // If city is required - all location fields also are required
  81              $uset_location_country = $uset_location_region = $uset_location_subregion = 'required';
  82          }
  83          else if( $uset_location_subregion == 'required' )
  84          {    // If subregion is required - country & region fields also are required
  85              $uset_location_country = $uset_location_region = 'required';
  86          }
  87          else if( $uset_location_region == 'required' )
  88          {    // If region is required - country field also is required
  89              $uset_location_country = 'required';
  90          }
  91  
  92          $Settings->set_array( array(
  93                                      array( 'min_picture_size', $uset_min_picture_size ),
  94                                      array( 'nickname_editing', $uset_nickname_editing ),
  95                                      array( 'firstname_editing', $uset_firstname_editing ),
  96                                      array( 'lastname_editing', $uset_lastname_editing ),
  97                                      array( 'location_country', $uset_location_country ),
  98                                      array( 'location_region', $uset_location_region ),
  99                                      array( 'location_subregion', $uset_location_subregion ),
 100                                      array( 'location_city', $uset_location_city ),
 101                                      array( 'minimum_age', $uset_minimum_age ),
 102                                      array( 'multiple_sessions', $uset_multiple_sessions ),
 103                                      array( 'emails_msgform', $uset_emails_msgform ) ) );
 104  
 105          if( ! $Messages->has_errors() )
 106          {
 107              if( $Settings->dbupdate() )
 108              {
 109                  if( $old_allow_avatars != $allow_avatars )
 110                  { // invalidate all PageCaches
 111                      invalidate_pagecaches();
 112                  }
 113  
 114                  $Messages->add( T_('General settings updated.'), 'success' );
 115              }
 116          }
 117  
 118          // Redirect so that a reload doesn't write to the DB twice:
 119          header_redirect( '?ctrl=usersettings', 303 ); // Will EXIT
 120          // We have EXITed already at this point!!
 121  
 122          break;
 123  }
 124  
 125  
 126  $AdminUI->breadcrumbpath_init( false );  // fp> I'm playing with the idea of keeping the current blog in the path here...
 127  $AdminUI->breadcrumbpath_add( T_('Users'), '?ctrl=users' );
 128  $AdminUI->breadcrumbpath_add( T_('Settings'), '?ctrl=settings' );
 129  $AdminUI->breadcrumbpath_add( T_('Profiles'), '?ctrl=usersettings' );
 130  
 131  
 132  // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
 133  $AdminUI->disp_html_head();
 134  
 135  // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
 136  $AdminUI->disp_body_top();
 137  
 138  // Begin payload block:
 139  $AdminUI->disp_payload_begin();
 140  
 141  // Display VIEW:
 142  $AdminUI->disp_view( 'users/views/_settings.form.php' );
 143  
 144  // End payload block:
 145  $AdminUI->disp_payload_end();
 146  
 147  // Display body bottom, debug info and close </html>:
 148  $AdminUI->disp_global_footer();
 149  
 150  ?>

title

Description

title

Description

title

Description

title

title

Body