Пример #1
0
 public static function send_winning_reminder_emails($term)
 {
     PHPWS_Core::initModClass('hms', 'HMS_Email.php');
     PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php');
     PHPWS_Core::initModclass('hms', 'StudentFactory.php');
     // Get a list of lottery winners who have not chosen a room yet, send them reminder emails
     $query = "select hms_new_application.username, hms_lottery_application.invite_expires_on FROM hms_new_application JOIN hms_lottery_application ON hms_new_application.id = hms_lottery_application.id\n                LEFT OUTER JOIN (SELECT asu_username FROM hms_assignment WHERE term={$term} AND lottery = 1) as foo ON hms_new_application.username = foo.asu_username\n                WHERE foo.asu_username IS NULL\n                AND hms_lottery_application.invite_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['username'], $term);
         HMS_Email::send_lottery_invite_reminder($row['username'], $student->getName(), $row['invite_expires_on'], $year);
         HMS_Activity_Log::log_activity($row['username'], ACTIVITY_LOTTERY_REMINDED, 'hms');
     }
 }
Пример #2
0
 private function sendWinningReminderEmails()
 {
     $ttl = INVITE_TTL_HRS * 3600;
     // Get a list of lottery winners who have not chosen a room yet, send them reminder emails
     $query = "select username from hms_new_application\n                    JOIN hms_lottery_application ON hms_new_application.id = hms_lottery_application.id\n                    LEFT OUTER JOIN (select * from hms_assignment where term = {$this->term}) AS foo ON hms_new_application.username = foo.asu_username\n                    WHERE foo.asu_username IS NULL\n                    AND hms_new_application.term = {$this->term}\n                    AND application_type = 'lottery'\n                    AND invited_on IS NOT NULL\n                    AND (hms_lottery_application.invited_on + {$ttl}) > {$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['username'], $this->term);
         HMS_Email::send_lottery_invite_reminder($row['username'], $student->getName(), $this->academicYear);
         HMS_Activity_Log::log_activity($row['username'], ACTIVITY_LOTTERY_REMINDED, UserStatus::getUsername());
     }
 }