예제 #1
0
 /**
  * the singleton pattern
  *
  * @return Sipgate_Controller
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new Sipgate_Controller();
     }
     return self::$_instance;
 }
예제 #2
0
 /**
  * get preference defaults if no default is found in the database
  *
  * @param string $_preferenceName
  * @param string|Tinebase_Model_User $_accountId
  * @param string $_accountType
  * @return Tinebase_Model_Preference
  */
 public function getApplicationPreferenceDefaults($_preferenceName, $_accountId = NULL, $_accountType = Tinebase_Acl_Rights::ACCOUNT_TYPE_USER)
 {
     switch ($_preferenceName) {
         case self::PHONEID:
             $dev = array();
             try {
                 $_phones = Sipgate_Controller::getInstance()->getPhoneDevices();
                 foreach ($_phones as $phone) {
                     $dev[] = $phone['SipUri'];
                 }
             } catch (Sipgate_Exception_Backend $seb) {
                 Tinebase_Core::getLogger()->warn(__METHOD__ . ' (' . __LINE__ . ') Could not get Sipgate phone devices: ' . $seb->getMessage());
             } catch (Zend_Exception $ze) {
                 Tinebase_Core::getLogger()->warn(__METHOD__ . ' (' . __LINE__ . ') Could not connect to sipgate: ' . $ze->getMessage());
             }
             $pref = $this->getOptions($_preferenceName, $dev);
             break;
         case self::FAXID:
             $dev = array();
             try {
                 $_faxes = Sipgate_Controller::getInstance()->getFaxDevices();
                 if (is_array($_faxes)) {
                     foreach ($_faxes as $fax) {
                         $dev[] = $fax['SipUri'];
                     }
                 }
             } catch (Sipgate_Exception_Backend $seb) {
                 Tinebase_Core::getLogger()->warn(__METHOD__ . ' (' . __LINE__ . ') Could not get Sipgate fax devices: ' . $seb->getMessage());
             } catch (Zend_Exception $ze) {
                 Tinebase_Core::getLogger()->warn(__METHOD__ . ' (' . __LINE__ . ') Could not connect to sipgate: ' . $ze->getMessage());
             }
             $pref = $this->getOptions($_preferenceName, $dev);
             break;
         case self::MOBILENUMBER:
             $config = Tinebase_Core::getConfig()->sipgate;
             if ($config && $config->numbers && $config->numbers->mobile) {
                 $pref = $this->getOptions($_preferenceName, $config->numbers->mobile);
             } else {
                 $pref = $this->_getDefaultBasePreference($_preferenceName);
             }
             break;
         default:
             throw new Tinebase_Exception_NotFound('Default preference with name ' . $_preferenceName . ' not found.');
     }
     return $pref;
 }
예제 #3
0
 /**
  * Returns registry data
  *
  * @return mixed array 'variable name' => 'data'
  */
 public function getRegistryData()
 {
     try {
         $phoneId = Tinebase_Core::getPreference($this->_applicationName)->getValue(Sipgate_Preference::PHONEID);
         $faxId = Tinebase_Core::getPreference($this->_applicationName)->getValue(Sipgate_Preference::FAXID);
         $mobileNumber = Tinebase_Core::getPreference($this->_applicationName)->getValue(Sipgate_Preference::MOBILENUMBER);
         $devices = Sipgate_Controller::getInstance()->getAllDevices();
     } catch (Sipgate_Exception_Backend $seb) {
         Tinebase_Core::getLogger()->warn(__METHOD__ . ' (' . __LINE__ . ') Could not get Sipgate registry data: ' . $seb->getMessage());
         return array();
     } catch (Zend_Exception $ze) {
         Tinebase_Core::getLogger()->warn(__METHOD__ . ' (' . __LINE__ . ') Could not connect to sipgate: ' . $ze->getMessage());
         return array();
     }
     return array('phoneId' => $phoneId, 'faxId' => $faxId, 'mobileNumber' => $mobileNumber, 'Devices' => $devices);
 }