Пример #1
0
 /**
  * Notify the relevant people of a new issue
  *
  * @param unknown_type $issue
  */
 private function notifyOfNewIssue($issue)
 {
     // get the group assigned to the project that this issue is against
     $project = $this->projectService->getProject($issue->projectid);
     $group = $this->groupService->getGroup($project->ownerid);
     // Only send if the group exists
     if ($group) {
         $users = $this->groupService->getUsersInGroup($group);
         $msg = new TemplatedMessage('new-issue.php', array('model' => $issue, 'project' => $project));
         $this->notificationService->notifyUser("New request has been created", $users, $msg);
     }
     // if the new issue is a severity 1, then sms as well
     if ($issue->severity == Issue::SEVERITY_ONE) {
         $this->trackerService->track('sev1request', 'request-' . $issue->id);
         $user = $this->userService->getUserByField('username', $issue->userid);
         if ($user != null && $user->contactid) {
             $contactDetails = $this->clientService->getContact($user->contactid);
             if ($contactDetails && mb_strlen($contactDetails->mobile)) {
                 // lets send a quick SMS
                 if ($this->smsService->send("New Severity 1 request #" . $issue->id . ": " . $issue->title . ", please login and check ASAP!", $contactDetails->mobile)) {
                     $this->trackerService->track('sendsms', 'request-' . $issue->id);
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * @return SmsService
  */
 public static function getInstance()
 {
     if (!isset(self::$instance) || !is_object(self::$instance)) {
         self::$instance = new SmsService();
     }
     return self::$instance;
 }
Пример #3
0
 function gw_set_incoming_action()
 {
     $kodeord = 'BBB';
     require_once 'SmsService.php';
     $options = array();
     $options['soap_version'] = SOAP_1_1;
     $options['location'] = $this->sms_param['service_url'];
     $options['uri'] = "http://soa01a.srv.bergenkom.no/biz/bk/sms/SmsService-v1";
     $options['trace'] = 1;
     $options['proxy_host'] = $this->sms_param['proxy_host'];
     $options['proxy_port'] = $this->sms_param['proxy_port'];
     $options['encoding'] = 'iso-8859-1';
     //'UTF-8';
     $options['login'] = $this->sms_param['login'];
     $options['password'] = $this->sms_param['password'];
     $service = new SmsService($this->sms_param['wsdl'], $options);
     $UserContext = new UserContext();
     $UserContext->userid = $GLOBALS['phpgw_info']['user']['account_lid'];
     $UserContext->appid = 'Portico';
     $getNyeInnkommendeMeldinger = new getNyeInnkommendeMeldinger();
     $getNyeInnkommendeMeldinger->userContext = $UserContext;
     $getNyeInnkommendeMeldinger->kodeord = $kodeord;
     $ReturnValue = $service->getNyeInnkommendeMeldinger($getNyeInnkommendeMeldinger);
     $response = array();
     if (isset($ReturnValue->return)) {
         $_response = $ReturnValue->return;
         if (is_array($_response)) {
             $response = $_response;
         } else {
             $response[] = $_response;
         }
     }
     $datetime_format = phpgwapi_db::datetime_format();
     foreach ($response as $entry) {
         $sms_datetime = date($datetime_format, time());
         // should not be calculated
         $message = trim(ltrim($entry->tekst, $entry->kodeord));
         $array_target_code = explode(' ', $message);
         $target_code = strtoupper(trim($array_target_code[0]));
         $message = $array_target_code[1];
         for ($i = 2; $i < count($array_target_code); $i++) {
             $message .= " {$array_target_code[$i]}";
         }
         $this->setsmsincomingaction($sms_datetime, $entry->tlfavsender, $target_code, $message);
     }
     return $ReturnValue;
 }
 private function sendSMS($phoneNumber, $message, $times = 0)
 {
     import('ORG.Sms.SmsService');
     if ($times > 3) {
         return -1;
     }
     $service = SmsService::getSMSChannel($phoneNumber);
     //选择模板,加上发送的验证码即可
     $result = $service->sendSMS($phoneNumber, $message);
     if ($result == '-1') {
         return $this->sendSMS($phoneNumber, $message, ++$times);
     } else {
         return $result;
     }
 }
Пример #5
0
 function gw_set_delivery_status($gp_code = "", $uid = "", $smslog_id = "", $p_datetime = "", $p_update = "", $external_id = 0)
 {
     if (!$external_id) {
         return;
     }
     require_once 'SmsService.php';
     $options = array();
     $options['soap_version'] = SOAP_1_1;
     $options['location'] = $this->sms_param['service_url'];
     $options['uri'] = "http://soa01a.srv.bergenkom.no/biz/bk/sms/SmsService-v1";
     $options['trace'] = 1;
     if (isset($this->sms_param['proxy_host']) && $this->sms_param['proxy_host']) {
         $options['proxy_host'] = $this->sms_param['proxy_host'];
         $options['proxy_port'] = $this->sms_param['proxy_port'];
     }
     $options['encoding'] = 'iso-8859-1';
     //'UTF-8';
     $options['login'] = $this->sms_param['login'];
     $options['password'] = $this->sms_param['password'];
     $service = new SmsService($this->sms_param['wsdl'], $options);
     $UserContext = new UserContext();
     $MeldingsStatus = new MeldingsStatus();
     $MeldingsStatus->id = $external_id;
     $MeldingsStatus->status = '';
     $MeldingsStatus->feiltekst = '';
     $hentStatus = new hentStatus();
     $hentStatus->userContext = $UserContext;
     $hentStatus->status = $MeldingsStatus;
     $ReturnValue = $service->hentStatus($hentStatus);
     $result['statuscode'] = $ReturnValue->return->status;
     $result['messageid'] = $ReturnValue->return->id;
     $result['description'] = $ReturnValue->return->feiltekst;
     // p_status :
     // 0 = pending
     // 1 = delivered
     // 2 = failed
     switch ($result['statuscode']) {
         case 'OK':
             $this->setsmsdeliverystatus($smslog_id, $uid, 1, $result['messageid']);
             $ret = true;
             break;
         case 'Venter':
             $this->setsmsdeliverystatus($smslog_id, $uid, 0, $result['messageid']);
             $ret = true;
             break;
         case 'Feil':
             $this->setsmsdeliverystatus($smslog_id, $uid, 2, $result['messageid']);
             $ret = true;
             break;
     }
     return;
 }
Пример #6
0
 /**
  * @param Irc $parent
  * @param $data
  * @param $extra
  * @return bool
  */
 public function privmsg($parent, $data, $extra)
 {
     extract($extra);
     $network = $parent->getNetworkName();
     $cmd = '';
     $data = '';
     if (strpos($msg, " ") !== false) {
         list(, $cmd) = explode(' ', trim($msg), 2);
         $cmd = trim($cmd);
         if (strpos($cmd, " ") !== false) {
             list($cmd, $data) = explode(' ', $cmd, 2);
             $data = trim($data);
         }
     }
     if (substr_count($msg, " ") > 2) {
         list(, $cmd, $data) = explode(' ', trim($msg), 3);
     }
     if ($private) {
         if (empty($cmd)) {
             $parent->privmsg($replyto, "Registrera: !sms reg #kanal dittnummer");
             $parent->privmsg($replyto, "Verifiera nummer: !sms verify koden");
             return true;
         }
         $cmd = strtolower($cmd);
         if ($cmd == 'reg' || $cmd == 'register') {
             if (strpos($data, ' ') !== false) {
                 list($chan, $num) = explode(' ', $data, 2);
                 $chan = trim($chan);
                 $num = trim($num);
             }
             if (!in_array(strtolower($chan), self::$channels[$network])) {
                 $parent->privmsg($replyto, "Ogiltig kanal, har kanalen sms-funktionen aktiverad?");
                 return true;
             }
             if (preg_match(self::$number, $num) == 0) {
                 $parent->privmsg($replyto, "Ogiltigt nummer, ange endast siffror. t.ex: !sms reg {$chan} 0701234567");
                 return true;
             }
             $confirm = '';
             $t = "abcdefghijklmnopqrstuvwxyz0123456789";
             for ($i = 0; $i < 6; $i++) {
                 $confirm .= substr($t, rand(0, strlen($t) - 1), 1);
             }
             if (!$this->service->sendSms($num, "Din verifieringskod är: {$confirm} - Om du inte vet vad det här är kan du ignorera detta sms")) {
                 $parent->privmsg($replyto, "Kunde inte skicka SMS, prova igen om en stund");
                 return true;
             }
             $this->service->regUser($nick, $chan, $network, $num, $confirm);
             $parent->privmsg($replyto, "Ditt nummer har sparats/uppdaterats för {$chan}. " . "Ett SMS har skickats för att verifiera ditt nummer, vänligen skriv /msg {$parent->me()->nick} !sms verify koden");
         }
         if ($cmd == 'verify') {
             $code = trim($data);
             if ($this->service->verifyUser($nick, $code)) {
                 $parent->privmsg($replyto, "Ditt nummer har verifierats, du kan nu skicka sms till och ta emot sms från kanalen.");
             } else {
                 $parent->privmsg($replyto, "Koden är ogiltig");
             }
         }
     } else {
         if (!in_array($target, self::$channels[$network])) {
             return false;
         }
         if (!empty($cmd) && strtolower($cmd) == "list" && empty($data)) {
             $users = $this->service->listUsers($network, $target);
             $this->parent->notice($nick, "SMS-Användare i {$target}: " . implode(', ', $users));
             return true;
         }
         if (empty($cmd) || empty($data)) {
             $parent->privmsg($replyto, "{$nick}: Syntax: !sms nick meddelande, t.ex: !sms {$nick} Hej! - !sms list, Lista med användare - För registrering: /msg {$parent->me()->nick} !sms reg {$target} 07xxxxxxxx");
             return true;
         }
         $tonick = $cmd;
         $number = $this->service->getNumber($tonick, $target, $network);
         if ($number === false) {
             $parent->privmsg($replyto, "{$nick}: {$tonick} är inte registrerad. /msg {$parent->me()->nick} !sms reg {$target} nummer");
             return true;
         }
         $smsprefix = "<{$nick}@{$target}> ";
         $smstext = $smsprefix . $data;
         if (strlen($smstext) > 160) {
             $parent->privmsg($replyto, "{$nick}: Ditt sms får max vara " . (160 - strlen($smsprefix)) . " tecken, nuvarande: " . strlen($data) . " tecken");
             return true;
         }
         if ($this->service->sendSms($number, $smstext, 1)) {
             $this->service->insertHistory($nick, $tonick, $target, $network, $number, 1);
             $parent->privmsg($replyto, "04[SMS] Skickar sms till {$tonick}: 12{$smstext}");
             return true;
         } else {
             $parent->privmsg($replyto, "{$nick}: Meddelandet kunde inte skickas, prova igen om en stund");
             return true;
         }
     }
 }