airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [1/2] airavata-php-gateway git commit: AIRAVATA-2184 Ownership info now using sharing API
Date Wed, 28 Dec 2016 16:05:49 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/develop 7ebc2e9a7 -> 199c9026d


AIRAVATA-2184 Ownership info now using sharing API


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

Branch: refs/heads/develop
Commit: 0c94cd875e877c1a48f06d40ec4e730d0c85d3c7
Parents: d3337ba
Author: Marcus Christie <machrist@iu.edu>
Authored: Fri Dec 16 16:17:53 2016 -0500
Committer: Marcus Christie <machrist@iu.edu>
Committed: Fri Dec 16 16:17:53 2016 -0500

----------------------------------------------------------------------
 app/controllers/ExperimentController.php | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/0c94cd87/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index 6d06aad..8bf2884 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -79,7 +79,7 @@ class ExperimentController extends BaseController
 
                 $projectOwner = array();
                 $sharedProjectOwner = SharingUtilities::getSharedResourceOwner($_POST['project'],
ResourceType::PROJECT);
-                if (strcmp(Session::get("username"), $sharedProjectOwner) !== 0) {
+                if (Session::get("username") !== $sharedProjectOwner) {
                     $projectOwner[$sharedProjectOwner] = $users[$sharedProjectOwner];
                     $users = array_diff_key($users, $projectOwner);
                 }
@@ -169,14 +169,15 @@ class ExperimentController extends BaseController
             );
             if(Config::get('pga_config.airavata')["data-sharing-enabled"]){
                 $users = SharingUtilities::getProfilesForSharedUsers(Input::get("expId"),
ResourceType::EXPERIMENT);
+                $sharedExperimentOwner = SharingUtilities::getSharedResourceOwner($experiment->experimentId,
ResourceType::EXPERIMENT);
                 $sharedProjectOwner = SharingUtilities::getSharedResourceOwner($experiment->projectId,
ResourceType::PROJECT);
 
                 $owner = array();
                 $projectOwner = array();
-                if (strcmp(Session::get("username"), $experiment->userName) !== 0) {
-                    $owner[$experiment->userName] = $users[$experiment->userName];
+                if (Session::get("username") !== $sharedExperimentOwner) {
+                    $owner[$sharedExperimentOwner] = $users[$sharedExperimentOwner];
                 }
-                if (strcmp(Session::get("username"), $sharedProjectOwner) !== 0) {
+                if (Session::get("username") !== $sharedProjectOwner) {
                     $projectOwner[$sharedProjectOwner] = $users[$sharedProjectOwner];
                 }
                 // Subtract out the owner and project owner from list of users
@@ -187,7 +188,7 @@ class ExperimentController extends BaseController
                 // Only allow editing sharing on the summary page if the owner
                 // and the experiment isn't editable. If the experiment is
                 // editable, the sharing can be edited on the edit page.
-                $canEditSharing = $this->isExperimentOwner($experiment, Session::get("username"))
&& !$expVal["editable"];
+                $canEditSharing = (Session::get("username") === $sharedExperimentOwner) &&
!$expVal["editable"];
                 $data['can_write'] = SharingUtilities::userCanWrite(Session::get("username"),
$experiment->experimentId, ResourceType::EXPERIMENT);
                 $data["users"] = json_encode($users);
                 $data["owner"] = json_encode($owner);
@@ -296,14 +297,15 @@ class ExperimentController extends BaseController
         if(Config::get('pga_config.airavata')["data-sharing-enabled"]){
             if (SharingUtilities::userCanWrite(Session::get("username"), $_GET['expId'],
ResourceType::EXPERIMENT) === true) {
                 $users = SharingUtilities::getProfilesForSharedUsers($_GET['expId'], ResourceType::EXPERIMENT);
+                $sharedExperimentOwner = SharingUtilities::getSharedResourceOwner($experiment->experimentId,
ResourceType::EXPERIMENT);
                 $sharedProjectOwner = SharingUtilities::getSharedResourceOwner($experiment->projectId,
ResourceType::PROJECT);
 
                 $owner = array();
                 $projectOwner = array();
-                if (strcmp(Session::get("username"), $experiment->userName) !== 0) {
-                    $owner[$experiment->userName] = $users[$experiment->userName];
+                if (Session::get("username") !==  $sharedExperimentOwner) {
+                    $owner[$sharedExperimentOwner] = $users[$sharedExperimentOwner];
                 }
-                if (strcmp(Session::get("username"), $sharedProjectOwner) !== 0) {
+                if (Session::get("username") !== $sharedProjectOwner) {
                     $projectOwner[$sharedProjectOwner] = $users[$sharedProjectOwner];
                 }
                 // Subtract out owner and project owner from list of users
@@ -312,7 +314,7 @@ class ExperimentController extends BaseController
                 // If project owner is the same as owner, just show the owner, not the project
owner
                 $projectOwner = array_diff_key($projectOwner, $owner);
 
-                $canEditSharing = $this->isExperimentOwner($experiment, Session::get('username'));
+                $canEditSharing = Session::get("username") === $sharedExperimentOwner;
 
                 return View::make("experiment/edit", array("expInputs" => $experimentInputs,
                     "users" => json_encode($users), "owner" => json_encode($owner),
@@ -485,11 +487,6 @@ class ExperimentController extends BaseController
             return Response::json(array("success" => false, "error" => "Error: failed
to update sharing: " . $ex->getMessage()));
         }
     }
-
-    private function isExperimentOwner($experiment, $username)
-    {
-        return strcmp($username, $experiment->userName) === 0;
-    }
 }
 
 ?>


Mime
View raw message