diff --git a/Controller/GrouperGroupsController.php b/Controller/GrouperGroupsController.php index 5e2a01c..b608308 100644 --- a/Controller/GrouperGroupsController.php +++ b/Controller/GrouperGroupsController.php @@ -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) { @@ -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']); } } @@ -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 diff --git a/Model/GrouperGroup.php b/Model/GrouperGroup.php index e1be79f..acf55b4 100644 --- a/Model/GrouperGroup.php +++ b/Model/GrouperGroup.php @@ -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', @@ -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 @@ -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; } diff --git a/View/GrouperGroups/groupmember.ctp b/View/GrouperGroups/groupmember.ctp index 0ec2394..5afee13 100644 --- a/View/GrouperGroups/groupmember.ctp +++ b/View/GrouperGroups/groupmember.ctp @@ -66,12 +66,15 @@ $numColumns = count($columns); - + + + + element('GrouperLite.Components/optAction', array( 'member' => $wggroup['optOut'], diff --git a/View/GrouperGroups/groupoptin.ctp b/View/GrouperGroups/groupoptin.ctp index 376feee..2b29502 100644 --- a/View/GrouperGroups/groupoptin.ctp +++ b/View/GrouperGroups/groupoptin.ctp @@ -67,12 +67,15 @@ $numColumns = count($columns); $wgoptin) : ?> - + + + + element('GrouperLite.Components/optAction', array( 'member' => $wgoptin['member'],