public function testDeleteDevice()
 {
     $device = $this->testCreateDevice();
     $this->_deviceBackend->delete($device);
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $this->_deviceBackend->get($device);
 }
 /**
  * set filter for different ActiveSync content types
  * 
  * @param unknown_type $_deviceId
  * @param unknown_type $_class
  * @param unknown_type $_filterId
  * 
  * @return ActiveSync_Model_Device
  */
 public function setDeviceContentFilter($_deviceId, $_class, $_filterId)
 {
     $device = $this->_backend->get($_deviceId);
     if ($device->owner_id != Tinebase_Core::getUser()->getId()) {
         throw new Tinebase_Exception_AccessDenied('not owner of device ' . $_deviceId);
     }
     $filterId = empty($_filterId) ? null : $_filterId;
     switch ($_class) {
         case Syncroton_Data_Factory::CLASS_CALENDAR:
             $device->calendarfilter_id = $filterId;
             break;
         case Syncroton_Data_Factory::CLASS_CONTACTS:
             $device->contactsfilter_id = $filterId;
             break;
         case Syncroton_Data_Factory::CLASS_EMAIL:
             $device->emailfilter_id = $filterId;
             break;
         case Syncroton_Data_Factory::CLASS_TASKS:
             $device->tasksfilter_id = $filterId;
             break;
         default:
             throw new ActiveSync_Exception('unsupported class ' . $_class);
     }
     $device = $this->_backend->update($device);
     return $device;
 }
 /**
  * (non-PHPdoc)
  * @see ActiveSync/ActiveSync_TestCase::setUp()
  */
 protected function setUp()
 {
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     Syncope_Registry::setDatabase(Tinebase_Core::getDb());
     Syncope_Registry::setTransactionManager(Tinebase_TransactionManager::getInstance());
     $this->_deviceBackend = new Syncope_Backend_Device(Tinebase_Core::getDb(), SQL_TABLE_PREFIX . 'acsync_');
     $this->_folderBackend = new Syncope_Backend_Folder(Tinebase_Core::getDb(), SQL_TABLE_PREFIX . 'acsync_');
     $this->_syncStateBackend = new Syncope_Backend_SyncState(Tinebase_Core::getDb(), SQL_TABLE_PREFIX . 'acsync_');
     $this->_contentStateBackend = new Syncope_Backend_Content(Tinebase_Core::getDb(), SQL_TABLE_PREFIX . 'acsync_');
     $this->_device = $this->_deviceBackend->create(ActiveSync_Backend_DeviceTests::getTestDevice());
     Syncope_Registry::set('deviceBackend', $this->_deviceBackend);
     Syncope_Registry::set('folderStateBackend', $this->_folderBackend);
     Syncope_Registry::set('syncStateBackend', $this->_syncStateBackend);
     Syncope_Registry::set('contentStateBackend', $this->_contentStateBackend);
     Syncope_Registry::set('loggerBackend', Tinebase_Core::getLogger());
     Syncope_Registry::setContactsDataClass('ActiveSync_Controller_Contacts');
     Syncope_Registry::setCalendarDataClass('ActiveSync_Controller_Calendar');
     Syncope_Registry::setEmailDataClass('ActiveSync_Controller_Email');
     Syncope_Registry::setTasksDataClass('ActiveSync_Controller_Tasks');
 }
 /**
  * force activesync calendar resync for iOS devices
  */
 public function update_11()
 {
     if (Tinebase_Application::getInstance()->isInstalled('ActiveSync')) {
         $deviceBackend = new ActiveSync_Backend_Device();
         $usersWithiPhones = $deviceBackend->search(new ActiveSync_Model_DeviceFilter(array('devicetype' => 'iphone')))->owner_id;
         $activeSyncController = ActiveSync_Controller::getInstance();
         foreach ($usersWithiPhones as $userId) {
             try {
                 $activeSyncController->resetSyncForUser($userId, 'Calendar');
             } catch (Exception $e) {
                 Tinebase_Exception::log($e, false);
             }
         }
     }
     $this->setApplicationVersion('Calendar', '8.12');
 }
 /**
  * fetch devices for user
  * 
  * @param string $userId
  */
 protected function _getDevicesForUser($userId)
 {
     $deviceBackend = new ActiveSync_Backend_Device();
     $deviceFilter = new ActiveSync_Model_DeviceFilter(array(array('field' => 'owner_id', 'operator' => 'equals', 'value' => $userId)));
     $devices = $deviceBackend->search($deviceFilter);
     return $devices;
 }
Example #6
0
 /**
  * Returns registry data of the application.
  *
  * Each application has its own registry to supply static data to the client.
  * Registry data is queried only once per session from the client.
  *
  * This registry must not be used for rights or ACL purposes. Use the generic
  * rights and ACL mechanisms instead!
  */
 public function getRegistryData()
 {
     $deviceBackend = new ActiveSync_Backend_Device();
     $userDevices = $deviceBackend->search(new ActiveSync_Model_DeviceFilter(array(array('field' => 'owner_id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->getId()))));
     return array('userDevices' => $userDevices->toArray());
 }
Example #7
0
 /**
  * store device information
  * 
  * @param ActiveSync_Model_Device $_device
  * @return ActiveSync_Model_Device
  */
 public function createDevice(ActiveSync_Model_Device $_device)
 {
     $device = $this->_deviceBackend->create($_device);
     return $device;
 }