示例#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 phone firmware
  *
  * @param Voipmanager_Model_Snom_Phone $_phone
  * @return string the firmware as xml string
  * @throws  Voipmanager_Exception_Validation
  */
 public function getFirmware(Voipmanager_Model_Snom_Phone $_phone)
 {
     if (!$_phone->isValid()) {
         throw new Voipmanager_Exception_Validation('invalid phone');
     }
     $snomLocation = new Voipmanager_Backend_Snom_Location($this->_db);
     $locationSettings = $snomLocation->get($_phone->location_id);
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><firmware-settings></firmware-settings>');
     $select = $this->_db->select()->from(SQL_TABLE_PREFIX . 'snom_phones', array())->where($this->_db->quoteIdentifier(SQL_TABLE_PREFIX . 'snom_phones.macaddress') . ' = ?', $_phone->macaddress)->join(SQL_TABLE_PREFIX . 'snom_templates', SQL_TABLE_PREFIX . 'snom_phones.template_id = ' . SQL_TABLE_PREFIX . 'snom_templates.id', array())->join(SQL_TABLE_PREFIX . 'snom_software', SQL_TABLE_PREFIX . 'snom_templates.software_id = ' . SQL_TABLE_PREFIX . 'snom_software.id', array('softwareimage_' . $_phone->current_model));
     $firmware = $this->_db->fetchOne($select);
     if (!empty($firmware)) {
         $child = $xml->addChild('firmware', $locationSettings->base_download_url . '/' . $firmware);
     }
     return $xml->asXML();
 }