Homogenize the code of the pages of the groups
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 28 Nov 2006 20:51:41 +0000 (20:51 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 28 Nov 2006 20:51:41 +0000 (20:51 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1194 839d8a87-29fc-0310-9880-83ba4fa771e5

include/xnet.inc.php
include/xnet/page.inc.php
modules/geoloc.php
modules/xnetevents.php
modules/xnetgrp.php
templates/xnet/groupe/annuaire.tpl
templates/xnet/groupe/asso.tpl
templates/xnet/groupe/inscrire.tpl
templates/xnetevents/admin.tpl
templates/xnetevents/index.tpl

index 854eda3..b82ccd8 100644 (file)
@@ -33,6 +33,7 @@ function new_page($tpl_name, $type = SKINNED)
     require_once("xnet/page.inc.php");
     $page = new XnetPage($tpl_name, $type);
     $page->assign('xorg_tpl', $tpl_name);
+    $page->assign('is_logged', S::logged());
 }
 
 function new_skinned_page($tpl_name)
@@ -51,6 +52,8 @@ function new_group_open_page($tpl_name, $refuse_access = false)
 
     $page->assign('asso', $globals->asso());
     $page->setType($globals->asso('cat'));
+    $page->assign('is_admin', may_update());
+    $page->assign('is_member', is_member());
 
     if ($refuse_access) {
         $page->kill("Vous n'avez pas les droits suffisants pour accéder à cette page");
@@ -74,6 +77,17 @@ function new_groupadmin_page($tpl_name)
 }
 
 // }}}
+// {{{ function new_annu_page()
+
+function new_annu_page($tpl_name)
+{
+    new_group_open_page($tpl_name, 
+                            !may_update()
+                            && (!is_member()  || $globals->asso('pub') != 'public')
+                            && $globals->asso('cat') != 'Promotions');
+}
+
+// }}}
 // {{{ function new_admin_page()
 
 function new_admin_page($tpl_name)
@@ -91,5 +105,6 @@ function new_admin_page($tpl_name)
 }
 
 // }}}
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>
index 03d6a1c..b164f37 100644 (file)
@@ -76,12 +76,11 @@ class XnetPage extends PlatalPage
             $sub = array();
             $dim = $globals->asso('diminutif');
             $sub['présentation'] = "login/$dim/";
-            if (may_update() || (is_member()  && $globals->asso('pub') == 'public')) {
+            if (may_update() || (is_member()  && $globals->asso('pub') == 'public')
+                || $globals->asso('cat') == 'Promotions') {
                 $sub['annuaire du groupe'] = "$dim/annuaire";
                 $sub['trombinoscope'] = "$dim/trombi";
                 $sub['carte'] = "$dim/geoloc";
-            } elseif ($globals->asso('cat') == 'Promotions') {
-                $sub['trombinoscope'] = "$dim/trombi";
             }
             if ((is_member() || may_update()) && $globals->asso('mail_domain')) {
                 $sub['listes de diffusion'] = "$dim/lists";
index ceb3243..f54f57e 100644 (file)
@@ -69,13 +69,7 @@ class GeolocModule extends PLModule
 
         if (!empty($GLOBALS['IS_XNET_SITE'])) {
             $page->assign('no_annu', 1);
-            if ($globals->asso('cat') == 'Promotions') {
-                new_group_open_page('geoloc/index.tpl');
-            } elseif ($globals->asso('pub') == 'public') {
-                new_group_page('geoloc/index.tpl');
-            } else {
-                new_groupadmin_page('geoloc/index.tpl');
-            }
+            new_annu_page('geoloc/index.tpl');
         } else {
             $page->changeTpl('geoloc/index.tpl');
         }
index 3295ca0..7afb82e 100644 (file)
@@ -119,8 +119,6 @@ class XnetEventsModule extends PLModule
         }
         
         $page->assign('archive', $archive);
-        $page->assign('admin', may_update());
-
         $evenements = XDB::iterator(
                 "SELECT  e.*, LEFT(10, e.debut) AS debut_day, LEFT(10, e.fin) AS fin_day,
                          IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10),
@@ -173,7 +171,6 @@ class XnetEventsModule extends PLModule
         }
         
         $page->assign('evenements', $evts);
-        $page->assign('is_member', is_member());
     }
 
     function handler_sub(&$page, $eid = null)
@@ -555,7 +552,6 @@ class XnetEventsModule extends PLModule
             $evt = get_event_detail($eid, $item_id);
         }
 
-        $page->assign('admin', may_update());
         $page->assign('evt', $evt);
         $page->assign('tout', is_null($item_id));
 
index 580716b..1b17bf6 100644 (file)
@@ -111,11 +111,7 @@ class XnetGrpModule extends PLModule
             return PL_NOT_FOUND;
         }
 
-        $page->changeTpl('xnet/groupe/asso.tpl');
-        $page->setType($globals->asso('cat'));
-        $page->assign('is_admin', may_update());
-        $page->assign('is_member', is_member());
-        $page->assign('logged', S::logged());
+        new_group_open_page('xnet/groupe/asso.tpl');
 
         if (S::logged()) {
             if (Env::has('read')) {
@@ -296,14 +292,7 @@ class XnetGrpModule extends PLModule
     function handler_annuaire(&$page)
     {
         global $globals;
-
-        if ($globals->asso('pub') == 'public') {
-            new_group_page('xnet/groupe/annuaire.tpl');
-        } else {
-            new_groupadmin_page('xnet/groupe/annuaire.tpl');
-        }
-
-        $page->assign('admin', may_update());
+        new_annu_page('xnet/groupe/annuaire.tpl');
 
         $sort = Env::v('order');
         switch (Env::v('order')) {
@@ -402,14 +391,7 @@ class XnetGrpModule extends PLModule
     function handler_trombi(&$page, $num = 1)
     {
         global $globals;
-        if ($globals->asso('cat') == 'Promotions') {
-            new_group_open_page('xnet/groupe/trombi.tpl');
-        } elseif ($globals->asso('pub') == 'public') {
-            new_group_page('xnet/groupe/trombi.tpl');
-        } else {
-            new_groupadmin_page('xnet/groupe/trombi.tpl');
-        }
-        $page->assign('admin', may_update());
+        new_annu_page('xnet/groupe/trombi.tpl');
         
         $page->assign('urlmainsite', "https://www.polytechnique.org/");
         $trombi = new Trombi(array($this, '_trombi_getlist'));
@@ -463,11 +445,7 @@ class XnetGrpModule extends PLModule
     {
         global $globals;
 
-        $page->changeTpl('xnet/groupe/inscrire.tpl');
-
-        $page->setType($globals->asso('cat'));
-        $page->assign('asso', $globals->asso());
-        $page->assign('admin', may_update());
+        new_group_open_page('xnet/groupe/inscrire.tpl');
 
         if (!$globals->asso('inscriptible'))
                 $page->kill("Il n'est pas possible de s'inscire en ligne à ce "
index 70eb634..f2dcd17 100644 (file)
@@ -34,7 +34,7 @@ Les membres ext
 Tu peux également :
 </p>
 <ul class="descr">
-  {if $admin}
+  {if $is_admin}
   <li>
     <a href="{$platal->ns}member/new">
       {icon name=add title="Ajouter un membre"} 
@@ -88,7 +88,7 @@ Tu peux 
       </a>
     </th>
     <th>Infos</th>
-    {if $admin}
+    {if $is_admin}
     <th>Actions</th>
     {/if}
   </tr>
@@ -113,7 +113,7 @@ Tu peux 
       <a href="mailto:{$m.email}">{icon name=email title="mail"}</a>
       {/if}
     </td>
-    {if $admin}
+    {if $is_admin}
     <td class="center">
       <a href="{$platal->ns}member/{if $m.x}{$m.email}{else}{$m.uid}{/if}">{icon name=user_edit title="Edition du profil"}</a>
       <a href="{$platal->ns}member/del/{if $m.x}{$m.email}{else}{$m.uid}{/if}">{icon name=delete title="Supprimer de l'annuaire"}</a>
index 964c12a..ac9f43a 100644 (file)
@@ -59,7 +59,7 @@
   </tr>
   {/if}
 
-  {if !$is_member && $logged && $asso.pub eq 'public' && $xnet_type != 'promotions'}
+  {if !$is_member && $is_logged && $asso.pub eq 'public' && $xnet_type != 'promotions'}
   <tr>
     <td class="titre">
       M'inscrire :
index 6313524..a881578 100644 (file)
@@ -22,7 +22,7 @@
 
 <h1>Demande d'inscription à {$asso.nom}</h1>
 
-{if $u && $admin && $show_form}
+{if $u && $is_admin && $show_form}
 
 <h2>
   Demande de la part de : {$prenom} {$nom} (X{$promo})
index 4018581..4177566 100644 (file)
@@ -51,7 +51,7 @@ L'
 {/foreach}
 </p>
 
-{if $admin}{literal}
+{if $is_admin}{literal}
 <script type="text/javascript">
 function remplitAuto(mail) {
   document.getElementById('inscription').mail.value=mail;
@@ -78,7 +78,7 @@ Ils ont pay
   {iterate from=$oubliinscription item=m}
   <tr style="background:#d0c198;">
     <td>
-      <a href="" {if $admin}onclick="return remplitAuto('{$m.email}')"{/if}>
+      <a href="" {if $is_admin}onclick="return remplitAuto('{$m.email}')"{/if}>
       {$m.prenom} {$m.nom}
       </a>
     </td>
@@ -111,7 +111,7 @@ Ils ont pay
       {else}
         <th>Nombre</th>
       {/if}
-      {if $admin && $evt.money}
+      {if $is_admin && $evt.money}
         <th>Montant</th>
         <th>Payé</th>
       {/if}
@@ -122,7 +122,7 @@ Ils ont pay
   {foreach from=$participants item=m}
   <tr>
     <td>
-      <a href="" {if $admin}onclick="return remplitAuto('{$m.email}')"{/if}>
+      <a href="" {if $is_admin}onclick="return remplitAuto('{$m.email}')"{/if}>
         {if $m.femme}&bull;{/if}{$m.prenom} {$m.nom}
       </a>
     </td>
@@ -144,7 +144,7 @@ Ils ont pay
       {else}
         <td>{$m[1]}</td>
       {/if}
-      {if $admin && $evt.money}
+      {if $is_admin && $evt.money}
         <td {if $m.montant > $m.paid}class="erreur"{/if}>{$m.montant}&euro;</td>
         <td>{$m.paid}&euro;</td>
       {/if}
@@ -163,7 +163,7 @@ Ils ont pay
 {/foreach}
 </p>
 
-{if $admin}
+{if $is_admin}
 
 <p class="descr">
 [<a href="{$platal->ns}events/csv/{$evt.eid}/{$platal->argv[2]}/{$evt.intitule}{if $evt.titre}.{$evt.titre}{/if}.csv">Télécharger le fichier Excel</a>]
index ca5c415..0daa0c1 100644 (file)
@@ -20,7 +20,7 @@
 {*                                                                        *}
 {**************************************************************************}
 
-{if !$admin}
+{if !$is_admin}
 <h1>{$asso.nom} : Evénements</h1>
 {else}
 <h1>
@@ -67,7 +67,7 @@
       {if !$e.inscr_open}
       (<span class="error">Inscriptions closes</span>)
       {/if}
-      {if $admin}
+      {if $is_admin}
       <br />
       [<a href="{$platal->ns}events/edit/{$e.short_name|default:$e.eid}">
         modifier
     </td>
   </tr>
 
-  {if $admin || $e.show_participants || ($e.deadline_inscription && $e.inscr_open)}
+  {if $is_admin || $e.show_participants || ($e.deadline_inscription && $e.inscr_open)}
   <tr>
     <td class="titre">Informations :</td>
     <td class='actions'>
-      {if $admin || $e.show_participants}
+      {if $is_admin || $e.show_participants}
       <a href="{$platal->ns}events/admin/{$e.short_name|default:$e.eid}">
         consulter la liste des participants
         {icon name=group title="Liste des participants"}