Exemplo n.º 1
0
 /**
  * Saves the vcard contact data to the database, returns the id of the
  * new connection record (resuses existing uid if provided).
  * Stores JUST the info from the CONTACT table itself, no sub-tables.
  * @param VCard $vcard The record to store.
  * @return string The new uid.
  */
 private function storeJustContact(VCard $vcard)
 {
     assert(!empty($this->connection));
     $vcard->setFNAppropriately();
     $uid = $vcard->checkSetUID();
     $stmt = $this->prepareCannedQuery('store', 'contact');
     $stmt->bindValue(':uid', $uid);
     foreach (['kind', 'rev'] as $simpleProperty) {
         assert($vcard->getSpecification($simpleProperty)->requiresSingleProperty(), $simpleProperty . ' must be a single value element');
         $stmt->bindValue(':' . $simpleProperty, empty($vcard->{$simpleProperty}) ? null : $vcard->{$simpleProperty}->getValue(), \PDO::PARAM_STR);
     }
     // HACK: #104, #105, #106 VCard and the spec think these are multiple.
     // Database doesn't. Arbitrarily take the first value.
     foreach (['fn', 'bday', 'anniversary'] as $hackMultiple) {
         assert(!$vcard->getSpecification($hackMultiple)->requiresSingleProperty(), $simpleProperty . ' must NOT be a single value element');
         $hackMultipleValue = $vcard->{$hackMultiple};
         if (empty($hackMultipleValue)) {
             $stmt->bindValue(':' . $hackMultiple, null, \PDO::PARAM_NULL);
         } else {
             $stmt->bindValue(':' . $hackMultiple, $hackMultipleValue[0]->getValue());
         }
     }
     $stmt->execute();
     return $uid;
 }
Exemplo n.º 2
0
 /**
  * Produce HTML output from the given vcard by applying named fragments
  * starting from 'vcard'.
  * @arg vCard vcard The vcard to output. Not null.
  * @return string The resulting HTML.
  */
 public function output(VCard $vcard)
 {
     assert(null !== $vcard);
     assert($this->fragments !== null);
     $vcard->setFNAppropriately();
     return $this->i_processFragment($vcard, 'vcard');
 }