/** * Replaces the x-prop_name value. Replaces the prop_name value IF the old value is the same as the old value of x-prop_name (meaning: the user has not manually changed it) * * @param Sabre\VObject\Component $component * @param string $prop_name * @param string $prop_value * @param array $parameters * @return void */ public static function card_set_automatic_value(&$component, $prop_name, $prop_value, $parameters = array()) { $automatic = $component->select("X-" . $prop_name); $curr = $component->select($prop_name); if (count($automatic) == 0) { $prop = new Sabre\VObject\Property('X-' . $prop_name, $prop_value); foreach ($parameters as $key => $val) { $prop->add($key, $val); } $component->children[] = $prop; if (count($curr) == 0) { $prop = new Sabre\VObject\Property($prop_name, $prop_value); foreach ($parameters as $key => $val) { $prop->add($key, $val); } $component->children[] = $prop; } } else { foreach ($automatic as $auto_prop) { /** @var Sabre\VObject\Property $auto_prop */ /** @var Sabre\VObject\Property $actual_prop */ foreach ($curr as $actual_prop) { if ($auto_prop->value == $actual_prop->value) { $actual_prop->setValue($prop_value); } } $auto_prop->setValue($prop_value); } } }
/** * parse categories from Tine20 model to VCard and attach it to VCard $card * * @param Tinebase_Record_Abstract $record * @param Sabre\VObject\Component $card */ protected function _fromTine20ModelAddCategories(Tinebase_Record_Abstract $record, Sabre\VObject\Component $card) { if (!isset($record->tags)) { // If the record has not been populated yet with tags, let's try to get them all and update the record $record->tags = Tinebase_Tags::getInstance()->getTagsOfRecord($record); } if (isset($record->tags) && count($record->tags) > 0) { // we have some tags attached, so let's convert them and attach to the VCARD $card->add('CATEGORIES', (array) $record->tags->name); } }
// Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); require_once __DIR__ . '/../loghandler.php'; $aid = isset($_POST['aid']) ? $_POST['aid'] : null; if (!$aid) { $addressbooks = OCA\Contacts\Addressbook::all(OCP\User::getUser(), true, false); if (count($addressbooks) === 0) { bailOut(OCA\Contacts\App::$l10n->t('You have no addressbooks.')); } else { $aid = $addressbooks[0]['id']; } } $isnew = isset($_POST['isnew']) ? $_POST['isnew'] : false; $vcard = Sabre\VObject\Component::create('VCARD'); $uid = substr(md5(rand() . time()), 0, 10); $vcard->add('UID', $uid); $id = null; try { $id = OCA\Contacts\VCard::add($aid, $vcard, null, $isnew); } catch (Exception $e) { bailOut($e->getMessage()); } if (!$id) { bailOut('There was an error adding the contact.'); } $lastmodified = OCA\Contacts\App::lastModified($vcard); if (!$lastmodified) { $lastmodified = new DateTime(); }
public function __isset($name) { return $this->vobject->__isset($name); }
/** * Fill the string properties in a one go * @param array $contact * @param Sabre\VObject\Component $vcard * @return Sabre\VObject\Component */ protected static function _addPropertyStrings($contact, $vcard) { foreach (self::$_propertyStrings as $property) { if (isset($contact[$property])) { $vcard->setString($property, $contact[$property]); } } return $vcard; }