b2evolution PHP Cross Reference Blogging Systems

Source: /inc/users/views/_user_preferences.form.php - 261 lines - 8835 bytes - Text - Print

Description: This file implements the UI view for the user properties. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the UI view for the user properties.
   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   * The Evo Factory grants Francois PLANQUE the right to license
  22   * The Evo Factory's contributions to this file and the b2evolution project
  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24   *
  25   * Daniel HAHLER grants Francois PLANQUE the right to license
  26   * Daniel HAHLER's contributions to this file and the b2evolution project
  27   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  28   * }}
  29   *
  30   * @package admin
  31   *
  32   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  33   * @author efy-maxim: Evo Factory / Maxim.
  34   * @author fplanque: Francois PLANQUE
  35   * @author blueyed: Daniel HAHLER
  36   *
  37   * @version $Id: _user_preferences.form.php 6136 2014-03-08 07:59:48Z manuel $
  38   */
  39  
  40  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  41  
  42  /**
  43   * @var instance of GeneralSettings class
  44   */
  45  global $Settings;
  46  /**
  47   * @var instance of UserSettings class
  48   */
  49  global $UserSettings;
  50  /**
  51   * @var instance of User class
  52   */
  53  global $edited_User;
  54  /**
  55   * @var current action
  56   */
  57  global $action;
  58  /**
  59   * @var user permission, if user is only allowed to edit his profile
  60   */
  61  global $user_profile_only;
  62  /**
  63   * @var Plugins
  64   */
  65  global $Plugins;
  66  /**
  67   * $var AdminUI
  68   */
  69  global $AdminUI;
  70  /**
  71   * @var the action destination of the form (NULL for pagenow)
  72   */
  73  global $form_action;
  74  
  75  
  76  // Default params:
  77  $default_params = array(
  78          'skin_form_params' => array(),
  79      );
  80  
  81  if( isset( $params ) )
  82  {    // Merge with default params
  83      $params = array_merge( $default_params, $params );
  84  }
  85  else
  86  {    // Use a default params
  87      $params = $default_params;
  88  }
  89  
  90  // ------------------- PREV/NEXT USER LINKS -------------------
  91  user_prevnext_links( array(
  92          'block_start'  => '<table class="prevnext_user"><tr>',
  93          'prev_start'   => '<td width="33%">',
  94          'prev_end'     => '</td>',
  95          'prev_no_user' => '<td width="33%">&nbsp;</td>',
  96          'back_start'   => '<td width="33%" class="back_users_list">',
  97          'back_end'     => '</td>',
  98          'next_start'   => '<td width="33%" class="right">',
  99          'next_end'     => '</td>',
 100          'next_no_user' => '<td width="33%">&nbsp;</td>',
 101          'block_end'    => '</tr></table>',
 102          'user_tab'     => 'userprefs'
 103      ) );
 104  // ------------- END OF PREV/NEXT USER LINKS -------------------
 105  
 106  $Form = new Form( $form_action, 'user_checkchanges' );
 107  
 108  $Form->switch_template_parts( $params['skin_form_params'] );
 109  
 110  if( !$user_profile_only )
 111  {
 112      echo_user_actions( $Form, $edited_User, $action );
 113  }
 114  
 115  $is_admin = is_admin_page();
 116  if( $is_admin )
 117  {
 118      $form_title = get_usertab_header( $edited_User, 'userprefs', T_( 'Edit preferences' ) );
 119      $form_class = 'fform';
 120      $Form->title_fmt = '<span style="float:right">$global_icons$</span><div>$title$</div>'."\n";
 121  }
 122  else
 123  {
 124      $form_title = '';
 125      $form_class = 'bComment';
 126  }
 127  
 128  $Form->begin_form( $form_class, $form_title );
 129  
 130      $Form->add_crumb( 'user' );
 131      $Form->hidden_ctrl();
 132      $Form->hidden( 'user_tab', 'userprefs' );
 133      $Form->hidden( 'preferences_form', '1' );
 134  
 135      $Form->hidden( 'user_ID', $edited_User->ID );
 136      $Form->hidden( 'edited_user_login', $edited_User->login );
 137      if( isset( $Blog ) )
 138      {
 139          $Form->hidden( 'blog', $Blog->ID );
 140      }
 141  
 142      /***************  Preferences  **************/
 143  
 144  $Form->begin_fieldset( $is_admin ? T_('Other preferences').get_manual_link('user_preferences') : '', array( 'class'=>'fieldset clear' ) );
 145  
 146  if( $action != 'view' )
 147  { // We can edit the values:
 148  
 149      $Form->select( 'edited_user_locale', $edited_User->get('locale'), 'locale_options_return', T_('Preferred locale'), T_('Preferred locale for admin interface, notifications, etc.'));
 150  
 151      // Enable/disable multiple sessions for the current user
 152      $multiple_sessions = $Settings->get( 'multiple_sessions' );
 153      switch( $multiple_sessions )
 154      {
 155          case 'never':
 156          case 'always':
 157              $multiple_sessions_field_hidden = true;
 158              $multiple_sessions_field_disabled = true;
 159              break;
 160          default:
 161              $multiple_sessions_field_hidden = false;
 162              if( ( $multiple_sessions == 'adminset_default_no' || $multiple_sessions == 'adminset_default_yes' ) && !$current_User->check_perm( 'users', 'edit' ) )
 163              {
 164                  $multiple_sessions_field_disabled = true;
 165              }
 166              else
 167              {
 168                  $multiple_sessions_field_disabled = false;
 169              }
 170      }
 171  
 172      $multiple_sessions_value = $UserSettings->get( 'login_multiple_sessions', $edited_User->ID );
 173  
 174      if( $multiple_sessions_field_hidden )
 175      {
 176          $Form->hidden( 'edited_user_set_login_multiple_sessions', $multiple_sessions_value );
 177      }
 178      else
 179      {
 180          $Form->checkbox( 'edited_user_set_login_multiple_sessions', $multiple_sessions_value, T_('Multiple sessions'),
 181                  T_('Check this if you want to be able to log in from different computers/browsers at the same time. Otherwise, logging in from a new computer/browser will automatically disconnect you on the previous one.'),
 182                  '', 1, $multiple_sessions_field_disabled );
 183      }
 184  
 185      // Session time out for the current user
 186      $timeout_sessions = $UserSettings->get( 'timeout_sessions', $edited_User->ID );
 187      $def_timeout_session = $Settings->get( 'timeout_sessions' );
 188  
 189      if( empty( $timeout_sessions ) )
 190      {
 191          $timeout_sessions_selected = 'default';
 192          $timeout_sessions = $def_timeout_session;
 193      }
 194      else
 195      {
 196          $timeout_sessions_selected = 'custom';
 197      }
 198  
 199      if( ( $current_User->ID == $edited_User->ID ) || ( $current_User->check_perm( 'users', 'edit' ) ) )
 200      {
 201          $Form->radio_input( 'edited_user_timeout_sessions', $timeout_sessions_selected, array(
 202                      array(
 203                          'value'   => 'default',
 204                          'label'   => T_('Use default duration.'),
 205                          'note'    => duration_format( $def_timeout_session ),
 206                          'onclick' => 'jQuery("[id$=timeout_sessions]").hide();' ),
 207                      array(
 208                          'value'   => 'custom',
 209                          'label'   => T_('Use custom duration...'),
 210                          'onclick' => 'jQuery("[id$=timeout_sessions]").show();' ),
 211                  ), T_('Session timeout'), array( 'lines' => true ) );
 212  
 213          // Note: jQuery is not used below ( display:none is used instead ),
 214          // Note: because using jQuery leads to 'timeout_sessions_container' flash for 'default duration' on page load.
 215          $fieldstart = $Form->fieldstart;
 216          if( $timeout_sessions_selected == 'default' )
 217          {
 218              $Form->fieldstart = str_replace( '>', ' style="display:none">', $Form->fieldstart );
 219          }
 220          $Form->duration_input( 'timeout_sessions', $timeout_sessions, T_('Custom duration'), 'months', 'seconds', array( 'minutes_step' => 1 ) );
 221          $Form->fieldstart = $fieldstart;
 222      }
 223      else
 224      {
 225          $Form->info( T_('Session timeout'), $timeout_sessions_selected );
 226      }
 227  
 228      $Form->checkbox( 'edited_user_showonline', $UserSettings->get( 'show_online', $edited_User->ID ), T_('Show online'), T_('Check this to be displayed as online when visiting the site.') );
 229  }
 230  else
 231  { // display only
 232      $Form->info( T_('Preferred locale'), $edited_User->get('locale'), T_('Preferred locale for admin interface, notifications, etc.') );
 233      $Form->info( T_('Show online'), ( $UserSettings->get( 'show_online', $edited_User->ID ) ) ? T_('yes') : T_('no') );
 234  }
 235  
 236  $Form->end_fieldset();
 237  
 238      /***************  Buttons  **************/
 239  
 240  if( $action != 'view' )
 241  { // Edit buttons
 242      $action_buttons = array(
 243          array( '', 'actionArray[update]', T_('Save !'), 'SaveButton' ),
 244          array( 'reset', '', T_('Reset'), 'ResetButton' ) );
 245      if( $is_admin )
 246      {
 247          // dh> TODO: Non-Javascript-confirm before trashing all settings with a misplaced click.
 248          $action_buttons[] = array( 'type' => 'submit', 'name' => 'actionArray[default_settings]', 'value' => T_('Restore defaults'), 'class' => 'ResetButton',
 249              'onclick' => "return confirm('".TS_('This will reset all your user settings.').'\n'.TS_('This cannot be undone.').'\n'.TS_('Are you sure?')."');" );
 250      }
 251      $Form->buttons( $action_buttons );
 252  }
 253  
 254  if( ( $current_User->ID == $edited_User->ID ) && isset( $Blog ) )
 255  {
 256      $Form->info( '', '<a href="'.url_add_param( $Blog->gen_blogurl(), 'disp=closeaccount' ).'">'.T_( 'I want to close my account...' ).'</a>' );
 257  }
 258  
 259  $Form->end_form();
 260  
 261  ?>

title

Description

title

Description

title

Description

title

title

Body