From 89460d9c89333fa05bea98bd89211f79a876671b Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Sun, 22 Oct 2006 16:33:53 +0000 Subject: [PATCH] Ooops, forgotten files git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1005 839d8a87-29fc-0310-9880-83ba4fa771e5 --- include/lists.inc.php | 4 +- include/vcard.inc.php | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 include/vcard.inc.php diff --git a/include/lists.inc.php b/include/lists.inc.php index d11c94f..8e1b5fb 100644 --- a/include/lists.inc.php +++ b/include/lists.inc.php @@ -72,8 +72,8 @@ function list_sort_owners(&$members, $tri_promo = true) { // {{{ function list_sort_members function list_sort_members(&$members, $tri_promo = true) { - $pi1 = create_function('$arr', 'return $arr[1];'); - return list_sort_owners(array_map($pi1, $members), $tri_promo); + $member_list = array_map(create_function('$arr', 'return $arr[1];'), $members); + return list_sort_owners($member_list, $tri_promo); } // }}} diff --git a/include/vcard.inc.php b/include/vcard.inc.php new file mode 100644 index 0000000..2e39463 --- /dev/null +++ b/include/vcard.inc.php @@ -0,0 +1,137 @@ +add_user($user, $freetext); + } + } else { + $this->add_user($users, $freetext); + } + } + + // {{{ text formatting stuff + + function escape($text) + { + return preg_replace('/[,;:]/', '\\\\$0', $text); + } + + function format_adr($params, &$smarty) + { + // $adr1, $adr2, $adr3, $postcode, $city, $region, $country + extract($params['adr']); + $adr = trim($adr1); + $adr = trim("$adr\n$adr2"); + $adr = trim("$adr\n$adr3"); + return $this->text_encode(';;' + . $this->escape($adr) . ';' + . $this->escape($city) . ';' + . $this->escape($region) . ';' + . $this->escape($postcode) . ';' + . $this->escape($country), false); + } + + function text_encode($text, $escape = true) + { + if ($escape) { + $text = $this->escape($text); + } + return preg_replace("/(\r\n|\n|\r)/", '\n', $text); + } + + // }}} + // {{{ function add_user() + + function add_user($x, $freetext) + { + global $globals; + + $login = get_user_forlife($x); + $user = get_user_details($login); + + if (strlen(trim($user['freetext']))) { + $user['freetext'] = html_entity_decode($user['freetext']); + } + if (!is_null($freetext)) { + if (strlen(trim($user['freetext']))) { + $user['freetext'] = $freetext . "\n" . $user['freetext']; + } else { + $user['freetext'] = $freetext; + } + } + + // alias virtual + $res = XDB::query( + "SELECT alias + FROM virtual + INNER JOIN virtual_redirect USING(vid) + INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' ) + WHERE ( redirect={?} OR redirect={?} ) + AND alias LIKE '%@{$globals->mail->alias_dom}'", + S::v('uid'), + $user['forlife'].'@'.$globals->mail->domain, + $user['forlife'].'@'.$globals->mail->domain2); + + $user['virtualalias'] = $res->fetchOneCell(); + + // get photo + $res = XDB::query( + "SELECT attach, attachmime + FROM photo AS p + INNER JOIN aliases AS a ON (a.id = p.uid AND a.type = 'a_vie') + WHERE a.alias = {?}", $login); + if ($res->numRows()) { + $user['photo'] = $res->fetchOneAssoc(); + } + $this->users[] = $user; + } + + // }}} + // {{{ function do_page() + + 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"); + } + + // }}} +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: +?> -- 2.1.4