Author: dpillot
Date: Thu Jun 14 17:05:31 2007
New Revision: 17562

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D17562&repname=
=3Djahia
Log:
TEMPLATES-279 241

Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/mysettings=
/MySettingsEngine.java

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/myse=
ttings/MySettingsEngine.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/engines/mysettings/MySettingsEngine.java&re=
v=3D17562&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/mysettings=
/MySettingsEngine.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/mysettings=
/MySettingsEngine.java Thu Jun 14 17:05:31 2007
@@ -51,11 +51,12 @@
 =

     public static final String REQUEST_KEY_PREFIX =3D "mysettings-user-";
     public static final String REQUEST_PASSWORD_KEY =3D REQUEST_KEY_PREFIX=
 + "password";
-    public static final String REQUEST_PASSWORD_CONFIRMATION_KEY =3D
-            REQUEST_KEY_PREFIX + "passwordConfirmation";
+    public static final String REQUEST_PASSWORD_CONFIRMATION_KEY =3D REQUE=
ST_KEY_PREFIX + "passwordConfirmation";
 =

     public static final String SEPARATOR =3D "#";
     public static final String USER_PROPERTY_PREFIX =3D REQUEST_KEY_PREFIX=
 + "property" + SEPARATOR;
+    public static final String USER_NEWPROPERTY_PREFIX =3D REQUEST_KEY_PRE=
FIX + "newpropkey";
+    public static final String USER_NEWPROPERTYVALUE_PREFIX =3D REQUEST_KE=
Y_PREFIX + "newpropvalue";
     public static final String EDIT_TOKEN =3D "edit";
     public static final String SAVE_TOKEN =3D "save";
 =

@@ -63,7 +64,6 @@
      * The engine's name
      */
     public static final String ENGINE_NAME =3D "mysettings";
-
     private static final String EDIT_JSP =3D "mysettings.jsp";
     private static final String SUCCESS_JSP =3D "mysettingschanged.jsp";
 =

@@ -78,7 +78,7 @@
      */
     private static MySettingsEngine instance;
     private EngineToolBox toolbox;
-
+    private boolean personalremoved=3Dfalse;
 =

     /**
      * Default constructor, creates a new <code>MySettingsEngine</code> ob=
ject instance.
@@ -204,17 +204,17 @@
      * @param jParams a ProcessingContext object
      */
     public void processScreen (ProcessingContext jParams, HashMap engineMa=
p)
-            throws JahiaException,
-            JahiaSessionExpirationException {
+            throws JahiaException {
 =

         if (logger.isDebugEnabled ())
-            logger.debug ("started");
-
+            logger.debug ("started process screen");
+        personalremoved=3Dfalse;
         // gets the actual screen
         // screen can be "edit" or "save"
         String theScreen =3D jParams.getParameter ("screen");
         if (theScreen =3D=3D null) {
             theScreen =3D EDIT_TOKEN;
+            logger.debug ("screen=3Dedit");
         }
 =

         JahiaUser user =3D jParams.getUser ();
@@ -227,6 +227,7 @@
 =

         // When the user clicked on the "save" button
         if (theScreen.equals (SAVE_TOKEN)) {
+            logger.debug("saving");
             ok =3D processSave (jParams, user);
         }
 =

@@ -238,7 +239,7 @@
             logger.debug ("end");
 =

         String targetJSP =3D EDIT_JSP;
-        if ("save".equals(theScreen) && ok) {
+        if ("save".equals(theScreen) && ok && !personalremoved) {
             targetJSP =3D SUCCESS_JSP;
         }
 =

@@ -289,6 +290,17 @@
                         return false;
                     }
                 }
+                //remove property
+                String removekey=3DjParams.getParameter("keytoremove");
+                if(removekey!=3Dnull && !"".equals(removekey)){
+                    logger.debug("to remove=3D"+removekey);
+                    UserProperty proptodelete=3D user.getUserProperty (rem=
ovekey);
+                    if(proptodelete!=3Dnull){
+                        user.removeProperty(removekey);
+                        personalremoved=3Dtrue;
+                        return true;
+                    }
+                }
 =

                 // pick out all the user properties parameters, and set it=
 into the
                 // user properties
@@ -296,11 +308,22 @@
                 if (names !=3D null) {
                     while (names.hasNext ()) {
                         String name =3D (String) names.next ();
+
                         if (name !=3D null && name.startsWith (USER_PROPER=
TY_PREFIX)) {
                             String newValue =3D jParams.getParameter (name=
);
+                            logger.debug(name+" "+newValue);
                             int index =3D name.indexOf (SEPARATOR);
                             String key =3D name.substring (index + 1);
-                            UserProperty currentProp =3D user.getUserPrope=
rty (key);
+
+                            if(key.equals("email")
+                                    ||key.equals("lastname")
+                                    ||key.equals("firstname")
+                                    ||key.equals("organization")){
+                            key =3D name.substring (index + 1);
+                            } else {
+                            key =3D name;
+                            }
+                            UserProperty currentProp=3D user.getUserProper=
ty (key);
                             if (newValue =3D=3D null) {
                                 continue;
                             }
@@ -310,11 +333,23 @@
                                 //TODO: The new data should be validated h=
ere!!
                                 if (!currentProp.isReadOnly()) {
                                     user.setProperty(key, newValue);
+                                } else {
+                                 logger.debug("this property is readonly")=
;   =

                                 }
                             }
                         }
                     }
                 }
+                String newPropertyKey=3D jParams.getParameter(USER_NEWPROP=
ERTY_PREFIX);
+                String newPropertyValue=3D jParams.getParameter(USER_NEWPR=
OPERTYVALUE_PREFIX);
+
+                if(newPropertyKey!=3Dnull
+                        && !newPropertyKey.equals("")
+                        && newPropertyValue!=3Dnull
+                        && !newPropertyValue.equals("")) {
+                    logger.debug("adding new value"+newPropertyValue+" for=
 property key:"+newPropertyKey);
+                        user.setProperty(USER_PROPERTY_PREFIX+newPropertyK=
ey, newPropertyValue);
+                }
 =

             } else {
                 return false;

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to