From: Florent Bruneau Date: Sun, 3 Oct 2010 10:25:26 +0000 (+0200) Subject: Add support for 'lists' permission in the list.rpc. X-Git-Tag: xorg/1.0.1~115 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=2ca5f0311c9b28e96bf3372435f8f82ae5dbe61f;p=platal.git Add support for 'lists' permission in the list.rpc. Signed-off-by: Florent Bruneau --- diff --git a/bin/lists.rpc.py b/bin/lists.rpc.py index 9ed42d8..c3cac82 100755 --- a/bin/lists.rpc.py +++ b/bin/lists.rpc.py @@ -126,23 +126,26 @@ class BasicAuthXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): self.end_headers() def getUser(self, uid, md5, vhost): - res = mysql_fetchone ("""SELECT a.full_name, aa.alias, IF (a.is_admin, 'admin', NULL) + res = mysql_fetchone ("""SELECT a.full_name, IF(aa.alias IS NULL, a.email, CONCAT(aa.alias, '@%s')), + IF (a.is_admin, 'admin', + IF(FIND_IN_SET('lists', at.perms) OR FIND_IN_SET('lists', a.user_perms), 'lists', NULL)) FROM accounts AS a - INNER JOIN aliases AS aa ON (a.uid = aa.uid AND aa.type = 'a_vie') + INNER JOIN account_types AS at ON (at.type = a.type) + LEFT JOIN aliases AS aa ON (a.uid = aa.uid AND aa.type = 'a_vie') WHERE a.uid = '%s' AND a.password = '%s' AND a.state = 'active' LIMIT 1""" \ - % (uid, md5)) + % (PLATAL_DOMAIN, uid, md5)) if res: name, forlife, perms = res if vhost != PLATAL_DOMAIN: - res = mysql_fetchone ("""SELECT m.uid + res = mysql_fetchone ("""SELECT m.uid, IF(m.perms = 'admin', 'admin', 'lists') FROM group_members AS m INNER JOIN groups AS g ON (m.asso_id = g.id) - WHERE perms = 'admin' AND uid = '%s' AND mail_domain = '%s'""" \ + WHERE uid = '%s' AND mail_domain = '%s'""" \ % (uid, vhost)) if res: - perms= 'admin' - userdesc = UserDesc(forlife+'@'+PLATAL_DOMAIN, name, None, 0) + _, perms = res + userdesc = UserDesc(forlife, name, None, 0) return (userdesc, perms, vhost) else: return None @@ -287,7 +290,7 @@ def get_list_info(userdesc, perms, mlist, front_page=0): members = mlist.getRegularMemberKeys() is_member = userdesc.address in members is_owner = userdesc.address in mlist.owner - if mlist.advertised or is_member or is_owner or (not front_page and perms == 'admin'): + if (mlist.advertised and perms in ('lists', 'admin')) or is_member or is_owner or (not front_page and perms == 'admin'): is_pending = False if not is_member and (mlist.subscribe_policy > 1): is_pending = list_call_locked(is_subscription_pending, userdesc, perms, mlist, False) diff --git a/modules/lists.php b/modules/lists.php index f6e0109..1c93980 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -26,23 +26,23 @@ class ListsModule extends PLModule function handlers() { return array( - 'lists' => $this->make_hook('lists', AUTH_MDP, 'lists'), - 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP, 'lists', NO_AUTH), + 'lists' => $this->make_hook('lists', AUTH_MDP), + 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP, 'user', NO_AUTH), 'lists/create' => $this->make_hook('create', AUTH_MDP, 'lists'), - 'lists/members' => $this->make_hook('members', AUTH_COOKIE, 'lists'), - 'lists/csv' => $this->make_hook('csv', AUTH_COOKIE, 'lists'), - 'lists/annu' => $this->make_hook('annu', AUTH_COOKIE, 'lists'), - 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE, 'lists'), - 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'lists', NO_HTTPS), + 'lists/members' => $this->make_hook('members', AUTH_COOKIE), + 'lists/csv' => $this->make_hook('csv', AUTH_COOKIE), + 'lists/annu' => $this->make_hook('annu', AUTH_COOKIE), + 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE), + 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS), - 'lists/moderate' => $this->make_hook('moderate', AUTH_MDP, 'lists'), - 'lists/admin' => $this->make_hook('admin', AUTH_MDP, 'lists'), - 'lists/options' => $this->make_hook('options', AUTH_MDP, 'lists'), - 'lists/delete' => $this->make_hook('delete', AUTH_MDP, 'lists'), + 'lists/moderate' => $this->make_hook('moderate', AUTH_MDP), + 'lists/admin' => $this->make_hook('admin', AUTH_MDP), + 'lists/options' => $this->make_hook('options', AUTH_MDP), + 'lists/delete' => $this->make_hook('delete', AUTH_MDP), - 'lists/soptions' => $this->make_hook('soptions', AUTH_MDP, 'lists'), - 'lists/check' => $this->make_hook('check', AUTH_MDP, 'lists'), + 'lists/soptions' => $this->make_hook('soptions', AUTH_MDP), + 'lists/check' => $this->make_hook('check', AUTH_MDP), 'admin/lists' => $this->make_hook('admin_all', AUTH_MDP, 'admin'), ); } diff --git a/templates/lists/index.tpl b/templates/lists/index.tpl index 726446c..6c7fddb 100644 --- a/templates/lists/index.tpl +++ b/templates/lists/index.tpl @@ -24,13 +24,17 @@ Listes de diffusion de Polytechnique.org +{if $owner|@count > 0 || $member|@count > 0 || ( hasPerm('lists') && $public|@count +> 0)}

L'inscription à une liste de diffusion

@@ -47,7 +51,13 @@ La diffusion a trois niveaux de modération. La diffusion peut être :
  • modérée : l'envoi d'un email à la liste est alors filtré par des modérateurs, eux seuls peuvent accepter un message envoyé à la liste.
  • +{else} +

    + Tu n'as actuellement accès à aucune liste de diffusion. +

    +{/if} +{if hasPerm('lists')}

    Demander la création d'une liste de diffusion

    @@ -61,6 +71,7 @@ thématique particulière. Tu peux demander la création d'une liste de diffusion sur le thème de ton choix.

    +{/if} {if $owner|@count}

    Listes dont tu es modérateur

    @@ -80,6 +91,8 @@ thématique particulière.

    Attention : lorsqu'une liste à laquelle tu es abonné est privée, l'icône {icon name=weather_cloudy} est affichée en début de ligne. Si tu t'en désinscris, il ne te sera pas possible de t'y abonner de nouveau sans l'action d'un modérateur.

    {/if} + +{if hasPerm('lists')}

    Listes de diffusion publiques auxquelles tu peux t'inscrire

    @@ -108,5 +121,6 @@ Les listes de diffusion publiques sont visibles par tous les X inscrits à Polyt +{/if} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/skin/common.menu.tpl b/templates/skin/common.menu.tpl index 5bb7c46..361bd17 100644 --- a/templates/skin/common.menu.tpl +++ b/templates/skin/common.menu.tpl @@ -68,9 +68,7 @@ {if $smarty.session.user->googleapps}

    {/if} -{if $smarty.session.user->checkPerms('lists')} -{/if} {if $smarty.session.user->checkPerms('payment')} {/if}