Exemplo n.º 1
0
 /**
  * update an existing phone
  *
  * @param Voipmanager_Model_Snom_Phone $_phone the phonedata
  * @return Voipmanager_Model_Snom_Phone
  * @throws  Voipmanager_Exception_Validation
  */
 public function updateStatus(Voipmanager_Model_Snom_Phone $_phone)
 {
     if (!$_phone->isValid()) {
         throw new Voipmanager_Exception_Validation('invalid phone');
     }
     $phoneId = $_phone->getId();
     $phoneData = $_phone->toArray();
     $statusData = array('ipaddress' => $_phone->ipaddress, 'current_software' => $_phone->current_software, 'current_model' => $_phone->current_model, 'settings_loaded_at' => $phoneData['settings_loaded_at'], 'firmware_checked_at' => $phoneData['firmware_checked_at']);
     $where = array($this->_db->quoteInto($this->_db->quoteIdentifier('id') . ' = ?', $phoneId));
     $this->_db->update($this->_tablePrefix . 'snom_phones', $statusData, $where);
     return $this->get($_phone);
 }
 /**
  * get config of one phone
  *
  * @param Voipmanager_Model_Snom_Phone $_phone
  * @return string the config as xml string
  * @throws  Voipmanager_Exception_Validation
  */
 public function getConfig(Voipmanager_Model_Snom_Phone $_phone)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " phone " . print_r($_phone->toArray(), true));
     }
     if (!$_phone->isValid()) {
         throw new Voipmanager_Exception_Validation('invalid phone');
     }
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><settings></settings>');
     $phoneSettings = $xml->addChild('phone-settings');
     $this->_appendLocationSettings($_phone, $phoneSettings);
     $this->_appendPhoneUrls($_phone, $phoneSettings);
     $this->_appendPhoneSettings($_phone, $phoneSettings);
     $this->_appendPhoneLines($_phone, $phoneSettings);
     $this->_appendUserSettings($_phone, $phoneSettings);
     // append available languages
     $snomLocation = new Voipmanager_Backend_Snom_Location($this->_db);
     $locationSettings = $snomLocation->get($_phone->location_id);
     $guiLanguages = $xml->addChild('gui-languages');
     foreach ($this->_guiLanguages as $iso => $translated) {
         $child = $guiLanguages->addChild('language');
         $child->addAttribute('url', $locationSettings->base_download_url . '/' . $_phone->current_software . '/snomlang/gui_lang_' . $iso . '.xml');
         $child->addAttribute('name', $translated);
     }
     $webLanguages = $xml->addChild('web-languages');
     foreach ($this->_webLanguages as $iso => $translated) {
         $child = $webLanguages->addChild('language');
         $child->addAttribute('url', $locationSettings->base_download_url . '/' . $_phone->current_software . '/snomlang/web_lang_' . $iso . '.xml');
         $child->addAttribute('name', $translated);
     }
     // append dialplann
     $dialPlan = $xml->addChild('dialplan');
     $this->_appendDialPlan($_phone, $dialPlan);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " xml " . $xml->asXML());
     }
     return $xml->asXML();
 }