From 11d4582679f5298d0000546422a6622cffccc7e7 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Mon, 1 Apr 2024 14:39:29 +0300 Subject: [PATCH] Refactoring. Add GrouperLiteActASPerson model --- Config/Schema/schema.xml | 25 ++++++++ Controller/GrouperGroupsController.php | 25 ++++---- Model/GrouperLiteActAsPerson.php | 65 +++++++++++++++++++++ Model/GrouperLiteWidget.php | 18 +++--- View/CoGrouperLiteWidgets/display.ctp | 11 ++-- View/GrouperGroups/base.ctp | 37 ++++++------ webroot/js/autocomplete.js | 2 +- webroot/js/page/ActAsUser.js | 81 ++++++++++++++++++++++++++ 8 files changed, 218 insertions(+), 46 deletions(-) create mode 100644 Model/GrouperLiteActAsPerson.php create mode 100644 webroot/js/page/ActAsUser.js diff --git a/Config/Schema/schema.xml b/Config/Schema/schema.xml index 506f630..e978574 100644 --- a/Config/Schema/schema.xml +++ b/Config/Schema/schema.xml @@ -51,4 +51,29 @@ + + + + + + + + REFERENCES cm_co_grouper_lite_widgets(id) + + + REFERENCES cm_co_people(id) + + + REFERENCES cm_co_people(id) + + + + + + co_grouper_lite_widget_id + + + co_person_id + +
\ No newline at end of file diff --git a/Controller/GrouperGroupsController.php b/Controller/GrouperGroupsController.php index b9749a0..19b927c 100644 --- a/Controller/GrouperGroupsController.php +++ b/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() { diff --git a/Model/GrouperLiteActAsPerson.php b/Model/GrouperLiteActAsPerson.php new file mode 100644 index 0000000..7d2eb9c --- /dev/null +++ b/Model/GrouperLiteActAsPerson.php @@ -0,0 +1,65 @@ + [ + '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 + ], + ]; + +} \ No newline at end of file diff --git a/Model/GrouperLiteWidget.php b/Model/GrouperLiteWidget.php index bfa3d4a..5c38153 100644 --- a/Model/GrouperLiteWidget.php +++ b/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 []; } - - } \ No newline at end of file diff --git a/View/CoGrouperLiteWidgets/display.ctp b/View/CoGrouperLiteWidgets/display.ctp index 8cb6201..3d79ede 100644 --- a/View/CoGrouperLiteWidgets/display.ctp +++ b/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(); ?> diff --git a/View/GrouperGroups/base.ctp b/View/GrouperGroups/base.ctp index ef2c37d..5594560 100644 --- a/View/GrouperGroups/base.ctp +++ b/View/GrouperGroups/base.ctp @@ -1,39 +1,36 @@ 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; - -?> - -Html->addCrumb(_txt('pl.grouperlite.crumb.root'), - array( + [ 'controller' => 'grouper_groups', 'action' => 'groupmember' - ), - array('prepend' => true)); + ], + ['prepend' => true] +); ?>
- fetch('content'); ?> + fetch('content') ?>
\ No newline at end of file diff --git a/webroot/js/autocomplete.js b/webroot/js/autocomplete.js index 368fec1..6a4bed2 100644 --- a/webroot/js/autocomplete.js +++ b/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) { diff --git a/webroot/js/page/ActAsUser.js b/webroot/js/page/ActAsUser.js new file mode 100644 index 0000000..4f7f276 --- /dev/null +++ b/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 '' + this.txt.search + ':' + } + }, + 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*/` + + +
+
+ {{ txt.noaccess }} + {{ txt.empty }} +
+
+ + + + + + + + +
+ {{ subscriber.name }} + + {{ subscriber.id }} + + +
+ + {{ txt.empty }} + +
+
+ ` +} \ No newline at end of file