diff --git a/Controller/CoGrouperLitesController.php b/Controller/CoGrouperLitesController.php index 57b143a..ccbaa42 100644 --- a/Controller/CoGrouperLitesController.php +++ b/Controller/CoGrouperLitesController.php @@ -31,7 +31,7 @@ public function display($id) { $this->set('pl_grouperlite_index_url', Router::url([ 'plugin' => "grouper_lite", - 'controller' => 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'index', 'co' => $this->cur_co['Co']['id'], 'glid' => $id diff --git a/Controller/GrouperGroupsController.php b/Controller/GrouperGroupsController.php index 69fc296..b9cd4dd 100644 --- a/Controller/GrouperGroupsController.php +++ b/Controller/GrouperGroupsController.php @@ -102,7 +102,7 @@ private function setConnection() { */ public function index() { return $this->redirect( - array('controller' => 'GrouperGroups', 'action' => 'groupoptin') + array('controller' => 'grouper_groups', 'action' => 'groupoptin') ); } @@ -180,8 +180,8 @@ public function groupOwner() { //Set initial settings for pagination $scope = [ 'userId' => $this->userId, - 'page' => ($this->passedArgs['page'] ? $this->passedArgs['page']: $this->paginate['page']), - 'limit' => ($this->passedArgs['limit'] ? $this->passedArgs['limit']: $this->paginate['limit']), + 'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']), + 'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']), ]; if (isset($this->request->data['search'])) { @@ -235,8 +235,8 @@ public function groupMember() { //Set initial settings for pagination $scope = [ 'userId' => $this->userId, - 'page' => ($this->passedArgs['page'] ? $this->passedArgs['page']: $this->paginate['page']), - 'limit' => ($this->passedArgs['limit'] ? $this->passedArgs['limit']: $this->paginate['limit']), + 'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']), + 'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']), ]; if (isset($this->request->data['search'])) { @@ -463,9 +463,17 @@ public function leaveGroup() { function isAuthorized() { $roles = $this->Role->calculateCMRoles(); - //Need to pull in UserID for access to Grouper + //This call just pulls in user ID from comanage but not Grouper, need the Grouper Id for API calls. + /* if ($this->Session->check('Auth.User.username')) { $this->userId = $this->Session->read('Auth.User.username'); + }*/ + + if ($this->Session->check('Plugin.Grouper.UserId')) { + $this->userId = $this->Session->read('Plugin.Grouper.UserId'); + } else { + $this->userId = $this->GrouperGroup->getGrouperUserId(); + $this->Session->write('Plugin.Grouper.UserId', $this->userId); } // Determine what operations this user can perform @@ -530,8 +538,8 @@ public function emaillistsMember() //Set initial settings for pagination $scope = [ 'userId' => $this->userId, - 'page' => ($this->passedArgs['page'] ? $this->passedArgs['page']: $this->paginate['page']), - 'limit' => ($this->passedArgs['limit'] ? $this->passedArgs['limit']: $this->paginate['limit']), + 'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']), + 'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']), ]; try { diff --git a/Lib/GrouperApiAccess.php b/Lib/GrouperApiAccess.php index bea20de..1d7a845 100644 --- a/Lib/GrouperApiAccess.php +++ b/Lib/GrouperApiAccess.php @@ -71,16 +71,13 @@ public function __construct() { } /** - * NOT BEING USED * Get User information from Grouper Web Service * - * @param array $queryData Array of conditions for querying - * @return array + * @return String User ID in Grouper Groups * @throws Exception */ - public function getGrouperUser(array $queryData) { + public function getGrouperUserId() { - $userId = $queryData['userId']; $this->http->setHeader(array('Content-Type' => 'application/json', 'Accept' => 'application/json')); // Create attributes want returned from call to Grouper WS @@ -94,7 +91,7 @@ public function getGrouperUser(array $queryData) { 'givenname' ), 'wsSubjectLookups' => array( - array('subjectIdentifier' => $userId) + array('subjectIdentifier' => $_SERVER['REMOTE_USER']) ) ) ); @@ -114,7 +111,7 @@ public function getGrouperUser(array $queryData) { throw $e; } - return array(); + return ''; } /** diff --git a/Model/GrouperGroup.php b/Model/GrouperGroup.php index 89bf151..bf12999 100644 --- a/Model/GrouperGroup.php +++ b/Model/GrouperGroup.php @@ -100,6 +100,24 @@ private function initApi() { } } + /** + * Gets the users Id from Grouper since can be different than what is in Comanage. + * + * @return String User's Id in Grouper + * @throws Exception + */ + public function getGrouperUserId() { + $this->initApi(); + + try { + return $this->grouperAPI->getGrouperUserId(); + + } catch (Exception $e) { + CakeLog::write('error', __METHOD__ . ': An error occurred'); + throw $e; + } + } + /** * Return all Groups that a User belongs to in Grouper. * Will also add Optin Groups and flag them as joined so can display Optout option in UI. diff --git a/View/CoGrouperLites/display.ctp b/View/CoGrouperLites/display.ctp index 6d1e03e..a862e21 100644 --- a/View/CoGrouperLites/display.ctp +++ b/View/CoGrouperLites/display.ctp @@ -53,7 +53,7 @@ echo $this->element('GrouperLite.base-styles'); 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'groupoptin', 'co' => $coid, 'glid' => $glid @@ -64,7 +64,7 @@ echo $this->element('GrouperLite.base-styles'); 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'groupmember', 'co' => $coid, 'glid' => $glid @@ -76,7 +76,7 @@ echo $this->element('GrouperLite.base-styles'); 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'groupowner', 'co' => $coid, 'glid' => $glid @@ -93,7 +93,7 @@ echo $this->element('GrouperLite.base-styles'); 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistsoptin', 'co' => $coid, 'glid' => $glid @@ -104,7 +104,7 @@ echo $this->element('GrouperLite.base-styles'); 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistsMember', 'co' => $coid, 'glid' => $glid @@ -116,7 +116,7 @@ echo $this->element('GrouperLite.base-styles'); 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistsManage', 'co' => $coid, 'glid' => $glid diff --git a/View/Elements/Components/navigation-emaillists.ctp b/View/Elements/Components/navigation-emaillists.ctp index 7597315..60b3856 100644 --- a/View/Elements/Components/navigation-emaillists.ctp +++ b/View/Elements/Components/navigation-emaillists.ctp @@ -5,7 +5,7 @@ print $this->Html->link( _txt('pl.grouperlite.nav.emaillists-join'), array( - 'controller' => 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistsoptin' ), array('class' => array('nav-link', $active == 'emaillistsoptin' ? 'active' : '')) @@ -17,7 +17,7 @@ print $this->Html->link( _txt('pl.grouperlite.nav.emaillists-member'), array( - 'controller' => 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistsmember' ), array('class' => array('nav-link', $active == 'emaillistsmember' ? 'active' : '')) @@ -29,7 +29,7 @@ print $this->Html->link( _txt('pl.grouperlite.nav.emaillists-manage'), array( - 'controller' => 'GrouperGroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistsmanage' ), array('class' => array('nav-link', $active == 'emaillistsmanage' ? 'active' : '')) @@ -42,7 +42,7 @@ Html->url( array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'groupcreatetemplateform' ) ); @@ -56,7 +56,7 @@ Html->url( array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'groupoptin' ) ); diff --git a/View/Elements/Components/navigation-groups.ctp b/View/Elements/Components/navigation-groups.ctp index 636e6c4..d28751b 100644 --- a/View/Elements/Components/navigation-groups.ctp +++ b/View/Elements/Components/navigation-groups.ctp @@ -5,7 +5,7 @@ print $this->Html->link( _txt('pl.grouperlite.nav.groups-can-join'), array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'groupoptin' ), array('class' => array('nav-link', $active == 'groupoptin' ? 'active' : '')) @@ -17,7 +17,7 @@ print $this->Html->link( _txt('pl.grouperlite.nav.memberships'), array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'groupmember' ), array('class' => array('nav-link', $active == 'groupmember' ? 'active' : '')) @@ -29,7 +29,7 @@ print $this->Html->link( _txt('pl.grouperlite.nav.groups-presided'), array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'groupowner' ), array('class' => array('nav-link', $active == 'groupowner' ? 'active' : '')) @@ -42,7 +42,7 @@ Html->url( array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'groupcreateform' ) ); @@ -56,7 +56,7 @@ Html->url( array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistsoptin' ) ); diff --git a/View/Elements/Components/optAction.ctp b/View/Elements/Components/optAction.ctp index 2928dca..6ac08f5 100644 --- a/View/Elements/Components/optAction.ctp +++ b/View/Elements/Components/optAction.ctp @@ -1,5 +1,5 @@ Form->create(false, array( - 'url' => array('controller' => 'groupergroups', 'action' => $action), + 'url' => array('controller' => 'grouper_groups', 'action' => $action), 'class' => 'd-flex justify-content-center' )); ?> Form->hidden('GroupName', array('default' => $group)); ?> diff --git a/View/Elements/Components/search.ctp b/View/Elements/Components/search.ctp index ca42a44..8e7a0e6 100644 --- a/View/Elements/Components/search.ctp +++ b/View/Elements/Components/search.ctp @@ -16,7 +16,7 @@ }); Form->create(false, array( - 'url' => array('controller' => 'groupergroups', 'action' => $active), + 'url' => array('controller' => 'grouper_groups', 'action' => $active), 'class' => 'search mb-4' )); ?>
diff --git a/View/GrouperGroups/base.ctp b/View/GrouperGroups/base.ctp index 6b393b3..54aaf95 100644 --- a/View/GrouperGroups/base.ctp +++ b/View/GrouperGroups/base.ctp @@ -6,7 +6,7 @@ print $this->Html->css('GrouperLite.co-grouper-plugin') . "\n "; Html->script('GrouperLite.typeahead.bundle.js') . "\n "; -$this->Html->addCrumb(_txt('pl.grouperlite.crumb.root'), array('controller' => 'groupergroups', 'action' => 'groupoptin'), array('prepend' => true)); +$this->Html->addCrumb(_txt('pl.grouperlite.crumb.root'), array('controller' => 'grouper_groups', 'action' => 'groupoptin'), array('prepend' => true)); ?>
diff --git a/View/GrouperGroups/emaillistsmanage.ctp b/View/GrouperGroups/emaillistsmanage.ctp index 3c3c41c..d783ae9 100644 --- a/View/GrouperGroups/emaillistsmanage.ctp +++ b/View/GrouperGroups/emaillistsmanage.ctp @@ -18,7 +18,7 @@ Html->link( isset($group['name']) ? $group['domain'] . ':' . $group['name'] : "--", array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistinfo', '?' => array('groupname' => urlencode($group['name'])) ) diff --git a/View/GrouperGroups/emaillistsmember.ctp b/View/GrouperGroups/emaillistsmember.ctp index ed1264a..45d17c5 100644 --- a/View/GrouperGroups/emaillistsmember.ctp +++ b/View/GrouperGroups/emaillistsmember.ctp @@ -18,7 +18,7 @@ Html->link( isset($group['name']) ? $group['domain'].':'.$group['name'] : "No Name", array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistinfo', '?' => array('groupname' => urlencode($group['name'])) ) diff --git a/View/GrouperGroups/emaillistsoptin.ctp b/View/GrouperGroups/emaillistsoptin.ctp index a980633..d049a5d 100644 --- a/View/GrouperGroups/emaillistsoptin.ctp +++ b/View/GrouperGroups/emaillistsoptin.ctp @@ -18,7 +18,7 @@ Html->link( isset($group['name']) ? $group['domain'] . ':' . $group['name'] : "No Name", array( - 'controller' => 'groupergroups', + 'controller' => 'grouper_groups', 'action' => 'emaillistinfo', '?' => array('groupname' => urlencode($group['name'])) ) diff --git a/View/GrouperGroups/groupcreate.ctp b/View/GrouperGroups/groupcreate.ctp index c3bf238..df9058c 100644 --- a/View/GrouperGroups/groupcreate.ctp +++ b/View/GrouperGroups/groupcreate.ctp @@ -15,7 +15,7 @@ $model = $this->name; Form->create(false, array( - 'url' => array('controller' => 'groupergroups', 'action' => 'groupcreate') + 'url' => array('controller' => 'grouper_groups', 'action' => 'groupcreate') )); ?> plugin)) { diff --git a/View/GrouperGroups/groupcreatetemplate.ctp b/View/GrouperGroups/groupcreatetemplate.ctp index c7db590..f5b9bd9 100644 --- a/View/GrouperGroups/groupcreatetemplate.ctp +++ b/View/GrouperGroups/groupcreatetemplate.ctp @@ -10,7 +10,7 @@ $model = $this->name;