Skip to content

Commit

Permalink
Merged feature/ICPCO-67 and ICPCO-66 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
axel committed Jan 13, 2021
2 parents 8415e4e + 78234e9 commit a48f8b9
Show file tree
Hide file tree
Showing 26 changed files with 1,541 additions and 442 deletions.
48 changes: 48 additions & 0 deletions Config/Schema/schema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" ?>
<!--
COmanage Registry Notification Widget Plugin Database Schema
Portions licensed to the University Corporation for Advanced Internet
Development, Inc. ("UCAID") under one or more contributor license agreements.
See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
UCAID licenses this file to you under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
While this schema mostly works with database prefixes, foreign key constraints
must be specified in raw SQL, which needs the prefixed table name.
-->
<schema version="0.3">
<table name="co_grouper_lites">
<field name="id" type="I">
<key />
<autoincrement />
</field>
<field name="co_dashboard_widget_id" type="I">
<constraint>REFERENCES cm_co_dashboard_widgets(id)</constraint>
</field>
<field name="connUrl" type="C" size="256" />
<field name="connVer" type="C" size="256" />
<field name="connUser" type="C" size="64" />
<field name="connPass" type="C" size="64" />
<field name="created" type="T" />
<field name="modified" type="T" />

<index name="co_grouper_lites_i1">
<col>co_dashboard_widget_id</col>
<unique />
</index>
</table>
</schema>
62 changes: 61 additions & 1 deletion Controller/CoGrouperLitesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,69 @@

class CoGrouperLitesController extends SDWController {

public $helpers = array('Html', 'Form', 'Flash');
public $components = array('Flash');

// Class name, used by Cake
public $name = "CoGrouperLites";

//TODO - need to add the call $this->calculateParentPermissions($roles); for authorization
public $uses = array(
"GrouperLite.CoGrouperLite"
);

/**
* Callback after controller methods are invoked but before views are rendered.
*
* @since COmanage Registry v3.2.0
*/

function beforeRender()
{
$this->set('title_for_layout', _txt('pl.grouperlite.config.edit.title'));

parent::beforeRender();
}

public function display($id)
{
$cfg = $this->CoGrouperLite->getConfig();

$this->set('title_for_layout', _txt('pl.grouperlite.config.display.title'));
// Pass the config so we know which div to overwrite
$this->set('vv_config', $cfg);
}


/**
* Authorization for this Controller, called by Auth component
* - precondition: Session.Auth holds data used for authz decisions
* - postcondition: $permissions set with calculated permissions
*
* @since COmanage Registry v3.2.0
* @return Array Permissions
*/

function isAuthorized()
{
$roles = $this->Role->calculateCMRoles();

// Determine what operations this user can perform

// Construct the permission set for this user, which will also be passed to the view.
// Ask the parent to calculate the display permission, based on the configuration.
// Note that the display permission is set at the Dashboard, not Dashboard Widget level.
$p = $this->calculateParentPermissions($roles);

// Delete an existing CO Announcements Widget?
$p['delete'] = ($roles['cmadmin'] || $roles['coadmin']);

// Edit an existing CO Announcements Widget?
$p['edit'] = ($roles['cmadmin'] || $roles['coadmin']);

// View an existing CO Announcements Widget?
$p['view'] = ($roles['cmadmin'] || $roles['coadmin']);

$this->set('permissions', $p);
return ($p[$this->action]);
}
}
30 changes: 15 additions & 15 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class GrouperGroupsController extends GrouperLiteAppController
public $components = array('Flash');

public $name = 'GrouperGroups';
public $userId = 'ryan.mathis@at.internet2.edu';

public function index() {
return $this->redirect(
Expand All @@ -20,7 +19,7 @@ public function index() {

public function groupUser()
{
$this->set('title', 'Grouper Groups:');
$this->set('title', _txt('pl.grouperlite.title.root'));
//TODO - Change to get userid somehow
$this->set('groupergroupsmember', $this->GrouperGroup->optinGroups($this->userId));
}
Expand All @@ -31,16 +30,17 @@ public function groupInfo()
$details = $this->GrouperGroup->groupDescriptions($name);

$this->set('groupname', $name);
$this->set('title', 'Group configuration and attributes');
$this->set('title', _txt('pl.grouperlite.title.groupinfo'));
$this->set('groupergroupsdetail', $details[0]);
}

public function groupOwner()
{
$this->set('title', 'Grouper Groups I Manage:');
$this->set('title', _txt('pl.grouperlite.title.groupowner'));
if (isset($this->request->data['search'])){
$searchCriteria = urldecode($this->request->data['search']);
$this->set('groupergroupsowner', $this->GrouperGroup->getSearchedGroups($this->userId, $searchCriteria, 'groupOwner'));
$this->set('searchcriteria', $searchCriteria);
} else {
$this->set('groupergroupsowner', $this->GrouperGroup->ownerGroups($this->userId));
}
Expand All @@ -49,7 +49,7 @@ public function groupOwner()

public function groupOptin()
{
$this->set('title', 'Grouper Groups I Can Join:');
$this->set('title', _txt('pl.grouperlite.title.groupoptin'));

if (isset($this->request->data['search'])){
$searchCriteria = urldecode($this->request->data['search']);
Expand All @@ -62,7 +62,7 @@ public function groupOptin()

public function emailListsOptin()
{
$this->set('title', 'Email lists');
$this->set('title', _txt('pl.grouperlite.title.emaillists'));
// mock data
$this->set('group', array(
'member' => true,
Expand All @@ -74,7 +74,7 @@ public function emailListsOptin()

public function emailListsManaged()
{
$this->set('title', 'Email lists I manage');
$this->set('title', _txt('pl.grouperlite.title.emaillistsmanaged'));
// mock data
$this->set('group', array(
'member' => true,
Expand All @@ -86,7 +86,7 @@ public function emailListsManaged()

public function emailListInfo()
{
$this->set('title', 'Email list configuration and attributes');
$this->set('title', _txt('pl.grouperlite.title.emaillistsinfo'));
// mock data
$this->set('groupergroupsdetail', array(
'member' => true,
Expand All @@ -103,7 +103,7 @@ public function emailListInfo()
}

public function groupCreateForm() {
$this->set('title', 'Create Grouper Group');
$this->set('title', _txt('pl.grouperlite.title.groupcreate'));
}

public function groupCreate()
Expand All @@ -120,13 +120,13 @@ public function joinGroup()
if ($this->request->is('post')) {
$name = $this->request->data['GroupName'];
if($this->GrouperGroup->joinGroup($this->userId, $name)) {
$this->Flash->success(__('You have been added to the group!'));
$this->Flash->success(_txt('You have been added to the group!'));
} else {
$this->Flash->error(__('You are unable to join the group!'));
$this->Flash->error(_txt('You are unable to join the group!'));
}
return $this->redirect(array('action' => 'groupoptin'));
}
$this->Flash->error(__('An error occurred in joining the group, please try again later.'));
$this->Flash->error(_txt('An error occurred in joining the group, please try again later.'));

}

Expand All @@ -135,13 +135,13 @@ public function leaveGroup()
if ($this->request->is('post')) {
$name = $this->request->data['GroupName'];
if($this->GrouperGroup->leaveGroup($this->userId, $name)) {
$this->Flash->success(__('You have been deleted from the group!'));
$this->Flash->success(_txt('You have been deleted from the group!'));
} else {
$this->Flash->error(__('You are unable to delete the group!'));
$this->Flash->error(_txt('You are unable to delete the group!'));
}
return $this->redirect(array('action' => 'groupoptin'));
}
$this->Flash->error(__('An error occurred in leaving the group, please try again later.'));
$this->Flash->error(_txt('An error occurred in leaving the group, please try again later.'));
}

/**
Expand Down
33 changes: 3 additions & 30 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,33 +158,6 @@ public function getGrouperGroups($queryData)
return array();
}

public function searchGrouperGroups($queryData) {

$subjectID = $queryData['conditions']['userId'];
$search = $queryData['conditions']['search'];

$groupsFiltered = array(
"WsRestFindGroupsRequest" => array(
"actAsSubjectLookup" => array("subjectId" => $subjectID),
"wsQueryFilter" => array(
"queryFilterType" => "FIND_BY_GROUP_NAME_APPROXIMATE",
"groupName" => $search
)
)
);

$this->http->setHeader(array('Content-Type' => 'application/json', 'Accept' => 'application/json'));

$connectionUrl = "{$this->config['fullUrl']}/groups";

$results = $this->http->sendRequest('POST', $connectionUrl, json_encode($groupsFiltered));

if (isset($results['WsFindGroupsResults']['groupResults']) && $results['WsFindGroupsResults']['groupResults'] != NULL) {
return $results['WsFindGroupsResults']['groupResults'];
}

return array();
}

public function getGrouperGroupDescription($queryData)
{
Expand Down Expand Up @@ -287,7 +260,7 @@ public function getGroupAttributes($queryData) {
"includeAssignmentsOnAssignments" => "T",
"wsOwnerGroupLookups" => array(
array(
"groupName" => $groupName
"groupName" => $groupName,
)
)
)
Expand All @@ -298,8 +271,8 @@ public function getGroupAttributes($queryData) {

$results = $this->http->sendRequest('POST', $connectionUrl, json_encode($stemToFind));

if (isset($results['WsGetAttributeAssignmentsResults']['wsAttributeDefNames']) && $results['WsGetAttributeAssignmentsResults']['wsAttributeDefNames'] != NULL) {
return $results['WsGetAttributeAssignmentsResults']['wsAttributeDefNames'];
if (isset($results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns']) && $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns'] != NULL) {
return $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns'];
}
return array();
}
Expand Down
73 changes: 73 additions & 0 deletions Lib/lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

$cm_grouper_lite_texts['en_US'] = array(
'pl.grouperlite.config.display.title' => 'Grouper Configuration Settings',
'pl.grouperlite.config.edit.title' => 'Edit Grouper Configuration Settings',
'pl.grouperlite.config.grouper-url' => 'Grouper URL',
'pl.grouperlite.config.grouper-version' => 'Grouper Version',
'pl.grouperlite.config.grouper-un' => 'Username',
'pl.grouperlite.config.grouper-pw' => 'Password',

'pl.grouperlite.crumb.root' => 'Grouper groups',
'pl.grouperlite.nav.groups' => 'Groups',
'pl.grouperlite.nav.groups-presided' => 'Groups I preside over',
'pl.grouperlite.nav.email-lists' => 'Email lists',
'pl.grouperlite.nav.email-lists-managed' => 'Email lists I manage',
'pl.grouperlite.nav.create-group' => 'Create group',

'pl.grouperlite.title.root' => 'Grouper Groups:',
'pl.grouperlite.title.groupinfo' => 'Group configuration and attributes',
'pl.grouperlite.title.groupowner' => 'Grouper Groups I Manage',
'pl.grouperlite.title.groupoptin' => 'Grouper Groups I Can Join',
'pl.grouperlite.title.emaillists' => 'Email lists',
'pl.grouperlite.title.emaillistsmanaged' => 'Email lists I manage',
'pl.grouperlite.title.emaillistsinfo' => 'Email list configuration and attributes',
'pl.grouperlite.title.groupcreate' => 'Create Grouper Group',

'pl.grouperlite.message.flash.join-group-success' => 'You have been added to the group!',
'pl.grouperlite.message.flash.join-group-failed' => 'You are unable to join the group!',
'pl.grouperlite.message.flash.join-group-error' => 'An error occurred in joining the group, please try again later.',

'pl.grouperlite.message.flash.leave-group-success' => 'You have been deleted from the group!',
'pl.grouperlite.message.flash.leave-group-failed' => 'You are unable to delete the group!',
'pl.grouperlite.message.flash.leave-group-error' => 'An error occurred in leaving the group, please try again later.',

'pl.grouperlite.table.name' => 'Name',
'pl.grouperlite.table.description' => 'Description',
'pl.grouperlite.table.status' => 'Status',
'pl.grouperlite.table.action' => 'Action',

'pl.grouperlite.value.descr.zerostate' => 'No Description',
'pl.grouperlite.value.enabled' => 'Enabled',
'pl.grouperlite.value.disabled' => 'Disabled',

'pl.grouperlite.action.join-group' => 'Join group',
'pl.grouperlite.action.leave-group' => 'Leave group',
'pl.grouperlite.action.edit-group' => 'Edit',
'pl.grouperlite.action.disable-group' => 'Disable',
'pl.grouperlite.action.subscribe' => 'Subscribe',
'pl.grouperlite.action.unsubscribe' => 'Unsubscribe',
'pl.grouperlite.action.search' => 'Search',
'pl.grouperlite.action.remove' => 'Remove',

'pl.grouperlite.form.group.template.label' => 'Select a template',
'pl.grouperlite.form.group.template.empty' => '(choose one)',
'pl.grouperlite.form.group.name.label' => 'Display name',
'pl.grouperlite.form.group.name.help' => 'Name is the label that identifies this group, and might change.',
'pl.grouperlite.form.group.stem.label' => 'Create in this folder:',
'pl.grouperlite.form.group.stem.help' => 'Enter a folder name.',
'pl.grouperlite.form.group.description.label' => 'Description:',
'pl.grouperlite.form.group.description.help' => 'Description contains notes about the group, which could include: what the group represents, why it was created, etc.',
'pl.grouperlite.form.group.privs.label' => 'Privileges',
'pl.grouperlite.form.group.privs.label.READ' => 'READ',
'pl.grouperlite.form.group.privs.label.VIEW' => 'VIEW',
'pl.grouperlite.form.group.privs.label.OPTIN' => 'OPTIN',
'pl.grouperlite.form.group.privs.label.OPTOUT' => 'OPTOUT',
'pl.grouperlite.form.group.privs.label.ATTRIBUTE_READ' => 'ATTRIBUTE READ',
'pl.grouperlite.form.group.subs.label' => 'Subscribers:',
'pl.grouperlite.form.group.subs.help' => 'Select subscribers to add to the group.',
'pl.grouperlite.form.group.subs.placeholder' => 'Search subscribers',
'pl.grouperlite.form.group.action.save' => 'Save Group',

'pl.grouperlite.search.tags.text' => 'Search',
);
Loading

0 comments on commit a48f8b9

Please sign in to comment.