function getRoleCounts() { $oUser = new APP_Model_User(); $aRoles = $oUser->select()->columns('role_id, count(id) as total')->from($oUser->getTableName())->group('role_id')->getList(); $aRetRoles = array(); foreach ($aRoles as $aRole) { $aRetRoles[$aRole['role_id']] = $aRole['total']; } return $aRetRoles; }
function getAddEditFormStructure($p_sMode = 'create', array $p_aOptions = array()) { $structure = array('fields' => array('title' => array('type' => 'text', 'label' => 'Title', 'size' => 60), 'category_id' => array('type' => 'dropdown', 'label' => 'Category', 'options' => array()), 'ticket_type' => array('type' => 'dropdown', 'label' => 'Type', 'options' => array()), 'severity' => array('type' => 'dropdown', 'label' => 'Severity', 'options' => array()), 'status' => array('type' => 'dropdown', 'label' => 'Status', 'options' => array()), 'version' => array('type' => 'dropdown', 'label' => 'Version', 'options' => array()), 'assigned_user_id' => array('type' => 'dropdown', 'label' => 'Assign', 'options' => array()), 'content' => array('type' => 'textarea', 'label' => 'Description', 'rows' => 10, 'cols' => 40), 'submit' => array('type' => 'submit', 'label' => '', 'value' => 'Create Ticket')), 'rules' => array('title' => array('type' => 'required', 'message' => 'Title cannot be blank'), 'content' => array('type' => 'required', 'message' => 'You must enter a description'))); if (isset($p_aOptions['isAdmin']) && $p_aOptions['isAdmin'] === false) { unset($structure['fields']['assigned_user_id']); unset($structure['fields']['severity']); unset($structure['fields']['status']); unset($structure['fields']['version']); } else { $structure['fields']['severity']['options'] = array('minor' => 'minor', 'major' => 'major', 'critical' => 'critical'); $structure['fields']['status']['options'] = array('open' => 'open', 'assigned' => 'assigned', 'closed' => 'closed'); $oUser = new APP_Model_User(); $oTicket = new APP_Model_Ticket(); $structure['fields']['version']['options'] = $this->convertGetListToDropdown($oTicket->getVersionsForFormStructure(), 'version'); $structure['fields']['assigned_user_id']['options'] = $this->convertGetListToDropdown($oUser->getList(), array('first_name', ' ', 'last_name')); } $oTicketCat = new APP_Model_Ticket_Category(); $structure['fields']['ticket_type']['options'] = array('feature_request' => 'Feature request', 'bug' => 'Bug', 'enhancement' => 'Enhancement'); $structure['fields']['category_id']['options'] = $this->convertGetListToDropdown($oTicketCat->getList(), 'title'); return $structure; }
/** * AdminController::userDelete() * Delete a user * @return void */ protected function userDelete() { if (($iUserID = $this->oInput->get('delete', 0)) < 1) { throw new PPI_Exception('Invalid User ID: ' . $iUserID); } if ($this->getAuthData(false)->id == $iUserID) { $this->setFlashMessage('Unable to delete yourself', false); $this->redirect('admin/user'); } $oUser = new APP_Model_User(); $oUser->delete($iUserID); $this->setFlashMessage('User successfully deleted.'); $this->redirect('admin/user'); }
/** * AdminController::userDelete() * Delete a user * @return void */ private function userDelete() { if (($iUserID = $this->oInput->get('delete', 0)) < 1) { throw new PPI_Exception('Invalid User ID: ' . $iUserID); } if (($iSchoolID = $this->oInput->get('schoolid', 0)) < 1) { throw new PPI_Exception('Invalid School ID: ' . $iSchoolID); } $oUser = new APP_Model_User(); $oUser->delete($iUserID); $oDept = new APP_Model_School_Department(); $oDept->delRecord('user_id', $iUserID); $this->setFlashMessage('User successfully deleted.'); $this->redirect('admin/user/list/schoolid/' . $iSchoolID); }
/** * Send the password recovery email to the user. * @param string $p_sEmail The Email Address * @param string $p_sSubject The Subject * @param string $p_sMessage The Message * @return boolean */ function sendRecoverEmail($p_aUser, $p_sSubject = '', $p_sMessage = '') { $oConfig = $this->getConfig(); if ($p_sSubject === '') { $p_sSubject = 'Password recovery'; } $sRecoveryCode = base64_encode(time()); if ($p_sMessage === '') { $p_sMessage = "Hi, {$p_aUser['first_name']}\n\nYou have requested a password recovery and your password has now been reset.\nPlease click the following verification link to reset your password.\n"; $p_sMessage .= $oConfig->system->base_url . 'user/recover/' . urlencode($sRecoveryCode); } $oEmail = new PPI_Model_Email_Advanced(); $oEmail->Subject = $p_sSubject; $oEmail->SetFrom($oConfig->system->adminEmail, $oConfig->system->adminName); $oEmail->AddAddress($p_aUser['email']); $oEmail->AltBody = $p_sMessage; $oEmail->MsgHTML($p_sMessage); // If the email sent successfully, if ($oEmail->Send()) { $oUser = new APP_Model_User(); $sPrimaryKey = $oUser->getPrimaryKey(); // Lets update the users record with their recovery_code $oUser->putRecord(array('recovery_code' => $sRecoveryCode, $sPrimaryKey => $p_aUser[$sPrimaryKey])); return true; } return false; }
/** * This function cannot be called directly, it must be extended by a child class and then called. * * @return void */ protected function register() { // If they are already logged in, send them to the postloginredirect location if ($this->isLoggedIn() === true) { $this->postLoginRedirect(); } // Init $oForm = new PPI_Model_Form(); $oUser = new APP_Model_User(); $oForm->init('user_register', '', 'post'); $oForm->setFormStructure($oUser->_registerFormStructure); // If the form has been submitted and has been validated if ($oForm->isSubmitted() && $oForm->isValidated()) { // Get the info from the form and pass it to the usermodel for insertion $oUser->putRecord($oForm->getSubmitValues()); // Redirect to the login page $this->redirect('user/login'); } $this->addStylesheet('formbuilder.css'); $this->addJavascript('jquery-validate/jquery.validate.min.js'); // show our registration page $this->load('user/register', array('formBuilder' => $oForm->getRenderInformation())); }