[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/users/views/ -> _user_list.view.php (source)

   1  <?php
   2  /**

   3   * This file implements the UI view for the user/group list for user/group editing.

   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-2007 by Francois PLANQUE - {@link http://fplanque.net/}

   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   * }}

  21   *

  22   * @package admin

  23   *

  24   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  25   * @author fplanque: Francois PLANQUE

  26   *

  27   * @version $Id: _user_list.view.php,v 1.4 2007/09/22 22:11:40 fplanque Exp $

  28   */
  29  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  30  
  31  
  32  /**

  33   * @var User

  34   */
  35  global $current_User;
  36  /**

  37   * @var GeneralSettings

  38   */
  39  global $Settings;
  40  /**

  41   * @var DB

  42   */
  43  global $DB;
  44  
  45  
  46  // query which groups have users (in order to prevent deletion of groups which have users)

  47  global $usedgroups;    // We need this in a callback below

  48  $usedgroups = $DB->get_col( 'SELECT grp_ID
  49                                                               FROM T_groups INNER JOIN T_users ON user_grp_ID = grp_ID
  50                                                              GROUP BY grp_ID');
  51  
  52  /*

  53   * Query user list:

  54   */
  55  $keywords = param( 'keywords', 'string', '', true );
  56  
  57  $where_clause = '';
  58  
  59  if( !empty( $keywords ) )
  60  {
  61      $kw_array = split( ' ', $keywords );
  62      foreach( $kw_array as $kw )
  63      {
  64          $where_clause .= 'CONCAT( user_login, \' \', user_firstname, \' \', user_lastname, \' \', user_nickname, \' \', user_email) LIKE "%'.$DB->escape($kw).'%" AND ';
  65      }
  66  }
  67  
  68  $sql = "SELECT T_users.*, grp_ID, grp_name, COUNT(blog_ID) AS nb_blogs
  69                      FROM T_users RIGHT JOIN T_groups ON user_grp_ID = grp_ID
  70                                  LEFT JOIN T_blogs on user_ID = blog_owner_user_ID
  71                   WHERE $where_clause 1
  72                   GROUP BY user_ID
  73                   ORDER BY grp_name, *";
  74  
  75  $count_sql = 'SELECT COUNT(*)
  76                                   FROM T_users
  77                               WHERE '.$where_clause.' 1';
  78  
  79  
  80  $Results = & new Results( $sql, 'user_', '-A', NULL, $count_sql );
  81  
  82  $Results->title = T_('Groups & Users');
  83  
  84  /*

  85   * Table icons:

  86   */
  87  if( $current_User->check_perm( 'users', 'edit', false ) )
  88  { // create new user link
  89      $Results->global_icon( T_('Create a new user...'), 'new', '?ctrl=users&amp;action=new_user', T_('Add user').' &raquo;', 3, 4  );
  90      $Results->global_icon( T_('Create a new group...'), 'new', '?ctrl=users&amp;action=new_group', T_('Add group').' &raquo;', 3, 4  );
  91  }
  92  
  93  
  94  /**

  95   * Callback to add filters on top of the result set

  96   *

  97   * @param Form

  98   */
  99  function filter_userlist( & $Form )
 100  {
 101      $Form->text( 'keywords', get_param('keywords'), 20, T_('Keywords'), T_('Separate with space'), 50 );
 102  }
 103  $Results->filter_area = array(
 104      'callback' => 'filter_userlist',
 105      'url_ignore' => 'results_user_page,keywords',
 106      'presets' => array(
 107          'all' => array( T_('All users'), '?ctrl=users' ),
 108          )
 109      );
 110  
 111  
 112  /*

 113   * Grouping params:

 114   */
 115  $Results->group_by = 'grp_ID';
 116  $Results->ID_col = 'user_ID';
 117  
 118  
 119  /*

 120   * Group columns:

 121   */
 122  $Results->grp_cols[] = array(
 123                          'td_class' => 'firstcol'.($current_User->check_perm( 'users', 'edit', false ) ? '' : ' lastcol' ),
 124                          'td_colspan' => -1,  // nb_colds - 1
 125                          'td' => '<a href="?ctrl=users&amp;grp_ID=$grp_ID$">$grp_name$</a>'
 126                                          .'¤conditional( (#grp_ID# == '.$Settings->get('newusers_grp_ID').'), \' <span class="notes">('.T_('default group for new users').')</span>\' )¤',
 127                      );
 128  
 129  function grp_actions( & $row )
 130  {
 131      global $usedgroups, $Settings;
 132  
 133      $r = action_icon( T_('Edit this group...'), 'edit', regenerate_url( 'action', 'grp_ID='.$row->grp_ID ) );
 134  
 135      $r .= action_icon( T_('Duplicate this group...'), 'copy', regenerate_url( 'action', 'action=new_group&amp;grp_ID='.$row->grp_ID ) );
 136  
 137      if( ($row->grp_ID != 1) && ($row->grp_ID != $Settings->get('newusers_grp_ID')) && !in_array( $row->grp_ID, $usedgroups ) )
 138      { // delete
 139          $r .= action_icon( T_('Delete this group!'), 'delete', regenerate_url( 'action', 'action=delete_group&amp;grp_ID='.$row->grp_ID ) );
 140      }
 141      else
 142      {
 143          $r .= get_icon( 'delete', 'noimg' );
 144      }
 145      return $r;
 146  }
 147  $Results->grp_cols[] = array(
 148                          'td_class' => 'shrinkwrap',
 149                          'td' => '%grp_actions( {row} )%',
 150                      );
 151  
 152  /*

 153   * Data columns:

 154   */
 155  $Results->cols[] = array(
 156                          'th' => T_('ID'),
 157                          'th_class' => 'shrinkwrap',
 158                          'td_class' => 'shrinkwrap',
 159                          'order' => 'user_ID',
 160                          'td' => '$user_ID$',
 161                      );
 162  
 163  $Results->cols[] = array(
 164                          'th' => T_('Login'),
 165                          'th_class' => 'shrinkwrap',
 166                          'order' => 'user_login',
 167                          'td' => '<a href="?ctrl=users&amp;user_ID=$user_ID$"><strong>$user_login$</strong></a>',
 168                      );
 169  
 170  $Results->cols[] = array(
 171                          'th' => T_('Nickname'),
 172                          'th_class' => 'shrinkwrap',
 173                          'order' => 'user_nickname',
 174                          'td' => '$user_nickname$',
 175                      );
 176  
 177  $Results->cols[] = array(
 178                          'th' => T_('Name'),
 179                          'order' => 'user_lastname, user_firstname',
 180                          'td' => '$user_firstname$ $user_lastname$',
 181                      );
 182  
 183  function user_mailto( $email )
 184  {
 185      if( empty( $email ) )
 186      {
 187          return '&nbsp;';
 188      }
 189      return action_icon( T_('Email').': '.$email, 'email', 'mailto:'.$email, T_('Email') );
 190  }
 191  $Results->cols[] = array(
 192                          'th' => T_('Email'),
 193                          'td_class' => 'shrinkwrap',
 194                          'td' => '%user_mailto( #user_email# )%',
 195                      );
 196  
 197  $Results->cols[] = array(
 198                          'th' => T_('URL'),
 199                          'td_class' => 'shrinkwrap',
 200                          'td' => '¤conditional( (#user_url# != \'http://\') && (#user_url# != \'\'), \'<a href="$user_url$" title="Website: $user_url$">'
 201                                  .get_icon( 'www', 'imgtag', array( 'class' => 'middle', 'title' => 'Website: $user_url$' ) ).'</a>\', \'&nbsp;\' )¤',
 202                      );
 203  
 204  $Results->cols[] = array(
 205                          'th' => T_('Blogs'),
 206                          'order' => 'nb_blogs',
 207                          'th_class' => 'shrinkwrap',
 208                          'td_class' => 'center',
 209                          'td' => '¤conditional( (#nb_blogs# > 0), #nb_blogs#, \'&nbsp;\' )¤',
 210                      );
 211  
 212  if( ! $current_User->check_perm( 'users', 'edit', false ) )
 213  {
 214      $Results->cols[] = array(
 215                          'th' => T_('Level'),
 216                          'th_class' => 'shrinkwrap',
 217                          'td_class' => 'right',
 218                          'order' => 'user_level',
 219                          'default_dir' => 'D',
 220                          'td' => '$user_level$',
 221                      );
 222  }
 223  else
 224  {
 225  	function display_level( $user_level, $user_ID )
 226      {
 227          $r = '';
 228          if( $user_level > 0)
 229          {
 230              $r .= action_icon( TS_('Decrease user level'), 'decrease',
 231                              regenerate_url( 'action', 'action=promote&amp;prom=down&amp;user_ID='.$user_ID ) );
 232          }
 233          else
 234          {
 235              $r .= get_icon( 'decrease', 'noimg' );
 236          }
 237          $r .= sprintf( '<code>% 2d </code>', $user_level );
 238          if( $user_level < 10 )
 239          {
 240              $r.= action_icon( TS_('Increase user level'), 'increase',
 241                              regenerate_url( 'action', 'action=promote&amp;prom=up&amp;user_ID='.$user_ID ) );
 242          }
 243          else
 244          {
 245            $r .= get_icon( 'increase', 'noimg' );
 246          }
 247          return $r;
 248      }
 249      $Results->cols[] = array(
 250                          'th' => T_('Level'),
 251                          'th_class' => 'shrinkwrap',
 252                          'td_class' => 'shrinkwrap',
 253                          'order' => 'user_level',
 254                          'default_dir' => 'D',
 255                          'td' => '%display_level( #user_level#, #user_ID# )%',
 256                      );
 257  
 258      $Results->cols[] = array(
 259                          'th' => T_('Actions'),
 260                          'td_class' => 'shrinkwrap',
 261                          'td' => action_icon( T_('Edit this user...'), 'edit', '%regenerate_url( \'action\', \'user_ID=$user_ID$\' )%' )
 262                                          .action_icon( T_('Duplicate this user...'), 'copy', '%regenerate_url( \'action\', \'action=new_user&amp;user_ID=$user_ID$\' )%' )
 263                                          .'¤conditional( (#user_ID# != 1) && (#nb_blogs# < 1) && (#user_ID# != '.$current_User->ID.'), \''
 264                                              .action_icon( T_('Delete this user!'), 'delete',
 265                                                  '%regenerate_url( \'action\', \'action=delete_user&amp;user_ID=$user_ID$\' )%' ).'\', \''
 266                          .get_icon( 'delete', 'noimg' ).'\' )¤'
 267                      );
 268  }
 269  
 270  
 271  // Display result :

 272  $Results->display();
 273  
 274  
 275  /*

 276   * $Log: _user_list.view.php,v $

 277   * Revision 1.4  2007/09/22 22:11:40  fplanque

 278   * fixed user list navigation

 279   *

 280   * Revision 1.3  2007/09/08 20:23:04  fplanque

 281   * action icons / wording

 282   *

 283   * Revision 1.2  2007/09/04 14:57:07  fplanque

 284   * interface cleanup

 285   *

 286   * Revision 1.1  2007/06/25 11:01:52  fplanque

 287   * MODULES (refactored MVC)

 288   *

 289   * Revision 1.15  2007/04/26 00:11:13  fplanque

 290   * (c) 2007

 291   *

 292   * Revision 1.14  2007/01/23 22:09:03  fplanque

 293   * visual alignment

 294   *

 295   * Revision 1.13  2006/11/24 18:27:26  blueyed

 296   * Fixed link to b2evo CVS browsing interface in file docblocks

 297   */
 298  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics