コード例 #1
0
 /**
  * get snom_phone_line by id
  *
  * @param string $_id the id of the line
  * @return Voipmanager_Model_Snom_Line
  */
 public function get($_id)
 {
     $id = Voipmanager_Model_Snom_Line::convertSnomLineIdToInt($_id);
     if (($result = $this->_cache->load('snomPhoneLine_' . $id)) === false) {
         $result = $this->_backend->get($id);
         $this->_cache->save($result, 'snomPhoneLine_' . $id, array('snomPhoneLine'), 5);
     }
     return $result;
 }
コード例 #2
0
 /**
  * #8380: write a test for saveMyPhone as unprivileged user
  * https://forge.tine20.org/mantisbt/view.php?id=8380
  */
 public function testSaveMyPhoneAsUnprivilegedUser()
 {
     // first save the phone as privileged user
     $userPhone = $this->_json->getMyPhone($this->_objects['phone']->getId());
     $userPhone['lines'][0]['asteriskline_id']['cfi_mode'] = "number";
     $userPhone['lines'][0]['asteriskline_id']['cfi_number'] = "+494949302111";
     // try to set a property which should be overwritten again
     $userPhone['description'] = 'no phone';
     $phone = $this->_json->saveMyPhone($userPhone);
     $this->assertEquals('number', $phone['lines'][0]['asteriskline_id']['cfi_mode']);
     $this->assertEquals('+494949302111', $phone['lines'][0]['asteriskline_id']['cfi_number']);
     $this->assertEquals('user phone', $phone['description']);
     $additionalLine = array('id' => Tinebase_Record_Abstract::generateUID(), 'snomphone_id' => $this->_objects['phone']->getId(), 'asteriskline_id' => $this->_objects['sippeer']->getId(), 'linenumber' => 2, 'lineactive' => 2);
     // use another user which doesn't have access to the phone
     Tinebase_Core::set(Tinebase_Core::USER, Tinebase_User::getInstance()->getFullUserByLoginName('pwulf'));
     $e = new Exception('No Exception has been thrown!');
     try {
         $this->_json->saveMyPhone($userPhone);
     } catch (Exception $e) {
     }
     $this->assertEquals('Tinebase_Exception_AccessDenied', get_class($e));
     // try to save with a line removed
     Tinebase_Core::set(Tinebase_Core::USER, $this->_adminUser);
     $snomLineBackend = new Voipmanager_Backend_Snom_Line();
     $snomLineBackend->create(new Voipmanager_Model_Snom_Line($additionalLine));
     $userPhone = $this->_json->getMyPhone($this->_objects['phone']->getId());
     unset($userPhone['lines'][1]);
     $this->setExpectedException('Tinebase_Exception_AccessDenied');
     $this->_json->saveMyPhone($userPhone);
 }
コード例 #3
0
 /**
  * Tears down the fixture
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     // remove phone, location, template
     $phoneBackend = new Voipmanager_Backend_Snom_Phone();
     $snomLocationBackend = new Voipmanager_Backend_Snom_Location();
     $snomTemplateBackend = new Voipmanager_Backend_Snom_Template();
     $snomSoftwareBackend = new Voipmanager_Backend_Snom_Software();
     $snomSettingBackend = new Voipmanager_Backend_Snom_Setting();
     $snomLineBackend = new Voipmanager_Backend_Snom_Line();
     $asteriskSipPeerBackend = new Voipmanager_Backend_Asterisk_SipPeer();
     $callHistoryBackend = Phone_Backend_Factory::factory(Phone_Backend_Factory::CALLHISTORY);
     $snomPhoneSettingBackend = new Voipmanager_Backend_Snom_PhoneSettings();
     $snomPhoneSettingBackend->delete($this->_objects['phone']->getId());
     $phoneBackend->delete($this->_objects['phone']->getId());
     $snomLocationBackend->delete($this->_objects['location']->getId());
     $snomTemplateBackend->delete($this->_objects['template']->getId());
     $snomSoftwareBackend->delete($this->_objects['software']->getId());
     $snomSettingBackend->delete($this->_objects['setting']->getId());
     $snomLineBackend->delete($this->_objects['line']->getId());
     $asteriskSipPeerBackend->delete($this->_objects['sippeer']->getId());
     $callHistoryBackend->delete($this->_objects['call1']->getId());
     $callHistoryBackend->delete($this->_objects['call2']->getId());
 }