Skip to content

Commit

Permalink
Replace group name with full hierarchy group text - refs BT#9431
Browse files Browse the repository at this point in the history
  • Loading branch information
ilosada committed Mar 4, 2015
1 parent b2327d8 commit 52ca266
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion main/admin/group_list.php
Expand Up @@ -102,9 +102,33 @@ function get_group_data($from, $number_of_items, $column, $direction) {
$status[GROUP_PERMISSION_OPEN] = get_lang('Open');
$status[GROUP_PERMISSION_CLOSED] = get_lang('Closed');

$result = Database::select(
'tGroupRelGroup.group_id, tGroup.id, tGroup.name',
Database::get_main_table(TABLE_MAIN_GROUP_REL_GROUP).
" AS tGroupRelGroup RIGHT JOIN ".Database::get_main_table(TABLE_MAIN_GROUP).
" AS tGroup ON tGroupRelGroup.subgroup_id = tGroup.id"
);
$groupRelations = array();
foreach ($result as $row) {
$groupRelations[$row['id']] = $row;
}

while ($group = Database::fetch_row($res)) {
$name = null;
$id = $group[0];
// Loops while the current group is a subgroup
while (isset($groupRelations[$id]['group_id'])) {
$name = $name ?
$groupRelations[$id]['name'] . " > " . $name :
$groupRelations[$id]['name'];
$id = $groupRelations[$id]['group_id'];
}
// The base group
$name = $name ?
$groupRelations[$id]['name'] . " > " . $name :
$groupRelations[$id]['name'];
$group[3] = $status[$group[3]];
$group['1'] = '<a href="'.api_get_path(WEB_CODE_PATH).'social/groups.php?id='.$group['0'].'">'.$group['1'].'</a>';
$group['1'] = '<a href="'.api_get_path(WEB_CODE_PATH).'social/groups.php?id='.$group['0'].'">'.$name.'</a>';
$groups[] = $group;
}
return $groups;
Expand Down

0 comments on commit 52ca266

Please sign in to comment.