From af35872b768ca9631fa6b9b5e5b32fdd348a11a4 Mon Sep 17 00:00:00 2001 From: Glen Date: Sun, 3 Jan 2016 20:01:47 -0700 Subject: [PATCH] Issue #244 CarrierSMS Added carriersms procedural changes --- .../Util/Server/Updater/StatusNotifier.php | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusNotifier.php b/src/psm/Util/Server/Updater/StatusNotifier.php index 1b54a862..717493f9 100644 --- a/src/psm/Util/Server/Updater/StatusNotifier.php +++ b/src/psm/Util/Server/Updater/StatusNotifier.php @@ -280,17 +280,33 @@ class StatusNotifier { // we have to build an userlist for the log table.. $userlist = array(); - // add all users to the recipients list - foreach ($users as $user) { - $userlist[] = $user['user_id']; - $sms->addRecipients($user['mobile']); + // CarrierSMS sends plain/text "email" so pass vars to CarrierSMS class. + if($GLOBALS['sm_config']['sms_gateway'] == 'carriersms') { + // add all users to the recipients list + foreach ($users as $user) { + if($user['carriersms'] != ""){ + // only log users configured with a mobile email address + $userlist[] = $user['user_id']; + $sms->addRecipients($user['carriersms']); + } + } + + // Send sms, CarrierSMS class will handle messaging + $result = $sms->sendSMS($this->status_new, $this->server); + $message = $sms->resultmessage; + }else{ + // add all users to the recipients list + foreach ($users as $user) { + $userlist[] = $user['user_id']; + $sms->addRecipients($user['mobile']); + } + + $message = psm_parse_msg($this->status_new, 'sms', $this->server); + + // Send sms + $result = $sms->sendSMS($message); } - $message = psm_parse_msg($this->status_new, 'sms', $this->server); - - // Send sms - $result = $sms->sendSMS($message); - if(psm_get_conf('log_sms')) { // save to log psm_add_log($this->server_id, 'sms', $message, implode(',', $userlist)); @@ -306,7 +322,7 @@ class StatusNotifier { public function getUsers($server_id) { // find all the users with this server listed $users = $this->db->query(" - SELECT `u`.`user_id`, `u`.`name`,`u`.`email`, `u`.`mobile`, `u`.`pushover_key`, `u`.`pushover_device` + SELECT `u`.`user_id`, `u`.`name`,`u`.`email`, `u`.`mobile`, `u`.`pushover_key`, `u`.`pushover_device`, `u`.`carriersms` FROM `".PSM_DB_PREFIX."users` AS `u` JOIN `".PSM_DB_PREFIX."users_servers` AS `us` ON ( `us`.`user_id`=`u`.`user_id` @@ -315,4 +331,4 @@ class StatusNotifier { "); return $users; } -} \ No newline at end of file +}