diff --git a/Config/Schema/empty b/Config/Schema/empty deleted file mode 100644 index e69de29..0000000 diff --git a/Controller/GrouperGroupsController.php b/Controller/GrouperGroupsController.php index 03f0146..dcaf0a6 100644 --- a/Controller/GrouperGroupsController.php +++ b/Controller/GrouperGroupsController.php @@ -38,7 +38,15 @@ class GrouperGroupsController extends GrouperLiteAppController { public $helpers = array('Html', 'Form', 'Flash'); - public $uses = array('GrouperLite.GrouperGroup', 'CoPerson'); + + // Dynamic properties are deprecated so we will define the property here + protected $userId = null; + + public $uses = array( + 'GrouperLite.GrouperGroup', + 'GrouperLite.CoGrouperLite', + 'CoPerson'); + public $components = array('Flash', 'Paginator', 'RequestHandler', 'Security' => array( 'validatePost' => false, 'csrfUseOnce' => false @@ -66,7 +74,7 @@ public function beforeFilter() 'groupOwner' ); - //Need to find which plugin instance choosing, if more than one from cm_co_grouper_lites + // Need to find which plugin instance choosing, if more than one from cm_co_grouper_lites // table being used in COmanage. $grouperConnData = $this->Session->read('Plugin.Grouper.Api'); if ($this->Session->check('Plugin.Grouper.Api.id') && count($grouperConnData) == 10) { @@ -86,7 +94,7 @@ public function beforeFilter() //Also check for CO of Organization if (!$this->Session->check('Plugin.Grouper.Api.co')) { - $this->Session->write('Plugin.Grouper.Api.co', $this->passedArgs['co']); + $this->Session->write('Plugin.Grouper.Api.co', $this->cur_co['Co']['id']); } } @@ -96,7 +104,7 @@ public function beforeFilter() private function setConnection() { $this->Session->write('Plugin.Grouper.Api.id', $this->passedArgs['glid']); - $this->Session->write('Plugin.Grouper.Api.co', $this->passedArgs['co']); + $this->Session->write('Plugin.Grouper.Api.co', $this->cur_co['Co']['id']); //Now get the setup Dasboard instance from db for connection info. $getConnInfo = new CoGrouperLite(); @@ -112,19 +120,24 @@ private function setConnection() $this->Session->write('Plugin.Grouper.Api.defaultCollapse', $connectionInfo['CoGrouperLite']['default_collapse']); } + /** + * @param $page + * + * @return array + */ private function getConfig($page = 'groupmember') { $this->set('title', _txt('pl.grouperlite.title.groupmember')); $config = [ "grouperbaseurl" => $this->Session->read('Plugin.Grouper.Api.grouperUrl'), - "isuserowner" => $this->GrouperGroup->isUserOwner($this->userId), - "isTemplateUser" => $this->GrouperGroup->isTemplateUser($this->userId), - "isGrouperVisible" => $this->GrouperGroup->isGrouperVisible($this->userId), + "isuserowner" => $this->GrouperGroup->isUserOwner($this->userId ?? ""), + "isTemplateUser" => $this->GrouperGroup->isTemplateUser($this->userId ?? ""), + "isGrouperVisible" => $this->GrouperGroup->isGrouperVisible($this->userId ?? ""), "defaultCollapse" => CakeSession::read('Plugin.Grouper.Api.defaultCollapse'), "adHocHeading" => CakeSession::read('Plugin.Grouper.Api.adHocHeading'), "wgHeading" => CakeSession::read('Plugin.Grouper.Api.wgHeading'), - 'co' => CakeSession::read('Plugin.Grouper.Api.co'), + 'co' => $this->cur_co['Co']['id'], 'glid' => $this->Session->read('Plugin.Grouper.Api.id'), 'view' => $page ]; @@ -142,18 +155,27 @@ public function index() $this->set('config', $this->getConfig('groupmember')); } + /** + * @return void + */ public function groupMember() { $this->set('config', $this->getConfig('groupmember')); $this->render('index'); } + /** + * @return void + */ public function groupOptin() { $this->set('config', $this->getConfig('groupoptin')); $this->render('index'); } + /** + * @return void + */ public function groupOwner() { $this->set('config', $this->getConfig('groupowner')); @@ -282,7 +304,6 @@ public function findSubscriber() $this->response->disableCache(); } - // $groupName = urldecode($this->request->query['group']); $findUserId = urldecode($this->request->query['term']); $co = urldecode($this->request->query['co']); @@ -744,44 +765,23 @@ function isAuthorized() { $roles = $this->Role->calculateCMRoles(); - /** - * The following code displays a few custom implementations of the - * login process used to crosswalk a user for Grouper authentication. - * - * You may need to further customize this section to meet your organization - * crosswalk needs. - */ - - /** - * Default when login-id is the same as grouper id - */ - // Default Begin =============================================== - - /* - if ($this->Session->check('Auth.User.username')) { - $this->userId = $this->Session->read('Auth.User.username'); - } - */ - // Default End =============================================== - - /** - * Customized Crosswalk from login-id to Grouper Username - */ - // Custom Begin =============================================== - - $username = $this->Session->read('Auth.User.username'); + // Find the identifier + $args = array(); + // XXX This should become configuration + $args['conditions']['Identifier.type'] = 'I2CollabPN'; + $args['conditions']['Identifier.status'] = SuspendableStatusEnum::Active; + $args['conditions']['Identifier.co_person_id'] = $roles["copersonid"]; + $args['contain'] = false; - if ($this->Session->check('Plugin.Grouper.UserId')) { - $this->userId = $this->Session->read('Plugin.Grouper.UserId'); - } else { - $uid = $this->getPersonIdFromUsername($username); - $this->userId = $this->getUserId($uid); - $this->Session->write('Plugin.Grouper.UserId', $this->userId); + $Identifier = ClassRegistry::init('Identifier'); + $identifiers = $Identifier->find('first', $args); + if(!empty($identifiers) + && is_array($identifiers) + && isset($identifiers["Identifier"]["identifier"]) + ) { + $this->userId = $identifiers["Identifier"]["identifier"]; } - // Custom End =============================================== - - // Determine what operations this user can perform // Construct the permission set for this user, which will also be passed to the view. //Note: Leaving in current format, in case need to restrict certain pages, can just remove true and add params. @@ -810,37 +810,6 @@ function isAuthorized() return ($p[$this->action]); } - private function getPersonIdFromUsername($username) - { - $args = array(); - $args['conditions']['Identifier.identifier'] = $username; - $args['conditions']['Identifier.status'] = SuspendableStatusEnum::Active; - $args['conditions']['Identifier.deleted'] = false; - $args['conditions']['Identifier.identifier_id'] = null; - $args['conditions']['NOT']['Identifier.co_person_id'] = null; - $args['conditions']['Identifier.type'] = 'eppn'; - $args['contain'] = false; - - $Identifier = new Identifier(); - $co_person_id = $Identifier->find('first', $args); - - return $co_person_id['Identifier']['co_person_id']; - } - - private function getUserId($id) - { - $args = array(); - $args['conditions']['Identifier.co_person_id'] = $id; - $args['conditions']['Identifier.type'] = 'I2CollabPN'; - $args['conditions']['Identifier.status'] = SuspendableStatusEnum::Active; - $args['contain'] = false; - - $Identifier = new Identifier(); - $grouper_identifier = $Identifier->find('first', $args); - - return $grouper_identifier['Identifier']['identifier']; - } - /** * Breakout Working Groups from AdHoc Groups for display purposes in UI. * @@ -869,5 +838,36 @@ private function breakoutGroups(array $recordSet, $type = 'basic') ); } + /** + * Override the default sanity check performed in AppController + * + * @since COmanage Registry v4.3.0 + * @return Boolean True if sanity check is successful + */ + + public function verifyRequestedId() { + return true; + } + + + /** + * For Models that accept a CO ID, find the provided CO ID. + * - precondition: A coid must be provided in $this->request (params or data) + * + * @since COmanage Registry v4.3.0 + * @return Integer The CO ID if found, or -1 if not + */ + + public function parseCOID($data = null) { + $connectionInfo = $this->CoGrouperLite->findById($this->passedArgs['glid']); + $this->CoGrouperLite->CoDashboardWidget->CoDashboard->id = $connectionInfo["CoDashboardWidget"]["co_dashboard_id"]; + $co_id = $this->CoGrouperLite->CoDashboardWidget->CoDashboard->field('co_id'); + + if(!empty($co_id)) { + return $co_id; + } + + return -1; + } } \ No newline at end of file diff --git a/View/CoGrouperLites/display.ctp b/View/CoGrouperLites/display.ctp index 480ee25..776aeea 100644 --- a/View/CoGrouperLites/display.ctp +++ b/View/CoGrouperLites/display.ctp @@ -33,9 +33,6 @@ $divid = $vv_config['CoGrouperLite']['co_dashboard_widget_id']; -// $coid = $config['co']; -// $glid = $config['glid']; - $this->extend('/GrouperGroups/base'); echo $this->element('GrouperLite.base-styles');