Skip to content

Commit

Permalink
changes completed
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Mar 8, 2021
1 parent cb23623 commit f980a5e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public function beforeFilter() {
}
$this->setConnection();
}

//Need to verify if user is part of
}

/**
Expand Down Expand Up @@ -201,6 +203,7 @@ public function groupOwner() {

}
$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
}

/**
Expand Down Expand Up @@ -255,6 +258,7 @@ public function groupMember() {
}
}
$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
}

/**
Expand Down Expand Up @@ -306,6 +310,7 @@ public function groupOptin() {
}
}
$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
}

//TODO - Need to combine this form with code below for groupCreate
Expand Down Expand Up @@ -432,6 +437,7 @@ public function emaillistsOptin() {
));

$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
}

public function emaillistsMember()
Expand All @@ -447,6 +453,7 @@ public function emaillistsMember()
));

$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
}

public function emaillistsManage() {
Expand All @@ -461,6 +468,7 @@ public function emaillistsManage() {
));

$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
}

public function emaillistInfo() {
Expand Down
24 changes: 24 additions & 0 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,30 @@ public function getOwnedGroups(array $queryData) {
return array();
}

/**
* Gets all groups in Grouper where user is an admin/owner
*
* @param array $queryData Array of conditions for querying
* @return array Array of groups from Grouper
* @throws GrouperLiteException
*
*/
public function getUserTemplateAuth(array $queryData) {
$queryData['groupType'] = 'Owner';

try {
$results = $this->useMembershipUrl($queryData);

if (isset($results['WsGetMembershipsResults']['wsGroups']) && $results['WsGetMembershipsResults']['wsGroups'] != NULL) {
return $results['WsGetMembershipsResults']['wsGroups'];
}
} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': An error occurred');
throw $e;
}
return array();
}

/**
* Get members associated to a specific Grouper Group
*
Expand Down
38 changes: 38 additions & 0 deletions Model/GrouperGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class GrouperGroup extends GrouperLiteAppModel

private $totalRecords = 0;

private $templateGroup = 'ref:workinggroupadmins';

/**
* Verifies if user is an owner/admin of a group and then stores results in Session.
* Session variable is reset on Group Creation and Group Deletion
Expand Down Expand Up @@ -81,6 +83,42 @@ public function isUserOwner(string $userId) {
}
}

public function isTemplateUser() {
if (CakeSession::check('Plugin.Grouper.isTemplateUser')) {
return CakeSession::read('Plugin.Grouper.isTemplateUser');
}

$this->initApi();

try {
$args = array();
$args['userId'] = $userId;

$memberOfGroups = $this->grouperAPI->getGrouperMemberOfGroups($args);

//now cycle through and see if part of correct group to be able to use template
$member = 'F';
foreach ($memberOfGroups as $memberOfGroup) {
if ($memberOfGroup['name'] == $this->templateGroup) {
$member = 'T';
break;
}
}

if ($member == 'T') {
CakeSession::write('Plugin.Grouper.isTemplateUser', 'T');
return 'T';
}
CakeSession::write('Plugin.Grouper.isTemplateUser', 'F');
return 'F';

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

}

/**
* Used to instantiate API class
*
Expand Down

0 comments on commit f980a5e

Please sign in to comment.