Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'develop' of bitbucket.org:unicon/comanagework into develop
rmathis committed Mar 9, 2021
2 parents 47745d1 + efc37f6 commit e56d2c3
Showing 3 changed files with 70 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Controller/GrouperGroupsController.php
@@ -76,6 +76,8 @@ public function beforeFilter() {
}
$this->setConnection();
}

//Need to verify if user is part of
}

/**
@@ -217,6 +219,7 @@ public function groupOwner() {

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

/**
@@ -271,6 +274,7 @@ public function groupMember() {
}
}
$this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId));
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
}

/**
@@ -322,6 +326,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
@@ -448,6 +453,7 @@ public function emaillistsOptin() {
));

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

public function emaillistsMember()
@@ -463,6 +469,7 @@ public function emaillistsMember()
));

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

public function emaillistsManage() {
@@ -477,6 +484,7 @@ public function emaillistsManage() {
));

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

public function emaillistInfo() {
24 changes: 24 additions & 0 deletions Lib/GrouperApiAccess.php
@@ -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
*
38 changes: 38 additions & 0 deletions Model/GrouperGroup.php
@@ -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
@@ -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
*

0 comments on commit e56d2c3

Please sign in to comment.