diff options
author | plegall <plg@piwigo.org> | 2014-03-18 22:23:38 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2014-03-18 22:23:38 +0000 |
commit | 6aa62e86134211462f74d7f3c13a851e519c9307 (patch) | |
tree | 834bc7d2d4a4291d8642f37cf5848228b27775cc /admin | |
parent | 7defc05b9d06d66d65ba13d699a60079e18e4cf1 (diff) |
merge r27836 from branch 2.6 to trunk
bug 3053 fixed: columns "groups" and "privacy level" come back in Piwigo 2.6
user manager (which still needs improvement on filtering options...)
git-svn-id: http://piwigo.org/svn/trunk@27837 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r-- | admin/themes/default/template/user_list.tpl | 2 | ||||
-rw-r--r-- | admin/user_list_backend.php | 42 |
2 files changed, 42 insertions, 2 deletions
diff --git a/admin/themes/default/template/user_list.tpl b/admin/themes/default/template/user_list.tpl index 79a2e4dd5..0fb47a0fc 100644 --- a/admin/themes/default/template/user_list.tpl +++ b/admin/themes/default/template/user_list.tpl @@ -880,6 +880,8 @@ span.infos, span.errors {background-image:none; padding:2px 5px; margin:0;border <th>{'Username'|@translate}</th> <th>{'Status'|@translate}</th> <th>{'Email address'|@translate}</th> + <th>{'Groups'|@translate}</th> + <th>{'Privacy level'|@translate}</th> <th>{'registration date'|@translate}</th> </tr> </thead> diff --git a/admin/user_list_backend.php b/admin/user_list_backend.php index 9d18f270b..b390ed1ec 100644 --- a/admin/user_list_backend.php +++ b/admin/user_list_backend.php @@ -35,7 +35,7 @@ check_status(ACCESS_ADMINISTRATOR); /* Array of database columns which should be read and sent back to DataTables. Use a space where * you want to insert a non-database field (for example a counter or static image) */ -$aColumns = array('id', 'username', 'status', 'mail_address', 'registration_date'); +$aColumns = array('id', 'username', 'status', 'mail_address', 'recent_period', 'level', 'registration_date'); $aColumns = trigger_change('user_list_columns', $aColumns); /* Indexed column (used for fast and accurate table cardinality) */ @@ -157,9 +157,13 @@ $output = array( "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array() ); - + +$user_ids = array(); + while ( $aRow = pwg_db_fetch_array( $rResult ) ) { + $user_ids[] = $aRow['id']; + $row = array(); for ( $i=0 ; $i<count($aColumns) ; $i++ ) { @@ -167,6 +171,10 @@ while ( $aRow = pwg_db_fetch_array( $rResult ) ) { $row[] = l10n('user_status_'.$aRow[ $aColumns[$i] ]); } + else if ( $aColumns[$i] == "level" ) + { + $row[] = $aRow[ $aColumns[$i] ] == 0 ? '' : l10n(sprintf('Level %d', $aRow[ $aColumns[$i] ])); + } else if ( $aColumns[$i] != ' ' ) { /* General output */ @@ -176,6 +184,36 @@ while ( $aRow = pwg_db_fetch_array( $rResult ) ) $output['aaData'][] = $row; } +// replace "recent_period" by the list of groups +if (count($user_ids) > 0) +{ + $groups_of_user = array(); + + $query = ' +SELECT + user_id, + GROUP_CONCAT(name ORDER BY name SEPARATOR ", ") AS groups + FROM '.USER_GROUP_TABLE.' + JOIN '.GROUPS_TABLE.' ON id = group_id + WHERE user_id IN ('.implode(',', $user_ids).') + GROUP BY user_id +;'; + $result = pwg_query($query); + while ($row = pwg_db_fetch_assoc($result)) + { + $groups_of_user[ $row['user_id'] ] = $row['groups']; + } + + $key_replace = array_search('recent_period', $aColumns); + + // replacement + foreach (array_keys($output['aaData']) as $idx) + { + $user_id = $output['aaData'][$idx][0]; + $output['aaData'][$idx][$key_replace] = isset($groups_of_user[$user_id]) ? $groups_of_user[$user_id] : ''; + } +} + $output = trigger_change('after_render_user_list', $output); echo json_encode( $output ); |