Application des patches crans.
darcs-hash:20070601130217-68412-6031a22f65c4203b17066a69c164031db0110c19.gz
This commit is contained in:
parent
329eea2862
commit
d294a22d41
3 changed files with 68 additions and 2 deletions
|
@ -1021,6 +1021,10 @@ class RequestBase(object):
|
|||
""" Set theme - forced theme, user theme or wiki default """
|
||||
if self.cfg.theme_force:
|
||||
theme_name = self.cfg.theme_default
|
||||
#### DEBUT HACK : Utilisation d'un thème différent pour www.crans.org
|
||||
if self.remote_addr in self.cfg.ip_theme.keys():
|
||||
theme_name = self.cfg.ip_theme[self.remote_addr]
|
||||
#### FIN DU HACK
|
||||
else:
|
||||
theme_name = self.user.theme_name
|
||||
self.loadTheme(theme_name)
|
||||
|
@ -1185,6 +1189,12 @@ space between words. Group page name is not allowed.""") % self.user.name
|
|||
@param url: relative or absolute url, ascii using url encoding.
|
||||
"""
|
||||
url = self.getQualifiedURL(url)
|
||||
|
||||
#### DEBUT HACK : pour le www, on redirige vers du www
|
||||
if self.remote_addr in self.cfg.ip_url_replace.keys():
|
||||
url = url.replace(self.cfg.ip_url_replace[self.remote_addr][0],self.cfg.ip_url_replace[self.remote_addr][1])
|
||||
#### FIN DU HACK
|
||||
|
||||
self.http_headers(["Status: 302 Found", "Location: %s" % url])
|
||||
|
||||
def setHttpHeader(self, header):
|
||||
|
|
|
@ -10,6 +10,7 @@ import string, time, re
|
|||
from MoinMoin import user, util, wikiutil
|
||||
from MoinMoin.util import web, mail, timefuncs
|
||||
from MoinMoin.widget import html
|
||||
from MoinMoin.PageEditor import PageEditor
|
||||
|
||||
_debug = 0
|
||||
|
||||
|
@ -102,6 +103,12 @@ Contact the owner of the wiki, who can enable email.""")
|
|||
except KeyError:
|
||||
return _("Empty user name. Please enter a user name.")
|
||||
|
||||
#### HACK CRANS : oblige les utilistaeurs a créer un WikiNom valide
|
||||
if not wikiutil.isStrictWikiname(theuser.name):
|
||||
return (u"""Nom d'utilisateur invalide {{{'%s'}}}.
|
||||
Le login doit être de la forme WikiNom, WikiPseudo, PrenomNom... (voir ci dessous pour plus d'informations).""" % wikiutil.escape(theuser.name))
|
||||
#### FIN HACK
|
||||
|
||||
# Don't allow users with invalid names
|
||||
if not user.isValidName(self.request, theuser.name):
|
||||
return _("""Invalid user name {{{'%s'}}}.
|
||||
|
@ -117,6 +124,15 @@ space between words. Group page name is not allowed.""") % wikiutil.escape(theus
|
|||
else:
|
||||
newuser = 0
|
||||
|
||||
#### HACK SAUVAGE
|
||||
if newuser and not self.cfg.ip_autorised_create_account(self.request.remote_addr):
|
||||
return _(u"""Création de compte impossible.
|
||||
Pour des raisons de sécurité, la fonction de création d'un compte n'est
|
||||
possible que depuis la zone CRANS.
|
||||
Si vous possédez un compte sur zamok, vous pouvez y exécuter
|
||||
creer_compte_wiki.""")
|
||||
#### FIN DU HACK
|
||||
|
||||
# try to get the password and pw repeat
|
||||
password = form.get('password', [''])[0]
|
||||
password2 = form.get('password2',[''])[0]
|
||||
|
@ -175,6 +191,15 @@ space between words. Group page name is not allowed.""") % wikiutil.escape(theus
|
|||
from MoinMoin import auth
|
||||
auth.setCookie(self.request, theuser)
|
||||
self.request.user = theuser
|
||||
|
||||
#### HACK : création de la page WikiNom
|
||||
try:
|
||||
p = PageEditor(self.request, theuser.name)
|
||||
p.saveText( 'Décrire ici %s' % theuser.name, 0)
|
||||
except:
|
||||
pass
|
||||
#### FIN DU HACK
|
||||
|
||||
return _("Use UserPreferences to change settings of the selected user account")
|
||||
else:
|
||||
return _("Use UserPreferences to change your settings or create an account.")
|
||||
|
|
|
@ -8,7 +8,13 @@
|
|||
"""
|
||||
|
||||
import re
|
||||
from MoinMoin import user
|
||||
from MoinMoin import user, search
|
||||
|
||||
#### HACK SAUVAGE 1/4
|
||||
import sys
|
||||
sys.path.append('/usr/scripts/gestion/')
|
||||
from iptools import is_crans
|
||||
#### FIN DU HACK 1/4
|
||||
|
||||
class AccessControlList:
|
||||
''' Access Control List
|
||||
|
@ -107,7 +113,10 @@ class AccessControlList:
|
|||
Default: ["read", "write", "delete", "admin"]
|
||||
'''
|
||||
|
||||
special_users = ["All", "Known", "Trusted"] # order is important
|
||||
#special_users = ["All", "Known", "Trusted"] # order is important
|
||||
#### HACK SAUVAGE 2/4
|
||||
special_users = ["All", "Known", "Trusted", "Conf"]
|
||||
#### FIN DU HACK 2/4
|
||||
|
||||
def __init__(self, request, lines=[]):
|
||||
"""Initialize an ACL, starting from <nothing>.
|
||||
|
@ -209,6 +218,8 @@ class AccessControlList:
|
|||
return ''.join(["%s%s%s" % (b,l,e) for l in self.acl_lines])
|
||||
|
||||
def _special_All(self, request, name, dowhat, rightsdict):
|
||||
if dowhat == "read" and self.is_page_public(request):
|
||||
return True
|
||||
return rightsdict.get(dowhat)
|
||||
|
||||
def _special_Known(self, request, name, dowhat, rightsdict):
|
||||
|
@ -220,6 +231,11 @@ class AccessControlList:
|
|||
return rightsdict.get(dowhat)
|
||||
return None
|
||||
|
||||
#### HACK SAUVAGE 3/4
|
||||
def _special_Conf(self, request, name, dowhat, rightsdict):
|
||||
return request.cfg.acl_request(self, request, name, dowhat, rightsdict)
|
||||
#### FIN DU HACK 3/4
|
||||
|
||||
def _special_Trusted(self, request, name, dowhat, rightsdict):
|
||||
""" check if user <name> is known AND even has logged in using a password.
|
||||
does not work for subsription emails that should be sent to <user>,
|
||||
|
@ -234,6 +250,21 @@ class AccessControlList:
|
|||
def __ne__(self, other):
|
||||
return self.acl_lines != other.acl_lines
|
||||
|
||||
#### HACK SAUVAGE 4/4
|
||||
def is_page_public(self,request):
|
||||
## On recherche si la page est publique
|
||||
if not request.page:
|
||||
return False
|
||||
this_page = request.page.page_name
|
||||
query = search.QueryParser().parse_query(u'CatégoriePagePublique')
|
||||
page = search.Page(request, this_page)
|
||||
result = query.search(page)
|
||||
if result:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
#### FIN DU HACK 4/4
|
||||
|
||||
|
||||
class ACLStringIterator:
|
||||
""" Iterator for acl string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue