- function do_page(&$page)
- {
- $page->changeTpl('vcard.tpl', NO_SKIN);
- $page->register_modifier('vcard_enc', array($this, 'text_encode'));
- $page->register_function('format_adr', array($this, 'format_adr'));
- $page->assign_by_ref('users', $this->users);
-
- header("Pragma: ");
- header("Cache-Control: ");
- header("Content-type: text/x-vcard; charset=iso-8859-15");
- header("Content-Transfer-Encoding: 8bit");
+ // Pro
+ $adrs = $pf->iterAddresses(Profile::ADDRESS_PRO);
+ while ($adr = $adrs->next()) {
+ // TODO : link address to company
+ $group = $entry->addWork(null, null, null, null,
+ $adr['text'], null, null, $adr['postalCode'],
+ $adr['locality'], $adr['administrativeArea'], $adr['country']);
+ if (!empty($adr['fixed_tel'])) {
+ $entry->addTel($group, $adr['fixed_tel']);
+ }
+ if (!empty($adr['fax_tel'])) {
+ $entry->addTel($group, $adr['display_tel'], true);
+ }
+ /* TODO : fetch email for jobs, too
+ if (!empty($pro['email'])) {
+ $entry->addMail($group, $pro['email']);
+ }
+ */
+ }
+
+ // Melix
+ if (!is_null($user)) {
+ $alias = $user->emailAlias();
+ if (!is_null($alias)) {
+ $entry->addMail(null, $alias);
+ }
+ }
+
+ // Custom fields
+ if (!is_null($user)) {
+ $groups = $user->groups();
+ if (count($groups)) {
+ $gn = DirEnum::getOptions(DirEnum::GROUPESX);
+ $gns = array();
+ foreach (array_keys($groups) as $gid) {
+ $gns[$gid] = $gn[$gid];
+ }
+ $entry->set('X-GROUPS', join(', ', $gns));
+ }
+ }
+
+ $binets = $pf->getBinets();
+
+ if (count($binets)) {
+ $bn = DirEnum::getOptions(DirEnum::BINETS);
+ $bns = array();
+ foreach ($binets as $bid) {
+ $bns[$bid] = $bn[$bid];
+ }
+ $entry->set('X-BINETS', join(', ', $bid));
+ }
+ if (!empty($pf->section)) {
+ $sections = DirEnum::getOptions(DirEnum::SECTIONS);
+ $entry->set('X-SECTION', $sections[$pf->section]);
+ }
+
+ // Photo
+ if ($this->photos) {
+ $res = XDB::query(
+ "SELECT attach, attachmime
+ FROM photo AS p
+ WHERE p.uid = {?}", $pf->id());
+ if ($res->numRows()) {
+ list($data, $type) = $res->fetchOneRow();
+ $entry->setPhoto($data, strtoupper($type));
+ }
+ }
+ return $entry;