/**
  * A method to get a meeting that is before the one that is provided as a parameter
  * @param Meeting $meeting the meeting after the one that should be returned
  * @return Meeting|null the previous meeting
  */
 public static function getPreviousMeeting($meeting)
 {
     # Get database connection
     $objPDO = PDOFactory::get();
     # Get project ID from session
     $projectId = HTTPSession::getInstance()->PROJECT_ID;
     # Get the previous meeting, which we can recognize by
     # 1. datetime of that meeting is less than meeting provided
     # 2. Meeting is not deleted, however can be cancelled, because we might look for a meeting that was cancelled
     # 3. Meeting is approved
     $strQuery = "SELECT id FROM Meeting WHERE project_id = :project_id\n                      AND datetime < (SELECT datetime FROM Meeting WHERE id = " . $meeting->getID() . ")\n                      AND is_deleted = 0\n                      AND is_approved = 1\n                      ORDER BY datetime DESC\n                      LIMIT 1";
     $objStatement = $objPDO->prepare($strQuery);
     $objStatement->bindValue(':project_id', $projectId, PDO::PARAM_INT);
     $objStatement->execute();
     # Define empty variable
     $prevMeeting = null;
     # Get the previous meeting if it exists
     if ($row = $objStatement->fetch(PDO::FETCH_ASSOC)) {
         $prevMeeting = new Meeting($row['id']);
     }
     # The previous meeting
     return $prevMeeting;
 }
Пример #2
0
 /**
  * A method to deny access if user is trying to cancel two meetings in a row
  * @param Meeting $meeting the meeting object
  * @param null $error if error should be displayed
  */
 protected function checkAuthTwoMeetingsInRow($meeting, $error = null)
 {
     # Two meetings in a row cannot be cancelled, if previous meeting was cancelled
     # then we cannot approve this meeting to be cancelled
     if ($meeting->getPreviousMeeting() instanceof Meeting && $meeting->getPreviousMeeting()->getIsCancelled() && !$error) {
         header('Location: ' . SITE_URL . 'meetings/cancel/' . $meeting->getID() . '/error');
     }
 }