Пример #1
0
function gs_group_members_groups_get($member_ids, $type, $subgroups = true)
{
    if (!$member_ids) {
        return array();
    }
    $db_slave = gs_db_slave_connect();
    if (!$db_slave) {
        return new GsError('Could not connect to database.');
    }
    $rs = $db_slave->execute('SELECT `id` FROM `groups` JOIN `group_members` ON `group_members`.`group` = `groups`.`id` WHERE `groups`.`type` = \'' . $db_slave->escape($type) . '\' AND `group_members`.`member` IN (' . implode(',', $member_ids) . ')');
    $groups = gs_group_members_groups_external_get($member_ids, $type);
    if ($rs) {
        while ($r = $rs->fetchRow()) {
            $groups[] = $r['id'];
        }
    }
    if ($groups && $subgroups) {
        $groups = gs_group_includes_get($groups, false);
    }
    return $groups;
}
<?php 
        foreach ($groups as $key => $group) {
            $sort_key[$key] = $group['name'];
        }
        array_multisort($sort_key, SORT_ASC, SORT_STRING, $groups);
        if (isGsError($groups)) {
            echo '<tr><td colspan="5">', $groups->getMsg(), '</td></tr>';
        } else {
            $i = 1;
            foreach ($groups as $group) {
                if ($i > $per_page * ($page + 1) || $i < $per_page * $page + 1) {
                    $i++;
                    continue;
                }
                $groups_same_type = gs_group_info_get(false, $group['type']);
                $group_includes_ids = gs_group_includes_get(array($group['id']), true, true);
                $group_includes = gs_group_info_get(array_diff($group_includes_ids, array($group['id'])));
                echo '<tr class="', $i % 2 === 0 ? 'odd' : 'even', '">', "\n";
                echo '<td class="l nobr">';
                echo $group['name'], '</td>', "\n";
                echo '<td>', $group['title'], '</td>', "\n";
                echo '<td class="r">', count(gs_group_members_get(array($group['id']))), ' / ', $num_sections + $num_modules, '</td>', "\n";
                echo '<td class="r">', "\n";
                echo '<a href="', gs_url($SECTION, $MODULE, null, 'action=edit&amp;id=' . $group['id'] . '&amp;page=' . $page), '"><img alt="', __('Bearbeiten'), '" title="', __('Bearbeiten'), '" src="', GS_URL_PATH, 'crystal-svg/16/act/edit.png" /></a>';
                echo '</td>', "\n";
                echo '</tr>', "\n";
                $i++;
            }
        }
        ?>
</tbody>