Skip to content

Commit

Permalink
Merge branch 'develop' of bitbucket.org:unicon/comanagework into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Oct 27, 2021
2 parents e0a7f4f + b8a5e9e commit bad48da
Show file tree
Hide file tree
Showing 8 changed files with 346 additions and 301 deletions.
119 changes: 34 additions & 85 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,81 +97,20 @@ private function setConnection() {
}

/**
* No true Index page, so sent to default page of Optin
* No true Index page, so sent to default page of My Membership
*
* @return CakeResponse Redirect to Optin page
* @return CakeResponse Redirect to MyMembership page
*/
public function index() {
return $this->redirect(
array('controller' => 'grouper_groups', 'action' => 'groupoptin')
array('controller' => 'grouper_groups', 'action' => 'groupmember')
);
}

/**
* Display of Grouper Group Information, such as Group Properties, Members and Attributes
*
*/
public function groupInfo() {
$name = urldecode($this->request->query['groupname']);

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

$this->set('title', _txt('pl.grouperlite.title.groupinfo'));

try {
$details = $this->GrouperGroup->groupDescriptions($name);
$this->set('groupergroupsdetail', $details[0]);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));

$this->set('groupergroupsdetail', array());
$this->Flash->set(_txt('pl.grouperlite.message.flash.info-group-failed'), array('key' => 'error'));
}

try {
$groupMembers = $this->membersInGroup();
$this->set('groupergroupssubscribers', $groupMembers);
} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));

$this->set('groupergroupssubscribers', array());
$this->Flash->set(_txt('pl.grouperlite.message.flash.group-detail-members-failed'), array('key' => 'error'));
}

$this->set('grouperbaseurl', $this->Session->read('Plugin.Grouper.Api.grouperUrl'));
}

/**
* Show all members of group in Grouper Group detail page
* Called from method GroupInfo
*
*/
public function membersInGroup() {
$groupName = urldecode($this->request->query['groupname']);

//Set initial
$scope = [
'groupName' => $groupName
];

$details = [];

try {
$details = $this->GrouperGroup->membersInGroup($scope);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));

$this->Flash->set(_txt('pl.grouperlite.message.flash.group-detail-members-failed'), array('key' => 'error'));
}

return $details;
}

/**
* Show all members of group in Grouper Group detail page
* Called from method GroupInfo
* Show all members of a group
* Called from all pages via AJAX call
*
*/
public function groupSubscribers() {
Expand All @@ -194,7 +133,7 @@ public function groupSubscribers() {
];

try {
$subscribers = $this->GrouperGroup->membersInGroup($scope);
$subscribers = $this->GrouperGroup->membersInGroup($scope, $this->userId);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
Expand Down Expand Up @@ -411,20 +350,27 @@ public function groupOptin() {
*/
public function groupCreateTemplate() {
if ($this->request->is('post')) {
if (!$this->GrouperGroup->createGroupWithTemplate($this->userId, $this->request->data)) {
$this->Flash->set("Error in creating group!", array('key' => 'error'));
return $this->redirect(array('action' => 'groupoptin'));
} else {
$this->Flash->set("Success in creating group!", array('key' => 'success'));
return $this->redirect(array('action' => 'groupoptin'));
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'));
}
}
$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 @@ -435,33 +381,40 @@ public function groupDeleteTemplate() {
$this->set('title', _txt('pl.grouperlite.title.templatecreate'));
}


/**
* @deprecated
* NOT USED IN CODE
*
* @return CakeResponse|void|null
*/
public function groupCreate() {
if ($this->request->is('post')) {
if (!$this->GrouperGroup->createUpdateGroup($this->userId, $this->request->data)) {
$this->Flash->set("Error in creating group!", array('key' => 'error'));
return $this->redirect(array('action' => 'groupOwner'));
} else {
$this->Flash->set("Your Group has been created!", array('key' => 'success'));
return $this->redirect(array('action' => 'groupOwner'));
}
return $this->redirect(array('action' => 'groupOwner'));
}

$this->set('title', _txt('pl.grouperlite.title.groupcreate'));
$this->set('grouperstems', $this->GrouperGroup->getOwnedStems($this->userId));
}

//TODO - Finish this call

/**
* This method is currently not used.
* @return CakeResponse|null
*/
public function groupDelete() {
if (!$this->GrouperGroup->deleteGroup($this->userId, $this->request->data)) {
$this->Flash->set("Error in deleting group!", array('key' => 'error'));
return $this->redirect(array('action' => 'groupOwner'));
} else {
$this->Flash->set("Your Group has been deleted!", array('key' => 'success'));
return $this->redirect(array('action' => 'groupOwner'));
}

$this->set('grouperstems', $this->GrouperGroup->getOwnedStems($this->userId));
return $this->redirect(array('action' => 'groupOwner'));
}


Expand All @@ -484,7 +437,6 @@ public function joinGroup() {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
$this->Flash->set(_txt('pl.grouperlite.message.flash.join-group-error'), array('key' => 'error'));
}

} else {
$this->Flash->set(_txt('pl.grouperlite.message.flash.join-group-error'));
}
Expand Down Expand Up @@ -752,11 +704,10 @@ private function breakoutGroups(array $recordSet, $type = 'basic') {
$wgRec['workingDesc'] = $this->hackDescription($rec['description']);
//Capturing record for incommon-collab since deleting a few lines below.
if ($rec['WGApp'] == 'incommon-collab') {
$recToDelete = $subCount;
if ($type == 'basic') {
//Removing record with stem of 'incommon-collab' since displaying on groups Member page,
// will show on Admin page
unset($wgRec['Groups'][$recToDelete]);
unset($wgRec['Groups'][$subCount]);
}
}
$subCount += 1;
Expand Down Expand Up @@ -787,14 +738,12 @@ private function breakoutGroups(array $recordSet, $type = 'basic') {
*
*/
private function hackDescription($description) {

//Verify description has period in it.
if (strpos($description, ".") === false) {
return $description;
}

$newString = substr($description, strpos($description, ".") + 1);
return trim($newString);

}
}
Loading

0 comments on commit bad48da

Please sign in to comment.