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 <machr...@iu.edu>
Authored: Fri Mar 24 10:42:43 2017 -0400
Committer: Marcus Christie <machr...@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) {

Reply via email to