Should fix the "Trombinoscope" (at least for search and MLs).
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 10 Apr 2010 15:58:10 +0000 (17:58 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 10 Apr 2010 15:58:10 +0000 (17:58 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/userfilter.php
core
include/userset.inc.php
modules/xnet.php
templates/include/plview.trombi.entry.tpl [new file with mode: 0644]
templates/include/plview.trombi.tpl

index f975eb7..24e1e9a 100644 (file)
@@ -1144,6 +1144,19 @@ class UFC_Medal implements UserFilterCondition
 }
 // }}}
 
+// {{{ class UFC_Photo
+/** Filters profiles with photo
+ */
+class UFC_Photo implements UserFilterCondition
+{
+    public function buildCondition(PlFilter &$uf)
+    {
+        $uf->addPhotoFilter();
+        return 'photo.attach IS NOT NULL';
+    }
+}
+// }}}
+
 // {{{ class UFC_Mentor_Expertise
 /** Filters users by mentoring expertise
  * @param $expertise Domain of expertise
@@ -2593,6 +2606,25 @@ class UserFilter extends PlFilter
     }
 
 
+    /** PHOTOS
+     */
+    private $with_photo;
+    public function addPhotoFilter()
+    {
+        $this->requireProfiles();
+        $this->with_photo = true;
+    }
+
+    protected function photoJoins()
+    {
+        if ($this->with_photo) {
+            return array('photo' => PlSqlJoin::left('profile_photos', '$ME.pid = $PID'));
+        } else {
+            return array();
+        }
+    }
+
+
     /** MARKETING
      */
     private $with_rm;
diff --git a/core b/core
index 501a6db..b0a8daa 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 501a6db205b3355bd9e15de6eac20ca033835201
+Subproject commit b0a8daa8a2428ffc76ea4eb690ab8379cdc22aec
index a403b8a..92e041a 100644 (file)
@@ -121,7 +121,7 @@ class SearchSet extends ProfileSet
     }
 }
 
-class ArraySet extends UserSet
+class ArraySet extends ProfileSet
 {
     public function __construct(array $users)
     {
@@ -268,6 +268,7 @@ class TrombiView extends ProfileView
                         new UFO_Promo(UserFilter::DISPLAY, true),
                         new UFO_Name(Profile::DN_SORT),
                     ), 'promotion'));
+        $set->addCond(new UFC_Photo());
         parent::__construct($set, $data, $params);
     }
 
index 9ad297a..3da7b6a 100644 (file)
@@ -45,7 +45,7 @@ class XnetModule extends PLModule
         }
 
         // Retrieve the photo and its mime type.
-        $photo = $profile->getPhoto(true);
+        $photo = $profile->getPhoto(true, true);
 
         // Display the photo, or a default one when not available.
         $photo->send();
diff --git a/templates/include/plview.trombi.entry.tpl b/templates/include/plview.trombi.entry.tpl
new file mode 100644 (file)
index 0000000..ea6dbcc
--- /dev/null
@@ -0,0 +1,42 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+{if $profile}
+{if $photo}
+<td class="center" style="vertical-align: middle">
+  <a href="profile/{$profile->hrid()}" class="popup2">
+    <img src="photo/{$profile->hrid()}" width="110" alt=" [ PHOTO ] " />
+  </a>
+  {if $trombi_with_admin && hasPerm('admin')}
+  <a href="{$mainsiteurl}admin/trombino/{$profile->id()}">{icon name=wrench title="[admin]"}</a>
+  {/if}
+</td>
+{else}
+<td class="center" style="vertical-align: bottom; padding-bottom: 15px">
+  <a href="profile/{$profile->hrid()}" class="popup2">
+    <span {if $profile->name_tooltip}class="hinted"
+    title="{$profile->directory_name}"{/if}>{$profile->directory_name}</span> 
+    {if $trombi_with_promo && $profile->promo()}({$profile->promo()}){/if}
+  </a>
+</td>
+{/if}
+{/if}
index 24c524c..15d9db0 100644 (file)
 </p>
 {else}
 <table cellpadding="0" cellspacing="2" style="width: 100%">
-  {section name=trombi loop=$set start=0}
+  {section name=trombi loop=$set_keys start=0}
   {if $smarty.section.trombi.index % 3 == 1}
+  {assign var=key_prev value=$set_keys[trombi.index_prev]}
+  {assign var=key_cur  value=$set_keys[trombi]}
+  {assign var=key_next value=$set_keys[trombi.index_next]}
   <tr>
-    <td class="center" style="vertical-align: middle">
-      <a href="{$mainsiteurl}profile/{$set[trombi.index_prev].hruid}" class="popup2">
-        <img src="photo/{$set[trombi.index_prev].hruid}" width="110" alt=" [ PHOTO ] " />
-      </a>
-      {if $trombi_with_admin && hasPerm('admin')}
-      <a href="{$mainsiteurl}admin/trombino/{$set[trombi.index_prev].uid}">{icon name=wrench title="[admin]"}</a>
-      {/if}
-    </td>
-    <td class="center" style="vertical-align: middle">
-      <a href="{$mainsiteurl}profile/{$set[trombi].hruid}" class="popup2">
-        <img src="photo/{$set[trombi].hruid}" width="110" alt=" [ PHOTO ] " />
-      </a>
-      {if $trombi_with_admin && hasPerm('admin')}
-      <a href="{$mainsiteurl}admin/trombino/{$set[trombi].uid}">{icon name=wrench title="[admin]"}</a>
-      {/if}
-    </td>
-    <td class="center" style="vertical-align: middle">
-    {if $set[trombi.index_next]}
-      <a href="{$mainsiteurl}profile/{$set[trombi.index_next].hruid}" class="popup2">
-        <img src="photo/{$set[trombi.index_next].hruid}" width="110" alt=" [ PHOTO ] " />
-      </a>
-      {if $trombi_with_admin && hasPerm('admin')}
-      <a href="{$mainsiteurl}admin/trombino/{$set[trombi.index_next].uid}">{icon name=wrench title="[admin]"}</a>
-      {/if}
-    {/if}
-    </td>
+    {include file="include/plview.trombi.entry.tpl" profile=$set[$key_prev] photo=true}
+    {include file="include/plview.trombi.entry.tpl" profile=$set[$key_cur] photo=true}
+    {include file="include/plview.trombi.entry.tpl" profile=$set[$key_next] photo=true}
   </tr>
   <tr>
-    <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
-      <a href="{$mainsiteurl}profile/{$set[trombi.index_prev].hruid}" class="popup2">
-        <span {if $set[trombi.index_prev].name_tooltip}class="hinted"
-        title="{$set[trombi.index_prev].name_tooltip}"{/if}>{$set[trombi.index_prev].name_display}</span>{if $trombi_with_promo} ({$set[trombi.index_prev].promo_display}){/if}
-      </a>
-    </td>
-    <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
-      <a href="{$mainsiteurl}profile/{$set[trombi].hruid}" class="popup2">
-        <span {if $set[trombi].name_tooltip}class="hinted" title="{$set[trombi].name_tooltip}"{/if}>{$set[trombi].name_display}</span>{if $trombi_with_promo} ({$set[trombi].promo_display}){/if}
-      </a>
-    </td>
-    <td class="center" style="vertical-align: bottom; padding-bottom: 15px">
-    {if $set[trombi.index_next]}
-      <a href="{$mainsiteurl}profile/{$set[trombi.index_next].hruid}" class="popup2">
-        <span {if $set[trombi.index_next].name_tooltip}class="hinted" title="{$set[trombi.index_next].name_tooltip}"{/if}>{$set[trombi.index_next].name_display}</span>{if $trombi_with_promo} ({$set[trombi.index_next].promo_display}){/if}
-      </a>
-    {/if}
-    </td>
+    {include file="include/plview.trombi.entry.tpl" profile=$set[$key_prev] photo=false}
+    {include file="include/plview.trombi.entry.tpl" profile=$set[$key_cur] photo=false}
+    {include file="include/plview.trombi.entry.tpl" profile=$set[$key_next] photo=false}
   </tr>
   {elseif ($smarty.section.trombi.index % 3 == 0) && ($smarty.section.trombi.last)}
+  {assign var=key_cur  value=$set_keys[trombi]}
   <tr>
-    <td class="center" style="vertical-align: middle; padding-bottom: 15px">
-      <a href="{$mainsiteurl}profile/{$set[trombi].hruid}" class="popup2">
-        <img src="photo/{$set[trombi].hruid}" width="110" alt=" [ PHOTO ] " />
-      </a>
-      {if $trombi_with_admin && hasPerm('admin')}
-      <a href="{$mainsiteurl}admin/trombino/{$set[trombi].uid}">{icon name=wrench title="[admin]"}</a>
-      {/if}
-    </td>
+    {include file="include/plview.trombi.entry.tpl" profile=$set[$key_cur] photo=true}
     <td></td><td></td>
   </tr>
   <tr style="margin-top: 0; padding-top: 0">
-    <td class="center" style="vertical-align: bottom">
-      <a href="{$mainsiteurl}profile/{$set[trombi].hruid}" class="popup2">
-      <a href="{$mainsiteurl}profile/{$set[trombi].forlife}" class="popup2">
-        <span {if $set[trombi].name_tooltip}class="hinted" title="{$set[trombi].name_tooltip}"{/if}>{$set[trombi].name_display}</span>{if $trombi_with_promo} ({$set[trombi].promo_display}){/if}
-      </a>
-    </td>
+    {include file="include/plview.trombi.entry.tpl" profile=$set[$key_cur] photo=false}
     <td></td><td></td>
   </tr>
   {/if}