=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/message/action/AddRecipientAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/message/action/AddRecipientAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/message/action/AddRecipientAction.java 2014-05-06 06:43:36 +0000
@@ -0,0 +1,101 @@
+package org.hisp.dhis.light.message.action;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ *
+ * @author Paul Mark Castillo
+ *
+ */
+public class AddRecipientAction
+ implements Action
+{
+ private static final Log log = LogFactory.getLog( AddRecipientAction.class );
+
+ public AddRecipientAction()
+ {
+ }
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private UserService userService;
+
+ public UserService getUserService()
+ {
+ return userService;
+ }
+
+ public void setUserService( UserService userService )
+ {
+ this.userService = userService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private String recipientCheckBox;
+ public String getRecipientCheckBox()
+ {
+ return recipientCheckBox;
+ }
+
+ public void setRecipientCheckBox( String recipientCheckBox )
+ {
+ this.recipientCheckBox = recipientCheckBox;
+ }
+
+ private Set recipient;
+ public Set getRecipient()
+ {
+ return recipient;
+ }
+
+ public void setRecipients( Set recipient )
+ {
+ this.recipient = recipient;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action Implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ updateRecipients(recipientCheckBox);
+ return SUCCESS;
+ }
+
+ /**
+ *
+ * @param recipientCheckBox
+ */
+ private void updateRecipients(String recipientCheckBox)
+ {
+ recipient = new HashSet();
+
+ if ( recipientCheckBox != null )
+ {
+ String rcbArray[] = recipientCheckBox.split( "," );
+
+ for ( int i = 0; i < rcbArray.length; i++ )
+ {
+ rcbArray[i] = rcbArray[i].trim();
+ User u = userService.getUser( Integer.parseInt( rcbArray[i] ) );
+ recipient.add( u );
+ }
+ }
+ }
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/FindUserAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/FindUserAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/FindUserAction.java 2014-05-06 06:43:36 +0000
@@ -29,7 +29,11 @@
*/
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserService;
@@ -38,11 +42,16 @@
public class FindUserAction
implements Action
{
+ private static final Log log = LogFactory.getLog( FindUserAction.class );
private static final String REDIRECT = "redirect";
private UserService userService;
+ public FindUserAction()
+ {
+ }
+
public UserService getUserService()
{
return userService;
@@ -101,10 +110,46 @@
this.userId = userId;
}
+ private String recipientCheckBox;
+ public String getRecipientCheckBox()
+ {
+ return recipientCheckBox;
+ }
+
+ public void setRecipientCheckBox( String recipientCheckBox )
+ {
+ this.recipientCheckBox = recipientCheckBox;
+ }
+
+ private Set recipient;
+ public Set getRecipient()
+ {
+ return recipient;
+ }
+
+ public void setRecipients( Set recipient )
+ {
+ this.recipient = recipient;
+ }
+
+ private int foundUsers;
+ public int getFoundUsers()
+ {
+ return foundUsers;
+ }
+
+ public void setFoundUsers( int foundUsers )
+ {
+ this.foundUsers = foundUsers;
+ }
+
+
@Override
public String execute()
throws Exception
{
+ updateRecipients(recipientCheckBox);
+
if ( keyword != null )
{
int index = keyword.indexOf( ' ' );
@@ -115,7 +160,7 @@
keyword = keys[0] + " " + keys[1];
}
}
-
+
users = userService.getUsersByName( keyword );
if ( users.size() == 1 )
@@ -125,6 +170,29 @@
return REDIRECT;
}
+ foundUsers = users.size();
+
return SUCCESS;
}
+
+ /**
+ *
+ * @param recipientCheckBox
+ */
+ private void updateRecipients(String recipientCheckBox)
+ {
+ recipient = new HashSet();
+
+ if ( recipientCheckBox != null )
+ {
+ String rcbArray[] = recipientCheckBox.split( "," );
+
+ for ( int i = 0; i < rcbArray.length; i++ )
+ {
+ rcbArray[i] = rcbArray[i].trim();
+ User u = userService.getUser( Integer.parseInt( rcbArray[i] ) );
+ recipient.add( u );
+ }
+ }
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/SendMessagesAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/SendMessagesAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/messaging/action/SendMessagesAction.java 2014-05-06 06:43:36 +0000
@@ -31,6 +31,8 @@
import java.util.HashSet;
import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.user.User;
@@ -43,6 +45,8 @@
public class SendMessagesAction
implements Action
{
+ private static final Log log = LogFactory.getLog( SendMessagesAction.class );
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -59,12 +63,12 @@
private User user;
- private Integer userId;
-
- public void setUserId( Integer userId )
- {
- this.userId = userId;
- }
+// private Integer userId;
+//
+// public void setUserId( Integer userId )
+// {
+// this.userId = userId;
+// }
public User getUser()
{
@@ -90,21 +94,71 @@
this.text = text;
}
+ private String recipientCheckBox;
+ public String getRecipientCheckBox()
+ {
+ return recipientCheckBox;
+ }
+
+ public void setRecipientCheckBox( String recipientCheckBox )
+ {
+ this.recipientCheckBox = recipientCheckBox;
+ }
+
+ private Set recipient;
+ public Set getRecipient()
+ {
+ return recipient;
+ }
+
+ public void setRecipients( Set recipient )
+ {
+ this.recipient = recipient;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
public String execute()
{
- user = userService.getUser( userId );
+ log.info( "SendMessagesAction.execute() called" );
+
+ updateRecipients(recipientCheckBox);
+
+// user = userService.getUser( userId );
String metaData = MessageService.META_USER_AGENT
+ ServletActionContext.getRequest().getHeader( ContextUtils.HEADER_USER_AGENT );
- Set users = new HashSet();
- users.add( user );
-
- messageService.sendMessage( subject, text, metaData, users );
-
+// Set users = new HashSet();
+// users.add( user );
+
+// messageService.sendMessage( subject, text, metaData, users );
+ messageService.sendMessage( subject, text, metaData, recipient );
+
+ log.debug( "SendMessagesAction.execute() exit: " + SUCCESS);
+
return SUCCESS;
}
+
+ /**
+ *
+ * @param recipientCheckBox
+ */
+ private void updateRecipients(String recipientCheckBox)
+ {
+ recipient = new HashSet();
+
+ if ( recipientCheckBox != null )
+ {
+ String rcbArray[] = recipientCheckBox.split( "," );
+
+ for ( int i = 0; i < rcbArray.length; i++ )
+ {
+ rcbArray[i] = rcbArray[i].trim();
+ User u = userService.getUser( Integer.parseInt( rcbArray[i] ) );
+ recipient.add( u );
+ }
+ }
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2014-02-14 16:13:55 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2014-05-06 06:43:36 +0000
@@ -600,4 +600,9 @@
class="org.hisp.dhis.light.messaging.action.FindUserAction" scope="prototype">
+
+
+
+
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2014-03-26 07:41:18 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2014-05-06 06:43:36 +0000
@@ -134,4 +134,10 @@
search_orgunit=Search Organisation Unit
date_of_birth_hint=*Approximated: enter age. Declared or Verified: enter date in format [yyyy-mm-dd]
select_attribute=Select attribute
-tracked_entity=Tracked entity
\ No newline at end of file
+tracked_entity=Tracked entity
+write=Write
+write_message=Write Message
+write_feedback=Write Feedback
+write_new_message=Write new message
+write_to_users=To User(s):
+write_add_to_recipients=Add to Recipient(s)
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2014-04-04 08:11:18 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2014-05-06 06:43:36 +0000
@@ -456,6 +456,11 @@
+
+
+ /dhis-web-light/main.vm
+ /dhis-web-light/sendMessageOnMobile2.vm
+
@@ -489,19 +494,25 @@
showUserList.action?userId=${userId}
/dhis-web-light/main.vm
- /dhis-web-light/messages.vm
+ /dhis-web-light/sendMessageOnMobile2.vm
+
+ /dhis-web-light/main.vm
+ /dhis-web-light/sendMessageOnMobile2.vm
+
/dhis-web-light/main.vm
- /dhis-web-light/sendMessageOnMobile.vm
+ /dhis-web-light/sendMessageOnMobile2.vm
- /light/messages.action
+ /dhis-web-light/main.vm
+ /dhis-web-light/menu.vm
-
+#*
+
-
-
-
-
-
-
-
+
+
+
+
+
+*#
+
+$i18n.getString( "write" )
+
+
+
+
+
$i18n.getString( "last_recipients" )
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/sendMessageOnMobile2.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/sendMessageOnMobile2.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/sendMessageOnMobile2.vm 2014-05-06 06:43:36 +0000
@@ -0,0 +1,79 @@
+## ============================================================================
+
+ $i18n.getString( "write_new_message" )
+
+
+
+## ============================================================================
+
+
+
+## ============================================================================
+$i18n.getString("search_user")
+
+
+
+
+## ============================================================================
+
+
+
+## ============================================================================
+
\ No newline at end of file