Skip to content

Commit

Permalink
updated for I2 Dev enviro
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Mar 29, 2021
1 parent 2654b5c commit 7b26c04
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
22 changes: 15 additions & 7 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public function groupOwner() {
//Set initial settings for pagination
$scope = [
'userId' => $this->userId,
'page' => ($this->passedArgs['page'] ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => ($this->passedArgs['limit'] ? $this->passedArgs['limit']: $this->paginate['limit']),
'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
Expand Down Expand Up @@ -235,8 +235,8 @@ public function groupMember() {
//Set initial settings for pagination
$scope = [
'userId' => $this->userId,
'page' => ($this->passedArgs['page'] ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => ($this->passedArgs['limit'] ? $this->passedArgs['limit']: $this->paginate['limit']),
'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']),
];

if (isset($this->request->data['search'])) {
Expand Down Expand Up @@ -463,9 +463,17 @@ public function leaveGroup() {
function isAuthorized() {
$roles = $this->Role->calculateCMRoles();

//Need to pull in UserID for access to Grouper
//This call just pulls in user ID from comanage but not Grouper, need the Grouper Id for API calls.
/*
if ($this->Session->check('Auth.User.username')) {
$this->userId = $this->Session->read('Auth.User.username');
}*/

if ($this->Session->check('Plugin.Grouper.UserId')) {
$this->userId = $this->Session->read('Plugin.Grouper.UserId');
} else {
$this->userId = $this->GrouperGroup->getGrouperUserId();
$this->Session->write('Plugin.Grouper.UserId', $this->userId);
}

// Determine what operations this user can perform
Expand Down Expand Up @@ -530,8 +538,8 @@ public function emaillistsMember()
//Set initial settings for pagination
$scope = [
'userId' => $this->userId,
'page' => ($this->passedArgs['page'] ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => ($this->passedArgs['limit'] ? $this->passedArgs['limit']: $this->paginate['limit']),
'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']),
'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']),
];

try {
Expand Down
11 changes: 4 additions & 7 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,13 @@ public function __construct() {
}

/**
* NOT BEING USED
* Get User information from Grouper Web Service
*
* @param array $queryData Array of conditions for querying
* @return array
* @return String User ID in Grouper Groups
* @throws Exception
*/
public function getGrouperUser(array $queryData) {
public function getGrouperUserId() {

$userId = $queryData['userId'];
$this->http->setHeader(array('Content-Type' => 'application/json', 'Accept' => 'application/json'));

// Create attributes want returned from call to Grouper WS
Expand All @@ -94,7 +91,7 @@ public function getGrouperUser(array $queryData) {
'givenname'
),
'wsSubjectLookups' => array(
array('subjectIdentifier' => $userId)
array('subjectIdentifier' => $_SERVER['REMOTE_USER'])
)
)
);
Expand All @@ -114,7 +111,7 @@ public function getGrouperUser(array $queryData) {
throw $e;
}

return array();
return '';
}

/**
Expand Down
18 changes: 18 additions & 0 deletions Model/GrouperGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ private function initApi() {
}
}

/**
* Gets the users Id from Grouper since can be different than what is in Comanage.
*
* @return String User's Id in Grouper
* @throws Exception
*/
public function getGrouperUserId() {
$this->initApi();

try {
return $this->grouperAPI->getGrouperUserId();

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': An error occurred');
throw $e;
}
}

/**
* Return all Groups that a User belongs to in Grouper.
* Will also add Optin Groups and flag them as joined so can display Optout option in UI.
Expand Down

0 comments on commit 7b26c04

Please sign in to comment.