dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21685
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10334: [mobile] limit access to programs that are not assigned to user's orgunit
------------------------------------------------------------
revno: 10334
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Wed 2013-03-20 10:54:42 +0700
message:
[mobile] limit access to programs that are not assigned to user's orgunit
modified:
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java
dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramList.vm
--
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-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java 2013-03-19 16:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java 2013-03-20 03:54:42 +0000
@@ -31,7 +31,6 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -48,6 +47,8 @@
import org.hisp.dhis.relationship.RelationshipService;
import org.hisp.dhis.relationship.RelationshipType;
import org.hisp.dhis.relationship.RelationshipTypeService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
import com.opensymphony.xwork2.Action;
@@ -142,6 +143,18 @@
this.relationshipTypeService = relationshipTypeService;
}
+ private CurrentUserService currentUserService;
+
+ public CurrentUserService getCurrentUserService()
+ {
+ return currentUserService;
+ }
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
@@ -249,10 +262,23 @@
return listOfCompletedProgram;
}
+ private User user;
+
+ public User getUser()
+ {
+ return user;
+ }
+
+ public void setUser( User user )
+ {
+ this.user = user;
+ }
+
@Override
public String execute()
throws Exception
{
+ user = currentUserService.getCurrentUser();
programInstances.clear();
relatedPeople = new HashMap<Relationship, Patient>();
@@ -321,7 +347,8 @@
programs.add( program );
}
else if ( programInstanceService.getProgramInstances( patient, program ).size() > 0
- && !program.getOnlyEnrollOnce() && programInstanceService.getProgramInstances( patient, program, false ).size() == 0)
+ && !program.getOnlyEnrollOnce()
+ && programInstanceService.getProgramInstances( patient, program, false ).size() == 0 )
{
programs.add( program );
}
=== 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 2013-03-19 04:35:21 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2013-03-20 03:54:42 +0000
@@ -241,6 +241,7 @@
ref="org.hisp.dhis.relationship.RelationshipTypeService" />
<property name="util" ref="org.hisp.dhis.light.utils.NamebasedUtils" />
<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramList.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramList.vm 2013-03-19 17:49:33 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryProgramList.vm 2013-03-20 03:54:42 +0000
@@ -10,13 +10,30 @@
<ul>
#if( $programInstances.size() > 0)
#foreach( $programInstance in $programInstances )
+ #set($authorized = false)
+ #foreach($orgUnit in $user.getOrganisationUnits())
+ #if($programInstance.getProgram().getOrganisationUnits().contains($orgUnit))
+ #set($authorized = true)
+ #end
+ #end
+
#if($programInstance.getProgram().isSingleEvent())
- <li><a href="showSingleEventForm.action?programId=$programInstance.getProgram().getId()&patientId=$patientId&organisationUnitId=$patient.getOrganisationUnit().getId()&isEditing=true">$programInstance.getProgram().getName()</a></li>
+ <li>
+ #if ($authorized)
+ <a href="showSingleEventForm.action?programId=$programInstance.getProgram().getId()&patientId=$patientId&organisationUnitId=$patient.getOrganisationUnit().getId()&isEditing=true">$programInstance.getProgram().getName()</a>
+ #else
+ $programInstance.getProgram().getName()
+ #end
+ </li>
#else
<li>
+ #if ($authorized)
<a href="showPatientProgramStageList.action?patientId=$patientId&programInstanceId=$programInstance.getId()&programId=$programInstance.getProgram().getId()&validated=false">
$programInstance.getProgram().getName()
</a>
+ #else
+ $programInstance.getProgram().getName()
+ #end
</li>
#set($nextStage = false)
@@ -24,7 +41,11 @@
#if($nextStage)
<li>
- <a href="showProgramStageSection.action?programId=$programInstance.getProgram().getId()&programStageId=$nextStage.getProgramStage().getId()&programStageInstanceId=$nextStage.getId()&patientId=$patient.getId()&programInstanceId=$programInstance.getId()&orgUnitId=0"> - Next: $nextStage.getProgramStage().getName()</a>
+ #if ($authorized)
+ <a href="showProgramStageSection.action?programId=$programInstance.getProgram().getId()&programStageId=$nextStage.getProgramStage().getId()&programStageInstanceId=$nextStage.getId()&patientId=$patient.getId()&programInstanceId=$programInstance.getId()&orgUnitId=0"> - Next: $nextStage.getProgramStage().getName()</a>
+ #else
+ - Next: $nextStage.getProgramStage().getName()
+ #end
</li>
#end
#end
@@ -39,13 +60,31 @@
<ul>
#if( $listOfCompletedProgram.size() != 0 )
#foreach( $programInstance in $listOfCompletedProgram )
+ #set($authorized = false)
+ #foreach($orgUnit in $user.getOrganisationUnits())
+ #if($programInstance.getProgram().getOrganisationUnits().contains($orgUnit))
+ #set($authorized = true)
+ #end
+ #end
+
#if($programInstance.getProgram().isSingleEvent())
- <li><a href="showSingleEventForm.action?programId=$programInstance.getProgram().getId()&patientId=$patientId&organisationUnitId=$patient.getOrganisationUnit().getId()&isEditing=true">$programInstance.getProgram().getName()</a></li>
-
- #else
- <li><a href="showPatientProgramStageList.action?patientId=$patientId&programInstanceId=$programInstance.getId()&programId=$programInstance.getProgram().getId()&validated=false">
- $programInstance.getProgram().getName()
- </a></li>
+ <li>
+ #if ($authorized)
+ <a href="showSingleEventForm.action?programId=$programInstance.getProgram().getId()&patientId=$patientId&organisationUnitId=$patient.getOrganisationUnit().getId()&isEditing=true">$programInstance.getProgram().getName()</a>
+ #else
+ $programInstance.getProgram().getName()
+ #end
+ </li>
+ #else
+ <li>
+ #if ($authorized)
+ <a href="showPatientProgramStageList.action?patientId=$patientId&programInstanceId=$programInstance.getId()&programId=$programInstance.getProgram().getId()&validated=false">
+ $programInstance.getProgram().getName()</a>
+
+ #else
+ $programInstance.getProgram().getName()
+ #end
+ </li>
#end
#end