Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactoring. Add GrouperLiteActASPerson model
Ioannis committed Apr 1, 2024
1 parent 9bbd03e commit 11d4582
Showing 8 changed files with 218 additions and 46 deletions.
25 changes: 25 additions & 0 deletions Config/Schema/schema.xml
@@ -51,4 +51,29 @@
<unique />
</index>
</table>

<table name="grouper_lite_act_as_people">
<field name="id" type="I">
<key />
<autoincrement />
</field>
<field name="co_grouper_lite_widget_id" type="I">
<constraint>REFERENCES cm_co_grouper_lite_widgets(id)</constraint>
</field>
<field name="act_as_co_person_id" type="I">
<constraint>REFERENCES cm_co_people(id)</constraint>
</field>
<field name="actor_co_person_id" type="I">
<constraint>REFERENCES cm_co_people(id)</constraint>
</field>
<field name="created" type="T" />
<field name="modified" type="T" />

<index name="grouper_lite_act_as_people_i1">
<col>co_grouper_lite_widget_id</col>
</index>
<index name="grouper_lite_act_as_people_i2">
<col>co_person_id</col>
</index>
</table>
</schema>
25 changes: 15 additions & 10 deletions Controller/GrouperGroupsController.php
@@ -37,21 +37,27 @@
*/
class GrouperGroupsController extends GrouperLiteWidgetAppController
{
public $helpers = array('Html', 'Form', 'Flash');
public $helpers = ['Html', 'Form', 'Flash'];

// Dynamic properties are deprecated, so we will define the property here
private $userId = null;

public $uses = array(
public $uses = [
'GrouperLiteWidget.GrouperGroup',
'GrouperLiteWidget.CoGrouperLiteWidget',
'Identifier',
'CoPerson');

public $components = array('Flash', 'Paginator', 'RequestHandler', 'Security' => array(
'validatePost' => false,
'csrfUseOnce' => false
));
'CoPerson'
];

public $components = [
'Flash',
'Paginator',
'RequestHandler',
'Security' => [
'validatePost' => false,
'csrfUseOnce' => false
]
];

public $name = 'GrouperGroups';

@@ -94,8 +100,7 @@ public function addSubscriber(): void
/**
* Overrides parent beforeFilter to verify that Session contains the correct API settings.
*
* @return CakeResponse|void|null
*
* @return void
*/
public function beforeFilter()
{
65 changes: 65 additions & 0 deletions Model/GrouperLiteActAsPerson.php
@@ -0,0 +1,65 @@
<?php
/**
* COmanage Registry Grouper Lite GrouperLiteActAsPerson Model
*
* 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.
*
* @link http://www.internet2.edu/comanage COmanage Project
* @package registry-plugin
* @since COmanage Registry v4.4.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

class GrouperLiteActAsPerson extends AppModel
{
public $name = 'GrouperLiteActAsPerson';


// Association rules from this model to other models
public $belongsTo = [
'GrouperLiteWidget',
'ActAsCoPerson' => [
'className' => 'CoPerson',
'foreignKey' => 'act_as_co_person_id'
],
'ActorCoPerson' => [
'className' => 'CoPerson',
'foreignKey' => 'actor_co_person_id'
]
];

// Validation rules for table elements
public $validate = [
'co_grouper_lite_widget_id' => [
'rule' => 'numeric',
'required' => true,
'allowEmpty' => false
],
'act_as_co_person_id' => [
'rule' => 'numeric',
'required' => true,
'allowEmpty' => false
],
'actor_co_person_id' => [
'rule' => 'numeric',
'required' => true,
'allowEmpty' => false
],
];

}
18 changes: 9 additions & 9 deletions Model/GrouperLiteWidget.php
@@ -27,25 +27,25 @@

class GrouperLiteWidget extends AppModel {
// Define class name for cake
public $name = "GrouperLiteWidget";
public $name = 'GrouperLiteWidget';

// Required by COmanage Plugins
public $cmPluginType = "dashboardwidget";
public $cmPluginType = 'dashboardwidget';

// Document foreign keys
public $cmPluginHasMany = array();
public $cmPluginHasMany = [];

// Association rules from this model to other models
public $belongsTo = array();
public $belongsTo = [];

public $hasMany = array();
public $hasMany = [
'GrouperLiteActAsPerson' => ['dependent' => true]
];

// Validation rules for table elements
public $validate = array();
public $validate = [];

public function cmPluginMenus() {
return array();
return [];
}


}
11 changes: 5 additions & 6 deletions View/CoGrouperLiteWidgets/display.ctp
@@ -29,17 +29,16 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

$this->extend('/GrouperGroups/base');
//echo $this->element('GrouperLiteWidget.base-styles');


// Figure out the widget ID so we can overwrite the dashboard's widget div

$divid = $vv_config['CoGrouperLiteWidget']['co_dashboard_widget_id'];

$plugin = filter_var($vv_codw["CoDashboardWidget"]["plugin"],FILTER_SANITIZE_SPECIAL_CHARS);
$plugin = filter_var($vv_codw['CoDashboardWidget']['plugin'], FILTER_SANITIZE_SPECIAL_CHARS);
$pl = Inflector::underscore($plugin);
$plcmodel = Inflector::pluralize($pl);

$this->extend('/GrouperGroups/base');
echo $this->element('GrouperLiteWidget.base-styles');

$idsuffix = rand();

?>
37 changes: 17 additions & 20 deletions View/GrouperGroups/base.ctp
@@ -1,39 +1,36 @@
<?php

echo $this->Html->meta(
array('http-equiv' => 'Cache-Control', 'content' => 'no-cache, no-store, must-revalidate'),
null,
array('inline' => false)
print $this->Html->meta(
['http-equiv' => 'Cache-Control', 'content' => 'no-cache, no-store, must-revalidate'],
null,
['inline' => false]
);
echo $this->Html->meta(
array('http-equiv' => 'Pragma', 'content' => 'no-cache'),
null,
array('inline' => false)
print $this->Html->meta(
['http-equiv' => 'Pragma', 'content' => 'no-cache'],
null,
['inline' => false]
);
echo $this->Html->meta(
array('http-equiv' => 'Expires', 'content' => '0'),
null,
array('inline' => false)
print $this->Html->meta(
['http-equiv' => 'Expires', 'content' => '0'],
null,
['inline' => false]
);

print $this->Html->script('GrouperLiteWidget.autocomplete.grouperplugin') . PHP_EOL;
print $this->element('GrouperLiteWidget.base-styles');
print $this->Html->css('GrouperLiteWidget.co-grouper-plugin') . PHP_EOL;


?>

<?php
$this->Html->addCrumb(_txt('pl.grouperlite.crumb.root'),
array(
[
'controller' => 'grouper_groups',
'action' => 'groupmember'
),
array('prepend' => true));
],
['prepend' => true]
);
?>

<!-- Load JavaScript -->

<div id="grouper-plugin" class="grouper pt-2">
<?php echo $this->fetch('content'); ?>
<?= $this->fetch('content') ?>
</div>
2 changes: 1 addition & 1 deletion webroot/js/autocomplete.js
@@ -63,7 +63,7 @@ export default {
type: 'GET',
dataType: "json",
data: {
// XXX Change the term key to any other query key that fits your needs.
// XXX Change the term key to any other query key that fit your needs.
term: request.term
},
success: function (data) {
81 changes: 81 additions & 0 deletions webroot/js/page/ActAsUser.js
@@ -0,0 +1,81 @@
import PageCount from '../pagecount.js';
import Pagination from '../pagination.js';
import GroupsTable from '../groups-table.js';
import Members from '../members.js';
import Autocomplete from '../autocomplete.js';
import Loader from '../loader.js';
export default {
components: {
Autocomplete,
Loader
},
data() {
return {
loading: false,
subscribers: [],
user: {},
rowLoading: false,
searched: false
}
},
inject: ['api', 'txt'],
computed: {
preInfoTxt() {
return '<em class="material-icons lg" aria-hidden="true">search</em><span class="ml-1">' + this.txt.search + ':</span>'
}
},
methods: {
reset() {
this.searched = false
// If you are in the middle of a row action we do not want to clear
// the results because we are breaking the user experience
if(!this.rowLoading) {
this.subscribers = []
}
},
async disableActAs() {

},
async findUsersIManage(user) {
}
},
template: /*html*/`
<autocomplete @callback="(item) => findGroupsForManagedUser(item)"
icon="search"
action="findGroupsForManagedUser"
:renderBtn="false"
:preInfo="this.preInfoTxt"
/>
<loader :active="loading"></loader>
<div v-if="!loading">
<div v-if="error">
<span v-if="error.status === 403">{{ txt.noaccess }}</span>
<span v-else>{{ txt.empty }}</span>
</div>
<div v-else>
<table v-if="subscribers.length > 0" class="table table-striped">
<tbody id="sub-body">
<tr v-for="subscriber in subscribers">
<td>
{{ subscriber.name }}
</td>
<td :colspan="remove ? 1 : 2">
{{ subscriber.id }}
</td>
<td v-if="remove">
<button :disabled="disabled.indexOf(subscriber.id) > -1"
@click=""
class="btn btn-grouper btn-block btn-primary btn-sm m-1 text-nowrap member-del-btn">
{{ txt.remove }}
</button>
</td>
</tr>
</tbody>
</table>
<span v-else>
{{ txt.empty }}
</span>
</div>
</div>
`
}

0 comments on commit 11d4582

Please sign in to comment.