rem:     function add_user(ldap) {  resolve(); try {  var userId = "";  var ldapId = null; if (ldap) { ldapId = ""; }  var email = ""; var fullName = ""; var description = ""; var messages = new Packages.java.util.ArrayList(); var password = ""; var confirmPassword = ""; var userManager = getAccreditableManager().getUserManager();  while (true) { cocoon.sendPageAndWait("users/profile.xml", { "page-title" : "Add User: Profile", "user-id" : userId, "fullname" : fullName, "email" : email, "description" : description, "messages" : messages, "ldap-id" : ldapId, "password" : password, "confirm-password" : confirmPassword, "new-user" : true, "ldap" : ldap });  if (cocoon.request.get("cancel")) { break; }  userId = cocoon.request.get("userid"); email = cocoon.request.get("email"); fullName = cocoon.request.get("fullname"); description = cocoon.request.get("description"); ldapId = cocoon.request.get("ldapid"); password = cocoon.request.get("new-password"); confirmPassword = cocoon.request.get("confirm-password");  messages = validate(userManager, ldap, userId, email, password, confirmPassword, ldapId);  if (messages.isEmpty()) { var configDir = userManager.getConfigurationDirectory(); var user; if (ldap) { user = new Packages.org.apache.lenya.cms.ac.LDAPUser(configDir, userId, email, ldapId); } else { user = new Packages.org.apache.lenya.cms.ac.FileUser(configDir, userId, fullName, email, ""); user.setName(fullName); user.setPassword(password); }  user.setDescription(description); user.save(); userManager.add(user); break; } } cocoon.sendPage("redirect.html", { "url" : "../users.html" }); } finally { release(); } }     function user_delete_user() {  resolve(); try {  var userManager = getAccreditableManager().getUserManager(); var userId = cocoon.request.get("user-id"); var user = userManager.getUser(userId); var name = user.getName(); var showPage = true;  while (showPage) { cocoon.sendPageAndWait("users/confirm-delete-common.xml", { "id" : userId, "name" : name, "type" : user });  if (cocoon.request.get("cancel")) { break; }  if (cocoon.request.get("submit")) { userManager.remove(user); user['delete'](); showPage = false; } }  cocoon.sendPage("redirect.html", { "url" : "../users.html" }); } finally { release(); } } 
context: function validate(userManager, ldap, userId, email, password, confirmPassword, messages, ldapId) {    	messages = new Packages.java.util.ArrayList();	    userid = new Packages.java.lang.String(email);    email = new Packages.java.lang.String(email);        var existingUser = userManager.getUser(userId);				if (existingUser != null) {		messages.add("This user already exists.");	}				if (!Packages.org.apache.lenya.cms.ac.AbstractItem.isValidId(userId)) {		messages.add("This is not a valid user ID.");	}			    if (email.length() == 0) {        messages.add("Please enter an e-mail address.");    }    	if (ldap) {	    var ldapUser = new LDAPUser();	    if (!ldapUser.existsUser(ldapId)) {	    	messages.add("This LDAP user ID does not exist.);	    }	}		else {    	password = new Packages.java.lang.String(password);	    confirmPassword = new Packages.java.lang.String(confirmPassword);    		if (!password.equals(confirmPassword)) {		   	messages.add("Password and confirmed password are not equal.");		}				    if (password.length() < 6) {    	    messages.add("The password must be at least six characters long.");	    }    	    if (!password.matches(".*\\d.*")) {    	    messages.add("The password must contain at least one number.");	    }    }            return messages;}//// Add a user.//function add_user(ldap) {	resolve();	try {			var userId = "";				var ldapId = null;		if (ldap) {			ldapId = "";		}				var email = "";		var fullName = "";		var description = "";		var messages = new Packages.java.util.ArrayList();		var password = "";		var confirmPassword = "";		var userManager = getAccreditableManager().getUserManager();				while (true) {			cocoon.sendPageAndWait("users/profile.xml", {				"page-title" : "Add User: Profile",				"user-id" : userId,		    	"fullname" : fullName,		    	"email" : email,		    	"description" : description,		    	"messages" : messages,		    	"ldap-id" : ldapId,	    		"password" : password,	    		"confirm-password" : confirmPassword,	    		"new-user" : true,	    		"ldap" : ldap			});					    if (cocoon.request.get("cancel")) {		    	break;		    }		    			userId = cocoon.request.get("userid");			email = cocoon.request.get("email");			fullName = cocoon.request.get("fullname");			description = cocoon.request.get("description");			ldapId = cocoon.request.get("ldapid");			password = cocoon.request.get("new-password");			confirmPassword = cocoon.request.get("confirm-password");						messages = validate(userManager, ldap, userId, email, password, confirmPassword, ldapId);						if (messages.isEmpty()) {				var configDir = userManager.getConfigurationDirectory();				var user;				if (ldap) {					user = new Packages.org.apache.lenya.cms.ac.LDAPUser(configDir, userId, email, ldapId);				}				else {					user = new Packages.org.apache.lenya.cms.ac.FileUser(configDir, userId, fullName, email, "");					user.setName(fullName);					user.setPassword(password);				}								user.setDescription(description);				user.save();				userManager.add(user);				break;			}		}	   	cocoon.sendPage("redirect.html", { "url" : "../users.html" });   	}   	finally {   		release();   	}}//// Delete user.//function user_delete_user() {	resolve();	try {			var userManager = getAccreditableManager().getUserManager();		var userId = cocoon.request.get("user-id");		var user = userManager.getUser(userId);		var name = user.getName();		var showPage = true;				while (showPage) {			cocoon.sendPageAndWait("users/confirm-delete-common.xml", {				"id" : userId,				"name" : name,				"type" : user			});						if (cocoon.request.get("cancel")) {				break;			}						if (cocoon.request.get("submit")) {				userManager.remove(user);				user['delete']();				showPage = false;			}		}		   	cocoon.sendPage("redirect.html", { "url" : "../users.html" });   	}   	finally {   		release();   	}}
meta: 791	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/791/1e7af5f3fcdb2db9a590f0478a8eb0fc7cab8fa5/user-admin.js/buggy/src/webapp/lenya/content/admin/users/user-admin.js