Skip to content

Commit

Permalink
changes for leave/join buttons at WG level
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Jul 16, 2021
1 parent 1db882d commit ce8b675
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 67 deletions.
126 changes: 60 additions & 66 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,10 @@ public function groupOwner() {

$data = $this->Paginator->paginate('GrouperGroup', $scope);

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}
$finalData = $this->breakoutGroups($data);

$this->set('groupsowners', $notWGData);
$this->set('wgowners', $wgData);
$this->set('groupsowners', $finalData['adHocGroups']);
$this->set('wgowners', $finalData['workingGroups']);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ' Search: ' . var_export($e->getMessage(), true));
Expand All @@ -221,18 +213,10 @@ public function groupOwner() {

$data = $this->Paginator->paginate('GrouperGroup', $scope);

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}
$finalData = $this->breakoutGroups($data);

$this->set('groupsowners', $notWGData);
$this->set('wgowners', $wgData);
$this->set('groupsowners', $finalData['adHocGroups']);
$this->set('wgowners', $finalData['workingGroups']);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
Expand All @@ -248,6 +232,48 @@ public function groupOwner() {
$this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId));
}

/**
* Breakout Working Groups from AdHoc Groups for display purposes in UI.
*
* @param array $recordSet
* @return array[]
*
*/
public function breakoutGroups(array $recordSet, $type='basic') {

$wgData = array();
$notWGData = array();
foreach($recordSet as $record) {
if(isset($record['WGName'])) {
$wgData[] = $record;
} else {
$notWGData[] = $record;
}
}

if ($type == 'basic') {
//Need to surface Optout flag to top level of a Working Group
foreach($wgData as &$wgRec) {
foreach($wgRec['Groups'] as $rec){
if(isset($rec['optOut'])) {
$wgRec['optOut'] = true;
$wgRec['workingGroupId'] = $rec['name'];
}
}
}
} elseif ($type == 'optin') {
foreach($wgData as &$wgRec) {
$wgRec['workingGroupId'] = $wgRec['Groups'][0]['name'];
}
}


return array(
'adHocGroups' => $notWGData,
'workingGroups' => $wgData
);
}

/**
* Returns all Groups that the User is a member of in Grouper
* This includes self-joined Optin Groups, as well as required Groups User cannot leave
Expand Down Expand Up @@ -275,18 +301,10 @@ public function groupMember() {

$data = $this->Paginator->paginate('GrouperGroup', $scope);

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}
$finalData = $this->breakoutGroups($data);

$this->set('groupmemberships', $notWGData);
$this->set('wgmemberships', $wgData);
$this->set('groupmemberships', $finalData['adHocGroups']);
$this->set('wgmemberships', $finalData['workingGroups']);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ' Search: ' . var_export($e->getMessage(), true));
Expand All @@ -303,18 +321,10 @@ public function groupMember() {

$data = $this->Paginator->paginate('GrouperGroup', $scope);

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}
$finalData = $this->breakoutGroups($data);

$this->set('groupmemberships', $notWGData);
$this->set('wgmemberships', $wgData);
$this->set('groupmemberships', $finalData['adHocGroups']);
$this->set('wgmemberships', $finalData['workingGroups']);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
Expand Down Expand Up @@ -355,18 +365,10 @@ public function groupOptin() {
$data = $this->Paginator->paginate('GrouperGroup', $scope);
//$this->set('groupoptin', $data);

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}
$finalData = $this->breakoutGroups($data, 'optin');

$this->set('groupoptins', $notWGData);
$this->set('wgoptins', $wgData);
$this->set('groupoptins', $finalData['adHocGroups']);
$this->set('wgoptins', $finalData['workingGroups']);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . 'Search: ' . var_export($e->getMessage(), true));
Expand All @@ -384,18 +386,10 @@ public function groupOptin() {
$data = $this->Paginator->paginate('GrouperGroup', $scope);
//$this->set('groupoptin', $data);

$wgData = array();
$notWGData = array();
foreach($data as $group) {
if(isset($group['WGName'])) {
$wgData[] = $group;
} else {
$notWGData[] = $group;
}
}
$finalData = $this->breakoutGroups($data,'optin');

$this->set('groupoptins', $notWGData);
$this->set('wgoptins', $wgData);
$this->set('groupoptins', $finalData['adHocGroups']);
$this->set('wgoptins', $finalData['workingGroups']);

} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
Expand Down
6 changes: 5 additions & 1 deletion Model/GrouperGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ private function getFriendlyWorkingGroupName(array $groups) {
$appCount += 1;
}
$group['WGApp'] = $appName;
$workingGroups[] = $group;
//TODO - FOR DISPLAY PURPOSE
if ($group['WGRole'] !== 'admins' && $group['WGRole'] !== 'owners') {
$workingGroups[] = $group;
}
//$workingGroups[] = $group;
unset($groups[$arrayIndex]);
}
}
Expand Down

0 comments on commit ce8b675

Please sign in to comment.