diff --git a/modules/websession/lib/webaccount.py b/modules/websession/lib/webaccount.py index c19694913..b64403c53 100644 --- a/modules/websession/lib/webaccount.py +++ b/modules/websession/lib/webaccount.py @@ -1,421 +1,415 @@ ## $Id$ ## CDSware User account information implementation. Useful for youraccount pages. ## This file is part of the CERN Document Server Software (CDSware). ## Copyright (C) 2002 CERN. ## ## The CDSware is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## The CDSware is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDSware; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ## $Id$ ## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES. ## read config variables: #include "config.wml" #include "configbis.wml" import sys import string import cgi from config import * from webpage import page from dbquery import run_sql from webuser import getUid,isGuestUser, get_user_preferences, set_user_preferences from access_control_admin import acc_findUserRoleActions from access_control_config import CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS, CFG_EXTERNAL_AUTHENTICATION imagesurl = "%s/img" % weburl # perform_info(): display the main features of CDS personalize def perform_info(req): out = "" uid = getUid(req) out += """
The CDS Search offers you a possibility to personalize the interface, to set up your own personal library of documents, or to set up an automatic alert query that would run periodically and would notify you of search results by email.
""" return out def perform_youradminactivities(uid): """Return text for the `Your Admin Activities' box. Analyze whether user UID has some admin roles, and if yes, then print suitable links for the actions he can do. If he's not admin, print a simple non-authorized message.""" if isGuestUser(uid): return """You seem to be the guest user. You have to login first.""" out = "" your_role_actions = acc_findUserRoleActions(uid) your_roles = [] your_admin_activities = [] for (role, action) in your_role_actions: if role not in your_roles: your_roles.append(role) if not your_roles: out += "
- Your Settings
- Set or change your account Email address or password. Specify your preferences about the way the interface looks like.
- Your Searches
- View all the searches you performed during the last 30 days.
- Your Baskets
- With baskets you can define specific collections of items, store interesting records you want to access later or share with others.""" if isGuestUser(uid): out+= warning_guest_user(type="baskets") out += """
- Your Alerts
- Subscribe to a search which will be run periodically by our service. The result can be sent to you via Email or stored in one of your baskets.""" if isGuestUser(uid): out+= warning_guest_user(type="alerts") if cfg_cern_site: out += """
- Your Loans
- Check out book you have on load, submit borrowing requests, etc. Requires CERN ID.""" out += """
You are not authorized to access administrative functions." else: out += "
You seem to be %s. " % string.join(your_roles, ", ")
out += "Here are some interesting web admin links for you:"
# add actions found by the RBAC:
for (role, action) in your_role_actions:
if action not in your_admin_activities:
your_admin_activities.append(action)
# add all actions if user is superadmin, to make sure he'll see all
# (since it is not necessary for the superadmin to be connected to actions in RBAC tables):
if "superadmin" in your_roles:
for action in ["cfgbibformat", "cfgbibrank", "cfgbibindex", "cfgwebaccess", "cfgwebsearch", "cfgwebsubmit"]:
if action not in your_admin_activities:
your_admin_activities.append(action)
# print proposed links:
for action in your_admin_activities:
if action == "cfgbibformat":
out += """
Configure BibFormat""" % weburl
if action == "cfgbibrank":
out += """
Configure BibRank""" % weburl
if action == "cfgbibindex":
out += """
Configure BibIndex""" % weburl
if action == "cfgwebaccess":
out += """
Configure WebAccess""" % weburl
if action == "cfgwebsearch":
out += """
Configure WebSearch""" % weburl
if action == "cfgwebsubmit":
out += """
Configure WebSubmit""" % weburl
out += """
For more admin-level activities, see the complete Admin Area.""" % weburl
return out
# perform_display_account(): display a dynamic page that shows the user's account
def perform_display_account(req,data,bask,aler,sear):
uid = getUid(req)
#your account
if isGuestUser(uid):
user ="guest"
accBody = """You are logged in as guest. You may want to login as a regular user
"""
bask=aler="""The guest users need to register first"""
sear="No queries found"
else:
user = data[0]
accBody ="""You are logged in as %s. You may want to a) logout; b) edit your account settings.
"""%user
out =""
out +=template_account("Your Account",accBody)
#your baskets
out +=template_account("Your Baskets",bask)
out +=template_account("Your Alert Searches",aler)
out +=template_account("Your Searches",sear)
out +=template_account("Your Submissions",
"""You can consult the list of your submissions
and inquire about their status.""" % weburl)
out +=template_account("Your Approvals",
"""You can consult the list of your approvals
with the documents you approved or refereed.""" % weburl)
out +=template_account("Your Administrative Activities", perform_youradminactivities(uid))
return out
# template_account() : it is a template for print each of the options from the user's account
def template_account(title,body):
out =""
out +="""
%s |
---|
%s |
%s |
---|
Deleting your account""" return out ## perform_set(email,password): edit your account parameters, email and password. def perform_set(email,password): uid = run_sql("SELECT id FROM user where email=%s", (email,)) prefs = get_user_preferences(uid[0][0]) CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL = CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS if CFG_EXTERNAL_AUTHENTICATION.has_key(prefs['login_method']) and CFG_EXTERNAL_AUTHENTICATION[prefs['login_method']][1] != True: CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL = 3 text = """
Edit parameters
""" % (CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL >= 2 and "disabled" or "", email, CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL >= 3 and "disabled" or "",password, CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL >= 3 and "disabled" or "", "") if len(CFG_EXTERNAL_AUTHENTICATION) >= 1: uid = run_sql("SELECT id FROM user where email=%s", (email,)) prefs = get_user_preferences(uid[0][0]) current_login_method = prefs['login_method'] text += """""" return text ## create_register_page_box(): register a new account def create_register_page_box(referer=''): text = "" if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS <= 1: text += """Please enter the values of your preference and choose the register button.""" if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS == 1: text += "The account will not be possible to use before it has been verified and activated." elif CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 2: text += """It is not possible to create an account yourself. Contact%s %s |
The CDS Search offers you a possibility to personalize the interface, to set up your own personal library of documents, or to set up an automatic alert query that would run periodically and would notify you of search results by email.
""" return out def perform_youradminactivities(uid): """Return text for the `Your Admin Activities' box. Analyze whether user UID has some admin roles, and if yes, then print suitable links for the actions he can do. If he's not admin, print a simple non-authorized message.""" if isGuestUser(uid): return """You seem to be the guest user. You have to login first.""" out = "" your_role_actions = acc_findUserRoleActions(uid) your_roles = [] your_admin_activities = [] for (role, action) in your_role_actions: if role not in your_roles: your_roles.append(role) if not your_roles: out += "
- Your Settings
- Set or change your account Email address or password. Specify your preferences about the way the interface looks like.
- Your Searches
- View all the searches you performed during the last 30 days.
- Your Baskets
- With baskets you can define specific collections of items, store interesting records you want to access later or share with others.""" if isGuestUser(uid): out+= warning_guest_user(type="baskets") out += """
- Your Alerts
- Subscribe to a search which will be run periodically by our service. The result can be sent to you via Email or stored in one of your baskets.""" if isGuestUser(uid): out+= warning_guest_user(type="alerts") if cfg_cern_site: out += """
- Your Loans
- Check out book you have on load, submit borrowing requests, etc. Requires CERN ID.""" out += """
You are not authorized to access administrative functions." else: out += "
You seem to be %s. " % string.join(your_roles, ", ")
out += "Here are some interesting web admin links for you:"
# add actions found by the RBAC:
for (role, action) in your_role_actions:
if action not in your_admin_activities:
your_admin_activities.append(action)
# add all actions if user is superadmin, to make sure he'll see all
# (since it is not necessary for the superadmin to be connected to actions in RBAC tables):
if "superadmin" in your_roles:
for action in ["cfgbibformat", "cfgbibrank", "cfgbibindex", "cfgwebaccess", "cfgwebsearch", "cfgwebsubmit"]:
if action not in your_admin_activities:
your_admin_activities.append(action)
# print proposed links:
for action in your_admin_activities:
if action == "cfgbibformat":
out += """
Configure BibFormat""" % weburl
if action == "cfgbibrank":
out += """
Configure BibRank""" % weburl
if action == "cfgbibindex":
out += """
Configure BibIndex""" % weburl
if action == "cfgwebaccess":
out += """
Configure WebAccess""" % weburl
if action == "cfgwebsearch":
out += """
Configure WebSearch""" % weburl
if action == "cfgwebsubmit":
out += """
Configure WebSubmit""" % weburl
out += """
For more admin-level activities, see the complete Admin Area.""" % weburl
return out
# perform_display_account(): display a dynamic page that shows the user's account
def perform_display_account(req,data,bask,aler,sear):
uid = getUid(req)
#your account
if isGuestUser(uid):
user ="guest"
accBody = """You are logged in as guest. You may want to login as a regular user
"""
bask=aler="""The guest users need to register first"""
sear="No queries found"
else:
user = data[0]
accBody ="""You are logged in as %s. You may want to a) logout; b) edit your account settings.
"""%user
out =""
out +=template_account("Your Account",accBody)
#your baskets
out +=template_account("Your Baskets",bask)
out +=template_account("Your Alert Searches",aler)
out +=template_account("Your Searches",sear)
out +=template_account("Your Submissions",
"""You can consult the list of your submissions
and inquire about their status.""" % weburl)
out +=template_account("Your Approvals",
"""You can consult the list of your approvals
with the documents you approved or refereed.""" % weburl)
out +=template_account("Your Administrative Activities", perform_youradminactivities(uid))
return out
# template_account() : it is a template for print each of the options from the user's account
def template_account(title,body):
out =""
out +="""
%s |
---|
%s |
%s |
---|
Deleting your account""" return out ## perform_set(email,password): edit your account parameters, email and password. def perform_set(email,password): uid = run_sql("SELECT id FROM user where email=%s", (email,)) prefs = get_user_preferences(uid[0][0]) CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL = CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS if CFG_EXTERNAL_AUTHENTICATION.has_key(prefs['login_method']) and CFG_EXTERNAL_AUTHENTICATION[prefs['login_method']][1] != True: CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL = 3 text = """
Edit parameters
""" % (CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL >= 2 and "disabled" or "", email, CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL >= 3 and "disabled" or "",password, CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL >= 3 and "disabled" or "", "") if len(CFG_EXTERNAL_AUTHENTICATION) >= 1: uid = run_sql("SELECT id FROM user where email=%s", (email,)) prefs = get_user_preferences(uid[0][0]) current_login_method = prefs['login_method'] text += """""" return text ## create_register_page_box(): register a new account def create_register_page_box(referer=''): text = "" if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS <= 1: text += """Please enter the values of your preference and choose the register button.""" if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS == 1: text += "The account will not be possible to use before it has been verified and activated." elif CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 2: text += """It is not possible to create an account yourself. Contact%s %s |