You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2016/07/13 16:36:52 UTC

[02/10] airavata-php-gateway git commit: functions to get user permissions for existing projects and experiments

functions to get user permissions for existing projects and experiments


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/8e618197
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/8e618197
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/8e618197

Branch: refs/heads/grouper-integration
Commit: 8e6181976c60fbbf0efdcfa0627c8854e4a5ed47
Parents: 20d46c8
Author: Jeff Kinnison <je...@gmail.com>
Authored: Tue Jul 12 10:13:58 2016 -0400
Committer: Jeff Kinnison <je...@gmail.com>
Committed: Tue Jul 12 10:13:58 2016 -0400

----------------------------------------------------------------------
 app/libraries/ExperimentUtilities.php | 19 +++++++++++++++++++
 app/libraries/ProjectUtilities.php    | 21 +++++++++++++++++++++
 2 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/8e618197/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index c6e3e79..9de1c5d 100644
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -1343,5 +1343,24 @@ class ExperimentUtilities
         GrouperUtilities::revokeSharingOfResourceFromUsers($expId, ResourceType::EXPERIMENT, $rrevoke);
     }
 
+    /**
+     * Retrieve the user sharing permissions for a project.
+     * @param $expId
+     * @return An array of [uid => [read => bool, write => bool] indicating the permissions for each user with read or write access.
+     */
+    public static function get_sharing_settings($expId) {
+        $read = GrouperUtilities::getAllAccessibleUsers($expId, ResourceType::PROJECT, ResourcePermissionType::READ);
+        $write = GrouperUtilities::getAllAccessibleUsers($expId, ResourceType::PROJECT, ResourcePermissionType::WRITE);
+
+        $share = array();
+        foreach($read as $uid) {
+            $share[$uid] = array("read" => true, "write" => false);
+        }
+
+        foreach($write as $uid) {
+            $share[$uid]["write"] = true;
+        }
 
+        return $share;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/8e618197/app/libraries/ProjectUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ProjectUtilities.php b/app/libraries/ProjectUtilities.php
index 96415b9..6ea7322 100644
--- a/app/libraries/ProjectUtilities.php
+++ b/app/libraries/ProjectUtilities.php
@@ -305,4 +305,25 @@ class ProjectUtilities
         GrouperUtilities::shareResourceWithUsers($projectId, ResourceType::PROJECT, $radd);
         GrouperUtilities::revokeSharingOfResourceFromUsers($projectId, ResourceType::PROJECT, $rrevoke);
     }
+
+    /**
+     * Retrieve the user sharing permissions for a project.
+     * @param $projectId
+     * @return An array of [uid => [read => bool, write => bool] indicating the permissions for each user with read or write access.
+     */
+    public static function get_sharing_settings($projectId) {
+        $read = GrouperUtilities::getAllAccessibleUsers($projectId, ResourceType::PROJECT, ResourcePermissionType::READ);
+        $write = GrouperUtilities::getAllAccessibleUsers($projectId, ResourceType::PROJECT, ResourcePermissionType::WRITE);
+
+        $share = array();
+        foreach($read as $uid) {
+            $share[$uid] = array("read" => true, "write" => false);
+        }
+
+        foreach($write as $uid) {
+            $share[$uid]["write"] = true;
+        }
+
+        return $share;
+    }
 }