b2evolution PHP Cross Reference Blogging Systems

Source: /inc/users/views/_group.view.php - 114 lines - 3757 bytes - Summary - Text - Print

Description: This file implements the UI view for Users > Groups

   1  <?php
   2  /**

   3   * This file implements the UI view for Users > Groups

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

  21   *

  22   * @package admin

  23   *

  24   * @version $Id: _group.view.php 349 2011-11-18 11:18:14Z yura $

  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  global $blog, $admin_url, $UserSettings;
  29  
  30  // query which groups have users (in order to prevent deletion of groups which have users)

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

  32  $usedgroups = $DB->get_col( 'SELECT grp_ID
  33      FROM T_groups INNER JOIN T_users ON user_grp_ID = grp_ID
  34      GROUP BY grp_ID');
  35  
  36  // Create result set:

  37  $SQL = new SQL();
  38  $SQL->SELECT( 'SQL_NO_CACHE grp_ID, grp_name' );
  39  $SQL->FROM( 'T_groups' );
  40  
  41  $CountSQL = new SQL();
  42  $CountSQL->SELECT( 'SQL_NO_CACHE COUNT(grp_ID)' );
  43  $CountSQL->FROM( 'T_groups' );
  44  
  45  $Results = new Results( $SQL->get(), 'grp_', 'A', $UserSettings->get( 'results_per_page' ), $CountSQL->get() );
  46  
  47  $Results->title = T_('User groups');
  48  
  49  /*

  50   * Table icons:

  51   */
  52  if( $current_User->check_perm( 'users', 'edit', false ) )
  53  {    // create new group link
  54      $Results->global_icon( T_('Create a new group...'), 'new', '?ctrl=groups&amp;action=new', T_('Add group').' &raquo;', 3, 4 );
  55  }
  56  
  57  $Results->cols[] = array(
  58          'th' => T_('ID'),
  59          'order' => 'grp_ID',
  60          'th_class' => 'shrinkwrap',
  61          'td_class' => 'right',
  62          'td' => '$grp_ID$',
  63      );
  64  
  65  if( $current_User->check_perm( 'users', 'edit', false ) )
  66  {    // User can edit this group
  67      $Results->cols[] = array(
  68              'th' => T_('Name'),
  69              'order' => 'grp_name',
  70              'td' => '<a href="'.$admin_url.'?ctrl=groups&amp;action=edit&amp;grp_ID=$grp_ID$"><b>$grp_name$</b></a>',
  71          );
  72  }
  73  else
  74  {    // No permission to edit group
  75      $Results->cols[] = array(
  76              'th' => T_('Name'),
  77              'order' => 'grp_name',
  78              'td' => '$grp_name$',
  79          );
  80  }
  81  
  82  function grp_actions( & $row )
  83  {
  84      global $usedgroups, $Settings, $current_User;
  85  
  86      $r = '';
  87      if( $current_User->check_perm( 'users', 'edit', false ) )
  88      {
  89          $r = action_icon( T_('Edit this group...'), 'edit', regenerate_url( 'ctrl,action', 'ctrl=groups&amp;action=edit&amp;grp_ID='.$row->grp_ID ) );
  90  
  91          $r .= action_icon( T_('Duplicate this group...'), 'copy', regenerate_url( 'ctrl,action', 'ctrl=groups&amp;action=new&amp;grp_ID='.$row->grp_ID ) );
  92  
  93          if( ($row->grp_ID != 1) && ($row->grp_ID != $Settings->get('newusers_grp_ID')) && !in_array( $row->grp_ID, $usedgroups ) )
  94          { // delete
  95              $r .= action_icon( T_('Delete this group!'), 'delete', regenerate_url( 'ctrl,action', 'ctrl=groups&amp;action=delete&amp;grp_ID='.$row->grp_ID.'&amp;'.url_crumb('group') ) );
  96          }
  97          else
  98          {
  99              $r .= get_icon( 'delete', 'noimg' );
 100          }
 101      }
 102      return $r;
 103  }
 104  $Results->cols[] = array(
 105          'th' => T_('Actions'),
 106          'th_class' => 'shrinkwrap small',
 107          'td_class' => 'shrinkwrap',
 108          'td' => '%grp_actions( {row} )%',
 109      );
 110  
 111  // Display results:

 112  $Results->display();
 113  
 114  ?>

title

Description

title

Description

title

Description

title

title

Body