auto detect if has thecookie (or better) or not for search
authorx2000habouzit <x2000habouzit>
Tue, 24 Aug 2004 19:53:35 +0000 (19:53 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 24 Aug 2004 19:53:35 +0000 (19:53 +0000)
htdocs/search.php
templates/search.form.tpl
templates/search.tpl

index ffb4c4f..cd809e2 100644 (file)
@@ -1,14 +1,13 @@
 <?php
 require("auto.prepend.inc.php");
 require("search.classes.inc.php");
-// choix entre partie publique (annuaire_public est vrai) et partie privée de l'annuaire.
-$public_directory = ((isset($_REQUEST['public_directory']) && $_REQUEST['public_directory']==1));
-if ($public_directory)
-    new_skinned_page('search.tpl', AUTH_PUBLIC);
-else
+
+new_skinned_page('search.tpl', AUTH_PUBLIC);
+if(logged()) {
     new_skinned_page('search.tpl', AUTH_COOKIE,true);
+}
+
 $page->assign('advanced',0);
-$page->assign('public_directory',$public_directory);
 require_once("applis.func.inc.php");
 require_once("geoloc.inc.php");
 
index 125c67e..5108482 100644 (file)
@@ -5,10 +5,12 @@
     Recherche simple
   {/if}
   <div class="floatright">
-    {if $advanced eq "1"}
-      <a href="search.php">-> Recherche simple</a>
-    {elseif $public_directory neq "1"}
-      <a href="advanced_search.php">-> Recherche avancée</a>
+    {if $advanced}
+      [<a href="search.php">Recherche simple</a>]
+    {else}
+      {min_auth level="cookie"}
+      [<a href="advanced_search.php">Recherche avancée</a>]
+      {/min_auth}
     {/if}
   </div>
 </div>
@@ -19,7 +21,6 @@
 {/if}
 <div class="center">
   <form action="{$smarty.server.PHP_SELF}" method="post" name="recherche">
-    <input type="hidden" name="public_directory" value="{$public_directory}">
     <table class="tinybicol" cellpadding="3" summary="Recherche">
       <tr>
         <td>Nom</td>
         <td>
           <select name="egal1">
             <option value="=" {if $smarty.request.egal1 eq "="}selected{/if}>&nbsp;=&nbsp;</option>
-            <option value=">" {if $smarty.request.egal1 eq ">"}selected{/if}>&nbsp;&gt;&nbsp;</option>
-            <option value="<" {if $smarty.request.egal1 eq "<"}selected{/if}>&nbsp;&lt;&nbsp;</option>
+           <option value="&gt;" {if $smarty.request.egal1 eq ">"}selected{/if}>&nbsp;&gt;&nbsp;</option>
+            <option value="&lt;" {if $smarty.request.egal1 eq "<"}selected{/if}>&nbsp;&lt;&nbsp;</option>
           </select>
           <input type="text" name="promo1" size="4" maxlength="4" value="{$smarty.request.promo1}" />
           &nbsp;ET&nbsp;
           <select name="egal2">
             <option value="=" {if $smarty.request.egal2 eq "="}selected{/if}>&nbsp;=&nbsp;</option>
-            <option value=">" {if $smarty.request.egal2 eq ">"}selected{/if}>&nbsp;&gt;&nbsp;</option>
-            <option value="<" {if $smarty.request.egal2 eq "<"}selected{/if}>&nbsp;&lt;&nbsp;</option>
+           <option value="&gt;" {if $smarty.request.egal2 eq ">"}selected{/if}>&nbsp;&gt;&nbsp;</option>
+           <option value="&lt;" {if $smarty.request.egal2 eq "<"}selected{/if}>&nbsp;&lt;&nbsp;</option>
           </select>
           <input type="text" name="promo2" size="4" maxlength="4" value="{$smarty.request.promo2}" />
         </td>
@@ -59,7 +60,7 @@
         <td>Pays</td>
         <td>
           <select name="pays" onChange="javascript:document.recherche.submit();">
-          {if isset($smarty.request.pays)}
+          {if $smarty.request.pays}
             {assign var="pays" value=$smarty.request.pays}
           {else}
             {assign var="pays" value=""}
@@ -72,7 +73,7 @@
         <td>Région ou département</td>
         <td>
           <select name="region">
-          {if isset($smarty.request.region)}
+          {if $smarty.request.region}
             {assign var="region" value=$smarty.request.region}
           {else}
             {assign var="region" value=""}
index 4a61ec4..9de63e3 100644 (file)
@@ -7,12 +7,12 @@
     {if $nb_resultats_total==0}Aucune{else}{$nb_resultats_total}{/if} réponse{if $nb_resultats_total>1}s{/if}.
     <div class="floatright">
       {if $with_soundex==0}
-        <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&with_soundex=1&rechercher=1&{$url_args}">
+        <a href="{$smarty.server.PHP_SELF}?with_soundex=1&rechercher=1&{$url_args}">
           Etendre à la recherche par proximité sonore
         </a>
       {/if}
       &nbsp;
-      <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}">Nouvelle recherche</a>
+      <a href="{$smarty.server.PHP_SELF}">Nouvelle recherche</a>
     </div>
   </div>
   <p class="normal">
@@ -21,9 +21,9 @@
       <div class="contact">
       <div class="{if $resultats[resultat].inscrit==1}pri3{else}pri1{/if}">
         {include file="search.result.public.tpl" result=$resultats[resultat]}
-        {if $public_directory!=1}
+       {min_auth level="cookie"}
           {include file="search.result.private.tpl" result=$resultats[resultat]}
-        {/if}
+       {/min_auth}
       </div>
       </div>
       {/section}
   {if $perpage<$nb_resultats_total}
   <p class="normal">
     {if $offset!=0}
-      <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&with_soundex={$with_soundex}&rechercher=1&{$url_args}&offset={$offset-$perpage}">
+      <a href="{$smarty.server.PHP_SELF}?with_soundex={$with_soundex}&rechercher=1&{$url_args}&offset={$offset-$perpage}">
         Précédent
       </a>
       &nbsp;
     {/if}
     {section name=offset loop=$offsets}
       {if $offset!=$smarty.section.offset.index*$perpage}
-        <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&with_soundex={$with_soundex}&rechercher=1&{$url_args}&offset={$smarty.section.offset.index*$perpage}">
+        <a href="{$smarty.server.PHP_SELF}?with_soundex={$with_soundex}&rechercher=1&{$url_args}&offset={$smarty.section.offset.index*$perpage}">
           {$smarty.section.offset.index+1}
         </a>
       {else}
@@ -48,7 +48,7 @@
       &nbsp;
     {/section}
     {if $offset<$nb_resultats_total-$perpage}
-      <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&with_soundex={$with_soundex}&rechercher=1&{$url_args}&offset={$offset+$perpage}">
+      <a href="{$smarty.server.PHP_SELF}?with_soundex={$with_soundex}&rechercher=1&{$url_args}&offset={$offset+$perpage}">
         Suivant
       </a>
       &nbsp;