b2evolution PHP Cross Reference Blogging Systems

Source: /inc/collections/views/_coll_user_perm.form.php - 301 lines - 13627 bytes - Text - Print

Description: This file implements the UI view (+more :/) for the blogs permission management. b2evolution - {@link http://b2evolution.net/} Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   1  <?php
   2  /**
   3   * This file implements the UI view (+more :/) for the blogs permission management.
   4   *
   5   * b2evolution - {@link http://b2evolution.net/}
   6   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
   7   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   8   *
   9   * @package admin
  10   *
  11   * @todo move user rights queries to object (fplanque)
  12   *
  13   * @version $Id: _coll_user_perm.form.php 6136 2014-03-08 07:59:48Z manuel $
  14   */
  15  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  16  
  17  /**
  18   * @var Blog
  19   */
  20  global $edited_Blog;
  21  /**
  22   * @var User
  23   */
  24  global $current_User;
  25  
  26  global $debug;
  27  global $UserSettings;
  28  global $rsc_url, $htsrv_url;
  29  
  30  global $Blog, $permission_to_change_admin;
  31  
  32  $permission_to_change_admin = $current_User->check_perm( 'blog_admin', 'edit', false, $Blog->ID );
  33  
  34  // Javascript:
  35  echo '
  36  <script type="text/javascript">var htsrv_url = "'.$htsrv_url.'";</script>
  37  <script type="text/javascript" src="'.$rsc_url.'js/collectionperms.js"></script>';
  38  
  39  $Form = new Form( NULL, 'blogperm_checkchanges', 'post', 'fieldset' );
  40  
  41  $Form->begin_form( 'fform' );
  42  
  43  $Form->add_crumb( 'collection' );
  44  $Form->hidden_ctrl();
  45  $Form->hidden( 'tab', 'perm' );
  46  $Form->hidden( 'blog', $edited_Blog->ID );
  47  
  48  $Form->begin_fieldset( T_('User permissions').get_manual_link('user_permissions') );
  49  
  50  
  51  /*
  52   * Query user list:
  53   */
  54  if( get_param('action') == 'filter2' )
  55  {
  56      $keywords = param( 'keywords2', 'string', '', true );
  57      set_param( 'keywords1', $keywords );
  58  }
  59  else
  60  {
  61      $keywords = param( 'keywords1', 'string', '', true );
  62      set_param( 'keywords2', $keywords );
  63  }
  64  
  65  $SQL = new SQL();
  66  $SQL->SELECT( 'user_ID, user_login, user_level, bloguser_perm_poststatuses + 0 as perm_poststatuses, bloguser_perm_edit, bloguser_ismember,'
  67      . 'bloguser_perm_delcmts, bloguser_perm_recycle_owncmts, bloguser_perm_vote_spam_cmts, bloguser_perm_cmtstatuses + 0 as perm_cmtstatuses, bloguser_perm_edit_cmt,'
  68      . 'bloguser_perm_delpost, bloguser_perm_edit_ts, bloguser_perm_cats,'
  69      . 'bloguser_perm_properties, bloguser_perm_admin, bloguser_perm_media_upload,'
  70      . 'bloguser_perm_media_browse, bloguser_perm_media_change, bloguser_perm_page,'
  71      . 'bloguser_perm_intro, bloguser_perm_podcast, bloguser_perm_sidebar' );
  72  $SQL->FROM( 'T_users LEFT JOIN T_coll_user_perms ON (
  73                                           user_ID = bloguser_user_ID
  74                                          AND bloguser_blog_ID = '.$edited_Blog->ID.' )' );
  75  $SQL->ORDER_BY( 'bloguser_ismember DESC, *, user_login, user_ID' );
  76  
  77  if( !empty( $keywords ) )
  78  {
  79      $SQL->add_search_field( 'user_login' );
  80      $SQL->add_search_field( 'user_firstname' );
  81      $SQL->add_search_field( 'user_lastname' );
  82      $SQL->add_search_field( 'user_nickname' );
  83      $SQL->add_search_field( 'user_email' );
  84      $SQL->WHERE_keywords( $keywords, 'AND' );
  85  }
  86  
  87  // Display wide layout:
  88  ?>
  89  
  90  <div id="userlist_wide" class="clear">
  91  
  92  <?php
  93  
  94  $Results = new Results( $SQL->get(), 'colluser_' );
  95  
  96  // Tell the Results class that we already have a form for this page:
  97  $Results->Form = & $Form;
  98  
  99  $Results->title = T_('User permissions');
 100  
 101  $Results->filter_area = array(
 102      'submit' => 'actionArray[filter1]',
 103      'callback' => 'filter_collobjectlist',
 104      'url_ignore' => 'results_colluser_page,keywords1,keywords2',
 105      'presets' => array(
 106          'all' => array( T_('All users'), regenerate_url( 'action,results_colluser_page,keywords1,keywords2', 'action=edit' ) ),
 107          )
 108      );
 109  
 110  /*
 111   * Grouping params:
 112   */
 113  $Results->group_by = 'bloguser_ismember';
 114  $Results->ID_col = 'user_ID';
 115  
 116  /*
 117   * Group columns:
 118   */
 119  $Results->grp_cols[] = array(
 120                          'td_colspan' => 0,  // nb_cols
 121                          'td' => '~conditional( #bloguser_ismember#, \''.format_to_output( TS_('Members'), 'htmlattr' ).'\', \''.format_to_output( TS_('Non members'), 'htmlattr' ).'\' )~',
 122                      );
 123  
 124  /*
 125   * Colmun definitions:
 126   */
 127  $Results->cols[] = array(
 128                          'th' => T_('Login'),
 129                          'order' => 'user_login',
 130                          'td' => '%get_user_identity_link( #user_login# )%',
 131                      );
 132  
 133  $Results->cols[] = array(
 134                          'th' => /* TRANS: User Level */ T_('L'),
 135                          'order' => 'user_level',
 136                          'td' => '$user_level$',
 137                          'td_class' => 'center',
 138                      );
 139  
 140  $Results->cols[] = array(
 141                          'th' => /* TRANS: SHORT table header on TWO lines */ T_('Is<br />member'),
 142                          'th_class' => 'checkright',
 143                          'td' => '%coll_perm_checkbox( {row}, \'bloguser_\', \'ismember\', \''.format_to_output( TS_('Permission to read members posts'), 'htmlattr' ).'\', \'checkallspan_state_$user_ID$\' )%',
 144                          'td_class' => 'center',
 145                      );
 146  
 147  $Results->cols[] = array(
 148                          'th' => T_('Post statuses'),
 149                          'th_class' => 'checkright',
 150                          'td' => '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'published\', \''.format_to_output( TS_('Permission to post into this blog with published status'), 'htmlattr' ).'\', \'post\' )%'.
 151                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'community\', \''.format_to_output( TS_('Permission to post into this blog with community status'), 'htmlattr' ).'\', \'post\' )%'.
 152                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'protected\', \''.format_to_output( TS_('Permission to post into this blog with members status'), 'htmlattr' ).'\', \'post\' )%'.
 153                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'private\', \''.format_to_output( TS_('Permission to post into this blog with private status'), 'htmlattr' ).'\', \'post\' )%'.
 154                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'review\', \''.format_to_output( TS_('Permission to post into this blog with review status'), 'htmlattr' ).'\', \'post\' )%'.
 155                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'draft\', \''.format_to_output( TS_('Permission to post into this blog with draft status'), 'htmlattr' ).'\', \'post\' )%'.
 156                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'deprecated\', \''.format_to_output( TS_('Permission to post into this blog with deprecated status'), 'htmlattr' ).'\', \'post\' )%'.
 157                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'redirected\', \''.format_to_output( TS_('Permission to post into this blog with redirected status'), 'htmlattr' ).'\', \'post\' )%',
 158                          'td_class' => 'center',
 159                      );
 160  
 161  $Results->cols[] = array(
 162                          'th' => T_('Post types'),
 163                          'th_class' => 'checkright',
 164                          'td' => '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_page\', \''.format_to_output( TS_('Permission to create pages'), 'htmlattr' ).'\' )%'.
 165                                  '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_intro\', \''.format_to_output( TS_('Permission to create intro posts (Intro-* post types)'), 'htmlattr' ).'\' )%'.
 166                                  '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_podcast\', \''.format_to_output( TS_('Permission to create podcast episodes'), 'htmlattr' ).'\' )%'.
 167                                  '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_sidebar\', \''.format_to_output( TS_('Permission to create sidebar links'), 'htmlattr' ).'\' )%',
 168                          'td_class' => 'center',
 169                      );
 170  
 171  $Results->cols[] = array(
 172                          'th' => /* TRANS: SHORT table header on TWO lines */ T_('Edit posts<br />/user level'),
 173                          'th_class' => 'checkright',
 174                          'default_dir' => 'D',
 175                          'td' => '%coll_perm_edit( {row}, \'bloguser_\' )%',
 176                          'td_class' => 'center',
 177                      );
 178  
 179  $Results->cols[] = array(
 180                          'th' => /* TRANS: SHORT table header on TWO lines */ T_('Delete<br />posts'),
 181                          'th_class' => 'checkright',
 182                          'order' => 'bloguser_perm_delpost',
 183                          'default_dir' => 'D',
 184                          'td' => '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_delpost\', \''.format_to_output( TS_('Permission to delete posts in this blog'), 'htmlattr' ).'\' )%',
 185                          'td_class' => 'center',
 186                      );
 187  
 188  $Results->cols[] = array(
 189                          'th' => /* TRANS: SHORT table header on TWO lines */ T_('Edit<br />TS'),
 190                          'th_class' => 'checkright',
 191                          'order' => 'bloguser_perm_edit_ts',
 192                          'default_dir' => 'D',
 193                          'td' => '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_edit_ts\', \''.format_to_output( TS_('Permission to edit timestamp on posts and comments in this blog'), 'htmlattr' ).'\' )%',
 194                          'td_class' => 'center',
 195                      );
 196  
 197  $Results->cols[] = array(
 198                          'th' => T_('Comment<br />statuses'),
 199                          'th_class' => 'checkright',
 200                          'td' => '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'published\', \''.format_to_output( TS_('Permission to comment into this blog with published status'), 'htmlattr' ).'\', \'comment\' )%'.
 201                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'community\', \''.format_to_output( TS_('Permission to comment into this blog with community status'), 'htmlattr' ).'\', \'comment\' )%'.
 202                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'protected\', \''.format_to_output( TS_('Permission to comment into this blog with members status'), 'htmlattr' ).'\', \'comment\' )%'.
 203                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'private\', \''.format_to_output( TS_('Permission to comment into this blog with private status'), 'htmlattr' ).'\', \'comment\' )%'.
 204                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'review\', \''.format_to_output( TS_('Permission to comment into this blog with review status'), 'htmlattr' ).'\', \'comment\' )%'.
 205                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'draft\', \''.format_to_output( TS_('Permission to comment into this blog with draft status'), 'htmlattr' ).'\', \'comment\' )%'.
 206                                  '%coll_perm_status_checkbox( {row}, \'bloguser_\', \'deprecated\', \''.format_to_output( TS_('Permission to comment into this blog with deprecated status'), 'htmlattr' ).'\', \'comment\' )%',
 207                          'td_class' => 'center',
 208                      );
 209  
 210  $Results->cols[] = array(
 211                          'th' => /* TRANS: SHORT table header on TWO lines */ T_('Edit cmts<br />/user level'),
 212                          'th_class' => 'checkright',
 213                          'default_dir' => 'D',
 214                          'td' => '%coll_perm_edit_cmt( {row}, \'bloguser_\' )%',
 215                          'td_class' => 'center',
 216                      );
 217  
 218  $Results->cols[] = array(
 219                          'th' => /* TRANS: SHORT table header on TWO lines */ T_('Delete<br />commts'),
 220                          'th_class' => 'checkright',
 221                          'order' => 'bloguser_perm_delcmts',
 222                          'default_dir' => 'D',
 223                          'td' => '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_delcmts\', \''.format_to_output( TS_('Permission to delete comments on this blog'), 'htmlattr' ).'\' )%&nbsp;'.
 224                                  '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_recycle_owncmts\', \''.format_to_output( TS_('Permission to recycle comments on their own posts'), 'htmlattr' ).'\' )%&nbsp;'.
 225                                  '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_vote_spam_cmts\', \''.format_to_output( TS_('Permission to give a spam vote on any comment'), 'htmlattr' ).'\' )%&nbsp;',
 226                          'td_class' => 'center',
 227                      );
 228  
 229  $Results->cols[] = array(
 230                          'th_group' => T_('Edit blog settings'),
 231                          'th' => T_('Cats'),
 232                          'th_title' => T_('Categories'),
 233                          'th_class' => 'checkright',
 234                          'order' => 'bloguser_perm_cats',
 235                          'default_dir' => 'D',
 236                          'td' => '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_cats\', \''.format_to_output( TS_('Permission to edit categories for this blog'), 'htmlattr' ).'\' )%',
 237                          'td_class' => 'center',
 238                      );
 239  
 240  $Results->cols[] = array(
 241                          'th_group' => T_('Edit blog settings'),
 242                          'th' => /* TRANS: Short for blog features */  T_('Feat.'),
 243                          'th_title' => T_('Features'),
 244                          'th_class' => 'checkright',
 245                          'order' => 'bloguser_perm_properties',
 246                          'default_dir' => 'D',
 247                          'td' => '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_properties\', \''.format_to_output( TS_('Permission to edit blog features'), 'htmlattr' ).'\' )%',
 248                          'td_class' => 'center',
 249                      );
 250  
 251  $Results->cols[] = array(
 252                          'th_group' => T_('Edit blog settings'),
 253                          'th' => /* TRANS: Short for advanced */  T_('Adv.'),
 254                          'th_title' => T_('Advanced/Administrative blog properties'),
 255                          'th_class' => 'checkright',
 256                          'order' => 'bloguser_perm_admin',
 257                          'default_dir' => 'D',
 258                          'td' => '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_admin\', \''.format_to_output( TS_('Permission to edit advanced/administrative blog properties'), 'htmlattr' ).'\' )%',
 259                          'td_class' => 'center',
 260                      );
 261  
 262  // Media Directory:
 263  $Results->cols[] = array(
 264                          'th' => /* TRANS: SHORT table header on TWO lines */ T_('Media<br />Dir'),
 265                          'th_class' => 'checkright',
 266                          'order' => 'bloguser_perm_media_upload',
 267                          'default_dir' => 'D',
 268                          'td' => '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_media_upload\', \''.format_to_output( TS_('Permission to upload into blog\'s media folder'), 'htmlattr' ).'\' )%'.
 269                                  '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_media_browse\', \''.format_to_output( TS_('Permission to browse blog\'s media folder'), 'htmlattr' ).'\' )%'.
 270                                  '%coll_perm_checkbox( {row}, \'bloguser_\', \'perm_media_change\', \''.format_to_output( TS_('Permission to change the blog\'s media folder content'), 'htmlattr' ).'\' )%',
 271                          'td_class' => 'center',
 272                      );
 273  
 274  $Results->cols[] = array(
 275                          'th' => '&nbsp;',
 276                          'td' => '%perm_check_all( {row}, \'bloguser_\' )%',
 277                          'td_class' => 'center',
 278                      );
 279  
 280  $Results->display();
 281  
 282  echo '</div>';
 283  
 284  // Permission note:
 285  // fp> TODO: link
 286  echo '<p class="note center">'.T_('Note: General group permissions may further restrict or extend any media folder permissions defined here.').'</p>';
 287  
 288  $Form->end_fieldset();
 289  
 290  // Make a hidden list of all displayed users:
 291  $user_IDs = array();
 292  foreach( $Results->rows as $row )
 293  {
 294      $user_IDs[] = $row->user_ID;
 295  }
 296  $Form->hidden( 'user_IDs', implode( ',', $user_IDs) );
 297  
 298  $Form->end_form( array( array( 'submit', 'actionArray[update]', T_('Update'), 'SaveButton' ),
 299                                                  array( 'reset', '', T_('Reset'), 'ResetButton' ) ) );
 300  
 301  ?>

title

Description

title

Description

title

Description

title

title

Body