Skip to content

Commit

Permalink
remove filtering ad-hoc, fix WG error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Oct 27, 2021
1 parent 1f5397c commit b8a5e9e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 43 deletions.
24 changes: 16 additions & 8 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -375,7 +382,8 @@ public function groupDeleteTemplate() {
}

/**
* This method is currently not used.
* @deprecated
* NOT USED IN CODE
*
* @return CakeResponse|void|null
*/
Expand Down
2 changes: 2 additions & 0 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
36 changes: 1 addition & 35 deletions Model/GrouperGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit b8a5e9e

Please sign in to comment.