/** * Create a new Administrator object, given the set of initial attribute values. * @param String $firstName the first name * @param lastName String the last name * @param userName String the user name (login name) * @param password String the password * @param emailAddress String the email address * @return Entity\AdministratorImpl a new Administrator object instance with the given attribute values * @throws RDException in case either firstName, lastName, or userName is null */ public function createAdministrator($firstName = null, $lastName = null, $userName = null, $password = null, $emailAddress = null) { //echo 'ASDFSFADFAF ' . $firstName . ' ' . $lastName . ' ' . $emailAddress; $anAdmin = new Entity\AdministratorImpl(); //if ($firstName != null && $lastName != null && $userName != null && // $password != null && $emailAddress != null) { $anAdmin->setFirstName($firstName); $anAdmin->setLastName($lastName); $anAdmin->setUserName($userName); $anAdmin->setPassword($password); $anAdmin->setEmailAddress($emailAddress); // }// //echo var_dump($anAdmin->getUserName() . ' ' . $anAdmin->getEmailAddress()); return $anAdmin; }
<?php require_once "autoload.php"; use edu\uga\cs\recdawgs\logic\impl\LogicLayerImpl; use edu\uga\cs\recdawgs\entity\impl as Entity; $logicLayer = new LogicLayerImpl(); $userName = trim($_POST['userName']); try { // find admin or student $adminModel = new Entity\AdministratorImpl(); $adminModel->setUserName($userName); $admin = $logicLayer->findAdmin($adminModel, -1)->current(); $studentModel = new Entity\StudentImpl(); $studentModel->setUserName($userName); $student = $logicLayer->findStudent($studentModel, -1)->current(); // reset password $logicLayer->resetPassword($student, $admin); $successMsg = urlencode("Password successfully reset!"); header("Location: ../login.php?status={$successMsg}"); } catch (\edu\uga\cs\recdawgs\RDException $rde) { $error_msg = urlencode($rde->string); header("Location: ../login.php?status={$error_msg}"); } catch (Exception $e) { $errorMsg = urlencode("Unexpected error"); header("Location: ../login.php?status={$errorMsg}"); } exit;