diff --git a/modules/websearch/web/admin/Makefile.am b/modules/websearch/web/admin/Makefile.am
index 989ed2a48..4ffc52817 100644
--- a/modules/websearch/web/admin/Makefile.am
+++ b/modules/websearch/web/admin/Makefile.am
@@ -1,29 +1,32 @@
## $Id$
## 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.
-webappdir = $(WEBDIR)
+webappdir = $(WEBDIR)/admin/websearch
-webapp_DATA=websearchadmin.py
+webapp_DATA= index.html websearchadmin.py
EXTRA_DIST = $(wildcard *.wml)
CLEANFILES = $(bin_SCRIPTS) $(webapp_DATA) *~ *.tmp search.pyc
%.py: %.py.wml ../../../../config/config.wml ../../../../config/configbis.wml
- $(WML) -o $@ $<
\ No newline at end of file
+ $(WML) -o $@ $<
+
+%.html: %.html.wml ../../../../config/config.wml ../../../../config/configbis.wml
+ $(WML) -o\(ALL-LANG_*\)+LANG_EN:$@ $<
diff --git a/modules/websearch/web/admin/Makefile.am b/modules/websearch/web/admin/index.html.wml
similarity index 54%
copy from modules/websearch/web/admin/Makefile.am
copy to modules/websearch/web/admin/index.html.wml
index 989ed2a48..53b54b1d1 100644
--- a/modules/websearch/web/admin/Makefile.am
+++ b/modules/websearch/web/admin/index.html.wml
@@ -1,29 +1,36 @@
## $Id$
## 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.
+## 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.
-webappdir = $(WEBDIR)
+#include "cdspage.wml" \
+ title="WebSearch Admin" \
+ navtrail_previous_links="/admin/
+ This is the gate to the admin area for WebSearch. You need to + login to enter. +
-webapp_DATA=websearchadmin.py - -EXTRA_DIST = $(wildcard *.wml) - -CLEANFILES = $(bin_SCRIPTS) $(webapp_DATA) *~ *.tmp search.pyc - -%.py: %.py.wml ../../../../config/config.wml ../../../../config/configbis.wml - $(WML) -o $@ $< \ No newline at end of file +Updating name ... %s" % c) - res = run_sql("UPDATE collection SET name=%s WHERE name=%s", (nc, c)) - req.write(" done.") - # update dbquery: - req.write("\n
Updating query (%s) ..." % nq) - res = run_sql("UPDATE collection SET dbquery=%s WHERE name=%s", (nq, nc)) - req.write(" done.") - # call reclist, if needed: - if ur: - req.write("\n
Updating reclist cache ...\n") - os.environ['collname'] = c - os.system('%s/webcoll update-reclist "$collname"' % bindir) - res = run_sql("SELECT nbrecs FROM collection WHERE name=%s", (nc,)) - if res: - req.write(" found %s records." % res[0][0]) - if uw: - req.write("\n
Updating web page cache ...\n") - os.environ['collname'] = c - os.system('%s/webcoll update-webpage "$collname"' % bindir) - req.write(" done.") - req.write("\n
Finished.") - req.write(pagefooteronly()) - return "\n" - -## IMPLEMENTATION - -def perform_index(): - """List all collections and the relevant information.""" - out = "" - res = run_sql("SELECT id,name,nbrecs,dbquery FROM collection ORDER BY name ASC") - if res: - out += """
- ID - | -- Name - | -- No. Recs - | -- Query - | -- ACTION - | -
---|---|---|---|---|
%s | %s | %s | %s | Edit |
No collection seem to be defined.""" - return out - -def perform_edit(c): - """Display collection data for editing.""" - out = "
" - res = run_sql("SELECT nbrecs,dbquery FROM collection WHERE name=%s", (c,)) - if res: - c_nbrecs, c_dbquery = res[0][0], res[0][1] - if c_dbquery == None: - c_dbquery = "" - out += """""" - out += """""" - else: - out += "
There is no collection named %s.""" % c
- return out
+def switchscore(req, colID, type, id_1, id_2, ln=cdslang):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_switchscore(colID=colID,
+ ln=ln,
+ type=type,
+ id_1=id_1,
+ id_2=id_2),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifydbquery(req, colID, ln=cdslang, dbquery='', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifydbquery(colID=colID,
+ ln=ln,
+ dbquery=dbquery,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifyrestricted(req, colID, ln=cdslang, rest='', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifyrestricted(colID=colID,
+ ln=ln,
+ rest=rest,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifytranslations(req, colID, ln=cdslang, sel_type='', trans = [], confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifytranslations(colID=colID,
+ ln=ln,
+ sel_type=sel_type,
+ trans=trans,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addcollectiontotree(req, colID, ln=cdslang, add_dad='', add_son='', rtype='', mtype='', callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection Tree",
+ body=wsc.perform_addcollectiontotree(colID=colID,
+ ln=cdslang,
+ add_dad=add_dad,
+ add_son=add_son,
+ rtype=rtype,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ navtrail = navtrail_previous_links,
+ urlargs=req.args,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addcollection(req, colID, ln=cdslang, collname='', dbquery='', rest='', callback="yes", confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection Tree",
+ body=wsc.perform_addcollection(colID=colID,
+ ln=cdslang,
+ collname=collname,
+ dbquery=dbquery,
+ rest=rest,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ navtrail = navtrail_previous_links,
+ urlargs=req.args,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifyrankmethods(req, colID, ln=cdslang, func='', rnkID='', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifyrankmethods(colID=colID,
+ ln=ln,
+ func=func,
+ rnkID=rnkID,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def deletecollection(req, colID, ln=cdslang, confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_deletecollection(colID=colID,
+ ln=ln,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def editcollection(req, colID=1, ln=cdslang, mtype=''):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_editcollection(colID=colID,
+ ln=ln,
+ mtype=mtype),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addoutputformat(req, colID, ln=cdslang, code='', name='', callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_addoutputformat(colID=colID,
+ ln=ln,
+ code=code,
+ name=name,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def showoutputformats(req, colID, ln=cdslang, callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_showoutputformats(colID=colID,
+ ln=ln,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addexistingoutputformat(req, colID, ln=cdslang, frmID=-1, callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_addexistingoutputformat(colID=colID,
+ ln=ln,
+ frmID=frmID,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def deleteoutputformat(req, colID, ln=cdslang, frmID=-1, callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_deleteoutputformat(colID=colID,
+ ln=ln,
+ frmID=frmID,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def removeoutputformat(req, colID, ln=cdslang, frmID='', callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_removeoutputformat(colID=colID,
+ ln=ln,
+ frmID=frmID,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifyoutputformat(req, colID, ln=cdslang, frmID=-1, sel_type='', trans=[], confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifyoutputformat(colID=colID,
+ ln=ln,
+ frmID=frmID,
+ sel_type=sel_type,
+ trans=trans,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifyportalbox(req, colID, ln=cdslang, pbxID=-1, score='', position='', sel_ln='', title='', body='', callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifyportalbox(colID=colID,
+ ln=ln,
+ pbxID=pbxID,
+ score=score,
+ position=position,
+ sel_ln=sel_ln,
+ title=title,
+ body=body,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def removeportalbox(req, colID, ln=cdslang, pbxID='', sel_ln='', callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_removeportalbox(colID=colID,
+ ln=ln,
+ pbxID=pbxID,
+ sel_ln=sel_ln,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addexistingportalbox(req, colID, ln=cdslang, pbxID=-1, score=0, position='', sel_ln='', callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_addexistingportalbox(colID=colID,
+ ln=ln,
+ pbxID=pbxID,
+ score=score,
+ position=position,
+ sel_ln=sel_ln,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return page(title='Authorization failure',
+ uid=uid,
+ body=wsc.adderrorbox('try to login first',
+ datalist=["""You are not a user authorized to perform admin tasks, try to
+ login with another account.""" % (weburl, weburl)]),
+ navtrail= navtrail_previous_links,
+ lastupdated=__lastupdated__)
+
+def deleteportalbox(req, colID, ln=cdslang, pbxID=-1, callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_deleteportalbox(colID=colID,
+ ln=ln,
+ pbxID=pbxID,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def showportalboxes(req, colID, ln=cdslang, callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_showportalboxes(colID=colID,
+ ln=ln,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addportalbox(req, colID, ln=cdslang, title='', body='', callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_addportalbox(colID=colID,
+ ln=ln,
+ title=title,
+ body=body,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifycollectiontree(req, colID, ln=cdslang, move_up='', move_down='', move_from='', move_to='', delete='', rtype='', callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection Tree",
+ body=wsc.perform_modifycollectiontree(colID=colID,
+ ln=ln,
+ move_up=move_up,
+ move_down=move_down,
+ move_from=move_from,
+ move_to=move_to,
+ delete=delete,
+ rtype=rtype,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def index(req, colID=1, ln=cdslang, mtype='', content='', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail()
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection Tree",
+ body=wsc.perform_index(colID=colID,
+ ln=ln,
+ mtype=mtype,
+ content=content,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def error_page(req):
+ return page(title=msg_internal_error[ln],
+ body = create_error_box(req, verbose=verbose, ln=ln),
+ description="%s - Internal Error" % cdsname,
+ keywords="%s, CDSware, Internal Error" % cdsname,
+ language=ln,
+ urlargs=req.args)
+
+def auth_failed(uid, navtrail_previous_links):
+ return page(title='Authorization failure',
+ uid=uid,
+ body=wsc.adderrorbox('try to login first',
+ datalist=["""You are not a user authorized to perform admin tasks, try to
+ login with another account.""" % (weburl, weburl)]),
+ navtrail= navtrail_previous_links,
+ lastupdated=__lastupdated__)
+
+
+
diff --git a/modules/websearch/web/admin/websearchadmin.py.wml b/modules/websearch/web/admin/websearchadmin.py.wml
index d10c6ff0c..2e04b8224 100644
--- a/modules/websearch/web/admin/websearchadmin.py.wml
+++ b/modules/websearch/web/admin/websearchadmin.py.wml
@@ -1,188 +1,613 @@
-## $Id$
-## CDSware WebSearch Administrator tools.
+## Administrator interface for WebSearch
## 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.
## read config variables:
#include "config.wml"
#include "configbis.wml"
-## start Python:
Updating name ... %s" % c)
- res = run_sql("UPDATE collection SET name=%s WHERE name=%s", (nc, c))
- req.write(" done.")
- # update dbquery:
- req.write("\n Updating query (%s) ..." % nq)
- res = run_sql("UPDATE collection SET dbquery=%s WHERE name=%s", (nq, nc))
- req.write(" done.")
- # call reclist, if needed:
- if ur:
- req.write("\n Updating reclist cache ...\n")
- os.environ['collname'] = c
- os.system('%s/webcoll update-reclist "$collname"' % bindir)
- res = run_sql("SELECT nbrecs FROM collection WHERE name=%s", (nc,))
- if res:
- req.write(" found %s records." % res[0][0])
- if uw:
- req.write("\n Updating web page cache ...\n")
- os.environ['collname'] = c
- os.system('%s/webcoll update-webpage "$collname"' % bindir)
- req.write(" done.")
- req.write("\n Finished.")
- req.write(pagefooteronly())
- return "\n"
-
-## IMPLEMENTATION
-
-def perform_index():
- """List all collections and the relevant information."""
- out = ""
- res = run_sql("SELECT id,name,nbrecs,dbquery FROM collection ORDER BY name ASC")
- if res:
- out += """ No collection seem to be defined."""
- return out
-
-def perform_edit(c):
- """Display collection data for editing."""
- out = " There is no collection named %s.""" % c
- return out
+def switchscore(req, colID, type, id_1, id_2, ln=cdslang):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_switchscore(colID=colID,
+ ln=ln,
+ type=type,
+ id_1=id_1,
+ id_2=id_2),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifydbquery(req, colID, ln=cdslang, dbquery='', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifydbquery(colID=colID,
+ ln=ln,
+ dbquery=dbquery,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifyrestricted(req, colID, ln=cdslang, rest='', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifyrestricted(colID=colID,
+ ln=ln,
+ rest=rest,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifytranslations(req, colID, ln=cdslang, sel_type='', trans = [], confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifytranslations(colID=colID,
+ ln=ln,
+ sel_type=sel_type,
+ trans=trans,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addcollectiontotree(req, colID, ln=cdslang, add_dad='', add_son='', rtype='', mtype='', callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection Tree",
+ body=wsc.perform_addcollectiontotree(colID=colID,
+ ln=cdslang,
+ add_dad=add_dad,
+ add_son=add_son,
+ rtype=rtype,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ navtrail = navtrail_previous_links,
+ urlargs=req.args,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addcollection(req, colID, ln=cdslang, collname='', dbquery='', rest='', callback="yes", confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection Tree",
+ body=wsc.perform_addcollection(colID=colID,
+ ln=cdslang,
+ collname=collname,
+ dbquery=dbquery,
+ rest=rest,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ navtrail = navtrail_previous_links,
+ urlargs=req.args,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifyrankmethods(req, colID, ln=cdslang, func='', rnkID='', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifyrankmethods(colID=colID,
+ ln=ln,
+ func=func,
+ rnkID=rnkID,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def deletecollection(req, colID, ln=cdslang, confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_deletecollection(colID=colID,
+ ln=ln,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def editcollection(req, colID=1, ln=cdslang, mtype=''):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_editcollection(colID=colID,
+ ln=ln,
+ mtype=mtype),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addoutputformat(req, colID, ln=cdslang, code='', name='', callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_addoutputformat(colID=colID,
+ ln=ln,
+ code=code,
+ name=name,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def showoutputformats(req, colID, ln=cdslang, callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_showoutputformats(colID=colID,
+ ln=ln,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addexistingoutputformat(req, colID, ln=cdslang, frmID=-1, callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_addexistingoutputformat(colID=colID,
+ ln=ln,
+ frmID=frmID,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def deleteoutputformat(req, colID, ln=cdslang, frmID=-1, callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_deleteoutputformat(colID=colID,
+ ln=ln,
+ frmID=frmID,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def removeoutputformat(req, colID, ln=cdslang, frmID='', callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_removeoutputformat(colID=colID,
+ ln=ln,
+ frmID=frmID,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifyoutputformat(req, colID, ln=cdslang, frmID=-1, sel_type='', trans=[], confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifyoutputformat(colID=colID,
+ ln=ln,
+ frmID=frmID,
+ sel_type=sel_type,
+ trans=trans,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifyportalbox(req, colID, ln=cdslang, pbxID=-1, score='', position='', sel_ln='', title='', body='', callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_modifyportalbox(colID=colID,
+ ln=ln,
+ pbxID=pbxID,
+ score=score,
+ position=position,
+ sel_ln=sel_ln,
+ title=title,
+ body=body,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def removeportalbox(req, colID, ln=cdslang, pbxID='', sel_ln='', callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_removeportalbox(colID=colID,
+ ln=ln,
+ pbxID=pbxID,
+ sel_ln=sel_ln,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addexistingportalbox(req, colID, ln=cdslang, pbxID=-1, score=0, position='', sel_ln='', callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_addexistingportalbox(colID=colID,
+ ln=ln,
+ pbxID=pbxID,
+ score=score,
+ position=position,
+ sel_ln=sel_ln,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return page(title='Authorization failure',
+ uid=uid,
+ body=wsc.adderrorbox('try to login first',
+ datalist=["""You are not a user authorized to perform admin tasks, try to
+ login with another account.""" % (weburl, weburl)]),
+ navtrail= navtrail_previous_links,
+ lastupdated=__lastupdated__)
+
+def deleteportalbox(req, colID, ln=cdslang, pbxID=-1, callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_deleteportalbox(colID=colID,
+ ln=ln,
+ pbxID=pbxID,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def showportalboxes(req, colID, ln=cdslang, callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_showportalboxes(colID=colID,
+ ln=ln,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def addportalbox(req, colID, ln=cdslang, title='', body='', callback='yes', confirm=-1):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection",
+ body=wsc.perform_addportalbox(colID=colID,
+ ln=ln,
+ title=title,
+ body=body,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def modifycollectiontree(req, colID, ln=cdslang, move_up='', move_down='', move_from='', move_to='', delete='', rtype='', callback='yes', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail() + """> Edit Collection Tree """ % (weburl)
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection Tree",
+ body=wsc.perform_modifycollectiontree(colID=colID,
+ ln=ln,
+ move_up=move_up,
+ move_down=move_down,
+ move_from=move_from,
+ move_to=move_to,
+ delete=delete,
+ rtype=rtype,
+ callback=callback,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def index(req, colID=1, ln=cdslang, mtype='', content='', confirm=0):
+ navtrail_previous_links = wsc.getnavtrail()
+
+ try:
+ uid = getUid(req)
+ except MySQLdb.Error, e:
+ return error_page(req)
+
+ if not wsc.check_user(uid):
+ return page(title="Edit Collection Tree",
+ body=wsc.perform_index(colID=colID,
+ ln=ln,
+ mtype=mtype,
+ content=content,
+ confirm=confirm),
+ uid=uid,
+ language=ln,
+ urlargs=req.args,
+ navtrail = navtrail_previous_links,
+ lastupdated=__lastupdated__)
+ else:
+ return auth_failed(uid, navtrail_previous_links)
+
+def error_page(req):
+ return page(title=msg_internal_error[ln],
+ body = create_error_box(req, verbose=verbose, ln=ln),
+ description="%s - Internal Error" % cdsname,
+ keywords="%s, CDSware, Internal Error" % cdsname,
+ language=ln,
+ urlargs=req.args)
+
+def auth_failed(uid, navtrail_previous_links):
+ return page(title='Authorization failure',
+ uid=uid,
+ body=wsc.adderrorbox('try to login first',
+ datalist=["""You are not a user authorized to perform admin tasks, try to
+ login with another account.""" % (weburl, weburl)]),
+ navtrail= navtrail_previous_links,
+ lastupdated=__lastupdated__)
+
+
+
Updating %s ...
""" % c)
- if nc != c:
- req.write("\n
-
-
"""
- else:
- out += """
-
-
- """
- for c_id, c_name, c_nbrecs, c_dbquery in res:
- out += """
- ID
-
-
- Name
-
-
- No. Recs
-
-
- Query
-
-
- ACTION
-
- """ \
- % (c_id, c_name, c_nbrecs, c_dbquery, weburl, urllib.quote_plus(c_name))
- out += """
- %s %s %s %s Edit "
- res = run_sql("SELECT nbrecs,dbquery FROM collection WHERE name=%s", (c,))
- if res:
- c_nbrecs, c_dbquery = res[0][0], res[0][1]
- if c_dbquery == None:
- c_dbquery = ""
- out += """"""
- out += """
"""
- else:
- out += "