From f58b6ad91f75c8ef3aeead8df9fb1b376e3a67da Mon Sep 17 00:00:00 2001 From: axman Date: Wed, 17 Mar 2021 09:41:52 -0700 Subject: [PATCH] fixed bug --- Controller/GrouperGroupsController.php | 10 +-- Lib/GrouperApiAccess.php | 23 ------- Model/GrouperGroup.php | 85 ++++++++++++++------------ 3 files changed, 52 insertions(+), 66 deletions(-) diff --git a/Controller/GrouperGroupsController.php b/Controller/GrouperGroupsController.php index e778038..4dd3f1f 100644 --- a/Controller/GrouperGroupsController.php +++ b/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)); } diff --git a/Lib/GrouperApiAccess.php b/Lib/GrouperApiAccess.php index 041ac1a..87d1de4 100644 --- a/Lib/GrouperApiAccess.php +++ b/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 diff --git a/Model/GrouperGroup.php b/Model/GrouperGroup.php index ed55e06..e8d14e2 100644 --- a/Model/GrouperGroup.php +++ b/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 * */