Changeset 27836


Ignore:
Timestamp:
Mar 18, 2014, 11:22:06 PM (7 years ago)
Author:
plg
Message:

bug 3053 fixed: columns "groups" and "privacy level" come back in Piwigo 2.6
user manager (which still needs improvement on filtering options...)

Location:
branches/2.6/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/admin/themes/default/template/user_list.tpl

    r27810 r27836  
    881881      <th>{'Status'|@translate}</th>
    882882      <th>{'Email address'|@translate}</th>
     883      <th>{'Groups'|@translate}</th>
     884      <th>{'Privacy level'|@translate}</th>
    883885      <th>{'registration date'|@translate}</th>
    884886    </tr>
  • branches/2.6/admin/user_list_backend.php

    r26618 r27836  
    3636 * you want to insert a non-database field (for example a counter or static image)
    3737 */
    38 $aColumns = array('id', 'username', 'status', 'mail_address', 'registration_date');
     38$aColumns = array('id', 'username', 'status', 'mail_address', 'recent_period', 'level', 'registration_date');
    3939$aColumns = trigger_change('user_list_columns', $aColumns);
    4040       
     
    158158  "aaData" => array()
    159159        );
    160        
     160
     161$user_ids = array();
     162
    161163while ( $aRow = pwg_db_fetch_array( $rResult ) )
    162164{
     165  $user_ids[] = $aRow['id'];
     166 
    163167  $row = array();
    164168  for ( $i=0 ; $i<count($aColumns) ; $i++ )
     
    168172      $row[] = l10n('user_status_'.$aRow[ $aColumns[$i] ]);
    169173    }
     174    else if ( $aColumns[$i] == "level" )
     175    {
     176      $row[] = $aRow[ $aColumns[$i] ] == 0 ? '' : l10n(sprintf('Level %d', $aRow[ $aColumns[$i] ]));
     177    }
    170178    else if ( $aColumns[$i] != ' ' )
    171179    {
     
    177185}
    178186
     187// replace "recent_period" by the list of groups
     188if (count($user_ids) > 0)
     189{
     190  $groups_of_user = array();
     191 
     192  $query = '
     193SELECT
     194    user_id,
     195    GROUP_CONCAT(name ORDER BY name SEPARATOR ", ") AS groups
     196  FROM '.USER_GROUP_TABLE.'
     197    JOIN '.GROUPS_TABLE.' ON id = group_id
     198  WHERE user_id IN ('.implode(',', $user_ids).')
     199  GROUP BY user_id
     200;';
     201  $result = pwg_query($query);
     202  while ($row = pwg_db_fetch_assoc($result))
     203  {
     204    $groups_of_user[ $row['user_id'] ] = $row['groups'];
     205  }
     206
     207  $key_replace = array_search('recent_period', $aColumns);
     208 
     209  // replacement
     210  foreach (array_keys($output['aaData']) as $idx)
     211  {
     212    $user_id = $output['aaData'][$idx][0];
     213    $output['aaData'][$idx][$key_replace] = isset($groups_of_user[$user_id]) ? $groups_of_user[$user_id] : '';
     214  }
     215}
     216
    179217$output = trigger_change('after_render_user_list', $output);
    180218       
Note: See TracChangeset for help on using the changeset viewer.