X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvcard.inc.php;h=08c46c8c13395a3cbc2d6b06d54bde3fdf74b353;hb=2893603b6c76aab5e8fa9150519201357ef39ecd;hp=2e39463b4529f08c6af329634e412dc1b1ea215a;hpb=89460d9c89333fa05bea98bd89211f79a876671b;p=platal.git diff --git a/include/vcard.inc.php b/include/vcard.inc.php index 2e39463..08c46c8 100644 --- a/include/vcard.inc.php +++ b/include/vcard.inc.php @@ -25,9 +25,11 @@ require_once('user.func.inc.php'); class VCard { var $users = array(); + var $photos; - function VCard($users, $freetext = null) + function VCard($users, $photos = true, $freetext = null) { + $this->photos = $photos; if (is_array($users)) { foreach ($users as $user) { $this->add_user($user, $freetext); @@ -37,8 +39,6 @@ class VCard } } - // {{{ text formatting stuff - function escape($text) { return preg_replace('/[,;:]/', '\\\\$0', $text); @@ -61,15 +61,15 @@ class VCard function text_encode($text, $escape = true) { + if (is_array($text)) { + return implode(',', array_map(array($this, 'text_encode'), $text)); + } 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; @@ -101,22 +101,22 @@ class VCard $user['forlife'].'@'.$globals->mail->domain2); $user['virtualalias'] = $res->fetchOneCell(); - + $user['gpxs_vcardjoin'] = join(',', array_map(array($this, 'text_encode'), $user['gpxs_name'])); + $user['binets_vcardjoin'] = join(',', array_map(array($this, 'text_encode'), $user['binets'])); // 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(); + if ($this->photos) { + $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); @@ -129,8 +129,6 @@ class VCard 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: