Example #1
0
 /**
  * The getChanges method returns all the changes that have happened, since
  * the specified syncToken and the current collection.
  *
  * This function should return an array, such as the following:
  *
  * [
  *   'syncToken' => 'The current synctoken',
  *   'added'   => [
  *      'new.txt',
  *   ],
  *   'modified'   => [
  *      'modified.txt',
  *   ],
  *   'deleted' => [
  *      'foo.php.bak',
  *      'old.txt'
  *   ]
  * ];
  *
  * The syncToken property should reflect the *current* syncToken of the
  * collection, as reported getSyncToken(). This is needed here too, to
  * ensure the operation is atomic.
  *
  * If the syncToken is specified as null, this is an initial sync, and all
  * members should be reported.
  *
  * The modified property is an array of nodenames that have changed since
  * the last token.
  *
  * The deleted property is an array with nodenames, that have been deleted
  * from collection.
  *
  * The second argument is basically the 'depth' of the report. If it's 1,
  * you only have to report changes that happened only directly in immediate
  * descendants. If it's 2, it should also include changes from the nodes
  * below the child collections. (grandchildren)
  *
  * The third (optional) argument allows a client to specify how many
  * results should be returned at most. If the limit is not specified, it
  * should be treated as infinite.
  *
  * If the limit (infinite or not) is higher than you're willing to return,
  * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
  *
  * If the syncToken is expired (due to data cleanup) or unknown, you must
  * return null.
  *
  * The limit is 'suggestive'. You are free to ignore it.
  *
  * @param string $syncToken
  * @param int $syncLevel
  * @param int $limit
  * @return array
  */
 function getChanges($syncToken, $syncLevel, $limit = null)
 {
     if (!$this->carddavBackend instanceof Backend\SyncSupport) {
         return null;
     }
     return $this->carddavBackend->getChangesForAddressBook($this->addressBookInfo['id'], $syncToken, $syncLevel, $limit);
 }
 /**
  * Creates a new addressbook
  *
  * @param string $name
  * @param array $resourceType
  * @param array $properties
  * @return void
  */
 public function createExtendedCollection($name, array $resourceType, array $properties)
 {
     if (!in_array('{' . Plugin::NS_CARDDAV . '}addressbook', $resourceType) || count($resourceType) !== 2) {
         throw new DAV\Exception\InvalidResourceType('Unknown resourceType for this collection');
     }
     $this->carddavBackend->createAddressBook($this->principalUri, $name, $properties);
 }
Example #3
0
 /**
  * Creates a new address book.
  *
  * @param string $name
  * @param MkCol $mkCol
  * @throws DAV\Exception\InvalidResourceType
  * @return void
  */
 function createExtendedCollection($name, MkCol $mkCol)
 {
     if (!$mkCol->hasResourceType('{' . Plugin::NS_CARDDAV . '}addressbook')) {
         throw new DAV\Exception\InvalidResourceType('Unknown resourceType for this collection');
     }
     $properties = $mkCol->getRemainingValues();
     $mkCol->setRemainingResultCode(201);
     $this->carddavBackend->createAddressBook($this->principalUri, $name, $properties);
 }
Example #4
0
 /**
  * Main processing method.
  * Fetches all foaf persons from RDF store, creates ContactInformation objects out of them and converts them to
  * vcards. The vcards will be stored in the CardDAV backend and printed.
  *
  * @throws \Erfurt_Store_Exception if something goes wrong
  */
 public function convert()
 {
     $query = 'PREFIX ' . $this->vocabularies['foaf']->name . ': <' . $this->vocabularies['foaf']->prefix . '> ' . 'SELECT ?person ' . 'WHERE { ' . '?person a ' . $this->vocabularies['foaf']->name . ':' . $this->vocabularies['foaf']->entityName . ' . ' . '}';
     $result = $this->getStore()->sparqlQuery($query);
     foreach ($result as $person) {
         $name_arr = explode('/', $person['person']);
         $name = $name_arr[count($name_arr) - 1] . '.vcf';
         $vcard = $this->contactToVCard($this->createContact($person['person'], $this->vocabularies['foaf']))->serialize();
         $this->cardDav->createCard(1, $name, $vcard);
         echo $vcard . "\n";
     }
 }
Example #5
0
 /**
  * Deletes the card
  *
  * @return void
  */
 public function delete()
 {
     $this->carddavBackend->deleteCard($this->addressBookInfo['id'], $this->cardData['uri']);
 }
Example #6
0
 /**
  * Updates properties on this node,
  *
  * The properties array uses the propertyName in clark-notation as key,
  * and the array value for the property value. In the case a property
  * should be deleted, the property value will be null.
  *
  * This method must be atomic. If one property cannot be changed, the
  * entire operation must fail.
  *
  * If the operation was successful, true can be returned.
  * If the operation failed, false can be returned.
  *
  * Deletion of a non-existent property is always successful.
  *
  * Lastly, it is optional to return detailed information about any
  * failures. In this case an array should be returned with the following
  * structure:
  *
  * array(
  *   403 => array(
  *      '{DAV:}displayname' => null,
  *   ),
  *   424 => array(
  *      '{DAV:}owner' => null,
  *   )
  * )
  *
  * In this example it was forbidden to update {DAV:}displayname.
  * (403 Forbidden), which in turn also caused {DAV:}owner to fail
  * (424 Failed Dependency) because the request needs to be atomic.
  *
  * @param array $mutations
  * @return bool|array
  */
 public function updateProperties($mutations)
 {
     return $this->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $mutations);
 }