コード例 #1
0
 /**
  * test xml generation for IPhone
  */
 public function testRemoteWipeStep2()
 {
     $this->testRemoteWipeStep1();
     $doc = new DOMDocument();
     $doc->loadXML('<?xml version="1.0" encoding="utf-8"?>
         <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
         <Provision xmlns="uri:Provision"><RemoteWipe><Status>1</Status></RemoteWipe></Provision>');
     $provision = new Syncope_Command_Provision($doc, $this->objects['device'], $this->objects['device']->policykey);
     $provision->handle();
     $responseDoc = $provision->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $this->objects['device'] = ActiveSync_Controller_Device::getInstance()->get($this->objects['device']);
     $this->assertEquals(Syncope_Command_Provision::REMOTEWIPE_CONFIRMED, $this->objects['device']->remotewipe);
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('Provision', 'uri:Provision');
     $nodes = $xpath->query('//Provision:Provision/Provision:Status');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(Syncope_Command_FolderSync::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//Provision:Provision/Provision:RemoteWipe');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
 }
コード例 #2
0
 /**
  * get user device
  *
  * @param string $_deviceId
  * @param string $_deviceType
  * @param string $_userAgent
  * @param string $_acsVersion
  * @return ActiveSync_Model_Device
  */
 public function getUserDevice($_deviceId, $_deviceType, $_userAgent, $_acsVersion)
 {
     $deviceFilter = new ActiveSync_Model_DeviceFilter(array(array('field' => 'deviceid', 'operator' => 'equals', 'value' => $_deviceId), array('field' => 'owner_id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->accountId)));
     $devices = $this->searchDevice($deviceFilter);
     if (count($devices) > 0) {
         // update existing device
         $device = $devices[0];
         $device->useragent = $_userAgent;
         $device->acsversion = $_acsVersion;
         $device->devicetype = $_deviceType;
         $device = $this->updateDevice($device);
     } else {
         // create new device
         $device = new ActiveSync_Model_Device(array('deviceid' => $_deviceId, 'devicetype' => $_deviceType, 'owner_id' => Tinebase_Core::getUser()->accountId, 'policy_id' => 1, 'useragent' => $_userAgent, 'acsversion' => $_acsVersion, 'policykey' => Syncope_Command_Provision::generatePolicyKey()));
         $device = $this->createDevice($device);
     }
     return $device;
 }