diff --git a/Controller/GrouperGroupsController.php b/Controller/GrouperGroupsController.php index e28a23b..69fc296 100644 --- a/Controller/GrouperGroupsController.php +++ b/Controller/GrouperGroupsController.php @@ -497,13 +497,27 @@ function isAuthorized() { public function emaillistsOptin() { $this->set('title', _txt('pl.grouperlite.title.emaillists-join')); - // mock data - $this->set('group', array( - 'member' => true, - 'name' => 'Email List 1', - 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', - 'enabled' => 'T' - )); + + //Set initial settings for pagination + $scope = [ + 'userId' => $this->userId, + 'page' => (isset($this->passedArgs['page']) ? $this->passedArgs['page']: $this->paginate['page']), + 'limit' => (isset($this->passedArgs['limit']) ? $this->passedArgs['limit']: $this->paginate['limit']), + ]; + + try { + //Add settings for optinEmailLists + $scope['method'] = 'optinEmailGroups'; + + $data = $this->Paginator->paginate('GrouperGroup', $scope); + $this->set('emailgroups', $data); + + } catch (Exception $e) { + CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true)); + $this->Flash->set("An error occurred with the Optin Groups, please try again later.", array('key' => 'error')); + $this->set('emailgroups', array()); + return; + } $this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId)); $this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId)); @@ -512,19 +526,34 @@ public function emaillistsOptin() { public function emaillistsMember() { $this->set('title', _txt('pl.grouperlite.title.emaillists-member')); - // mock data - $this->set('group', array( - 'member' => true, - 'name' => 'Email List 1', - 'domain' => 'internet2', - 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', - 'enabled' => 'T' - )); + + //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']), + ]; + + try { + //Add setting for Group Membership + $scope['method'] = 'filteredMemberOfEmails'; + + $data = $this->Paginator->paginate('GrouperGroup', $scope); + $this->set('emailgroups', $data); + + } catch (Exception $e) { + CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true)); + + $this->Flash->set("Your Member Group cannot be found, please try again later.", array('key' => 'error')); + $this->set('emailgroups', array()); + return; + } $this->set('isuserowner', $this->GrouperGroup->isUserOwner($this->userId)); $this->set('isTemplateUser', $this->GrouperGroup->isTemplateUser($this->userId)); } + public function emaillistsManage() { $this->set('title', _txt('pl.grouperlite.title.emaillists-manage')); // mock data diff --git a/Model/GrouperGroup.php b/Model/GrouperGroup.php index e4f5995..89bf151 100644 --- a/Model/GrouperGroup.php +++ b/Model/GrouperGroup.php @@ -138,6 +138,19 @@ public function filteredMemberOfGroups(array $conditions) { } } + public function filteredMemberOfEmails(array $conditions) { + $memberOfEmails = $this->filteredMemberOfGroups($conditions); + + // Strip out all Groups that are not in Sympa Stem/Directory + foreach($memberOfEmails as $key => $value){ + if(strpos($value['name'], 'sympa') === false) { + unset($memberOfEmails[$key]); + } + } + + return $memberOfEmails; + } + /** * Internal process used by other functions to fetch Groups the User is a member of * @@ -362,6 +375,19 @@ public function optinGroups(array $conditions) { } } + public function optinEmailGroups(array $conditions) { + $allGroups = $this->optinGroups($conditions); + + // Strip out all Groups that are not in Sympa Stem/Directory + foreach($allGroups as $key => $value){ + if(strpos($value['name'], 'sympa') === false) { + unset($allGroups[$key]); + } + } + + return $allGroups; + } + /** * Determine if User can use the Grouper Template to create a suite of Groups including Email lists. * diff --git a/View/GrouperGroups/emaillistsmember.ctp b/View/GrouperGroups/emaillistsmember.ctp index d678648..ed1264a 100644 --- a/View/GrouperGroups/emaillistsmember.ctp +++ b/View/GrouperGroups/emaillistsmember.ctp @@ -13,6 +13,7 @@
+