/** * Dials a number by the given lineId * * @param string $lineId * @param string $number * @throws Sipgate_Exception_Backend */ public function dialNumber($lineId = NULL, $number = NULL) { $line = $this->_getLineToOperateOn($lineId); Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " contact number: " . $number); $number = preg_replace("/[^0-9+()]+/", "", $number); $number = preg_replace("/\\(.*\\)/", "", $number); Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " number to dail: " . $number); if (!$number) { throw new Sipgate_Exception('Please use a number!'); } elseif (strpos($number, '+') == 0) { // number has already the international format $number = 'sip:' . str_replace('+', '', $number) . '@sipgate.de'; } elseif (substr($number, 0, 2) == '00') { // number has the international format with 00 prefixed $number = 'sip:+' . substr($number, 2) . '@sipgate.de'; } elseif (strpos($number, '0') == 0) { // number has the national format $pref = new Sipgate_Preference(); $number = 'sip:' . $pref->getValue(Sipgate_Preference::INTERNATIONAL_PREFIX) . substr($number, 1) . '@sipgate.de'; } else { throw new Sipgate_Exception('The number yout tried to call can not be resolved properly!'); } Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " SIP Number: " . $number); return array('result' => Sipgate_Backend_Api::getInstance()->connect($line->account_id)->dialNumber($line->sip_uri, $number), 'line' => $line); }
/** * send SMS * * @param string $_number * @param string $_content */ public function sendSms($_number, $_content) { $_sender = $this->_pref->getValue('mobileNumber'); $backend = Sipgate_Backend_Factory::factory(); return $backend->sendSms($_sender, $_number, $_content); }