Skip to content

Commit

Permalink
Merged feature/ICPCO-116 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Mar 25, 2021
2 parents 2b2abc2 + ccf5534 commit 7e19b58
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 20 deletions.
59 changes: 44 additions & 15 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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
Expand Down
26 changes: 26 additions & 0 deletions Model/GrouperGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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.
*
Expand Down
13 changes: 8 additions & 5 deletions View/GrouperGroups/emaillistsmember.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</tr>
</thead>
<tbody>
<?php foreach ($emailgroups as $group) : ?>
<tr>
<td><?php echo $this->Html->link(
isset($group['name']) ? $group['domain'].':'.$group['name'] : "No Name",
Expand All @@ -23,13 +24,15 @@
)
) ?></td>
<td><?php echo isset($group['description']) ? $group['description'] : _txt('pl.grouperlite.value.descr.zerostate'); ?></td>
<td class="text-center">
<button class="btn btn-raised btn-danger" type="submit">
<?php echo _txt('pl.grouperlite.action.leave') ?>
<i class="fa fa-<?php echo $member ? 'user-times' : 'users'; ?> fa-sm"></i>
</button>
<td>
<?php echo $group['optedin'] ? $this->element('GrouperLite.Components/optAction', array(
'member' => $group['optedin'],
'action' => 'leavegroup',
'group' => $group['name']
)) : ''; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
2 changes: 2 additions & 0 deletions View/GrouperGroups/emaillistsoptin.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</tr>
</thead>
<tbody>
<?php foreach ($emailgroups as $group) : ?>
<tr>
<td><?php echo $this->Html->link(
isset($group['name']) ? $group['domain'] . ':' . $group['name'] : "No Name",
Expand All @@ -30,6 +31,7 @@
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>

0 comments on commit 7e19b58

Please sign in to comment.