diff --git a/config/configbis.wml.in b/config/configbis.wml.in
index ad8627f43..4cb6c1e3d 100644
--- a/config/configbis.wml.in
+++ b/config/configbis.wml.in
@@ -1,176 +1,179 @@
 ## $Id$
 
 ## DO NOT TOUCH ANY OF THE ``configbis.wml'' AND ``configbis.wml.in''
 ## FILES.  IF YOU DO EDIT THEM, BAD THINGS MAY HAPPEN.  YOU HAVE BEEN
 ## WARNED!
 
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
 ##
 ## CDS Invenio 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.
 ##
 ## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc.,
 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
 ## read autoconf parameters and define new WML tags out of them:
 <define-tag VERSION whitespace=delete>
 @VERSION@
 </define-tag>
 <define-tag WML whitespace=delete>
 @WML@
 </define-tag>
 <define-tag MYSQL whitespace=delete>
 @MYSQL@
 </define-tag>
 <define-tag PHP whitespace=delete>
 @PHP@
 </define-tag>
 <define-tag PYTHON whitespace=delete>
 @PYTHON@
 </define-tag>
 <define-tag BINDIR whitespace=delete>
 @prefix@/bin
 </define-tag>
 <define-tag LIBDIR whitespace=delete>
 @prefix@/lib
 </define-tag>
 <define-tag LOGDIR whitespace=delete>
 @localstatedir@/log
 </define-tag>
 <define-tag ETCDIR whitespace=delete>
 @prefix@/etc
 </define-tag>
 <define-tag LOCALEDIR whitespace=delete>
 @prefix@/share/locale
 </define-tag>
 <define-tag TMPDIR whitespace=delete>
 @localstatedir@/tmp
 </define-tag>
 <define-tag CACHEDIR whitespace=delete>
 @localstatedir@/cache
 </define-tag>
 <define-tag DATADIR whitespace=delete>
 @localstatedir@/data
 </define-tag>
 <define-tag WEBDIR whitespace=delete>
 @localstatedir@/www
 </define-tag>
 <define-tag WEBURL whitespace=delete>
 @WEBURL@
 </define-tag>
+<define-tag HTTPSURL whitespace=delete>
+@HTTPSURL@
+</define-tag>
 <define-tag DBHOST whitespace=delete>
 @DBHOST@
 </define-tag>
 <define-tag DBNAME whitespace=delete>
 @DBNAME@
 </define-tag>
 <define-tag DBUSER whitespace=delete>
 @DBUSER@
 </define-tag>
 <define-tag DBPASS whitespace=delete>
 @DBPASS@
 </define-tag>
 <define-tag LYNX whitespace=delete>
 @LYNX@
 </define-tag>
 <define-tag ACROREAD whitespace=delete>
 @ACROREAD@
 </define-tag>
 <define-tag GZIP whitespace=delete>
 @GZIP@
 </define-tag>
 <define-tag GUNZIP whitespace=delete>
 @GUNZIP@
 </define-tag>
 <define-tag TAR whitespace=delete>
 @TAR@
 </define-tag>
 <define-tag DISTILLER whitespace=delete>
 @PS2PDF@
 </define-tag>
 <define-tag GFILE whitespace=delete>
 @FILE@
 </define-tag>
 <define-tag DJPEG whitespace=delete>
 @DJPEG@
 </define-tag>
 <define-tag CONVERT whitespace=delete>
 @CONVERT@
 </define-tag>
 <define-tag GIFTEXT whitespace=delete>
 @GIFTEXT@
 </define-tag>
 <define-tag JPEGSIZE whitespace=delete>
 @JPEGSIZE@
 </define-tag>
 <define-tag PNMSCALE whitespace=delete>
 @PNMSCALE@
 </define-tag>
 <define-tag PPMQUANT whitespace=delete>
 @PPMQUANT@
 </define-tag>
 <define-tag PPMTOGIF whitespace=delete>
 @PPMTOGIF@
 </define-tag>
 <define-tag GIFINTER whitespace=delete>
 @GIFINTER@
 </define-tag>
 <define-tag GIFRSIZE whitespace=delete>
 @GIFRSIZE@
 </define-tag>
 <define-tag PDFTOTEXT whitespace=delete>
 @PDFTOTEXT@
 </define-tag>
 <define-tag PSTOTEXT whitespace=delete>
 @PSTOTEXT@
 </define-tag>
 <define-tag PSTOASCII whitespace=delete>
 @PSTOASCII@
 </define-tag>
 <define-tag ANTIWORD whitespace=delete>
 @ANTIWORD@
 </define-tag>
 <define-tag CATDOC whitespace=delete>
 @CATDOC@
 </define-tag>
 <define-tag WVTEXT whitespace=delete>
 @WVTEXT@
 </define-tag>
 <define-tag PPTHTML whitespace=delete>
 @PPTHTML@
 </define-tag>
 <define-tag XLHTML whitespace=delete>
 @XLHTML@
 </define-tag>
 <define-tag HTMLTOTEXT whitespace=delete>
 @HTMLTOTEXT@
 </define-tag>
 <define-tag CLISP whitespace=delete>
 @CLISP@
 </define-tag>
 <define-tag CMUCL whitespace=delete>
 @CMUCL@
 </define-tag>
 <define-tag SBCL whitespace=delete>
 @SBCL@
 </define-tag>
 <define-tag GNUPLOT whitespace=delete>
 @GNUPLOT@
 </define-tag>
 
 
 
 
 
 
 
 
diff --git a/configure.ac b/configure.ac
index 8f89b7171..1eb2f8807 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,688 +1,698 @@
 ## $Id$
 ## Purpose: CDS Invenio main configure.ac file.
 ## Note: If you change this file, please run "autoreconf" to regenerate the "configure" script.
 
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
 ##
 ## CDS Invenio 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.
 ##
 ## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc.,
 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
 ## Initialize autoconf and automake:
 AC_INIT(cds-invenio, 0.89.0.20060502, cds.support@cern.ch)
 AM_INIT_AUTOMAKE(cds-invenio, 0.89.0.20060502)
 
 ## Check for install:
 AC_PROG_INSTALL
 
 ## Define WEBURL URL:
 AC_ARG_WITH(weburl, AC_HELP_STRING([--with-weburl], [specify URL where web files will be reached (e.g. http://webserver.domain.com/doc/)]), WEBURL=${withval})
 if test -z "$WEBURL"; then
    AC_MSG_ERROR([
    You have not used the "--with-weburl" argument that should define the corresponding URL where the site will be reached.  
    Example: "--with-weburl=http://webserver.domain.com/doc/".])
 fi   
 
+AC_ARG_WITH(httpsurl, AC_HELP_STRING([--with-httpsurl], [specify URL where HTTPS files will be reached (e.g. https://cdsdev.cern.ch/)]), HTTPSURL=${withval})
+if test -z "${HTTPSURL}"; then
+   HTTPSURL="${WEBURL}"
+   AC_MSG_WARN([
+   You have not specified a secure URL for accessing the site. Authentification will be sent in clear text across the network.
+   ])
+fi   
+
 ## Define DBHOST database host:
 AC_ARG_WITH(dbhost, AC_HELP_STRING([--with-dbhost], [specify DB server (e.g. sqlserver.domain.com)]), DBHOST=${withval})
 if test -z "$DBHOST"; then
    AC_MSG_ERROR([
    You have not used the "--with-dbhost" argument that should define which DB server to use.  
    Example: "--with-dbhost=sqlserver.domain.com".])
 fi   
 
 ## Define DBNAME database name:
 AC_ARG_WITH(dbname, AC_HELP_STRING([--with-dbname], [specify DB name (e.g. cdsinvenio)]), DBNAME=${withval})
 if test -z "$DBNAME"; then
    AC_MSG_ERROR([
    You have not used the "--with-dbname" argument that should define DB name.  
    Example: "--with-dbname=cdsinvenio".])
 fi   
 
 ## Define DBUSER user name:
 AC_ARG_WITH(dbuser, AC_HELP_STRING([--with-dbuser], [specify DB user name (e.g. cdsinvenio)]), DBUSER=${withval})
 if test -z "$DBUSER"; then
    AC_MSG_ERROR([
    You have not used the "--with-dbuser" argument that should define DB user name.  
    Example: "--with-dbuser=cdsinvenio".])
 fi   
 
 ## Define DBPASS user password:
 AC_ARG_WITH(dbpass, AC_HELP_STRING([--with-dbpass], [specify DB user password (e.g. myp1ss)]), DBPASS=${withval})
 if test -z "$DBPASS"; then
    AC_MSG_ERROR([
    You have not used the "--with-dbpass" argument that should define DB user password.  
    Example: "--with-dbpass=myp1ss".])
 fi   
 
 ## Check for gettext support
 AM_GNU_GETTEXT(external)
 AM_GNU_GETTEXT_VERSION(0.14.4)
 
 ## Check for WML:
 AC_PATH_PROG(WML, wml)
 if test -z "$WML"; then
    AC_MSG_ERROR([
    WML (Website META Language) was not found in your PATH.  Please install it first.  
    Available from <http://www.engelschall.com/sw/wml/>.])
 fi
 
 ## Set option -c in WML so that it can work from a separate build tree
 WML="${WML} -c"
 
 ## Check for MySQL client:
 AC_PATH_PROG(MYSQL, mysql)
 if test -z "$MYSQL"; then
    AC_MSG_ERROR([
    MySQL command-line client was not found in your PATH.  Please install it first.
    Available from <http://mysql.com/>.])
 fi
 
 ## Check for Python:
 AC_MSG_CHECKING(for python)
 AC_ARG_WITH(python, AC_HELP_STRING([--with-python], [path to a specific Python binary (optional)]), PYTHON=${withval})
 if test -n "$PYTHON"; then
    AC_MSG_RESULT($PYTHON)
 else
    AC_PATH_PROG(PYTHON, python)
    if test -z "$PYTHON"; then
       AC_MSG_ERROR([
       Python was not found in your PATH.  Please either install it 
       in your PATH or specify --with-python configure option.
       Python is available from <http://python.org/>.])
    fi
 fi
 
 ## Check for Python version and modules:
 AC_MSG_CHECKING(for required Python modules)
 $PYTHON ${srcdir}/configure-tests.py
 if test $? -ne 0; then
    AC_MSG_ERROR([Please fix the above Python problems before continuing.])
 fi
 AC_MSG_RESULT(found)
 
 ## Check for PHP:
 AC_PATH_PROG(PHP, php)
 if test -z "$PHP"; then
    AC_MSG_ERROR([
    PHP standalone command-line executable (i.e. not compiled as Apache module!) 
    was not found in your PATH.  Please install it first.
    Available from <http://www.php.net/manual/en/install.commandline.php>.])
 fi
 
 ## Check for Acrobat Reader:
 AC_PATH_PROG(ACROREAD, acroread)
 if test -z "$ACROREAD"; then
    AC_MSG_WARN([
    Acrobat Reader was not found in your PATH.  It is used in 
    the WebSubmit module for automatic conversion of submitted documents.  
    You can continue without it but you will miss some CDS Invenio 
    functionality.  We recommend you to install it first and to rerun 
    the configure script.  Acrobat Reader is available from
    <http://www.adobe.com/products/acrobat/readstep.html>.])
 fi
 
 ## Check for gzip:
 AC_PATH_PROG(GZIP, gzip)
 if test -z "$GZIP"; then
    AC_MSG_WARN([
    Gzip was not found in your PATH.  It is used in 
    the WebSubmit module to compress the data submitted in an archive.
    You can continue without it but you will miss some CDS Invenio 
    functionality.  We recommend you to install it first and to rerun 
    the configure script.  Gzip is available from
    <http://www.gzip.org/>.])
 fi
 
 ## Check for gunzip:
 AC_PATH_PROG(GUNZIP, gunzip)
 if test -z "$GUNZIP"; then
    AC_MSG_WARN([
    Gunzip was not found in your PATH.  It is used in 
    the WebSubmit module to correctly deal with submitted compressed
    files.
    You can continue without it but you will miss some CDS Invenio 
    functionality.  We recommend you to install it first and to rerun 
    the configure script.  Gunzip is available from
    <http://www.gzip.org/>.])
 fi
 
 ## Check for tar:
 AC_PATH_PROG(TAR, tar)
 if test -z "$TAR"; then
    AC_MSG_WARN([
    Tar was not found in your PATH.  It is used in 
    the WebSubmit module to pack the submitted data into an archive.
    You can continue without it but you will miss some CDS Invenio 
    functionality.  We recommend you to install it first and to rerun 
    the configure script.  Tar is available from
    <ftp://prep.ai.mit.edu/pub/gnu/tar/>.])
 fi
 
 ## Check for ps2pdf:
 AC_PATH_PROG(PS2PDF, ps2pdf)
 if test -z "$PS2PDF"; then
    AC_MSG_WARN([
    ps2pdf was not found in your PATH.  It is used in 
    the WebSubmit module to convert submitted PostScripts into PDF.
    You can continue without it but you will miss some CDS Invenio 
    functionality.  We recommend you to install it first and to rerun 
    the configure script.  PS2PDF is available from
    <http://www.cs.wisc.edu/~ghost/doc/AFPL/6.50/Ps2pdf.htm>.])
 fi
 
 ## Check for pdftotext:
 AC_PATH_PROG(PDFTOTEXT, pdftotext)
 if test -z "$PDFTOTEXT"; then
    AC_MSG_WARN([
    pdftotext was not found in your PATH.  It is used for the fulltext indexation 
    of PDF files.
    You can continue without it but you may miss fulltext searching capability 
    of CDS Invenio.  We recomend you to install it first and to rerun the configure 
    script.  pdftotext is available from <http://www.foolabs.com/xpdf/home.html>. 
    ])
 fi
 
 ## Check for pstotext:
 AC_PATH_PROG(PSTOTEXT, pstotext)
 if test -z "$PSTOTEXT"; then
    AC_MSG_WARN([
    pstotext was not found in your PATH.  It is used for the fulltext indexation 
    of PDF and PostScript files.
    You can continue without it but you may miss fulltext searching capability 
    of CDS Invenio.  We recomend you to install it first and to rerun the configure 
    script.  pstotext is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.
    ])
 fi
 
 ## Check for ps2ascii:
 AC_PATH_PROG(PSTOASCII, ps2ascii)
 if test -z "$PSTOASCII"; then
    AC_MSG_WARN([
    ps2ascii was not found in your PATH.  It is used for the fulltext indexation 
    of PostScript files.
    You can continue without it but you may miss fulltext searching capability 
    of CDS Invenio.  We recomend you to install it first and to rerun the configure 
    script.  ps2ascii is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.
    ])
 fi
 
 ## Check for antiword:
 AC_PATH_PROG(ANTIWORD, antiword)
 if test -z "$ANTIWORD"; then
    AC_MSG_WARN([
    antiword was not found in your PATH.  It is used for the fulltext indexation 
    of Microsoft Word files.
    You can continue without it but you may miss fulltext searching capability 
    of CDS Invenio.  We recomend you to install it first and to rerun the configure 
    script.  antiword is available from <http://www.winfield.demon.nl/index.html>. 
    ])
 fi
 
 ## Check for catdoc:
 AC_PATH_PROG(CATDOC, catdoc)
 if test -z "$CATDOC"; then
    AC_MSG_WARN([
    catdoc was not found in your PATH.  It is used for the fulltext indexation 
    of Microsoft Word files.
    You can continue without it but you may miss fulltext searching capability 
    of CDS Invenio.  We recomend you to install it first and to rerun the configure 
    script.  catdoc is available from <http://www.ice.ru/~vitus/catdoc/index.html>.
    ])
 fi
 
 ## Check for wvText:
 AC_PATH_PROG(WVTEXT, wvText)
 if test -z "$WVTEXT"; then
    AC_MSG_WARN([
    wvText was not found in your PATH.  It is used for the fulltext indexation 
    of Microsoft Word files.
    You can continue without it but you may miss fulltext searching capability 
    of CDS Invenio.  We recomend you to install it first and to rerun the configure 
    script.  wvText is available from <http://sourceforge.net/projects/wvware>.
    ])
 fi     
 
 ## Check for ppthtml:
 AC_PATH_PROG(PPTHTML, ppthtml)
 if test -z "$PPTHTML"; then
    AC_MSG_WARN([
    ppthtml was found in your PATH. It is used for the fulltext indexation 
    of Microsoft PowerPoint files.
    You can continue without it but you may miss fulltext searching capability 
    of CDS Invenio.  We recomend you to install it first and to rerun the configure 
    script.  ppthtml is available from <http://www.xlhtml.org/>.
    ])
 fi
 
 ## Check for xlhtml:
 AC_PATH_PROG(XLHTML, xlhtml)
 if test -z "$XLHTML"; then
    AC_MSG_WARN([
    xlhtml was found in your PATH. It is used for the fulltext indexation 
    of Microsoft Excel files.
    You can continue without it but you may miss fulltext searching capability 
    of CDS Invenio.  We recomend you to install it first and to rerun the configure 
    script.  xlhtml is available from <http://chicago.sourceforge.net/xlhtml/>.
    ])
 fi
 
 ## Check for html2text:
 AC_PATH_PROG(HTMLTOTEXT, html2text)
 if test -z "$HTMLTOTEXT"; then
    AC_MSG_WARN([
    html2text was found in your PATH. It is used for the fulltext indexation 
    of Microsoft PowerPoint and Excel files.
    You can continue without it but you may miss fulltext searching capability 
    of CDS Invenio.  We recomend you to install it first and to rerun the configure 
    script.  html2text is available from <http://userpage.fu-berlin.de/~mbayer/tools/html2text.html>.
    ])
 fi
 
 ## Check for Giftext:
 AC_PATH_PROG(GIFTEXT, giftext)
 if test -z "$GIFTEXT"; then
    AC_MSG_WARN([
    Giftext was not found in your PATH.  It is used in 
    the WebSubmit module to create an icon from a submitted picture.
    You can continue without it but you will miss some CDS Invenio 
    functionality.  We recommend you to install it first and to rerun 
    the configure script.  Giftext is available from
    <http://prtr-13.ucsc.edu/~badger/software/libungif/getting.shtml>.])
 fi
 
 ## Check for file:
 AC_PATH_PROG(FILE, file)
 if test -z "$FILE"; then
    AC_MSG_WARN([
    File was not found in your PATH.  It is used in 
    the WebSubmit module to check the validity of the submitted files.
    You can continue without it but you will miss some CDS Invenio 
    functionality.  We recommend you to install it first and to rerun 
    the configure script.  File is available from
    <ftp://ftp.astron.com/pub/file/>.])
 fi
 
 ## Check for convert:
 AC_PATH_PROG(CONVERT, convert)
 if test -z "$CONVERT"; then
    AC_MSG_WARN([
    Convert was not found in your PATH.  It is used in 
    the WebSubmit module to create an icon from a submitted picture.
    You can continue without it but you will miss some CDS Invenio 
    functionality.  We recommend you to install it first and to rerun 
    the configure script.  Convert is available from
    <http://www.imagemagick.org/>.])
 fi
 
 ## Check for CLISP:
 AC_MSG_CHECKING(for clisp)
 AC_ARG_WITH(clisp, AC_HELP_STRING([--with-clisp], [path to a specific CLISP binary (optional)]), CLISP=${withval})
 if test -n "$CLISP"; then
    AC_MSG_RESULT($CLISP)
 else
    AC_PATH_PROG(CLISP, clisp)
    if test -z "$CLISP"; then
       AC_MSG_WARN([
       GNU CLISP was not found in your PATH.  It is used by the WebStat
       module to produce statistics about CDS Invenio usage.  (Alternatively,
       SBCL or CMUCL can be used instead of CLISP.)
       You can continue without it but you will miss this feature.  We 
       recommend you to install it first (if you don't have neither CMUCL
       nor SBCL) and to rerun the configure script.  
       GNU CLISP is available from <http://clisp.cons.org/>.])
    fi
 fi
 
 ## Check for CMUCL:
 AC_MSG_CHECKING(for cmucl)
 AC_ARG_WITH(cmucl, AC_HELP_STRING([--with-cmucl], [path to a specific CMUCL binary (optional)]), CMUCL=${withval})
 if test -n "$CMUCL"; then
    AC_MSG_RESULT($CMUCL)
 else
    AC_PATH_PROG(CMUCL, cmucl)
    if test -z "$CMUCL"; then
       AC_MSG_CHECKING(for lisp) # CMUCL can also be installed under `lisp' exec name
       AC_PATH_PROG(CMUCL, lisp) 
    fi
    if test -z "$CMUCL"; then   
       AC_MSG_WARN([
       CMUCL was not found in your PATH.  It is used by the WebStat
       module to produce statistics about CDS Invenio usage.  (Alternatively,
       CLISP or SBCL can be used instead of CMUCL.)
       You can continue without it but you will miss this feature.  We 
       recommend you to install it first (if you don't have neither CLISP
       nor SBCL) and to rerun the configure script.  
       CMUCL is available from <http://www.cons.org/cmucl/>.])
    fi    
 fi
 
 ## Check for SBCL:
 AC_MSG_CHECKING(for sbcl)
 AC_ARG_WITH(sbcl, AC_HELP_STRING([--with-sbcl], [path to a specific SBCL binary (optional)]), SBCL=${withval})
 if test -n "$SBCL"; then
    AC_MSG_RESULT($SBCL)
 else
    AC_PATH_PROG(SBCL, sbcl)
    if test -z "$SBCL"; then
       AC_MSG_WARN([
       SBCL was not found in your PATH.  It is used by the WebStat
       module to produce statistics about CDS Invenio usage.  (Alternatively,
       CLISP or CMUCL can be used instead of SBCL.)
       You can continue without it but you will miss this feature.  We 
       recommend you to install it first (if you don't have neither CLISP
       nor CMUCL) and to rerun the configure script.  
       SBCL is available from <http://sbcl.sourceforge.net/>.])
    fi    
 fi
 
 ## Check for gnuplot:
 AC_PATH_PROG(GNUPLOT, gnuplot)
 if test -z "$GNUPLOT"; then
    AC_MSG_WARN([
    Gnuplot was not found in your PATH.  It is used by the BibRank
    module to produce graphs about download and citation history.
    You can continue without it but you will miss these graphs.  We 
    recommend you to install it first and to rerun the configure script.  
    Gnuplot is available from <http://www.gnuplot.info/>.])
 fi
 
 ## Substitute variables:
 AC_SUBST(VERSION)
 AC_SUBST(WML)
 AC_SUBST(MYSQL)
 AC_SUBST(PHP)
 AC_SUBST(PYTHON)
 AC_SUBST(CLIDIR)
 AC_SUBST(WEBURL)
+AC_SUBST(HTTPSURL)
 AC_SUBST(DBHOST)
 AC_SUBST(DBNAME)
 AC_SUBST(DBUSER)
 AC_SUBST(DBPASS)
 AC_SUBST(PDFTOTEXT)
 AC_SUBST(PSTOTEXT)
 AC_SUBST(PSTOASCII)
 AC_SUBST(ANTIWORD)
 AC_SUBST(CATDOC)
 AC_SUBST(WVTEXT)
 AC_SUBST(PPTHTML)
 AC_SUBST(XLHTML)
 AC_SUBST(HTMLTOTEXT)
 AC_SUBST(localstatedir, `eval echo "${localstatedir}"`)
 AC_SUBST(CACHEDIR)
 AC_SUBST(CLISP)
 AC_SUBST(CMUCL)
 AC_SUBST(SBCL)
 AC_SUBST(GNUPLOT)
 AC_SUBST(DJPEG)
 AC_SUBST(CONVERT)
 AC_SUBST(GIFTEXT)
 AC_SUBST(JPEGSIZE)
 AC_SUBST(PNMSCALE)
 AC_SUBST(PPMQUANT)
 AC_SUBST(PPMTOGIF)
 AC_SUBST(GIFINTER)
 AC_SUBST(GIFRSIZE)
 
 ## Define output files:
 AC_CONFIG_FILES([config.nice  \
 	  Makefile \
           po/Makefile.in \
 	  config/Makefile \
 	  config/configbis.wml \
 	  modules/Makefile \
 	  modules/bibconvert/Makefile \
 	  modules/bibconvert/bin/Makefile \
 	  modules/bibconvert/bin/bibconvert \
 	  modules/bibconvert/doc/Makefile \
 	  modules/bibconvert/doc/admin/Makefile \
 	  modules/bibconvert/doc/hacking/Makefile \
 	  modules/bibconvert/etc/Makefile \
 	  modules/bibconvert/lib/Makefile \
 	  modules/bibmatch/Makefile \
 	  modules/bibmatch/bin/Makefile \
 	  modules/bibmatch/bin/bibmatch \
 	  modules/bibmatch/doc/Makefile \
 	  modules/bibmatch/doc/admin/Makefile \
 	  modules/bibmatch/etc/Makefile \
 	  modules/bibmatch/lib/Makefile \
 	  modules/bibedit/Makefile \
 	  modules/bibedit/bin/Makefile \
 	  modules/bibedit/bin/refextract \
 	  modules/bibedit/bin/xmlmarclint \
 	  modules/bibedit/doc/Makefile \
 	  modules/bibedit/doc/admin/Makefile \
 	  modules/bibedit/doc/hacking/Makefile \
 	  modules/bibedit/etc/Makefile \
 	  modules/bibedit/lib/Makefile \
 	  modules/bibedit/web/Makefile \
 	  modules/bibedit/web/admin/Makefile \
 	  modules/bibformat/Makefile \
 	  modules/bibformat/bin/Makefile \
 	  modules/bibformat/bin/bibformat \
 	  modules/bibformat/bin/bibreformat \
 	  modules/bibformat/doc/Makefile \
 	  modules/bibformat/doc/admin/Makefile \
 	  modules/bibformat/doc/hacking/Makefile \
 	  modules/bibformat/lib/Makefile \
 	  modules/bibformat/lib/core/Makefile \
 	  modules/bibformat/lib/common/Makefile \
 	  modules/bibformat/web/Makefile \
 	  modules/bibformat/web/admin/Makefile \
 	  modules/bibharvest/Makefile \
 	  modules/bibharvest/bin/Makefile \
 	  modules/bibharvest/bin/bibharvest \
 	  modules/bibharvest/bin/oaiharvest \
 	  modules/bibharvest/bin/oaiarchive \
 	  modules/bibharvest/doc/Makefile \
 	  modules/bibharvest/doc/admin/Makefile \
 	  modules/bibharvest/doc/hacking/Makefile \
 	  modules/bibharvest/lib/Makefile \
 	  modules/bibharvest/web/Makefile \
 	  modules/bibharvest/web/admin/Makefile \
 	  modules/bibclassify/Makefile
 	  modules/bibclassify/bin/Makefile
 	  modules/bibclassify/bin/bibclassify
 	  modules/bibclassify/doc/Makefile \
 	  modules/bibclassify/doc/admin/Makefile \
 	  modules/bibclassify/doc/hacking/Makefile \
 	  modules/bibclassify/etc/Makefile
 	  modules/bibclassify/lib/Makefile
 	  modules/bibindex/Makefile \
 	  modules/bibindex/bin/Makefile \
 	  modules/bibindex/bin/bibindex \
 	  modules/bibindex/bin/bibstat \
 	  modules/bibindex/doc/Makefile \
 	  modules/bibindex/doc/admin/Makefile \
 	  modules/bibindex/doc/hacking/Makefile \
 	  modules/bibindex/lib/Makefile \
 	  modules/bibindex/web/Makefile \
 	  modules/bibindex/web/admin/Makefile \
 	  modules/bibrank/Makefile \
 	  modules/bibrank/bin/Makefile \
 	  modules/bibrank/bin/bibrank \
 	  modules/bibrank/bin/bibrankgkb \
 	  modules/bibrank/doc/Makefile \
 	  modules/bibrank/doc/admin/Makefile \
 	  modules/bibrank/doc/hacking/Makefile \
 	  modules/bibrank/etc/Makefile \
 	  modules/bibrank/etc/bibrankgkb.cfg \
 	  modules/bibrank/etc/demo_jif.cfg \
 	  modules/bibrank/etc/template_single_tag_rank_method.cfg \
 	  modules/bibrank/lib/Makefile \
 	  modules/bibrank/web/Makefile \
 	  modules/bibrank/web/admin/Makefile \
 	  modules/bibsched/Makefile \
 	  modules/bibsched/bin/Makefile \
 	  modules/bibsched/bin/bibsched \
 	  modules/bibsched/bin/bibtaskex \
 	  modules/bibsched/doc/Makefile \
 	  modules/bibsched/doc/admin/Makefile \
 	  modules/bibsched/doc/hacking/Makefile \
 	  modules/bibupload/Makefile \
 	  modules/bibupload/bin/Makefile \
 	  modules/bibupload/bin/bibupload \
 	  modules/bibupload/doc/Makefile \
 	  modules/bibupload/doc/admin/Makefile \
 	  modules/bibupload/doc/hacking/Makefile \
 	  modules/elmsubmit/Makefile \
 	  modules/elmsubmit/bin/Makefile \
 	  modules/elmsubmit/bin/elmsubmit \
 	  modules/elmsubmit/doc/Makefile \
 	  modules/elmsubmit/doc/admin/Makefile \
 	  modules/elmsubmit/doc/hacking/Makefile \
 	  modules/elmsubmit/etc/Makefile \
 	  modules/elmsubmit/etc/elmsubmit.cfg \
 	  modules/elmsubmit/lib/Makefile \
 	  modules/elmsubmit/lib/magic/Makefile \
 	  modules/miscutil/Makefile \
 	  modules/miscutil/bin/Makefile \
 	  modules/miscutil/bin/dbexec \
 	  modules/miscutil/bin/dbtest \
 	  modules/miscutil/bin/testsuite \
 	  modules/miscutil/lib/Makefile \
 	  modules/miscutil/demo/Makefile \
 	  modules/miscutil/sql/Makefile \
 	  modules/miscutil/web/Makefile \
 	  modules/miscutil/doc/Makefile \
 	  modules/miscutil/doc/hacking/Makefile \
 	  modules/webaccess/Makefile \
 	  modules/webaccess/bin/Makefile \
 	  modules/webaccess/bin/authaction \
 	  modules/webaccess/bin/webaccessadmin \
 	  modules/webaccess/doc/Makefile \
 	  modules/webaccess/doc/admin/Makefile \
 	  modules/webaccess/doc/hacking/Makefile \
 	  modules/webaccess/lib/Makefile \
 	  modules/webaccess/web/Makefile \
 	  modules/webaccess/web/admin/Makefile \
 	  modules/webalert/Makefile \
 	  modules/webalert/bin/Makefile \
 	  modules/webalert/bin/alertengine \
 	  modules/webalert/doc/Makefile \
 	  modules/webalert/doc/admin/Makefile \
 	  modules/webalert/doc/hacking/Makefile \
 	  modules/webalert/lib/Makefile \
 	  modules/webalert/web/Makefile \
 	  modules/webhelp/Makefile \
 	  modules/webhelp/web/Makefile \
 	  modules/webhelp/web/hacking/Makefile \
 	  modules/webhelp/web/admin/Makefile \
 	  modules/webhelp/web/admin/howto/Makefile \
 	  modules/websearch/Makefile \
 	  modules/websearch/bin/Makefile \
 	  modules/websearch/bin/webcoll \
 	  modules/websearch/doc/Makefile \
 	  modules/websearch/doc/admin/Makefile \
 	  modules/websearch/doc/hacking/Makefile \
 	  modules/websearch/lib/Makefile \
 	  modules/websearch/web/Makefile \
 	  modules/websearch/web/admin/Makefile \
 	  modules/websession/Makefile \
 	  modules/websession/bin/Makefile \
 	  modules/websession/doc/Makefile \
 	  modules/websession/doc/admin/Makefile \
 	  modules/websession/doc/hacking/Makefile \
 	  modules/websession/lib/Makefile \
 	  modules/websession/web/Makefile \
 	  modules/webstat/Makefile \
 	  modules/webstat/bin/Makefile \
 	  modules/webstat/bin/webstat \
 	  modules/webstat/doc/Makefile \
 	  modules/webstat/doc/admin/Makefile \
 	  modules/webstat/doc/hacking/Makefile \
 	  modules/webstat/etc/Makefile \
 	  modules/webstat/lib/Makefile \
 	  modules/webstyle/Makefile \
 	  modules/webstyle/css/Makefile \
 	  modules/webstyle/doc/Makefile \
 	  modules/webstyle/doc/admin/Makefile \
 	  modules/webstyle/doc/hacking/Makefile \
 	  modules/webstyle/img/Makefile \
 	  modules/webstyle/lib/Makefile \
 	  modules/webcomment/Makefile \
 	  modules/webcomment/doc/Makefile \
 	  modules/webcomment/doc/admin/Makefile \
 	  modules/webcomment/doc/hacking/Makefile \
 	  modules/webcomment/lib/Makefile \
 	  modules/webcomment/web/Makefile \
 	  modules/webcomment/web/admin/Makefile \
 	  modules/webbasket/Makefile \
 	  modules/webbasket/doc/Makefile \
 	  modules/webbasket/doc/admin/Makefile \
 	  modules/webbasket/doc/hacking/Makefile \
 	  modules/webbasket/lib/Makefile \
 	  modules/webbasket/web/Makefile \
 	  modules/webmessage/Makefile \
 	  modules/webmessage/bin/Makefile \
 	  modules/webmessage/bin/webmessageadmin \
 	  modules/webmessage/doc/Makefile \
 	  modules/webmessage/doc/admin/Makefile \
 	  modules/webmessage/doc/hacking/Makefile \
 	  modules/webmessage/lib/Makefile \
 	  modules/webmessage/web/Makefile \
 	  modules/websubmit/Makefile \
 	  modules/websubmit/bin/Makefile \
 	  modules/websubmit/bin/thumbmaker \
 	  modules/websubmit/etc/Makefile \
 	  modules/websubmit/etc/bibconvert/Makefile \
 	  modules/websubmit/etc/bibconvert/KB/Makefile \
 	  modules/websubmit/etc/bibconvert/config/Makefile \
 	  modules/websubmit/etc/bibconvert/config/EDSPICTcreate.tpl \
 	  modules/websubmit/etc/bibconvert/config/EDSRPICTcreate.tpl \
 	  modules/websubmit/etc/bibconvert/config/EDSTEXTcreate.tpl \
 	  modules/websubmit/etc/bibconvert/config/EDSRTEXTcreate.tpl \
 	  modules/websubmit/doc/Makefile \
 	  modules/websubmit/doc/admin/Makefile \
 	  modules/websubmit/doc/hacking/Makefile \
 	  modules/websubmit/lib/Makefile \
 	  modules/websubmit/lib/functions/Makefile \
 	  modules/websubmit/web/Makefile \
 	  modules/websubmit/web/admin/Makefile \
 	  ])
 
 AC_CONFIG_COMMANDS(.wmlrc, [
 cat<<EOF>.wmlrc
 -Iconfig -I${srcdir}/config
 EOF
 ])
 
 ## Finally, write output files:
 AC_OUTPUT
 
 ## Write help:
 AC_MSG_RESULT([****************************************************************************])
 AC_MSG_RESULT([** Your CDS Invenio installation is now ready                             **]) 
 AC_MSG_RESULT([** for building.  You have entered the following parameters:              **]) 
 AC_MSG_RESULT([**   - CDS Invenio main install directory: ${prefix}])
 AC_MSG_RESULT([**   - Web home URL: $WEBURL])
+AC_MSG_RESULT([**   - Secure URL: $HTTPSURL])
 AC_MSG_RESULT([**   - DB server: $DBHOST])
 AC_MSG_RESULT([**   - DB name: $DBNAME])
 AC_MSG_RESULT([**   - DB username: $DBUSER])
 AC_MSG_RESULT([**   - DB password: $DBPASS])
 AC_MSG_RESULT([**   - Python executable: $PYTHON])
 AC_MSG_RESULT([**   - CLISP executable: $CLISP])
 AC_MSG_RESULT([**   - CMUCL executable: $CMUCL])
 AC_MSG_RESULT([**   - SBCL executable: $SBCL])
 AC_MSG_RESULT([** Here are the steps to continue the building process:                   **])
 AC_MSG_RESULT([**   1) Customize self-explanatory config file './config/config.wml'.     **])
 AC_MSG_RESULT([**   2) Type 'make' to build your customized CDS Invenio installation.    **])
 AC_MSG_RESULT([**   3) Type 'make create-tables' if you have not created tables before.  **])
 AC_MSG_RESULT([**   4) Type 'make install' to install the system.                        **])
 AC_MSG_RESULT([**   5) Type 'make create-demo-site' to install and test the demo site.   **])
 AC_MSG_RESULT([** Good luck, and thanks for choosing CDS Invenio.                        **])
 AC_MSG_RESULT([**              -- CDS Development Group <cds.support@cern.ch>            **])
 AC_MSG_RESULT([****************************************************************************])
 
 ## end of file
diff --git a/modules/miscutil/lib/config.py.wml b/modules/miscutil/lib/config.py.wml
index b5b7d77f9..7ea03fdb0 100644
--- a/modules/miscutil/lib/config.py.wml
+++ b/modules/miscutil/lib/config.py.wml
@@ -1,177 +1,178 @@
 ## $Id$
 ## CDS Invenio config file, to be read by all Python programs.
 
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
 ##
 ## CDS Invenio 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.
 ##
 ## CDS Invenio 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 CDS Invenio; 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:
 <protect>## -*- coding: utf-8 -*-</protect>
 <protect>## $Id$</protect>
 <protect>## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDS Invenio WML SOURCES.</protect>
 """CDS Invenio config file, to be read by all Python programs."""
 
 ## fill all the generally-interesting config variables from WML:
 cdsname = "<CDSNAME>"
 cdslang = "<CDSLANG>"
 supportemail = "<SUPPORTEMAIL>"
 adminemail = "<ADMINEMAIL>"
 alertengineemail = "<ALERTENGINEEMAIL>"
 webdir = "<WEBDIR>"
 weburl = "<WEBURL>"
+httpsurl = "<HTTPSURL>"
 bindir = "<BINDIR>"
 pylibdir = "<LIBDIR>/python"
 cachedir = "<CACHEDIR>"
 logdir = "<LOGDIR>"
 tmpdir = "<TMPDIR>"
 etcdir = "<ETCDIR>"
 version = "<VERSION>"
 cfg_template_skin = "<CFG_TEMPLATE_SKIN>"
 localedir = "<LOCALEDIR>"
 
 ## intl versions of CDSNAME of this installation:
 cdsnameintl = {}
 <de>cdsnameintl['de'] = "<CDSNAMEINTL>"</de>
 <en>cdsnameintl['en'] = "<CDSNAMEINTL>"</en>
 <es>cdsnameintl['es'] = "<CDSNAMEINTL>"</es>
 <ca>cdsnameintl['ca'] = "<CDSNAMEINTL>"</ca>
 <pt>cdsnameintl['pt'] = "<CDSNAMEINTL>"</pt>
 <fr>cdsnameintl['fr'] = "<CDSNAMEINTL>"</fr>
 <it>cdsnameintl['it'] = "<CDSNAMEINTL>"</it>
 <ru>cdsnameintl['ru'] = "<CDSNAMEINTL>"</ru>
 <sk>cdsnameintl['sk'] = "<CDSNAMEINTL>"</sk>
 <cs>cdsnameintl['cs'] = "<CDSNAMEINTL>"</cs>
 <no>cdsnameintl['no'] = "<CDSNAMEINTL>"</no>
 <sv>cdsnameintl['sv'] = "<CDSNAMEINTL>"</sv>
 <el>cdsnameintl['el'] = "<CDSNAMEINTL>"</el>
 <uk>cdsnameintl['uk'] = "<CDSNAMEINTL>"</uk>
 <ja>cdsnameintl['ja'] = "<CDSNAMEINTL>"</ja>
 <pl>cdsnameintl['pl'] = "<CDSNAMEINTL>"</pl>
 
 ## Apache password/group files:
 cfg_apache_password_file = "<CFG_APACHE_PASSWORD_FILE>"
 cfg_apache_group_file = "<CFG_APACHE_GROUP_FILE>"
 
 ## are we running CERN specifics?
 cfg_cern_site = <CFG_CERN_SITE>
 
 ## page elements:
 cdspageheader = """<CDSPAGEHEADER>"""
 cdspageboxlefttop = """<CDSPAGEBOXLEFTTOP>"""
 cdspageboxleftbottom = """<CDSPAGEBOXLEFTBOTTOM>"""
 cdspageboxrighttop = """<CDSPAGEBOXRIGHTTOP>"""
 cdspageboxrightbottom = """<CDSPAGEBOXRIGHTBOTTOM>"""
 cdspagefooter = """<CDSPAGEFOOTER>"""
 
 ## helper programs:
 pdftotext = "<PDFTOTEXT>"
 pstotext = "<PSTOTEXT>"
 pstoascii = "<PSTOASCII>"
 antiword = "<ANTIWORD>"
 catdoc = "<CATDOC>"
 wvtext = "<WVTEXT>"
 ppthtml = "<PPTHTML>"
 xlhtml = "<XLHTML>"
 htmltotext = "<HTMLTOTEXT>"
 gfile = "<GFILE>"
 gzip = "<GZIP>"
 tar = "<TAR>"
 gunzip = "<GUNZIP>"
 acroread = "<ACROREAD>"
 distiller = "<DISTILLER>"
 convert = "<CONVERT>"
 
 ## for search_engine_config:
 cfg_max_recID = <CFG_MAX_RECID> 
 cfg_instant_browse = <CFG_NB_LATEST_ADDITIONS>
 cfg_author_et_al_threshold = <CFG_AUTHOR_ET_AL_THRESHOLD> 
 cfg_search_cache_size = <CFG_SEARCH_CACHE_SIZE> 
 cfg_nb_records_to_sort = <CFG_NB_RECORDS_TO_SORT> 
 cfg_call_bibformat = <CFG_CALL_BIBFORMAT>
 cfg_use_aleph_sysnos = <CFG_USE_OLD_SYSNOS> 
 cfg_fields_convert = <CFG_FIELDS_CONVERT>
 cfg_simplesearch_pattern_box_width = <CFG_SIMPLESEARCH_PATTERN_BOX_WIDTH> 
 cfg_advancedsearch_pattern_box_width = <CFG_ADVANCEDSEARCH_PATTERN_BOX_WIDTH> 
 cfg_narrow_search_show_grandsons = <CFG_NARROW_SEARCH_SHOW_GRANDSONS> 
 cfg_oaiidtag = "<OAIIDTAG>" 
 cfg_create_similarly_named_authors_link_box = <CFG_CREATE_SIMILARLY_NAMED_AUTHORS_LINK_BOX>
 cfg_google_box = <CFG_GOOGLE_BOX>
 cfg_google_box_servers = <CFG_GOOGLE_BOX_SERVERS>
 
 ## for websubmit_config:
 images = "<WEBURL>/img"
 urlpath = "<WEBURL>"
 accessurl = "<WEBURL>/search.py"
 counters = "<CFG_SUBMIT_COUNTER>"
 storage = "<CFG_SUBMIT_DIR>"
 filedir	 = "<CFG_FILE_DIR>"
 filedirsize = <CFG_FILE_DIR_SIZE>
 bibupload = "<BINDIR>/bibupload"
 bibformat = "<BINDIR>/bibformat"
 bibwords = "<BINDIR>/bibwords"
 bibconvert = "<BINDIR>/bibconvert"
 bibconvertconf = "<ETCDIR>/bibconvert/config"
 htdocsurl = "<WEBURL>"
 
 ## for access_control_config:
 CFG_ACCESS_CONTROL_LEVEL_SITE = <CFG_ACCESS_CONTROL_LEVEL_SITE>
 CFG_ACCESS_CONTROL_LEVEL_GUESTS = <CFG_ACCESS_CONTROL_LEVEL_GUESTS>
 CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS = <CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS>
 CFG_ACCESS_CONTROL_LIMIT_REGISTRATION_TO_DOMAIN = "<CFG_ACCESS_CONTROL_LIMIT_REGISTRATION_TO_DOMAIN>"
 CFG_ACCESS_CONTROL_NOTIFY_ADMIN_ABOUT_NEW_ACCOUNTS = <CFG_ACCESS_CONTROL_NOTIFY_ADMIN_ABOUT_NEW_ACCOUNTS>
 CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT = <CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT>
 CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_ACTIVATION = <CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_ACTIVATION>
 CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_DELETION = <CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_DELETION>
 
 ## for oai_repository_config:
 oaiidprefix = "<OAIIDPREFIX>"
 oaisampleidentifier = "<OAISAMPLEIDENTIFIER>"
 oaiidentifydescription = """<OAIIDENTIFYDESCRIPTION>"""
 oaiidfield = "<OAIIDTAG>"
 oaisetfield = "<OAISETTAG>"
 oaideleted = "<OAIDELETEDPOLICY>"
 oai_rt_expire = <OAIEXPIRE>
 oai_sleep = <OAISLEEP>
 nb_records_in_resume = <OAILOAD>
 nb_identifiers_in_resume = <OAILOAD>
 
 ## for bibindex_engine_config:
 cfg_bibindex_fulltext_index_local_files_only = <CFG_BIBINDEX_FULLTEXT_INDEX_LOCAL_FILES_ONLY>
 cfg_bibindex_stemmer_default_language = "<CFG_BIBINDEX_STEMMER_DEFAULT_LANGUAGE>"
 cfg_bibindex_remove_stopwords = <CFG_BIBINDEX_REMOVE_STOPWORDS>
 cfg_bibindex_path_to_stopwords_file = "<CFG_BIBINDEX_PATH_TO_STOPWORDS_FILE>"
 cfg_bibindex_chars_alphanumeric_separators = r"[<CFG_BIBINDEX_CHARS_ALPHANUMERIC_SEPARATORS>]"
 cfg_bibindex_chars_punctuation = r"[<CFG_BIBINDEX_CHARS_PUNCTUATION>]"
 cfg_bibindex_remove_html_markup = <CFG_BIBINDEX_REMOVE_HTML_MARKUP>
 cfg_bibindex_min_word_length = <CFG_BIBINDEX_MIN_WORD_LENGTH>
 cfg_bibindex_urlopener_username = "<CFG_BIBINDEX_URLOPENER_USERNAME>"
 cfg_bibindex_urlopener_password = "<CFG_BIBINDEX_URLOPENER_PASSWORD>"
 
 ## for commenting:
 cfg_webcomment_allow_comments = 1
 cfg_webcomment_allow_reviews = 1
 cfg_webcomment_nb_reports_before_send_email_to_admin = 5
 cfg_webcomment_nb_comments_in_detailed_view = 1
 cfg_webcomment_nb_reviews_in_detailed_view = 1
 cfg_webcomment_admin_notification_level = 1
 cfg_webcomment_timelimit_processing_comments_in_seconds = 20
 cfg_webcomment_timelimit_processing_reviews_in_seconds = 20
 cfg_webcomment_timelimit_vote_validity_in_days = 365
 cfg_webcomment_timelimit_report_validity_in_days = 100
diff --git a/modules/webbasket/lib/webbasket_templates.py b/modules/webbasket/lib/webbasket_templates.py
index 5ff836e51..02c5ff9a8 100644
--- a/modules/webbasket/lib/webbasket_templates.py
+++ b/modules/webbasket/lib/webbasket_templates.py
@@ -1,1368 +1,1368 @@
 ## $Id$
 
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
 ##
 ## CDS Invenio 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.
 ##
 ## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc.,
 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
 from invenio.messages import gettext_set_language
 from invenio.webbasket_config import cfg_webbasket_categories, \
                                      cfg_webbasket_share_levels
 from invenio.webmessage_mailutils import email_quoted_txt2html, email_quote_txt
-from invenio.config import weburl, cdslang
+from invenio.config import weburl, httpsurl, cdslang
 from invenio.textutils import indent_text
 from invenio.webuser import get_user_info
 from invenio.dateutils import convert_datetext_to_dategui
 
 class Template:
     
     ######################## General interface ###############################
 
     def tmpl_display(self,
                      topicsbox='',
                      baskets_infobox='',
                      baskets=[],
                      selected_category=cfg_webbasket_categories['PRIVATE'],
                      nb_groups=0,
                      nb_external_baskets=0,
                      ln=cdslang):
         """Generic display. takes formatted baskets, infobox and topicsbox, 
         add tabs and returns complete interface"""
         _ = gettext_set_language(ln)
         if type(baskets) not in (list, tuple):
             baskets = [baskets]
         tabs = self.__create_tabs(selected_category, nb_groups, nb_external_baskets, ln)
         
         out = """
 <div id="bskcontainer">
   <div id="bsktabs">%s
   </div>
   <div id="bskcontent">""" % indent_text(tabs, 2)
         if topicsbox:
             out += indent_text(topicsbox, 6)
         out += """
     <div id="bskbaskets">"""
         if baskets_infobox:
             out += """
       <div id="bskinfos">%s
       </div>""" % indent_text(baskets_infobox, 5)
         for basket in baskets:
             out += indent_text(basket, 4)
         out += """
     </div>
   </div>
 </div>"""
         return out
     
     def __create_tabs(self,
                       selected_category=cfg_webbasket_categories['PRIVATE'],
                       nb_groups=0,
                       nb_external_baskets=0,
                       ln=cdslang):
         """private function, display tabs (private baskets, group baskets, other's basket)."""
         _ = gettext_set_language(ln)
         selected = ' id="bsktab_selected"'
         private = cfg_webbasket_categories['PRIVATE']
         group = cfg_webbasket_categories['GROUP']
         external = cfg_webbasket_categories['EXTERNAL']
         tab = """
 <div class="bsktab"%(selected)s>
   <img src="%(url)s/img/%(img)s" alt="%(label)s" />
   <a href="%(url)s/yourbaskets.py/display?category=%(cat)s&amp;ln=%(ln)s">%(label)s</a>
 </div>"""
         out = tab % {'selected': selected_category == private and selected or '',
                      'url': weburl,
                      'img': 'webbasket_us.png',
                      'label': _("Personal baskets"),
                      'cat': private,
                      'ln': ln}
         if nb_groups:
             out += tab % {'selected': selected_category == group and selected or '',
                           'url': weburl,
                           'img': 'webbasket_ugs.png',
                           'label': _("Group baskets"),
                           'cat': group,
                           'ln': ln}
         if nb_external_baskets:            
             out += tab % {'selected': selected_category == external and selected or '',
                           'url': weburl,
                           'img': 'webbasket_ws.png',
                           'label': _("Others' baskets"),
                           'cat': external,
                           'ln': ln}
         return out
 
     def tmpl_topic_selection(self,
                              topics_list=[],
                              selected_topic=0,
                              ln=cdslang):
         """Display the topics selection area which appears on the top of external baskets category.
         @param topics_list: list of (topic name, number of baskets) tuples
         @param selected_topic: # of selected topic in topics_list"""
         category = cfg_webbasket_categories['PRIVATE']
         if len(topics_list):
             selected_topic = selected_topic <= len(topics_list) and selected_topic or 0
             i = 0
             out = ''
             for (topic, number_of_baskets) in topics_list:
                 out += '<span class="bsktopic">'
                 topic_label = topic + ' (' + str(number_of_baskets) + ')'
                 if i != selected_topic:
                     topic_link = '%s/yourbaskets.py/display?category=%s&amp;topic=%i&amp;ln=%s'
                     topic_link %= (weburl, category, i, ln)
                     out += '<a href="%s">' % topic_link
                     out += topic_label + '</a>'
                 else:
                     out += topic_label
                 out += '</span> '    
                 i += 1
             out = """
 <table id="bsktopics">
   <tr>
     <td>%s
     </td>
   </tr>
 </table>""" % out
         else:
             out = self.tmpl_create_basket(ln=cdslang)
             
         return out
 
     def tmpl_group_selection(self,
                              groups_list=[],
                              selected_group_id=0,
                              ln=cdslang):
         """Display the group selection area which appears on the top of group baskets category.
         @param groups_list: list of (group id, group name, number of baskets) tuples
         @param selected_group id: id of group selected"""
         out = ''
         category = cfg_webbasket_categories['GROUP']
         if len(groups_list): 
             for (group_id, group_name, number_of_baskets) in groups_list:
                 out += '<span class="bsktopic">'
                 group_label = group_name + ' (' + str(number_of_baskets) + ')'
                 if group_id != selected_group_id:
                     group_link = '%s/yourbaskets.py/display?category=%s&amp;group=%i&amp;ln=%s'
                     group_link %= (weburl, category, group_id, ln)
                     out += '<a href="%s">' % group_link
                     out += group_label + '</a>'
                 else:
                     out += group_label
             out += '</span>'
             out = """
 <table id="bsktopics">
   <tr>
     <td>%s
     </td>
   </tr>
 </table>""" % out
         return out
 
     def tmpl_baskets_infobox(self, basket_infos=[], create_link='', ln=cdslang):
         """
         displays infos about baskets.
         @param basket_infos: list of (bskid, bsk_name, bsk_last_update) tuples
         @param create_link: link for the creation of basket (will appear next to descriptions)
         @param ln: language
         @return html as string
         """
         _ = gettext_set_language(ln)
         label = _("There are %i baskets") % len(basket_infos)
         basket_list = ''
         if len(basket_infos):
             basket_list += '<ul>\n'
             for (bskid, name, last_update) in basket_infos:
                 last_update = convert_datetext_to_dategui(last_update)
                 basket_list += '<li><a href="#bsk%i">%s</a> - ' % (bskid, name)
                 basket_list += _("updated on") + ' ' + last_update + '</li>\n'
             basket_list += '</ul>'
         if len(basket_infos) < 2:
             label = ''
             basket_list = ''
         out = """
 <table style="width: 100%%; vertical-align: top">
   <tr>
     <td style="vertical-align: top">%s</td>
     <td>%s</td>
     <td  style="vertical-align: top">%s</td>
   </tr>
 </table>""" % (label, basket_list, create_link)
         return out
         
     def tmpl_display_public(self,
                              (bskid, bsk_name,          
                              bsk_date_modification,bsk_nb_views, 
                              bskid_owner, bsk_owner_nickname, bsk_share_level),
                              bsk_items=[],
                              ln=cdslang):
         """
         Display public basketwith link to subscribe to it.
         @param bsk_share_level is not currently used.  
         """
         _ = gettext_set_language(ln)
         items_html = ''
         if not(len(bsk_items)):
             items_html = """
 <tr>
   <td colspan="3" style="text-align:center; height:100px">
     %s
   </td>
 </tr>""" % _("Basket is empty")
         for item in bsk_items:
             items_html += self.__tmpl_basket_item(bskid=bskid, item=item, ln=ln)
         
         if bsk_owner_nickname:
             display = bsk_owner_nickname
         else:
             (bskid_owner, bsk_owner_nickname, display) = get_user_info(int(bskid_owner))
         messaging_link = self.__create_messaging_link(bsk_owner_nickname, display, ln)
         general_label = _("This basket belongs to %s. You can freely subscribe to it by using the link below.") % messaging_link      
         out = """
 %(general_label)s      
 <table class="bskbasket">
   <thead class="bskbasketheader">
     <tr>
       <td>
         <img src="%(weburl)s/img/webbasket_world.png" alt="%(image_label)s"/>
       </td>
       <td class="bsktitle">
         <b>%(name)s</b></a>
         %(nb_items)i %(records_label)s - %(last_update_label)s: %(last_update)s
       </td>
       <td class="bskcmtcol">
         <a href="%(weburl)s/yourbaskets.py/subscribe?bskid=%(bskid)i&amp;ln=%(ln)s">%(subscribe_label)s</a>
       </td>
     </tr>
   </thead>
   <tbody>
 %(items)s
   </tbody>
 </table>""" % {'general_label': general_label,
                'weburl': weburl,
                'image_label': _("Public basket"),
                'name': bsk_name,
                'nb_items': len(bsk_items),
                'records_label': _("records"),
                'last_update_label': _("last update"),
                'last_update': convert_datetext_to_dategui(bsk_date_modification),
                'bskid': bskid,
                'ln': ln,
                'subscribe_label': _("Subscribe to this basket"),
                'items': items_html}
         return out        
             
     
     ############################ Baskets ###################################
     
     def tmpl_basket(self, bskid,
                     name,
                     date_modification,
                     nb_views,
                     nb_items, last_added,
                     (user_can_view_content, user_can_manage_rights, user_can_delete_basket, 
                     user_can_view_comments, user_can_add_item, user_can_delete_item),
                     nb_comments, last_comment,
                     group_sharing_level,
                     selected_category=cfg_webbasket_categories['PRIVATE'],
                     selected_topic=0, selected_group=0,
                     items=[],
                     ln=cdslang):
         """
         display a basket.
         @param access_rights: rights user has on this basket (see cfg_webbasket_share_levels)
         @param group_sharing_level: Indicate to which level a basket is shared 
                                     (None for nobody, 0 for everybody, any other natural for group)
         @param items: list of (record id, nb of comments, last comment (date), body to display, score (int)) tuples
         """
         _ = gettext_set_language(ln)
         items_html = ''
         actions = '<table class="bskbasketheaderactions"><tr>'
         if group_sharing_level == None:
             group_img_name = 'webbasket_user.png'
             group_alt = _("Non shared basket")
         elif group_sharing_level == 0:
             group_img_name = 'webbasket_world.png'
             group_alt = _("Shared basket")
         else:
             group_img_name = 'webbasket_usergroup.png'
             group_alt = _("Group shared basket")
         manage_link = ''
         logo = "<img src=\"%s/img/%s\" alt=\"%s\" />" % (weburl, group_img_name, group_alt)
         if user_can_manage_rights:
             url = weburl + '/yourbaskets.py/manage_rights?bskid=%i&amp;topic=%i&amp;ln=%s'
             url %= (bskid, selected_topic, ln)
             logo = '<a href="%s">%s</a>' % (url, logo + '<br />' + _("Manage rights")) 
         actions += "<td>" + logo + "</td>"
         if user_can_delete_basket:
             url = "%s/yourbaskets.py/delete?bskid=%i&amp;"
             url += "category=%s&amp;topic=%i&amp;group=%i&amp;ln=%s"
             url = url % (weburl,
                          bskid,
                          selected_category,
                          selected_topic,
                          selected_group,
                          ln)
             img = "%s/img/webbasket_delete.png" % weburl
             action = "<a href=\"%s\"><img src=\"%s\" alt=\"%s\" /></a>"
             actions += "<td>" + action % (url, img, _("Delete basket")) + "</td>"
             if selected_category == cfg_webbasket_categories['PRIVATE']:
                 img = "%s/img/webbasket_move.png" % weburl
                 url = "%s/yourbaskets.py/move?bskids=%i&amp;"
                 url += "category=%s&amp;topic=%i&amp;group=%i&amp;ln=%s"
                 url = url % (weburl,
                              bskid,
                              selected_category,
                              selected_topic,
                              selected_group,
                              ln)
                 actions += "<td>" + action % (url, img, _("Move basket to another topic"))+ "</td>" 
         actions += "</tr></table>"
         if user_can_view_content:
             if not(len(items)):
                 items_html = """
 <tr>
   <td colspan="3" style="text-align:center; height:100px">
     %s
   </td>
 </tr>""" % _("Basket is empty")
             for item in items:
                 copy = 1
                 up = down = delete = 0
                 if user_can_add_item:
                     up = down = 1
                     if item == items[0]:
                         up = 0
                     if item == items[-1]:
                         down = 0
                 if user_can_delete_item:
                     delete = 1
                 items_html += self.__tmpl_basket_item(bskid=bskid,
                                                       item=item,
                                                       uparrow=up,
                                                       downarrow=down,
                                                       copy_item=copy,
                                                       delete_item=delete,
                                                       view_comments=user_can_view_comments,
                                                       selected_category=selected_category,
                                                       selected_topic=selected_topic,
                                                       selected_group=selected_group,
                                                       ln=ln)
         else:
             items_html = """
 <tr>
   <td colspan="3" style="text-align:center; height:100px">
     %s
   </td>
 </tr>""" % _("You don't have sufficient rights to view this basket's content")
         content = ''
         if selected_category == cfg_webbasket_categories['EXTERNAL']:
             url = "%s/yourbaskets.py/unsubscribe?bskid=%i&amp;ln=%s" % (weburl, bskid, ln)
             action = "<a href=\"%s\">%s</a>"
             action %= (url, _("Unsubscribe to this basket"))
             content += action
         footer = self.tmpl_basket_footer(bskid,
                                          selected_category,
                                          selected_topic,
                                          selected_group,
                                          group_sharing_level,
                                          content,
                                          ln)
         comments_field = ''
         if nb_comments:
             comments_field = """
 %i %s<br/>
 %s %s""" % (nb_comments,  _("comments"), _("last comment:"), last_comment)
         out = """       
 <table class="bskbasket">
   <thead class="bskbasketheader">
     <tr>
       <td>%(actions)s</td>
       <td class="bsktitle">
         <a name="bsk%(bskid)i"><b>%(name)s</b></a><br />
         %(nb_items)i %(records_label)s - %(last_update_label)s: %(last_update)s
       </td>
       <td class="bskcmtcol">
 %(comments_field)s
       </td>
     </tr>
   </thead>
   <tbody>
 %(items)s
 %(footer)s
   </tbody>
 </table>"""
         out %= {'actions': actions,
                 'name': name,
                 'bskid': bskid,
                 'nb_items': nb_items,
                 'records_label': _('records'),
                 'last_update_label': _("last update"),
                 'last_update': date_modification,
                 'comments_field': user_can_view_comments and indent_text(comments_field, 4) or '',
                 'items': items_html,
                 'footer': footer}
         return out
                
     def __tmpl_basket_item(self,
                          bskid,
                          item,
                          uparrow=0, downarrow=0, copy_item=0, delete_item=0, view_comments=0,
                          selected_category=cfg_webbasket_categories['PRIVATE'],
                          selected_topic=0, selected_group=0,
                          ln=cdslang):
         """
         display a row in a basket (row is item description and actions).
         @param bskid: basket id (int)
         @param item: (record id, nb of comments, last comment (date), body to display, score (int)) tuple
         @param uparrow, downarrow, copy_item, delete_item, view_comments: actions. set to 1 to display these actions.
         """
         _ = gettext_set_language(ln)
         (recid, nb_cmt, last_cmt, val, score) = item
         actions = ''
         if uparrow:
             url = "%s/yourbaskets.py/modify?action=moveup&amp;bskid=%i&amp;recid=%i"
             url += "&amp;category=%s&amp;topic=%i&amp;group=%i&amp;ln=%s"
             url = url % (weburl,
                          bskid,
                          recid,
                          selected_category,
                          selected_topic,
                          selected_group,
                          ln)
             img = "%s/img/webbasket_up.png" % weburl
             actions += "<a href=\"%s\"><img src=\"%s\" alt=\"%s\" /></a>"
             actions = actions % (url,
                                  img,
                                  _("Bring item up"))
         if downarrow:
             url = "%s/yourbaskets.py/modify?action=movedown&amp;bskid=%i&amp;recid=%i"
             url += "&amp;category=%s&amp;topic=%i&amp;group=%i&amp;ln=%s"
             url = url % (weburl,
                          bskid,
                          recid,
                          selected_category,
                          selected_topic,
                          selected_group,
                          ln)
             img = "%s/img/webbasket_down.png" % weburl
             actions += "<a href=\"%s\"><img src=\"%s\" alt=\"%s\" /></a>"
             actions = actions % (url,
                                  img,
                                  _("Bring item down"))
         if copy_item:
             url = "%s/yourbaskets.py/modify?action=copy&amp;bskid=%i&amp;recid=%i"
             url += "&amp;category=%s&amp;topic=%i&amp;group_id=%i&amp;ln=%s"
             url = url % (weburl,
                          bskid,
                          recid,
                          selected_category,
                          selected_topic,
                          selected_group,
                          ln)
             img = "%s/img/webbasket_move.png" % weburl
             actions += "<a href=\"%s\"><img src=\"%s\" alt=\"%s\" /></a>"
             actions = actions % (url,
                                  img,
                                  _("Copy item"))
         if delete_item:
             url = "%s/yourbaskets.py/modify?action=delete&amp;bskid=%i&amp;recid=%i"
             url += "&amp;category=%s&amp;topic=%i&amp;group=%i&amp;ln=%s"
             url = url % (weburl,
                          bskid,
                          recid,
                          selected_category,
                          selected_topic,
                          selected_group,
                          ln)
             img = "%s/img/webbasket_delete.png" % weburl
             actions += "<a href=\"%s\"><img src=\"%s\" alt=\"%s\" /></a>"
             actions = actions % (url,
                                  img,
                                  _("Remove item"))
         if recid < 0:
             actions += "<img src=\"%s/img/webbasket_extern.png\" alt=\"%s\" />"
             actions = actions % (weburl, _("Extern record"))
         else:
             pass
             #actions += "<img src=\"%s/img/webbasket_intern.png\" alt=\"%s\" />"
             #actions = actions % (weburl, _("Intern record"))
         out = """
 <tr>
   <td class="bskactions">%(actions)s</td>
   <td class="bskcontentcol" colspan="2">
     %(content)s
     <hr />"""
         if view_comments:
             if nb_cmt > 0:
                 out += """
 %(nb_cmts)i %(cmts_label)s; %(last_cmt_label)s: %(last_cmt)s<br />
 """
             out += """
 <a href="%(weburl)s/yourbaskets.py/display_item?bskid=%(bskid)s&amp;recid=%(recid)i&amp;category=%(category)s&amp;group=%(group)i&amp;topic=%(topic)i&amp;ln=%(ln)s">%(detailed_label)s</a>
 """
         out += """
   </td>
 </tr>"""
         out = out % {'actions': actions,
                      'content': val,
                      'nb_cmts': nb_cmt,
                      'last_cmt': last_cmt,
                      'weburl': weburl,
                      'bskid': bskid,
                      'recid': recid,
                      'cmts_label': _("comments"),
                      'last_cmt_label': _("last"),
                      'detailed_label': _("Details and comments"),
                      'category': selected_category,
                      'topic': selected_topic,
                      'group': selected_group,
                      'ln': ln}
         return out
 
     def tmpl_basket_footer(self,
                            bskid,
                            selected_category=cfg_webbasket_categories['PRIVATE'],
                            selected_topic=0,
                            selected_group=0,
                            group_sharing_level=None,
                            content='',
                            ln=cdslang):
         """display footer of a basket."""
         _ = gettext_set_language(ln)
         public_infos = ''
         if group_sharing_level == 0:
             public_url = weburl + '/yourbaskets.py/display_public?bskid=' + str(bskid)
             public_link = '<a href="%s">%s</a>' % (public_url, public_url)
             public_infos = _("This basket is publicly accessible at this adress: %s.") % public_link
         if content:
             content += '<br />'
         if not(content) and not(public_infos):
             content += '<br />'
         out = """ 
 <tr>
   <td colspan="3" class="bskbasketfooter">
     <!-- Commented. Ready for next release
     <form name="bsk_sort_%(bskid)i" action="%(weburl)s/yourbaskets.py/display" method="GET">
       <input type="hidden" name="bsk_to_sort" value="%(bskid)i" />
       <input type="hidden" name="category" value="%(category)s" />
       <input type="hidden" name="topic" value="%(topic)i" />
       <input type="hidden" name="group" value="%(group_id)i" />
       <input type="hidden" name="ln" value="%(ln)s" />
       %(sort_label)s:
       <input type="submit" name="sort_by_title" value="%(title_label)s" class="nonsubmitbutton" />
       <input type="submit" name="sort_by_date" value="%(date_label)s" class="nonsubmitbutton" />
     </form>-->
     %(content)s
     %(public_infos)s
   </td>
 </tr>
 """
         out %= {'weburl': weburl,
                  'bskid': int(bskid),
                  'category': selected_category,
                  'topic': int(selected_topic),
                  'group_id': int(selected_group),
                  'ln': ln,
                  'sort_label': _("Sort by"),
                  'title_label': _("Title"),
                  'date_label': _("Date"),
                  'content': content,
                  'public_infos': public_infos
                  }
         return out
 
     ######################### Display of items and commenting ###################################
    
     def tmpl_item(self,
                   (bskid, bsk_name, bsk_date_modification, bsk_nb_views, bsk_nb_records, bsk_id_owner), 
                   recid, record, comments,
                   sharing_level, (user_can_view_comments, user_can_add_comment, user_can_delete_comment),
                   selected_category=cfg_webbasket_categories['PRIVATE'],
                   selected_topic=0, selected_group_id=0, ln=cdslang):
         """display a specific item inside a basket. first parameter is this a big tuple which defines a basket."""
         _ = gettext_set_language(ln)
         total_comments = len(comments)
         action = weburl + '/yourbaskets.py/write_comment?bskid=%i&amp;recid=%i'
         action += '&amp;category=%s&amp;topic=%i&amp;group=%i&amp;ln=%s'
         action %= (bskid, recid, selected_category, selected_topic, selected_group_id, ln)
         back_url = weburl + '/yourbaskets.py/display?category=%s&amp;topic=%i&amp;group=%i'
         back_url %= (selected_category, selected_topic, selected_group_id)
                 
         def list_to_str(elt1, elt2):
             """return elt1 <br /> elt2"""
             return elt1 + "<br />\n" + elt2
         if comments and user_can_view_comments:
             comments = [self.__tmpl_display_comment(bskid, recid, comment, 
                                                     (user_can_add_comment, user_can_delete_comment), 
                                                     selected_category, selected_topic, selected_group_id, 
                                                     ln)
                         for comment in comments]
             comments = reduce(list_to_str, comments)
         else:
             comments = ''
         if record:
             record_text = record[-1]
         body = """
 %(record)s
 <hr /><br />"""
         if user_can_view_comments:
             body += """
 <h2>%(comments_label)s</h2>
 %(total_label)s<br />"""
         if user_can_add_comment:
             body += """
 <form name="write_comment" method="POST" action="%(action)s">
   <input type="submit" value="%(button_label)s" style="margin: 10px;" class="formbutton" />
 </form>"""
         if user_can_view_comments:
             body += """
 <br />
 %(comments)s"""
         body %= {'record': record_text,
                 'comments_label': _("Comments"),
                 'total_label': _("There is a total of %i comments") % total_comments,
                 'action': action,
                 'button_label': _("Write a comment"),
                 'comments': comments}
         if sharing_level == None:
             img = '<img src="%s/img/webbasket_user.png" alt="%s" />' % (weburl, _("Non shared basket"))
         elif sharing_level == 0:
             img = '<img src="%s/img/webbasket_world.png" alt="%s" />' % (weburl, _("Shared basket"))
         else:
             img = '<img src="%s/img/webbasket_usergroup.png" alt="%s" />' % (weburl, _("Group shared basket"))
         content = ''
         if selected_category == cfg_webbasket_categories['EXTERNAL']:
             url = "%s/yourbaskets.py/unsubscribe?bskid=%i&amp;ln=%s" % (weburl, bskid, ln)
             action = "<a href=\"%s\">%s</a>"
             action %= (url, _("Unsubscribe to this basket"))
             content += action
         footer = self.tmpl_basket_footer(bskid,
                                          selected_category,
                                          selected_topic,
                                          selected_group_id,
                                          sharing_level,
                                          content,
                                          ln)
         out = """      
 <table class="bskbasket">
   <thead class="bskbasketheader">
     <tr>
       <td>%(img)s</td>
       <td class="bsktitle" style="height: 65px">
         <b><a href="%(weburl)s/yourbaskets.py/display?bskid=%(bskid)s&amp;category=%(category)s&amp;topic=%(topic)i&amp;group=%(group)i&amp;ln=%(ln)s">%(name)s</a></b><br />
         %(nb_items)i %(records_label)s - %(last_update_label)s: %(last_update)s
       </td>
       <td class="bskcmtcol"></td>
     </tr>
   </thead>
   <tbody>
     <tr>
       <td colspan="3" style="padding: 5px;">
 %(body)s
       </td>
     </tr>
 %(footer)s
   </tbody>
 </table>""" % {'img': img,
                'weburl': weburl,
                'bskid': bskid,
                'category': selected_category,
                'topic': selected_topic,
                'group': selected_group_id,
                'ln': ln,
                'name': bsk_name,
                'nb_items': bsk_nb_records,
                'records_label': _("records"),
                'last_update_label': _("last update"),
                'last_update': bsk_date_modification,
                'body': body,
                'footer': footer}
         out += """
 <a href="%s">%s</a>""" % (back_url, _("Back to baskets"))
         return out
 
     def __tmpl_display_comment(self, bskid, recid, 
                                (cmt_uid, cmt_nickname, cmt_title, cmt_body, cmt_date, cmt_priority, cmtid),
                                (user_can_add_comment, user_can_delete_comment),
                                selected_category=cfg_webbasket_categories['PRIVATE'],
                                selected_topic=0, selected_group_id=0, ln=cdslang):
         """Display a given comment. 
         @param rights: defines which links (reply, delete, ...) will be displayed. see config file for rights.
         """
         _ = gettext_set_language(ln)
         out = """
 <div class="bskcomment">
   <b>%(title)s</b>, %(label_author)s <a href="%(url)s/yourmessages.py/write?msg_to=%(user)s">%(user_display)s</a> %(label_date)s <i>%(date)s</i><br/><br/>
   %(body)s
   <br />"""
         if user_can_add_comment:
             out += """ 
 <a href="%(url)s/yourbaskets.py/write_comment?bskid=%(bskid)i&amp;recid=%(recid)i&amp;cmtid=%(cmtid)i&amp;category=%(category)s&amp;topic=%(topic)i&amp;group=%(group_id)i&amp;ln=%(ln)s">%(reply_label)s</a>""" 
         if user_can_delete_comment:
             out += """ 
 | <a href="%(url)s/yourbaskets.py/delete_comment?bskid=%(bskid)i&amp;recid=%(recid)i&amp;cmtid=%(cmtid)i&amp;category=%(category)s&amp;topic=%(topic)i&amp;group=%(group_id)i&amp;ln=%(ln)s">%(delete_label)s</a>""" 
         out += """
 </div>"""
         out %= {'title': cmt_title,
                 'url': weburl,
                 'label_author': _("by"),
                 'label_date': _("on"),
                 'user': cmt_nickname or cmt_uid,
                 'user_display': cmt_nickname or get_user_info(cmt_uid)[2],
                 'date': convert_datetext_to_dategui(cmt_date),
                 'body': email_quoted_txt2html(cmt_body),
                 'bskid': bskid,
                 'recid': recid,
                 'cmtid': cmtid,
                 'category': selected_category,
                 'topic': selected_topic,
                 'group_id': selected_group_id,
                 'ln': ln,
                 'reply_label': _("Reply"),
                 'delete_label': _("Delete comment")}
         return out
 
     def tmpl_quote_comment(self, title, uid, nickname, date, body, ln=cdslang):
         """Return a comment in a quoted form (i.e. with '>' signs before each line)
         @param title: title of comment to quote
         @param uid: user id of user who posted comment to quote
         @param nickname: nickname of user who posted comment to quote
         @param date: date of post of comment to quote
         @param body: body of comment to quote
         @param ln: language"""
         _ = gettext_set_language(ln)
         if not(nickname):
             nickname = get_user_info(uid)[2]
         out = title + ', ' + _("by") + ' ' + nickname + ' ' + _("on") + ' ' + date + '\n' + body
         return email_quote_txt(out)
 
     def tmpl_write_comment(self, bskid, recid,
                            record,
                            cmt_body='',
                            selected_category=cfg_webbasket_categories['PRIVATE'],
                            selected_topic=0, selected_group_id=0,
                            ln=cdslang,
                            warnings=[]):
         """Display interface to write a comment.
         @param bskid: basket id (int)
         @param recid: record id (int)
         @param record: text of the record (str)
         @param selected_category: cfg_webbasket_categories
         @param selected_topic: # of topic
         @param selected_group_id: in case of category: group, id of selected group
         @param ln: language
         @param warnings: list of warnings"""
         _ = gettext_set_language(ln)
         action = '%s/yourbaskets.py/save_comment?bskid=%i&amp;recid=%i'
         action += '&amp;category=%s&amp;topic=%i&amp;group=%i&amp;ln=%s'
         action %= (weburl, bskid, recid,
                    selected_category, selected_topic, selected_group_id, ln)
         if warnings:
             warnings_box = self.tmpl_warnings(warnings, ln)
         else:
             warnings_box = ''
         out = """
 <div style="width:100%%">%(warnings)s
   %(record)s
   <hr />
   <h2>%(write_label)s</h2>
   <form name="write_comment" method="POST" action="%(action)s">
     <p class="bsklabel">%(title_label)s:</p>
     <input type="text" name="title" size="80" />
     <p class="bsklabel">%(comment_label)s:</p>
     <textarea name="text" rows="20" cols="80">%(cmt_body)s</textarea><br />
     <input type="submit" class="formbutton" value="%(button_label)s" />
   </form>
 </div>""" % {'warnings': warnings_box,
              'record': record and record[-1] or '',
              'write_label': _("Add Comment"),
              'title_label': _("Title"),
              'comment_label': _("Comment"),
              'action': action,
              'cmt_body': cmt_body,
              'button_label': _("Add Comment")
             }
                 
         return out
         
         ############################ Basket creation ###################################
    
     def tmpl_create_basket_link(self, selected_topic=0, ln=cdslang):
         """ Create link to basket creation """
         _ = gettext_set_language(ln)
         url = weburl + '/yourbaskets.py/create_basket?topic_number=%i&amp;ln=%s'
         url %= (selected_topic, ln) 
         image = '<img src="%s/img/webbasket_create_small.png" style="vertical-align: middle; margin-right: 5px" />' % weburl
         out = """
 <div class="bsk_create_link">
   <a href="%s">%s%s</a>
 </div>""" % (url, image, _("Create new basket"))
         return out
 
     def __tmpl_basket_box(self, img='', title='&nbsp;', subtitle='&nbsp;', body=''):
         """ private function, display a basket/topic selection box """ 
         out = """
 <table class="bskbasket">
   <thead class="bskbasketheader">
     <tr>
       <td class="bskactions">
         <img src="%(logo)s" alt="%(label)s" />
       </td>
       <td class="bsktitle">
         <b>%(label)s</b><br />
         %(count)s
       </td>
     </tr>
   </thead>
   <tbody>
     <tr>
       <td colspan="2">
         <table>%(basket_list)s
         </table>
       </td>
     </tr>
   </tbody>
 </table>"""
         out %= {'logo': img,
               'label': title, 'count': subtitle,
               'basket_list': indent_text(body, 5)}
         return out
 
     def tmpl_create_box(self, new_basket_name='', new_topic_name='',
                         topics=[], selected_topic=None,
                         ln=cdslang):
         """Display a HTML box for creation of a new basket
         @param new_basket_name: prefilled value (string)
         @param new_topic_name: prefilled value (string)
         @param topic: list of topics (list of strings)
         @param selected_topic: preselected value for topic selection
         @param ln: language"""
         _ = gettext_set_language(ln)
         topics_html = ''
         topics =  map(lambda x: x[0], topics)
         if selected_topic:
             try:
                 selected_topic = topics.index(selected_topic[0])
             except:
                 selected_topic = None
         if len(topics):
             topics = zip(range(len(topics)), topics)
             topics.insert(0, (-1, _("Select topic")))
             topics_html = self.__create_select_menu('create_in_topic', topics, selected_topic)
         create_html = """
 <tr>
   <td>%s</td>
   <td>
     <input type="text" name="new_basket_name" value="%s"/>
   </td>
 </tr>
 <tr>
   <td colspan="2">%s %s: <input type="text" name="new_topic_name" value="%s"/>
 </tr>""" % (_("New basket's name"), new_basket_name,
             topics_html,
             topics_html!='' and _("or create a new one") or _("Create a new topic"),
             new_topic_name)
         return self.__tmpl_basket_box(img=weburl + '/img/webbasket_create.png',
                                       title=_("Create a new basket"),
                                       body=create_html)
 
     def tmpl_create_basket(self, new_basket_name='',
                            new_topic_name='', create_in_topic=None, topics_list=[],
                            ln=cdslang):
         """Template for basket creation"""
         _ = gettext_set_language(ln)
         out = """
 <form name="create_basket" action="%(action)s" method="POST">
   <input type="hidden" name="ln" value="%(ln)s" />
   <div style="padding:10px;">
     %(create_box)s
     <input type="submit" value="%(label)s" class="formbutton"/>
   </div>
 </form>""" % {'action': weburl + '/yourbaskets.py/create_basket',
               'ln': ln,
               'create_box': indent_text(self.tmpl_create_box(new_basket_name=new_basket_name,
                                                              new_topic_name=new_topic_name,
                                                              topics=topics_list,
                                                              selected_topic=create_in_topic,
                                                              ln=ln),
                                         2),
               'label': _("Create new basket")}
         return out
 
     
     ############################ functions on baskets ###################################
     
     def tmpl_add(self, recids,
                  personal_baskets,
                  group_baskets,
                  external_baskets,
                  topics,
                  referer, ln=cdslang):
         """ returns HTML for the basket selection form """
         _ = gettext_set_language(ln)
         action = weburl + '/yourbaskets.py/add?ln=' + ln
         personal = ''
         group = ''
         external = ''
         if personal_baskets:
             topic_names = {}
             map(topic_names.setdefault, [row[2] for row in personal_baskets])
             topic_names = topic_names.keys()
             topic_names.sort()
             personal_html = ''
             for topic_name in topic_names:
                 baskets = map(lambda x: (x[0], x[1]),
                               filter(lambda x: x[2]==topic_name,
                                      personal_baskets))
                 baskets.insert(0, (0, _("Select basket"))) 
                 personal_html += """<tr>
   <td>%s</td>
   <td>%s</td>
 </tr>"""
                 personal_html %= (topic_name,
                                   indent_text(self.__create_select_menu('topic ' + topic_name,
                                                                         baskets),
                                               2))
             personal = self.__tmpl_basket_box(weburl + '/img/webbasket_user.png',
                                               _("Add to a personal basket"),
                                               _("%i baskets") % len(personal_baskets),
                                               personal_html) 
         if group_baskets:
             group_names = {}
             map(group_names.setdefault, [row[2] for row in group_baskets])
             group_names = group_names.keys()
             group_names.sort()
             groups_html = ''
             for group_name in group_names:
                 baskets = map(lambda x: (x[0], x[1]),
                               filter(lambda x: x[2]==group_name,
                                      group_baskets))
                 baskets.insert(0, (0, _("Select basket"))) 
                 groups_html += """<tr>
   <td>%s</td>
   <td>%s</td>
 </tr>"""
                 groups_html %= (group_name,
                                 indent_text(self.__create_select_menu('group ' + group_name,
                                                                       baskets),
                                             2))
 
             group = self.__tmpl_basket_box(weburl + '/img/webbasket_usergroup.png',
                                            _("Add to a group shared basket"),
                                            _("%i baskets") % len(group_baskets),
                                            groups_html)    
         if external_baskets:
             external_html = """
 <tr>
   <td>
     <select name="external_baskets">
       <option value="0">%s</option>""" % _("Select basket")
             for basket in external_baskets:
                 value = int(basket[0])
                 label = basket[1]
                 external_html += indent_text('<option value="%i">%s</option>'% (value, label), 3)
             external_html += """
     </select>
   </td>
 </tr>"""
             external = self.__tmpl_basket_box(weburl + '/img/webbasket_world.png',
                                               _("Add to a public basket"),
                                               _("%i baskets") % len(external_baskets),
                                               external_html)
         create = self.tmpl_create_box(topics=topics, ln=ln)
         recids_field = reduce(lambda x, y: str(x) + ',' + str(y), recids)
         fields = filter(lambda x: x != '', [personal, group, external, create])
         while (len(fields) != 4): 
             fields.append('')
         out = """
 <form name="add_to_basket" action="%(action)s" method="POST">
   <p>%(label)s:</p>
   <input type="hidden" name="referer" value="%(referer)s" />
   <input type="hidden" name="recid" value="%(recids)s" />
   <table style="width:100%%;">
     <tr>
     <td style="width:50%%;vertical-align:top;">%(field1)s</td>
     <td style="width: 50%%;vertical-align:top;">%(field2)s</td>
     </tr>
     <tr>
       <td style="vertical-align:top;">%(field3)s</td>
       <td style="vertical-align:top;">%(field4)s</td>
     </tr>
     <tr>
       <td colspan="2">
         <input type="submit" class="formbutton" value="%(submit_label)s" />
       </td>
     </tr>
   </table>
 </form>""" % {'action': action,
               'referer': referer,
               'recids': recids_field,
               'label': _("Adding %i records to these baskets") % len(recids),
               'field1': fields[0],
               'field2': fields[1],
               'field3': fields[2],
               'field4': fields[3],
               'submit_label': _("Add to baskets")}
         return out
 
     def tmpl_added_to_basket(self, nb_baskets_modified=0, ln=cdslang):
         """Display message for addition of records to baskets"""
         _ = gettext_set_language(ln)
         if nb_baskets_modified:
             out = _("The selected records have been successfully added to %i baskets")
             out %= nb_baskets_modified
         else:
             out = _("No records were added to the selected baskets.")
         return '<p>' + out + '</p>'
     
     
     def tmpl_confirm_delete(self, bskid,
                             (nb_users, nb_groups, nb_alerts),
                             category=cfg_webbasket_categories['PRIVATE'],
                             selected_topic=0, selected_group_id=0,
                             ln=cdslang):
         """
         display a confirm message
         @param bskid: basket id
         @param category: private, group or external baskets are selected
         @param selected_topic: if private baskets, topic nb
         @param selected_group_id: if group: group to display baskets of
         @param ln: language
         @return html output
         """
         _ = gettext_set_language(ln)
         message = _("Are your sure you want to delete this basket?")
         if nb_users:
             message += '<p>' + _("%i users have subscribed to this basket")% nb_users + '</p>'
         if nb_groups:
             message += '<p>' + _("%i usergroups have subscribed to this basket")% nb_groups + '</p>'
         if nb_alerts:
             message += '<p>' + _("You have set %i alerts on this basket")% nb_alerts + '</p>'
         out = """
 <table class="confirmoperation">
   <tr>
     <td colspan="2" class="confirmmessage">
       %(message)s
     </td>
   </tr>
   <tr>
     <td>
       <form name="validate" action="%(url_ok)s" method="post">
         <input type="hidden" name="confirmed" value="1" />
         <input type="hidden" name="category" value="%(category)s" />
         <input type="hidden" name="group" value="%(group)i" />
         <input type="hidden" name="topic" value="%(topic)i" />
         <input type="hidden" name="ln" value="%(ln)s" />
         <input type="hidden" name="bskid" value="%(bskid)i" />
         <input type="submit" value="%(yes_label)s" class="formbutton" />
       </form>
     </td>
     <td>
       <form name="cancel" action="%(url_cancel)s" method="get">
         <input type="hidden" name="category" value="%(category)s" />
         <input type="hidden" name="group" value="%(group)i" />
         <input type="hidden" name="topic" value="%(topic)i" />
         <input type="hidden" name="ln" value="%(ln)s" />
         <input type="submit" value="%(no_label)s" class="formbutton" />
       </form>
     </td>
   </tr>
 </table>"""% {'message': message,
               'bskid': bskid,
               'url_ok': 'delete',
               'url_cancel': 'display',
               'category': category,
               'topic': selected_topic,
               'group': selected_group_id,
               'ln':ln,
               'yes_label': _("Yes"),
               'no_label': _("Cancel")}
         return indent_text(out, 2)
 
     def tmpl_move(self, bskids, topics, ln=cdslang):
         """Display a topic selection / creation for moving of give baskets.
         @param bskids: list of basket ids
         @param topics: list of tuples (see webbasket_db_layer: get_personal_topics
         @param ln: language
         """        
         _ = gettext_set_language(ln)
         topics_selection = zip(range(len(topics)), map(lambda x: x[0], topics))
         topics_selection.insert(0, (-1, _("Select topic"))) 
         topics_body = """
 <tr>
   <td>%s</td>
 </tr>""" %  indent_text(self.__create_select_menu('selected_topic', topics_selection), 2)
         if len(topics):
             topics_box = self.__tmpl_basket_box(img=weburl + '/img/webbasket_user.png',
                                                 title=_("Select a topic"),
                                                 body=topics_body)
         else:
             topics_box = ''
 
         create_body = """
 <tr>
   <td>%s</td>
   <td>
     <input type="text" name="new_topic_name" />
   </td>
 </tr>""" % _("New topic's name")
         create_box = self.__tmpl_basket_box(img=weburl + '/img/webbasket_create.png',
                                             title=_("Create a new topic"),
                                             body=create_body)
         action = weburl + '/yourbaskets.py/move'
         bskids_field = reduce(lambda x, y: str(x) + ',' + str(y), bskids) 
         out = """
 <form name="move_basket" action="%(action)s" method="POST">
   <p>%(label)s:</p>
   <input type="hidden" name="ln" value="%(ln)s" />
   <input type="hidden" name="bskids" value="%(bskids)s" />
   <table style="width:100%%;">
     <tr>
       <td style="width:50%%;vertical-align:top;">%(topics)s</td>
       <td style="width:50%%;vertical-align:top;">%(create)s</td>
     </tr>
     <tr>
       <td colspan="2">
         <input type="submit" class="formbutton" value="%(submit_label)s" />
       </td>
     </tr>
   </table>
 </form>""" % {'action': action,
               'ln': ln,
               'bskids': bskids_field,
               'label': _("Moving %i baskets to this topic") % len(bskids),
               'topics': topics_box,
               'create': create_box,
               'submit_label': _("Move to topic")}
         return out
 
     def tmpl_manage_rights(self, bskid, bsk_name, groups_rights, external_rights,
                            selected_topic, ln=cdslang):
         """Display interface for rights management over the given basket
         @param group_rights: list of (group id, name, rights) tuples
         @param external_rights: rights as defined in cfg_webbasket_share_levels
         """
         _ = gettext_set_language(ln)
         groups_body = ''
         for (group_id, name, rights) in groups_rights:
             groups_body += """
 <tr>
   <td>%s</td>
   <td>%s</td>
 </tr>""" % (name, self.__create_rights_selection_menu(str(group_id), rights, ln))
         groups_body += """
 <tr>
   <td colspan="2">
     <input type="submit" name="add_group" class="nonsubmitbutton" value="%s"/>
   </td>
 </tr>""" % _("Add group")
         groups_box = self.__tmpl_basket_box(img=weburl + '/img/webbasket_usergroup.png',
                                             title=_("Manage groups rights"),
                                             body=groups_body)
         external_body = """
 <tr>
   <td>%s</td>
 </tr>""" % self.__create_rights_selection_menu('external', external_rights, ln)
         external_box = self.__tmpl_basket_box(img=weburl + '/img/webbasket_world.png',
                                               title=_("Manage global sharing rights"),
                                               body=external_body)
         out = """
 <form name="manage_rights" action="%(action)s" method="POST">
   <p>%(label)s</p>
   <input type="hidden" name="ln" value="%(ln)s" />
   <input type="hidden" name="bskid" value="%(bskid)i" />
   <input type="hidden" name="topic" value ="%(topic)i" />
   <table style="width:100%%;">
     <tr>
       <td style="width:50%%;vertical-align:top;">%(groups)s</td>
       <td style="width:50%%;vertical-align:top;">%(external)s</td>
     </tr>
     <tr>
       <td colspan="2">
         <input type="submit" class="formbutton" name="submit" value="%(submit_label)s" />
       </td>
     </tr>
   </table>
 </form>""" % {'label': _('Modifying sharing rights for basket "%s"') % bsk_name,
               'action': weburl + '/yourbaskets.py/manage_rights',
               'ln': ln,
               'topic': selected_topic,
               'bskid': bskid,
               'groups': indent_text(groups_box, 4),
               'external': indent_text(external_box, 4),
               'submit_label': _("Change rights")}
         return out
 
     def __create_rights_selection_menu(self, name, current_rights, ln=cdslang):
         """Private function. create a drop down menu for selection of rights
         @param current_rights: rights as defined in cfg_webbasket_share_levels
         @param ln: language
         """
         _ = gettext_set_language(ln)
         elements = [('NO', _("No rights")),
                     (cfg_webbasket_share_levels['READITM'],
                      _("View records")),
                     (cfg_webbasket_share_levels['READCMT'],
                      '... ' + _("and") + ' ' + _("view comments")),
                     (cfg_webbasket_share_levels['ADDCMT'],
                      '... ' + _("and") + ' ' + _("add comments")),
                     (cfg_webbasket_share_levels['ADDITM'],
                      '... ' + _("and") + ' ' + _("add records")),
                     (cfg_webbasket_share_levels['DELCMT'],
                      '... ' + _("and") + ' ' + _("delete comments")),
                     (cfg_webbasket_share_levels['DELITM'],
                      '... ' + _("and") + ' ' + _("remove records")),
                     (cfg_webbasket_share_levels['MANAGE'],
                      '... ' + _("and") + ' ' + _("manage sharing rights"))
                     ]
         return self.__create_select_menu(name, elements, current_rights)
 
     def tmpl_add_group(self, bskid, selected_topic, groups=[], ln=cdslang):
         """
         return form for selection of groups.
         @param bskid: basket id (int)
         @param selected_topic: topic currently displayed (int)
         @param groups: list of tuples (group id, group name)
         @param ln: language
         """
         _ = gettext_set_language(ln)
         if len(groups):
             groups_body = """
 <tr>
   <td>%s</td>
 </tr>""" % self.__create_select_menu('new_group', groups, selected_key=None)
         else:
             groups_body = """
 <tr>
   <td>%s</td>
 </tr>""" % _("You're not member of a group")
         groups_box = self.__tmpl_basket_box(img=weburl + '/img/webbasket_usergroup.png',
                                             title=_("Add group"),
                                             body=groups_body)
         out = """
 <form name="add_group" action="%(action)s" method="POST">
   <p>%(label)s</p>
   <input type="hidden" name="ln" value="%(ln)s" />
   <input type="hidden" name="bskid" value="%(bskid)i" />
   <input type="hidden" name="topic" value ="%(topic)i" />
   <table style="width:100%%;">
     <tr>
       <td style="width:50%%;vertical-align:top;">%(groups)s</td>
       <td style="width:50%%;vertical-align:top;"></td>
     </tr>
     <tr>
       <td colspan="2">
         <input type="submit" class="formbutton" name="cancel" value="%(cancel_label)s" />
         <input type="submit" class="formbutton" name="add_group" value="%(submit_label)s" />
       </td>
     </tr>
   </table>
 </form>""" % {'label': _('Sharing basket to a new group'),
               'action': weburl + '/yourbaskets.py/manage_rights',
               'ln': ln,
               'topic': selected_topic,
               'bskid': bskid,
               'groups': indent_text(groups_box, 4),
               'cancel_label': _("Cancel"),
               'submit_label': _("Add group")}
         return out
 
     def tmpl_personal_baskets_selection_box(self,
                                             baskets=[],
                                             select_box_name='baskets',
                                             selected_bskid=None,
                                             ln=cdslang):
         """return an HTML popupmenu
         @param baskets: list of (bskid, bsk_name, bsk_topic) tuples
         @param select_box_name: name that will be used for the control
         @param selected_bskid: id of the selcte basket, use None for no selection
         @param ln: language"""
         _ = gettext_set_language(ln)
         elements = [(0, '- ' + _("no basket") + ' -')]
         for (bskid, bsk_name, bsk_topic) in baskets:
             elements.append((bskid, bsk_topic + ' > ' + bsk_name))
         return self.__create_select_menu(select_box_name, elements, selected_bskid)
 
     def tmpl_create_guest_warning_box(self, ln=cdslang):
         """return html warning box for non registered users"""
         _ = gettext_set_language(ln)
         message = _("You are logged in as a guest user, so your baskets will disappear at the end of the current session. If you wish you can %slogin or register here%s.")
-        message %= ('<a href="%s/youraccount.py/login?ln=%s">'% (weburl, ln), '</a>')
+        message %= ('<a href="%s/youraccount.py/login?ln=%s">'% (httpsurl, ln), '</a>')
         out = """
 <table class="errorbox">
   <thead>
     <tr>
       <th class="errorboxheader">%s</th>
     </tr>
   </thead>
 </table>"""
         return out % message
       
 
     ############################ Utilities ###################################
   
     def __create_select_menu(self, name, elements, selected_key=None):
         """ private function, returns a popup menu
         @param name: name of HTML control
         @param elements: list of (key, value)
         """
         out = '<select name="%s">' % name         
         for (key, label) in elements:
             selected = ''
             if key == selected_key:
                 selected = ' selected="selected"'
             out += indent_text('<option value="%s"%s>%s</option>'% (key, selected, label), 1)
         out += '</select>'
         return out
      
     def tmpl_warnings(self, warnings=[], ln=cdslang):
         """ returns HTML for warnings """
         from invenio.errorlib import get_msgs_for_code_list
         out = ''
         if type(warnings) is not list:
             warnings = [warnings]
         if len(warnings):
             warnings_parsed = get_msgs_for_code_list(warnings, 'warning', ln)
             for (warning_code, warning_text) in warnings_parsed:
                 out += '<div class="important" style="padding: 10px;">%s</div>' % warning_text 
         return out
 
     def tmpl_back_link(self, link, ln):
         """ returns HTML for a link whose label should be
         'Back to search results'
         """
         _ = gettext_set_language(ln)
         label = _("(Back to search results)")
         out = '<a href="%s">%s</a>' % (link, label)
         return out
        
     def __create_messaging_link(self, to, display_name, ln=cdslang):
         """prints a link to the messaging system"""
         link = "%s/yourmessages.py/write?msg_to=%s&amp;ln=%s" % (weburl, to, ln)
         if to:
             return '<a href="%s" class="maillink">%s</a>' % (link, display_name)
         else:
             return display_name
     
     def tmpl_xml_basket(self, items=[]):
         items_xml = ''
         for item in items:
             items_xml += '  ' + item + '\n'
         return """<?xml version="1.0" encoding="UTF-8"?>
 <collection>
 %s
 </collection>
 """ % items_xml
-            
\ No newline at end of file
+            
diff --git a/modules/websession/lib/webaccount.py b/modules/websession/lib/webaccount.py
index 98ed780a2..112683910 100644
--- a/modules/websession/lib/webaccount.py
+++ b/modules/websession/lib/webaccount.py
@@ -1,245 +1,246 @@
 ## $Id$
 
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
 ##
 ## CDS Invenio 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.
 ##
 ## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc.,
 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
 import sys
 import string
 import cgi
 
 from invenio.config import *
 from invenio.webpage import page
 from invenio.dbquery import run_sql
 from invenio.webuser import getUid,isGuestUser, get_user_preferences, set_user_preferences
 from invenio.access_control_admin import acc_findUserRoleActions
 from invenio.access_control_config import CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS, CFG_EXTERNAL_AUTHENTICATION
 
 from invenio.messages import gettext_set_language
 
 import invenio.template
 websession_templates = invenio.template.load('websession')
 
 imagesurl = "%s/img" % weburl
 
 # perform_info(): display the main features of CDS personalize
 def perform_info(req, ln):
     out = ""
     uid = getUid(req)
 
     return websession_templates.tmpl_account_info(
             ln = ln,
             uid = uid,
             guest = isGuestUser(uid),
             cfg_cern_site = cfg_cern_site,
            );
 
 
 def perform_youradminactivities(uid, ln):
     """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."""
     your_role_actions = acc_findUserRoleActions(uid)
     your_roles = []
     your_admin_activities = []
     guest = isGuestUser(uid)
     for (role, action) in your_role_actions:
         if role not in your_roles:
             your_roles.append(role)
         if action not in your_admin_activities:
             your_admin_activities.append(action)
 
     if "superadmin" in your_roles:
         for action in ["cfgbibformat", "cfgbibharvest", "cfgbibrank", "cfgbibindex", "cfgwebaccess", "cfgwebcomment", "cfgwebsearch", "cfgwebsubmit"]:
             if action not in your_admin_activities:
                 your_admin_activities.append(action)
 
     return websession_templates.tmpl_account_adminactivities(
              ln = ln,
              uid = uid,
              guest = guest,
              roles = your_roles,
              activities = your_admin_activities,
              weburl = weburl,
            )
 
 # perform_display_account(): display a dynamic page that shows the user's account
 def perform_display_account(req,data,bask,aler,sear,msgs,ln):
 
     # load the right message language
     _ = gettext_set_language(ln)
 
     uid = getUid(req)
     #your account
     if isGuestUser(uid):
         user = "guest"
-        accBody = _("""You are logged in as guest. You may want to <A href="../youraccount.py/login?ln=%s">login</A> as a regular user""") % ln + "<BR><BR>"
-        bask=aler=msgs= _("""The <strong class="headline">guest</strong> users need to <A href="../youraccount.py/login?ln=%s">register</A> first""") % ln
+        login = "%s/youraccount.py/login?ln=%s" % (httpsurl, ln)
+        accBody = _("""You are logged in as guest. You may want to <A href="%s">login</A> as a regular user""") % login + "<BR><BR>"
+        bask=aler=msgs= _("""The <strong class="headline">guest</strong> users need to <A href="%s">register</A> first""") % login
         sear= _("No queries found")
     else:
         user = data[0]
         accBody = websession_templates.tmpl_account_body(
                     ln = ln,
                     user = user,
                   )
 
     return websession_templates.tmpl_account_page(
              ln = ln,
              weburl = weburl,
              accBody = accBody,
              baskets = bask,
              alerts = aler,
              searches = sear,
              messages = msgs,
              administrative = perform_youradminactivities(uid, ln)
            )
 
 # template_account() : it is a template for print each of the options from the user's account
 def template_account(title, body, ln):
     return websession_templates.tmpl_account_template(
              ln = ln,
              title = title,
              body = body
            )
 
 # warning_guest_user(): It returns an alert message,showing that the user is a guest user and should log into the system
 def warning_guest_user(type, ln=cdslang):
 
     # load the right message language
     _ = gettext_set_language(ln)
 
     return websession_templates.tmpl_warning_guest_user(
              ln = ln,
              type = type,
            )
 
 ## perform_delete():delete  the account of the user, not implement yet
 def perform_delete(ln):
     return websession_templates.tmpl_account_delete(ln = ln)
 
 ## perform_set(email,password): edit your account parameters, email and password.
 def perform_set(email,password, ln):
 
     try:
         uid = run_sql("SELECT id FROM user where email=%s", (email,))
         uid = uid[0][0]
     except:
         uid = 0
 
     CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL = CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS
     prefs = get_user_preferences(uid)
     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
 
     out = websession_templates.tmpl_user_preferences(
              ln = ln,
              email = email,
              email_disabled = (CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL >= 2),
              password = password,
              password_disabled = (CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS_LOCAL >= 3)
            )
 
     if len(CFG_EXTERNAL_AUTHENTICATION) >= 1:
         try:
             uid = run_sql("SELECT id FROM user where email=%s", (email,))
             uid = uid[0][0]
         except:
             uid = 0
         prefs = get_user_preferences(uid)
         current_login_method = prefs['login_method']
         methods = CFG_EXTERNAL_AUTHENTICATION.keys()
         methods.sort()
 
         out += websession_templates.tmpl_user_external_auth(
                  ln = ln,
                  methods = methods,
                  current = current_login_method,
                  method_disabled = (CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 4)
                )
     return out
 
 ##  create_register_page_box(): register a new account
 def create_register_page_box(referer='', ln=cdslang):
 
     return websession_templates.tmpl_register_page(
              referer = referer,
              ln = ln,
              level = CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS,
              supportemail = supportemail,
              cdsname = cdsname
            )
 
 ##  create_login_page_box(): ask for the user's email and password, for login into the system
 def create_login_page_box(referer='', ln=cdslang):
 
     internal = None
     for system in CFG_EXTERNAL_AUTHENTICATION.keys():
         if not CFG_EXTERNAL_AUTHENTICATION[system][0]:
             internal = system
             break
     register_available = CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS <= 1 and internal
     methods = CFG_EXTERNAL_AUTHENTICATION.keys()
     methods.sort()
     selected = ''
     for method in methods:
         if CFG_EXTERNAL_AUTHENTICATION[method][1] == True:
             selected = method
             break
 
     return websession_templates.tmpl_login_form(
              ln = ln,
              referer = referer,
              internal = internal,
              register_available = register_available,
              methods = methods,
              selected_method = selected,
              supportemail = supportemail,
            )
 
 
 # perform_logout: display the message of not longer authorized,
 def perform_logout(req, ln):
     return websession_templates.tmpl_account_logout(ln = ln)
 
 #def perform_lost: ask the user for his email, in order to send him the lost password
 def perform_lost(ln):
     return websession_templates.tmpl_lost_password_form(
              ln = ln,
              msg = websession_templates.tmpl_lost_password_message(ln = ln, supportemail = supportemail),
            )
 
 # perform_emailSent(email): confirm that the password has been emailed to 'email' address
 def perform_emailSent(email, ln):
     return websession_templates.tmpl_account_emailSent(ln = ln, email = email)
 
 # peform_emailMessage : display a error message when the email introduced is not correct, and sugest to try again
 def perform_emailMessage(eMsg, ln):
     return websession_templates.tmpl_account_emailMessage( ln = ln,
                                            msg = eMsg
                                          )
 
 # perform_back(): template for return to a previous page, used for login,register and setting
 def perform_back(mess,act,linkname='', ln='en'):
     if not linkname:
         linkname = act
 
     return websession_templates.tmpl_back_form(
              ln = ln,
              message = mess,
              act = act,
              link = linkname,
            )
diff --git a/modules/websession/lib/websession_templates.py b/modules/websession/lib/websession_templates.py
index 58cb48d04..94a8e8c09 100644
--- a/modules/websession/lib/websession_templates.py
+++ b/modules/websession/lib/websession_templates.py
@@ -1,809 +1,816 @@
 ## $Id$
 
 ## This file is part of CDS Invenio.
 ## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
 ##
 ## CDS Invenio 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.
 ##
 ## CDS Invenio 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 CDS Invenio; if not, write to the Free Software Foundation, Inc.,
 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
 import urllib
 import time
 import cgi
 import gettext
 import string
 import locale
 
 from invenio.config import *
 from invenio.messages import gettext_set_language
 
 class Template:
     def tmpl_lost_password_message(self, ln, supportemail):
         """
         Defines the text that will be displayed on the 'lost password' page
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'supportemail' *string* - The email of the support team
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         return _("If you have lost password for your CDS Invenio internal account, then please enter your email address below and the lost password will be emailed to you.") +\
                "<br /><br />" +\
                _("Note that if you have been using an external login system (such as CERN NICE), then we cannot do anything and you have to ask there.") +\
                _("Alternatively, you can ask %s to change your login system from external to internal.") % ("""<a href="mailto:%(email)s">%(email)s</a>""" % { 'email' : supportemail }) +\
                "<br><br>"
 
     def tmpl_back_form(self, ln, message, act, link):
         """
         A standard one-message-go-back-link page.
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'message' *string* - The message to display
 
           - 'act' *string* - The action to accomplish when going back
 
           - 'link' *string* - The link text
         """
         out = """
                  <table>
                     <tr>
                       <td align=center>%(message)s
                        <A href="./%(act)s">%(link)s</A></td>
                     </tr>
                  </table>
              """% {
                'message' : message,
                'act'     : act,
                'link'    : link
              }
 
         return out
 
     def tmpl_user_preferences(self, ln, email, email_disabled, password, password_disabled):
         """
         Displays a form for the user to change his email/password.
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'email' *string* - The email of the user
 
           - 'email_disabled' *boolean* - If the user has the right to edit his email
 
           - 'password' *string* - The password of the user
 
           - 'password_disabled' *boolean* - If the user has the right to edit his password
 
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = """
                 <p><big><strong class="headline">Edit parameters</strong></big></p>
-                <form method="post" action="../youraccount.py/change">
+                <form method="post" action="%(httpsurl)s/youraccount.py/change">
                 <p>%(change_user_pass)s</p>
                 <table>
                   <tr><td align="right"><strong>
                       %(new_email)s:</strong><br/>
                       <small class="important">(%(mandatory)s)</small>
                     </td><td>
                       <input type="text" size="25" name="email" %(email_disabled)s value="%(email)s"><br>
                       <small><span class="quicknote">%(example)s:</span>
                         <span class="example">johndoe@example.com</span>
                       </small>
                     </td>
                     <td></td>
                   </tr>
                   <tr>
                     <td align="right"><strong>%(new_password)s:</strong><br>
                       <small class="quicknote">(%(optional)s)</small>
                     </td><td align="left">
                       <input type="password" size="25" name="password" %(password_disabled)s value="%(password)s"><br>
                       <small><span class=quicknote>%(note)s:</span>
                        %(password_note)s
                       </small>
                     </td>
                   </tr>
                   <tr>
                     <td align="right"><strong>%(retype_password)s:</strong></td>
                     <td align="left">
                       <input type="password" size="25" name="password2" %(password_disabled)s value="">
                     </td>
                     <td><input type="hidden" name="action" value="edit"></td>
                   </tr>
                   <tr><td align="center" colspan="3">
                     <code class="blocknote"><input class="formbutton" type="submit" value="%(set_values)s"></code>&nbsp;&nbsp;&nbsp;
                   </td></tr>
                 </table>
               </form>
         """ % {
           'change_user_pass' : _("If you want to change your email address or password, please set new values in the form below."),
           'new_email' : _("New email address"),
           'mandatory' : _("mandatory"),
           'example' : _("Example"),
           'new_password' : _("New password"),
           'optional' : _("optional"),
           'note' : _("Note"),
           'password_note' : _("The password phrase may contain punctuation, spaces, etc."),
           'retype_password' : _("Retype password"),
           'set_values' : _("Set new values"),
 
           'email' : email,
           'email_disabled' : email_disabled and "disabled" or "",
           'password' : password,
           'password_disabled' : password_disabled and "disabled" or "",
+          'httpsurl': httpsurl,
         }
         return out
 
     def tmpl_user_external_auth(self, ln, methods, current, method_disabled):
         """
         Displays a form for the user to change his authentication method.
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'methods' *array* - The methods of authentication
 
           - 'method_disabled' *boolean* - If the user has the right to change this
 
           - 'current' *string* - The currently selected method
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = """
-                 <form method="post" action="../youraccount.py/change">
+                 <form method="post" action="%(httpsurl)s/youraccount.py/change">
                    <big><strong class="headline">%(edit_method)s</strong></big>
                    <p>%(explain_method)s:</p>
                    <table>
                      <tr><td valign="top"><b>%(select_method)s:</b></td><td>
                """ % {
                  'edit_method' : _("Edit login method"),
                  'explain_method' : _("Please select which login method you would like to use to authenticate yourself"),
                  'select_method' : _("Select method"),
+                 'httpsurl': httpsurl,
                }
         for system in methods:
             out += """<input type="radio" name="login_method" value="%(system)s" %(disabled)s %(selected)s>%(system)s<br>""" % {
                      'system' : system,
                      'disabled' : method_disabled and "disabled" or "",
                      'selected' : current == system and "disabled" or "",
                    }
         out += """  </td><td></td></tr>
                    <tr><td></td>
                      <td><input class="formbutton" type="submit" value="%(select_method)s"></td></tr></table>
                     </form>""" % {
                      'select_method' : _("Select method"),
                    }
 
         return out
 
     def tmpl_lost_password_form(self, ln, msg):
         """
         Displays a form for the user to ask for his password sent by email.
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'msg' *string* - Explicative message on top of the form.
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = """
           <form  method="post" action="../youraccount.py/send_email">
             %(msg)s
           <table>
                 <tr>
               <td align="right"><strong>%(email)s:</strong></td>
               <td><input type="text" size="25" name="p_email" value=""></td>
               <td><input type="hidden" name="action" value="lost"></td>
             </tr>
             <tr><td></td>
               <td><code class="blocknote"><input class="formbutton" type="submit" value="%(send)s"></code></td>
             </tr>
           </table>
 
           </form>
           """ % {
             'msg' : msg,
             'email' : _("Email address"),
             'send' : _("Send lost password"),
           }
         return out
 
     def tmpl_account_info(self, ln, uid, guest, cfg_cern_site):
         """
         Displays the account information
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'uid' *string* - The user id
 
           - 'guest' *boolean* - If the user is guest
 
           - 'cfg_cern_site' *boolean* - If the site is a CERN site
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = """<P>%(account_offer)s</P>
                  <blockquote>
                  <dl>
               """ % {
                 'account_offer' : _("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."),
               }
 
         if not guest:
             out += """
                    <dt>
                    <A href="./edit?ln=%(ln)s">%(your_settings)s</A>
                    <dd>%(change_account)s""" % {
                      'ln' : ln,
                      'your_settings' : _("Your Settings"),
                      'change_account' : _("Set or change your account Email address or password. Specify your preferences about the way the interface looks like.")
                    }
 
         out += """
         <dt><A href="../youralerts.py/display?ln=%(ln)s">%(your_searches)s</A>
         <dd>%(search_explain)s
 
         <dt><A href="../yourbaskets.py/display?ln=%(ln)s">%(your_baskets)s</A>
         <dd>%(basket_explain)s""" % {
           'ln' : ln,
           'your_searches' : _("Your Searches"),
           'search_explain' : _("View all the searches you performed during the last 30 days."),
           'your_baskets' : _("Your Baskets"),
           'basket_explain' : _("With baskets you can define specific collections of items, store interesting records you want to access later or share with others."),
         }
         if guest:
             out += self.tmpl_warning_guest_user(ln = ln, type = "baskets")
         out += """
         <dt><A href="../youralerts.py/list?ln=%s">%(your_alerts)s</A>
         <dd>%(explain_alerts)s""" % {
           'ln' : ln,
           'your_alerts' : _("Your Alerts"),
           'explain_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 guest:
             out += self.tmpl_warning_guest_user(type="alerts", ln = ln)
 
         if cfg_cern_site:
             out += """
             <dt><A href="http://weblib.cern.ch/cgi-bin/checkloan?uid=&version=2">%(your_loans)s</A>
             <dd>%(explain_loans)s""" % {
               'your_loans' : _("Your Loans"),
               'explain_loans' : _("Check out book you have on load, submit borrowing requests, etc.  Requires CERN ID."),
             }
 
         out += """
         </dl>
         </blockquote>"""
 
         return out
 
     def tmpl_warning_guest_user(self, ln, type):
         """
         Displays a warning message about the specified type
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'type' *string* - The type of data that will get lost in case of guest account
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         msg= _("""You are logged in as a guest user, so your %s will disappear at the end of the current session. If you wish you can
-               <a href="../youraccount.py/login?ln=%s">login or register here</a>.""") % (type, ln)
+               <a href="%s/youraccount.py/login?ln=%s">login or register here</a>.""") % (type, httpsurl, ln)
         return """<table class="errorbox" summary="">
                            <thead>
                             <tr>
                              <th class="errorboxheader">%s</th>
                             </tr>
                            </thead>
                           </table>""" % msg
 
     def tmpl_account_body(self, ln, user):
         """
         Displays the body of the actions of the user
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'user' *string* - The user name
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
-        return _("""You are logged in as %s. You may want to a) <A href="../youraccount.py/logout?ln=%s">logout</A>; b) edit your <A href="../youraccount.py/edit?ln=%s">account settings</a>.""") % (user, ln, ln) + "<BR><BR>"
+        return _("""You are logged in as %(user)s. You may want to a) <A href="%(logout)s">logout</A>; b) edit your <A href="%(edit)s">account settings</a>.""") % {
+            'user': user,
+            'logout': '%s/youraccount.py/logout?ln=%s' % (httpsurl, ln),
+            'edit': '%s/youraccount.py/edit?ln=%s' % (httpsurl, ln)
+            } + "<BR><BR>"
 
     def tmpl_account_template(self, title, body, ln):
         """
         Displays a block of the your account page
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'title' *string* - The title of the block
 
           - 'body' *string* - The body of the block
         """
 
         out =""
         out +="""
               <table class="searchbox" width="90%%" summary=""  >
                            <thead>
                             <tr>
                              <th class="searchboxheader">%s</th>
                             </tr>
                            </thead>
                            <tbody>
                             <tr>
                              <td class="searchboxbody">%s</td>
                             </tr>
                            </tbody>
                           </table>""" % (title, body)
         return out
 
     def tmpl_account_page(self, ln, weburl, accBody, baskets, alerts, searches, messages, administrative):
         """
         Displays the your account page
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'weburl' *string* - The URL of CDS Invenio
 
           - 'accBody' *string* - The body of the heading block
 
           - 'baskets' *string* - The body of the baskets block
 
           - 'alerts' *string* - The body of the alerts block
 
           - 'searches' *string* - The body of the searches block
 
           - 'messages' *string* - The body of the messages block
 
           - 'administrative' *string* - The body of the administrative block
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = ""
         out += self.tmpl_account_template(_("Your Account"), accBody, ln)
         #your baskets
         out += self.tmpl_account_template(_("Your Baskets"), baskets, ln)
         out += self.tmpl_account_template(_("Your Messages"), messages, ln)
         out += self.tmpl_account_template(_("Your Alert Searches"), alerts, ln)
         out += self.tmpl_account_template(_("Your Searches"), searches, ln)
         out += self.tmpl_account_template(_("Your Submissions"),
                                _("You can consult the list of %(your_submissions)s and inquire about their status.") % {
                                  'your_submissions' :
                                     """<a href="%(weburl)s/yoursubmissions.py?ln=%(ln)s">%(your_sub)s</a>""" % {
                                       'ln' : ln,
                                       'weburl' : weburl,
                                       'your_sub' : _("your submissions")
                                     }
                                }, ln)
         out += self.tmpl_account_template(_("Your Approvals"),
                                _("You can consult the list of %(your_approvals)s with the documents you approved or refereed.") % {
                                  'your_approvals' :
                                     """ <a href="%(weburl)s/yourapprovals.py?ln=%(ln)s">%(your_app)s</a>""" % {
                                       'ln' : ln,
                                       'weburl' : weburl,
                                       'your_app' : _("your approvals"),
                                     }
                                }, ln)
         out += self.tmpl_account_template(_("Your Administrative Activities"), administrative, ln)
         return out
 
     def tmpl_account_emailMessage(self, ln, msg):
         """
         Displays a link to retrieve the lost password
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'msg' *string* - Explicative message on top of the form.
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out =""
         out +="""
         <body>
            %(msg)s <A href="../youraccount.py/lost?ln=%(ln)s">%(try_again)s</A>
 
               </body>
 
           """ % {
             'ln' : ln,
             'msg' : msg,
             'try_again' : _("Try again")
           }
         return out
 
     def tmpl_account_emailSent(self, ln, email):
         """
         Displays a confirmation message for an email sent
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'email' *string* - The email to which the message has been sent
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out =""
         out += _("Okay, password has been emailed to %s") % email
         return out
 
     def tmpl_account_delete(self, ln):
         """
         Displays a confirmation message about deleting the account
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = "<p>" + _("""Deleting your account""")
         return out
 
     def tmpl_account_logout(self, ln):
         """
         Displays a confirmation message about logging out
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = ""
         out += _("""You are no longer recognized.  If you wish you can <A href="./login?ln=%s">login here</A>.""") % ln
         return out
 
     def tmpl_login_form(self, ln, referer, internal, register_available, methods, selected_method, supportemail):
         """
         Displays a login form
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'referer' *string* - The referer URL - will be redirected upon after login
 
           - 'internal' *boolean* - If we are producing an internal authentication
 
           - 'register_available' *boolean* - If users can register freely in the system
 
           - 'methods' *array* - The available authentication methods
 
           - 'selected_method' *string* - The default authentication method
 
           - 'supportemail' *string* - The email of the support team
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = "<p>%(please_login)s<br>" % {
                 'please_login' : _("If you already have an account, please login using the form below.")
               }
 
         if register_available:
             out += _("""If you don't own an account yet, please <a href="../youraccount.py/register?ln=%s">register</a> an internal account.""") % ln
         else:
             out += _("""It is not possible to create an account yourself. Contact %s if you want an account.""") % (
                       """<a href="mailto:%(email)s">%(email)s</a>""" % { 'email' : supportemail }
                     )
         out += """<form method="post" action="../youraccount.py/login">
                   <table>
 
                """
         if len(methods) > 1:
             # more than one method, must make a select
             login_select = """<select name="login_method">"""
             for method in methods:
                 login_select += """<option value="%(method)s" %(selected)s>%(method)s</option>""" % {
                                   'method' : method,
                                   'selected' : (method == selected_method and "selected" or "")
                                 }
             login_select += "</select>"
             out += """
                    <tr>
                       <td align="right">%(login_title)s</td>
                       <td>%(login_select)s</td>
                       <td></td>
                    </tr>""" % {
                      'login_title' : _("Login via:"),
                      'login_select' : login_select,
                    }
         else:
             # only one login method available
             out += """<input type="hidden" name="login_method" value="%s">""" % (methods[0])
 
         out += """<tr>
                    <td align="right">
                      <input type="hidden" name="ln" value="%(ln)s">
                      <input type="hidden" name="referer" value="%(referer)s">
                      <strong>%(username)s:</strong>
                    </td>
                    <td><input type="text" size="25" name="p_email" value=""></td>
                    <td></td>
                   </tr>
                   <tr>
                    <td align="right"><strong>%(password)s:</strong></td>
                    <td align="left"><input type="password" size="25" name="p_pw" value=""></td>
                    <td></td>
                   </tr>
                   <tr>
                    <td></td>
                    <td align="center" colspan="3"><code class="blocknote"><input class="formbutton" type="submit" name="action" value="%(login)s"></code>""" % {
                        'ln': ln,
                        'referer' : cgi.escape(referer),
                        'username' : _("Username"),
                        'password' : _("Password"),
                        'login' : _("login"),
                        }
         if internal:
             out += """&nbsp;&nbsp;&nbsp;(<a href="./lost?ln=%(ln)s">%(lost_pass)s</a>)""" % {
                      'ln' : ln,
                      'lost_pass' : _("Lost your password?")
                    }
         out += """</td><td></td>
                     </tr>
                   </table></form>"""
         return out
 
     def tmpl_register_page(self, ln, referer, level, supportemail, cdsname):
         """
         Displays a login form
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'referer' *string* - The referer URL - will be redirected upon after login
 
           - 'level' *int* - Login level (0 - all access, 1 - accounts activated, 2+ - no self-registration)
 
           - 'supportemail' *string* - The email of the support team
 
           - 'cdsname' *string* - The name of the installation
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = ""
         if level <= 1:
             out += _("""Please enter your email address and desired password:""")
             if level == 1:
                 out += _("The account will not be possible to use before it has been verified and activated.")
             out += """
               <form method="post" action="../youraccount.py/register">
               <input type="hidden" name="referer" value="%(referer)s">
               <table>
                 <tr>
                  <td align="right"><strong>%(email_address)s:</strong><br><small class="important">(%(mandatory)s)</small></td>
                  <td><input type="text" size="25" name="p_email" value=""><br>
                      <small><span class="quicknote">%(example)s:</span>
                      <span class="example">johndoe@example.com</span></small>
                  </td>
                  <td></td>
                 </tr>
                 <tr>
                  <td align="right"><strong>%(password)s:</strong><br><small class="quicknote">(%(optional)s)</small></td>
                  <td align="left"><input type="password" size="25" name="p_pw" value=""><br>
                     <small><span class="quicknote">%(note)s:</span> %(password_contain)s</small>
                  </td>
                  <td></td>
                 </tr>
                 <tr>
                  <td align="right"><strong>%(retype)s:</strong></td>
                  <td align="left"><input type="password" size="25" name="p_pw2" value=""></td>
                  <td></td>
                 </tr>
                 <tr>
                  <td></td>
                  <td align="left" colspan="3"><code class="blocknote"><input class="formbutton" type="submit" name="action" value="%(register)s"></code></td>
                 </tr>
               </table>
               <p><strong>%(note)s:</strong> %(explain_acc)s""" % {
                 'referer' : cgi.escape(referer),
                 'email_address' : _("Email address"),
                 'password' : _("Password"),
                 'mandatory' : _("mandatory"),
                 'optional' : _("optional"),
                 'example' : _("Example"),
                 'note' : _("Note"),
                 'password_contain' : _("The password phrase may contain punctuation, spaces, etc."),
                 'retype' : _("Retype Password"),
                 'register' : _("register"),
                 'explain_acc' : _("Please do not use valuable passwords such as your Unix, AFS or NICE passwords with this service. Your email address will stay strictly confidential and will not be disclosed to any third party. It will be used to identify you for personal services of %s. For example, you may set up an automatic alert search that will look for new preprints and will notify you daily of new arrivals by email.") % cdsname,
               }
         return out
 
     def tmpl_account_adminactivities(self, ln, weburl, uid, guest, roles, activities):
         """
         Displays the admin activities block for this user
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'weburl' *string* - The address of the site
 
           - 'uid' *string* - The used id
 
           - 'guest' *boolean* - If the user is guest
 
           - 'roles' *array* - The current user roles
 
           - 'activities' *array* - The user allowed activities
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = ""
         # guest condition
         if guest:
             return _("""You seem to be the guest user.  You have to <a href="../youraccount.py/login?ln=%s">login</a> first.""") % ln
 
         # no rights condition
         if not roles:
             return "<p>" + _("You are not authorized to access administrative functions.") + "</p>"
 
         # displaying form
         out += "<p>" + _("You seem to be <em>%s</em>.") % string.join(roles, ", ") + " "
         out += _("Here are some interesting web admin links for you:")
 
         # print proposed links:
         activities.sort(lambda x, y: cmp(string.lower(x), string.lower(y)))
         for action in activities:
             if action == "cfgbibformat":
                 out += """<br>&nbsp;&nbsp;&nbsp; <a href="%s/admin/bibformat/?ln=%s">%s</a>""" % (weburl, ln, _("Configure BibFormat"))
             if action == "cfgbibharvest":
                 out += """<br>&nbsp;&nbsp;&nbsp; <a href="%s/admin/bibharvest/bibharvestadmin.py?ln=%s">%s</a>""" % (weburl, ln, _("Configure BibHarvest"))
             if action == "cfgbibindex":
                 out += """<br>&nbsp;&nbsp;&nbsp; <a href="%s/admin/bibindex/bibindexadmin.py?ln=%s">%s</a>""" % (weburl, ln, _("Configure BibIndex"))
             if action == "cfgbibrank":
                 out += """<br>&nbsp;&nbsp;&nbsp; <a href="%s/admin/bibrank/bibrankadmin.py?ln=%s">%s</a>""" % (weburl, ln, _("Configure BibRank"))
             if action == "cfgwebaccess":
                 out += """<br>&nbsp;&nbsp;&nbsp; <a href="%s/admin/webaccess/?ln=%s">%s</a>""" % (weburl, ln, _("Configure WebAccess"))
             if action == "cfgwebcomment":
                 out += """<br>&nbsp;&nbsp;&nbsp; <a href="%s/admin/webcomment/webcommentadmin.py?ln=%s">%s</a>""" % (weburl, ln, _("Configure WebComment"))
             if action == "cfgwebsearch":
                 out += """<br>&nbsp;&nbsp;&nbsp; <a href="%s/admin/websearch/websearchadmin.py?ln=%s">%s</a>""" % (weburl, ln, _("Configure WebSearch"))
             if action == "cfgwebsubmit":
                 out += """<br>&nbsp;&nbsp;&nbsp; <a href="%s/admin/websubmit/?ln=%s">%s</a>""" % (weburl, ln, _("Configure WebSubmit"))
         out += "<br>" + _("""For more admin-level activities, see the complete %(admin_area)s""") % {
                            'admin_area' : """<a href="%s/admin/index.%s.html">%s</a>.""" % (weburl, ln, _("Admin Area"))
                          }
 
         return out
 
     def tmpl_create_userinfobox(self, ln, weburl, guest, email, submitter, referee, admin):
         """
         Displays the user block
 
         Parameters:
 
           - 'ln' *string* - The language to display the interface in
 
           - 'weburl' *string* - The address of the site
 
           - 'guest' *boolean* - If the user is guest
 
           - 'email' *string* - The user email (if known)
 
           - 'submitter' *boolean* - If the user is submitter
 
           - 'referee' *boolean* - If the user is referee
 
           - 'admin' *boolean* - If the user is admin
         """
 
         # load the right message language
         _ = gettext_set_language(ln)
 
         out = """<img src="%s/img/head.gif" border="0" alt="">""" % weburl
         if guest:
             out += """%(guest_msg)s ::
     	       <a class="userinfo" href="%(weburl)s/youraccount.py/display?ln=%(ln)s">%(session)s</a> ::
                    <a class="userinfo" href="%(weburl)s/youralerts.py/list?ln=%(ln)s">%(alerts)s</a> ::
                    <a class="userinfo" href="%(weburl)s/yourbaskets.py/display?ln=%(ln)s">%(baskets)s</a> ::
-                   <a class="userinfo" href="%(weburl)s/youraccount.py/login?ln=%(ln)s">%(login)s</a>""" % {
+                   <a class="userinfo" href="%(httpsurl)s/youraccount.py/login?ln=%(ln)s">%(login)s</a>""" % {
                      'weburl' : weburl,
+                     'httpsurl': httpsurl,
                      'ln' : ln,
                      'guest_msg' : _("guest"),
                      'session' : _("session"),
                      'alerts' : _("alerts"),
                      'baskets' : _("baskets"),
                      'login' : _("login"),
                    }
         else:
             out += """%(email)s ::
     	       <a class="userinfo" href="%(weburl)s/youraccount.py/display?ln=%(ln)s">%(account)s</a> ::
                    <a class="userinfo" href="%(weburl)s/youralerts.py/list?ln=%(ln)s">%(alerts)s</a> ::
                    <a class="userinfo" href="%(weburl)s/yourmessages.py/display?ln=%(ln)s">%(messages)s</a> ::
 		   <a class="userinfo" href="%(weburl)s/yourbaskets.py/display?ln=%(ln)s">%(baskets)s</a> :: """ % {
                      'email' : email,
                      'weburl' : weburl,
                      'ln' : ln,
                      'account' : _("account"),
                      'alerts' : _("alerts"),
 		     'messages': _("messages"),
                      'baskets' : _("baskets"),
                    }
             if submitter:
                 out += """<a class="userinfo" href="%(weburl)s/yoursubmissions.py?ln=%(ln)s">%(submission)s</a> :: """ % {
                          'weburl' : weburl,
                          'ln' : ln,
                          'submission' : _("submissions"),
                        }
             if referee:
                 out += """<a class="userinfo" href="%(weburl)s/yourapprovals.py?ln=%(ln)s">%(approvals)s</a> :: """ % {
                          'weburl' : weburl,
                          'ln' : ln,
                          'approvals' : _("approvals"),
                        }
             if admin:
                 out += """<a class="userinfo" href="%(weburl)s/youraccount.py/youradminactivities?ln=%(ln)s">%(administration)s</a> :: """ % {
                          'weburl' : weburl,
                          'ln' : ln,
                          'administration' : _("administration"),
                        }
             out += """<a class="userinfo" href="%(weburl)s/youraccount.py/logout?ln=%(ln)s">%(logout)s</a>""" % {
                      'weburl' : weburl,
                      'ln' : ln,
                      'logout' : _("logout"),
                    }
         return out