Show user's melix in administration page
[platal.git] / include / vcard.inc.php
index 749af3d..08c46c8 100644 (file)
@@ -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);
@@ -59,6 +61,9 @@ 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);
         }
@@ -96,15 +101,18 @@ 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;
     }