Esempio n. 1
0
 /**
  * the singleton pattern
  *
  * @return Phone_Controller_MyPhone
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new Phone_Controller_MyPhone();
     }
     return self::$_instance;
 }
 /**
  * the singleton pattern
  *
  * @return Phone_Controller_MyPhone
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Esempio n. 3
0
 /**
  * check user phones (add user phone ids to filter
  *
  * @param Zend_Db_Select $_select
  */
 protected function _appendAclSqlFilter($_select)
 {
     if (!$this->_isResolved) {
         //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($this->toArray(), true));
         $phoneIdFilter = $this->_findFilter('phone_id');
         // set user phone ids as filter
         $filter = new Voipmanager_Model_Snom_PhoneFilter(array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->getId())));
         $userPhoneIds = Phone_Controller_MyPhone::getInstance()->search($filter)->getArrayOfIds();
         if ($phoneIdFilter === NULL) {
             $phoneIdFilter = $this->createFilter('phone_id', 'in', $userPhoneIds);
             $this->addFilter($phoneIdFilter);
         } else {
             $phoneIdFilter->setValue(array_intersect((array) $phoneIdFilter->getValue(), $userPhoneIds));
         }
         $this->_isResolved = TRUE;
     }
 }
 /**
  * create edit MyPhone dialog
  *
  * @param int $phoneId
  * 
  * @todo remove that when new myphone edit dialog is working
  * @deprecated
  */
 public function editMyPhone($phoneId = NULL)
 {
     $currentAccount = Tinebase_Core::getUser()->toArray();
     if (!empty($phoneId)) {
         $snomPhone = Phone_Controller_MyPhone::getInstance()->get($phoneId);
         //unset($phone->lines);
         $_phoneData = $snomPhone->toArray();
         $_phoneSettingsData = Voipmanager_Controller_Snom_PhoneSettings::getInstance()->get($_phoneData['id'])->toArray();
         $_templateData = Voipmanager_Controller_Snom_Template::getInstance()->get($_phoneData['template_id'])->toArray();
         $_settingsData = Voipmanager_Controller_Snom_Setting::getInstance()->get($_templateData['setting_id'])->toArray();
         $_writableFields = array('web_language', 'language', 'display_method', 'mwi_notification', 'mwi_dialtone', 'headset_device', 'message_led_other', 'global_missed_counter', 'scroll_outgoing', 'show_local_line', 'show_call_status', 'call_waiting');
         foreach ($_writableFields as $wField) {
             $_fieldRW = $wField . '_writable';
             if ($_settingsData[$_fieldRW] == '0') {
                 $_phoneSettingsData[$wField] = $_settingsData[$wField];
                 $_notWritable[$wField] = 'true';
             } else {
                 if ($_phoneSettingsData[$wField] === NULL) {
                     $_phoneSettingsData[$wField] = $_settingsData[$wField];
                 }
                 $_notWritable[$wField] = '';
             }
         }
         $encodedWritable = Zend_Json::encode($_notWritable);
         $_phoneData = array_merge($_phoneSettingsData, $_phoneData);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_phoneData, true));
         }
         // encode the data arrays
         $encodedSnomPhone = Zend_Json::encode($_phoneData);
     } else {
         //$phone = new Voipmanager_Model_Snom_Phone();
         //$lines = new Tinebase_Record_RecordSet('Voipmanager_Model_Snom_Line');
         $encodedWritable = '{}';
         $encodedSnomPhone = '{}';
         //$encodedSettings = '{}';
     }
     $view = new Zend_View();
     $view->setScriptPath('Tinebase/views');
     $view->title = "edit myPhone data";
     $view->jsExecute = 'Tine.Voipmanager.MyPhones.EditDialog.display(' . $encodedSnomPhone . ', ' . $encodedWritable . ');';
     header('Content-Type: text/html; charset=utf-8');
     echo $view->render('jsclient.php');
 }
 /**
  * appends custom filters to a given select object
  * 
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  * @return void
  */
 public function appendFilterSql($_select, $_backend)
 {
     if ($this->getId() == 'OuterFilter' && !$this->_ignoreAcl) {
         $phoneIdFilter = $this->_findFilter('phone_id');
         // set user phone ids as filter
         $filter = new Voipmanager_Model_Snom_PhoneFilter(array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->getId())));
         $userPhoneIds = Phone_Controller_MyPhone::getInstance()->search($filter)->getId();
         if ($phoneIdFilter === NULL) {
             $this->addFilter($this->_getDefaultPhoneFilter($userPhoneIds));
         } else {
             $phoneId = $phoneIdFilter->getValue();
             $phoneId = $phoneId[0]['value'];
             if (!in_array($phoneId, $userPhoneIds)) {
                 $this->removeFilter('phone_id');
                 $this->addFilter(new Tinebase_Model_Filter_Text(array('id' => 'defaultAdded', 'field' => 'id', 'operator' => 'equals', 'value' => 'notexists')));
             }
         }
     }
 }
 /**
  * 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}");
     }
 }
 /**
  * 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;
 }