/**
  * Returns an array with all the child nodes
  *
  * @param int $limit
  * @param int $offset
  * @param bool $omitdata
  * @return Contact[]
  */
 public function getChildren($limit = null, $offset = null, $omitdata = false)
 {
     if (!$this->hasPermission(\OCP\PERMISSION_READ)) {
         throw new \Exception(self::$l10n->t('You do not have permissions to see these contacts'), Http::STATUS_FORBIDDEN);
     }
     $contacts = array();
     $options = array('limit' => $limit, 'offset' => $offset, 'omitdata' => $omitdata);
     foreach ($this->backend->getContacts($this->getId(), $options) as $contact) {
         //\OCP\Util::writeLog('contacts', __METHOD__.' id: '.$contact['id'], \OCP\Util::DEBUG);
         if (!isset($this->objects[$contact['id']])) {
             $this->objects[$contact['id']] = new Contact($this, $this->backend, $contact);
         }
         $contacts[] = $this->objects[$contact['id']];
     }
     //\OCP\Util::writeLog('contacts', __METHOD__.' children: '.count($contacts), \OCP\Util::DEBUG);
     return $contacts;
 }
Esempio n. 2
0
 public function testDeleteContact()
 {
     $this->assertTrue($this->backend->deleteContact('foo', '123'));
     $this->assertEquals(array(), $this->backend->getContacts('foo'));
 }