Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 /**
  * Deletes an Admin or Student from db.
  *
  * @param Entity\AdministratorImpl $user
  * @throws RDException
  */
 public function delete($user)
 {
     if ($user->getId() == -1) {
         //if user isn't persistent, we are done
         return;
     }
     //Prepare mySQL query
     $q = 'DELETE FROM ' . DB_NAME . '.user WHERE user_id = ?;';
     //create Prepared statement
     $stmt = $this->dbConnection->prepare($q);
     //bind parameter to query
     $persistenceId = $user->getId();
     $stmt->bindParam(1, $persistenceId, \PDO::PARAM_INT);
     //execute query
     if ($stmt->execute()) {
         echo 'User deleted successfully';
     } else {
         throw new RDException('Deletion of User successful');
     }
 }
Пример #3
0
 /**
  * Adds student as member of team.
  * 
  * @param Entity\AdministratorImpl $student
  * @param Entity\TeamImpl $team
  * @throws RDException
  */
 public function storeStudentMemberOf($student, $team)
 {
     $q = 'INSERT INTO is_member_of (user_id, team_id) VALUES(?, ?);';
     $stmt = $this->dbConnection->prepare($q);
     $studentID = $student->getId();
     $teamID = $team->getId();
     $stmt->bindParam(1, $studentID, \PDO::PARAM_INT);
     $stmt->bindParam(2, $teamID, \PDO::PARAM_INT);
     if ($stmt->execute()) {
         echo "\n            {$student->getFirstName()} {$student->getLastName()} successfully added as team member of: " . $team->getName();
     } else {
         throw new RDException($student->getUserName() . ' unsuccessfully added as team member of: ' . $team->getName());
     }
 }
Пример #4
0
<?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;