dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20653
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9560: disable public sharing in UI, when user does not have the privileges to create public objects
------------------------------------------------------------
revno: 9560
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-01-18 16:54:53 +0100
message:
disable public sharing in UI, when user does not have the privileges to create public objects
added:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Meta.java
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Sharing.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.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-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java 2013-01-18 14:03:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java 2013-01-18 15:54:53 +0000
@@ -102,6 +102,8 @@
Sharing sharing = new Sharing();
+ sharing.getMeta().setAllowPublicAccess( SharingUtils.canCreatePublic( currentUserService.getCurrentUser(), object ) );
+
sharing.getObject().setId( object.getUid() );
sharing.getObject().setName( object.getDisplayName() );
sharing.getObject().setPublicAccess( object.getPublicAccess() );
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Meta.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Meta.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Meta.java 2013-01-18 15:54:53 +0000
@@ -0,0 +1,53 @@
+package org.hisp.dhis.api.webdomain.sharing;
+
+/*
+ * 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 com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class Meta
+{
+ @JsonProperty
+ private boolean allowPublicAccess;
+
+ public Meta()
+ {
+ }
+
+ public boolean isAllowPublicAccess()
+ {
+ return allowPublicAccess;
+ }
+
+ public void setAllowPublicAccess( boolean allowPublicAccess )
+ {
+ this.allowPublicAccess = allowPublicAccess;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Sharing.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Sharing.java 2013-01-04 10:00:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/sharing/Sharing.java 2013-01-18 15:54:53 +0000
@@ -35,12 +35,25 @@
public class Sharing
{
@JsonProperty
+ private Meta meta = new Meta();
+
+ @JsonProperty
private SharingObject object = new SharingObject();
public Sharing()
{
}
+ public Meta getMeta()
+ {
+ return meta;
+ }
+
+ public void setMeta( Meta meta )
+ {
+ this.meta = meta;
+ }
+
public SharingObject getObject()
{
return object;
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2013-01-16 09:40:57 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2013-01-18 15:54:53 +0000
@@ -423,6 +423,10 @@
$( '#sharingName' ).text( data.object.name );
+ if ( !data.meta.allowPublicAccess ) {
+ $( '#sharingPublicAccess' ).attr( 'disabled', true );
+ }
+
$( '.removeUserGroupAccess' ).unbind( 'click' ).bind( 'click', removeUserGroupAccess );
$( '#addUserGroupAccess' ).unbind( 'click' ).bind( 'click', addUserGroupAccessSelectedItem );
@@ -538,6 +542,4 @@
<td style="width: 25px; text-align: center;"><a href="" class="removeUserGroupAccess">X</a></td>
</tr>
</script>
-
-
-#end
\ No newline at end of file
+#end