Adding hobby visibility on profile.
authorVictor Berger <victor.berger@m4x.org>
Sun, 16 Feb 2014 16:04:23 +0000 (17:04 +0100)
committerVictor Berger <victor.berger@m4x.org>
Sun, 16 Feb 2014 16:04:50 +0000 (17:04 +0100)
Signed-off-by: Victor Berger <victor.berger@m4x.org>
classes/profile.php
templates/profile/profile.tpl

index 29de2b1..7065598 100644 (file)
@@ -1013,6 +1013,22 @@ class Profile implements PlExportable
         }
     }
 
+    /* Hobbies
+     */
+    public function getHobbies() {
+        if ($this->visibility->isVisible(Visibility::EXPORT_PRIVATE)) {
+            return XDB::fetchAllAssoc('type', 'SELECT  type, GROUP_CONCAT(text)
+                                         FROM  profile_hobby
+                                        WHERE  pid = {?}
+                                     GROUP BY  type', $this->id());
+        } else {
+            return XDB::fetchAllAssoc('type', 'SELECT  type, GROUP_CONCAT(text)
+                                         FROM  profile_hobby
+                                        WHERE  pub = \'public\' AND pid = {?}
+                                      GROUP BY type', $this->id());
+        }
+    }
+
     /* Medals
      */
     private $medals = null;
index ff67147..2fee8b6 100644 (file)
@@ -86,6 +86,14 @@ $($.closeOnEsc);
       {/foreach}
     {/if}
 
+    {assign var=hobbies value=$profile->getHobbies()}
+    {if count($hobbies) > 0}
+      <h2>Hobbies...</h2>
+      {foreach from=$hobbies key=type item=text}
+        <div><em class="intitule">{$type} : </em>{$text}</div>
+      {/foreach}
+    {/if}
+
     {if $profile->freetext}
       <h2>Commentaires&nbsp;:</h2>
       <span>{$profile->freetext|miniwiki|smarty:nodefaults}</span>