Esempio n. 1
0
/**
 * Put user group and relative access_level
 */
function sumo_put_user_grouplevel($id = FALSE)
{
    $user = sumo_get_user_info($id, 'id', FALSE);
    $group_level = $user['group_level'];
    if (!empty($group_level)) {
        global $SUMO, $language;
        $num_groups = count($group_level);
        $group = array_keys($group_level);
        $value = array_values($group_level);
        $list = '';
        for ($g = 0; $g < $num_groups; $g++) {
            if ($group[$g]) {
                $SUMO['user']['group_level'][$group[$g]] = !isset($SUMO['user']['group_level'][$group[$g]]) ? '' : $SUMO['user']['group_level'][$group[$g]];
                $style = sumo_alternate_str('tab-row-on', 'tab-row-off');
                $val = "<select name='group_level[{$g}]'>\n<option value='" . $value[$g] . "'>" . $value[$g] . "</option>\n";
                $last_value = !isset($SUMO['user']['group_level'][$group[$g]]) ? 7 : $SUMO['user']['group_level'][$group[$g]];
                $last_value = in_array('sumo', $SUMO['user']['group']) && $group[$g] != 'sumo' ? 7 : $last_value;
                $group_name[$g] = "<input type='hidden' name='group_name[{$g}]' value='" . $group[$g] . "'>" . $group[$g];
                // Create link to remove group
                if ($SUMO['user']['group_level'][$group[$g]] > $value[$g] || $SUMO['user']['group_level']['sumo'] >= 4) {
                    $delete = "<a href='javascript:sumo_ajax_get(\"" . $_SESSION['module'] . ".content\",\"?module=users&action=deletegroup&group=" . $group[$g] . ":" . $value[$g] . "&id=" . intval($id) . "&decoration=false&SecurityOptions_visibility=1\");'>" . $language['Remove'] . "</a>";
                } else {
                    $delete = '';
                }
                if ($SUMO['user']['group_level'][$group[$g]] > $value[$g] || in_array('sumo', $SUMO['user']['group'])) {
                    for ($l = 1; $l <= $last_value; $l++) {
                        if ($l != $value[$g]) {
                            $val .= "<option value='{$l}'>{$l}</option>\n";
                        }
                    }
                }
                $val .= "</select>";
                // Only for SUMO user (administrator)
                if ($user['user'] == 'sumo') {
                    $val = 7;
                    $delete = '';
                }
                $list .= "<tr>\n" . " <td class='" . $style . "'>" . $group_name[$g] . "</td>\n" . " <td class='" . $style . "'>" . sumo_get_group_description($group[$g]) . "</td>\n" . " <td class='" . $style . "'>" . $val . "</td>\n" . " <td class='" . $style . "'>" . $delete . "</td>\n" . "</tr>\n";
            }
        }
        return $list;
    } else {
        return FALSE;
    }
}
Esempio n. 2
0
/**
 * Get html list of group_level
 */
function sumo_get_user_grouplevel($group_level = FALSE)
{
    if ($group_level) {
        $num_groups = count($group_level);
        $group = array_keys($group_level);
        $value = array_values($group_level);
        $list = '';
        for ($g = 0; $g < $num_groups; $g++) {
            $style = sumo_alternate_str('tab-row-on', 'tab-row-off');
            if ($group[$g]) {
                $list .= "<tr>\n" . " <td class='{$style}'>" . $group[$g] . "</td>\n" . " <td class='{$style}'>" . sumo_get_group_description($group[$g]) . "</td>\n" . " <td class='{$style}'>" . intval($value[$g]) . "</td>\n" . "</tr>\n";
            }
        }
        return $list;
    } else {
        return FALSE;
    }
}
Esempio n. 3
0
/**
 * Put accesspoint group (in Html format)
 * 
 * @author Alberto Basso
 */
function sumo_put_accesspoint_group($id = FALSE)
{
    if ($id > 0) {
        $accesspoint = sumo_get_accesspoint_info($id, 'id', FALSE);
        if (!empty($accesspoint['usergroup'])) {
            global $SUMO, $language;
            $list = "<table cellspacing='0' class='tab'>\n" . " <tr>\n" . "  <td class='tab-title'>" . $language['Name'] . "</td>\n" . "  <td class='tab-title'>" . $language['Description'] . "</td>\n" . "  <td class='tab-title'>&nbsp;</td>\n" . " </tr>\n";
            for ($g = 0; $g < count($accesspoint['usergroup']); $g++) {
                if ($accesspoint['usergroup'][$g]) {
                    $style = sumo_alternate_str('tab-row-on', 'tab-row-off');
                    $ap_name = $accesspoint['usergroup'][$g] == 'sumo' ? "<font color='#BB0000'><b>sumo</b></font>" : $accesspoint['usergroup'][$g];
                    $group_name = "<input type='hidden' size='25' name='group[" . $g . "]' value='" . $accesspoint['usergroup'][$g] . "'>" . $ap_name;
                    // Create link to remove group
                    $delete = "<a href='javascript:sumo_ajax_get(\"" . $_SESSION['module'] . "\",\"" . "?module=accesspoints&action=deletegroup&group=" . $accesspoint['usergroup'][$g] . "&id=" . intval($id) . "&SecurityOptions_visibility=1\");'>" . $language['Remove'] . "</a>";
                    $list .= "<tr>\n" . " <td class='" . $style . "'>" . $group_name . "</td>\n" . " <td class='" . $style . "'>" . sumo_get_group_description($accesspoint['usergroup'][$g]) . "</td>\n" . " <td class='" . $style . "'>" . $delete . "</td>\n" . "</tr>\n";
                }
            }
            $list .= "</table>";
            return $list;
        }
    } else {
        return FALSE;
    }
}