Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added conditions to SMS sending to check for SMSlib

  • Loading branch information...
commit f2155573ffc10c081e65cdd01b4ddd59d9455c8a 1 parent e839b6e
Mark Johnson authored
Showing with 16 additions and 12 deletions.
  1. +16 −12 block_course_appointments.php
View
28 block_course_appointments.php
@@ -94,10 +94,12 @@ public function cron() {
$a = new stdClass;
$a->name = fullname($teacher);
$a->time = date('H:i', $appointment->timestart);
- $sms = SMS::Loader($CFG);
- if ($sms->format_number($student->phone2)) {
- $reminder = get_string('remindsms', 'block_course_appointments', $a);
- $sent = $sms->send_message(array($student->phone2), $reminder);
+ if (class_exists('SMS')) {
+ $sms = SMS::Loader($CFG);
+ if ($sms->format_number($student->phone2)) {
+ $reminder = get_string('remindsms', 'block_course_appointments', $a);
+ $sent = $sms->send_message(array($student->phone2), $reminder);
+ }
}
}
}
@@ -378,14 +380,16 @@ public function process_form() {
$subject = get_string('notifysubject', 'block_course_appointments', $names->teacher);
$message = get_string('notifytext', 'block_course_appointments', $names);
$notified = email_to_user($this->student, $USER, $subject, $message);
- $sms = SMS::Loader($CFG);
- if ($sms->format_number($this->student->phone2)) {
- $message = get_string('notifysms', 'block_course_appointments', $names);
- $sent = $sms->send_message(array($this->student->phone2), $message);
- // Create a list of users to whom the message failed to send
- foreach ($sent->responses as $response) {
- if ($response->code == 1) {
- $notified = true;
+ if (class_exists('SMS')) {
+ $sms = SMS::Loader($CFG);
+ if ($sms->format_number($this->student->phone2)) {
+ $message = get_string('notifysms', 'block_course_appointments', $names);
+ $sent = $sms->send_message(array($this->student->phone2), $message);
+ // Create a list of users to whom the message failed to send
+ foreach ($sent->responses as $response) {
+ if ($response->code == 1) {
+ $notified = true;
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.