/**
  * 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();
 }
 /**
  * dial number
  *
  * @param   int $_number
  * @param   string $_phoneId
  * @param   string $_lineId
  * @throws  Phone_Exception_NotFound
  * 
  * @todo check dial right here
  * @todo move to MyPhone controller
  */
 public function dialNumber($_number, $_phoneId = NULL, $_lineId = NULL)
 {
     $accountId = Tinebase_Core::getUser()->getId();
     $vmController = Voipmanager_Controller_Snom_Phone::getInstance();
     $backend = Phone_Backend_Factory::factory($this->_callBackendType);
     $number = $this->_cleanNumber($_number);
     if ($_phoneId === NULL && $_lineId === NULL) {
         // use first phone and first line
         $filter = new Voipmanager_Model_Snom_PhoneFilter(array(array('field' => 'account_id', 'operator' => 'equals', 'value' => $accountId)));
         $phones = $vmController->search($filter);
         if (count($phones) > 0) {
             $phone = $vmController->get($phones[0]->id);
             if ($this->_callBackendType === Phone_Backend_Factory::ASTERISK) {
                 if (count($phone->lines) > 0) {
                     $asteriskLineId = $phone->lines[0]->asteriskline_id;
                 } else {
                     throw new Phone_Exception_NotFound('No line found for this phone.');
                 }
             }
         } else {
             throw new Phone_Exception_NotFound('No phones found.');
         }
     } else {
         // use given phone and line ids
         $phone = Phone_Controller_MyPhone::getInstance()->get($_phoneId);
         if ($this->_callBackendType === Phone_Backend_Factory::ASTERISK) {
             $line = $phone->lines[$phone->lines->getIndexById($_lineId)];
             $asteriskLineId = $line->asteriskline_id;
         }
     }
     if ($this->_callBackendType === Phone_Backend_Factory::SNOM_WEBSERVER) {
         $filter = new Voipmanager_Model_Snom_PhoneFilter(array(array('field' => 'account_id', 'operator' => 'equals', 'value' => $accountId)));
         foreach ($vmController->search($filter) as $p) {
             if ($p->id == $phone->id) {
                 // @todo http_user / http_pass
                 $backend->dialNumber($p->ipaddress, $number, null, null);
                 break;
             }
         }
     } else {
         $asteriskLine = Voipmanager_Controller_Asterisk_SipPeer::getInstance()->get($asteriskLineId);
         $asteriskContext = Voipmanager_Controller_Asterisk_Context::getInstance()->get($asteriskLine->context_id);
         $backend->dialNumber('SIP/' . $asteriskLine->name, $asteriskContext->name, $number, 1, "WD {$number}");
     }
 }
 /**
  * get asterisk SipPeer data
  *
  * @return Voipmanager_Model_Asterisk_SipPeer
  */
 protected function _getAsteriskSipPeer()
 {
     // create context
     $context = $this->_getAsteriskContext();
     $context = Voipmanager_Controller_Asterisk_Context::getInstance()->create($context);
     return new Voipmanager_Model_Asterisk_SipPeer(array('name' => Tinebase_Record_Abstract::generateUID(), 'context' => $context['name'], 'context_id' => $context['id']), TRUE);
 }
Exemple #4
0
 /**
  * delete multiple contexts
  *
  * @param  array $ids list of contextId's to delete
  * @return array
  */
 public function deleteAsteriskContexts($ids)
 {
     return $this->_delete($ids, Voipmanager_Controller_Asterisk_Context::getInstance());
 }
Exemple #5
0
 /**
  * create voicemail.conf and upload to asterisk server
  * 
  * @return void
  */
 public static function publishConfiguration()
 {
     Zend_Registry::get('logger')->debug(__METHOD__ . '::' . __LINE__ . ' publish voicemail configuration');
     if (isset(Tinebase_Core::getConfig()->asterisk)) {
         $asteriskConfig = Tinebase_Core::getConfig()->asterisk;
         $url = $asteriskConfig->managerbaseurl;
         $username = $asteriskConfig->managerusername;
         $password = $asteriskConfig->managerpassword;
     } else {
         throw new Voipmanager_Exception_NotFound('can\'t publish configuration. No settings found for asterisk backend in config file!');
     }
     $filter = new Voipmanager_Model_Asterisk_ContextFilter();
     $contexts = Voipmanager_Controller_Asterisk_Context::getInstance()->search($filter);
     $fp = fopen("php://temp", 'r+');
     foreach ($contexts as $context) {
         $filter = new Voipmanager_Model_Asterisk_VoicemailFilter(array(array('field' => 'context_id', 'operator' => 'equals', 'value' => $context->getId())));
         $voicemails = Voipmanager_Controller_Asterisk_Voicemail::getInstance()->search($filter);
         if (count($voicemails) == 0) {
             continue;
         }
         fputs($fp, "[" . $context->name . "]\n");
         foreach ($voicemails as $voicemail) {
             fputs($fp, sprintf("%s = %s,%s,%s\n", $voicemail->mailbox, $voicemail->password, $voicemail->fullname, $voicemail->email));
         }
         fputs($fp, "\n");
     }
     rewind($fp);
     $ajam = new Ajam_Connection($url);
     $ajam->login($username, $password);
     $ajam->upload($url . '/tine20config', 'voicemail.conf', stream_get_contents($fp));
     $ajam->command('voicemail reload');
     $ajam->logout();
 }
 /**
  * create edit asterisk context dialog
  *
  * @param int $lineId
  * 
  */
 public function editAsteriskVoicemail($voicemailId = NULL)
 {
     if (!empty($voicemailId)) {
         $voicemail = Voipmanager_Controller_Asterisk_Voicemail::getInstance()->get($voicemailId);
         $encodedVoicemail = Zend_Json::encode($voicemail->toArray());
     } else {
         $encodedVoicemail = '{}';
     }
     $encodedContexts = Zend_Json::encode(Voipmanager_Controller_Asterisk_Context::getInstance()->search()->toArray());
     $view = new Zend_View();
     $view->setScriptPath('Tinebase/views');
     $view->title = "edit asterisk voicemail data";
     $view->jsExecute = 'Tine.Voipmanager.Asterisk.Voicemail.EditDialog.display(' . $encodedVoicemail . ',' . $encodedContexts . ');';
     header('Content-Type: text/html; charset=utf-8');
     echo $view->render('jsclient.php');
 }