/**
  * Appends a 'relationships' section to the output XML that contains an XHTML table with loglines
  * @return string XML content
  */
 function xmlExport(&$contact)
 {
     //global $errorHandler;
     global $CONFIG_DB_PREFIX, $CONFIG_REL_XML_OTHER_PROPERTIES, $CONFIG_REL_XML_DATE_PROPERTIES, $CONFIG_RELT_XML_OTHER_PROPERTIES, $CONFIG_RELT_XML_DATE_PROPERTIES;
     $db = DB::getSingleton();
     $content = "<relationships>\n";
     // fetch dropdown
     $dropdown = $this->getDropdown($db);
     $content .= '<ddJSON>' . HTMLHelper::arrayToJSON($dropdown) . '</ddJSON>';
     // list outgoing relationships
     $id = $contact->contact['id'];
     $db->query("SELECT r.* FROM `{$CONFIG_DB_PREFIX}Relationships` as r, `{$CONFIG_DB_PREFIX}contact` as c WHERE r.ownerId={$id} AND c.id=r.ownerId AND c.hidden=0", 'Relationships');
     $i = 0;
     while ($r = $db->next('Relationships')) {
         $to = htmlspecialchars($r['relatedToId'], ENT_NOQUOTES, 'UTF-8');
         $desc = htmlspecialchars($r['relationship'], ENT_NOQUOTES, 'UTF-8');
         $content .= "<relationship>\n<ownerId>{$id}</ownerId>\n<relatedToId>{$to}</relatedToId>\n<relatedTo>";
         $relatedTo = new Contact($r['relatedToId']);
         $content .= $relatedTo->generateFullName() . "</relatedTo>\n";
         foreach ($CONFIG_REL_XML_OTHER_PROPERTIES as $tag => $prop) {
             $p = $relatedTo->getProperty('other', $prop);
             $content .= "<{$tag}>" . ($p !== FALSE ? $p : '') . "</{$tag}>";
         }
         foreach ($CONFIG_REL_XML_DATE_PROPERTIES as $tag => $prop) {
             $p = $relatedTo->getDate($prop);
             $content .= "<{$tag}><from>" . ($p !== FALSE ? $p[0] : '') . "</from><to>" . ($p !== FALSE ? $p[1] : '') . "</to></{$tag}>";
         }
         $content .= "<description>{$desc}</description>\n</relationship>\n";
     }
     // list incoming relationships
     $id = $contact->contact['id'];
     $db->query("SELECT r.* FROM `{$CONFIG_DB_PREFIX}Relationships` as r, `{$CONFIG_DB_PREFIX}contact` as c WHERE r.relatedToId={$id} AND c.id=r.relatedToId AND c.hidden=0", 'Relationships');
     $i = 0;
     while ($r = $db->next('Relationships')) {
         $id = $r['ownerId'];
         $to = htmlspecialchars($r['relatedToId'], ENT_NOQUOTES, 'UTF-8');
         $desc = htmlspecialchars($r['relationship'], ENT_NOQUOTES, 'UTF-8');
         $content .= "<relationshipTarget>\n<ownerId>{$id}</ownerId>\n<relatedToId>{$to}</relatedToId>\n<relatedTo>";
         $relatedTo = new Contact($id);
         $content .= $relatedTo->generateFullName() . "</relatedTo>\n";
         foreach ($CONFIG_RELT_XML_OTHER_PROPERTIES as $tag => $prop) {
             $p = $relatedTo->getProperty('other', $prop);
             $content .= "<{$tag}>" . ($p !== FALSE ? $p : '') . "</{$tag}>";
         }
         foreach ($CONFIG_RELT_XML_DATE_PROPERTIES as $tag => $prop) {
             $p = $relatedTo->getDate($prop);
             $content .= "<{$tag}><from>" . ($p !== FALSE ? $p[0] : '') . "</from><to>" . ($p !== FALSE ? $p[1] : '') . "</to></{$tag}>";
         }
         $content .= "<description>{$desc}</description>\n</relationshipTarget>\n";
     }
     $content .= "</relationships>\n";
     return $content;
 }