public static function send_roommate_reminder_emails($term) { PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModclass('hms', 'StudentFactory.php'); // Get a list of outstanding roommate requests, send them reminder emails $query = "select hms_lottery_reservation.* FROM hms_lottery_reservation\n LEFT OUTER JOIN (SELECT asu_username FROM hms_assignment WHERE term={$term} AND lottery = 1) as foo ON hms_lottery_reservation.asu_username = foo.asu_username\n WHERE foo.asu_username IS NULL\n AND hms_lottery_reservation.expires_on > " . time(); $result = PHPWS_DB::getAll($query); if (PEAR::isError($result)) { PHPWS_Error::log($result); test($result, 1); } $year = Term::toString($term) . ' - ' . Term::toString(Term::getNextTerm($term)); foreach ($result as $row) { $student = StudentFactory::getStudentByUsername($row['asu_username'], $term); $requestor = StudentFactory::getStudentByUsername($row['requestor'], $term); $bed = new HMS_Bed($row['bed_id']); $hall_room = $bed->where_am_i(); HMS_Email::send_lottery_roommate_reminder($row['asu_username'], $student->getName(), $row['expires_on'], $requestor->getName(), $hall_room, $year); HMS_Activity_Log::log_activity($row['asu_username'], ACTIVITY_LOTTERY_ROOMMATE_REMINDED, 'hms'); } }
private function sendRoommateReminderEmails() { // Get a list of outstanding roommate requests, send them reminder emails $query = "select hms_lottery_reservation.* FROM hms_lottery_reservation\n LEFT OUTER JOIN (SELECT asu_username FROM hms_assignment WHERE term={$this->term}) as foo ON hms_lottery_reservation.asu_username = foo.asu_username\n WHERE foo.asu_username IS NULL\n AND hms_lottery_reservation.term = {$this->term}\n AND hms_lottery_reservation.expires_on > " . $this->now; $result = PHPWS_DB::getAll($query); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } foreach ($result as $row) { $student = StudentFactory::getStudentByUsername($row['asu_username'], $this->term); $requestor = StudentFactory::getStudentByUsername($row['requestor'], $this->term); $bed = new HMS_Bed($row['bed_id']); $hall_room = $bed->where_am_i(); HMS_Email::send_lottery_roommate_reminder($row['asu_username'], $student->getName(), $row['expires_on'], $requestor->getName(), $hall_room, $this->academicYear); HMS_Activity_Log::log_activity($row['asu_username'], ACTIVITY_LOTTERY_ROOMMATE_REMINDED, UserStatus::getUsername()); } }