コード例 #1
0
 protected function _createCalls()
 {
     $lineId = $this->_phone->lines[0]['id'];
     $phoneId = $this->_phone->getId();
     $d1 = Tinebase_DateTime::now()->subDay()->setTime(12, 00, 00);
     $d2 = clone $d1;
     $d2->addSecond(10);
     $d3 = clone $d2;
     $d3->addMinute(20);
     $i = 1;
     while ($i < 20) {
         $call = array('line_id' => $lineId, 'phone_id' => $phoneId, 'callerid' => $i * 100, 'start' => $d1, 'connected' => $d2, 'disconnected' => $d3, 'duration' => $d3->getTimestamp() - $d2->getTimestamp(), 'ringing' => $i, 'direction' => $i % 2 ? 'in' : 'out', 'source' => '+49123456789', 'destination' => '+44' . $i . $i . $i . $i);
         Phone_Controller_Call::getInstance()->create(new Phone_Model_Call($call));
         $d1->addMinute(20)->subSecond($i);
         $d2->addMinute(20)->addSecond($i);
         $d3->addMinute(20)->addSecond($i * 1);
         $i++;
     }
 }
コード例 #2
0
 /**
  * set value of http_client_info_sent
  *
  * @param string|array|Tinebase_Record_RecordSet $_id
  * @param boolean $_status
  * @throws  Voipmanager_Exception_Backend
  */
 public function setHttpClientInfoSent($_id, $_status)
 {
     foreach ((array) $_id as $id) {
         $phoneId = Voipmanager_Model_Snom_Phone::convertSnomPhoneIdToInt($id);
         $where[] = $this->_db->quoteInto($this->_db->quoteIdentifier('id') . ' = ?', $phoneId);
     }
     try {
         $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction($this->_db);
         // NOTE: cascading delete for lines and phone_settings
         // SECOND NOTE: using array for second argument won't work as delete function joins array items using "AND"
         #foreach($where AS $where_atom)
         #{
         #    $this->_db->delete($this->_tablePrefix . 'snom_phones', $where_atom);
         #}
         $phoneData = array('http_client_info_sent' => (bool) $_status);
         $this->_db->update($this->_tablePrefix . 'snom_phones', $phoneData, $where);
         Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
     } catch (Exception $e) {
         Tinebase_TransactionManager::getInstance()->rollBack();
         throw new Voipmanager_Exception_Backend($e->getMessage());
     }
 }
コード例 #3
0
 /**
  * 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();
 }
コード例 #4
0
 /**
  * create lines / sippeers
  * 
  * @param Voipmanager_Model_Snom_Phone|Phone_Model_MyPhone $_phone
  * @param array $_lines
  * @return void
  */
 protected function _createLines($_phone, $_lines)
 {
     foreach ($_lines as $line) {
         $line->snomphone_id = $_phone->getId();
         if (is_array($line->asteriskline_id)) {
             $sippeer = new Voipmanager_Model_Asterisk_SipPeer($line->asteriskline_id);
             $sippeer = Voipmanager_Controller_Asterisk_SipPeer::getInstance()->update($sippeer);
             $line->asteriskline_id = $sippeer->getId();
         }
         if (empty($line->asteriskline_id)) {
             throw new Voipmanager_Exception_Validation('asteriskline_id is required.');
         }
         $addedLine = Voipmanager_Controller_Snom_Line::getInstance()->create($line);
     }
 }
コード例 #5
0
 /**
  * delete lines(s) identified by phone id
  *
  * @param string|Voipmanager_Model_Snom_Phone $_id
  */
 public function deletePhoneLines($_id)
 {
     $phoneId = Voipmanager_Model_Snom_Phone::convertSnomPhoneIdToInt($_id);
     $where[] = $this->_db->quoteInto($this->_db->quoteIdentifier('snomphone_id') . ' = ?', $phoneId);
     $this->_db->delete($this->_tablePrefix . $this->_tableName, $where);
 }