airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [13/50] [abbrv] airavata-php-gateway git commit: added checks for existence of users
Date Wed, 27 Jul 2016 17:05:21 GMT
added checks for existence of users


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

Branch: refs/heads/develop
Commit: 7d4787a86055e6a6cbcf371ee1ca4b262e0292f9
Parents: 8598e24
Author: Jeff Kinnison <jeffdkinnison@gmail.com>
Authored: Tue Jul 12 12:22:24 2016 -0400
Committer: Jeff Kinnison <jeffdkinnison@gmail.com>
Committed: Tue Jul 12 12:22:24 2016 -0400

----------------------------------------------------------------------
 app/libraries/SharingUtilities.php | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/7d4787a8/app/libraries/SharingUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/SharingUtilities.php b/app/libraries/SharingUtilities.php
index cacd939..27e9f00 100644
--- a/app/libraries/SharingUtilities.php
+++ b/app/libraries/SharingUtilities.php
@@ -25,8 +25,13 @@ class SharingUtilities {
      * @return True if the user has read permission, false otherwise.
      */
     public static function userCanRead($uid, $resourceId, $dataResourceType) {
-        $read = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::READ);
-        return (array_key_exists($uid, $read) ? true : false);
+        if (WSIS::usernameExists($uid)) {
+            $read = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType,
ResourcePermissionType::READ);
+            return (array_key_exists($uid, $read) ? true : false);
+        }
+        else {
+            return false;
+        }
     }
 
     /**
@@ -42,6 +47,14 @@ class SharingUtilities {
         $read = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::READ);
         $write = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType,
ResourcePermissionType::WRITE);
 
+        $read = array_filter($read, function($uid) {
+            return ($uid !== Session::get('username') && WSIS::usernameExists($uid));
+        });
+
+        $write = array_filter($write, function($uid) {
+            return ($uid !== Session::get('username') && WSIS::usernameExists($uid));
+        });
+
         foreach($read as $uid) {
             $users[$uid] = array('read' => true, 'write' => false);
         }
@@ -60,11 +73,12 @@ class SharingUtilities {
      * @return An array [uid => [firstname => string, lastname => string, email
=> string]]
      */
     public static function getUserProfiles($uids) {
+        $uids = array_filter($uids, function($uid) {
+            return ($uid !== Session::get('username') && WSIS::usernameExists($uid));
+        });
         $profiles = array();
         foreach ($uids as $uid) {
-            if (WSIS::usernameExists($uid)) {
-                $profiles[$uid] = WSIS::getUserProfile($uid);
-            }
+            $profiles[$uid] = WSIS::getUserProfile($uid);
         }
         return $profiles;
     }


Mime
View raw message