Example #1
0
 /**
  * @param unknown_type $_class
  * @param Syncope_Model_IDevice $_device
  * @param DateTime $_timeStamp
  * @throws InvalidArgumentException
  * @return Syncope_Data_IData
  */
 public static function factory($_classFactory, Syncope_Model_IDevice $_device, DateTime $_timeStamp)
 {
     switch ($_classFactory) {
         case self::CLASS_CALENDAR:
             $className = Syncope_Registry::get(Syncope_Registry::CALENDAR_DATA_CLASS);
             break;
         case self::CLASS_CONTACTS:
             $className = Syncope_Registry::get(Syncope_Registry::CONTACTS_DATA_CLASS);
             break;
         case self::STORE_EMAIL:
         case self::CLASS_EMAIL:
             $className = Syncope_Registry::get(Syncope_Registry::EMAIL_DATA_CLASS);
             break;
         case self::CLASS_TASKS:
             $className = Syncope_Registry::get(Syncope_Registry::TASKS_DATA_CLASS);
             break;
         default:
             throw new InvalidArgumentException('invalid class type provided');
             breeak;
     }
     $class = new $className($_device, $_timeStamp);
     if (!$class instanceof Syncope_Data_IData) {
         throw new RuntimeException('class must be instanceof Syncope_Data_IData');
     }
     return $class;
 }
Example #2
0
 public function __construct($userId, Zend_Controller_Request_Http $request = null, $body = null)
 {
     if (Syncope_Registry::isRegistered('loggerBackend')) {
         $this->_logger = Syncope_Registry::get('loggerBackend');
     }
     $this->_userId = $userId;
     $this->_request = $request !== null ? $request : new Zend_Controller_Request_Http();
     $this->_body = $body !== null ? $body : fopen('php://input', 'r');
     $this->_deviceBackend = Syncope_Registry::get('deviceBackend');
 }
 /**
  * constructor
  */
 private function __construct()
 {
     if (Syncope_Registry::isRegistered('loggerBackend')) {
         $this->_logger = Syncope_Registry::get('loggerBackend');
     }
 }
Example #4
0
 /**
  * the constructor
  *
  * @param  mixed                    $_requestBody
  * @param  Syncope_Model_Device  $_device
  * @param  string                   $_policyKey
  */
 public function __construct($_requestBody, Syncope_Model_IDevice $_device, $_policyKey)
 {
     $this->_policyKey = $_policyKey;
     $this->_device = $_device;
     $this->_deviceBackend = Syncope_Registry::get('deviceBackend');
     $this->_folderBackend = Syncope_Registry::get('folderStateBackend');
     $this->_syncStateBackend = Syncope_Registry::get('syncStateBackend');
     $this->_contentStateBackend = Syncope_Registry::get('contentStateBackend');
     if (Syncope_Registry::isRegistered('loggerBackend')) {
         $this->_logger = Syncope_Registry::get('loggerBackend');
     }
     if ($this->_skipValidatePolicyKey !== true && $this->_policyKey === null) {
         #throw new Syncope_Exception_PolicyKeyMissing();
     }
     if ($this->_skipValidatePolicyKey !== true && ($this->_policyKey === 0 || $this->_device->policykey != $this->_policyKey)) {
         #throw new Syncope_Exception_ProvisioningNeeded();
     }
     // should we wipe the mobile phone?
     if ($this->_skipValidatePolicyKey !== true && !empty($this->_policyKey) && $this->_device->remotewipe >= Syncope_Command_Provision::REMOTEWIPE_REQUESTED) {
         throw new Syncope_Exception_ProvisioningNeeded();
     }
     $this->_inputDom = $_requestBody;
     $this->_syncTimeStamp = new DateTime(null, new DateTimeZone('UTC'));
     if ($this->_logger instanceof Zend_Log) {
         $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " sync timestamp: " . $this->_syncTimeStamp->format('Y-m-d H:i:s'));
     }
     // Creates an instance of the DOMImplementation class
     $imp = new DOMImplementation();
     // Creates a DOMDocumentType instance
     $dtd = $imp->createDocumentType('AirSync', "-//AIRSYNC//DTD AirSync//EN", "http://www.microsoft.com/");
     // Creates a DOMDocument instance
     $this->_outputDom = $imp->createDocument($this->_defaultNameSpace, $this->_documentElement, $dtd);
     $this->_outputDom->formatOutput = false;
     $this->_outputDom->encoding = 'utf-8';
 }