예제 #1
0
/**
 * Add group and "registration group" to accesspoint
 * 
 * @author Alberto Basso
 */
function sumo_add_accesspoint_group($groups_exist = array(), $name = '', $enabled = TRUE)
{
    global $SUMO;
    $group_exist = is_array($groups_exist) ? '' : $groups_exist;
    $groups_exist = !is_array($groups_exist) ? array($groups_exist) : $groups_exist;
    $group_name = sumo_get_grouplevel(sumo_get_user_available_group($SUMO['user']['user']), TRUE);
    $name = $name ? $name : 'newgroup';
    $disabled = $enabled ? '' : ' disabled';
    $available = FALSE;
    $list = "<select name='" . $name . "'" . $disabled . ">\n" . "<option value='" . $group_exist . "'>" . $group_exist . "</option>\n";
    for ($g = 0; $g < count($group_name); $g++) {
        if ($group_name[$g] == 'sumo') {
            $available_group = sumo_get_available_group();
            //$list = "<select name='".$name."'>\n<option></option>\n";
            //if(!in_array('sumo', $group_exist)) $list .= "<option value='sumo' style='color:#BB0000'>sumo</option>\n";
            for ($g = 0; $g < count($available_group); $g++) {
                //if(!in_array($available_group[$g], $group_exist) && $available_group[$g] != 'sumo')
                if (!in_array($available_group[$g], $groups_exist)) {
                    $style = $available_group[$g] == 'sumo' ? " style='color:#BB0000'" : "";
                    $list .= "<option value='" . $available_group[$g] . "'{$style}>" . $available_group[$g] . "</option>\n";
                }
            }
            $available = TRUE;
            break;
        } else {
            if (!in_array($group_name[$g], $group_exist)) {
                $list .= "<option value='" . $group_name[$g] . "'>" . $group_name[$g] . "</option>\n";
                $available = TRUE;
            }
        }
    }
    $list .= "</select>";
    if (!$available) {
        $list = '';
    }
    return $list;
}
예제 #2
0
/**
 * Add group and "registration group" to accesspoint
 * 
 * NOTE: this function is have tha same name 
 *       of a function into accesspoint module 
 * 
 * @author Alberto Basso
 */
function sumo_put_accesspoint_group($group_exist = '')
{
    $available_group = sumo_get_available_group();
    $list = "<select name='config[accesspoints][def_group]'>\n" . "<option value='" . $group_exist . "'>" . $group_exist . "</option>\n";
    for ($g = 0; $g < count($available_group); $g++) {
        if ($available_group[$g] != $group_exist) {
            $style = $available_group[$g] == 'sumo' ? " style='color:#BB0000'" : "";
            $list .= "<option value='" . $available_group[$g] . "'{$style}>" . $available_group[$g] . "</option>\n";
        }
    }
    $list .= "</select>";
    return $list;
}
예제 #3
0
}
$_POST['path'] = sumo_get_normalized_accesspoint($_POST['path']);
// If new group exist add it
if ($_POST['newgroup']) {
    $_POST['group'] = sumo_get_normalized_group($_POST['newgroup'] . ";" . $_POST['group'], TRUE);
}
// If registration enabled require reg_group
$reg_group = $_POST['registration'] ? 1 : 0;
$data = array(array('id', $_GET['id'], 1), array('node', $_POST['node'], 1), array('name', $_POST['name'], 1), array('path', $_POST['path'], 1), array('usergroup', $_POST['group'], 1), array('reg_group', $_POST['reg_group'], $reg_group), array('boolean', $_POST['http_auth'], 1), array('boolean', $_POST['filtering'], 1), array('boolean', $_POST['pwd_encrypt'], 1), array('boolean', $_POST['change_pwd'], 1), array('boolean', $_POST['registration'], 1), array('theme', $_POST['theme']));
$validate = sumo_validate_accesspoint_data($data, TRUE);
// verify if accesspoint already exist
//if(sumo_verify_accesspoint_exist($_POST['node'], $_POST['path'])) $validate = array(FALSE, sumo_get_message('I07002C', $_POST['path']));
// Verify submittedd groups with current user group
if ($validate[0]) {
    $submitted_group = sumo_get_grouplevel($_POST['group'], TRUE);
    $available_group = sumo_get_available_group();
    for ($g = 0; $g < count($submitted_group); $g++) {
        if (!in_array($submitted_group[$g], $available_group) && $submitted_group[$g]) {
            //$validate = array(false, sumo_get_message('GroupNotAvailable', $submitted_group[$g]));
            $validate[0] = true;
            $warning = sumo_get_message('GroupNotAvailable', $submitted_group[$g]);
            break;
        }
    }
}
if (!$validate[0]) {
    $tpl['MESSAGE:H'] = $language['AccessPointNotUpdated'] . ": " . $validate[1];
} else {
    $update = sumo_update_accesspoint_data(array('id' => $_GET['id'], 'node' => $_POST['node'], 'path' => $_POST['path'], 'name' => $_POST['name'], 'group' => $_POST['group'], 'reg_group' => $_POST['reg_group'], 'http_auth' => $_POST['http_auth'], 'filtering' => $_POST['filtering'], 'pwd_encrypt' => $_POST['pwd_encrypt'], 'change_pwd' => $_POST['change_pwd'], 'registration' => $_POST['registration'], 'theme' => $_POST['theme']));
    if ($update && !$warning) {
        $tpl['MESSAGE:L'] = $language['AccessPointUpdated'];
예제 #4
0
/**
 * Combo box to add group and relative level to user
 */
function sumo_add_user_grouplevel($form_name = '', $group_exist = array())
{
    global $SUMO;
    $groups_array = sumo_get_grouplevel(sumo_get_user_available_group($SUMO['user']['user']));
    $groups_name = array_keys($groups_array);
    $form_name = $form_name ? $form_name : ucfirst($_SESSION['action']) . ucfirst($_SESSION['module']);
    $available = FALSE;
    $script = "";
    $change = "n=document.forms['{$form_name}'].group;\n" . "l=document.forms['{$form_name}'].newgroup;\n" . "gr=n.options[n.selectedIndex].value;\n" . "ls=g[gr];l.options.length=0;if(!gr)return;\n" . "for(i=0;i<ls.length;i+=2){l.options[i/2]=new Option(ls[i],ls[i+1]);}\n";
    $list = "<select name='group' onchange=\"" . $change . "\">\n<option></option>\n";
    for ($g = 0; $g < count($groups_name); $g++) {
        // ...administrator can add all groups
        if ($groups_name[$g] == 'sumo') {
            $available_group = sumo_get_available_group();
            // ...to display 'sumo' group on top
            //if(!in_array('sumo', $group_exist))
            //	$list .= " <option value='sumo' style='color:#BB0000'>sumo</option>\n";
            for ($g = 0; $g < count($available_group); $g++) {
                // create levels
                for ($l = 1; $l <= 7; $l++) {
                    $value[$l] = $l . ",'" . $available_group[$g] . ":" . $l . "'";
                    if ($available_group[$g] == 'sumo' && $SUMO['user']['group_level']['sumo'] <= $l) {
                        break;
                    }
                }
                $script .= "g['" . $available_group[$g] . "']=new Array(" . implode(',', $value) . ");\n";
                //
                if (!in_array($available_group[$g], $group_exist)) {
                    $list .= " <option value='" . $available_group[$g] . "'>" . $available_group[$g] . "</option>\n";
                }
            }
            $available = TRUE;
            break;
        } else {
            // create levels
            for ($l = 1; $l <= $groups_array[$groups_name[$g]]; $l++) {
                $value[$l] = $l . ",'" . $groups_name[$g] . ":" . $l . "'";
            }
            $script .= "g['" . $groups_name[$g] . "']=new Array(" . implode(',', $value) . ");";
            //
            if (!in_array($groups_name[$g], $group_exist)) {
                $list .= " <option value='" . $groups_name[$g] . "'>" . $groups_name[$g] . "</option>\n";
                $available = TRUE;
            }
        }
    }
    $list .= "</select>&nbsp;:&nbsp;<select name='newgroup'></select>";
    $list = str_replace("onchange=\"", "onchange=\"g=new Array();" . $script, $list);
    return $available ? $list : '';
}