From c1ee0ddee3f49e26c1ae3a3115fbdf700fe46076 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Mon, 9 Jan 2017 15:09:54 +0100 Subject: [PATCH] migrate multiple resource definition to plugin --- .../controllers/CustomFieldsController.php | 24 +------ .../admin/controllers/FormationController.php | 23 +------ .../controllers/NewsletterController.php | 49 +------------ .../admin/controllers/PrintController.php | 26 +------ .../SessionFormationController.php | 33 +-------- .../admin/controllers/UsergroupController.php | 23 +------ .../admin/controllers/UsersController.php | 22 +----- library/ZendAfi/Controller/Action.php | 22 +++--- .../Controller/Plugin/Manager/CustomField.php | 1 + .../Controller/Plugin/Manager/Manager.php | 18 +++++ .../Plugin/ResourceDefinition/Abstract.php | 10 +++ .../Plugin/ResourceDefinition/CustomField.php | 43 ++++++++++++ .../Plugin/ResourceDefinition/Formation.php | 40 +++++++++++ .../ResourceDefinition/ModeleFusion.php | 43 ++++++++++++ .../Plugin/ResourceDefinition/Newsletter.php | 69 +++++++++++++++++++ .../ResourceDefinition/SessionFormation.php | 51 ++++++++++++++ .../Plugin/ResourceDefinition/User.php | 41 +++++++++++ .../Plugin/ResourceDefinition/UserGroup.php | 42 +++++++++++ .../ProfilOptionsControllerTest.php | 2 +- 19 files changed, 387 insertions(+), 195 deletions(-) create mode 100644 library/ZendAfi/Controller/Plugin/ResourceDefinition/CustomField.php create mode 100644 library/ZendAfi/Controller/Plugin/ResourceDefinition/Formation.php create mode 100644 library/ZendAfi/Controller/Plugin/ResourceDefinition/ModeleFusion.php create mode 100644 library/ZendAfi/Controller/Plugin/ResourceDefinition/Newsletter.php create mode 100644 library/ZendAfi/Controller/Plugin/ResourceDefinition/SessionFormation.php create mode 100644 library/ZendAfi/Controller/Plugin/ResourceDefinition/User.php create mode 100644 library/ZendAfi/Controller/Plugin/ResourceDefinition/UserGroup.php diff --git a/application/modules/admin/controllers/CustomFieldsController.php b/application/modules/admin/controllers/CustomFieldsController.php index e36e15c16ef..6973ceea487 100644 --- a/application/modules/admin/controllers/CustomFieldsController.php +++ b/application/modules/admin/controllers/CustomFieldsController.php @@ -22,28 +22,8 @@ class Admin_CustomFieldsController extends ZendAfi_Controller_Action { public function getPlugins() { - return ['ZendAfi_Controller_Plugin_Manager_CustomField']; - } - - - public function getRessourceDefinitions() { - return [ - 'model' => [ - 'class' => 'Class_CustomField', - 'name' => 'custom_fields', - 'order' => 'id', - 'scope' => 'model'], - - 'messages' => [ - 'successful_save' => $this->_('Champ personnalisé "%s" sauvegardé'), - 'successful_add' => $this->_('Champ personnalisé "%s" ajouté')], - - 'actions' => [ - 'add' => ['title' => $this->_('Nouveau champ personnalisé')], - 'edit' => ['title' => $this->_('Modifier un champ personnalisé')], - 'index' => ['title' => $this->_('Champs personnalisés')]], - - 'form_class_name' => 'ZendAfi_Form_Admin_CustomFields_CustomFieldModel']; + return ['ZendAfi_Controller_Plugin_ResourceDefinition_CustomField', + 'ZendAfi_Controller_Plugin_Manager_CustomField']; } diff --git a/application/modules/admin/controllers/FormationController.php b/application/modules/admin/controllers/FormationController.php index f2543858ced..1a5bd1690b6 100644 --- a/application/modules/admin/controllers/FormationController.php +++ b/application/modules/admin/controllers/FormationController.php @@ -21,30 +21,11 @@ class Admin_FormationController extends ZendAfi_Controller_Action { public function getPlugins() { - return ['ZendAfi_Controller_Plugin_Manager_Manager']; + return ['ZendAfi_Controller_Plugin_ResourceDefinition_Formation', + 'ZendAfi_Controller_Plugin_Manager_Manager']; } - public function getRessourceDefinitions() { - return [ - 'model' => [ - 'class' => 'Class_Formation', - 'name' => 'formation', - 'order' => 'id'], - - 'messages' => [ - 'successful_save' => $this->_('Formation "%s" sauvegardée'), - 'successful_add' => $this->_('La formation "%s" a été sauvegardée'), - 'successful_delete' => $this->_('Formation "%s" supprimée')], - - 'actions' => [ - 'add' => ['title' => $this->_("Ajouter une formation")], - 'edit' => ['title' => $this->_("Modifier la formation: %s")]], - - 'form_class_name' => 'ZendAfi_Form_Admin_Formation', - 'after_add' => function($formation) { $this->_redirect('/admin/session-formation/add/formation_id/' . $formation->getId());} ]; - } - protected function setYearsForCombo() { $years = Class_SessionFormation::getYears(); diff --git a/application/modules/admin/controllers/NewsletterController.php b/application/modules/admin/controllers/NewsletterController.php index c594a13f9fb..38f0ba45bdc 100644 --- a/application/modules/admin/controllers/NewsletterController.php +++ b/application/modules/admin/controllers/NewsletterController.php @@ -24,53 +24,8 @@ class Admin_NewsletterController extends ZendAfi_Controller_Action { public function getPlugins() { - return ['ZendAfi_Controller_Plugin_Manager_Newsletter']; - } - - - public function getRessourceDefinitions() { - return ['model' => ['class' => 'Class_Newsletter', - 'name' => 'newsletter', - 'order' => 'titre'], - - 'actions' => ['index' => ['title' => $this->_('Lettres d\'information')], - 'add' => ['title' => $this->_('Créer une lettre d\'information')], - 'edit' => ['title' => $this->_('Modifier une lettre d\'information : %s')]], - - 'messages' => ['successful_save' => $this->_('Lettre d\'information "%s" enregistrée'), - 'successful_delete' => $this->_('Lettre d\'information supprimée')], - - 'form_class_name' => 'ZendAfi_Form_Admin_Newsletter', - - 'model_actions' => [ - ['action' => 'edit', 'content' => $this->view->boutonIco('type=edit')], - ['action' => 'preview', 'content' => $this->view->boutonIco('type=show')], - ['action' => 'edit-subscribers', - 'content' => function($model) { - return $this->view->tag('span', $this->view->boutonIco("picto=users", "bulle=" . $this->_('Inscrits')) . $model->getNumberOfUsers(), ['style' => 'white-space:nowrap']); - }], - ['action' => 'sendtest', 'content' => $this->view->boutonIco('type=test')], - ['action' => 'send', - 'content' => function($model) { - Class_ScriptLoader::getInstance()->addJQueryReady(" -function sendNewsletterClick(event) { - var target = $(event.target).closest('a'); - var answer = confirm(\"".$this->_("Envoyer la lettre d'information ?")."\"); - if (answer == false) { - event.preventDefault(); - return; - } -} - - $(\"a[rel='send']\").click(sendNewsletterClick); -"); - - - return $this->view->boutonIco('type=mail');}], - ['action' => 'duplicate', 'content' => $this->view->boutonIco('type=duplicate')], - ['action' => 'delete', 'content' => $this->view->boutonIco('type=del')], - ], - ]; + return ['ZendAfi_Controller_Plugin_ResourceDefinition_Newsletter', + 'ZendAfi_Controller_Plugin_Manager_Newsletter']; } diff --git a/application/modules/admin/controllers/PrintController.php b/application/modules/admin/controllers/PrintController.php index 66ec0f7ac8c..bedc2dfd142 100644 --- a/application/modules/admin/controllers/PrintController.php +++ b/application/modules/admin/controllers/PrintController.php @@ -22,30 +22,8 @@ class Admin_PrintController extends ZendAfi_Controller_Action { public function getPlugins() { - return ['ZendAfi_Controller_Plugin_Manager_Manager']; - } - - - public function getRessourceDefinitions() { - return [ - 'model' => [ - 'class' => 'Class_ModeleFusion', - 'name' => 'modele_fusion', - 'order' => 'id'], - - 'messages' => [ - 'successful_save' => $this->_('Modèle "%s" sauvegardé'), - 'successful_add' => $this->_('Le modèle "%s" a été sauvegardé'), - 'successful_delete' => $this->_('Modèle "%s" supprimé')], - - 'actions' => [ - 'add' => ['title' => $this->_("Ajouter un modèle")], - 'edit' => ['title' => $this->_("Modifier le modèle: %s")]], - - 'form_class_name' => 'ZendAfi_Form_ModeleFusion', - - 'after_delete' => function() { $this->_redirect('/admin/print/index');} - ]; + return ['ZendAfi_Controller_Plugin_ResourceDefinition_ModeleFusion', + 'ZendAfi_Controller_Plugin_Manager_Manager']; } diff --git a/application/modules/admin/controllers/SessionFormationController.php b/application/modules/admin/controllers/SessionFormationController.php index 227e2170523..d9146ba8da2 100644 --- a/application/modules/admin/controllers/SessionFormationController.php +++ b/application/modules/admin/controllers/SessionFormationController.php @@ -20,32 +20,8 @@ */ class Admin_SessionFormationController extends ZendAfi_Controller_Action { public function getPlugins() { - return ['ZendAfi_Controller_Plugin_Manager_SessionFormation']; - } - - - public function getRessourceDefinitions() { - return [ - 'model' => [ - 'class' => 'Class_SessionFormation', - 'name' => 'session_formation', - 'order' => 'id'], - - 'messages' => [ - 'successful_save' => $this->_('Session "%s" sauvegardée'), - 'successful_add' => $this->_('La session "%s" a été sauvegardée'), - 'successful_delete' => $this->_('Session "%s" supprimée')], - - 'actions' => [ - 'add' => ['title' => $this->_("Ajouter une session")], - 'edit' => ['title' => $this->_("Modifier la session: %s")]], - - 'form_class_name' => 'ZendAfi_Form_Admin_SessionFormation', - - 'after_delete' => function($model) { $this->_redirect('/admin/formation/index');}, - - 'after_add' => function($session) { $this->afterAdd($session); } - ]; + return ['ZendAfi_Controller_Plugin_ResourceDefinition_SessionFormation', + 'ZendAfi_Controller_Plugin_Manager_SessionFormation']; } @@ -66,11 +42,6 @@ class Admin_SessionFormationController extends ZendAfi_Controller_Action { } - public function afterAdd($session) { - Class_Formation::find($this->_getParam('formation_id'))->addSession($session)->save(); - } - - public function inscriptionsAction() { $session = Class_SessionFormation::getLoader()->find((int)$this->_getParam('id')); diff --git a/application/modules/admin/controllers/UsergroupController.php b/application/modules/admin/controllers/UsergroupController.php index 6db548d902b..e50cd142239 100644 --- a/application/modules/admin/controllers/UsergroupController.php +++ b/application/modules/admin/controllers/UsergroupController.php @@ -24,27 +24,8 @@ class Admin_UsergroupController extends ZendAfi_Controller_Action { public function getPlugins() { - return ['ZendAfi_Controller_Plugin_Manager_UserGroup']; - } - - - public function getRessourceDefinitions() { - return [ - 'model' => [ - 'class' => 'Class_UserGroup', - 'name' => 'user_group', - 'order' => 'id'], - - 'messages' => [ - 'successful_save' => $this->_('Groupe "%s" sauvegardé'), - 'successful_add' => $this->_('Le groupe "%s" a été sauvegardé'), - 'successful_delete' => $this->_('Groupe "%s" supprimé')], - - 'actions' => [ - 'add' => ['title' => $this->_("Ajouter un groupe d'utilisateurs")], - 'edit' => ['title' => $this->_("Modifier le groupe d'utilisateurs: %s")]], - - 'form_class_name' => 'ZendAfi_Form_Admin_UserGroup']; + return ['ZendAfi_Controller_Plugin_ResourceDefinition_UserGroup', + 'ZendAfi_Controller_Plugin_Manager_UserGroup']; } diff --git a/application/modules/admin/controllers/UsersController.php b/application/modules/admin/controllers/UsersController.php index fdeda026c14..610a6407083 100644 --- a/application/modules/admin/controllers/UsersController.php +++ b/application/modules/admin/controllers/UsersController.php @@ -22,24 +22,8 @@ class Admin_UsersController extends ZendAfi_Controller_Action { public function getPlugins() { - return ['ZendAfi_Controller_Plugin_Manager_User']; - } - - - public function getRessourceDefinitions() { - return ['model' => ['class' => 'Class_Users', - 'name' => 'user', - 'order' => 'id'], - - 'messages' => ['successful_save' => $this->_('L\'utilisateur "%s" a été sauvegardé'), - 'successful_add' => $this->_('L\'utilisateur "%s" a été ajouté'), - 'successful_delete' => $this->_('L\'utilisateur "%s" a été supprimé')], - - 'actions' => ['add' => ['title' => $this->_('Ajouter un utilisateur')], - 'edit' => ['title' => $this->_('Modifier l\'utilisateur: %s')], - 'delete' => ['title' => $this->_('Supprimer l\'utilisateur: %s')]], - - 'form_class_name' => 'ZendAfi_Form_Admin_User']; + return ['ZendAfi_Controller_Plugin_ResourceDefinition_User', + 'ZendAfi_Controller_Plugin_Manager_User']; } @@ -49,8 +33,6 @@ class Admin_UsersController extends ZendAfi_Controller_Action { } - - public function changeAdminSkinAction() { $admin_skin = $this->_request->getParam(Class_User_Settings::ADMIN_SKIN, ''); $color = $this->_request->getParam(Class_User_Settings::ADMIN_SKIN_COLOR, ''); diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index 614e02ce88e..f2d13eb4a34 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -67,16 +67,12 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { public function preDispatch() { - $this->_definitions = new ZendAfi_Controller_Action_RessourceDefinitions($this->getRessourceDefinitions()); - $plugin_helper = new ZendAfi_Controller_Action_Plugins($this); - $this->_plugins = $plugin_helper->getPlugins(); - $this->_plugins = $this->view->plugins = $plugin_helper->init(); + $plugins_helper = new ZendAfi_Controller_Action_Plugins($this); + $this->_plugins = $plugins_helper->getPlugins(); + $this->_plugins = $this->view->plugins = $plugins_helper->init(); if ($this->isPopupRequest()) $this->switchToPopupMode(); - - if ('add' != $this->_request->getActionName()) - $this->view->model_actions = $this->_definitions->getModelActions(); } @@ -112,6 +108,11 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { } + public function setResourceDefinition($definitions) { + $this->_definitions = $definitions; + } + + public function getPlugins() { return []; } @@ -338,7 +339,12 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { ->visitRedirectToIndex(function() { $this->_redirectToIndex(); - }); + }) + ->visitPreDispatch(function() + { + $this->preDispatch(); + }) + ; return $this; } diff --git a/library/ZendAfi/Controller/Plugin/Manager/CustomField.php b/library/ZendAfi/Controller/Plugin/Manager/CustomField.php index 32b34d0c336..8334a3c002e 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/CustomField.php +++ b/library/ZendAfi/Controller/Plugin/Manager/CustomField.php @@ -21,6 +21,7 @@ class ZendAfi_Controller_Plugin_Manager_CustomField extends ZendAfi_Controller_Plugin_Manager_Manager { + public function addAction() { $model = $this->_getParam('model'); $this->_view->form = ZendAfi_Form_Admin_CustomFields_CustomFieldModel::newWith([ 'model' => $model]); diff --git a/library/ZendAfi/Controller/Plugin/Manager/Manager.php b/library/ZendAfi/Controller/Plugin/Manager/Manager.php index 84d10aa70eb..43da7be8c22 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/Manager.php +++ b/library/ZendAfi/Controller/Plugin/Manager/Manager.php @@ -22,6 +22,13 @@ class ZendAfi_Controller_Plugin_Manager_Manager extends ZendAfi_Controller_Plugin_Abstract { + public function init() { + parent::init(); + + if ('add' != $this->_request->getActionName()) + $this->_view->model_actions = $this->_getModelActions(); + } + public function acceptVisitor($visitor) { $visitor->visitGetForm(function($model) { @@ -475,4 +482,15 @@ class ZendAfi_Controller_Plugin_Manager_Manager extends ZendAfi_Controller_Plugi protected function _find($id) { return call_user_func($this->_find, $id); } + + + public function visitModelActions($callback) { + $this->_model_actions = $callback; + return $this; + } + + + protected function _getModelActions() { + return call_user_func($this->_model_actions); + } } \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php index 12eaf3a407b..4b3c53a54b6 100644 --- a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php @@ -26,6 +26,11 @@ abstract class ZendAfi_Controller_Plugin_ResourceDefinition_Abstract extends Zen public function __construct($controller) { parent::__construct($controller); + } + + + public function init() { + parent::init(); $this->_attribs = $this->getDefinitions(); } @@ -334,7 +339,12 @@ abstract class ZendAfi_Controller_Plugin_ResourceDefinition_Abstract extends Zen { return $this->getModelId(); }) + ->visitModelActions(function() + { + return $this->getModelActions(); + }) ; + $this->_controller->setResourceDefinition($this); return $this; } diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/CustomField.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/CustomField.php new file mode 100644 index 00000000000..9df3f3fddd6 --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/CustomField.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Plugin_ResourceDefinition_CustomField extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract { + public function getDefinitions() { + return ['model' => [ + 'class' => 'Class_CustomField', + 'name' => 'custom_fields', + 'order' => 'id', + 'scope' => 'model'], + + 'messages' => [ + 'successful_save' => $this->_('Champ personnalisé "%s" sauvegardé'), + 'successful_add' => $this->_('Champ personnalisé "%s" ajouté')], + + 'actions' => [ + 'add' => ['title' => $this->_('Nouveau champ personnalisé')], + 'edit' => ['title' => $this->_('Modifier un champ personnalisé')], + 'index' => ['title' => $this->_('Champs personnalisés')]], + + 'form_class_name' => 'ZendAfi_Form_Admin_CustomFields_CustomFieldModel']; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Formation.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Formation.php new file mode 100644 index 00000000000..d3ceb341e1c --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Formation.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Plugin_ResourceDefinition_Formation extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract { + public function getDefinitions() { + return ['model' => ['class' => 'Class_Formation', + 'name' => 'formation', + 'order' => 'id'], + + 'messages' => ['successful_save' => $this->_('Formation "%s" sauvegardée'), + 'successful_add' => $this->_('La formation "%s" a été sauvegardée'), + 'successful_delete' => $this->_('Formation "%s" supprimée')], + + 'actions' => ['add' => ['title' => $this->_("Ajouter une formation")], + 'edit' => ['title' => $this->_("Modifier la formation: %s")]], + + 'form_class_name' => 'ZendAfi_Form_Admin_Formation', + 'after_add' => function($formation) { $this->_redirect('/admin/session-formation/add/formation_id/' . $formation->getId());} ]; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/ModeleFusion.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/ModeleFusion.php new file mode 100644 index 00000000000..65ff2689a55 --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/ModeleFusion.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Plugin_ResourceDefinition_ModeleFusion extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract { + + public function getDefinitions() { + return ['model' => ['class' => 'Class_ModeleFusion', + 'name' => 'modele_fusion', + 'order' => 'id'], + + 'messages' => ['successful_save' => $this->_('Modèle "%s" sauvegardé'), + 'successful_add' => $this->_('Le modèle "%s" a été sauvegardé'), + 'successful_delete' => $this->_('Modèle "%s" supprimé')], + + 'actions' => ['add' => ['title' => $this->_("Ajouter un modèle")], + 'edit' => ['title' => $this->_("Modifier le modèle: %s")]], + + 'form_class_name' => 'ZendAfi_Form_ModeleFusion', + + 'after_delete' => function() { $this->_redirect('/admin/print/index');} + ]; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Newsletter.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Newsletter.php new file mode 100644 index 00000000000..fbf840f664c --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Newsletter.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Plugin_ResourceDefinition_Newsletter extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract { + public function getDefinitions() { + return ['model' => ['class' => 'Class_Newsletter', + 'name' => 'newsletter', + 'order' => 'titre'], + + 'actions' => ['index' => ['title' => $this->_('Lettres d\'information')], + 'add' => ['title' => $this->_('Créer une lettre d\'information')], + 'edit' => ['title' => $this->_('Modifier une lettre d\'information : %s')]], + + 'messages' => ['successful_save' => $this->_('Lettre d\'information "%s" enregistrée'), + 'successful_delete' => $this->_('Lettre d\'information supprimée')], + + 'form_class_name' => 'ZendAfi_Form_Admin_Newsletter', + + 'model_actions' => [ + ['action' => 'edit', 'content' => $this->_view->boutonIco('type=edit')], + ['action' => 'preview', 'content' => $this->_view->boutonIco('type=show')], + ['action' => 'edit-subscribers', + 'content' => function($model) { + return $this->_view->tag('span', $this->_view->boutonIco("picto=users", "bulle=" . $this->_('Inscrits')) . $model->getNumberOfUsers(), ['style' => 'white-space:nowrap']); + }], + ['action' => 'sendtest', 'content' => $this->_view->boutonIco('type=test')], + ['action' => 'send', + 'content' => function($model) { + Class_ScriptLoader::getInstance()->addJQueryReady(" +function sendNewsletterClick(event) { + var target = $(event.target).closest('a'); + var answer = confirm(\"".$this->_("Envoyer la lettre d'information ?")."\"); + if (answer == false) { + event.preventDefault(); + return; + } +} + + $(\"a[rel='send']\").click(sendNewsletterClick); +"); + + + return $this->_view->boutonIco('type=mail');}], + ['action' => 'duplicate', 'content' => $this->_view->boutonIco('type=duplicate')], + ['action' => 'delete', 'content' => $this->_view->boutonIco('type=del')], + ], + ]; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/SessionFormation.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/SessionFormation.php new file mode 100644 index 00000000000..bf227d33f81 --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/SessionFormation.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Plugin_ResourceDefinition_SessionFormation extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract { + + public function getDefinitions() { + return ['model' => ['class' => 'Class_SessionFormation', + 'name' => 'session_formation', + 'order' => 'id'], + + 'messages' => ['successful_save' => $this->_('Session "%s" sauvegardée'), + 'successful_add' => $this->_('La session "%s" a été sauvegardée'), + 'successful_delete' => $this->_('Session "%s" supprimée')], + + 'actions' => ['add' => ['title' => $this->_("Ajouter une session")], + 'edit' => ['title' => $this->_("Modifier la session: %s")]], + + 'form_class_name' => 'ZendAfi_Form_Admin_SessionFormation', + + 'after_delete' => function($model) { $this->_redirect('/admin/formation/index');}, + + 'after_add' => function($session) { $this->_afterAdd($session); } + ]; + } + + + protected function _afterAdd($session) { + Class_Formation::find($this->_getParam('formation_id'))->addSession($session)->save(); + } + +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/User.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/User.php new file mode 100644 index 00000000000..dcd759d7c0b --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/User.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Plugin_ResourceDefinition_User extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract { + + public function getDefinitions() { + return ['model' => ['class' => 'Class_Users', + 'name' => 'user', + 'order' => 'id'], + + 'messages' => ['successful_save' => $this->_('L\'utilisateur "%s" a été sauvegardé'), + 'successful_add' => $this->_('L\'utilisateur "%s" a été ajouté'), + 'successful_delete' => $this->_('L\'utilisateur "%s" a été supprimé')], + + 'actions' => ['add' => ['title' => $this->_('Ajouter un utilisateur')], + 'edit' => ['title' => $this->_('Modifier l\'utilisateur: %s')], + 'delete' => ['title' => $this->_('Supprimer l\'utilisateur: %s')]], + + 'form_class_name' => 'ZendAfi_Form_Admin_User']; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/UserGroup.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/UserGroup.php new file mode 100644 index 00000000000..fda472900f2 --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/UserGroup.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Plugin_ResourceDefinition_UserGroup extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract { + public function getDefinitions() { + return ['model' => [ + 'class' => 'Class_UserGroup', + 'name' => 'user_group', + 'order' => 'id'], + + 'messages' => [ + 'successful_save' => $this->_('Groupe "%s" sauvegardé'), + 'successful_add' => $this->_('Le groupe "%s" a été sauvegardé'), + 'successful_delete' => $this->_('Groupe "%s" supprimé')], + + 'actions' => [ + 'add' => ['title' => $this->_("Ajouter un groupe d'utilisateurs")], + 'edit' => ['title' => $this->_("Modifier le groupe d'utilisateurs: %s")]], + + 'form_class_name' => 'ZendAfi_Form_Admin_UserGroup']; + } +} +?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index 9b5bddb5cf1..578a06d8abe 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -2206,7 +2206,7 @@ class ProfilOptionsControllerWithFormationWidgetAndNoLoggedUserTest extends Abst ZendAfi_Auth::getInstance()->clearIdentity(); - $this->dispatch('/opac'); + $this->dispatch('/opac', true); } -- GitLab