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);
 }
Exemple #2
0
 public static function send_break_emails(HMS_Roommate $request, $breaker)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     $breakee = $request->get_other_guy($breaker);
     $breakerStudent = StudentFactory::getStudentByUsername($breaker, $request->term);
     $breakeeStudent = Studentfactory::getStudentByUsername($breakee, $request->term);
     $tags = array();
     $tags['BREAKER'] = $breakerStudent->getFullName();
     $tags['BREAKER_FIRST'] = $breakerStudent->getFirstName();
     $tags['BREAKEE'] = $breakeeStudent->getFullName();
     // to the breaker
     HMS_Email::send_template_message($breaker . TO_DOMAIN, 'HMS Roommate Pairing Broken', 'email/roommate_break_breaker.tpl', $tags);
     // to the breakee
     HMS_Email::send_template_message($breakee . TO_DOMAIN, 'HMS Roommate Pairing Broken', 'email/roommate_break_breakee.tpl', $tags);
     return TRUE;
 }