########## admin ##########
# language: english
-# $Id: admin_en.properties,v 1.48 2003/05/03 23:30:49 zapata Exp $
+# $Id: admin_en.properties,v 1.48.2.1 2003/06/19 02:24:12 zapata Exp $
languagename=English
# users
user.htmltitle=User
user.login=Login
+user.ownpassword=Your own password
+user.oldpassword=Old password
user.password=Password
user.password2=Password (confirmation)
user.admin=Admin
# head
head.start=start
head.logout=logout
+head.changepassword=password
head.help=help
head.search=search
head.logged_in=logged in
user.error.missingpasswords=The new password must be entered twice
user.error.passwordmismatch=The passwords are not equal
user.error.missingpassword=A password must be entered
+user.error.incorrectpassword= Incorrect password
########## infomessages ##########
</td></tr></table>
<br>
<br>
- <font color="#cc0033" size="+3"> <b><span id="indy">my.mir.indymedia.org</span></b></font>
+ <font color="#cc0033" size="+3"> <b><span id="indy">${config["Mir.Name"]}</span></b></font>
</td>
</tr>
<tr>
* Mir.java - main servlet, that dispatches to servletmodules
*
* @author $Author: zapata $
- * @version $Id: Mir.java,v 1.49.2.1 2003/06/13 03:54:08 zapata Exp $
+ * @version $Id: Mir.java,v 1.49.2.2 2003/06/19 02:24:12 zapata Exp $
*
*/
public class Mir extends AbstractServlet {
}
}
- // FIXME: this should probalby go into AbstractServlet so it can be used in
- // OpenMir as well -mh
protected String getDefaultLanguage(HttpServletRequest aRequest) {
String defaultlanguage =
MirGlobal.config().getString("Mir.Login.DefaultLanguage", "");
return fallbackLocale;
}
- public void process(HttpServletRequest aRequest, HttpServletResponse aResponse)
- throws ServletException, IOException, UnavailableException {
- long startTime = System.currentTimeMillis();
- long sessionConnectTime = 0;
- EntityUsers userEntity;
- HttpSession session;
- String http = "";
+ public void process(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletException, IOException, UnavailableException {
+ try {
+ long startTime = System.currentTimeMillis();
+ long sessionConnectTime = 0;
+ EntityUsers userEntity;
+ HttpSession session;
- configuration.addProperty("ServletName", getServletName());
+ configuration.addProperty("ServletName", getServletName());
- session = aRequest.getSession(true);
- userEntity = (EntityUsers) session.getAttribute("login.uid");
+ session = aRequest.getSession(true);
+ userEntity = ServletHelper.getUser(aRequest);
- if (aRequest.getServerPort() == 443) {
- http = "https";
- }
- else {
- http = "http";
- }
+ setNoCaching(aResponse);
- setNoCaching(aResponse);
+ Locale locale = new Locale(getDefaultLanguage(aRequest), "");
- Locale locale = new Locale(getDefaultLanguage(aRequest), "");
+ aResponse.setContentType("text/html; charset=" +
+ configuration.getString("Mir.DefaultHTMLCharset", "UTF-8"));
- aResponse.setContentType("text/html; charset=" +
- configuration.getString("Mir.DefaultHTMLCharset", "UTF-8"));
+ String moduleName = aRequest.getParameter("module");
+ checkLanguage(session, aRequest);
- String moduleName = aRequest.getParameter("module");
- checkLanguage(session, aRequest);
+ // Authentication
+ if ( ( (moduleName != null) && moduleName.equals("login")) || (userEntity == null)) {
+ String user = aRequest.getParameter("login");
+ String passwd = aRequest.getParameter("password");
+ logger.debug("--login: evaluating for user: " + user);
+ userEntity = allowedUser(user, passwd);
- // Authentication
- if (((moduleName != null) && moduleName.equals("login")) || (userEntity == null)) {
- String user = aRequest.getParameter("login");
- String passwd = aRequest.getParameter("password");
- logger.debug("--login: evaluating for user: " + user);
- userEntity = allowedUser(user, passwd);
+ if (userEntity == null) {
+ // login failed: redirecting to login
+ logger.warn("--login: failed!");
+ _sendLoginPage(aResponse, aRequest, aResponse.getWriter());
- if (userEntity == null) {
- // login failed: redirecting to login
- logger.warn("--login: failed!");
- _sendLoginPage(aResponse, aRequest, aResponse.getWriter());
+ return;
+ }
+ else if ( (moduleName != null) && moduleName.equals("login")) {
+ // login successful
+ logger.info("--login: successful! setting uid: " + userEntity.getId());
+ ServletHelper.setUser(aRequest, userEntity);
- return;
- }
- else if ((moduleName != null) && moduleName.equals("login")) {
- // login successful
- logger.info("--login: successful! setting uid: " + userEntity.getId());
- session.setAttribute("login.uid", userEntity);
- logger.debug("--login: trying to retrieve login.target");
-
- String target = (String) session.getAttribute("login.target");
-
- if (target != null) {
- logger.debug("Redirect: " + target);
-
- int serverPort = aRequest.getServerPort();
- String redirect = "";
- String redirectString = "";
-
- if (serverPort == 80) {
- redirect =
- aResponse.encodeURL(http + "://" + aRequest.getServerName() + target);
- redirectString =
- "<html><head><meta http-equiv=refresh content=\"1;URL=" +
- redirect + "\"></head><body>going <a href=\"" + redirect +
- "\">Mir</a></body></html>";
- } else {
- redirect =
- aResponse.encodeURL(http + "://" + aRequest.getServerName() + ":" +
- aRequest.getServerPort() + target);
- redirectString =
- "<html><head><meta http-equiv=refresh content=\"1;URL=" +
- redirect + "\"></head><body>going <a href=\"" + redirect +
- "\">Mir</a></body></html>";
- }
+ logger.debug("--login: trying to retrieve login.target");
+ String target = (String) session.getAttribute("login.target");
+
+ if (target != null) {
+ logger.debug("Redirect: " + target);
- aResponse.getWriter().println(redirectString);
+ aResponse.sendRedirect(
+ MirPropertiesConfiguration.instance().getString("RootUri") + "/Mir?" + target);
- //aResponse.sendRedirect(redirect);
- } else {
- // redirecting to default target
- logger.debug("--login: no target - redirecting to default");
- _sendStartPage(aResponse, aRequest, aResponse.getWriter(), userEntity);
+ }
+ else {
+ logger.debug("--login: no target - redirecting to default");
+ _sendStartPage(aResponse, aRequest, aResponse.getWriter(), userEntity);
+ }
+
+ return;
}
+ // if login succesful
+ }
+ // if login
+
+ if ( (moduleName != null) && moduleName.equals("logout")) {
+ logger.info("--logout");
+ session.invalidate();
+
+ _sendLoginPage(aResponse, aRequest, aResponse.getWriter());
return;
}
- // if login succesful
- }
- // if login
-
- if ((moduleName != null) && moduleName.equals("logout")) {
- logger.info("--logout");
- session.invalidate();
- _sendLoginPage(aResponse, aRequest, aResponse.getWriter());
+ // Check if authed!
+ if (userEntity == null) {
+ // redirect to loginpage
+ String redirectString = aRequest.getRequestURI();
+ String queryString = aRequest.getQueryString();
- return;
- }
+ if ( (queryString != null) && queryString.length() != 0) {
+ redirectString += ("?" + aRequest.getQueryString());
+ session.setAttribute("login.target", redirectString);
+ }
- // Check if authed!
- if (userEntity == null) {
- // redirect to loginpage
- String redirectString = aRequest.getRequestURI();
- String queryString = aRequest.getQueryString();
+ _sendLoginPage(aResponse, aRequest, aResponse.getWriter());
- if ((queryString != null) && queryString.length()!=0) {
- redirectString += ("?" + aRequest.getQueryString());
- session.setAttribute("login.target", redirectString);
+ return;
}
- _sendLoginPage(aResponse, aRequest, aResponse.getWriter());
+ // If no module is specified goto standard startpage
+ if ( (moduleName == null) || moduleName.equals("")) {
+ _sendStartPage(aResponse, aRequest, aResponse.getWriter(), userEntity);
- return;
- }
-
- // If no module is specified goto standard startpage
- if ((moduleName == null) || moduleName.equals("")) {
-// logger.debug("no module: redirect to standardpage");
- _sendStartPage(aResponse, aRequest, aResponse.getWriter(), userEntity);
+ return;
+ }
- return;
- }
+ try {
+ // get servletmodule by parameter and continue with dispacher
+ ServletModule smod = getServletModuleForName(moduleName);
+ ServletModuleDispatch.dispatch(smod, aRequest, aResponse);
+ }
+ catch (Throwable e) {
+ Throwable cause = ExceptionFunctions.traceCauseException(e);
- try {
- // get servletmodule by parameter and continue with dispacher
- ServletModule smod = getServletModuleForName(moduleName);
- ServletModuleDispatch.dispatch(smod, aRequest, aResponse);
- }
- catch (Throwable e) {
- Throwable cause = ExceptionFunctions.traceCauseException(e);
+ if (cause instanceof ServletModuleUserExc)
+ handleUserError(aRequest, aResponse, aResponse.getWriter(), (ServletModuleUserExc) cause);
+ else
+ handleError(aRequest, aResponse, aResponse.getWriter(), cause);
- if (cause instanceof ServletModuleUserExc)
- handleUserError(aRequest, aResponse, aResponse.getWriter(), (ServletModuleUserExc) cause);
- else
- handleError(aRequest, aResponse, aResponse.getWriter(), cause);
+ }
+ // timing...
+ sessionConnectTime = System.currentTimeMillis() - startTime;
+ logger.info("EXECTIME (" + moduleName + "): " + sessionConnectTime + " ms");
+ }
+ catch (Throwable t) {
+ throw new ServletException(t.toString());
}
-
- // timing...
- sessionConnectTime = System.currentTimeMillis() - startTime;
- logger.info("EXECTIME (" + moduleName + "): " + sessionConnectTime + " ms");
}
/**
String sessionUrl = aResponse.encodeURL("");
try {
- Map mergeData = ServletHelper.makeGenerationData(aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale()}, "bundles.admin", "bundles.adminlocal");
+ Map mergeData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale()}, "bundles.admin", "bundles.adminlocal");
mergeData.put("messages",
new CachingRewindableIterator(
new EntityIteratorAdapter( "", "webdb_create desc", 10,
public String getServletInfo() {
return "Mir " + configuration.getString("Mir.Version");
}
-
-/* private void checkLanguage(HttpSession session, HttpServletRequest aRequest) {
- // a lang parameter always sets the language
- String lang = aRequest.getParameter("language");
-
- if (lang != null) {
- logger.info("selected language " + lang + " overrides accept-language");
- setLanguage(session, lang);
- }
- // otherwise store language from accept header in session
- else if (session.getAttribute("language") == null) {
- logger.info("accept-language is " + aRequest.getLocale().getLanguage());
- setLanguage(session, aRequest.getLocale().getLanguage());
- }
- }
-*/
}
Mir.Admin.FallbackLanguage=en
+# Which usernames have admin priviliges (, seperated usernames)
+AccessControl.SuperUsers = admin
+
# the templates
Mir.Localizer.Producer.GeneratorLibrary= default=freemarker(etc/producer/)
Mir.Localizer.Admin.GeneratorLibrary= default=freemarker(templates/admin/)
--- /dev/null
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir 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.
+ *
+ * Mir 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 Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+
+package mircoders.accesscontrol;
+
+import java.util.*;
+import mir.log.*;
+import mir.config.*;
+import mircoders.entity.*;
+import mircoders.global.*;
+
+public class AccessControl {
+ private UserAccessControl user;
+ protected LoggerWrapper logger = new LoggerWrapper("Global.AccessControl");
+ protected MirPropertiesConfiguration configuration;
+
+ public AccessControl() {
+ try {
+ configuration = MirPropertiesConfiguration.instance();
+
+ user = new UserAccessControl(configuration.getVector("AccessControl.SuperUsers"));
+ }
+ catch (Throwable t) {
+ throw new RuntimeException(t.toString());
+ }
+ }
+
+ public UserAccessControl user() {
+ return user;
+ }
+
+ public class UserAccessControl {
+ private List superusers;
+
+ public UserAccessControl(List aSuperUsers) {
+ superusers = new Vector(aSuperUsers);
+ }
+
+ public void assertMayAddUsers(EntityUsers aSubject) throws AuthorizationExc, AuthorizationFailure {
+ try {
+ if (!mayAddUsers(aSubject))
+ throw new AuthorizationExc("not allowed to add users");
+ }
+ catch (Throwable t) {
+ throw new AuthorizationFailure(t);
+ }
+
+ }
+
+ public boolean mayAddUsers(EntityUsers aSubject) {
+ return superusers.contains(aSubject.getValue("login"));
+ }
+
+ public void assertMayEditUser(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure {
+ try {
+ if (!mayEditUser(aSubject, anObject))
+ throw new AuthorizationExc("not allowed to edit user " + anObject.getId());
+ }
+ catch (Throwable t) {
+ throw new AuthorizationFailure(t);
+ }
+
+ }
+
+ public boolean mayEditUser(EntityUsers aSubject, EntityUsers anObject) {
+ return superusers.contains(aSubject.getValue("login"));
+ }
+
+ public boolean mayEditUsers(EntityUsers aSubject) {
+ return superusers.contains(aSubject.getValue("login"));
+ }
+
+ public void assertMayDeleteUser(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure {
+ try {
+ if (!mayDeleteUser(aSubject, anObject))
+ throw new AuthorizationExc("not allowed to delete user " + anObject.getId());
+ }
+ catch (Throwable t) {
+ throw new AuthorizationFailure(t);
+ }
+ }
+
+ public boolean mayDeleteUser(EntityUsers aSubject, EntityUsers anObject) {
+ return superusers.contains(aSubject.getValue("login"));
+ }
+
+ public boolean mayDeleteUsers(EntityUsers aSubject) {
+ return superusers.contains(aSubject.getValue("login"));
+ }
+
+ public boolean mayChangeUserPassword(EntityUsers aSubject, EntityUsers anObject) {
+ return aSubject.getId().equals(anObject.getId()) || superusers.contains(aSubject.getValue("login"));
+ }
+
+ public void assertMayChangeUserPassword(EntityUsers aSubject, EntityUsers anObject) throws AuthorizationExc, AuthorizationFailure {
+ try {
+ if (!mayChangeUserPassword(aSubject, anObject))
+ throw new AuthorizationExc("not allowed to change user " + anObject.getId()+"'s password");
+ }
+ catch (Throwable t) {
+ throw new AuthorizationFailure(t);
+ }
+
+ }
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir 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.
+ *
+ * Mir 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 Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mircoders.accesscontrol;
+
+import multex.Exc;
+
+public class AuthorizationExc extends Exc {
+ public AuthorizationExc(String aMessage) {
+ super(aMessage);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir 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.
+ *
+ * Mir 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 Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mircoders.accesscontrol;
+
+import multex.Failure;
+
+public class AuthorizationFailure extends Failure {
+
+ public AuthorizationFailure(String aMessage, Throwable aCause) {
+ super (aMessage, aCause);
+ }
+
+ public AuthorizationFailure(Throwable aCause) {
+ this (aCause.getMessage(), aCause);
+ }
+}
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
* this class implements mapping of one line of the database table content
* to a java object
*
- * @version $Id: EntityContent.java,v 1.19 2003/04/21 12:42:54 idfx Exp $
+ * @version $Id: EntityContent.java,v 1.19.2.1 2003/06/19 02:24:12 zapata Exp $
* @author mir-coders group
*
*/
if (_entCache.containsKey(key)) {
return (TemplateModel)_entCache.get(key);
}
- if (key.equals("to_comments")) {
+/* if (key.equals("to_comments")) {
try {
_entCache.put(key, getComments());
return (TemplateModel)_entCache.get(key);
else {
return new SimpleScalar(getValue(key));
}
-
+*/
}
return null;
}
*
* @return freemarker.template.SimpleList
*/
- private EntityList getComments() throws StorageObjectFailure {
- return ((DatabaseContent)theStorageObject).getComments(this);
- }
+// private EntityList getComments() throws StorageObjectFailure {
+// return ((DatabaseContent)theStorageObject).getComments(this);
+// }
private boolean hasMedia() throws StorageObjectFailure
{
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
import mir.misc.ConfigException;
import mircoders.localizer.MirCachingLocalizerDecorator;
import mircoders.localizer.MirLocalizer;
+import mircoders.accesscontrol.*;
public class MirGlobal {
static private MirPropertiesConfiguration configuration;
static private ProducerEngine producerEngine;
static private Abuse abuse;
static private MRUCache mruCache;
+ static private AccessControl accessControl;
public static MirLocalizer localizer() {
String localizerClassName;
public static MRUCache mruCache() {
synchronized(MirGlobal.class) {
if (mruCache == null) {
- mruCache = new MRUCache();
+ mruCache = new MRUCache();
}
return mruCache;
}
}
+
+ public static synchronized AccessControl accessControl() {
+ if (accessControl == null) {
+ accessControl=new AccessControl();
+ }
+
+ return accessControl;
+ }
}
-
+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
}
}
+ public boolean checkUserPassword(EntityUsers aUser, String aPassword) throws ModuleExc, ModuleFailure {
+ try {
+ return aUser.getValue("password").equals(MirGlobal.localizer().adminInterface().makePasswordDigest(aPassword));
+ }
+ catch (Throwable t) {
+ throw new ModuleFailure(t);
+ }
+ }
+
private Map digestPassword(Map aValues) throws ModuleExc, ModuleFailure {
Map result = aValues;
import java.util.Locale;
import java.util.Map;
-import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.*;
import org.apache.struts.util.MessageResources;
import mir.util.CachingRewindableIterator;
import mir.util.ResourceBundleGeneratorFunction;
import mircoders.global.MirGlobal;
+import mircoders.entity.*;
public class ServletHelper {
static LoggerWrapper logger = new LoggerWrapper("ServletModule.Helper");
- public static Map makeGenerationData(HttpServletResponse aResponse, Locale[] aLocales) throws ServletModuleExc {
- return makeGenerationData(aResponse, aLocales, "bundles.adminlocal", "bundles.admin");
+ public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales) throws ServletModuleExc {
+ return makeGenerationData(aRequest, aResponse, aLocales, "bundles.adminlocal", "bundles.admin");
}
- public static Map makeGenerationData(HttpServletResponse aResponse, Locale[] aLocales, String aBundle) throws ServletModuleExc {
- return makeGenerationData(aResponse, aLocales, aBundle, aBundle);
+ public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle) throws ServletModuleExc {
+ return makeGenerationData(aRequest, aResponse, aLocales, aBundle, aBundle);
}
- public static Map makeGenerationData(HttpServletResponse aResponse, Locale[] aLocales, String aBundle, String aDefaultBundle) throws ServletModuleExc {
+ public static Map makeGenerationData(HttpServletRequest aRequest, HttpServletResponse aResponse, Locale[] aLocales, String aBundle, String aDefaultBundle) throws ServletModuleExc {
try {
Map result = new HashMap();
aResponse.encodeURL(MirGlobal.config().getString("RootUri") + "/servlet/Mir"));
result.put("returnurl", null);
+ result.put("login_user", getUser(aRequest));
Object languages =
new CachingRewindableIterator(
throw new ServletModuleFailure(t);
}
}
+
+ public static void setUser(HttpServletRequest aRequest, EntityUsers aUser) {
+ aRequest.getSession().setAttribute("login.uid", aUser);
+ }
+
+ public static EntityUsers getUser(HttpServletRequest aRequest) {
+ return (EntityUsers) aRequest.getSession().getAttribute("login.uid");
+ }
}
URLBuilder urlBuilder = new URLBuilder();
try {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
urlBuilder.setValue("module", "Abuse");
urlBuilder.setValue("do", "showfilters");
URLBuilder urlBuilder = new URLBuilder();
try {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
urlBuilder.setValue("module", "Abuse");
urlBuilder.setValue("do", "showsettings");
int count;
try {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
urlBuilder.setValue("module", "Abuse");
urlBuilder.setValue("do", "showlog");
responseData.put("thisurl", urlBuilder.getQuery());
int count;
try {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
urlBuilder.setValue("module", "Admin");
urlBuilder.setValue("do", "superusermenu");
public void showComment(String anId, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
try {
HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)});
EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();
Map comment;
URLBuilder urlBuilder = new URLBuilder();
int count;
try {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
model = MirGlobal.localizer().dataModel().adapterModel();
Object commentList =
* ServletModuleContent -
* deliver html for the article admin form.
*
- * @version $Id: ServletModuleContent.java,v 1.52.2.1 2003/05/24 15:56:38 zapata Exp $
+ * @version $Id: ServletModuleContent.java,v 1.52.2.2 2003/06/19 02:24:13 zapata Exp $
* @author rk, mir-coders
*
*/
}
}
- public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
- _showObject(null, req, res);
+ public void add(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+ _showObject(null, aRequest, aResponse);
}
- public void insert(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
+ public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
//theLog.printDebugInfo(":: content :: trying to insert");
try {
- EntityUsers user = _getUser(req);
- Map withValues = getIntersectingValues(req, DatabaseContent.getInstance());
+ Map withValues = getIntersectingValues(aRequest, DatabaseContent.getInstance());
String now = StringUtil.date2webdbDate(new GregorianCalendar());
withValues.put("date", now);
withValues.put("publish_path", StringUtil.webdbDate2path(now));
- withValues.put("to_publisher", user.getId());
+ withValues.put("to_publisher", ServletHelper.getUser(aRequest));
withValues.put("is_produced", "0");
if (!withValues.containsKey("is_published"))
withValues.put("is_published","0");
String id = mainModule.add(withValues);
List topics;
- DatabaseContentToTopics.getInstance().setTopics(id, req.getParameterValues("to_topic"));
+ DatabaseContentToTopics.getInstance().setTopics(id, aRequest.getParameterValues("to_topic"));
- _showObject(id, req, res);
+ _showObject(id, aRequest, aResponse);
}
catch (Throwable e) {
throw new ServletModuleFailure(e);
}
}
- public void delete(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
+ public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
if (!configuration.getString("Mir.Localizer.Admin.AllowDeleteArticle", "0").equals("1"))
throw new ServletModuleExc("Operation not permitted");
- EntityUsers user = _getUser(req);
-
- String idParam = req.getParameter("id");
+ String idParam = aRequest.getParameter("id");
if (idParam == null) throw new ServletModuleExc("Invalid call: id missing");
- String confirmParam = req.getParameter("confirm");
- String cancelParam = req.getParameter("cancel");
+ String confirmParam = aRequest.getParameter("confirm");
+ String cancelParam = aRequest.getParameter("cancel");
- logger.info("where = " + req.getParameter("where"));
+ logger.info("where = " + aRequest.getParameter("where"));
if (confirmParam == null && cancelParam == null) {
mergeData.put("module", "Content");
mergeData.put("infoString", "Content: " + idParam);
mergeData.put("id", idParam);
- mergeData.put("where", req.getParameter("where"));
- mergeData.put("order", req.getParameter("order"));
- mergeData.put("offset", req.getParameter("offset"));
- deliver(req, res, mergeData, templateConfirmString);
+ mergeData.put("where", aRequest.getParameter("where"));
+ mergeData.put("order", aRequest.getParameter("order"));
+ mergeData.put("offset", aRequest.getParameter("offset"));
+ deliver(aRequest, aResponse, mergeData, templateConfirmString);
}
else {
if (confirmParam!= null && !confirmParam.equals("")) {
catch (Throwable e) {
throw new ServletModuleFailure(e);
}
- list(req,res);
+ list(aRequest,aResponse);
}
else {
// Datensatz anzeigen
- _showObject(idParam, req, res);
+ _showObject(idParam, aRequest, aResponse);
}
}
}
- public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
+ public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
- String idParam = req.getParameter("id");
+ String idParam = aRequest.getParameter("id");
if (idParam == null)
throw new ServletModuleExc("Invalid call: id not supplied ");
- _showObject(idParam, req, res);
+ _showObject(idParam, aRequest, aResponse);
}
// methods for attaching media file
- public void attach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
+ public void attach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
- String mediaIdParam = req.getParameter("mid");
- String articleId = req.getParameter("articleid");
+ String mediaIdParam = aRequest.getParameter("mid");
+ String articleId = aRequest.getParameter("articleid");
if (articleId == null || mediaIdParam==null)
throw new ServletModuleExc("smod content :: attach :: articleid/mid missing");
throw new ServletModuleFailure(e);
}
- _showObject(articleId, req, res);
+ _showObject(articleId, aRequest, aResponse);
}
- public void dettach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
+ public void dettach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
- String articleId = req.getParameter("articleid");
- String midParam = req.getParameter("mid");
+ String articleId = aRequest.getParameter("articleid");
+ String midParam = aRequest.getParameter("mid");
if (articleId == null)
throw new ServletModuleExc("smod content :: dettach :: articleid missing");
if (midParam == null)
throw new ServletModuleFailure(e);
}
- _showObject(articleId, req, res);
+ _showObject(articleId, aRequest, aResponse);
}
public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
throws ServletModuleExc {
try {
HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();
Map article;
URLBuilder urlBuilder = new URLBuilder();
new EntityIteratorAdapter("", configuration.getString("Mir.Localizer.Admin.TopicListOrder"),
20, MirGlobal.localizer().dataModel().adapterModel(), "topic"));
-
-
responseData.put("returnurl", requestParser.getParameter("returnurl"));
responseData.put("thisurl", urlBuilder.getQuery());
int count;
try {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
model = MirGlobal.localizer().dataModel().adapterModel();
Object articleList =
redirect(aResponse, returnUrl);
}
-
- private EntityUsers _getUser(HttpServletRequest req)
- {
- HttpSession session=req.getSession(false);
-
- return (EntityUsers)session.getAttribute("login.uid");
- }
}
* in the config file.
*
* @author $Author: zapata $
- * @version $Revision: 1.13 $ $Date: 2003/05/08 02:43:42 $
+ * @version $Revision: 1.13.2.1 $ $Date: 2003/06/19 02:24:13 $
*
*/
public void listSubDirectory(FileEditDirectory aDirectory, String aSubDirectory, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
try {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
File dir = new File(aDirectory.getRootDirectory(), aSubDirectory);
if (!validateDirectory(aDirectory, dir) || !dir.isDirectory()) {
listSubDirectory(aDirectory, "", aRequest, aResponse);
}
else {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
URLBuilder urlBuilder = new URLBuilder();
urlBuilder.setValue("module", "FileEdit");
try {
HttpSession session = aRequest.getSession(false);
return MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter
- ("user", (EntityUsers) session.getAttribute("login.uid"));
+ ("user", ServletHelper.getUser(aRequest));
}
catch (Throwable e) {
throw new ServletModuleFailure("ServletModuleLocalizer.getActiveUser: " + e.getMessage(), e);
String[] operations = aRequest.getParameterValues("operation");
- for (int i=0; i<operations.length; i++) {
- if (operations[i].length()>0) {
- List parts = StringRoutines.splitString(operations[i], ";");
+ if (operations!=null) {
+ for (int i = 0; i < operations.length; i++) {
+ if (operations[i].length() > 0) {
+ List parts = StringRoutines.splitString(operations[i], ";");
- if (parts.size() != 2) {
- logger.error("commentoperationbatch: operation string invalid: " +
- operations[i]);
- }
- else {
- String commentIdString = (String) parts.get(0);
- String operationString = (String) parts.get(1);
+ if (parts.size() != 2) {
+ logger.error("commentoperationbatch: operation string invalid: " +
+ operations[i]);
+ }
+ else {
+ String commentIdString = (String) parts.get(0);
+ String operationString = (String) parts.get(1);
- performCommentOperation(getActiveUser(aRequest), commentIdString, operationString);
+ performCommentOperation(getActiveUser(aRequest), commentIdString, operationString);
+ }
}
}
}
String[] operations = aRequest.getParameterValues("operation");
- for (int i=0; i<operations.length; i++) {
- if (operations[i].length()>0) {
- List parts = StringRoutines.splitString(operations[i], ";");
+ if (operations!=null) {
- if (parts.size() != 2) {
- logger.error("articleoperationbatch: operation string invalid: " + operations[i]);
- }
- else {
- String articleIdString = (String) parts.get(0);
- String operationString = (String) parts.get(1);
+ for (int i = 0; i < operations.length; i++) {
+ if (operations[i].length() > 0) {
+ List parts = StringRoutines.splitString(operations[i], ";");
- performArticleOperation(getActiveUser(aRequest), articleIdString, operationString);
+ if (parts.size() != 2) {
+ logger.error("articleoperationbatch: operation string invalid: " + operations[i]);
+ }
+ else {
+ String articleIdString = (String) parts.get(0);
+ String operationString = (String) parts.get(1);
+
+ performArticleOperation(getActiveUser(aRequest), articleIdString, operationString);
+ }
}
}
}
* open-postings to the newswire
*
* @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.3 2003/06/13 03:54:08 zapata Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.4 2003/06/19 02:24:13 zapata Exp $
*
*/
Session session = new HTTPAdapters.HTTPSessionAdapter(aRequest.getSession());
SimpleResponse response = new SimpleResponse(
- ServletHelper.makeGenerationData(aResponse, new Locale[] { getResponseLocale(aRequest.getSession(), aRequest), getFallbackLocale(aRequest)},
+ ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getResponseLocale(aRequest.getSession(), aRequest), getFallbackLocale(aRequest)},
"bundles.open"));
response.setResponseValue("actionURL", aResponse.encodeURL(HttpUtils.getRequestURL(aRequest).toString())+"?"+SESSION_REQUEST_KEY+"="+aRequest.getSession().getId());
public void deliver(PrintWriter anOutputWriter, HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator)
throws ServletModuleFailure {
try {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}, "bundles.open");
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)}, "bundles.open");
responseData.put("data", aData);
responseData.put("extra", anExtra);
public void deliver(PrintWriter anOutputWriter, HttpServletRequest aRequest, HttpServletResponse aResponse, Map aData, Map anExtra, String aGenerator,String aLocaleString)
throws ServletModuleFailure {
try {
- Map responseData = ServletHelper.makeGenerationData(aResponse, new Locale[] { new Locale(aLocaleString,""), getFallbackLocale(aRequest)}, "bundles.open");
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { new Locale(aLocaleString,""), getFallbackLocale(aRequest)}, "bundles.open");
responseData.put("data", aData);
responseData.put("extra", anExtra);
try {
generator = MirGlobal.localizer().generators().makeAdminGeneratorLibrary().makeGenerator("producerqueue.template");
- generationData = ServletHelper.makeGenerationData(aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ generationData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
generationData.put( "thisurl", "module=Producer&do=showProducerQueueStatus");
producersData = new Vector();
* ServletModuleBilder -
* liefert HTML fuer Bilder
*
- * @version $Id: ServletModuleUploadedMedia.java,v 1.28 2003/04/29 02:36:51 zapata Exp $
+ * @version $Id: ServletModuleUploadedMedia.java,v 1.28.2.1 2003/06/19 02:24:13 zapata Exp $
* @author RK, the mir-coders group
*/
logger = new LoggerWrapper("ServletModule.UploadedMedia");
}
- public void insert(HttpServletRequest req, HttpServletResponse res)
+ public void insert(HttpServletRequest aRequest, HttpServletResponse aResponse)
throws ServletModuleExc, ServletModuleUserExc {
try {
- HTTPParsedRequest parsedRequest = new HTTPParsedRequest(req,
+ HTTPParsedRequest parsedRequest = new HTTPParsedRequest(aRequest,
configuration.getString("Mir.DefaultEncoding"),
configuration.getInt("MaxMediaUploadSize")*1024,
configuration.getString("TempDir"));
- EntityUsers user = _getUser(req);
Map mediaValues = new HashMap();
- mediaValues.put("to_publisher", _getUser(req).getId());
+ mediaValues.put("to_publisher", ServletHelper.getUser(aRequest).getId());
Iterator i = mainModule.getStorageObject().getFields().iterator();
while (i.hasNext()) {
entContent.attach(((EntityUploadedMedia) i.next()).getId());
}
- ((ServletModuleContent) ServletModuleContent.getInstance())._showObject(articleid, req, res);
+ ((ServletModuleContent) ServletModuleContent.getInstance())._showObject(articleid, aRequest, aResponse);
return;
}
comment.attach( ( (EntityUploadedMedia) i.next()).getId());
}
- ((ServletModuleComment) ServletModuleComment.getInstance()).showComment(commentid, req, res);
+ ((ServletModuleComment) ServletModuleComment.getInstance()).showComment(commentid, aRequest, aResponse);
return;
}
//fetch the popups
popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());
// raus damit
- deliver(req, res, mergeData, popups, templateListString);
+ deliver(aRequest, aResponse, mergeData, popups, templateListString);
}
catch (Throwable t) {
Throwable cause = ExceptionFunctions.traceCauseException(t);
}
}
- public void update(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+ public void update(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
try {
- HTTPParsedRequest parsedRequest = new HTTPParsedRequest(req,
+ HTTPParsedRequest parsedRequest = new HTTPParsedRequest(aRequest,
configuration.getString("Mir.DefaultEncoding"),
configuration.getInt("MaxMediaUploadSize")*1024,
configuration.getString("TempDir"));
- EntityUsers user = _getUser(req);
Map mediaValues = new HashMap();
Iterator i = mainModule.getStorageObject().getFields().iterator();
mediaValues.put(field, value);
}
- mediaValues.put("to_publisher", user.getId());
+ mediaValues.put("to_publisher", ServletHelper.getUser(aRequest));
mediaValues.put("is_produced", "0");
if (!mediaValues.containsKey("is_published"))
mediaValues.put("is_published", "0");
String id = mainModule.set(mediaValues);
logger.debug("update: media ID = " + id);
- _edit(id, req, res);
+ _edit(id, aRequest, aResponse);
}
catch (Throwable e) {
throw new ServletModuleFailure("upload -- exception " + e.toString(), e);
}
- public void list(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+ public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
// Parameter auswerten
SimpleHash mergeData = new SimpleHash();
SimpleHash popups = new SimpleHash();
- String query_text = req.getParameter("query_text");
+ String query_text = aRequest.getParameter("query_text");
mergeData.put("query_text", query_text);
if (query_text != null) mergeData.put("query_text_encoded", URLEncoder.encode(query_text));
- String query_field = req.getParameter("query_field");
+ String query_field = aRequest.getParameter("query_field");
mergeData.put("query_field", query_field);
- String query_is_published = req.getParameter("query_is_published");
+ String query_is_published = aRequest.getParameter("query_is_published");
mergeData.put("query_is_published", query_is_published);
- String query_media_folder = req.getParameter("query_media_folder");
+ String query_media_folder = aRequest.getParameter("query_media_folder");
mergeData.put("query_media_folder", query_media_folder);
- String offset = req.getParameter("offset");
+ String offset = aRequest.getParameter("offset");
if (offset == null || offset.equals("")) offset = "0";
mergeData.put("offset", offset);
- String order = req.getParameter("order");
+ String order = aRequest.getParameter("order");
if (order == null || order.equals("")) order = "webdb_lastchange desc";
// if in connection mode to content
- mergeData.put("articleid", req.getParameter("articleid"));
- mergeData.put("commentid", req.getParameter("commentid"));
+ mergeData.put("articleid", aRequest.getParameter("articleid"));
+ mergeData.put("commentid", aRequest.getParameter("commentid"));
// sql basteln
}
popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());
- deliver(req, res, mergeData, popups, templateListString);
+ deliver(aRequest, aResponse, mergeData, popups, templateListString);
}
catch (Throwable e) {
throw new ServletModuleFailure(e);
}
- public void add(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+ public void add(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
try {
SimpleHash mergeData = new SimpleHash();
SimpleHash popups = new SimpleHash();
String maxMedia = MirPropertiesConfiguration.instance().getString("ServletModule.OpenIndy.MaxMediaUploadItems");
- String numOfMedia = req.getParameter("medianum");
+ String numOfMedia = aRequest.getParameter("medianum");
mergeData.put("new", "1");
- mergeData.put("articleid", req.getParameter("articleid"));
- mergeData.put("commentid", req.getParameter("commentid"));
+ mergeData.put("articleid", aRequest.getParameter("articleid"));
+ mergeData.put("commentid", aRequest.getParameter("commentid"));
popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());
}
mergeData.put("medianum",numOfMedia);
mergeData.put("mediafields",mediaFields);
- deliver(req, res, mergeData, popups, templateObjektString);
+ deliver(aRequest, aResponse, mergeData, popups, templateObjektString);
}
catch (Exception e) {
throw new ServletModuleFailure(e);
}
}
- public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
- String idParam = req.getParameter("id");
- _edit(idParam, req, res);
+ public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+ String idParam = aRequest.getParameter("id");
+ _edit(idParam, aRequest, aResponse);
}
- private void _edit(String idParam, HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
+ private void _edit(String idParam, HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
if (idParam != null && !idParam.equals("")) {
try {
SimpleHash popups = new SimpleHash();
popups.put("mediafolderPopupData", DatabaseMediafolder.getInstance().getPopupData());
- deliver(req, res, mainModule.getById(idParam), popups,
+ deliver(aRequest, aResponse, mainModule.getById(idParam), popups,
templateObjektString);
}
catch (Throwable e) {
}
- /** @todo should be in ServletModule.java */
- private EntityUsers _getUser(HttpServletRequest req) {
- HttpSession session = req.getSession(false);
- return (EntityUsers) session.getAttribute("login.uid");
- }
-
- public void getMedia(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc {
- String idParam = req.getParameter("id");
+ public void getMedia(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
+ String idParam = aRequest.getParameter("id");
if (idParam!=null && !idParam.equals("")) {
try {
EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);
mediaHandler = MediaHelper.getHandler(mediaType);
InputStream in = mediaHandler.getMedia(ent, mediaType);
- res.setContentType(ctx.getMimeType(fName));
- //important that before calling this res.getWriter was not called first
- ServletOutputStream out = res.getOutputStream();
+ aResponse.setContentType(ctx.getMimeType(fName));
+ //important that before calling this aResponse.getWriter was not called first
+ ServletOutputStream out = aResponse.getOutputStream();
int read ;
byte[] buf = new byte[8 * 1024];
// no exception allowed
}
- public void getIcon(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
+ public void getIcon(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
- String idParam = req.getParameter("id");
+ String idParam = aRequest.getParameter("id");
if (idParam!=null && !idParam.equals("")) {
try {
EntityUploadedMedia ent = (EntityUploadedMedia) mainModule.getById(idParam);
if (in==null)
throw new ServletModuleExc("no icon available");
- res.setContentType(mediaHandler.getIconMimeType(ent, mediaType));
- //important that before calling this res.getWriter was not called first
- ServletOutputStream out = res.getOutputStream();
+ aResponse.setContentType(mediaHandler.getIconMimeType(ent, mediaType));
+ //important that before calling this aResponse.getWriter was not called first
+ ServletOutputStream out = aResponse.getOutputStream();
int read ;
byte[] buf = new byte[8 * 1024];
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
* If you do not wish to do so, delete this exception statement from your version.
*/
package mircoders.servlet;
-import java.util.Map;
+import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import freemarker.template.SimpleHash;
+
import mir.log.LoggerWrapper;
import mir.servlet.ServletModule;
import mir.servlet.ServletModuleExc;
import mir.servlet.ServletModuleFailure;
import mir.servlet.ServletModuleUserExc;
import mir.storage.StorageObjectFailure;
-import mir.util.HTTPRequestParser;
+import mir.util.*;
+import mir.entity.adapter.*;
import mircoders.module.ModuleUsers;
import mircoders.storage.DatabaseUsers;
-import freemarker.template.SimpleHash;
+import mircoders.global.*;
+import mircoders.entity.*;
+import mircoders.servlet.*;
/*
* ServletModuleUsers -
public class ServletModuleUsers extends ServletModule
{
+ private String editTemplate;
+ private String listTemplate;
+
private static ServletModuleUsers instance = new ServletModuleUsers();
public static ServletModule getInstance() { return instance; }
+ protected ModuleUsers usersModule;
private ServletModuleUsers() {
super();
logger = new LoggerWrapper("ServletModule.Users");
- templateListString = configuration.getString("ServletModule.Users.ListTemplate");
- templateObjektString = configuration.getString("ServletModule.Users.ObjektTemplate");
+ listTemplate = configuration.getString("ServletModule.Users.ListTemplate");
+ editTemplate = configuration.getString("ServletModule.Users.ObjektTemplate");
templateConfirmString = configuration.getString("ServletModule.Users.ConfirmTemplate");
try {
- mainModule = new ModuleUsers(DatabaseUsers.getInstance());
+ usersModule = new ModuleUsers(DatabaseUsers.getInstance());
+ mainModule = usersModule;
}
catch (StorageObjectFailure e) {
logger.debug("initialization of ServletModuleUsers failed!: " + e.getMessage());
}
}
- public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc
+ public void edit(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
{
- String idParam = req.getParameter("id");
+ String idParam = aRequest.getParameter("id");
if (idParam == null)
throw new ServletModuleExc("ServletModuleUser.edit: invalid call: (id) not specified");
try {
- deliver(req, res, mainModule.getById(idParam), templateObjektString);
+ EntityUsers user = (EntityUsers) mainModule.getById(idParam);
+ MirGlobal.accessControl().user().assertMayEditUser(ServletHelper.getUser(aRequest), user);
+
+ showUser(idParam, false, aRequest, aResponse);
}
catch (Throwable e) {
throw new ServletModuleFailure(e);
}
}
- public void add(HttpServletRequest req, HttpServletResponse res)
+ public void add(HttpServletRequest aRequest, HttpServletResponse aResponse)
throws ServletModuleExc
{
try {
- SimpleHash mergeData = new SimpleHash();
- mergeData.put("new", "1");
- deliver(req, res, mergeData, templateObjektString);
+ MirGlobal.accessControl().user().assertMayAddUsers(ServletHelper.getUser(aRequest));
+
+ showUser(null, false, aRequest, aResponse);
}
catch (Throwable e) {
throw new ServletModuleFailure(e);
}
}
- public String checkPassword(HTTPRequestParser aRequestParser) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
+ public String validatePassword(EntityUsers aUser, HTTPRequestParser aRequestParser) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
{
if ( (aRequestParser.getParameter("newpassword") != null &&
aRequestParser.getParameter("newpassword").length() > 0) ||
) {
String newPassword = aRequestParser.getParameterWithDefault("newpassword", "");
String newPassword2 = aRequestParser.getParameterWithDefault("newpassword2", "");
+ String oldPassword = aRequestParser.getParameterWithDefault("oldpassword", "");
+
+ try {
+ if (!usersModule.checkUserPassword(aUser, oldPassword)) {
+ throw new ServletModuleUserExc("user.error.incorrectpassword", new String[] {});
+ }
+ }
+ catch (Throwable t) {
+ throw new ServletModuleFailure(t);
+ }
+
if (newPassword.length() == 0 || newPassword2.length() == 0) {
throw new ServletModuleUserExc("user.error.missingpasswords", new String[] {});
throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
{
try {
+ MirGlobal.accessControl().user().assertMayAddUsers(ServletHelper.getUser(aRequest));
+
HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());
- String newPassword=checkPassword(requestParser);
+ String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);
if (newPassword!=null)
withValues.put("password", newPassword);
else
{
try {
HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ EntityUsers user = (EntityUsers) mainModule.getById(requestParser.getParameter("id"));
+ MirGlobal.accessControl().user().assertMayEditUser(ServletHelper.getUser(aRequest), user);
Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());
- String newPassword=checkPassword(requestParser);
+ String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);
if (newPassword!=null)
withValues.put("password", newPassword);
}
}
+ public void updatepassword(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
+ {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ EntityUsers user = (EntityUsers) mainModule.getById(requestParser.getParameter("id"));
+ MirGlobal.accessControl().user().assertMayChangeUserPassword(ServletHelper.getUser(aRequest), user);
+
+ String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);
+ if (newPassword!=null) {
+ user.setValueForProperty("password", newPassword);
+ user.update();
+
+ // hackish: to make sure the cached logged in user is up-to-date:
+ ServletHelper.setUser(aRequest, (EntityUsers) mainModule.getById(ServletHelper.getUser(aRequest).getId()));
+ }
+
+ if (requestParser.hasParameter("returnurl"))
+ redirect(aResponse, requestParser.getParameter("returnurl"));
+ else
+ redirect(aResponse, "");
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void list(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+
+ int offset = requestParser.getIntegerWithDefault("offset", 0);
+
+ returnUserList(aRequest, aResponse, offset);
+ }
+
+ public void returnUserList(
+ HttpServletRequest aRequest,
+ HttpServletResponse aResponse,
+ int anOffset) throws ServletModuleExc {
+
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ URLBuilder urlBuilder = new URLBuilder();
+ EntityAdapterModel model;
+ int count;
+ int nrUsersPerPage = 20;
+
+ try {
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ model = MirGlobal.localizer().dataModel().adapterModel();
+
+ Object userList =
+ new CachingRewindableIterator(
+ new EntityIteratorAdapter( "", "login", nrUsersPerPage,
+ MirGlobal.localizer().dataModel().adapterModel(), "user", nrUsersPerPage, anOffset)
+ );
+
+ responseData.put("nexturl", null);
+ responseData.put("prevurl", null);
+
+ count=mainModule.getSize("");
+
+ urlBuilder.setValue("module", "Users");
+ urlBuilder.setValue("do", "list");
+
+ urlBuilder.setValue("offset", anOffset);
+ responseData.put("offset" , new Integer(anOffset).toString());
+ responseData.put("thisurl" , urlBuilder.getQuery());
+
+ if (count>=anOffset+nrUsersPerPage) {
+ urlBuilder.setValue("offset", (anOffset + nrUsersPerPage));
+ responseData.put("nexturl" , urlBuilder.getQuery());
+ }
+
+ if (anOffset>0) {
+ urlBuilder.setValue("offset", Math.max(anOffset - nrUsersPerPage, 0));
+ responseData.put("prevurl" , urlBuilder.getQuery());
+ }
+
+ responseData.put("users", userList);
+ responseData.put("mayDeleteUsers", new Boolean(MirGlobal.accessControl().user().mayDeleteUsers(ServletHelper.getUser(aRequest))));
+ responseData.put("mayAddUsers", new Boolean(MirGlobal.accessControl().user().mayAddUsers(ServletHelper.getUser(aRequest))));
+ responseData.put("mayEditUsers", new Boolean(MirGlobal.accessControl().user().mayEditUsers(ServletHelper.getUser(aRequest))));
+
+ responseData.put("from" , Integer.toString(anOffset+1));
+ responseData.put("count", Integer.toString(count));
+ responseData.put("to", Integer.toString(Math.min(anOffset+nrUsersPerPage, count)));
+ responseData.put("offset" , Integer.toString(anOffset));
+
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, listTemplate);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void showUser(String anId, boolean anOnlyPassword, HttpServletRequest aRequest, HttpServletResponse aResponse)
+ throws ServletModuleExc {
+ try {
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);
+ Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+ EntityAdapterModel model = MirGlobal.localizer().dataModel().adapterModel();
+ Map user;
+ URLBuilder urlBuilder = new URLBuilder();
+
+ urlBuilder.setValue("module", "Users");
+ if (anOnlyPassword)
+ urlBuilder.setValue("do", "changepassword");
+ else
+ urlBuilder.setValue("do", "edit");
+ urlBuilder.setValue("id", anId);
+ urlBuilder.setValue("returnurl", requestParser.getParameter("returnurl"));
+
+ if (anId!=null) {
+ responseData.put("new", Boolean.FALSE);
+ user = model.makeEntityAdapter("user", mainModule.getById(anId));
+ }
+ else {
+ List fields = DatabaseUsers.getInstance().getFields();
+ responseData.put("new", Boolean.TRUE);
+ user = new HashMap();
+ Iterator i = fields.iterator();
+ while (i.hasNext()) {
+ user.put(i.next(), null);
+ }
+
+ MirGlobal.localizer().adminInterface().initializeArticle(user);
+ }
+ responseData.put("user", user);
+ responseData.put("passwordonly", new Boolean(anOnlyPassword));
+
+ responseData.put("returnurl", requestParser.getParameter("returnurl"));
+ responseData.put("thisurl", urlBuilder.getQuery());
+
+ ServletHelper.generateResponse(aResponse.getWriter(), responseData, editTemplate);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
+
+ public void delete(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleUserExc, ServletModuleExc, ServletModuleFailure {
+ try {
+ EntityUsers user = (EntityUsers) mainModule.getById(aRequest.getParameter("id"));
+
+ MirGlobal.accessControl().user().assertMayDeleteUser(ServletHelper.getUser(aRequest), user);
+
+ super.delete(aRequest, aResponse);
+ }
+ catch (Throwable t) {
+ throw new ServletModuleFailure(t);
+ }
+ }
+
+ public void changepassword(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc
+ {
+ String idParam = aRequest.getParameter("id");
+
+ if (idParam == null)
+ throw new ServletModuleExc("ServletModuleUser.edit: invalid call: (id) not specified");
+
+ try {
+ EntityUsers user = (EntityUsers) mainModule.getById(idParam);
+ MirGlobal.accessControl().user().assertMayChangeUserPassword(ServletHelper.getUser(aRequest), user);
+
+ showUser(idParam, true, aRequest, aResponse);
+ }
+ catch (Throwable e) {
+ throw new ServletModuleFailure(e);
+ }
+ }
}
+
</td>
</tr>
-
+ <assign grey="0">
-<list contentlist as entry>
- <if grey=="1">
- <assign grey="0">
- <tr class="${listrow1CSS}">
- <else>
- <assign grey="1">
- <tr class="${listrow2CSS}">
- </if>
-
- <list data_keys as indexVariable>
+ <list contentlist as entry>
+ <if grey=="1">
+ <assign grey="0">
+ <tr class="${listrow1CSS}">
+ <else>
+ <assign grey="1">
+ <tr class="${listrow2CSS}">
+ </if>
+
+ <list data_keys as indexVariable>
+ <td>
+ ${entry[indexVariable]}
+ </td>
+ </list>
<td>
- ${entry[indexVariable]}
+ <a class="listcommand" href="${config.actionRoot}?module=${module_name}&do=delete&id=${entry.id}">${lang("delete")}</a>
+ | <a class="listcommand" href="${config.actionRoot}?module=${module_name}&do=edit&id=${entry.id}">${lang("edit")}</a>
</td>
+ </tr>
</list>
- <td>
- <a class="listcommand" href="${config.actionRoot}?module=${module_name}&do=delete&id=${entry.id}">${lang("delete")}</a>
- | <a class="listcommand" href="${config.actionRoot}?module=${module_name}&do=edit&id=${entry.id}">${lang("edit")}</a>
- </td>
- </tr>
-</list>
<tr>
</table>
</function>
+<assign TABLE_HEAD_CLASS "table-head">
+<assign TABLE_FOOT_CLASS "table-head">
+<assign LIST_ROW_CLASS "listrow1">
+<assign LIST_ROW_CLASS_ALTERNATIVE "listrow2">
+
+<function EntityTable(anEntityList, aDataKeys, aHeaders, aFrom, aTo, aCount, aShowDelete, aShowEdit, aModuleName)>
+ <table cellspacing="2" border="0">
+ <tr>
+ <list aHeaders as i>
+ <td class="${TABLE_HEAD_CLASS}">
+ <b>${i}</b>
+ </td>
+ </list>
+ <if aShowDelete == "1" || aShowEdit == "1">
+ <td class="${TABLE_HEAD_CLASS}">
+
+ </td>
+ </if>
+ </tr>
+ <assign alternative="0">
+
+ <list anEntityList as entry>
+ <if alternative=="0">
+ <assign alternative="1">
+ <tr class="${LIST_ROW_CLASS}">
+ <else>
+ <assign alternative="0">
+ <tr class="${LIST_ROW_CLASS_ALTERNATIVE}">
+ </if>
+
+ <list aDataKeys as i>
+ <td>
+ ${entry[i]}
+ </td>
+ </list>
+ <if aShowDelete == "1" || aShowEdit == "1" >
+ <td>
+ <if aShowDelete>
+ <a class="listcommand" href="${config.actionRoot}?module=${aModuleName}&do=delete&id=${entry.id}">${lang("delete")}</a>
+ </if>
+ <if aShowDelete == "1" && aShowEdit == "1">
+ |
+ </if>
+ <if aShowEdit == "1">
+ <a class="listcommand" href="${config.actionRoot}?module=${aModuleName}&do=edit&id=${entry.id}">${lang("edit")}</a>
+ </if>
+ </td>
+ </if>
+ </tr>
+ </list>
+
+
+ <tr>
+ <td colspan="${column_nr}" class="${TABLE_HEAD_CLASS}">
+ ${aCount} ${lang("records")} / ${lang("show_from_to", aFrom, aTo)}
+ </td>
+ </tr>
+
+ </table>
+</function>
+
+
<comment>creates browse links, only called if necessary</comment>
<function PrevNextPage(module_name)>
<p>
</p>
</function>
+<function showAddOrBack(anAllowAdd, anAddModule, aBackModule, aBackMethod, )>
+ <p>
+ <if anAllowAdd == "1">
+ <a class="link-box" href="${config.actionRoot}?module=${anAddModule}&do=add">[+] ${lang("add")}</a>
+ </if>
+ <a class="link-box" href="${config.actionRoot}?module=${aBackModule}&do=${aBackMethod}">[<] ${lang("back")} </a>
+ <a class="link-box" href="${config.actionRoot}">[<<<] ${lang("head.start")}</a>
+ </p>
+</function>
+
</tr>
</function>
+<function ReadonlyTextTableRow (label, fieldcontent)>
+ <tr>
+ <td align="right" class="table-left">
+ <b>${label}:</b>
+ </td>
+
+ <td class="listrow2">
+ ${utility.encodeHTML(fieldcontent)}
+ </td>
+ </tr>
+</function>
+
<function PasswordTextInputTableRow (label, size, maxlength, fieldname, fieldcontent)>
<tr>
<td align="right" class="table-left">
</if>
</if>
-
<call showPrevNextLinks(prevurl, nexturl, "right")>
-
-
<else>
<p align="center" class="box">${lang("no_matches_found")}</p>
</if>
${config["Mir.Name"]}
</td>
<td align="right">
+ <a href="${config.actionRoot}?module=Users&do=changepassword&id=${login_user.id}&returnurl="><span class="table-head">${lang("head.changepassword")}</span></a>
<if returnurl>
<a href="${config.actionRoot}?${returnurl}"><span class="table-head">[ < ] ${lang("back")}</span></a> |
</if>
<form action="${config.actionRoot}" method="post">
<input type="hidden" name="module" value="Users">
- <input type="hidden" name="id" value="${data.id}">
- <if data.new>
- <input type="hidden" name="do" value="insert">
+ <input type="hidden" name="id" value="${user.id}">
+ <if passwordonly=="1">
+ <input type="hidden" name="do" value="updatepassword">
<else>
- <input type="hidden" name="do" value="update">
+ <if new=="1">
+ <input type="hidden" name="do" value="insert">
+ <else>
+ <input type="hidden" name="do" value="update">
+ </if>
</if>
<table border="0">
- <call TextInputTableRow (lang("user.login"), 40, 40, "login", data.login)>
+ <if passwordonly=="1">
+ <call ReadonlyTextTableRow(lang("user.login"), user.login)>
+ <call PasswordTextInputTableRow (lang("user.oldpassword"), 40, 40, "oldpassword", "")>
+ <else>
+ <call TextInputTableRow (lang("user.login"), 40, 40, "login", user.login)>
+ <call PasswordTextInputTableRow (lang("user.ownpassword"), 40, 40, "oldpassword", "")>
+ </if>
<call PasswordTextInputTableRow (lang("user.password"), 40, 40, "newpassword", "")>
<call PasswordTextInputTableRow (lang("user.password2"), 40, 40, "newpassword2", "")>
- <tr>
- <td align="right" class="table-left">
- <b>${lang("user.admin")}:</b>
- </td>
- <td class="listrow2">
- <input type="checkbox" name="is_admin" value="1"<if data.is_admin=="1"> checked</if>>
- </td>
- </tr>
+ <if passwordonly>
+ <call ReadonlyTextTableRow(lang("user.admin"), user.is_admin)>
+ <else>
+ <call CheckboxTableRow(lang("user.admin"), "is_admin", user.is_admin)>
+ </if>
<tr>
<td colspan="2" align="right" class="table-foot">
<span class="witetext">
- <if data.new>
+ <if new=="1">
<input type="submit" name="save" value="${lang("insert")}">
<else>
<input type="submit" name="save" value="${lang("save")}">
<include "FUNCTIONS.template">
<include "head.template">
- <assign contentlist = data.contentlist>
- <assign column_nr = 3>
-
- <assign column_head_texts = [lang("user.login"), lang("user.admin")]>
- <assign data_keys = ["login","is_admin"]>
- <assign column_head_CSS = "table_head">
- <assign listrow1CSS = "listrow1">
- <assign listrow2CSS = "listrow2">
- <assign footer_css = "table_foot">
- <assign module_name = "Users">
- <assign module_jumpback = "Admin">
- <assign do_jumpback = "superusermenu">
-
-
-
- <call AddOrBack(module_name, module_jumpback, do_jumpback)>
+ <call showAddOrBack(mayAddUsers, "Users", "Admin", "superusermenu")>
- <if data.contentlist>
- <call ListTable(contentlist, data_keys, column_head_texts, column_head_CSS, listrow1CSS, listrow2CSS, footer_css, module_name)>
- <call AddOrBack(module_name, module_jumpback, do_jumpback)>
- <else>
+ <if users>
+ <call showPrevNextLinks(prevurl, nexturl, "left")>
+ <call EntityTable(users, ["login","is_admin"], [lang("user.login"), lang("user.admin")], from, to, count, mayDeleteUsers, mayEditUsers, "Users")>
+ <call showPrevNextLinks(prevurl, nexturl, "left")>
+ <call showAddOrBack(mayAddUsers, "Users", "Admin", "superusermenu")>
+ <else>
<P align="center">${lang("no_matches_found")}</p>
</if>
-
<include "foot.template">
</body>