/** * the singleton pattern * * @return Voipmanager_Controller_Snom_Line */ public static function getInstance() { if (self::$_instance === NULL) { self::$_instance = new Voipmanager_Controller_Snom_Line(); } return self::$_instance; }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->_backends['Asterisk_Context'] = Voipmanager_Controller_Asterisk_Context::getInstance(); $this->_backends['Asterisk_Meetme'] = Voipmanager_Controller_Asterisk_Meetme::getInstance(); $this->_backends['Asterisk_SipPeer'] = Voipmanager_Controller_Asterisk_SipPeer::getInstance(); $this->_backends['Asterisk_Voicemail'] = Voipmanager_Controller_Asterisk_Voicemail::getInstance(); $this->_backends['Snom_Line'] = Voipmanager_Controller_Snom_Line::getInstance(); $this->_backends['Snom_Location'] = Voipmanager_Controller_Snom_Location::getInstance(); $this->_backends['Snom_Phone'] = Voipmanager_Controller_Snom_Phone::getInstance(); $this->_backends['Snom_Setting'] = Voipmanager_Controller_Snom_Setting::getInstance(); $this->_backends['Snom_Software'] = Voipmanager_Controller_Snom_Software::getInstance(); $this->_backends['Snom_Template'] = Voipmanager_Controller_Snom_Template::getInstance(); }
/** * Returns registry data of the phone application. * @see Tinebase_Application_Json_Abstract * * @return mixed array 'variable name' => 'data' */ public function getRegistryData() { // get user phones $filter = new Voipmanager_Model_Snom_PhoneFilter(array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->getId()))); $phones = Phone_Controller_MyPhone::getInstance()->search($filter); foreach ($phones as $phone) { $filter = new Voipmanager_Model_Snom_LineFilter(array(array('field' => 'snomphone_id', 'operator' => 'equals', 'value' => $phone->id))); $phone->lines = Voipmanager_Controller_Snom_Line::getInstance()->search($filter); } $registryData = array('Phones' => $phones->toArray()); return $registryData; }
/** * 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); } }