コード例 #1
0
 /**
  * constructor
  *
  * @param Zend_Db_Adapter_Abstract|optional $_db the database adapter to use
  */
 public function __construct($_db = NULL)
 {
     if ($_db instanceof Zend_Db_Adapter_Abstract) {
         $this->_db = $_db;
     } else {
         $this->_db = Zend_Db_Table_Abstract::getDefaultAdapter();
     }
     $this->_baseURL = Voipmanager_Frontend_Snom_Abstract::getBaseUrl();
 }
コード例 #2
0
 protected function _appendLocationSettings(Voipmanager_Model_Snom_Phone $_phone, SimpleXMLElement $_xml)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " xml " . $_xml->asXML());
     }
     $snomLocation = new Voipmanager_Backend_Snom_Location($this->_db);
     $locationSettings = $snomLocation->get($_phone->location_id);
     #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " localtion_id " . print_r($locationSettings, true));
     $locationSettings = $locationSettings->toArray();
     unset($locationSettings['id']);
     unset($locationSettings['name']);
     unset($locationSettings['description']);
     unset($locationSettings['registrar']);
     unset($locationSettings['base_download_url']);
     // see http://wiki.snom.com/Interoperability/Asterisk#Basic_Asterisk_configuration
     $locationSettings['user_phone'] = 'off';
     $locationSettings['filter_registrar'] = 'off';
     $locationSettings['challenge_response'] = 'off';
     $locationSettings['call_completion'] = 'off';
     // disable redundant keys
     $locationSettings['redundant_fkeys'] = 'off';
     $locationSettings['setting_server'] = Voipmanager_Frontend_Snom_Abstract::getBaseUrl() . '?method=Voipmanager.settings&mac=' . $_phone->macaddress;
     $locationSettings['firmware_status'] = Voipmanager_Frontend_Snom_Abstract::getBaseUrl() . '?method=Voipmanager.firmware&mac=' . $_phone->macaddress;
     foreach ($locationSettings as $key => $value) {
         $child = $_xml->addChild($key, $value);
         if ($key == 'admin_mode') {
             $child->addAttribute('perm', 'RW');
         } else {
             $child->addAttribute('perm', 'RO');
         }
     }
     // reset old dialplan
     $child = $_xml->addChild('user_dp_str1');
     $child->addAttribute('perm', 'RW');
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " xml " . $_xml->asXML());
     }
 }
コード例 #3
0
 /**
  * keeps track of the call history
  * 
  * the callId can be 3c3b966053be-phxdiv27t9gm or 7027a58643aeb25149e4861076f1b0a9@xxx.xxx.xxx.xxx
  * we strip everything after the @ character
  *
  * @param string $mac the mac address of the phone
  * @param string $event event can be connected, disconnected, incoming, outgoing, missed
  * @param string $callId the callid
  * @param string $local the username of the asterisk sip peer
  * @param string $remote the remote number
  * 
  * @todo add correct line_id
  */
 public function callHistory($mac, $event, $callId, $local, $remote)
 {
     // there is no need to start session for call history
     // it's a single shot request
     parent::_authenticate();
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Event: {$event} CallId: {$callId} Local: {$local} Remote: {$remote} ");
     }
     $phone = Voipmanager_Controller_Snom_Phone::getInstance()->getByMacAddress($mac);
     $controller = Phone_Controller::getInstance();
     $pos = strpos($callId, '@');
     if ($pos !== false) {
         $callId = substr($callId, 0, $pos);
     }
     $pos = strpos($local, '@');
     if ($pos !== false) {
         $local = substr($local, 0, $pos);
     }
     $pos = strpos($remote, '@');
     if ($pos !== false) {
         $remote = substr($remote, 0, $pos);
     }
     $call = new Phone_Model_Call(array('id' => substr($callId, 0, 40), 'phone_id' => $phone->getId(), 'line_id' => $local));
     switch ($event) {
         case 'outgoing':
             $call->source = $local;
             $call->destination = $remote;
             $call->direction = Phone_Model_Call::TYPE_OUTGOING;
             $controller->callStarted($call);
             break;
         case 'incoming':
             $call->source = $local;
             $call->destination = $remote;
             $call->direction = Phone_Model_Call::TYPE_INCOMING;
             $controller->callStarted($call);
             break;
         case 'connected':
             $controller->callConnected($call);
             break;
         case 'disconnected':
             $controller->callDisconnected($call);
             break;
     }
 }