Fixes igoogle search gadget.
authorStéphane Jacob <sj@m4x.org>
Sat, 3 Jul 2010 12:42:23 +0000 (14:42 +0200)
committerStéphane Jacob <sj@m4x.org>
Sat, 3 Jul 2010 12:42:23 +0000 (14:42 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
include/userset.inc.php
modules/gadgets.php
templates/gadgets/ig-minifiche.tpl
templates/gadgets/ig-search.tpl
templates/gadgets/ig-skin.tpl

index 23a117e..8d65239 100644 (file)
@@ -117,7 +117,8 @@ class SearchSet extends ProfileSet
 
     protected function &getFilterResults(PlFilter &$pf, PlLimit $limit)
     {
-        return $pf->getProfiles($limit, Profile::FETCH_MINIFICHES);
+        $profiles = $pf->getProfiles($limit, Profile::FETCH_MINIFICHES);
+        return $profiles;
     }
 }
 
index c7eb989..b8700de 100644 (file)
@@ -44,7 +44,6 @@ class GadgetsModule extends PLModule
 
         $events = XDB::iterator("SELECT  SQL_CALC_FOUND_ROWS
                                          e.id, e.titre, UNIX_TIMESTAMP(e.creation_date) AS creation_date,
-                                         IF(u.nom_usage = '', u.nom, u.nom_usage) AS nom, u.prenom, u.promo,
                                          ev.uid IS NULL AS nonlu, e.uid
                                    FROM  announces     AS e
                               LEFT JOIN  announce_read AS ev ON (e.id = ev.evt_id AND ev.uid = {?})
@@ -72,7 +71,9 @@ class GadgetsModule extends PLModule
     function handler_ig_search(&$page)
     {
         if (Env::has('quick') && Env::s('quick') != '') {
+            global $globals;
             require_once 'userset.inc.php';
+
             $view = new SearchSet(true);
             $view->addMod('gadget', 'Gadget', true);
             $view->apply(null, $page);
@@ -86,6 +87,8 @@ class GadgetsModule extends PLModule
                 $page->assign('error', 'Recherche trop générale.');
             } elseif (empty($nb_tot)) {
                 $page->assign('error', 'Il n\'existe personne correspondant à ces critères dans la base !');
+            } else {
+                $page->assign('error', false);
             }
         }
 
index 0ce6087..c5e8069 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-{if (!$c.inscrit && $smarty.session.auth ge AUTH_COOKIE) || $c.dcd}<div class='grayed'>{/if}
-<div class="contact" {if $c.inscrit}{if $smarty.session.auth ge AUTH_COOKIE}title="Fiche mise à jour le {$c.date|date_format}"{/if}{/if}>
+{assign var=dead    value=$profile->deathdate}
+{if $smarty.session.auth ge AUTH_COOKIE}
+  {assign var=withAuth value=true}
+  {assign var=user value=$profile->owner()}
+  {if $user == null}
+    {assign var=hasowner value=false}
+    {assign var=registered value=false}
+  {else}
+    {assign var=hasowner value=true}
+    {if $user->state neq 'pending'}
+      {assign var=registered value=true}
+    {else}
+      {assign var=registered value=false}
+    {/if}
+  {/if}
+{else}
+  {* Without auth, all profiles appear as registered and with owner *}
+  {assign var=hasowner value=true}
+  {assign var=registered value=true}
+  {assign var=withAuth value=false}
+{/if}
+
+<div class="contact {if !$registered || $dead }grayed{/if}"
+     {if $registered}title="fiche mise à jour le {$profile->last_change|date_format}"{/if}>
   <div class="nom">
-    {if $c.sexe}&bull;{/if}
-    {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}<a href="profile/{$c.hruid}" class="popup2">{/if}
-    {if $c.nom_usage}{$c.nom_usage} {$c.prenom}<br />({$c.nom}){else}{$c.nom} {$c.prenom}{/if}
-    {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}</a>{/if}
+    {if $profile->isFemale()}&bull;{/if}
+    {if !$dead && $registered}<a href="profile/{$profile->hrid()}" class="popup2">{/if}
+    {$profile->full_name}
+    {if !$dead && $registered}</a>{/if}
   </div>
   <div class="autre">
-    {if $c.iso3166_1}
-    <img src='images/flags/{$c.iso3166_1}.gif' alt='{$c.nat1}' height='11' title='{$c.nat1}' />&nbsp;
-    {/if}
-    {if $c.iso3166_2}
-    <img src='images/flags/{$c.iso3166_2}.gif' alt='{$c.nat2}' height='11' title='{$c.nat2}' />&nbsp;
-    {/if}
-    {if $c.iso3166_3}
-    <img src='images/flags/{$c.iso3166_3}.gif' alt='{$c.nat3}' height='11' title='{$c.nat3}' />&nbsp;
-    {/if}
-    (X {$c.promo})
-    {if $c.dcd}décédé{if $c.sexe}e{/if} le {$c.deces|date_format}{/if}
-    {if $smarty.session.auth ge AUTH_COOKIE}
-    {if !$c.wasinscrit && !$c.dcd}
-      {if $show_action eq ajouter}
-        <a href="carnet/notifs/add_nonins/{$c.uid}?token={xsrf_token}" target="_top">{*
-        *}{icon name=add title="Ajouter à la liste de mes surveillances"}</a>
-      {else}
-        <a href="carnet/notifs/del_nonins/{$c.uid}?token={xsrf_token}" target="_top">{*
-        *}{icon name=cross title="Retirer de la liste de mes surveillances"}</a>
+    {foreach from=$profile->nationalities() item=nat}
+    <img src='images/flags/{$nat}.gif' alt='{$nat}' height='11' title='{$nat}' />&nbsp;
+    {/foreach}
+    {$profile->promo()}{*
+    *}{if $dead}, {"décédé"|sex:"décédée":$profile} le {$profile->deathdate|date_format}{/if}
+    {if $withAuth}
+      {if $registered || (!$dead && $hasowner)}
+        {if !$registered && !$dead && $hasowner}
+          {if !$smarty.session.user->isWatchedUser($profile)}
+      <a href="carnet/notifs/add_nonins/{$user->login()}?token={xsrf_token}">{*
+      *}{icon name=add title="Ajouter à la liste de mes surveillances"}</a>
+          {else}
+      <a href="carnet/notifs/del_nonins/{$user->login()}?token={xsrf_token}">{*
+      *}{icon name=cross title="Retirer de la liste de mes surveillances"}</a>
+          {/if}
+        {elseif $registered}
+          {if !$dead}
+      <a href="vcard/{$profile->hrid()}.vcf">{*
+      *}{icon name=vcard title="Afficher la carte de visite"}</a>
+            {if !$smarty.session.user->isContact($profile)}
+      <a href="carnet/contacts?action=ajouter&amp;user={$profile->hrid()}&amp;token={xsrf_token}">{*
+      *}{icon name=add title="Ajouter à mes contacts"}</a>
+            {else}
+      <a href="carnet/contacts?action=retirer&amp;user={$profile->hrid()}&amp;token={xsrf_token}">{*
+      *}{icon name=cross title="Retirer de mes contacts"}</a>
+            {/if}
+          {/if}
+        {/if}
       {/if}
-    {elseif $c.wasinscrit && !$c.dcd}
-        <a href="vcard/{$c.hruid}.vcf">{*
-        *}{icon name=vcard title="Afficher la carte de visite"}</a>
-      {if $show_action eq ajouter}
-        <a href="carnet/contacts?action={$show_action}&amp;user={$c.hruid}&amp;token={xsrf_token}" target="_top">{*
-        *}{icon name=add title="Ajouter à mes contacts"}</a>
-      {else}
-        <a href="carnet/contacts?action={$show_action}&amp;user={$c.hruid}&amp;token={xsrf_token}" target="_top">{*
-        *}{icon name=cross title="Retirer de mes contacts"}</a>
-      {/if}
-    {/if}
     {/if}
   </div>
   <div class="long">
-  {if $c.wasinscrit}
-    {if $c.mobile || $c.countrytxt || $c.city}
+  {if !$dead}
+    {assign var=address value=$profile->getMainAddress()}
+    {if $profile->mobile || ($address && $address->country)}
     <table cellspacing="0" cellpadding="0">
-      {if $c.countrytxt || $c.city}
+      {if $address && $address->country}
       <tr>
         <td class="lt">Géographie&nbsp;:</td>
-        <td class="rt">{$c.city}{if $c.city && $c.countrytxt}, {/if}{$c.countrytxt}</td>
+        <td class="rt">{if $address->locality}{$address->locality}, {/if}{$address->country}</td>
       </tr>
       {/if}
-      {if $c.mobile && !$c.dcd}
+      {if $profile->mobile && !$dead}
       <tr>
         <td class="lt">Mobile&nbsp;:</td>
-        <td class="rt">{$c.mobile}</td>
+        <td class="rt">{$profile->mobile}</td>
       </tr>
       {/if}
     </table>
   {/if}
   </div>
 </div>
-{if !$c.inscrit || $c.dcd}</div>{/if}
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 88daf4a..502fb77 100644 (file)
 {elseif $set}
 <div class="contact-list">
 {foreach from=$set item=res}
-  {if $res.contact}
-  {include file="gadgets/ig-minifiche.tpl" c=$res show_action="retirer"}
-  {else}
-  {include file="gadgets/ig-minifiche.tpl" c=$res show_action="ajouter"}
-  {/if}
+  {include file="gadgets/ig-minifiche.tpl" profile=$res}
 {/foreach}
 </div>
 <div class="more">
index 957a2ca..e5b8f3e 100644 (file)
@@ -29,9 +29,6 @@
     {javascript name=ajax}
     {javascript name=xorg}
     {javascript name=igoogle}
-    {foreach from=$gadget_js item=js}
-    <script type="text/javascript" src="{$js}"></script>
-    {/foreach}
   </head>
   <body onload="igOnLoadHandler();">
 {if $gadget_tpl}{include file=$gadget_tpl}{/if}