def get_menu(datas, socket): menu = None if check_admin(datas, socket, alerte=False): menu = menu_admin(datas, socket) elif check_edit(datas, socket, alerte=False): menu = menu_editor(datas, socket) return menu
def edit_site(self): if not check_admin(self.datas,self.socket): return baseurl=self.datas.url_base if self.path!='/': baseurl+=self.path inputslang="" for code in self.config.langues: titre=self.socket.input_text_value('titre_%s' % code) if not titre: titre='' self.set_propriete("site_titre_%s" % code,titre) keywords=self.socket.input_text_value('keywords_%s' % code) if not keywords: keywords='' self.set_propriete("site_keywords_%s" % code,keywords) description=self.socket.input_text_value('description_%s' % code) if not description: description='' self.set_propriete("site_description_%s" % code,description) self.socket.redirection_http(baseurl, "Action Ok")
def affiche(self): if not check_admin(self.datas, self.socket, False): return typeactu = self.datas.objet_actu.name_class if (typeactu == 0) and (self.datas.objet_actu.action.__name__ != "affiche"): typeactu = -1 active = self.get_propriete("active", "false") posx = self.get_propriete("initx", "0") posy = self.get_propriete("inity", "30") id_user = self.datas.my_session.id_user if id_user > -1: active = get_propriete(self.glob, id_user, "pal_active", active) posx = get_propriete(self.glob, id_user, "pal_initx", posx) posy = get_propriete(self.glob, id_user, "pal_inity", posy) if active != "false": self.socket.send_datas( """<div class="pere_palette"> <div id="palette" class="palette" alt="palette"> Palette </div> <script language="javascript"> jsbox_init_box("palette",%s,%s,120,100,'white'); http_url_datas_to_fct("/%s/in/%s",load_palette); </script> </div> """ % (posx, posy, self.get_name(), typeactu) )
def get_palette(datas, socket, t): palette = None if check_admin(datas, socket, alerte=False): palette = palette_admin(datas, socket, t) elif check_edit(datas, socket, alerte=False): palette = palette_editor(datas, socket, t) return palette
def palette_admin(datas, socket, t): _ = datas._ palette = [[(_("Se deconnecter"), "logout", 1, None), (_("A propos"), "apropos", 1, None)]] if check_admin(datas, socket, alerte=False): palette.extend( [ [ (_("Editer Proprietes"), "editsite", 1, None), (_("Editer Skins"), "editskins", 1, None), (_("Gestion Utilisateurs"), "editusers", 1, None), ] ] ) else: palette.extend([[(_("Editer Proprietes"), "editsite", 1, None), (_("Editer Skins"), "editskins", 1, None)]]) if t == "2": ## TODO Externaliser le palette d'un type d'objet dans sa classe # PAGE palette.extend( [ [ (_("Ajouter une page"), "addpage", 1, None), (_("Editer page"), "editpage", 1, None), (_("Deplacer page"), "movepage", 1, None), (_("Detruire page"), "delpage", 1, None), ], [ (_("Ajouter Texte"), "addtext", 1, None), (_("Ajouter Image"), "addimage", 1, None), (_("Ajouter Fichier"), "addfile", 1, None), (_("Ajouter Galerie"), "addgalerie", 1, None), ], ] ) elif t == "0": # RACINE palette.extend( [ [(_("Ajouter une page"), "addpage", 1, None), (_("Editer page"), "editpage", 1, None)], [ (_("Ajouter Texte"), "addtext", 1, None), (_("Ajouter Image"), "addimage", 1, None), (_("Ajouter Fichier"), "addfile", 1, None), (_("Ajouter Galerie"), "addgalerie", 1, None), ], ] ) elif t == "4": # GALERIE palette.extend( [[(_("Editer propriete"), "editgalinfo", 1, None), (_("Ajouter Element"), "addelemgal", 1, None)]] ) else: # AUTRE pass return palette
def admin(self): if not check_admin(self.datas,self.socket): return _=self.datas._ self.socket.send_datas(_('<h1>Administration </h1>\n')) self.socket.send_datas('<a href="%s/admin/users">%s</a><br />' % (self.datas.url_base,_('Gestion des utilisateurs'))) self.socket.send_datas('<a href="%s/admin/globs">%s</a><br />' % (self.datas.url_base,_('Vue technique des objets')))
def admin_stop(self): if not check_admin(self.datas,self.socket): return _=self.datas._ self.socket.send_datas('<h1>FIN</h1>\n') self.glob.stop_flag=True self.socket.newsoc()
def admin_users_new(self): if not check_admin(self.datas,self.socket): return _=self.datas._ newuser=self.socket.input_text_value('newopenid') self.datas.my_session.set_new_url('/admin/users/') if newuser in self.glob.openids.keys(): redirect_ok(self.socket,self.datas) create_element(self.glob,self.database,40,0,{},{'openid':newuser,}) redirect_ok(self.socket,self.datas)
def delete(self): _=self.datas._ if not check_admin(self.datas,self.socket): self.socket.send_datas(_('connectez vous...')) return self.path_obj=self.path_entier.split('/delete')[0] pathpere=path_pere(self.path_obj) self.fs_svn.trash(self.path_obj) self.datas.my_session.set_new_url(pathpere) redirect_ok(self.socket,self.datas)
def edit(self): _=self.datas._ if not check_admin(self.datas,self.socket): self.socket.send_datas(_('connectez vous...')) return self.path_obj=self.path_entier.split('/edit')[0] typemime=mimetypes.guess_type(self.path_obj)[0] if typemime in self.type_edit: if typemime=='text/css': self.edit_text() else: self.socket.send_datas(_("Type non pris en compte")+" : %s <br />" % typemime)
def edit_text_ok(self): _=self.datas._ if not check_admin(self.datas,self.socket): self.socket.send_datas(_('connectez vous...')) return urlobj="%s/%s" % (self.datas.url_base,self.path_obj) text=self.socket.input_text_value('text') if text: self.fs_svn.trash(self.path_obj) self.fssvn.modif(self.path_obj) pathpere=path_pere(self.path_obj) self.datas.my_session.set_new_url(pathpere) redirect_ok(self.socket,self.datas)
def admin_users(self): if not check_admin(self.datas,self.socket): return _=self.datas._ self.socket.send_datas('<h1>%s</h1>\n' % _('Gestion des utilisateurs')) users=self.glob.utilisateurs self.socket.send_datas('<br /><br /><ul class="liste">') for (id,user) in users.items(): listgroups="(%s)" % ', '.join(user.groupes) self.socket.send_datas('<li>[<a href="%s/admin/users/edit/%s">E</a>] [<a href="%s/admin/users/delete/%s">D</a>]%s %s</li>\n' % (self.datas.url_base,id,self.datas.url_base,id,listgroups,user['proprietes']['openid'])) self.socket.send_datas('</ul>') self.socket.send_datas('<form action="%s/admin/users/new" method="post">' % self.datas.url_base) self.socket.send_datas('%s <input type="text" name="newopenid" value="" />' % _('Nouvel utilisateur : openid')) self.socket.send_datas('<input type="submit" value="%s" />' % _('Valider')) self.socket.send_datas('</form>')
def admin_users_delete(self): if not check_admin(self.datas,self.socket): return _=self.datas._ elem=self.datas.action_params[0] iduser=int(elem) self.datas.my_session.set_new_url('/admin/users/') openid=self.glob.utilisateurs[elem]['proprietes']['openid'] del(self.glob.openids[openid]) del(self.glob.utilisateurs[elem]) for (idg,groupe) in self.glob.groupes.items(): if elem in groupe.responsables: groupe.responsable.remove(elem) if elem in groupe.membres: groupe.membres.remove(elem) detruire_element(self.interfaces,iduser) redirect_ok(self.socket,self.datas)
def admin_users_edit(self): if not check_admin(self.datas,self.socket): return _=self.datas._ elem=self.datas.action_params[0] self.socket.send_datas('<h1>%s %s</h1>\n' % (_('Edition Utilisateur'),elem)) allgroups=self.glob.groupes self.socket.send_datas('<form action="%s/admin/users/valid/edit" method="post">' % self.datas.url_base) self.socket.send_datas('<input type="hidden" name="iduser" value="%s" />' % elem) self.socket.send_datas('%s' % _('Liste des groupes :<br />')) for (idg,groupe) in allgroups.items(): nameg=groupe['proprietes']['nom'] if idg in self.glob.utilisateurs[elem].groupes: checked=' checked ' else: checked=' ' self.socket.send_datas('<input type="checkbox" name="groupe_%s" %s /> %s <br />' % (idg,checked,nameg)) self.socket.send_datas('<input type="submit" value="%s" />' % _('Valider')) self.socket.send_datas('</form>')
def edit_text(self): _=self.datas._ if not check_admin(self.datas,self.socket): self.socket.send_datas(_('connectez vous...')) return txt=self.fssvn.get(self.path_obj) urlobj="%s/%s" % (self.datas.url_base,self.path_obj) html=""" <form class="edittext" action="%s/edit/ok" method="POST"> <textarea name="text"> %s </textarea> <input type="submit" value="%s"> </form> """ % (urlobj,txt,_('Valider')) self.socket.send_datas(html)
def affiche(self): _=self.datas._ self.socket.send_datas('<body><h1>'+_('SERVEUR HTTPDtekio : Repertoires et Fichiers Publics')+'</h1>\n') pathpere=path_pere(self.path_entier) parent=name_from_path(pathpere) if not parent: parent='Racine' self.socket.send_datas(_('Retour')+' : <a href="%s">%s</a> <br />' % (pathpere,parent)) self.socket.send_datas('<br />') self.socket.send_datas(_("Contenu du Repertoire Actuel")+" : %s <br />" % self.path_entier) for elem in self.fs_svn.listdir(self.path_entier): path_obj="%s/%s" % (self.path_entier,elem) urlobj="%s/%s" % (self.datas.url_base,path_obj) admins_action='' if check_admin(self.datas,self.socket): typemime=mimetypes.guess_type(path_obj)[0] if typemime in self.type_edit: admins_action='[<a href="http://%s/edit">E</a>] [<a href="http://%s/delete">D</a>]' % (urlobj,urlobj) self.socket.send_datas('<a href="http://%s">%s</a> %s<br />' % (urlobj,elem,admins_action)) return
def admin_users_valid_edit(self): if not check_admin(self.datas,self.socket): return iduser=int(self.socket.input_text_value('iduser')) for g in self.glob.utilisateurs[iduser].groupes: self.glob.groupes[g].membres.remove(iduser) self.glob.utilisateurs[iduser].groupes=[] self.database.write('del_my_groupes',(iduser,)) listgr=[] for k in self.socket.input_text_value: if k.find('groupe_')!=-1: listgr.append(int(k.split('groupe_')[1])) for gr in listgr: self.database.write('add_liaison',(int(gr),iduser,3)) self.glob.groupes[gr].membres.append(iduser) self.glob.utilisateurs[iduser].groupes.append(gr) self.datas.my_session.set_new_url('/admin/users/') redirect_ok(self.socket,self.datas)
def menu_admin(datas, socket): _ = datas._ classe_actu = datas.objet_actu.__class__.__name__ action_actu = datas.objet_actu.action.__name__ menu = [(_("Tekio"), None, 1, [(_("Se deconnecter"), "logout", 1, None), (_("A propos"), "apropos", 1, None)])] if check_admin(datas, socket, alerte=False): menu.extend( [ ( _("Site"), None, 1, [(_("Editer Proprietes"), "editsite", 1, None), (_("Gestion Utilisateurs"), "editusers", 1, None)], ) ] ) else: menu.extend([(_("Site"), None, 1, [(_("Editer Proprietes"), "editsite", 1, None)])]) if check_admin(datas, socket, alerte=False): if classe_actu == "Skin": menu.extend( [ ( _("Skin"), None, 1, [ (_("Liste Des Skins"), "editskins", 1, None), (_("Generation des couleurs"), "skingencolors", 1, None), (_("Retourche des couleurs"), "skincolors", 1, None), (_("Modification des images"), "skinimages", 1, None), (_("Modification des styles"), "skinstyles", 1, None), (_("Changer la disposition"), "skindisposition", 1, None), ], ) ] ) elif (classe_actu == "Page") or (classe_actu == "Racine"): menu.extend( [ ( _("Skin"), None, 1, [ (_("Liste Des Skins"), "editskins", 1, None), (_("Generation des couleurs"), "skingencolors_%s" % datas.skin_name, 1, None), (_("Retourche des couleurs"), "skincolors_%s" % datas.skin_name, 1, None), (_("Modification des images"), "skinimages_%s" % datas.skin_name, 1, None), (_("Modification des styles"), "skinstyles_%s" % datas.skin_name, 1, None), (_("Changer la disposition"), "skindisposition_%s" % datas.skin_name, 1, None), ], ) ] ) else: menu.extend([(_("Skin"), None, 1, [(_("Liste Des Skins"), "editskins", 1, None)])]) if classe_actu == "Page": ## TODO Externaliser le menu d'un type d'objet dans sa classe # PAGE menu.extend( [ ( _("Page"), None, 1, [ (_("Ajouter une page"), "addpage", 1, None), (_("Editer page"), "editpage", 1, None), (_("Deplacer page"), "movepage", 1, None), (_("Detruire page"), "delpage", 1, None), ], ), ( _("Contenu"), None, 1, [ (_("Activer edition de contenu"), "wikion", 1, None), (_("Ajouter Texte"), "addtext", 1, None), (_("Ajouter Image"), "addimage", 1, None), (_("Ajouter Fichier"), "addfile", 1, None), ], ), ] ) elif (classe_actu == "Racine") and (action_actu == "affiche"): # RACINE menu.extend( [ ( _("Page"), None, 1, [(_("Ajouter une page"), "addpage", 1, None), (_("Editer page"), "editpage", 1, None)], ), ( _("Contenu"), None, 1, [ (_("Activer edition de contenu"), "wikion", 1, None), (_("Ajouter Texte"), "addtext", 1, None), (_("Ajouter Image"), "addimage", 1, None), (_("Ajouter Fichier"), "addfile", 1, None), ], ), ] ) else: # AUTRE pass return menu
def affiche(self): _=self.datas._ if self.datas.my_session.user: self.socket.send_datas('<h1>%s</h1>\n' % _('Compte utilisateur')) self.socket.send_datas('<br /> %s : %s [<a href="%s/user/logout">%s</a>]<br />' % (_('Utilisateur'),self.datas.my_session.user,self.datas.url_base,_('Deconnection'))) pl=self.datas.my_session.langue options_langues='' for l in self.config.langues_interface: selected="" if l==pl: selected=" SELECTED" options_langues+='<option value="%s"%s>%s</option>' % (l,selected,tablang[l]) options_palette="" if check_admin(self.datas,self.socket,alerte=False): id_pal=self.glob.objets[0]['urls'][pl].get('palette') id_user=self.datas.my_session.id_user active=get_propriete(self.glob,id_pal,'active',"false") posx=get_propriete(self.glob,id_pal,'initx','0') posy=get_propriete(self.glob,id_pal,'inity',"30") active=get_propriete(self.glob,id_user,'pal_active',active) posx=get_propriete(self.glob,id_user,'pal_initx',posx) posy=get_propriete(self.glob,id_user,'pal_inity',posy) s1="" s2="" if active=='false': s2=" SELECTED" else: s1=" SELECTED" options_palette=""" <li> <br /> %s <select name="pal_active"> <option value="true" %s>%s</option> <option value="false" %s>%s</option> </select> / %s X : <input type="text" name="pal_initx" value="%s" size="4" /> Y : <input type="text" name="pal_inity" value="%s" size="4" /><br /> </li> """ % (_('Activation de la palette'),s1,_('Activer'),s2,_('Desactiver'), _('Coordonees'),posx,posy) ordre_infos=self.get_propriete('ordre_infos','').split(',') infos=self.get_dico_proprietes('infos') for k in infos.keys(): if not k in ordre_infos: ordre_infos.append(k) infos_html="" pl=self.datas.my_session.langue id_user=self.datas.my_session.id_user for elem in ordre_infos: if elem in infos.keys(): info=infos[elem] type_info="" if type(info)==type({}): type_info=info.keys()[0] info=info[type_info] else: type_info='textr' if type(info)==type({}): langs=info.keys() if 'all' in langs: value=info['all'] elif pl in langs: value=info[pl] elif len(langs)>0: value=info[langs[0]] else: value='' else: value=str(info) if type_info=='textr': if value: infos_html+="<li><br /><p>%s</p></li>" % value if type_info=='textu': uservalue=get_propriete(self.glob,id_user,elem,"") if uservalue: infos_html+="<li><br />" if value: infos_html+=value+" : " infos_html+=uservalue+"</li>" elif type_info=="textw": uservalue=get_propriete(self.glob,id_user,elem,"") infos_html+="""<li><br /> %s : <input type="text" name="%s" value="%s" /></li>""" % (value,elem,uservalue) self.socket.send_datas(""" <form action="%s/user/edit" method="post"> <ul> <li> <br />%s : <select name="monlanguage"> %s </select> </li> %s %s <li> <br /><input type="submit" value="%s"> </li> </ul> </form> """ % ( self.datas.url_base,_("Votre language"),options_langues,options_palette,infos_html,_("Valider"))) else: self.socket.send_datas ( """ <h1>%s</h1> <form action="%s/user/verify" method="post"> <input type="hidden" name="ie" value="e"> <ul> <li> <br />%s : <input type="text" name="openid" value=""> </li> <li> <li> <br /><input type="checkbox" name="autoconnect" value="yes"> %s </li> <br /><input type="submit" value="%s"> </li> </ul> </form> """ % (_('Connection'), self.datas.url_base, _('Identifiant tekio ou Open ID'), _('Se connecter automatiquement la prochaine fois'), _('se connecter')) )