From: x2003bruneau
Date: Tue, 28 Nov 2006 20:51:41 +0000 (+0000)
Subject: Homogenize the code of the pages of the groups
X-Git-Tag: xorg/0.9.13~257
X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=d24c8a1195dce2641e62477fc4618786d931ebce;p=platal.git
Homogenize the code of the pages of the groups
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1194 839d8a87-29fc-0310-9880-83ba4fa771e5
---
diff --git a/include/xnet.inc.php b/include/xnet.inc.php
index 854eda3..b82ccd8 100644
--- a/include/xnet.inc.php
+++ b/include/xnet.inc.php
@@ -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:
?>
diff --git a/include/xnet/page.inc.php b/include/xnet/page.inc.php
index 03d6a1c..b164f37 100644
--- a/include/xnet/page.inc.php
+++ b/include/xnet/page.inc.php
@@ -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";
diff --git a/modules/geoloc.php b/modules/geoloc.php
index ceb3243..f54f57e 100644
--- a/modules/geoloc.php
+++ b/modules/geoloc.php
@@ -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');
}
diff --git a/modules/xnetevents.php b/modules/xnetevents.php
index 3295ca0..7afb82e 100644
--- a/modules/xnetevents.php
+++ b/modules/xnetevents.php
@@ -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));
diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php
index 580716b..1b17bf6 100644
--- a/modules/xnetgrp.php
+++ b/modules/xnetgrp.php
@@ -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 "
diff --git a/templates/xnet/groupe/annuaire.tpl b/templates/xnet/groupe/annuaire.tpl
index 70eb634..f2dcd17 100644
--- a/templates/xnet/groupe/annuaire.tpl
+++ b/templates/xnet/groupe/annuaire.tpl
@@ -34,7 +34,7 @@ Les membres ext
Tu peux également :
- {if $admin}
+ {if $is_admin}
-
{icon name=add title="Ajouter un membre"}
@@ -88,7 +88,7 @@ Tu peux
Infos |
- {if $admin}
+ {if $is_admin}
Actions |
{/if}
@@ -113,7 +113,7 @@ Tu peux
{icon name=email title="mail"}
{/if}
- {if $admin}
+ {if $is_admin}
{icon name=user_edit title="Edition du profil"}
{icon name=delete title="Supprimer de l'annuaire"}
diff --git a/templates/xnet/groupe/asso.tpl b/templates/xnet/groupe/asso.tpl
index 964c12a..ac9f43a 100644
--- a/templates/xnet/groupe/asso.tpl
+++ b/templates/xnet/groupe/asso.tpl
@@ -59,7 +59,7 @@
{/if}
- {if !$is_member && $logged && $asso.pub eq 'public' && $xnet_type != 'promotions'}
+ {if !$is_member && $is_logged && $asso.pub eq 'public' && $xnet_type != 'promotions'}
|
M'inscrire :
diff --git a/templates/xnet/groupe/inscrire.tpl b/templates/xnet/groupe/inscrire.tpl
index 6313524..a881578 100644
--- a/templates/xnet/groupe/inscrire.tpl
+++ b/templates/xnet/groupe/inscrire.tpl
@@ -22,7 +22,7 @@
Demande d'inscription à {$asso.nom}
-{if $u && $admin && $show_form}
+{if $u && $is_admin && $show_form}
Demande de la part de : {$prenom} {$nom} (X{$promo})
diff --git a/templates/xnetevents/admin.tpl b/templates/xnetevents/admin.tpl
index 4018581..4177566 100644
--- a/templates/xnetevents/admin.tpl
+++ b/templates/xnetevents/admin.tpl
@@ -51,7 +51,7 @@ L'
{/foreach}
-{if $admin}{literal}
+{if $is_admin}{literal}
|