/** * Create a new Contact object * * @param AddressBook $parent * @param Backend\AbstractBackend $backend * @param mixed $data */ public function __construct($parent, $backend, $data = null) { parent::__construct('VCARD'); self::$l10n = $parent::$l10n; //\OCP\Util::writeLog('contacts', __METHOD__ . ' , data: ' . print_r($data, true), \OCP\Util::DEBUG); $this->props['parent'] = $parent; $this->props['backend'] = $backend; $this->props['retrieved'] = false; $this->props['saved'] = false; if (!is_null($data)) { if ($data instanceof VObject\VCard) { foreach ($data->children as $child) { $this->add($child); } $this->setRetrieved(true); } elseif (is_array($data)) { foreach ($data as $key => $value) { switch ($key) { case 'id': $this->props['id'] = $value; break; case 'permissions': $this->props['permissions'] = $value; break; case 'lastmodified': $this->props['lastmodified'] = $value; break; case 'uri': $this->props['uri'] = $value; break; case 'carddata': $this->props['carddata'] = $value; $this->retrieve(); break; case 'vcard': $this->props['vcard'] = $value; $this->retrieve(); break; case 'displayname': case 'fullname': if (is_string($value)) { $this->props['displayname'] = $value; $this->FN = $value; // Set it to saved again as we're not actually changing anything $this->setSaved(); } break; } } } } }