You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/05/01 17:17:25 UTC

[21/30] airavata-php-gateway git commit: AIRAVATA-2346 Owner is implied to have READ and WRITE permission

AIRAVATA-2346 Owner is implied to have READ and WRITE permission


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/0dca1aa5
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/0dca1aa5
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/0dca1aa5

Branch: refs/heads/dreg-gateway
Commit: 0dca1aa5add77c1880f5870baa6e5917d46f79b5
Parents: 3c12fea
Author: Marcus Christie <ma...@iu.edu>
Authored: Fri Mar 24 10:42:43 2017 -0400
Committer: Marcus Christie <ma...@iu.edu>
Committed: Fri Mar 24 10:42:43 2017 -0400

----------------------------------------------------------------------
 app/libraries/SharingUtilities.php | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/0dca1aa5/app/libraries/SharingUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/SharingUtilities.php b/app/libraries/SharingUtilities.php
index fb2fb84..f069e55 100755
--- a/app/libraries/SharingUtilities.php
+++ b/app/libraries/SharingUtilities.php
@@ -25,6 +25,11 @@ class SharingUtilities {
      * @return True if the user has read permission, false otherwise.
      */
     public static function userCanRead($uid, $resourceId, $dataResourceType) {
+        // If the user is the owner, then it is implied they can read the resource
+        $owner = SharingUtilities::getSharedResourceOwner($resourceId, $dataResourceType);
+        if ($uid == $owner) {
+            return true;
+        }
         $read = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::READ);
         foreach($read as $user) {
             if (strcmp($uid, $user) === 0) {
@@ -43,6 +48,11 @@ class SharingUtilities {
      * @return True if the user has write permission, false otherwise.
      */
     public static function userCanWrite($uid, $resourceId, $dataResourceType) {
+        // If the user is the owner, then it is implied they can write to the resource
+        $owner = SharingUtilities::getSharedResourceOwner($resourceId, $dataResourceType);
+        if ($uid == $owner) {
+            return true;
+        }
         $write = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::WRITE);
         foreach($write as $user) {
             if (strcmp($uid, $user) === 0) {