public function users($username = NULL) { // Make sure the user can view this page if (!$this->check_permission('manage_users')) { return; } // No Username, Build the index page if ($username == NULL) { // Build our page title / desc, then load the view $data = array('page_title' => "Manage Users", 'page_desc' => "Here you can manage the account of all your users."); $this->load->view('users_index', $data); } else { // Get users information. We can use GET because the queries second param will be cleaned // by the PDO class when bound to the "?". $query = "SELECT * FROM `pcms_accounts` INNER JOIN `pcms_account_groups` ON\n pcms_accounts.group_id = pcms_account_groups.group_id WHERE `username` = ?"; $user = $this->DB->query($query, array($username))->fetchRow(); // If $user isnt an array, we failed to load the user if (!is_array($user)) { // Load the page, and we are done :) output_message('error', 'user_not_found_1'); // Build our page title / desc, then load the view $data = array('page_title' => "Loading", 'page_desc' => "Please wait while we redirect you..."); redirect('admin/users', 5); $this->load->view('redirect', $data); } else { // Use the realm database to grab user information first $Account = $this->realm->fetchAccount($user['username']); $data['expansion_data'] = array(); $level = $this->realm->expansionLevel(); // Add expansion data to the exp_data array for ($i = 0; $i <= $level; $i++) { $data['expansion_data'][$i] = expansionToText($i); } // Use the additional inforamation from the realm DB if (is_object($Account)) { // Determine out Account status if (!$this->realm->accountBanned($user['id'])) { // Set ban status to Ban $data['account_ban_button'] = "ban"; $data['account_ban_button_text'] = "Ban Account"; // Load lock status if (!$Account->isLocked()) { $user['status'] = 'Active'; $data['account_lock_button'] = "lock"; $data['account_lock_button_text'] = "Lock Account"; } else { $user['status'] = 'Locked'; $data['account_lock_button'] = "unlock"; $data['account_lock_button_text'] = "UnLock Account"; } } else { $user['status'] = 'Banned'; $data['account_ban_button'] = "unban"; $data['account_ban_button_text'] = "UnBan Account"; $data['account_lock_button'] = "lock"; $data['account_lock_button_text'] = "Lock Account"; } // Assign more user variables $user['expansion'] = $Account->getExpansion(); $user['joindate'] = $Account->joinDate(); $user['last_login'] = $Account->lastLogin(); // Set some JS vars $this->Template->setjs('userid', $user['id']); $this->Template->setjs('username', $user['username']); $this->Template->setjs('level', $this->user['group_id']); $this->Template->setjs('is_super', $this->user['is_super_admin']); // Finish Building our data array $data['page_title'] = ucfirst(strtolower($username)) . " (Account ID: " . $user['id'] . ")"; $data['page_desc'] = "Here you can manage the account of all your users."; $data['user'] = $user; $data['groups'] = $this->DB->query("SELECT * FROM `pcms_account_groups`")->fetchAll(); // Load the view $this->load->view('user_manage', $data); } else { // Load the page, and we are done :) output_message('error', 'user_not_found_2'); // Build our page title / desc, then load the view $data = array('page_title' => "", 'page_desc' => ""); // Load the error page, no redirect $this->load->view('redirect', $data); return; } } } }
public function getExpansion($asText = false) { // We need to convert the bit value to normal $exp = $this->data[$this->cols['expansion']]; $val = array_search($exp, $this->config['expansionToBit']); return $asText == true ? expansionToText($val) : (int) $val; }