From b8a5e9edb8d861f934d9c499c29140928ff5fa1f Mon Sep 17 00:00:00 2001 From: axman Date: Wed, 27 Oct 2021 12:58:20 -0700 Subject: [PATCH] remove filtering ad-hoc, fix WG error messages --- Controller/GrouperGroupsController.php | 24 +++++++++++------ Lib/GrouperApiAccess.php | 2 ++ Model/GrouperGroup.php | 36 +------------------------- 3 files changed, 19 insertions(+), 43 deletions(-) diff --git a/Controller/GrouperGroupsController.php b/Controller/GrouperGroupsController.php index eb50333..2d52501 100644 --- a/Controller/GrouperGroupsController.php +++ b/Controller/GrouperGroupsController.php @@ -350,20 +350,27 @@ public function groupOptin() { */ public function groupCreateTemplate() { if ($this->request->is('post')) { - $status = $this->GrouperGroup->createGroupWithTemplate($this->userId, $this->request->data); - if ($status['status'] !== true) { - $this->Flash->set($status['message'], array('key' => 'error')); - } else { - $this->Flash->set("Success in creating group!", array('key' => 'success')); + try { + $status = $this->GrouperGroup->createGroupWithTemplate($this->userId, $this->request->data); + + if ($status['status'] !== true) { + $this->Flash->set($status['message'], array('key' => 'error')); + } else { + $this->Flash->set("Success in creating group!", array('key' => 'success')); + return $this->redirect(array('action' => 'groupowner')); + } + + } catch (Exception $e) { + CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true)); + $this->Flash->set(var_export($e->getMessage(), true), array('key' => 'error')); } - return $this->redirect(array('action' => 'groupcreatetemplate')); } $this->set('title', _txt('pl.grouperlite.title.templatecreate')); } /** * Delete a Grouper Group via Grouper Template - * + * NOT USED IN CODE */ public function groupDeleteTemplate() { if (!$this->GrouperGroup->deleteGroupWithTemplate($this->userId, $this->request->data)) { @@ -375,7 +382,8 @@ public function groupDeleteTemplate() { } /** - * This method is currently not used. + * @deprecated + * NOT USED IN CODE * * @return CakeResponse|void|null */ diff --git a/Lib/GrouperApiAccess.php b/Lib/GrouperApiAccess.php index ab5fc15..518ddd7 100644 --- a/Lib/GrouperApiAccess.php +++ b/Lib/GrouperApiAccess.php @@ -488,6 +488,8 @@ public function createGroupWithTemplate(array $queryData) { $status = false; $message = 'An error occurred, please try again later.'; } + } elseif (stripos($results['WsGshTemplateExecResult']['resultMetadata']['resultCode'], "EXCEPTION", 0) !== false) { + throw new GrouperLiteException("An error occurred in creating your Working Group!"); } } } catch (Exception $e) { diff --git a/Model/GrouperGroup.php b/Model/GrouperGroup.php index 4352b22..d5ebae4 100644 --- a/Model/GrouperGroup.php +++ b/Model/GrouperGroup.php @@ -63,12 +63,6 @@ class GrouperGroup extends GrouperLiteAppModel //Stem for email groups, only email groups using this stem are viewable private $emailStem = 'app:sympa'; - // Current listing of stems that are allowed to be viewed in Comanage as AdHoc groups - private $stemsAdHocAllowed = array( - 'app', - 'org', - 'ref' - ); /** * Verifies if user is an owner/admin of a group and then stores results in Session. @@ -809,8 +803,7 @@ private function getFriendlyWorkingGroupName(array $groups, $method) { } } - $filteredGroups = $this->verifyAdHocStem(array_values($groups)); - $friendlyGroups = $this->getFriendlyName($filteredGroups); + $friendlyGroups = $this->getFriendlyName(array_values($groups)); //Now need to add the groups back together for one set foreach ($friendlyGroups as $friendlyGroup) { @@ -820,33 +813,6 @@ private function getFriendlyWorkingGroupName(array $groups, $method) { return $finalWorkingGroups; } - /** - * Verify that the AdHoc groups are only coming from stems listed in $stemsAdHocAllowed - * - * @param array $groups Array of Ad Hoc groups - * @return array Ad Hoc groups that are coming from approved stems - * - */ - private function verifyAdHocStem(array $groups) { - - foreach ($groups as $key => $value) { - $legit = true; - foreach ($this->stemsAdHocAllowed as $legitStem) { - $len = strlen($legitStem); - if (substr(strtolower($value['name']), 0, $len) === $legitStem) { - $legit = true; - break; - } else { - $legit = false; - } - } - if (!$legit) { - unset($groups[$key]); - } - } - - return $groups; - } /** * Determine if result set contains friendly name, if so add as a new attribute in result set