/**
  * initiate new call
  *
  * http://www.voip-info.org/wiki/index.php?page=Asterisk+Manager+API+Action+Originate
  * 
  * @param string $_channel
  * @param string $_context
  * @param string $_exten
  * @param int $_priority
  * @param string $_callerId
  */
 public function dialNumber($_channel, $_context, $_exten, $_priority, $_callerId = "Ajam Service")
 {
     $this->_ajam->login($this->_username, $this->_password);
     $this->_ajam->originate($_channel, $_context, $_exten, $_priority, $_callerId);
     $this->_ajam->logout();
 }
 /**
  * create sip.conf and upload to asterisk server
  * 
  * @return void
  */
 public static function publishConfiguration()
 {
     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('No settings found for asterisk backend in config file!');
     }
     /*
     $filter = new Voipmanager_Model_Asterisk_SipPeerFilter(array());
     
     $sipPeers = $controller = Voipmanager_Controller_Asterisk_SipPeer::getInstance()->search($filter);
     
     $fieldsToSkip = array('id', 'name', 'fullcontact', 'username');
     
     $fp = fopen("php://temp", 'r+');
     foreach($sipPeers as $sipPeer) {
         fputs($fp, "[" . $sipPeer->name . "]\n");
         foreach($sipPeer as $key => $value) {
             if(empty($value) || in_array($key, $fieldsToSkip)) {
                 continue;
             }
             fputs($fp, " $key = $value\n");
         }
         fputs($fp, "\n");
     }
     rewind($fp);
     */
     try {
         $ajam = new Ajam_Connection($url);
         $ajam->login($username, $password);
         #$ajam->upload($url . '/tine20config', 'sip.conf', stream_get_contents($fp));
         $ajam->command('sip reload');
         $ajam->logout();
     } catch (Exception $e) {
         throw new Tinebase_Exception_Backend($e->getMessage());
     }
 }
Пример #3
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();
 }