public function recover()
 {
     $user_details = $this->resume_session();
     if (is_array($user_details)) {
         $this->logged_in = true;
         $Roles = new PerchUserRoles();
         $Role = $Roles->get_one_by('roleSlug', $user_details['role']);
         $details = array();
         $details['userID'] = $user_details['email'];
         $details['userEmail'] = $user_details['email'];
         $details['roleID'] = $Role->id();
         $details['userMasterAdmin'] = $Role->roleMasterAdmin();
         $details['roleMasterAdmin'] = $Role->roleMasterAdmin();
         $this->set_details($details);
         $AuthenticatedUser = new PerchAuthenticatedUser(array());
         $this->_load_privileges($Role);
         return true;
     }
     $this->logged_in = false;
     return false;
 }
示例#2
0
<?php

$Roles = new PerchUserRoles();
$roles = $Roles->all();
/* --------- New User Form ----------- */
$fCreateUser = new PerchForm('createuser', false);
$req = array();
$req['userUsername'] = "Required";
$req['userGivenName'] = "Required";
$req['userFamilyName'] = "Required";
$req['userEmail'] = "Required";
$req['userPassword'] = "Required";
$req['roleID'] = "Required";
$fCreateUser->set_required($req);
$validation = array();
$validation['userUsername'] = array("username", PerchLang::get("Username not available, try another."));
$validation['userEmail'] = array("email", PerchLang::get("Email incomplete or already in use."));
$fCreateUser->set_validation($validation);
if ($fCreateUser->posted() && $fCreateUser->validate()) {
    $data = array();
    $postvars = array('userUsername', 'userGivenName', 'userFamilyName', 'userEmail', 'userPassword', 'roleID');
    $data = $fCreateUser->receive($postvars);
    $sendEmail = false;
    if (isset($_POST['sendEmail']) && $_POST['sendEmail'] == '1') {
        $sendEmail = true;
    }
    $Users->create($data, $sendEmail);
    $Alert->set('success', PerchLang::get('User successfully created.'));
    $fCreateUser->clear();
}
示例#3
0
<?php

$Roles = new PerchUserRoles();
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = (int) $_GET['id'];
    $Role = $Roles->find($id);
} else {
    $id = false;
    $Role = false;
}
if (!$Role || !is_object($Role)) {
    PerchUtil::redirect(PERCH_LOGINPATH . '/users');
}
/* --------- Delete User Form ----------- */
$Form = new PerchForm('delete', false);
if ($Form->posted() && $Form->validate()) {
    $postvars = array('roleID');
    $data = $Form->receive($postvars);
    $Role->migrate_users($data['roleID']);
    $Role->delete();
    if ($Form->submitted_via_ajax) {
        echo PERCH_LOGINPATH . '/core/users/roles/';
        exit;
    } else {
        PerchUtil::redirect(PERCH_LOGINPATH . '/core/users/roles/');
    }
}
$details = $Role->to_array();
$all_roles = $Roles->all();
示例#4
0
<?php

$Roles = new PerchUserRoles();
$Privs = new PerchUserPrivileges();
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = (int) $_GET['id'];
    $Role = $Roles->find($id);
} else {
    $id = false;
    $Role = false;
}
$Form = new PerchForm('role', false);
$req = array();
$req['roleTitle'] = "Required";
$Form->set_required($req);
if ($Form->posted() && $Form->validate()) {
    PerchUtil::debug($_POST);
    $data = array();
    $postvars = array('roleTitle');
    $data = $Form->receive($postvars);
    $data['roleSlug'] = PerchUtil::urlify($data['roleTitle']);
    if (is_object($Role)) {
        $Role->update($data);
    } else {
        $Role = $Roles->create($data);
    }
    $privs = $Form->find_items('privs-');
    $new_privs = array();
    if (PerchUtil::count($privs)) {
        foreach ($privs as $category) {
            if (PerchUtil::count($category)) {
示例#5
0
<?php

include PERCH_PATH . '/core/apps/content/PerchContent_Regions.class.php';
include PERCH_PATH . '/core/apps/content/PerchContent_Region.class.php';
include PERCH_PATH . '/core/apps/content/PerchContent_Pages.class.php';
include PERCH_PATH . '/core/apps/content/PerchContent_Page.class.php';
$Roles = new PerchUserRoles();
$Regions = new PerchContent_Regions();
$Pages = new PerchContent_Pages();
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = (int) $_GET['id'];
    $Role = $Roles->find($id);
} else {
    $id = false;
    $Role = false;
}
if (!is_object($Role)) {
    PerchUtil::redirect(PERCH_LOGINPATH . '/core/users/roles/');
}
$Form = new PerchForm('action', false);
if ($Form->posted() && $Form->validate()) {
    PerchUtil::debug($_POST);
    $action = false;
    if (isset($_POST['regions']) && $_POST['regions'] != '' && $_POST['regions'] != 'noaction') {
        if ($_POST['regions'] == 'grant') {
            $Regions->modify_permissions('grant', $Role->id());
        }
        if ($_POST['regions'] == 'revoke') {
            $Regions->modify_permissions('revoke', $Role->id());
        }
        $action = true;