Exemplo n.º 1
0
function delete_session_user_group()
{
    // get global user object
    global $user;
    // get url query
    $query = get_url_query();
    // protect from unauthorized access
    if (!isset($user) or ($user->getAdmin() != '1' or !isset($_SESSION['session_user'])) or !isset($query["page"]) and !isset($query["group_type"]) and !isset($query["group_id"])) {
        logout();
        die;
    }
    $session_user = new User();
    $session_user = unserialize($_SESSION['session_user']);
    $group_id = $query["group_id"];
    if ($query["group_type"] == "staff") {
        $user_staff_groups = array();
        if (is_array(unserialize($session_user->getStaffGroups()))) {
            $user_staff_groups = unserialize($session_user->getStaffGroups());
        }
        if (($key = array_search($group_id, $user_staff_groups)) !== false) {
            unset($user_staff_groups[$key]);
        }
        $session_user->setStaffGroups(serialize($user_staff_groups));
    } elseif ($query["group_type"] == "student") {
        $user_student_groups = array();
        if (is_array(unserialize($session_user->getStudentGroups()))) {
            $user_student_groups = unserialize($session_user->getStudentGroups());
        }
        if (($key = array_search($group_id, $user_student_groups)) !== false) {
            unset($user_student_groups[$key]);
        }
        $session_user->setStudentGroups(serialize($user_student_groups));
    } elseif ($query["group_type"] == "local") {
        $user_local_groups = array();
        if (is_array(unserialize($session_user->getLocalGroups()))) {
            $user_local_groups = unserialize($session_user->getLocalGroups());
        }
        if (($key = array_search($group_id, $user_local_groups)) !== false) {
            unset($user_local_groups[$key]);
        }
        $session_user->setLocalGroups(serialize($user_local_groups));
    }
    $_SESSION['session_user'] = serialize($session_user);
    $cookie_key = 'msg';
    $cookie_value = 'Вие успешно премахнахте група от този потребител!';
    setcookie($cookie_key, $cookie_value, time() + 1);
    header('location: ' . ROOT_DIR . '?page=survey_user');
    die;
}
Exemplo n.º 2
0
     foreach ($user_types as $user_type) {
         $run_result .= ' | ';
         if ($user_type == $current_type) {
             $run_result .= $user_type;
         } else {
             $run_result .= '<a href="' . get_url_query(1, 'admin::users', 'user_type=' . $user_type) . '">' . $user_type . '</a>';
         }
     }
 }
 $run_result .= "<form action=\"" . url . "_userdetails/\" method=\"get\">";
 $run_result .= templates_draw(array('context' => 'adminTable', 'name' => "<h4>" . __gettext("Enter username") . "</h4>", 'column1' => "<input type=\"text\" name=\"profile_name\" value=\"\" /><input type=\"hidden\" name=\"context\" value=\"admin\" />", 'column2' => "<input type=\"submit\" value=\"" . __gettext("Edit user") . "\" />"));
 $run_result .= "</form>";
 $maxusers = count_records('users', 'user_type', $current_type);
 if ($users = get_records('users', 'user_type', $current_type, 'name ASC', '*', $offset, 50)) {
     if ($maxusers > $offset + 50) {
         $next = "<a href=\"" . get_url_query(null, 'admin::users', "user_type={$current_type}&offset=" . ($offset + 50)) . "\">" . __gettext("Next") . "</a>";
     } else {
         $next = "";
     }
     $prevoffset = $offset - 50;
     if ($prevoffset < 0) {
         $prevoffset = 0;
     }
     if ($prevoffset != $offset) {
         $prev = "<a href=\"" . get_url(null, 'admin::users', "user_type={$current_type}&offset=" . $prevoffset) . "\">" . __gettext("Previous") . "</a>";
     } else {
         $prev = "";
     }
     $nav = templates_draw(array('context' => 'adminTable', 'name' => __gettext('Total users') . ":&nbsp;" . $maxusers, 'column1' => $prev . "&nbsp;" . $next, 'column2' => "&nbsp;"));
     $run_result .= $nav;
     $run_result .= templates_draw(array('context' => 'adminTable', 'name' => "<h3>" . __gettext("First Name") . "</h3>", 'column1' => "<h3>" . __gettext("Last Name") . "</h3>", 'column3' => "<h3>" . __gettext("Username") . "</h3>", 'column2' => "<h3>" . __gettext("Extra info") . "</h3>"));
function elggadmin_page_config()
{
    // restore!
    if (optional_param('action') == 'elggadmin:config:restore') {
        if (require_confirm(__gettext(__gettext('Are you sure to restore default configuration?')))) {
            if (elggadmin_config_restore()) {
                elgg_messages_add(__gettext('Your configuration has been restored to default values'));
            }
            header_redirect(get_url(null, 'elggadmin::config'));
        }
    }
    $show_all = optional_param('view');
    $_config = elggadmin_get_defconfig();
    $page = new StdClass();
    $page->title = __gettext('Configuration manager');
    $page->body = null;
    if (empty($show_all)) {
        $view_all = '&raquo; ' . pages_html_a(get_url_query(1, 'elggadmin::', 'view=all'), __gettext('View all options'));
        $page->body .= pages_html_wrap('div', pages_html_wrap('label', $view_all), array('class' => ''));
    } else {
        $restore = '&raquo; ' . pages_html_a(get_url_query(1, 'elggadmin::', 'action=elggadmin:config:restore'), __gettext('Restore default values'));
        $page->body .= pages_html_wrap('div', pages_html_wrap('label', $restore), array('class' => ''));
    }
    $note = __gettext('Note: some fields are disabled because the value is forced by your <code>config.php</code>.');
    $note .= __gettext('To change you must hand edit your <code>config.php</code>.');
    $page->body .= pages_html_wrap('p', $note);
    foreach ($_config as $c => $obj) {
        if ((isset($obj->noteditable) || isset($obj->hidden)) && !$show_all) {
            continue;
        }
        $name = htmlspecialchars($obj->name, ENT_COMPAT, 'utf-8');
        if (isset($obj->important)) {
            $name .= ': *';
        } else {
            $name .= ': &nbsp;';
        }
        $class = 'form-item ' . (isset($obj->important) ? ' important' : '');
        $desc = isset($obj->description) ? $obj->description : '&nbsp;';
        $input = pages_html_wrap('label', $name, array('class' => 'input-label'));
        $input .= elggadmin_config_input($c, $obj);
        $input .= pages_html_wrap('span', $desc);
        $page->body .= pages_html_wrap('div', $input, array('class' => $class));
    }
    $page->body .= pages_html_input('hidden', array('name' => 'action', 'value' => 'elggadmin:config'));
    $page->body = pages_html_form('elggconfig', $page->body);
    return $page;
}