Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merged bugfix/ICPCO-111 into develop
axel committed Mar 17, 2021
2 parents 9d2c8c7 + f58b6ad commit fb6ca5d
Showing 3 changed files with 52 additions and 66 deletions.
10 changes: 5 additions & 5 deletions Controller/GrouperGroupsController.php
@@ -44,8 +44,8 @@ class GrouperGroupsController extends GrouperLiteAppController
//page navigation unless change record count and go back to lower number on Display record selection!! Sucks!
public $paginate = array(
//Default records per page.
'limit' => 2,
'maxlimit' => 4,
'limit' => 20,
'maxlimit' => 100,
'page' => 1
);

@@ -331,9 +331,11 @@ public function groupOptin() {

/**
* Create a new Grouper Group via Grouper Template
* Note: This is tighly coupled code to requirements, so view is hardcoded to reflect current reqs. Will need
* Note: This is tightly coupled code to requirements, so view is hardcoded to reflect current reqs. Will need
* to update when reqs change or are updated!!!
*
* Editing via a template will not be supported in this version of the plugin - Bill Kaufman
*
*/
public function groupCreateTemplateForm() {
if ($this->request->is('post')){
@@ -342,9 +344,7 @@ public function groupCreateTemplateForm() {
return $this->redirect(array('action' => 'groupoptin'));
}
}
//TODO - not sure if will be able to edit via Templates, so will need to fix once known.
$this->set('title', _txt('pl.grouperlite.title.templatecreate'));
//$this->set('grouperstems', $this->GrouperGroup->getOwnedStems($this->userId));
}


23 changes: 0 additions & 23 deletions Lib/GrouperApiAccess.php
@@ -255,29 +255,6 @@ 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
85 changes: 47 additions & 38 deletions Model/GrouperGroup.php
@@ -44,7 +44,8 @@ class GrouperGroup extends GrouperLiteAppModel

private $totalRecords = 0;

private $templateGroup = 'ref:workinggroupadmins';
/** @var string Group whose members can create Groups via Template process*/
private $templateCreationGroup = 'ref:workinggroupadmins';

/**
* Verifies if user is an owner/admin of a group and then stores results in Session.
@@ -83,42 +84,6 @@ 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
*
@@ -395,6 +360,50 @@ public function optinGroups(array $conditions) {
}
}

/**
* Determine if User can use the Grouper Template to create a suite of Groups including Email lists.
*
* @param string $userId Id of User
* @return string T for True and F for False
* @throws GrouperLiteException
*/
public function isTemplateUser(string $userId) {
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->templateCreationGroup) {
$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;
}

}


/**
* Create a new Grouper Group using the Template methodology in Grouper
*
@@ -544,7 +553,7 @@ public function getSearchedGroups(array $conditions) {
* Method needed to support Pagination
* Adjusted to fit the data source being the Grouper API vs DB calls
*
* @param $conditions Listing of conditions for display of records with pagination
* @param array $conditions Listing of conditions for display of records with pagination
* @return array Records requested by user with pagination support
*
*/

0 comments on commit fb6ca5d

Please sign in to comment.