b2evolution PHP Cross Reference Blogging Systems

Source: /inc/users/views/_user_advanced.form.php - 266 lines - 9803 bytes - Summary - Text - Print

Description: This file implements the UI view for the user advanced 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 advanced 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   *
  10   * {@internal License choice
  11   * - If you have received this file as part of a package, please find the license.txt file in
  12   *   the same folder or the closest folder above for complete license terms.
  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  14   *   then you must choose one of the following licenses before using the file:
  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  17   * }}
  18   *
  19   * {@internal Open Source relicensing agreement:
  20   * The Evo Factory grants Francois PLANQUE the right to license
  21   * The Evo Factory's contributions to this file and the b2evolution project
  22   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  23   * }}
  24   *
  25   * @package admin
  26   *
  27   * @author fplanque: Francois PLANQUE
  28   * @author efy-asimo: Attila SIMO
  29   *
  30   * @version $Id: _user_advanced.form.php 6136 2014-03-08 07:59:48Z manuel $
  31   */
  32  
  33  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  34  
  35  /**
  36   * @var instance of GeneralSettings class
  37   */
  38  global $Settings;
  39  /**
  40   * @var instance of UserSettings class
  41   */
  42  global $UserSettings;
  43  /**
  44   * @var instance of User class
  45   */
  46  global $edited_User;
  47  /**
  48   * @var current action
  49   */
  50  global $action;
  51  /**
  52   * @var user permission, if user is only allowed to edit his profile
  53   */
  54  global $user_profile_only;
  55  /**
  56   * @var Plugins
  57   */
  58  global $Plugins;
  59  /**
  60   * $var AdminUI
  61   */
  62  global $AdminUI;
  63  
  64  
  65  // Admin skin dropdown list handler
  66  // Display settings corresponding only for the current (loaded) admin skin
  67  ?>
  68  <script type="text/javascript">
  69  	function admin_skin_changed()
  70      {
  71          // admin skin dropdown list selected value
  72          var val = jQuery( '#edited_user_admin_skin' ).val();
  73  
  74          if( val == null )
  75          { // there is no admin skin drop down list
  76              return;
  77          }
  78  
  79          if( val != jQuery( '[name |= current_admin_skin]' ).val() )
  80          { // popup selected value is different then current admin skin => hide skin settings
  81              jQuery( '#admin_skin_settings_div' ).hide();
  82          }
  83          else
  84          { // popup selected value is the same as the current admin skin => show skin settings
  85              jQuery( '#admin_skin_settings_div' ).show();
  86          }
  87      }
  88  </script>
  89  <?php
  90  
  91  
  92  // Begin payload block:
  93  $this->disp_payload_begin();
  94  
  95  // ------------------- PREV/NEXT USER LINKS -------------------
  96  user_prevnext_links( array(
  97          'block_start'  => '<table class="prevnext_user"><tr>',
  98          'prev_start'   => '<td width="33%">',
  99          'prev_end'     => '</td>',
 100          'prev_no_user' => '<td width="33%">&nbsp;</td>',
 101          'back_start'   => '<td width="33%" class="back_users_list">',
 102          'back_end'     => '</td>',
 103          'next_start'   => '<td width="33%" class="right">',
 104          'next_end'     => '</td>',
 105          'next_no_user' => '<td width="33%">&nbsp;</td>',
 106          'block_end'    => '</tr></table>',
 107          'user_tab'     => 'advanced'
 108      ) );
 109  // ------------- END OF PREV/NEXT USER LINKS -------------------
 110  
 111  $Form = new Form( NULL, 'user_checkchanges' );
 112  
 113  $Form->title_fmt = '<span style="float:right">$global_icons$</span><div>$title$</div>'."\n";
 114  
 115  if( !$user_profile_only )
 116  {
 117      echo_user_actions( $Form, $edited_User, $action );
 118  }
 119  
 120  $Form->begin_form( 'fform', get_usertab_header( $edited_User, 'advanced', T_( 'Edit advanced preferences' ) ) );
 121  
 122      $Form->add_crumb( 'user' );
 123      $Form->hidden_ctrl();
 124      $Form->hidden( 'user_tab', 'advanced' );
 125      $Form->hidden( 'advanced_form', '1' );
 126  
 127      $Form->hidden( 'user_ID', $edited_User->ID );
 128      $Form->hidden( 'edited_user_login', $edited_User->login );
 129  
 130      /***************  Preferences  **************/
 131  
 132  $Form->begin_fieldset( T_('Preferences').get_manual_link('user_preferences') );
 133  
 134  $value_admin_skin = get_param('edited_user_admin_skin');
 135  if( !$value_admin_skin )
 136  { // no value supplied through POST/GET
 137      $value_admin_skin = $UserSettings->get( 'admin_skin', $edited_User->ID );
 138  }
 139  if( !$value_admin_skin )
 140  { // Nothing set yet for the user, use the default
 141      $value_admin_skin = $Settings->get('admin_skin');
 142  }
 143  
 144  $Form->hidden( 'current_admin_skin', $value_admin_skin );
 145  
 146  if( $action != 'view' )
 147  { // We can edit the values:
 148  
 149      $Form->select_input_array( 'edited_user_admin_skin', $value_admin_skin, get_admin_skins(), T_('Admin skin'), T_('The skin defines how the backoffice appears to you.'), array( 'onchange' => 'admin_skin_changed()' ) );
 150  
 151    // fp> TODO: We gotta have something like $edited_User->UserSettings->get('legend');
 152      // Icon/text thresholds:
 153      $Form->text( 'edited_user_action_icon_threshold', $UserSettings->get( 'action_icon_threshold', $edited_User->ID), 1, T_('Action icon display'), T_('1:more icons ... 5:less icons') );
 154      $Form->text( 'edited_user_action_word_threshold', $UserSettings->get( 'action_word_threshold', $edited_User->ID), 1, T_('Action word display'), T_('1:more action words ... 5:less action words') );
 155  
 156      // To display or hide icon legend:
 157      $Form->checkbox( 'edited_user_legend', $UserSettings->get( 'display_icon_legend', $edited_User->ID ), T_('Display icon legend'), T_('Display a legend at the bottom of every page including all action icons used on that page.') );
 158  
 159      // To activate or deactivate bozo validator:
 160      $Form->checkbox( 'edited_user_bozo', $UserSettings->get( 'control_form_abortions', $edited_User->ID ), T_('Control form closing'), T_('This will alert you if you fill in data into a form and try to leave the form before submitting the data.') );
 161  
 162      // To activate focus on first form input text
 163      $Form->checkbox( 'edited_user_focusonfirst', $UserSettings->get( 'focus_on_first_input', $edited_User->ID ), T_('Focus on first field'), T_('The focus will automatically go to the first input text field.') );
 164  
 165      // Number of results per page
 166      $results_per_page_options = array(
 167              '10' => sprintf( T_('%s lines'), '10' ),
 168              '20' => sprintf( T_('%s lines'), '20' ),
 169              '30' => sprintf( T_('%s lines'), '30' ),
 170              '40' => sprintf( T_('%s lines'), '40' ),
 171              '50' => sprintf( T_('%s lines'), '50' ),
 172              '100' => sprintf( T_('%s lines'), '100' ),
 173              '200' => sprintf( T_('%s lines'), '200' ),
 174              '500' => sprintf( T_('%s lines'), '500' ),
 175          );
 176      $Form->select_input_array( 'edited_user_results_page_size', $UserSettings->get( 'results_per_page', $edited_User->ID ), $results_per_page_options, T_('Results per page'), T_('Number of rows displayed in results tables.'), array( 'force_keys_as_values' => true ) );
 177  }
 178  else
 179  { // display only
 180      $Form->info_field( T_('Admin skin'), $value_admin_skin, array( 'note' => T_('The skin defines how the backoffice appears to you.') ) );
 181  
 182      // fp> TODO: a lot of things will not be displayed in view only mode. Do we want that?
 183  
 184      $Form->info_field( T_('Results per page'), $UserSettings->get( 'results_per_page', $edited_User->ID ), array( 'note' => T_('Number of rows displayed in results tables.') ) );
 185  }
 186  
 187  $Form->end_fieldset();
 188  
 189      /***************  Admin skin settings  **************/
 190  // asimo> this div is needed to make sure the settings show/hide js part always work without reference to the AdminUI.
 191  echo '<div id="admin_skin_settings_div">';
 192      $AdminUI->display_skin_settings( $Form, $edited_User->ID );
 193  echo '</div>';
 194  
 195      /***************  Plugins  **************/
 196  
 197  if( $action != 'view' )
 198  { // We can edit the values:
 199      // PluginUserSettings
 200      load_funcs('plugins/_plugin.funcs.php');
 201  
 202      $Plugins->restart();
 203      while( $loop_Plugin = & $Plugins->get_next() )
 204      {
 205          if( ! $loop_Plugin->UserSettings /* NOTE: this triggers autoloading in PHP5, which is needed for the "hackish" isset($this->UserSettings)-method to see if the settings are queried for editing (required before 1.9) */
 206              && ! $Plugins->has_event($loop_Plugin->ID, 'PluginSettingsEditDisplayAfter') ) // What do we care about this event for?
 207          {
 208              continue;
 209          }
 210  
 211          // We use output buffers here to display the fieldset only, if there's content in there (either from PluginUserSettings or PluginSettingsEditDisplayAfter).
 212          ob_start();
 213          $Form->begin_fieldset( $loop_Plugin->name );
 214  
 215          ob_start();
 216          // UserSettings:
 217          $plugin_user_settings = $loop_Plugin->GetDefaultUserSettings( $tmp_params = array('for_editing'=>true, 'user_ID' => $edited_User->ID) );
 218          if( is_array($plugin_user_settings) )
 219          {
 220              foreach( $plugin_user_settings as $l_name => $l_meta )
 221              {
 222                  // Display form field for this setting:
 223                  autoform_display_field( $l_name, $l_meta, $Form, 'UserSettings', $loop_Plugin, $edited_User );
 224              }
 225          }
 226  
 227          // fp> what's a use case for this event? (I soooo want to nuke it...)
 228          $Plugins->call_method( $loop_Plugin->ID, 'PluginUserSettingsEditDisplayAfter',
 229              $tmp_params = array( 'Form' => & $Form, 'User' => $edited_User ) );
 230  
 231          $has_contents = strlen( ob_get_contents() );
 232          $Form->end_fieldset();
 233  
 234          if( $has_contents )
 235          {
 236              ob_end_flush();
 237              ob_end_flush();
 238          }
 239          else
 240          { // No content, discard output buffers:
 241              ob_end_clean();
 242              ob_end_clean();
 243          }
 244      }
 245  }
 246  
 247      /***************  Buttons  **************/
 248  
 249  if( $action != 'view' )
 250  { // Edit buttons
 251      $Form->buttons( array(
 252          array( '', 'actionArray[update]', T_('Save !'), 'SaveButton' ),
 253          array( 'reset', '', T_('Reset'), 'ResetButton' ),
 254          // dh> TODO: Non-Javascript-confirm before trashing all settings with a misplaced click.
 255          array( 'type' => 'submit', 'name' => 'actionArray[default_settings]', 'value' => T_('Restore defaults'), 'class' => 'ResetButton',
 256              'onclick' => "return confirm('".TS_('This will reset all your user settings.').'\n'.TS_('This cannot be undone.').'\n'.TS_('Are you sure?')."');" ),
 257      ) );
 258  }
 259  
 260  
 261  $Form->end_form();
 262  
 263  // End payload block:
 264  $this->disp_payload_end();
 265  
 266  ?>

title

Description

title

Description

title

Description

title

title

Body