Ejemplo n.º 1
0
 protected function createPairing(HousingApplication $a, HousingApplication $b)
 {
     // Determine lifestyle option
     $option = LO_COED;
     if ($a->lifestyle_option == LO_SINGLE_GENDER || $b->lifestyle_option == LO_SINGLE_GENDER) {
         $option = LO_SINGLE_GENDER;
     }
     try {
         $studentA = StudentFactory::getStudentByUsername($a->username, $this->term);
     } catch (StudentNotFoundException $e) {
         echo 'StudentNotFoundException: ' . $a->username . ' Could not pair ' . $a->username . ', ' . $b->username . "\n";
         return null;
     }
     try {
         $studentB = Studentfactory::getStudentByUsername($b->username, $this->term);
     } catch (StudentNotFoundException $e) {
         echo 'StudentNotFoundException: ' . $b->username . ' Could not pair ' . $a->username . ', ' . $b->username . "\n";
         return null;
     }
     if ($a->getCreatedOn() < $b->getCreatedOn()) {
         $earliestTime = $a->getCreatedOn();
     } else {
         $earliestTime = $b->getCreatedOn();
     }
     // Looks like there is no problem here.
     return new AssignmentPairing($studentA, $studentB, $option, $earliestTime);
 }
Ejemplo n.º 2
0
 /**
  * Sends everyone involved in a room change notice when it is fully approved and
  * can happen in the real world.  Note this is a little different than the other
  * ones because it does the looping itself and sends multiple messages.
  *
  * @param $r RoomChangeRequest The Room Change Request that is in process
  * TODO: Add to/from bed for each participant
  */
 public static function sendRoomChangeInProcessNotice(RoomChangeRequest $r)
 {
     PHPWS_Core::initModClass('hms', 'StudentFactory.php');
     $subject = 'Room Change Approved!';
     $template = 'email/roomChangeApprovalNotice.tpl';
     $tags = array('PARTICIPANTS' => array());
     $recipients = array();
     foreach ($r->getParticipants() as $p) {
         $student = Studentfactory::getStudentByBannerID($p->getBannerID(), $r->getTerm());
         $current = new HMS_Bed($p->getFromBed());
         $future = new HMS_Bed($p->getToBed());
         $recipients[] = $student;
         $tags['PARTICIPANTS'][] = array('NAME' => $student->getName(), 'CURRENT_LOCATION' => $current->where_am_i(), 'FUTURE_LOCATION' => $future->where_am_i());
     }
     foreach ($r->getAllPotentialApprovers() as $a) {
         $recipients[] = array($a . TO_DOMAIN => '');
     }
     $message = self::makeSwiftmailMessage(null, $subject, $tags, $template);
     foreach ($recipients as $r) {
         if ($r instanceof Student) {
             $message->setTo($r->getUsername() . TO_DOMAIN);
         } else {
             $message->setTo($r);
         }
         self::sendSwiftmailMessage($message);
     }
 }