Skip to content

Commit

Permalink
move description to WG level, remove incommon-collab group from view
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Jul 23, 2021
1 parent 9d46f36 commit b45189d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
32 changes: 31 additions & 1 deletion Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,12 @@ public function groupOwner() {
* Breakout Working Groups from AdHoc Groups for display purposes in UI.
*
* @param array $recordSet
* @param string $type
* @return array[]
*
*/
public function breakoutGroups(array $recordSet, $type='basic') {

//TODO - May move this logic down into the GrouperGroup model file, once all is agreed upon.
$wgData = array();
$notWGData = array();
foreach($recordSet as $record) {
Expand All @@ -254,16 +255,26 @@ public function breakoutGroups(array $recordSet, $type='basic') {
if ($type == 'basic') {
//Need to surface Optout flag to top level of a Working Group
foreach($wgData as &$wgRec) {
$subCount = 0;
foreach($wgRec['Groups'] as $rec){
if(isset($rec['optOut'])) {
$wgRec['optOut'] = true;
$wgRec['workingGroupId'] = $rec['name'];
$wgRec['workingDesc'] = $this->hackDescription($rec['description']);
}
//Capturing record for incommon-collab since deleting a few lines below.
if ($rec['WGApp'] == 'incommon-collab') {
$recToDelete = $subCount;
}
$subCount += 1;
}
//Removing record with name of incommon-collab since means nothing to the user.
unset($wgRec['Groups'][$recToDelete]);
}
} elseif ($type == 'optin') {
foreach($wgData as &$wgRec) {
$wgRec['workingGroupId'] = $wgRec['Groups'][0]['name'];
$wgRec['workingDesc'] = $this->hackDescription($wgRec['Groups'][0]['description']);
}
}

Expand All @@ -274,6 +285,25 @@ public function breakoutGroups(array $recordSet, $type='basic') {
);
}

/**
* Eliminating canned description added by Grouper on creation of a WG in Grouper
*
* @param $description
* @return string
*
*/
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);

}

/**
* 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
19 changes: 17 additions & 2 deletions Model/GrouperGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class GrouperGroup extends GrouperLiteAppModel
/** @var string Group whose members can create Groups via Template process*/
private $templateCreationGroup = 'ref:workinggroupadmins';

// Current listing of groups that are associated to Working Groups
private $stemsWorkingGroup = array(
'app:jira',
'app:confluence',
Expand Down Expand Up @@ -197,13 +198,27 @@ private function memberOfGroups(array $conditions) {
}
}


/**
* Return array of Working Groups for display on coManage site.
* Logic is for each WG to have one key=>value of main WG name, then array of all associated
* Groups.
*
* NOTE: This is a major hack due to Grouper not giving us the right logic for displaying, so have to run all
* groups through a mapped listing of types of Groups in a WG to see if match and then parse and massage to display
*
* @param array $groups Listing of Groups
* @return array Listing of Groups in WG format for display
*
*/
private function getFriendlyWorkingGroupName(array $groups) {

$arrayIndex = 0;

//Loop through groups to see if possibly part of a Working Group
foreach ($groups as &$group) {
foreach($this->stemsWorkingGroup as $stem) {
$len = strlen($stem);
// if match to name of group within WG mapping then start making a WG group array
if (substr(strtolower($group['name']), 0, $len) === $stem){
$stemSections = explode(':', $group['name']);
//Get second to last stem section
Expand Down Expand Up @@ -231,7 +246,7 @@ private function getFriendlyWorkingGroupName(array $groups) {
$appCount += 1;
}
$group['WGApp'] = $appName;
//TODO - FOR DISPLAY PURPOSE
//TODO - FOR DEMO PURPOSE THAT LEAVES OUT ADMIN GROUPS TO SHOW WHAT AVERAGE USER SEES
if ($group['WGRole'] !== 'admins' && $group['WGRole'] !== 'owners') {
$workingGroups[] = $group;
}
Expand Down
5 changes: 4 additions & 1 deletion View/GrouperGroups/groupmember.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ $numColumns = count($columns);
<tbody>
<?php foreach ($wgmemberships as $wggroup) : ?>
<tr>
<td colspan="<?php echo $numColumns - 1; ?>">
<td colspan="<?php echo $numColumns - 2; ?>">
<button type="button" class="btn btn-link btn-text collapse-btn h6 fw-bold m-0 collapsed" data-toggle="collapse" data-target=".collapse-wg-<?php echo $wggroup['WGName']; ?>" role="button" aria-expanded="false">
<?php echo $wggroup['WGName'] ?? "No Name"; ?>
<i class="fa fa-caret-down fa-sm"></i>
</button>
</td>
<td>
<?php echo $wggroup['workingDesc'] ?? " "; ?>
</td>
<td>
<?php echo $wggroup['optOut'] ? $this->element('GrouperLite.Components/optAction', array(
'member' => $wggroup['optOut'],
Expand Down
5 changes: 4 additions & 1 deletion View/GrouperGroups/groupoptin.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,15 @@ $numColumns = count($columns);
<tbody>
<?php foreach ($wgoptins as $i => $wgoptin) : ?>
<tr>
<td colspan="<?php echo $numColumns - 1; ?>">
<td colspan="<?php echo $numColumns - 2; ?>">
<button type="button" class="btn btn-link btn-text collapse-btn h6 fw-bold m-0 collapsed" data-toggle="collapse" data-target=".collapse-wg-<?php echo $wgoptin['WGName']; ?>" role="button" aria-expanded="false">
<?php echo $wgoptin['WGName'] ?? "No Name"; ?>
<i class="fa fa-caret-down fa-sm"></i>
</button>
</td>
<td>
<?php echo $wgoptin['workingDesc'] ?? " "; ?>
</td>
<td>
<?php echo $this->element('GrouperLite.Components/optAction', array(
'member' => $wgoptin['member'],
Expand Down

0 comments on commit b45189d

Please sign in to comment.