From 437a98e00b91970b94d87333ed4c0b09763dec44 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 7 Oct 2007 18:07:27 +0200 Subject: [PATCH] User organization in banana depends on the location (xnet or not)/rights of the user Signed-off-by: Florent Bruneau --- include/banana/forum.inc.php | 4 ++-- include/banana/hooks.inc.php | 15 +++++++++++++++ include/banana/ml.inc.php | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/banana/forum.inc.php b/include/banana/forum.inc.php index 10302d8..7195d1e 100644 --- a/include/banana/forum.inc.php +++ b/include/banana/forum.inc.php @@ -86,7 +86,7 @@ class ForumsBanana extends Banana LEFT JOIN {$globals->banana->table_prefix}list ON list.fid=abos.fid WHERE uid={?}", S::i('uid')); Banana::$profile['headers']['From'] = "$nom <$mail>"; - Banana::$profile['headers']['Organization'] = 'Utilisateur de Polytechnique.org'; + Banana::$profile['headers']['Organization'] = make_Organization(); Banana::$profile['signature'] = $sig; Banana::$profile['display'] = $disp; Banana::$profile['autoup'] = $maj; @@ -130,7 +130,7 @@ class ForumsBanana extends Banana WHERE a.alias = {?}', $this->forlife); list($nom, $prenom, $promo, $bestalias) = $res->fetchOneRow(); Banana::$profile['headers']['From'] = "$prenom $nom ($promo) <$bestalias@{$globals->mail->domain}>"; - Banana::$profile['headers']['Organization'] = 'Utilisateur de Polytechnique.org'; + Banana::$profile['headers']['Organization'] = make_Organization(); return parent::post($dest, $reply, $subject, $body); } diff --git a/include/banana/hooks.inc.php b/include/banana/hooks.inc.php index 46aa962..7a6367e 100644 --- a/include/banana/hooks.inc.php +++ b/include/banana/hooks.inc.php @@ -205,6 +205,21 @@ function hook_makeJs($src) return ' '; } +function make_Organization() +{ + global $globals; + $perms = S::v('perms'); + $group = $globals->asso('nom'); + if (S::has_perms()) { + return "Administrateur de Polytechnique.org"; + } else if ($group && $perms->hasFlag('groupadmin')) { + return "Animateur de $group"; + } else if ($group && $perms->hasFlag('groupmember')) { + return "Membre de $group"; + } + return "Utilisateur de Polytechnique.org"; +} + function get_banana_params(array &$get, $group = null, $action = null, $artid = null) { if (!is_null($group)) { diff --git a/include/banana/ml.inc.php b/include/banana/ml.inc.php index a4be8df..713a90f 100644 --- a/include/banana/ml.inc.php +++ b/include/banana/ml.inc.php @@ -61,7 +61,7 @@ class MLBanana extends Banana // Build user profile Banana::$profile['headers']['From'] = "$nom <$mail>"; - Banana::$profile['headers']['Organization'] = 'Utilisateur de Polytechnique.org'; + Banana::$profile['headers']['Organization'] = make_Organization(); Banana::$profile['signature'] = $sig; // Page design -- 2.1.4