From 470d14f6148c522e1ee2968cb61140104e7fade0 Mon Sep 17 00:00:00 2001
From: Florent Bruneau
Date: Sat, 10 Apr 2010 17:58:10 +0200
Subject: [PATCH] Should fix the "Trombinoscope" (at least for search and MLs).
Signed-off-by: Florent Bruneau
---
classes/userfilter.php | 32 ++++++++++++++
core | 2 +-
include/userset.inc.php | 3 +-
modules/xnet.php | 2 +-
templates/include/plview.trombi.entry.tpl | 42 ++++++++++++++++++
templates/include/plview.trombi.tpl | 72 ++++++-------------------------
6 files changed, 91 insertions(+), 62 deletions(-)
create mode 100644 templates/include/plview.trombi.entry.tpl
diff --git a/classes/userfilter.php b/classes/userfilter.php
index f975eb7..24e1e9a 100644
--- a/classes/userfilter.php
+++ b/classes/userfilter.php
@@ -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
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 501a6db205b3355bd9e15de6eac20ca033835201
+Subproject commit b0a8daa8a2428ffc76ea4eb690ab8379cdc22aec
diff --git a/include/userset.inc.php b/include/userset.inc.php
index a403b8a..92e041a 100644
--- a/include/userset.inc.php
+++ b/include/userset.inc.php
@@ -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);
}
diff --git a/modules/xnet.php b/modules/xnet.php
index 9ad297a..3da7b6a 100644
--- a/modules/xnet.php
+++ b/modules/xnet.php
@@ -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
index 0000000..ea6dbcc
--- /dev/null
+++ b/templates/include/plview.trombi.entry.tpl
@@ -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}
+
+
+ {if $trombi_with_admin && hasPerm('admin')}
+ {icon name=wrench title="[admin]"}
+ {/if}
+ |
+{else}
+
+
+ |
+{/if}
+{/if}
diff --git a/templates/include/plview.trombi.tpl b/templates/include/plview.trombi.tpl
index 24c524c..15d9db0 100644
--- a/templates/include/plview.trombi.tpl
+++ b/templates/include/plview.trombi.tpl
@@ -26,75 +26,29 @@
{else}
- {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]}
-
-
- {if $trombi_with_admin && hasPerm('admin')}
- {icon name=wrench title="[admin]"}
- {/if}
- |
-
-
- {if $trombi_with_admin && hasPerm('admin')}
- {icon name=wrench title="[admin]"}
- {/if}
- |
-
- {if $set[trombi.index_next]}
-
- {if $trombi_with_admin && hasPerm('admin')}
- {icon name=wrench title="[admin]"}
- {/if}
- {/if}
- |
+ {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}
-
-
- |
-
-
- |
-
- {if $set[trombi.index_next]}
-
- {/if}
- |
+ {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}
{elseif ($smarty.section.trombi.index % 3 == 0) && ($smarty.section.trombi.last)}
+ {assign var=key_cur value=$set_keys[trombi]}
-
-
- {if $trombi_with_admin && hasPerm('admin')}
- {icon name=wrench title="[admin]"}
- {/if}
- |
+ {include file="include/plview.trombi.entry.tpl" profile=$set[$key_cur] photo=true}
| |
-
-
- |
+ {include file="include/plview.trombi.entry.tpl" profile=$set[$key_cur] photo=false}
| |
{/if}
--
2.1.4