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++; } }
/** * 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); }
/** * appends user settings * * @param Voipmanager_Model_Snom_Phone $_phone * @param SimpleXMLElement $_xml */ protected function _appendUserSettings(Voipmanager_Model_Snom_Phone $_phone, SimpleXMLElement $_xml) { $phoneSettinsgBackend = new Voipmanager_Backend_Snom_PhoneSettings($this->_db); $phoneSettings = $phoneSettinsgBackend->get($_phone->getId()); $templateBackend = new Voipmanager_Backend_Snom_Template($this->_db); $template = $templateBackend->get($_phone->template_id); $defaultPhoneSettingsBackend = new Voipmanager_Backend_Snom_Setting($this->_db); $defaultPhoneSettings = $defaultPhoneSettingsBackend->get($template->setting_id); $userSettings = array(); foreach ($phoneSettings as $key => $value) { if ($key == 'phone_id') { continue; } $isWritableProperty = $key . '_w'; if (!$defaultPhoneSettings->has($isWritableProperty)) { continue; } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Writable property: ' . $key); } if ($defaultPhoneSettings->{$isWritableProperty} == true && $value !== NULL) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Setting ' . $key . ' = ' . $value); } $userSettings[$key]['value'] = $value; $userSettings[$key]['perms'] = 'RW'; } else { if ($defaultPhoneSettings->{$key} !== NULL) { $userSettings[$key]['value'] = $defaultPhoneSettings->{$key}; if ($defaultPhoneSettings->{$isWritableProperty} == true) { $userSettings[$key]['perms'] = 'RW'; } else { $userSettings[$key]['perms'] = 'RO'; } } } } foreach ($userSettings as $key => $value) { $child = $_xml->addChild($key, $value['value']); $child->addAttribute('perm', $value['perms']); } }
/** * 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); } }
protected function _appendUserSettings(Voipmanager_Model_Snom_Phone $_phone, SimpleXMLElement $_xml) { $phoneSettinsgBackend = new Voipmanager_Backend_Snom_PhoneSettings($this->_db); $phoneSettings = $phoneSettinsgBackend->get($_phone->getId()); $templateBackend = new Voipmanager_Backend_Snom_Template($this->_db); $template = $templateBackend->get($_phone->template_id); $defaultPhoneSettingsBackend = new Voipmanager_Backend_Snom_Setting($this->_db); $defaultPhoneSettings = $defaultPhoneSettingsBackend->get($template->setting_id); $userSettings = array(); foreach ($phoneSettings as $key => $value) { if ($key == 'phone_id') { continue; } $isWriteAbleProperty = $key . '_writable'; if (!$defaultPhoneSettings->has($isWriteAbleProperty)) { continue; } if ($defaultPhoneSettings->{$isWriteAbleProperty} == true && $value !== NULL) { $userSettings[$key]['value'] = $value; $userSettings[$key]['perms'] = 'RW'; } elseif ($defaultPhoneSettings->{$key} !== NULL) { $userSettings[$key]['value'] = $defaultPhoneSettings->{$key}; if ($defaultPhoneSettings->{$isWriteAbleProperty} == true) { $userSettings[$key]['perms'] = 'RW'; } else { $userSettings[$key]['perms'] = 'RO'; } } } foreach ($userSettings as $key => $value) { $child = $_xml->addChild($key, $value['value']); $child->addAttribute('perm', $value['perms']); } }