dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19347
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8397: User Profile - Added new details
------------------------------------------------------------
revno: 8397
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-10-06 15:45:50 +0700
message:
User Profile - Added new details
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserProfileForm.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserProfileForm.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/profile_edit.png
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserAccountForm.vm
dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties
dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-07-02 12:40:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2012-10-06 08:45:50 +0000
@@ -74,19 +74,34 @@
private String email;
private String phoneNumber;
-
+
private String jobTitle;
+ private String introduction;
+
+ private String gender;
+
+ private Date birthday;
+
+ private String nationality;
+
+ private String employer;
+
+ private String education;
+
+ private String interests;
+
+ private String languages;
+
private Date lastCheckedInterpretations;
-
+
private UserCredentials userCredentials;
private Set<UserGroup> groups = new HashSet<UserGroup>();
-
+
/**
- * All OrgUnits where the user could belong
- * <p/>
- * TODO This should have been put in UserCredentials
+ * All OrgUnits where the user could belong <p/> TODO This should have been
+ * put in UserCredentials
*/
@Scanned
private Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
@@ -119,7 +134,8 @@
// Logic
// -------------------------------------------------------------------------
- // TODO fix, users might very well have the same name, should use credentials
+ // TODO fix, users might very well have the same name, should use
+ // credentials
@Override
public boolean equals( Object object )
@@ -233,7 +249,7 @@
* Null is returned if the user has no organisation units. Which
* organisation unit to return is undefined if the user has multiple
* organisation units.
- *
+ *
* @return an organisation unit associated with the user.
*/
public OrganisationUnit getOrganisationUnit()
@@ -271,7 +287,7 @@
// -------------------------------------------------------------------------
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public String getFirstName()
{
@@ -284,7 +300,7 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public String getSurname()
{
@@ -297,7 +313,7 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public String getEmail()
{
@@ -310,7 +326,7 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public String getJobTitle()
{
@@ -323,7 +339,7 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public String getPhoneNumber()
{
@@ -335,6 +351,110 @@
this.phoneNumber = phoneNumber;
}
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public String getIntroduction()
+ {
+ return introduction;
+ }
+
+ public void setIntroduction( String introduction )
+ {
+ this.introduction = introduction;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public String getGender()
+ {
+ return gender;
+ }
+
+ public void setGender( String gender )
+ {
+ this.gender = gender;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public Date getBirthday()
+ {
+ return birthday;
+ }
+
+ public void setBirthday( Date birthday )
+ {
+ this.birthday = birthday;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public String getNationality()
+ {
+ return nationality;
+ }
+
+ public void setNationality( String nationality )
+ {
+ this.nationality = nationality;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public String getEmployer()
+ {
+ return employer;
+ }
+
+ public void setEmployer( String employer )
+ {
+ this.employer = employer;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public String getEducation()
+ {
+ return education;
+ }
+
+ public void setEducation( String education )
+ {
+ this.education = education;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public String getInterests()
+ {
+ return interests;
+ }
+
+ public void setInterests( String interests )
+ {
+ this.interests = interests;
+ }
+
+ @JsonProperty
+ @JsonView( { DetailedView.class, ExportView.class } )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public String getLanguages()
+ {
+ return languages;
+ }
+
+ public void setLanguages( String languages )
+ {
+ this.languages = languages;
+ }
+
public Date getLastCheckedInterpretations()
{
return lastCheckedInterpretations;
@@ -346,7 +466,7 @@
}
@JsonProperty
- @JsonView( {DetailedView.class, ExportView.class} )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public UserCredentials getUserCredentials()
{
@@ -370,7 +490,7 @@
@JsonProperty
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
- @JsonView( {DetailedView.class, ExportView.class} )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlElementWrapper( localName = "organisationUnits", namespace = Dxf2Namespace.NAMESPACE )
@JacksonXmlProperty( localName = "organisationUnit", namespace = Dxf2Namespace.NAMESPACE )
public Collection<OrganisationUnit> getOrganisationUnits()
@@ -384,7 +504,7 @@
}
@JsonProperty( value = "attributes" )
- @JsonView( {DetailedView.class, ExportView.class} )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlElementWrapper( localName = "attributes", namespace = Dxf2Namespace.NAMESPACE )
@JacksonXmlProperty( localName = "attribute", namespace = Dxf2Namespace.NAMESPACE )
public Set<AttributeValue> getAttributeValues()
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml 2012-07-02 12:40:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/user/hibernate/User.hbm.xml 2012-10-06 08:45:50 +0000
@@ -28,6 +28,22 @@
<property name="jobTitle" length="160" />
+ <property name="introduction" type="text" />
+
+ <property name="gender" length="5" />
+
+ <property name="birthday" type="date" />
+
+ <property name="nationality" length="160" />
+
+ <property name="employer" length="160" />
+
+ <property name="education" type="text" />
+
+ <property name="interests" type="text" />
+
+ <property name="languages" type="text" />
+
<property name="lastCheckedInterpretations" type="timestamp" />
<one-to-one name="userCredentials" class="org.hisp.dhis.user.UserCredentials" foreign-key="fk_userinfo_userid" />
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserProfileForm.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserProfileForm.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserProfileForm.js 2012-10-06 08:45:50 +0000
@@ -0,0 +1,35 @@
+jQuery( document ).ready( function()
+{
+ var rules = getValidationRules( "profile" );
+
+ validation2( 'updateUserProfileForm', updateUserProfile, {
+ 'rules' : rules
+ } );
+
+ datePickerValid( 'birthday', false );
+
+ jQuery( '#email' ).focus();
+} );
+
+function updateUserProfile()
+{
+ jQuery.postUTF8( 'updateUserProfile.action',
+ {
+ id: getFieldValue( 'id' ),
+ email: getFieldValue( 'email' ),
+ phoneNumber: getFieldValue( 'phoneNumber' ),
+ introduction: getFieldValue( 'introduction' ),
+ jobTitle: getFieldValue( 'jobTitle' ),
+ gender: getFieldValue( 'gender' ),
+ birthday: getFieldValue( 'birthday' ),
+ nationality: getFieldValue( 'nationality' ),
+ employer: getFieldValue( 'employer' ),
+ education: getFieldValue( 'education' ),
+ interests: getFieldValue( 'interests' ),
+ languages: getFieldValue( 'languages' )
+ }
+ , function( json )
+ {
+ setHeaderDelayMessage( json.message );
+ } );
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2012-08-22 07:08:08 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2012-10-06 08:45:50 +0000
@@ -38,6 +38,15 @@
"required" : true
}
},
+ "profile" : {
+ "email" : {
+ "email" : true,
+ "rangelength" : [ 0, 160 ]
+ },
+ "phoneNumber" : {
+ "rangelength" : [ 0, 80 ]
+ }
+ },
"role" : {
"name" : {
"required" : true,
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserAccountForm.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserAccountForm.vm 2012-10-05 08:36:10 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserAccountForm.vm 2012-10-06 08:45:50 +0000
@@ -1,6 +1,8 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/useraccount/updateUserAccountForm.js"></script>
-<h3>$i18n.getString( "update_user" )</h3>
+<h3>$i18n.getString( "update_user" )
+<a href="showUpdateUserProfileForm.action" title="$i18n.getString( 'edit_profile' )"><img src="../icons/profile_edit.png" alt="$i18n.getString( 'edit_profile' )"/></a>
+</h3>
<form id="updateUserinforForm" action="updateUserAccount.action" method="post" onsubmit='return false;'>
<div>
@@ -13,18 +15,18 @@
</tr>
<tr>
<td><label for="username">$i18n.getString( "user_name" )</label></td>
- <td><input type="text" id="username" name="username" value="$encoder.htmlEncode( $userCredentials.username )" style="width:20em" disabled="disabled"></td>
- </tr>
- <tr>
- <td><label for="firstName">$i18n.getString( "first_name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
- <td><input type="text" id="firstName" name="firstName" value="$encoder.htmlEncode( $userCredentials.user.firstName )" style="width:20em"></td>
- </tr>
- <tr>
- <td><label for="surname">$i18n.getString( "last_name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
- <td><input type="text" id="surname" name="surname" value="$encoder.htmlEncode( $userCredentials.user.surname )" style="width:20em"></td>
+ <td><input type="text" id="username" name="username" value="$!encoder.htmlEncode( $!userCredentials.username )" style="width:20em" disabled="disabled"></td>
+ </tr>
+ <tr>
+ <td><label for="firstName">$i18n.getString( "first_name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="firstName" name="firstName" value="$!encoder.htmlEncode( $!userCredentials.user.firstName )" style="width:20em"></td>
+ </tr>
+ <tr>
+ <td><label for="surname">$i18n.getString( "last_name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td><input type="text" id="surname" name="surname" value="$!encoder.htmlEncode( $!userCredentials.user.surname )" style="width:20em"></td>
</tr>
<tr>
- <td><label for="rawPassword">$i18n.getString( "old_password" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+ <td><label for="rawPassword">$i18n.getString( "old_password" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><input type="password" id="oldPassword" name="oldPassword" style="width:20em"></td>
</tr>
<tr>
@@ -37,15 +39,15 @@
</tr>
<tr>
<td><label for="email">$i18n.getString( "email" )</label></td>
- <td><input type="text" id="email" name="email" value="$!encoder.htmlEncode( $userCredentials.user.email )" style="width:20em"/></td>
+ <td><input type="text" id="email" name="email" value="$!encoder.htmlEncode( $!userCredentials.user.email )" style="width:20em"/></td>
</tr>
<tr>
<td><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
- <td><input type="text" id="phoneNumber" name="phoneNumber" value="$!encoder.htmlEncode( $userCredentials.user.phoneNumber )" style="width:20em"/></td>
+ <td><input type="text" id="phoneNumber" name="phoneNumber" value="$!encoder.htmlEncode( $!userCredentials.user.phoneNumber )" style="width:20em"/></td>
</tr>
<tr>
<td></td>
- <td valign="top"><input type="submit" value="$i18n.getString( "save" )" style="width:10em">
+ <td valign="top"><input type="submit" value="$i18n.getString( 'save' )" style="width:10em">
<input type="button" value="$i18n.getString( 'back' )" onclick="window.location.href='$!backUrl'" style="width:120px"/></td>
</tr>
</table>
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserProfileForm.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserProfileForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/updateUserProfileForm.vm 2012-10-06 08:45:50 +0000
@@ -0,0 +1,69 @@
+<script type="text/javascript" src="../dhis-web-commons/javascripts/useraccount/updateUserProfileForm.js"></script>
+
+<h3>$encoder.htmlEncode( $userCredentials.user.getName() )</h3>
+
+<form id="updateUserProfileForm" name="updateUserProfileForm">
+<div>
+ <input type="hidden" id="id" name="id" value="$userCredentials.id"/>
+</div>
+
+<table>
+ <tr>
+ <th colspan="2">$i18n.getString( "profile_details" )</th>
+ </tr>
+ <tr>
+ <td><label for="email">$i18n.getString( "email" )</label></td>
+ <td><input type="text" id="email" name="email" value="$!encoder.htmlEncode( $userCredentials.user.email )" style="width:20em"/></td>
+ </tr>
+ <tr>
+ <td><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
+ <td><input type="text" id="phoneNumber" name="phoneNumber" value="$!encoder.htmlEncode( $userCredentials.user.phoneNumber )" style="width:20em"/></td>
+ </tr>
+ <tr>
+ <td><label for="introduction">$i18n.getString( "introduction" )</label></td>
+ <td><textarea id="introduction" name="introduction" style="width:20em">$!encoder.htmlEncode( $!userCredentials.user.introduction )</textarea></td>
+ </tr>
+ <tr>
+ <td><label for="jobTitle">$i18n.getString( "job_title" )</label></td>
+ <td><input type="text" id="jobTitle" name="jobTitle" value="$!encoder.htmlEncode( $userCredentials.user.jobTitle )" style="width:20em"></td>
+ </tr>
+ <tr>
+ <td><label for="gender">$i18n.getString( "gender" )</label></td>
+ <td><select type="text" id="gender" name="gender" style="width:20em">
+ <option value="">[ $i18n.getString( "please_select" ) ]</option>
+ <option value="M" #if( $!userCredentials.user.gender == "M" ) selected="selected" #end>$i18n.getString( "male" )</option>
+ <option value="F" #if( $!userCredentials.user.gender == "F" ) selected="selected" #end>$i18n.getString( "female" )</option>
+ <option value="O" #if( $!userCredentials.user.gender == "O" ) selected="selected" #end>$i18n.getString( "other" )</option>
+ </select></td>
+ </tr>
+ <tr>
+ <td><label for="birthday">$i18n.getString( "birthday" )</label></td>
+ <td><input type="text" id="birthday" name="birthday" value="$!format.formatDate( $!userCredentials.user.birthday )" style="width:20em"/></td>
+ </tr>
+ <tr>
+ <td><label for="nationality">$i18n.getString( "nationality" )</label></td>
+ <td><input type="text" id="nationality" name="nationality" value="$!encoder.htmlEncode( $!userCredentials.user.nationality )" style="width:20em"/></td>
+ </tr>
+ <tr>
+ <td><label for="employer">$i18n.getString( "employer" )</label></td>
+ <td><input type="text" id="employer" name="employer" value="$!encoder.htmlEncode( $!userCredentials.user.employer )" style="width:20em"/></td>
+ </tr>
+ <tr>
+ <td><label for="education">$i18n.getString( "education" )</label></td>
+ <td><textarea id="education" name="education" style="width:20em">$!encoder.htmlEncode( $!userCredentials.user.education )</textarea></td>
+ </tr>
+ <tr>
+ <td><label for="interests">$i18n.getString( "interests" )</label></td>
+ <td><textarea id="interests" name="interests" style="width:20em">$!encoder.htmlEncode( $!userCredentials.user.interests )</textarea></td>
+ </tr>
+ <tr>
+ <td><label for="languages">$i18n.getString( "languages" )</label></td>
+ <td><textarea id="languages" name="languages" style="width:20em">$!encoder.htmlEncode( $!userCredentials.user.languages )</textarea></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td valign="top"><input type="submit" value="$i18n.getString( 'update' )" style="width:10em">
+ <input type="button" value="$i18n.getString( 'back' )" onclick="window.location.href='$!backUrl'" style="width:120px"/></td>
+ </tr>
+</table>
+</form>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/profile_edit.png'
Binary files dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/profile_edit.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/icons/profile_edit.png 2012-10-06 08:45:50 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/useraccount/action/UpdateUserProfileAction.java 2012-10-06 08:45:50 +0000
@@ -0,0 +1,223 @@
+package org.hisp.dhis.useraccount.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import static org.hisp.dhis.system.util.TextUtils.nullIfEmpty;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+public class UpdateUserProfileAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private UserService userService;
+
+ // -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
+ private I18n i18n;
+
+ private I18nFormat format;
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ private String email;
+
+ private String phoneNumber;
+
+ private String introduction;
+
+ private String gender;
+
+ private String birthday;
+
+ private String nationality;
+
+ private String employer;
+
+ private String education;
+
+ private String interests;
+
+ private String languages;
+
+ private String message;
+
+ private String jobTitle;
+
+ // -------------------------------------------------------------------------
+ // Getters && Setters
+ // -------------------------------------------------------------------------
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ public void setFormat( I18nFormat format )
+ {
+ this.format = format;
+ }
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ public void setPhoneNumber( String phoneNumber )
+ {
+ this.phoneNumber = phoneNumber;
+ }
+
+ public void setEmail( String email )
+ {
+ this.email = email;
+ }
+
+ public void setIntroduction( String introduction )
+ {
+ this.introduction = introduction;
+ }
+
+ public void setJobTitle( String jobTitle )
+ {
+ this.jobTitle = jobTitle;
+ }
+
+ public void setGender( String gender )
+ {
+ this.gender = gender;
+ }
+
+ public void setBirthday( String birthday )
+ {
+ this.birthday = birthday;
+ }
+
+ public void setNationality( String nationality )
+ {
+ this.nationality = nationality;
+ }
+
+ public void setEmployer( String employer )
+ {
+ this.employer = employer;
+ }
+
+ public void setEducation( String education )
+ {
+ this.education = education;
+ }
+
+ public void setInterests( String interests )
+ {
+ this.interests = interests;
+ }
+
+ public void setLanguages( String languages )
+ {
+ this.languages = languages;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ // ---------------------------------------------------------------------
+ // Prepare values
+ // ---------------------------------------------------------------------
+
+ email = nullIfEmpty( email );
+ phoneNumber = nullIfEmpty( phoneNumber );
+ introduction = nullIfEmpty( introduction );
+ jobTitle = nullIfEmpty( jobTitle );
+ nationality = nullIfEmpty( nationality );
+ employer = nullIfEmpty( employer );
+ education = nullIfEmpty( education );
+ interests = nullIfEmpty( interests );
+ languages = nullIfEmpty( languages );
+
+ User user = userService.getUser( id );
+
+ if ( user == null )
+ {
+ message = i18n.getString( "user_is_not_available" );
+
+ return ERROR;
+ }
+
+ // ---------------------------------------------------------------------
+ // Update User
+ // ---------------------------------------------------------------------
+
+ user.setEmail( email );
+ user.setPhoneNumber( phoneNumber );
+ user.setIntroduction( introduction );
+ user.setJobTitle( jobTitle );
+ user.setGender( gender );
+ user.setBirthday( format.parseDate( birthday ) );
+ user.setNationality( nationality );
+ user.setEmployer( employer );
+ user.setEducation( education );
+ user.setInterests( interests );
+ user.setLanguages( languages );
+
+ userService.updateUser( user );
+
+ message = i18n.getString( "update_user_profile_success" );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2012-10-05 11:57:54 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2012-10-06 08:45:50 +0000
@@ -584,6 +584,9 @@
</property>
</bean>
+ <bean id="org.hisp.dhis.useraccount.action.UpdateUserProfileAction" class="org.hisp.dhis.useraccount.action.UpdateUserProfileAction"
+ scope="prototype"/>
+
<bean id="org.hisp.dhis.commons.action.GetPingAction" class="org.hisp.dhis.commons.action.GetPingAction">
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2012-09-19 11:41:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2012-10-06 08:45:50 +0000
@@ -858,6 +858,11 @@
<param name="page">/dhis-web-commons/useraccount/updateUserAccountForm.vm</param>
</action>
+ <action name="showUpdateUserProfileForm" class="org.hisp.dhis.useraccount.action.GetCurrentUserAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-commons/useraccount/updateUserProfileForm.vm</param>
+ </action>
+
<action name="updateUserAccount" class="org.hisp.dhis.useraccount.action.UpdateUserAccountAction">
<result name="success" type="velocity-xml">
/dhis-web-commons/useraccount/updateUserSuccess.vm
@@ -867,6 +872,15 @@
</result>
</action>
+ <action name="updateUserProfile" class="org.hisp.dhis.useraccount.action.UpdateUserProfileAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
+ <result name="error" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseError.vm
+ </result>
+ </action>
+
<action name="modules" class="org.hisp.dhis.commons.action.NoAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-commons/about/modules.vm</param>
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2012-10-05 08:36:10 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global.properties 2012-10-06 08:45:50 +0000
@@ -296,6 +296,21 @@
system_overview=System Overview
server_date=Server date
online_release_page=online release page
+edit_profile=Edit profile
+profile_details=Profile details
+job_title=Job title
+introduction=Introduction
+gender=Gender
+male=Male
+female=Female
+other=Other
+birthday=Birthday
+nationality=Nationality
+employer=Employer
+education=Education
+interests=Interests
+languages=Languages
+update_user_profile_success=Update user profile successfully
#-- Change Log------------------------------------------------------------------#
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties 2012-09-19 15:26:57 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/i18n_global_vi_VN.properties 2012-10-06 08:45:50 +0000
@@ -410,3 +410,18 @@
help_center=Trung t\u00e2m h\u1ed7 tr\u1ee3
clear=X\u00f3a
Monthly=H\u00e0ng th\u00e1ng
+edit_profile=Ch\u1ec9nh s\u1eeda Profile
+profile_details=Chi ti\u1ebft Profile
+job_title=Ngh\u1ec1 nghi\u1ec7p
+introduction=Gi\u1edbi thi\u1ec7u b\u1ea3n th\u00e2n
+gender=Gi\u1edbi t\u00ednh
+male=Nam
+female=N\u1eef
+other=Kh\u00e1c
+birthday=Ng\u00e0y sinh
+nationality=Qu\u1ed1c t\u1ecbch
+employer=C\u00f4ng ty
+education=Tr\u00ecnh \u0111\u1ed9
+interests=S\u1edf th\u00edch
+languages=Ng\u00f4n ng\u1eef
+update_user_profile_success=C\u1eadp nh\u1eadt profile cho ng\u01b0\u1eddi d\u00f9ng th\u00e0nh c\u00f4ng
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2012-09-26 08:42:25 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2012-10-06 08:45:50 +0000
@@ -263,5 +263,4 @@
month=month
months=months
select=Select
-object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type
-job_title=Job title
\ No newline at end of file
+object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type
\ No newline at end of file