diff --git a/FEATURES/127263 b/FEATURES/127263 new file mode 100644 index 0000000000000000000000000000000000000000..b1b97d1e1d79ffbfdc91dcbce9e69abcd42bcf28 --- /dev/null +++ b/FEATURES/127263 @@ -0,0 +1,10 @@ + '127263' => + ['Label' => $this->_('Inscription ouverte aux activités'), + 'Desc' => $this->_('Ajout des sessions ouvertes à tous; champs personnalisés sur les inscriptions et ajout âge minimum requis pour les enfants'), + 'Image' => '', + 'Video' => 'https://youtu.be/3ZhNRQA1b2U', + 'Category' => $this->_('Activités'), + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => 'http://wiki.bokeh-library-portal.org/index.php?title=Gestion_des_activités', + 'Test' => '', + 'Date' => '2021-02-02'], \ No newline at end of file diff --git a/VERSIONS_WIP/127263 b/VERSIONS_WIP/127263 new file mode 100644 index 0000000000000000000000000000000000000000..71b7e01b22dd8989916fcb21f7e613d08e07ab55 --- /dev/null +++ b/VERSIONS_WIP/127263 @@ -0,0 +1 @@ + - ticket #127263 : Module activité : Ajout des sessions ouvertes à tous; champs personnalisés sur les inscriptions et ajout âge minimum requis pour les enfants \ No newline at end of file diff --git a/application/modules/admin/controllers/ProfilController.php b/application/modules/admin/controllers/ProfilController.php index cada6d941d6cc2635fa44a60e7a9a47cf4f6b1d7..bc83f6c4e09e9a9c163d7be8d0364d249bd6c919 100644 --- a/application/modules/admin/controllers/ProfilController.php +++ b/application/modules/admin/controllers/ProfilController.php @@ -110,9 +110,20 @@ class Admin_ProfilController extends ZendAfi_Controller_Action { public function proprietesAction() { $this->view->titre = $this->_("Propriétés des modules: %s", $this->_profil->getLibelle()); - // Définition des modules - $cls=new Class_Systeme_ModulesNotice(); - $this->view->modules=$cls->getModules(); + $this->view->modules = [ ['title' => $this->_('Bloc des exemplaires'), + 'url' => ['module' => 'admin', + 'controller' => 'modulesnotice', + 'action' => 'exemplaires', + 'id_profil' => $this->_profil->getId()]] ]; + + (new Class_Template_Loader) + ->findFromProfile($this->_profil->getId()) + ->setProfile($this->_profil) + ->allConfigurableScreensDo(function ($title, $url) + { + $this->view->modules [] = ['title' => $title, + 'url' => $url]; + }); } @@ -564,4 +575,4 @@ class Admin_ProfilController extends ZendAfi_Controller_Action { return explode('=', $item, 2); } -} \ No newline at end of file +} diff --git a/application/modules/admin/controllers/SessionActivityController.php b/application/modules/admin/controllers/SessionActivityController.php index 2866d07ff0a869951c9896152eaf783eb952647f..67a27a53004f45555db0e8f6c8c99ca6eb44ceca 100644 --- a/application/modules/admin/controllers/SessionActivityController.php +++ b/application/modules/admin/controllers/SessionActivityController.php @@ -56,7 +56,8 @@ class Admin_SessionActivityController extends ZendAfi_Controller_Action { $content = $this->view->renderCsv($description, $session->getMetaDatas()); $description = (new Class_TableDescription_SessionActivityInscriptionsExport('')) - ->setAgeChildMax($session->getAgeChildMax()); + ->setAgeChildMax($session->getAgeChildMax()) + ->setAgeChildMin($session->getAgeChildMin()); $content .= "\n" . $this->view->renderCsv($description, diff --git a/application/modules/admin/views/scripts/activity/_session_actions.phtml b/application/modules/admin/views/scripts/activity/_session_actions.phtml index c82f799492ddaa9368086517216eccaead0f67eb..d3ae43c14ad1133e915f1cd61368f44efdaba5b7 100644 --- a/application/modules/admin/views/scripts/activity/_session_actions.phtml +++ b/application/modules/admin/views/scripts/activity/_session_actions.phtml @@ -34,7 +34,7 @@ $actions = 'action' => 'inscriptions', 'id' => null], 'icon' => 'users', - 'label' => $this->_('Stagiaires')], + 'label' => $this->_('Participants')], ['url' => ['controller' => 'activity', 'action' => 'presences', diff --git a/application/modules/admin/views/scripts/profil/proprietes.phtml b/application/modules/admin/views/scripts/profil/proprietes.phtml index 78cf9724c61d61ad35fb3171de7e57b4c9602d0a..aa06487ecaddf21733a4b25bbf02941a4a69524d 100644 --- a/application/modules/admin/views/scripts/profil/proprietes.phtml +++ b/application/modules/admin/views/scripts/profil/proprietes.phtml @@ -1,82 +1,23 @@ -<?php echo $this->partial('profil/_profil_panel.phtml', - ['profil' => $this->profil]);?> +<?php +echo $this->partial('profil/_profil_panel.phtml', + ['profil' => $this->profil]); -<table cellspacing="0" cellpadding="0"> - <tr class="soustitre"> - <td><?php echo $this->_('Blocs et onglets des notices');?></td> - <td width="20px"> </td> - </tr> - <tr> - <td colspan="3" class="separ"></td> - </tr> +$description = (new Class_TableDescription('')) + ->addColumn($this->_('Écran'), + function($module) { return $module['title']; }) + ->addRowAction( + function($module) + { - <?php - $ligne = 0; - foreach($this->modules as $id_module => $module) { - $class = ($ligne & 1) ? 'first' : 'second'; + return $this->tagAnchor($this->url($module['url'], null, true), + Class_Admin_Skin::current()->renderActionIconOn('edit', + $this, + ['alt' => $module['title']]), + ['data-popup' => 'true', + 'title' => $module['title']]); + }); - $edit = $this->renderModelAction($this->profil, - ['url' => ['module' => 'admin', - 'controller' => 'modulesnotice', - 'action' => strtolower($id_module), - 'config' => 'admin', - 'id_profil' => '%s'], - 'icon' => 'edit', - 'label' => $this->_('Modifier'), - 'anchorOptions' => ['data-popup' => 'true']]); - echo $this->tag('tr', - $this->tag('td', $module['libelle']) - . $this->tag('td', $edit), - ['class' => $class, - 'style' => 'height:20px']); - $ligne ++ ; - } - ?> -</table> -<table cellspacing="0" cellpadding="0"> - <tr class="soustitre"> - <td><?php echo $this->_('Écrans');?></td> - <td width="20px"> </td> - </tr> - <tr> - <td colspan="3" class="separ"></td> - </tr> - <?php - $edit = $this->renderModelAction($this->profil, - ['url' => ['module' => 'admin', - 'controller' => 'modules', - 'action' => 'recherche', - 'config' => 'site', - 'type_module' => 'recherche', - 'id_profil' => '%s', - 'action1' => 'avancee'], - 'icon' => 'edit', - 'label' => $this->_('Modifier'), - 'anchorOptions' => ['data-popup' => 'true']]); - echo $this->tag('tr', - $this->tag('td', $this->_('Recherche avancée')) - . $this->tag('td', $edit), - ['class' => 'first', - 'style' => 'height:20px']); - - $edit = $this->renderModelAction($this->profil, - ['url' => ['module' => 'admin', - 'controller' => 'modules', - 'action' => 'recherche', - 'config' => 'site', - 'type_module' => 'recherche', - 'id_profil' => '%s', - 'action1' => 'resultat', - 'action2' => 'simple'], - 'icon' => 'edit', - 'label' => $this->_('Modifier'), - 'anchorOptions' => ['data-popup' => 'true']]); - echo $this->tag('tr', - $this->tag('td', $this->_('Résultat de recherche simple')) - . $this->tag('td', $edit), - ['class' => 'first', - 'style' => 'height:20px']); - ?> -</table> +echo $this->renderTable($description, + $this->modules); diff --git a/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml b/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml index 92f7c7dfb86ab3577525d46921349a01f08830b9..94470b899a6aabcc96b0bacccb19807cc1145910 100644 --- a/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml +++ b/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml @@ -3,13 +3,4 @@ if (!$this->isPopup()) echo $this->partial('activity/_activity_panel.phtml', ['activity' => $this->inscription->getActivity()]); -$session = $this->inscription->getSessionActivity(); -$messages = new Class_SessionActivityInscription_Messages; - -if ($session->isFullAdults()) - echo $this->tag('div', $messages->noMoreAdultRoom(), ['class' => 'error']); - -if ($session->isFullChildren()) - echo $this->tag('div', $messages->noMoreChildRoom(), ['class' => 'error']); - echo $this->renderForm($this->form); diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 95bdbd4241aa59ef21dc1525414ff3805285fff7..41a61d3b2836e5dcf68af5e77ea6b96ccb7a2711 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -20,7 +20,7 @@ */ class AbonneController extends ZendAfi_Controller_Action { - protected $_user = null; // Le user connecté + protected $_user = null; public function getPlugins() { diff --git a/cosmogramme/sql/patch/patch_403.php b/cosmogramme/sql/patch/patch_403.php new file mode 100644 index 0000000000000000000000000000000000000000..ad16f277f96e4772cf990c91df768db9517e185c --- /dev/null +++ b/cosmogramme/sql/patch/patch_403.php @@ -0,0 +1,12 @@ +<?php +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); + +try { + $adapter->query( + 'ALTER TABLE `session_activity` ' + . 'ADD COLUMN `everybody_can_subscribe` boolean default false, ' + . 'ADD COLUMN `age_child_min` int(11) unsigned not null default 0, ' + . 'CHANGE `date_limite_inscription` `date_limite_fin` date NOT NULL, ' + . 'ADD `date_limite_debut` date NOT NULL' + ); +} catch(Exception $e) {} diff --git a/index.php b/index.php index bf1e8e086c63d037983121e0aa2293047fe9b61f..f4bbc160722a5af52dc1d4843408d10225c1a701 100644 --- a/index.php +++ b/index.php @@ -20,7 +20,8 @@ */ // Run Bokeh installer if not configured -if ((!file_exists('local.php') || !file_exists('config.ini') || !file_exists('cosmogramme/config.php')) && file_exists('scripts/install-bokeh.php')) { +if ((!file_exists('local.php') || !file_exists('config.ini') || !file_exists('cosmogramme/config.php')) + && file_exists('scripts/install-bokeh.php')) { include('scripts/install-bokeh.php'); } diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index 2ff31b4f68fe1d22e7383e09cc0f20ef5954ee98..49ba0efc1007e49c7c5c414859c03a3982f47a63 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -606,7 +606,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'ACTIVITY_SESSION_QUOTAS' => Class_AdminVar_Meta::newOnOff($this->_('Activer ou désactiver la gestion des quotas pour les activités')), 'ACTIVITY_NOTIFICATION_DELAY' => Class_AdminVar_Meta::newDefault($this->_('Délai d\'envoie des rappel pour les activités (en jours)'), ['value' => '0']), 'ACTIVITY_NOTIFICATION_SUBJECT' => Class_AdminVar_Meta::newDefault($this->_('Sujet de l\'email de rappel pour les activités'), ['value'=> 'Rappel : {session.libelle_activity}']), - 'ACTIVITY_NOTIFICATION_BODY' => Class_AdminVar_Meta::newEditor($this->_('Contenu de l\'email de rappel pour les activités'), ['value' => '<p>Bonjour {stagiaire.nom_complet},</p><p>L\'activité {session.libelle_activity} à laquelle vous êtes inscrit, commencera le {session.date_debut_texte}.</p><p>Cordialement</p>']) + 'ACTIVITY_NOTIFICATION_BODY' => Class_AdminVar_Meta::newEditor($this->_('Contenu de l\'email de rappel pour les activités'), ['value' => '<p>Bonjour {stagiaire.nom_complet},</p><p>L\'activité {session.libelle_activity} à laquelle vous êtes inscrit, commencera le {session.date_debut_texte}.</p><p>Cordialement</p>']), + 'ACTIVITY_ALLOW_SUBSCRIPTIONS_FOR_ALL' => Class_AdminVar_Meta::newOnOff($this->_('Activer ou désactiver la possibilité d\'ouvrir les inscriptions à l\'ensemble des comptes')), ]; } @@ -1218,6 +1219,11 @@ class Class_AdminVarLoader extends Storm_Model_Loader { public function isActivitySessionQuotasEnabled() { return Class_AdminVar::isModuleEnabled('ACTIVITY_SESSION_QUOTAS'); } + + + public function isActivityAllowSubscriptionsForAllEnabled() { + return Class_AdminVar::isModuleEnabled('ACTIVITY_ALLOW_SUBSCRIPTIONS_FOR_ALL'); + } } diff --git a/library/Class/CustomField/Model.php b/library/Class/CustomField/Model.php index 71744c41b8d930eb053e3590875e18c9674bb43c..46a99b43a7ee1eb087486166997a653827153532 100644 --- a/library/Class/CustomField/Model.php +++ b/library/Class/CustomField/Model.php @@ -67,7 +67,12 @@ class Class_CustomField_Model { $translator->_('Bibliothèque'), ['module' => 'admin', 'controller' => 'bib', - 'action' => 'edit']) + 'action' => 'edit']), + new Class_CustomField_ModelConfiguration('SessionActivityInscription', + $translator->_('Inscription aux activités'), + ['module' => 'admin', + 'controller' => 'session-activity-inscription', + 'action' => 'edit']), ]; static::$_models = []; diff --git a/library/Class/CustomField/ModelConfiguration/Activity.php b/library/Class/CustomField/ModelConfiguration/Activity.php index faf6d6332abb65c843915763978cc0c8ec2fe86f..66e00b1ea610b7fad50fae367b2495e484bd21d2 100644 --- a/library/Class/CustomField/ModelConfiguration/Activity.php +++ b/library/Class/CustomField/ModelConfiguration/Activity.php @@ -21,13 +21,13 @@ class Class_CustomField_ModelConfiguration_Activity extends Class_CustomField_ModelConfiguration { - public function __construct() { - $this->_class_name = 'Activity'; - $this->_label = $this->_('Activité'); - $this->_edit_url = [ - 'module' => 'admin', - 'controller' => 'activity', - 'action' => 'edit']; - } + public function __construct() { + $this->_class_name = 'Activity'; + $this->_label = $this->_('Activité'); + $this->_edit_url = [ + 'module' => 'admin', + 'controller' => 'activity', + 'action' => 'edit']; + } } -?> \ No newline at end of file +?> diff --git a/library/Class/CustomField/ModelValues.php b/library/Class/CustomField/ModelValues.php index f8822efa7cc21da8cc48a2c8db480554d3de21b3..add390de8a7ab4081bbaa08d18ade13a0905ae9e 100644 --- a/library/Class/CustomField/ModelValues.php +++ b/library/Class/CustomField/ModelValues.php @@ -58,6 +58,17 @@ class Class_CustomField_ModelValues { } + public function callGetterByAttributeName($name) { + if (0 !== strpos($name, 'field_value_')) // getter for value by id: getFieldValueX + return null; + + if (!$value = $this->getFieldValue(str_replace('field_value_', '', $name))) + return null; + + return $value->getValue(); + } + + public function setFieldValue($custom_field_id, $value) { $instance = $this->getFieldValue($custom_field_id); diff --git a/library/Class/Profil.php b/library/Class/Profil.php index 2920769b8167a7040677afb6544d9f92b66db1e0..38b03d910e027b3ffff25457d2ea9248a014da81 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -341,8 +341,7 @@ class Class_Profil extends Storm_Model_Abstract { 'plan' => 1, 'resa' => 1, 'dispo' => 1, - 'date_retour' => 0, - 'en_pret' => Class_WebService_SIGB_Exemplaire::newInstance()->message('DISPO_EN_PRET')]]), + 'date_retour' => 0]]), 'hauteur_banniere' => 100, 'mail_site' => '', 'mail_suggestion_achat' => '', @@ -1100,13 +1099,7 @@ class Class_Profil extends Storm_Model_Abstract { * @return array */ public function getCfgNoticeAsArray() { - $cfg = $this->_getCfgAsArrayNamed('Notice'); - $module = new Class_Systeme_ModulesNotice(); - - $cfg['exemplaires'] = array_merge($module->getValeursParDefaut('exemplaires'), - $cfg['exemplaires'] ? $cfg['exemplaires'] : []); - - return $cfg; + return $this->_getCfgAsArrayNamed('Notice'); } diff --git a/library/Class/Profil/ItemsSettings.php b/library/Class/Profil/ItemsSettings.php index 748c699fa363541eab2fb5a8a5989359edc6c62b..5d39ab1a2ce3e6ce671ab93766474a875a48c4dc 100644 --- a/library/Class/Profil/ItemsSettings.php +++ b/library/Class/Profil/ItemsSettings.php @@ -33,13 +33,12 @@ class Class_Profil_ItemsSettings { public function __construct($profile) { $this->_profile = $profile; - $this->_settings = $profile->getCfgNoticeAsArray()['exemplaires']; - - if (!isset($this->_settings['libraries'])) - $this->_settings['libraries'] = ''; - - if (!isset($this->_settings['all_items_map'])) - $this->_settings['all_items_map'] = 1; + $this->_settings = array_merge(['libraries' => '', + 'all_items_map' => 1, + 'order_by' => '', + 'order_direction' => '', + 'en_pret' => ''], + $profile->getCfgNoticeAsArray()['exemplaires']); } @@ -68,6 +67,11 @@ class Class_Profil_ItemsSettings { } + public function getCheckedOutLabel() { + return $this->_settings['en_pret']; + } + + public function getIncludedSubfields() { $codes = isset($this->_settings['datas_items_code']) ? $this->_settings['datas_items_code'] : []; $labels = isset($this->_settings['datas_items_label']) ? $this->_settings['datas_items_label'] : []; diff --git a/library/Class/SessionActivity.php b/library/Class/SessionActivity.php index 8dee0c3f7d3a7b3984220949d04f8f861ac0cb38..a6f569f02ff20ab5f57d8d1e3c6358d92cef97c5 100644 --- a/library/Class/SessionActivity.php +++ b/library/Class/SessionActivity.php @@ -102,6 +102,7 @@ class SessionActivityLoader extends Storm_Model_Loader { + class Class_SessionActivity extends Storm_Model_Abstract { use Trait_TimeSource, Trait_Translator, Trait_CustomFields; @@ -133,6 +134,7 @@ class Class_SessionActivity extends Storm_Model_Abstract { 'effectif_child_min' => 0, 'effectif_child_max' => 0, 'age_child_max' => 0, + 'age_child_min' => 0, 'all_day' => 1, 'effectif_inscription_max' => 0, 'effectif_inscription_child_max' => 0, @@ -140,13 +142,15 @@ class Class_SessionActivity extends Storm_Model_Abstract { 'duree' => 0, 'date_debut' => '', 'date_fin' => '', - 'date_limite_inscription' => null, + 'date_limite_debut' => '', + 'date_limite_fin' => '', 'contenu' => '', 'objectif' => '', 'horaires' => '', 'is_annule' => false, 'visible' => true, - 'article_id' => null]; + 'article_id' => null, + 'everybody_can_subscribe' => false]; protected $_is_max_registration_limited = true, @@ -215,15 +219,28 @@ class Class_SessionActivity extends Storm_Model_Abstract { * @return bool */ public function isInscriptionClosed() { - return $this->alreadyStarted() + return !$this->isValid() || $this->isAnnule() - || (!$this->hasDateLimiteInscription()) + || $this->alreadyStarted() + || $this->isFull() || $this->isDateSubscriptionExhausted(); } + public function isInscriptionOpened() { + if ($this->isInscriptionClosed()) + return false; + + return !$this->hasDateLimiteDebut() + || strtotime($this->getDateLimiteDebut()) < strtotime(self::getTimeSource()->dateYmd()); + } + + public function isDateSubscriptionExhausted() { - return strtotime($this->getDateLimiteInscription()) < strtotime(self::getTimeSource()->dateYmd()); + if (!$date_end = $this->getDateLimiteFin()) + $date_end = $this->getDateDebut(); + + return strtotime($date_end) < strtotime(self::getTimeSource()->dateYmd()); } @@ -235,6 +252,12 @@ class Class_SessionActivity extends Storm_Model_Abstract { } + public function isEverybodyCanSubscribe() { + return (0 != (int)$this->getEverybodyCanSubscribe()) + && Class_AdminVar::isActivityAllowSubscriptionsForAllEnabled(); + } + + /** * @return Class_SessionActivity */ @@ -277,17 +300,31 @@ class Class_SessionActivity extends Storm_Model_Abstract { } + public function getDateDebut() { + return $this->_rangeDateFormat(parent::_get('date_debut')); + } + + public function getDateFin() { - $date = parent::_get('date_fin'); - return $date ? $date : null; //pour ne pas retourner chaine vide, probleme zend_form + return $this->_rangeDateFormat(parent::_get('date_fin')); + } + + + public function getDateLimiteDebut() { + return $this->_rangeDateFormat(parent::_get('date_limite_debut')); } - public function getDateLimiteInscription() { - $date = parent::_get('date_limite_inscription'); + public function getDateLimiteFin() { + return $this->_rangeDateFormat(parent::_get('date_limite_fin')); + } + + + protected function _rangeDateFormat($date) { if ('0000-00-00' == $date) $date = null; - return $date ? $date : null; + + return $date ? $date : null; //pour ne pas retourner chaine vide, probleme zend_form } @@ -314,7 +351,7 @@ class Class_SessionActivity extends Storm_Model_Abstract { foreach($this->getStagiaires() as $stagiaire) { $this->checkAttribute("effectif_max", - $stagiaire->hasRightSuivreActivity(), + $this->isUserCanSubscribe($stagiaire), $this->_("Le stagiaire %s n'a pas les droits suffisants pour suivre une activité", $stagiaire->getLogin())); } @@ -322,12 +359,8 @@ class Class_SessionActivity extends Storm_Model_Abstract { $this->checkAttribute('activity_range', $start_date, $this->_('La date de début est requise')); - $limit_date = DateTime::createFromFormat('!Y-m-d', $this->getDateLimiteInscription()); - $this->checkAttribute('date_limite_inscription', $limit_date, - $this->_('La date limite d\'inscription est requise')); - - if ($start_date && $limit_date) - $this->checkAttribute('date_limite_inscription', + if ($start_date && ($limit_date = DateTime::createFromFormat('!Y-m-d', $this->getDateLimiteFin()))) + $this->checkAttribute('date_limite_fin', $limit_date <= $start_date, $this->_("La date limite d'inscription doit être inférieure ou égale à la date de début")); @@ -340,6 +373,11 @@ class Class_SessionActivity extends Storm_Model_Abstract { } + public function isUserCanSubscribe($user) { + return $user && ($this->isEverybodyCanSubscribe() || $user->hasRightSuivreActivity()); + } + + protected function _checkAttributesWithQuotas() { if (!Class_AdminVar::isActivitySessionQuotasEnabled()) return; @@ -360,6 +398,10 @@ class Class_SessionActivity extends Storm_Model_Abstract { $this->getEffectifChildMax() <= 0 || $this->getAgeChildMax() > 0, $this->_("L'âge maximum pour les enfants doit être renseigné")); + $this->checkAttribute('age_child_min', + $this->getAgeChildMin() <= $this->getAgeChildMax(), + $this->_("L'âge minimum doit être inférieur à l'âge maximum pour les enfants")); + $this->checkAttribute("effectif_inscription_max", $this->getEffectifMax() <= 0 || $this->getEffectifInscriptionMax() > 0, $this->_("Adultes maximum par inscription doit être renseigné")); @@ -491,19 +533,21 @@ class Class_SessionActivity extends Storm_Model_Abstract { } - public function getDateLimiteInscriptionHumanRead() { - return $this->_getHumanDate($this->getDateLimiteInscription()); + public function getDateLimiteDebutHumanRead() { + return $this->_getHumanDate($this->getDateLimiteDebut()); + } + + + public function getDateLimiteFinHumanRead() { + return $this->_getHumanDate($this->getDateLimiteFin()); } public function isSubscriableFor($user) { - if ($user && !$user->hasRightSuivreActivity()) + if (!$this->isInscriptionOpened()) return false; - return $this->isValid() - && !$this->isFull() - && !$this->isAnnule() - && !$this->isInscriptionClosed(); + return !$user || $this->isUserCanSubscribe($user); } @@ -672,11 +716,11 @@ class Class_SessionActivity_Article protected function _getRegistrationLimit($model) { - return $model->hasDateLimiteInscription() - ? $this->_getTerm($this->_('Date limite d\'inscription'), - $model->getDateLimiteInscriptionHumanRead(), - 'registration_limitdate') - : ''; + $limit = new Class_SessionActivity_SubscriptionLimit($model); + + return $this->_getTerm($limit->getTitle(), + $limit->getValue(), + 'registration_limitdate'); } @@ -754,4 +798,4 @@ class SessionActivity_MetaData { public function getValue() { return $this->_value; } -} \ No newline at end of file +} diff --git a/library/Class/SessionActivity/SubscriptionLimit.php b/library/Class/SessionActivity/SubscriptionLimit.php new file mode 100644 index 0000000000000000000000000000000000000000..73635c891a155350c235149434222f7610835f1b --- /dev/null +++ b/library/Class/SessionActivity/SubscriptionLimit.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright (c) 2012-2020, 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 Class_SessionActivity_SubscriptionLimit { + use Trait_Translator; + + protected $_session_activity; + + public function __construct($session_activity) { + $this->_session_activity = $session_activity; + } + + + public function getTitle() { + return $this->_session_activity->hasDateLimiteDebut() + ? $this->_('Date d\'inscription') + : $this->_('Date limite d\'inscription'); + } + + + public function getValue() { + $date_limit_end = $this->_session_activity->hasDateLimiteFin() + ? $this->_session_activity->getDateLimiteFinHumanRead() + : $this->_session_activity->getDateDebutTexte(); + + return $this->_session_activity->hasDateLimiteDebut() + ? $this->_('du %s au %s', + $this->_session_activity->getDateLimiteDebutHumanRead(), + $date_limit_end) + : $date_limit_end; + } +} diff --git a/library/Class/SessionActivityInscription.php b/library/Class/SessionActivityInscription.php index a819e359361591b52400303f8f822728f99e646d..a6de6e987bc3a683ab3039edc72051c9771a6541 100644 --- a/library/Class/SessionActivityInscription.php +++ b/library/Class/SessionActivityInscription.php @@ -63,7 +63,7 @@ class Class_SessionActivityInscriptionLoader extends Storm_Model_Loader { class Class_SessionActivityInscription extends Storm_Model_Abstract { - use Trait_Translator; + use Trait_Translator, Trait_CustomFields; protected $_table_name = 'session_activity_inscriptions', @@ -249,8 +249,8 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract { } - public function getDateLimiteInscriptionHumanRead() { - return $this->_getSessionAttribute('date_limite_inscription_human_read'); + public function getDateLimiteFinHumanRead() { + return $this->_getSessionAttribute('date_limite_fin_human_read'); } @@ -332,4 +332,4 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract { public function isWithoutQuotas() { return 0 == $this->getAdults() && 0 == $this->getChildren() && !$this->isNew(); } -} \ No newline at end of file +} diff --git a/library/Class/Systeme/ModulesAccueil/Action/AuthRegister.php b/library/Class/Systeme/ModulesAccueil/Action/AuthRegister.php new file mode 100644 index 0000000000000000000000000000000000000000..49b750793b8f092ed08319b184908d314fdcec2f --- /dev/null +++ b/library/Class/Systeme/ModulesAccueil/Action/AuthRegister.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright (c) 2021, 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 Class_Systeme_ModulesAccueil_Action_AuthRegister extends Class_Systeme_ModulesAccueil_Action { + + public function __construct() { + parent::__construct(); + $this->_form = ZendAfi_Form_Configuration_Widget_Action_AuthRegister::class; + } +} diff --git a/library/Class/Systeme/ModulesAppli.php b/library/Class/Systeme/ModulesAppli.php index e1968acc746d905c39dca58d13dd633cdf30ab72..381c7c2ba8a89d4e26ec6a01518142a95e1932b9 100644 --- a/library/Class/Systeme/ModulesAppli.php +++ b/library/Class/Systeme/ModulesAppli.php @@ -242,6 +242,7 @@ class Class_Systeme_ModulesAppli extends Class_Systeme_ModulesAbstract { } + public function acceptVisitor($visitor) { foreach ($this->_data as $actions) { foreach ($actions as $params) { @@ -256,4 +257,4 @@ class Class_Systeme_ModulesAppli extends Class_Systeme_ModulesAbstract { } } } -} \ No newline at end of file +} diff --git a/library/Class/Systeme/ModulesNotice.php b/library/Class/Systeme/ModulesNotice.php deleted file mode 100644 index e4af861d2d058472f8ddd87b8687055bc27263e8..0000000000000000000000000000000000000000 --- a/library/Class/Systeme/ModulesNotice.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php -/** - * Copyright (c) 2012, 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 Class_Systeme_ModulesNotice { - use Trait_Translator; - - const - GROUPED = 0, - ROW = 1; - - private $groupes = ["notice" => "Notices", - "auteur" => "Auteurs"]; - - private $modules = ["exemplaires" => ["libelle" => "Exemplaires", - "groupe" => "notice", - "popup_width" => 550, - "popup_height" => 480]]; - - public static function getDisplayGroups() { - $instance = new static(); - return [static::GROUPED => $instance->_('Grouper par bibliothèques et par cote'), - static::ROW => $instance->_('Afficher une ligne par exemplaire')]; - } - - - public static function getOrders() { - $instance = new static(); - $possibles = array_merge(range(0, 9), range('a', 'z')); - $multioptions = ['' => $instance->_('Par défaut')]; - - foreach($possibles as $possible) - $multioptions[$possible] = '995$' . $possible; - - return $multioptions; - } - - - public static function getOrderDirections() { - $instance = new static(); - return ['ASC' => $instance->_('Ascendant'), - 'DESC' => $instance->_('Descendant')]; - } - - - public static function getAvailableColumns() { - $instance = new static(); - return ['bib' => $instance->_('bibliothèque'), - 'annexe' => $instance->_('annexe'), - 'section' => $instance->_('section'), - 'emplacement' => $instance->_('emplacement'), - 'dispo' => $instance->_('disponibilité'), - 'date_retour' => $instance->_('date de retour'), - 'localisation' => $instance->_('localisation interne'), - 'plan' => $instance->_('plan d\'accès'), - 'resa' => $instance->_('réservation')]; - } - - - public function getModules() { - return $this->modules; - } - - - public function getModule($type) { - return ($module = $this->modules[$type]) ? - $module : false; - } - - - public function getValeursParDefaut($type) { - switch($type) { - case "bandeAnnonce": - return $this->getDefautBandeAnnonce(); - case "exemplaires": - return $this->getDefautExemplaires(); - default: - return []; - } - } - - - private function getDefautBandeAnnonce() { - return ['target' => '1', // Ouvrir dans un nouvel onglet ou pas - 'url' => 'https://google.fr', // Test de proprietes - ]; - } - - - private function getDefautExemplaires() { - return ['grouper' => '0', // Groupage - 'order_by' => '', // trié par (uniquement si non groupés) - 'order_direction' => 'ASC', // direction du tri (ASC/DESC) - 'bib' => '1', // Afficher la bibliotheque - 'section' => '0', // Afficher la section - 'emplacement' => '0', // Afficher l'emplacement - 'localisation' => '1', // Afficher lien vers la localisation sur le plan - 'plan' => '1', // Afficher lien vers google maps - 'resa' => '1', // Afficher le lien de réservation - 'en_pret' => 'emprunté', // Libéllé des exemplaires empruntés - 'dispo' => '1']; // Afficher la disponibilité - } -} \ No newline at end of file diff --git a/library/Class/Systeme/Widget/Action/AuthRegister.php b/library/Class/Systeme/Widget/Action/AuthRegister.php new file mode 100644 index 0000000000000000000000000000000000000000..8f321d48459cb20c9698a945fe0d0fdd38412218 --- /dev/null +++ b/library/Class/Systeme/Widget/Action/AuthRegister.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 Class_Systeme_Widget_Action_AuthRegister extends Class_Systeme_Widget_Action { + public function getResourcesDefinition() { + return (new Class_Systeme_ModulesAccueil_Action_AuthRegister); + } + + + public function _getTitle() { + return $this->_('Configuration de la page de demande d\'inscrption'); + } +} diff --git a/library/Class/Systeme/Widget/ActionLoader.php b/library/Class/Systeme/Widget/ActionLoader.php index 016fc2ffdb87d95df53c9e61fbab8495999c0d86..1b54e57f8d5d542a2358c702875385f8d28053a8 100644 --- a/library/Class/Systeme/Widget/ActionLoader.php +++ b/library/Class/Systeme/Widget/ActionLoader.php @@ -20,7 +20,9 @@ */ + class Class_Systeme_Widget_ActionLoader { + public function find($id) { $actions = $this->_getActions(); @@ -32,19 +34,33 @@ class Class_Systeme_Widget_ActionLoader { } - protected function _getActions() { - $record_action = 'Class_Systeme_Widget_Action_Record'; + public function actionsDo($callback) { + $profile_id = Class_Profil::getCurrentProfil()->getId(); + + foreach (array_keys($this->_getActions()) as $id) { + $action = $this->find($id); + $action->setProfileId($profile_id); + if ($widget = $action->load()) + $callback($id, $widget->getTitle()); + } - $actions = ['recherche_resultat_simple' => 'Class_Systeme_Widget_Action_SearchResult', - 'recherche_viewnotice' => 'Class_Systeme_Widget_Action_Record', - 'recherche_avancee' => 'Class_Systeme_Widget_Action_AdvancedSearch', - 'abonne_fiche' => 'Class_Systeme_Widget_Action_User', - 'author_view' => 'Class_Systeme_Widget_Action_Author', - 'bib_en-lire-plus' => 'Class_Systeme_Widget_Action_Library']; + return $this; + } + + + protected function _getActions() { + $actions = ['recherche_resultat_simple' => Class_Systeme_Widget_Action_SearchResult::class, + 'recherche_viewnotice' => Class_Systeme_Widget_Action_Record::class, + 'recherche_avancee' => Class_Systeme_Widget_Action_AdvancedSearch::class, + 'abonne_fiche' => Class_Systeme_Widget_Action_User::class, + 'author_view' => Class_Systeme_Widget_Action_Author::class, + 'bib_en-lire-plus' => Class_Systeme_Widget_Action_Library::class, + 'auth_register' => Class_Systeme_Widget_Action_AuthRegister::class + ]; foreach (Class_TypeDoc::findAll() as $doc_type) - $actions ['recherche_viewnotice_' . $doc_type->getId()] = $record_action; + $actions ['recherche_viewnotice_' . $doc_type->getId()] = Class_Systeme_Widget_Action_Record::class; return $actions; } -} \ No newline at end of file +} diff --git a/library/Class/TableDescription/SessionActivityInscriptions.php b/library/Class/TableDescription/SessionActivityInscriptions.php index 26d021090ae0c9a090e04662539aa1b4c40c9fd7..117630e085ceaf8fb60f517efe1cbedc0e20212c 100644 --- a/library/Class/TableDescription/SessionActivityInscriptions.php +++ b/library/Class/TableDescription/SessionActivityInscriptions.php @@ -27,6 +27,7 @@ class Class_TableDescription_SessionActivityInscriptions extends Class_TableDesc ->addColumn($this->_('Prénom'), 'prenom') ->addColumn($this->_('Identifiant'), 'login') ->addColumn($this->_('Email'), 'mail') + ->addColumn($this->_('Site d\'inscription'), 'libelle_bib') ->addColumn($this->_('Intervenant'), ['callback' => [$this, 'speakers']]) ->addColumn($this->_('Activité'), 'activity_label') diff --git a/library/Class/TableDescription/SessionActivityInscriptionsExport.php b/library/Class/TableDescription/SessionActivityInscriptionsExport.php index a21f9463407fb1995516533827dded3c78922f0a..3d72986284ac95ab52b94e45b294853dc5dc6fd9 100644 --- a/library/Class/TableDescription/SessionActivityInscriptionsExport.php +++ b/library/Class/TableDescription/SessionActivityInscriptionsExport.php @@ -22,7 +22,9 @@ class Class_TableDescription_SessionActivityInscriptionsExport extends Class_TableDescription { - protected $_age_child_max; + protected + $_age_child_max, + $_age_child_min; public function setAgeChildMax($age_child_max) { $this->_age_child_max = $age_child_max; @@ -30,6 +32,12 @@ class Class_TableDescription_SessionActivityInscriptionsExport extends Class_Tab } + public function setAgeChildMin($age_child_min) { + $this->_age_child_min = $age_child_min; + return $this; + } + + public function columnsCollect($callback) { if ($this->_columns->isEmpty()) $this->_initColumns(); @@ -52,8 +60,11 @@ class Class_TableDescription_SessionActivityInscriptionsExport extends Class_Tab protected function _getChildrenLabel() { - return $this->_age_child_max - ? $this->_('Enfants (âge max %s)', $this->_age_child_max) - : $this->_('Enfants'); + if (!$this->_age_child_max) + return $this->_('Enfants'); + + return $this->_age_child_min + ? $this->_('Enfants (âge compris entre %s et %s)', $this->_age_child_min, $this->_age_child_max) + : $this->_('Enfants (âge max %s)', $this->_age_child_max); } } diff --git a/library/Class/TableDescription/SessionActivityRegistrationOngoing.php b/library/Class/TableDescription/SessionActivityRegistrationOngoing.php index b731ef6c6c5f98a5eb28b9b520c5f92f9ac403c1..d09b4359095117a7c8ac05fa2ecbc26a5ac28874 100644 --- a/library/Class/TableDescription/SessionActivityRegistrationOngoing.php +++ b/library/Class/TableDescription/SessionActivityRegistrationOngoing.php @@ -27,10 +27,10 @@ class Class_TableDescription_SessionActivityRegistrationOngoing parent::_initDatas(); $this ->addColumn($this->_('Informations'), - function($model) + function($inscription) { - return $this->_('Date limite d\'inscription : %s', - $model->getDateLimiteInscriptionHumanRead()); + $limit = new Class_SessionActivity_SubscriptionLimit($inscription->getSessionActivity()); + return $limit->getTitle() . $limit->getValue(); }); return $this; diff --git a/library/Class/Template.php b/library/Class/Template.php index ac634587390c6bf4b2d82b999dd7be6d84665e6f..3e30bafdb4d3a31a9c18d39fcb816a4445a55316 100644 --- a/library/Class/Template.php +++ b/library/Class/Template.php @@ -652,4 +652,9 @@ class Class_Template { public function getRedirectActionFor($action) { return $action; } + + + public function allConfigurableScreensDo($callback_with_title_url) { + return $this; + } } diff --git a/library/Class/User/SessionActivity.php b/library/Class/User/SessionActivity.php index 7d67b0725a0a15cf10c038ee39a4919876dc9637..f74cb9b463e15fa5ae8e22b633dad946a5a3c7d0 100644 --- a/library/Class/User/SessionActivity.php +++ b/library/Class/User/SessionActivity.php @@ -81,6 +81,11 @@ class Class_User_SessionActivity { public function getAgeChildMax() { return $this->_session_activity->getAgeChildMax(); } + + + public function getAgeChildMin() { + return $this->_session_activity->getAgeChildMin(); + } } diff --git a/library/Class/WebService/SIGB/Exemplaire.php b/library/Class/WebService/SIGB/Exemplaire.php index f947e91d7d68a3a615a59a32e28c47ef36176eb2..74bbd3f4c74a5d69dec3778409f72efa21842af3 100644 --- a/library/Class/WebService/SIGB/Exemplaire.php +++ b/library/Class/WebService/SIGB/Exemplaire.php @@ -342,7 +342,9 @@ class Class_WebService_SIGB_Exemplaire { public function getLibelleDispoEnPret() { - return Class_Profil::getCurrentProfil()->getCfgNoticeAsArray()['exemplaires']['en_pret']; + return ($label = Class_Profil_ItemsSettings::current()->getCheckedOutLabel()) + ? $label + : $this->message('DISPO_EN_PRET'); } @@ -535,4 +537,4 @@ class Class_WebService_SIGB_Exemplaire { } } -?> \ No newline at end of file +?> diff --git a/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php b/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php index 18d9159e12f78f5b4db811d3e0eb5816c198464a..32294bc63c36a9a54386f65bc1f1e68c4460f80b 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php +++ b/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php @@ -20,12 +20,14 @@ */ + class ZendAfi_Controller_Plugin_Manager_AbonneSessionActivity extends ZendAfi_Controller_Plugin_Manager_SessionActivityInscriptionBasic { public function init() { parent::init(); - $this->_validators[] = '_sessionNotClosed'; + $this->_validators[] = '_sessionInscriptionNotClosed'; + $this->_validators[] = '_sessionInscriptionOpened'; $this->_user = Class_Users::getIdentity(); $this->_session_activity = Class_SessionActivity::find((int)$this->_getParam('id')); $this->_messages = new ZendAfi_Controller_Plugin_Manager_AbonneSessionActivityMessages; @@ -55,7 +57,7 @@ class ZendAfi_Controller_Plugin_Manager_AbonneSessionActivity protected function _initRedirect() { - $redirect_action = ['inscrire-session' => Class_Template::redirectActionFor('activities'), + $redirect_action = ['inscrire-session' => Class_Template::redirectActionFor('activities-registered'), 'edit-session' => Class_Template::redirectActionFor('edit-session')]; $this->_redirect_default_url = $this->_getParam('redirect_url', $this->_getReferer()); @@ -67,9 +69,8 @@ class ZendAfi_Controller_Plugin_Manager_AbonneSessionActivity }); if ($previous) - $this->_redirect_default_url = Class_Url::absolute(['controller' => 'abonne', - 'action' => $redirect_action[$previous]], - null, true); + $this->_redirect_default_url = Class_Url::relative(['controller' => 'abonne', + 'action' => $redirect_action[$previous]]); } @@ -80,7 +81,7 @@ class ZendAfi_Controller_Plugin_Manager_AbonneSessionActivity } - protected function _sessionNotClosed() { + protected function _sessionInscriptionNotClosed() { if (!$this->_session_activity->isInscriptionClosed()) return true; @@ -89,6 +90,16 @@ class ZendAfi_Controller_Plugin_Manager_AbonneSessionActivity } + protected function _sessionInscriptionOpened() { + if ($this->_session_activity->isInscriptionOpened()) + return true; + + $limit = new Class_SessionActivity_SubscriptionLimit($this->_session_activity); + $this->_add_message = $limit->getTitle() . ' : ' . $limit->getValue(); + return false; + } + + protected function _canEdit($model) { return parent::_canEdit($model) && $this->_user->getId() === $model->getStagiaireId(); diff --git a/library/ZendAfi/Controller/Plugin/Manager/SessionActivity.php b/library/ZendAfi/Controller/Plugin/Manager/SessionActivity.php index 0626c416951b6d7ba5da3b6e2354ca8123bb236a..3c5824be27a4ef9aefad020e87157a60787965d5 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/SessionActivity.php +++ b/library/ZendAfi/Controller/Plugin/Manager/SessionActivity.php @@ -25,10 +25,12 @@ class ZendAfi_Controller_Plugin_Manager_SessionActivity public function _getPost($key = null, $default = null) { $post = parent::_getPost($key, $default); - foreach(['date_debut', 'date_fin'] as $field) + foreach(['date_debut', 'date_fin', 'date_limite_debut', 'date_limite_fin'] as $field) $post[$field] = $this->_readPostActivityDate($this->_request->getPost($field)); - $post['date_limite_inscription'] = $this->_readPostDate($this->_request->getPost('date_limite_inscription')); + if (!$post['date_limite_fin']) + $post['date_limite_fin'] = $post['date_debut']; + return $post; } @@ -43,11 +45,6 @@ class ZendAfi_Controller_Plugin_Manager_SessionActivity } - protected function _readPostDate($date) { - return Class_Date::frToIso($date); - } - - public function addAction() { if (!$activity = Class_Activity::find($this->_getParam('activity_id'))) { $this->_redirect('admin/activity'); diff --git a/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscription.php b/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscription.php index c2c76ebd69e907aeea318398f94e81fc27e39811..c97fa4796ca82243c0e478129466759dc867483b 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscription.php +++ b/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscription.php @@ -69,8 +69,8 @@ class ZendAfi_Controller_Plugin_Manager_SessionActivityInscription } - protected function _getSuccessfulDeleteMessage() { - return $this->_('L\'utilisateur a bien été désinscrit'); + protected function _getSuccessfulDeleteMessage($model) { + return $this->_('Le participant a bien été désinscrit'); } @@ -80,7 +80,7 @@ class ZendAfi_Controller_Plugin_Manager_SessionActivityInscription } - protected function _getDoAfterDelete() { + protected function _getDoAfterDelete($model) { } diff --git a/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscriptionBasic.php b/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscriptionBasic.php index 59589fe62287fbaa8832af7c9aec0b7cf88617a5..76cee2bb5e3d5f91f1f5d79dfe634789724ac05d 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscriptionBasic.php +++ b/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscriptionBasic.php @@ -125,7 +125,7 @@ class ZendAfi_Controller_Plugin_Manager_SessionActivityInscriptionBasic protected function _userHasRight() { - if ($this->_user && $this->_user->hasRightSuivreActivity()) + if ($this->_session_activity->isUserCanSubscribe($this->_user)) return true; $this->_add_message = $this->_messages->noRight(); diff --git a/library/ZendAfi/Form.php b/library/ZendAfi/Form.php index ab255af92fd235d2b754de1b1654132a945a74c8..5a78bab1ad3c929ce4d12bb86dd44a4bde3e22cd 100644 --- a/library/ZendAfi/Form.php +++ b/library/ZendAfi/Form.php @@ -223,18 +223,18 @@ class ZendAfi_Form extends Zend_Form { } - public function addToDisplayGroup($elements, $name) { - if(!$group = $this->getDisplayGroup($name)) + public function addToDisplayGroup($element_names, $group_name) { + if(!$group = $this->getDisplayGroup($group_name)) return $this; $elements = array_map(function($element) { unset($this->_order[$element]); return $this->getElement($element); - }, $elements); + }, $element_names); $group->addElements($elements); - $this->_order[$name] = $this->_displayGroups[$name]->getOrder(); + $this->_order[$group_name] = $this->_displayGroups[$group_name]->getOrder(); $this->_orderUpdated = true; return $this; } @@ -402,4 +402,4 @@ class ZendAfi_Form extends Zend_Form { $this->setAttrib('id', $id); return $this; } -} \ No newline at end of file +} diff --git a/library/ZendAfi/Form/Admin/SessionActivity.php b/library/ZendAfi/Form/Admin/SessionActivity.php index 6195d41f33e9dfc72e8e85cf9240a7d54d23bdb1..2f74cbf3c327fb4025cf645232fcd33e99e7d5a2 100644 --- a/library/ZendAfi/Form/Admin/SessionActivity.php +++ b/library/ZendAfi/Form/Admin/SessionActivity.php @@ -64,11 +64,13 @@ class ZendAfi_Form_Admin_SessionActivity extends ZendAfi_Form { ->addElement('checkbox', 'all_day', ['label' => $this->_("L'activitée dure toute la journée")]) - ->addElement('datePicker', 'date_limite_inscription', - ['label' => $this->_('Date limite d\'inscription'), - 'size' => 10, - 'required' => true, - 'allowEmpty' => false]) + ->addElement('dateRangePicker', + 'activity_limit_range', + ['label' => $this->_("Date d'inscription"), + 'start' => ['name' => 'date_limite_debut', + 'dateOnly' => true], + 'end' => ['name' => 'date_limite_fin', + 'dateOnly' => true]]) ->addElement('text', 'duree', ['label' => $this->_('Durée (h)'), @@ -117,6 +119,16 @@ class ZendAfi_Form_Admin_SessionActivity extends ZendAfi_Form { 'bilan', ['legend' => $this->_('Compte-rendu')]) ; + + + if (Class_AdminVar::isActivityAllowSubscriptionsForAllEnabled()) { + $this->addElement('checkbox', + 'everybody_can_subscribe', + ['label' => $this->_('Ouvrir à tous les utilisateurs')]); + + $this->addToDisplayGroup(['everybody_can_subscribe'], + 'session'); + } } @@ -135,7 +147,7 @@ class ZendAfi_Form_Admin_SessionActivity extends ZendAfi_Form { protected function _addChildrenEffectifs() { $elements = ['activity_range', 'all_day', - 'date_limite_inscription', + 'activity_limit_range', 'effectif_min', 'effectif_max', 'lieu_id', @@ -154,11 +166,12 @@ class ZendAfi_Form_Admin_SessionActivity extends ZendAfi_Form { $this ->_addNumber('effectif_min', $this->_('Adultes minimum')) ->_addNumber('effectif_max', $this->_('Adultes maximum')) + ->_addNumber('effectif_inscription_max', $this->_('Adultes maximum par inscription')) ->_addNumber('effectif_child_min', $this->_('Enfants minimum')) ->_addNumber('effectif_child_max', $this->_('Enfants maximum')) - ->_addNumber('age_child_max', $this->_('Âge maximum des enfants')) - ->_addNumber('effectif_inscription_max', $this->_('Adultes maximum par inscription')) - ->_addNumber('effectif_inscription_child_max', $this->_('Enfants maximum par inscription')); + ->_addNumber('effectif_inscription_child_max', $this->_('Enfants maximum par inscription')) + ->_addNumber('age_child_min', $this->_('Âge minimum des enfants')) + ->_addNumber('age_child_max', $this->_('Âge maximum des enfants')); return array_filter($elements, function($item) @@ -172,11 +185,12 @@ class ZendAfi_Form_Admin_SessionActivity extends ZendAfi_Form { return Class_AdminVar::isActivitySessionQuotasEnabled() ? $this->addDisplayGroup(['effectif_min', 'effectif_max', + 'effectif_inscription_max', 'effectif_child_min', 'effectif_child_max', - 'age_child_max', - 'effectif_inscription_max', - 'effectif_inscription_child_max'], + 'effectif_inscription_child_max', + 'age_child_min', + 'age_child_max'], 'quotas', ['legend' => $this->_('Effectif')]) : $this; diff --git a/library/ZendAfi/Form/Configuration/Items.php b/library/ZendAfi/Form/Configuration/Items.php index e815a2fdcc671e54ab0918b4ae6051326601b85b..73a1dd1d29bbbc37f3f48991d045c1e3e1150426 100644 --- a/library/ZendAfi/Form/Configuration/Items.php +++ b/library/ZendAfi/Form/Configuration/Items.php @@ -21,6 +21,47 @@ class ZendAfi_Form_Configuration_Items extends ZendAfi_Form { + const + GROUPED = 0, + ROW = 1; + + public function getDisplayStyles() { + return [static::GROUPED => $this->_('Grouper par bibliothèques et par cote'), + static::ROW => $this->_('Afficher une ligne par exemplaire')]; + } + + + public function getOrders() { + $possibles = array_merge(range(0, 9), range('a', 'z')); + $multioptions = ['' => $this->_('Par défaut')]; + + foreach($possibles as $possible) + $multioptions[$possible] = '995$' . $possible; + + return $multioptions; + } + + + public function getOrderDirections() { + + return ['ASC' => $this->_('Ascendant'), + 'DESC' => $this->_('Descendant')]; + } + + + public function getAvailableColumns() { + return ['bib' => $this->_('bibliothèque'), + 'annexe' => $this->_('annexe'), + 'section' => $this->_('section'), + 'emplacement' => $this->_('emplacement'), + 'dispo' => $this->_('disponibilité'), + 'date_retour' => $this->_('date de retour'), + 'localisation' => $this->_('localisation interne'), + 'plan' => $this->_('plan d\'accès'), + 'resa' => $this->_('réservation')]; + } + + public function init() { Class_ScriptLoader::getInstance() ->addJQueryReady( @@ -31,17 +72,17 @@ class ZendAfi_Form_Configuration_Items extends ZendAfi_Form { ->addElement('select', 'grouper', ['label' => $this->_('Mode d\'affichage'), - 'multiOptions' => Class_Systeme_ModulesNotice::getDisplayGroups()]) + 'multiOptions' => $this->getDisplayStyles()]) ->addElement('select', 'order_by', ['label' => $this->_('Tri'), - 'multiOptions' => Class_Systeme_ModulesNotice::getOrders()]) + 'multiOptions' => $this->getOrders()]) ->addElement('select', 'order_direction', ['label' => $this->_('Direction du tri'), - 'multiOptions' => Class_Systeme_ModulesNotice::getOrderDirections()]) + 'multiOptions' => $this->getOrderDirections()]) ->addElement('text', 'en_pret', @@ -82,11 +123,11 @@ class ZendAfi_Form_Configuration_Items extends ZendAfi_Form { protected function _addColumns() { - foreach(Class_Systeme_ModulesNotice::getAvailableColumns() as $key => $label) + foreach($this->getAvailableColumns() as $key => $label) $this->addElement('checkbox', $key, ['label' => $label]); - return $this; + return $this; } } ?> diff --git a/library/ZendAfi/Form/Configuration/Widget/Action/AuthRegister.php b/library/ZendAfi/Form/Configuration/Widget/Action/AuthRegister.php new file mode 100644 index 0000000000000000000000000000000000000000..ebc67516a4fa23cf4bbd8b3faf5c099828181b18 --- /dev/null +++ b/library/ZendAfi/Form/Configuration/Widget/Action/AuthRegister.php @@ -0,0 +1,49 @@ +<?php +/** + * Copyright (c) 2012-2021, 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_Form_Configuration_Widget_Action_AuthRegister extends ZendAfi_Form_Configuration_Widget_Action { + + + public function init() { + parent::init(); + $this + ->setAttrib('id', 'auth_register_conf') + + ->addElement('text', 'titre', ['label' => $this->_('Titre'), + 'size' => 40]) + + ->addElement('textarea', 'register_help', ['label' => $this->_('Texte d\'aide'), + 'cols' => 70, + 'rows' => 5]) + + ->addElement('textarea', 'register_confirm', ['label' => $this->_('Texte de confirmation'), + 'cols' => 70, + 'rows' => 5]) + + ->addDisplayGroup(['titre', 'register_help', 'register_confirm'], + 'prefs', + ['legend' => $this->_('Préférences')]) + ; + + } + +} diff --git a/library/ZendAfi/Form/SessionActivityInscription.php b/library/ZendAfi/Form/SessionActivityInscription.php index 6b15526019405a9c7aa188464d9bec596ae2b54e..c8f35f77fdc5a4b4910cd7bd56252c3ca6b9b0a5 100644 --- a/library/ZendAfi/Form/SessionActivityInscription.php +++ b/library/ZendAfi/Form/SessionActivityInscription.php @@ -35,7 +35,6 @@ class ZendAfi_Form_SessionActivityInscription extends ZendAfi_Form { ['value' => 0, 'min' => 0, 'max' => 0]) - ->addUniqDisplayGroup('registration', ['legend' => $this->_('Participants')]); } @@ -47,15 +46,13 @@ class ZendAfi_Form_SessionActivityInscription extends ZendAfi_Form { $session = Class_User_SessionActivity::forUserIdAndSession($datas['stagiaire_id'], $session); - $session->isFullAdults() - ? $this->removeElement('adults') - : $this->getElement('adults') - ->setAttrib('max', $session->getNextAdultsMax()); + $this->getElement('adults') + ->setAttrib('max', $session->getNextAdultsMax()); + + $this->_updateAdultLabel($session); - $session->isFullChildren() - ? $this->removeElement('children') - : $this->getElement('children') - ->setAttrib('max', $session->getNextChildrenMax()); + $this->getElement('children') + ->setAttrib('max', $session->getNextChildrenMax()); $this->_updateChildrenlabel($session); @@ -63,11 +60,35 @@ class ZendAfi_Form_SessionActivityInscription extends ZendAfi_Form { } + protected function _updateAdultLabel($session) { + if ($session->isFullAdults()) + $this->getElement('adults') + ->setLabel((new Class_SessionActivityInscription_Messages)->noMoreAdultRoom()) + ->setAttrib('disabled', 'disabled'); + + return $this; + } + + protected function _updateChildrenlabel($session) { - if (!$element_children = $this->getElement('children')) - return; + $element_children = $this->getElement('children'); + + if ($session->isFullChildren()) { + $element_children + ->setLabel((new Class_SessionActivityInscription_Messages)->noMoreChildRoom()) + ->setAttrib('disabled', 'disabled'); + return $this; + } + + if ($session->getAgeChildMin()) { + $element_children->setLabel($this->_('Nombre d\'enfants (âge compris entre %s et %s)', + $session->getAgeChildMin(), + $session->getAgeChildMax())); + return $this; + } $element_children->setLabel($this->_('Nombre d\'enfants (âge max %s)', $session->getAgeChildMax())); + return $this; } } diff --git a/library/ZendAfi/View/Helper/Abonne/Activities.php b/library/ZendAfi/View/Helper/Abonne/Activities.php index b269cea3308939062e389a8aef4609d991841924..9acd4b31b15935d457d2716dd6fe74bd81a35061 100644 --- a/library/ZendAfi/View/Helper/Abonne/Activities.php +++ b/library/ZendAfi/View/Helper/Abonne/Activities.php @@ -54,7 +54,8 @@ class ZendAfi_View_Helper_Abonne_Activities extends ZendAfi_View_Helper_Abonne_A protected function _renderActivitySubscriber($user) { - return $user->hasRightSuivreActivity() + return ($user->hasRightSuivreActivity() + || Class_AdminVar::isActivityAllowSubscriptionsForAllEnabled()) ? ($this->view->tagAnchor($this->_activites_url, $this->_('S\'inscrire à une activité')) . $this->_renderSubscriptions()) @@ -74,4 +75,4 @@ class ZendAfi_View_Helper_Abonne_Activities extends ZendAfi_View_Helper_Abonne_A 'action' => 'activities-registered'], $this->_('Mes inscriptions en cours')))); } -} \ No newline at end of file +} diff --git a/library/ZendAfi/View/Helper/Abonne/AvailableActivities.php b/library/ZendAfi/View/Helper/Abonne/AvailableActivities.php index f4ba61ac119fc1f62ad1607e1cfa5252721dbb2b..e4a38642e0b5e579d88b7821badf90f8b0212a23 100644 --- a/library/ZendAfi/View/Helper/Abonne/AvailableActivities.php +++ b/library/ZendAfi/View/Helper/Abonne/AvailableActivities.php @@ -54,8 +54,7 @@ class ZendAfi_View_Helper_Abonne_AvailableActivities extends ZendAfi_View_Helper ->addColumn($this->_('Informations'), ['attribute' => 'infos', 'callback' => function($model) { - return $this->_('Date limite d\'inscription : %s', - $model->getDateLimiteInscriptionHumanRead()); + return $this->_getLimiteInscription($model); }]) ->addRowAction(function($model) { return $this->_actionsFor($model); }) ; @@ -68,6 +67,12 @@ class ZendAfi_View_Helper_Abonne_AvailableActivities extends ZendAfi_View_Helper } + protected function _getLimiteInscription($session) { + $limit = new Class_SessionActivity_SubscriptionLimit($session); + return $limit->getTitle() . ' : ' . $limit->getValue(); + } + + protected function _actionsFor($model) { $items = [['url' => $this->_details_link . '/id/%s?retour=' . $this->_current_link, 'icon' => 'view', diff --git a/library/ZendAfi/View/Helper/RenderSession.php b/library/ZendAfi/View/Helper/RenderSession.php index 2de6974c8eb4c0e4adbeffb15f0835584cb9e26e..a6e4398d3a9d7d9d10fad38f93e065dd9dba1572 100644 --- a/library/ZendAfi/View/Helper/RenderSession.php +++ b/library/ZendAfi/View/Helper/RenderSession.php @@ -35,6 +35,7 @@ class ZendAfi_View_Helper_RenderSession extends ZendAfi_View_Helper_BaseHelper { + class Render_Session { use Trait_Translator; @@ -49,6 +50,7 @@ class Render_Session { return $this->view->tag('span', $msg, ['class' => 'error']); } + public function displayCustomFields($session) { $html=''; foreach ($session->getAllCustomFields()->getFields() as $custom_field) { @@ -60,6 +62,36 @@ class Render_Session { return $html; } + + + protected function _sessionInformations($session) { + $html = $session->isAnnule() + ? $this->errorSpan($this->_('Annulée')) + : ''; + + $html .= $session->isDateSubscriptionExhausted() + ? $this->errorSpan($this->_('Date de limite d\'inscription dépassée : %s', + $session->getDateLimiteFinHumanRead())) + : $this->view->tag('span', $this->_getLimiteInscription($session)); + + $html .= $session->isFull() + ? $this->errorSpan($this->_('Complet: maximum de personnes inscrites')) + : ''; + + return $html; + } + + + protected function _getLimiteInscription($session) { + $limit = new Class_SessionActivity_SubscriptionLimit($session); + return $limit->getTitle() . ' : ' . $limit->getValue(); + } + + + protected function _getDisplayTitleValue($title, $value) { + return $this->view->tag('dt', $title) + . $this->view->tag('dd', $value); + } } @@ -67,7 +99,6 @@ class Render_Session { class Render_Session_Dl extends Render_Session { - public function render($session) { return $this->definitionListFor($session). $this->actionsFor($session); @@ -82,51 +113,43 @@ class Render_Session_Dl extends Render_Session { protected function definitionListFor($session) { - $html = - $this->view->tag('dt', $this->_('Informations')). - $this->view->tag('dd', - ($session->isFull() - ? $this->_('Complet ') - : '' ) - . - (!$session->isDateSubscriptionExhausted() - ? '' - : $this->_('Date de limite d\'inscription dépassée'))). - - $this->view->tag('dt', $this->_('Lieu')). - $this->view->tag('dd', $this->view->renderLieu($session->getLieu(), ['size' => '300x300'])). - - $this->view->tag('dt', $this->_('Date de limite d\'inscription')). - $this->view->tag('dd', $session->getDateLimiteInscriptionHumanRead()). - - $this->view->tag('dt', $this->_('Date de début')). - $this->view->tag('dd', $session->getDateDebutTexte()); - - if ($session->getDateFin() != '') { - $html .= $this->view->tag('dt', $this->_('Date de fin')). - $this->view->tag('dd', $session->getDateFinTexte()); + $html = $this->_getDisplayTitleValue($this->_('Informations'), + $this->_getInformations($session)); + + $html .= $this->_getDisplayTitleValue($this->_('Lieu'), + $this->view->renderLieu($session->getLieu(), + ['size' => '300x300'])); + + $html .= $this->_getLimiteInscription($session); + + $html .= $this->_getDisplayTitleValue($this->_('Date de début'), + $session->getDateDebutTexte()); + + if ($session->hasDateFin()) { + $html .= $this->_getDisplayTitleValue($this->_('Date de fin'), + $session->getDateFinTexte()); } - $html .= $this->view->tag('dt', $this->_('Horaires')). - $this->view->tag('dd', $session->getHoraires()). + $html .= $this->_getDisplayTitleValue($this->_('Horaires'), + $session->getHoraires()); - $this->view->tag('dt', $this->_('Durée de la session')). - $this->view->tag('dd', $session->getDuree() . ' h'). + $html .= $this->_getDisplayTitleValue($this->_('Durée de la session'), + $session->getDuree() . ' h'); - $this->view->tag('dt', $this->_('Nombre de participants')). - $this->view->tag('dd', sprintf('%s: %d, %s: %d, %s: %d', - $this->_('minimum'), - $session->getAttendeesMin(), - $this->_('maximum'), - $session->getAttendeesMax(), - $this->_('actuel'), - $session->numberOfAttendees())). + $html .= $this->_getDisplayTitleValue($this->_('Nombre de participants'), + sprintf('%s: %d, %s: %d, %s: %d', + $this->_('minimum'), + $session->getAttendeesMin(), + $this->_('maximum'), + $session->getAttendeesMax(), + $this->_('actuel'), + $session->numberOfAttendees())); - $this->view->tag('dt', $this->_('Intervenants')). - $this->view->tag('dd', $this->getIntervenantsFor($session)). + $html .= $this->_getDisplayTitleValue($this->_('Intervenants'), + $this->_getIntervenantsFor($session)); - $this->view->tag('dt', $this->_('Contenu')). - $this->view->tag('dd', $session->getContenu()); + $html .= $this->_getDisplayTitleValue($this->_('Contenu'), + $session->getContenu()); $html .= $this->displayCustomFields($session); @@ -134,7 +157,23 @@ class Render_Session_Dl extends Render_Session { } - protected function getIntervenantsFor($session) { + protected function _getInformations($session) { + return ($session->isFull() + ? $this->_('Complet ') + : '' ) + . (!$session->isDateSubscriptionExhausted() + ? '' + : $this->_('Date de limite d\'inscription dépassée')); + } + + + protected function _getLimiteInscription($session) { + $limit = new Class_SessionActivity_SubscriptionLimit($session); + return $this->_getDisplayTitleValue($limit->getTitle(), $limit->getValue()); + } + + + protected function _getIntervenantsFor($session) { $html = ''; foreach ($session->getIntervenants() as $intervenant){ $html.= $this->view->tag('li', $intervenant->getNom().', '.$intervenant->getPrenom()); @@ -149,7 +188,6 @@ class Render_Session_Dl extends Render_Session { class Render_Session_Table extends Render_Session { - public function render($session) { $html = $this->view->tag('td', $this->view->renderDateRange( $session->getDateDebut() , @@ -160,30 +198,10 @@ class Render_Session_Table extends Render_Session { 'id' => $session->getId()], $this->_('Détails de la session'))); $html.= $this->view->tag('td', $this->view->tagSessionActivityInscription($session)); - $html.= $this->view->tag('td', $this->sessionInformations($session)); + $html.= $this->view->tag('td', $this->_sessionInformations($session)); return $this->view->tag('tr', $html, ['class' => 'session']); } - - - protected function sessionInformations($session) { - $html = $session->isAnnule() - ? $this->errorSpan($this->_('Annulée')) - : ''; - $html.= $session->isDateSubscriptionExhausted() - ? $this->errorSpan( $this->_('Date de limite d\'inscription dépassée: '). - $session->getDateLimiteInscriptionHumanRead()) - : ($session->hasDateLimiteInscription() - ? $this->view->tag('span',$this->_('Date de limite d\'inscription: '). - $session->getDateLimiteInscriptionHumanRead()) - :''); - - $html.= $session->isFull() - ? $this->errorSpan($this->_('Complet: maximum de personnes inscrites')) - : ''; - - return $html; - } } @@ -192,7 +210,6 @@ class Render_Session_Table extends Render_Session { class Render_Session_Block extends Render_Session { public function render($session) { - $html = $this->view->tag('dt', $this->_('Date')) . $this->view->tag('dd', $this->view->renderDateRange( @@ -230,31 +247,11 @@ class Render_Session_Block extends Render_Session { $html .= $this->view->tag('dt', $this->_('Informations')) . - $this->view->tag('dd', $this->sessionInformations($session), + $this->view->tag('dd', $this->_sessionInformations($session), ['class' => 'training_informations']); $html .= $this->displayCustomFields($session); return $this->view->tag('dl', $html); } - - - protected function sessionInformations($session) { - $html = $session->isAnnule() - ? $this->errorSpan($this->_('Annulée')) - : ''; - $html.= $session->isDateSubscriptionExhausted() - ? $this->errorSpan( $this->_('Date de limite d\'inscription dépassée: '). - $session->getDateLimiteInscriptionHumanRead()) - : ($session->hasDateLimiteInscription() - ? $this->view->tag('span',$this->_('Date de limite d\'inscription: '). - $session->getDateLimiteInscriptionHumanRead()) - :''); - - $html.= $session->isFull() - ? $this->errorSpan($this->_('Complet: maximum de personnes inscrites')) - : ''; - - return $html; - } } diff --git a/library/ZendAfi/View/Helper/SessionActivityRegister.php b/library/ZendAfi/View/Helper/SessionActivityRegister.php index ccef2accf27024b4f9c115a7e0bfc835db5add07..c8336b27f16fcc0bfda3d6ceca18172f11037351 100644 --- a/library/ZendAfi/View/Helper/SessionActivityRegister.php +++ b/library/ZendAfi/View/Helper/SessionActivityRegister.php @@ -23,28 +23,13 @@ class ZendAfi_View_Helper_SessionActivityRegister extends ZendAfi_View_Helper_BaseHelper { protected $_session_activity, - $_form, - $_messages; + $_form; public function sessionActivityRegister($inscription, $form) { $this->_session_activity = Class_User_SessionActivity::forCurrentUser($inscription->getSessionActivity()); $this->_form = $form; - $this->_messages = new Class_SessionActivityInscription_Messages; - return $this->view->openBoiteContent($this->view->titre) - . $this->_renderNoRoom() - . $this->view->renderForm($form) - . $this->view->closeBoiteContent(); - } - - - protected function _renderNoRoom() { - if ($this->_session_activity->isFullAdults()) - return $this->_tag('span', $this->_messages->noMoreAdultRoom()); - - if ($this->_session_activity->isFullChildren()) - return $this->_tag('span', $this->_messages->noMoreChildRoom()); - - return ''; + return $this->view->openCloseBoite($this->view->titre, + $this->view->renderForm($form)); } } diff --git a/library/templates/Historic/Template.php b/library/templates/Historic/Template.php index 3092408eafd0c660ab56748c52a0adbbeeeeb50d..7a5b3f8e434e06aeb90803a397d0fe1c7e831df3 100644 --- a/library/templates/Historic/Template.php +++ b/library/templates/Historic/Template.php @@ -139,4 +139,33 @@ class Historic_Template extends Class_Template { ? 'activities-registered' : parent::getRedirectActionFor($action); } + + + + public function allConfigurableScreensDo($callback_with_title_url) { + $screens = [ + ['title' => $this->_('Recherche simple'), + 'url' => ['controller' => 'modules', + 'action' => 'recherche', + 'type_module' => 'recherche', + 'action1' => 'resultat', + 'action2' => 'simple'] ], + + + ['title' => $this->_('Recherche avancée'), + 'url' => ['controller' => 'modules', + 'action' => 'recherche', + 'type_module' => 'recherche', + 'action1' => 'avancee'] ] + ]; + + + foreach($screens as $screen) { + $screen['url']['module'] = 'admin'; + $screen['url']['id_profil'] = $this->_profile->getId(); + + $callback_with_title_url($screen['title'], $screen['url']); + } + return $this; + } } diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/SessionInscription.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/SessionInscription.php index 5a115967fff4fea17301659b807954fbb1d707c4..103c48cd0d7033539a546d597a37c557384a44b5 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/SessionInscription.php +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/SessionInscription.php @@ -23,12 +23,9 @@ class Intonation_Library_View_Wrapper_User_RichContent_SessionInscription extends Intonation_Library_View_Wrapper_User_RichContent_Agenda { - protected - $_form, - $_messages; + protected $_form; public function __construct() { - $this->_messages = new Class_SessionActivityInscription_Messages; } @@ -52,26 +49,6 @@ class Intonation_Library_View_Wrapper_User_RichContent_SessionInscription public function getContent() { - return - $this->_renderNoRoom() - . $this->_view->renderForm($this->_form); - } - - - protected function _renderNoRoom() { - if (!$session = $this->_model->getSessionActivity()) - return ''; - - $session = Class_User_SessionActivity::forCurrentUser($session); - - if ($session->isFullAdults()) - return $this->_div(['class' => 'alert alert-warning'], - $this->_messages->noMoreAdultRoom()); - - if ($session->isFullChildren()) - return $this->_div(['class' => 'alert alert-warning'], - $this->_messages->noMoreChildRoom()); - - return ''; + return $this->_view->renderForm($this->_form); } } diff --git a/library/templates/Intonation/Template.php b/library/templates/Intonation/Template.php index ce6d176231bd917e1161c227d6214acbe18ea9bc..3033fac6fd7c2ad7e796f0cb72327de017931514 100644 --- a/library/templates/Intonation/Template.php +++ b/library/templates/Intonation/Template.php @@ -420,6 +420,20 @@ class Intonation_Template extends Class_Template { } + public function allConfigurableScreensDo($callback_with_title_url) { + (new Class_Systeme_Widget_ActionLoader) + ->actionsDo(function ($id, $title) use ($callback_with_title_url) + { + $callback_with_title_url($title, + ['module' => 'admin', + 'controller' => 'widget', + 'action' => 'edit-action', + 'id' => $id, + 'id_profil' => $this->_profile->getId()]); + }); + } + + protected function _getMapWrapper() { return ['Class_Notice' => 'Intonation_Library_View_Wrapper_Record', 'Class_Bib' => 'Intonation_Library_View_Wrapper_Library']; diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index ea239221f106d18c800baf869b2f78ba6cc9b983..c7dbd393ab261254a944bcf9e0c46c07a416cb91 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -506,8 +506,14 @@ Error: ', public function assertRedirectTo($url, $message = '') { - $location = isset($this->response->getHeaders()[0]) - ? $this->response->getHeaders()[0]['value'] + $location_headers = array_values(array_filter($this->response->getHeaders(), + function($header) + { + return $header['name'] = 'Location'; + })); + + $location = isset($location_headers[0]) + ? $location_headers[0]['value'] : $this->_response->getBody(); return $message diff --git a/tests/application/modules/admin/controllers/ActivityControllerTest.php b/tests/application/modules/admin/controllers/ActivityControllerTest.php index f6ba0cde41ad0f459cffffb33900804556f4370b..91f8cd17b03fcb9a5e6a459bc4fa72950e35f8b7 100644 --- a/tests/application/modules/admin/controllers/ActivityControllerTest.php +++ b/tests/application/modules/admin/controllers/ActivityControllerTest.php @@ -95,7 +95,7 @@ abstract class Admin_ActivityControllerTestCase extends Admin_AbstractController $this->_session_python_juillet = $this->fixture('Class_SessionActivity', ['id'=> 121, 'date_debut' => '2009-07-21', - 'date_limite_inscription' => '2009-07-20', + 'date_limite_fin' => '2009-07-20', 'activity' => $this->_learn_python, 'contenu' => 'un contenu', 'stagiaires' => []]); @@ -124,7 +124,8 @@ abstract class Admin_ActivityControllerTestCase extends Admin_AbstractController 'contenu' => 'Intro à la syntaxe', 'horaires' => '9h - 12h, 13h - 18h', 'lieu' => $this->_salle_reunion, - 'date_limite_inscription'=>'2012-03-05', + 'date_limite_debut'=> '2012-03-05', + 'date_limite_fin'=> '2012-03-26', 'intervenants' => [$this->_prof_laurent], ]); @@ -132,7 +133,7 @@ abstract class Admin_ActivityControllerTestCase extends Admin_AbstractController ['id' => 31, 'activity' => $this->_learn_java, 'date_debut' => '2012-02-17', - 'date_limite_inscription' => '2012-02-16', + 'date_limite_fin' => '2012-02-16', 'date_fin' => '', 'effectif_min' => 1, 'effectif_max' => 10, @@ -157,6 +158,19 @@ abstract class Admin_ActivityControllerTestCase extends Admin_AbstractController 'stagiaire' => $this->_benoit, 'session_activity' => $this->_session_java_mars]); + $this->fixture('Class_CustomField_Meta', + ['id' => 1, + 'label' => 'Noms et prénoms', + 'field_type' => Class_CustomField_Meta::TEXT_AREA]); + + $this->fixture('Class_CustomField', + ['id' => 1, + 'meta_id' => 1, + 'priority' => 1, + 'model' => 'SessionActivityInscription']); + + $this->_benoit_inscription->setCustomField('Noms et prénoms', 'Tom et Jerry') + ->saveWithCustomFields(); $this->_benoit_inscription->beAbsent(); $this->_session_java_mars @@ -167,7 +181,6 @@ abstract class Admin_ActivityControllerTestCase extends Admin_AbstractController ['id' => 999, 'stagiaire_id' => 999, 'session_activity' => $this->_session_java_mars])]); - $this->fixture('Class_Activity', ['id' => 14, 'libelle' => 'Learn emptyness']); } @@ -822,8 +835,14 @@ class Admin_ActivityControllerEditSessionLearningJavaMars27Test /** @test */ - function inputDateLimiteInscriptionShouldContains05_03_2012() { - $this->assertXPath('//form[@id="sessionForm"]//input[@name="date_limite_inscription"][@value="05/03/2012"]'); + function inputDateLimiteDebutShouldContains05_03_2012() { + $this->assertXPath('//form[@id="sessionForm"]//input[@name="date_limite_debut"][@value="05/03/2012"]'); + } + + + /** @test */ + function inputDateLimiteFinShouldContains26_03_2012() { + $this->assertXPath('//form[@id="sessionForm"]//input[@name="date_limite_fin"][@value="26/03/2012"]'); } @@ -981,14 +1000,14 @@ class Admin_ActivityControllerSessionDefaultYearSelectionTest extends Admin_Act ['id' => 144, 'activity_id' => 12, 'date_debut' => '2010-03-21', - 'date_limite_inscription' => '2010-03-20', + 'date_limite_fin' => '2010-03-20', 'stagiaires' => []]); $this->fixture('Class_SessionActivity', ['id' => 148, 'activity_id' => 12, 'date_debut' => '2012-06-21', - 'date_limite_inscription' => '2012-06-20', + 'date_limite_fin' => '2012-06-20', 'stagiaires' => [] ]); @@ -1028,7 +1047,7 @@ class Admin_ActivityControllerSessionLearnPythonTest extends Admin_ActivityCont ['id' => 144, 'activity_id' => 12, 'date_debut' => '2009-03-21', - 'date_limite_inscription' => '2009-03-20', + 'date_limite_fin' => '2009-03-20', 'stagiaires' => [] ]); } @@ -1070,41 +1089,43 @@ class Admin_ActivityControllerSessionLearnPythonTest extends Admin_ActivityCont class Admin_ActivityControllerPostSessionLearnJavaTest extends Admin_ActivityControllerTestCase { - protected $_session, $_article; + protected + $_session_post, + $_article; public function setUp() { parent::setUp(); $this->postDispatch('/admin/session-activity/edit/id/32', ['date_debut' => '29/05/2012', - 'date_limite_inscription' => '03/05/2012', + 'date_limite_fin' => '03/05/2012', 'effectif_min' => '1', 'effectif_max' => '8', 'horaires' => '9h - 18h', 'lieu_id' => 18, 'is_annule' => '1']); - $this->_session = Class_SessionActivity::find(32); - $this->_article = $this->_session->getArticle(); + $this->_session_post = Class_SessionActivity::find(32); + $this->_article = $this->_session_post->getArticle(); } /** @test */ public function sessionShouldBeValid() { - $this->assertTrue($this->_session->isValid(), - implode(',', $this->_session->getErrors())); + $this->assertTrue($this->_session_post->isValid(), + implode(',', $this->_session_post->getErrors())); } /** @test */ public function dateDebutShouldBe2012_05_29() { - $this->assertEquals('2012-05-29', $this->_session->getDateDebut()); + $this->assertEquals('2012-05-29', $this->_session_post->getDateDebut()); } /** @test */ - public function dateLimiteInscriptionShouldBe2012_05_03() { - $this->assertEquals('2012-05-03', $this->_session->getDateLimiteInscription()); + public function dateLimiteFinShouldBe2012_05_03() { + $this->assertEquals('2012-05-03', $this->_session_post->getDateLimiteFin()); } @@ -1116,19 +1137,19 @@ class Admin_ActivityControllerPostSessionLearnJavaTest extends Admin_ActivityCon /** @test */ public function effectifMaxShouldBeHeight() { - $this->assertEquals(8, $this->_session->getEffectifMax()); + $this->assertEquals(8, $this->_session_post->getEffectifMax()); } /** @test */ public function horairesShouldBe9h18h() { - $this->assertEquals('9h - 18h', $this->_session->getHoraires()); + $this->assertEquals('9h - 18h', $this->_session_post->getHoraires()); } /** @test */ public function lieuShouldEqualsAuCafeDuCoin() { - $this->assertEquals('Au café du coin', $this->_session->getLieu()->getLibelle()); + $this->assertEquals('Au café du coin', $this->_session_post->getLieu()->getLibelle()); } @@ -1146,7 +1167,38 @@ class Admin_ActivityControllerPostSessionLearnJavaTest extends Admin_ActivityCon /** @test */ public function sessionShouldBeAnnule() { - $this->assertTrue($this->_session->isAnnule()); + $this->assertTrue($this->_session_post->isAnnule()); + } +} + + + + +class Admin_ActivityControllerPostSessionLearnJavaWithoutLimiteFinTest + extends Admin_ActivityControllerTestCase { + + protected + $_session_post, + $_article; + + public function setUp() { + parent::setUp(); + + $this->postDispatch('/admin/session-activity/edit/id/32', + ['date_debut' => '29/05/2012', + 'effectif_min' => '1', + 'effectif_max' => '8', + 'horaires' => '9h - 18h', + 'lieu_id' => 18, + 'is_annule' => '1']); + + $this->_session_post = Class_SessionActivity::find(32); + } + + + /** @test */ + public function dateLimiteFinShouldBe2012_05_29() { + $this->assertEquals('2012-05-29', $this->_session_post->getDateLimiteFin()); } } @@ -1162,7 +1214,7 @@ class Admin_ActivityControllerPostSessionLearnJavaWithInvalidDataTest array('date_debut' => '', 'effectif_min' => 20, 'effectif_max' => 4, - 'date_limite_inscription' => '05/01/2022')); + 'date_limite_fin' => '05/01/2022')); } @@ -1331,7 +1383,7 @@ class Admin_ActivityControllerPostAddSessionToActivityLearningPythonTest $this->postDispatch('/admin/session-activity/add/activity_id/12', ['date_debut' => '17/02/2010', 'date_fin' => '17/02/2010', - 'date_limite_inscription' => '10/02/2010', + 'date_limite_fin' => '10/02/2010', 'effectif_min' => '3', 'effectif_max' => '12', 'contenu' => 'On charme les serpents', @@ -1680,8 +1732,9 @@ abstract class ActivityControllerImpressionsTestCase extends Admin_ActivityContr </p> <p> - {session_activity.stagiaires["Nom":nom, "Prénom":prenom, "Signature"]} + {session_activity.session_activity_inscriptions["Nom":nom, "Prénom":prenom, "Téléphone":stagiaire.telephone, "inscrits":all_custom_fields.field_value_1]} </p> + </div>']); $modele_lettre_convocation = $this->fixture('Class_ModeleFusion', @@ -1699,7 +1752,9 @@ abstract class ActivityControllerImpressionsTestCase extends Admin_ActivityContr 'nom' =>'ACTIVITY_LISTE_STAGIAIRES', 'contenu' => '<h1>Liste des stagiaires pour la session du {session_activity.date_debut_texte} au {session_activity.date_fin_texte}</h1> <h2>{session_activity.activity.libelle}</h2> - {session_activity.stagiaires["Nom":nom, "Prénom":prenom, "Bibliothèque":bib.libelle, "Téléphone":telephone]}']); + {session_activity.stagiaires["Nom":nom, "Prénom":prenom, "Bibliothèque":bib.libelle, "Téléphone":telephone]} + +']); $modele_lettre_attestation = $this->fixture('Class_ModeleFusion', @@ -1900,6 +1955,12 @@ class ActivityControllerFicheEmargementSessionJavaMarsTest extends ActivityContr public function pageShouldContainsLettreFor29Mars() { $this->assertXPathContentContains('//div[@class="lettre_fusion"]//div[5]//p', '29 mars 2012', $this->_response->getBody()); } + + + /** @test */ + public function pageShouldContainsTableWithTomAndJerry() { + $this->assertXPathContentContains('//table//td', 'Tom et Jerry', $this->_response->getBody()); + } } @@ -2099,6 +2160,55 @@ class Admin_ActivityControllerLinkedArticleWithoutArticleActionTest $this->assertContains('Here you will learn some old and boring stuff', $this->_linked_article->getContenu()); } + + + /** @test */ + public function linkedArticleContenuShouldContainsActivityLimiteFin() { + $this->assertContains('<dt class="registration_limitdate">Date d\'inscription</dt><dd class="registration_limitdate">du 05 mars 2012 au 26 mars 2012</dd>', + $this->_linked_article->getContenu()); + } +} + + + + +class Admin_ActivityControllerLinkedArticleWithoutLimiteInscriptionActionTest + extends Admin_ActivityControllerLinkedArticleTestCase { + + protected function _updateModels() { + $this->_session_java_mars + ->setDateLimiteFin('') + ->setDateLimiteDebut('') + ->save(); + } + + + /** @test */ + public function linkedArticleContenuShouldContainsActivityLimiteFin() { + $this->assertContains('<dt class="registration_limitdate">Date limite d\'inscription</dt><dd class="registration_limitdate">27 mars 2012</dd>', + $this->_linked_article->getContenu()); + } +} + + + + +class Admin_ActivityControllerLinkedArticleWithLimiteInscriptionActionTest + extends Admin_ActivityControllerLinkedArticleTestCase { + + protected function _updateModels() { + $this->_session_java_mars + ->setDateLimiteFin('2012-03-12') + ->setDateLimiteDebut('2012-03-01') + ->save(); + } + + + /** @test */ + public function linkedArticleContenuShouldContainsActivityLimiteDebutEtFin() { + $this->assertContains('<dt class="registration_limitdate">Date d\'inscription</dt><dd class="registration_limitdate">du 01 mars 2012 au 12 mars 2012</dd>', + $this->_linked_article->getContenu()); + } } @@ -2202,11 +2312,11 @@ abstract class Admin_ActivityControllerDownloadActivitiesTestCase public function csvLines() { - return [['Nom;Prénom;Identifiant;Email;Intervenant;Activité;Session;"Date début";Lieu'], - ['Curzillat;Benoit;Benoit;;;"Learn Java";"Learn Java, 17 février 2012";17/02/2012', 'Salle reunion AFI'], - ['Barroca;Patrick;Pat;user@server.org;"Laurent Laffont";"Learn Java";"Learn Java, 27 mars 2012";27/03/2012'], - ['Curzillat;Benoit;Benoit;;"Laurent Laffont";"Learn Java";"Learn Java, 27 mars 2012";27/03/2012','Salle reunion AFI'], - ['Anonyme;;n/a;;"Laurent Laffont";"Learn Java";"Learn Java, 27 mars 2012";27/03/2012', 'Salle reunion AFI'], + return [['Nom;Prénom;Identifiant;Email;"Site d\'inscription";Intervenant;Activité;Session;"Date début";Lieu'], + ['Curzillat;Benoit;Benoit;;;;"Learn Java";"Learn Java, 17 février 2012";17/02/2012', 'Salle reunion AFI'], + ['Barroca;Patrick;Pat;user@server.org;Annecy;"Laurent Laffont";"Learn Java";"Learn Java, 27 mars 2012";27/03/2012'], + ['Curzillat;Benoit;Benoit;;;"Laurent Laffont";"Learn Java";"Learn Java, 27 mars 2012";27/03/2012','Salle reunion AFI'], + ['Anonyme;;n/a;;;"Laurent Laffont";"Learn Java";"Learn Java, 27 mars 2012";27/03/2012', 'Salle reunion AFI'], ]; } @@ -2242,4 +2352,4 @@ class Admin_ActivityControllerDownloadActivitiesWithoutYearTest parent::setUp(); $this->dispatch('/admin/activity/download/format/csv'); } -} \ No newline at end of file +} diff --git a/tests/application/modules/admin/controllers/CustomFieldsControllerTest.php b/tests/application/modules/admin/controllers/CustomFieldsControllerTest.php index 808685846133a6c4a0c0b82cf18f299b1d5a9e34..fcfaca9e94367e6eee8565e6c60e2a49e9072196 100644 --- a/tests/application/modules/admin/controllers/CustomFieldsControllerTest.php +++ b/tests/application/modules/admin/controllers/CustomFieldsControllerTest.php @@ -122,9 +122,10 @@ class CustomFieldsControllerIndexTest extends CustomFieldControllerTestCase { public function customFieldsCategories() { - return [ ['Article', 'Article' ], - ['Activity', 'Activity'], - ['UserGroup', "Groupe d'utilisateurs"]]; + return [['Article', 'Article' ], + ['Activity', 'Activity'], + ['UserGroup', "Groupe d'utilisateurs"], + ['SessionActivityInscription', 'Inscription aux activités']]; } @@ -759,4 +760,4 @@ class CustomFieldsControllerValuesForInexistingActivityTest extends CustomFieldC $this->assertRedirectTo('/admin/activity/edit/id/232', $this->getResponseLocation()); } } -?> \ No newline at end of file +?> diff --git a/tests/application/modules/admin/controllers/ProfilControllerTest.php b/tests/application/modules/admin/controllers/ProfilControllerTest.php index 5f2c8c721e487555a07dd01c8ad5f4d71aa8de9b..d077c458fbe80a3d4638675f82e8bb267759e7bd 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerTest.php @@ -1735,4 +1735,32 @@ class ProfilControllerDispatchReferencementProfilTest extends Admin_AbstractCont public function refTagsShouldContainsMaster() { $this->assertXPathContentContains('//textarea[@name="ref_tags"]', 'master'); } -} \ No newline at end of file +} + + + + +class Admin_ProfilControllerProfilJeunesseProprietesActionTest extends Admin_ProfilControllerProfilJeunesseTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/profil/proprietes/id_profil/5'); + } + + + /** @test */ + public function pageShouldLinkToModuleNoticeExemplaires() { + $this->assertXPath('//a[@href="/admin/modulesnotice/exemplaires/id_profil/5"]'); + } + + + /** @test */ + public function pageShouldContainsLinkToEditModuleRechercheAvancee() { + $this->assertXPath('//a[@href="/admin/modules/recherche/type_module/recherche/action1/avancee/id_profil/5"]'); + } + + + /** @test */ + public function pageShouldContainsLinkToEditModuleRechercheSimple() { + $this->assertXPath('//a[@href="/admin/modules/recherche/type_module/recherche/action1/resultat/action2/simple/id_profil/5"]'); + } +} diff --git a/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerTest.php b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerTest.php index 7180c847cd8d4736517f36d9492386975e2a27a3..1b7870d3da76c928d563ee51e9d0b563eb61018f 100644 --- a/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerTest.php +++ b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerTest.php @@ -293,6 +293,6 @@ class Admin_SessionActivityInscriptionControllerUnsubscribePatSessionMarsJavaTes /** @test */ public function removableShouldBeNotified() { - $this->assertFlashMessengerContentContains('L\'utilisateur a bien été désinscrit'); + $this->assertFlashMessengerContentContains('Le participant a bien été désinscrit'); } } \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/AbonneControllerActivitiesTest.php b/tests/application/modules/opac/controllers/AbonneControllerActivitiesTest.php index 2a220bdbd9728ac1a88e2408abfdbf4b4169bf6d..c90320f1cd6f748aac3044b7fecfb3b5dd5fc740 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerActivitiesTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerActivitiesTest.php @@ -106,7 +106,7 @@ abstract class AbstractAbonneControllerActivitiesTestCase 'lieu' => $this->_gallice_cafe, 'date_debut' => '2015-01-10', 'date_fin' => '2015-01-10', - 'date_limite_inscription' => '2015-01-10', + 'date_limite_fin' => '2015-01-10', 'stagiaires' => []]); $this->_session_smalltalk_juillet = $this @@ -119,7 +119,7 @@ abstract class AbstractAbonneControllerActivitiesTestCase 'stagiaires' => [], 'date_debut' => '2014-07-11', 'date_fin' => '2014-07-15', - 'date_limite_inscription' => '2014-07-11']); + 'date_limite_fin' => '2014-07-11']); $this->_learn_smalltalk ->setSessions([$this->_session_smalltalk_janvier, @@ -142,7 +142,7 @@ abstract class AbstractAbonneControllerActivitiesTestCase 'date_debut' => '2015-02-10', 'date_fin' => '2015-02-20', 'stagiaires' => [], - 'date_limite_inscription' => '2015-01-20']); + 'date_limite_fin' => '2015-01-20']); $this->_session_java_fevrier->setArticle($this->fixture('Class_Article', ['id' => 10, @@ -162,7 +162,7 @@ abstract class AbstractAbonneControllerActivitiesTestCase 'lieu' => $this->_gallice_cafe, 'date_debut' => '2015-03-01', 'stagiaires' => [], - 'date_limite_inscription' => '2015-03-01']); + 'date_limite_fin' => '2015-03-01']); $this->_session_java_septembre = $this->fixture('Class_SessionActivity', ['id' => 30, @@ -173,7 +173,7 @@ abstract class AbstractAbonneControllerActivitiesTestCase 'date_fin' => '2014-09-10', 'stagiaires' => [], 'lieu' => $this->_gallice_cafe, - 'date_limite_inscription' => '2014-09-10']); + 'date_limite_fin' => '2014-09-10']); $this->_session_java_septembre->beAnnule(); $this->_learn_java @@ -193,7 +193,7 @@ abstract class AbstractAbonneControllerActivitiesTestCase 'activity' => $this->_learn_python, 'date_debut' => '2014-07-10', 'date_fin' => '2014-07-14', - 'date_limite_inscription' => '2014-04-29', + 'date_limite_fin' => '2014-04-29', 'contenu' => 'Introduction a la syntaxe', 'objectif' => 'Ecrire un premier programme', 'effectif_min' => 1, @@ -316,6 +316,16 @@ class AbonneControllerActivitiesListTest extends AbstractAbonneControllerActivit Class_Profil::newInstanceWithId(42, ['cfg_modules' => ['abonne' => ['activities' => ['barre_nav' => 'Les activities']]]])); + $this->_session_smalltalk_janvier + ->setDateLimiteDebut('2014-04-01') + ->setdateLimiteFin('2014-07-08') + ->assertSave(); + + $this->_session_smalltalk_juillet + ->setDateLimiteDebut('2014-07-01') + ->setdateLimiteFin('2014-07-08') + ->assertSave(); + $this->_session_python_juillet ->show() ->assertSave(); @@ -354,6 +364,12 @@ class AbonneControllerActivitiesListTest extends AbstractAbonneControllerActivit } + /** @test */ + function session_juillet_smalltalk_ShouldNotHaveLinkForInscrireAsSessionNotOpened() { + $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/12")]'); + } + + /** @test */ function session_juillet_smalltalk_ShouldNotDisplayLimiteAsNotSet() { $this->assertNotXPathContentContains('//td[@class="session_12"]', 'Limite:'); @@ -362,13 +378,13 @@ class AbonneControllerActivitiesListTest extends AbstractAbonneControllerActivit /** @test */ function sessionJanuary2015ShouldBeFirst() { - $this->assertXPathContentContains('//tr[2]//td', '10 janvier 2015'); + $this->assertXPathContentContains('//tr[1]//td', '10 janvier 2015'); } /** @test */ - function sessionMarsShouldBeFirst() { - $this->assertXPathContentContains('//tr[4]//td', '1 mars 2015'); + function sessionMarsShouldBeThird() { + $this->assertXPathContentContains('//tr[3]//td', '1 mars 2015'); } @@ -379,8 +395,8 @@ class AbonneControllerActivitiesListTest extends AbstractAbonneControllerActivit /** @test */ - function sessionFebruary2015ShouldBeLast() { - $this->assertXPathContentContains('//tbody//tr[3]//td', ' février 2015'); + function sessionFebruary2015ShouldBeSecond() { + $this->assertXPathContentContains('//tbody//tr[2]//td', ' février 2015'); } @@ -391,8 +407,8 @@ class AbonneControllerActivitiesListTest extends AbstractAbonneControllerActivit /** @test */ - function session11Juillet2014ShouldBePresend() { - $this->assertXPathContentContains('//tr//td', '11 juillet 2014'); + function session10Janvier2015ShouldBePresend() { + $this->assertXPathContentContains('//tr//td', '10 janvier 2015'); } @@ -410,9 +426,15 @@ class AbonneControllerActivitiesListTest extends AbstractAbonneControllerActivit /** @test */ - function session_fevrier_17_ShouldDisplayDateLimite15Fevrier() { + function session_fevrier_17_ShouldDisplayDateLimite20Janvier() { $this->assertXPathContentContains('//tbody//tr/td', - '20 janvier 2015'); + 'Date limite d\'inscription : 20 janvier 2015'); + } + + + /** @test */ + public function sessionSmalltalkJanvierShouldDisplayDateLimiteDebutEtFin() { + $this->assertXPathContentContains('//tbody//tr/td', 'Date d\'inscription : du 01 avril 2014 au 08 juillet 2014'); } @@ -622,7 +644,7 @@ class AbonneControllerActivitiesDoneActionTest parent::setUp(); $this->_session_python_juillet ->setDateDebut('2006-09-09') - ->setDateLimiteInscription('2006-09-01') + ->setDateLimiteFin('2006-09-01') ->assertSave(); $this->dispatch('/abonne/activities-done', true); @@ -699,12 +721,13 @@ class AbonneControllerActivitiesListWithoutRightSuivreActivityTest extends Abstr -class AbonneControllerActivitiesAmadouInscritSessionMarsJavaClosedTest extends AbstractAbonneControllerActivitiesTestCase { +class AbonneControllerActivitiesAmadouInscritSessionMarsJavaClosedTest + extends AbstractAbonneControllerActivitiesTestCase { public function setUp() { parent::setUp(); $this->_session_java_mars ->setDateDebut('2014-03-01') - ->setDateLimiteInscription('2014-03-01') + ->setDateLimiteFin('2014-03-01') ->assertSave(); $this->dispatch('/opac/abonne/inscrire-session/id/32'); } @@ -712,7 +735,8 @@ class AbonneControllerActivitiesAmadouInscritSessionMarsJavaClosedTest extends A /** @test */ public function inscrireSessionShouldNotCallSave() { - $this->assertNotContains($this->_amadou, Class_SessionActivityInscription::findAllBy(['session_activity_id'=>32])); + $this->assertEmpty(Class_SessionActivityInscription::findAllBy(['session_activity_id' => 32, + 'stagiaire_id' => $this->_amadou->getId()])); } @@ -726,11 +750,47 @@ class AbonneControllerActivitiesAmadouInscritSessionMarsJavaClosedTest extends A public function notificationShouldContainsSessionClosed() { $this->assertFlashMessengerContentContains('cette session est fermée'); } +} + + + + +class AbonneControllerActivitiesAmadouInscritSessionMarsJavaNotOpenTest + extends AbstractAbonneControllerActivitiesTestCase { + + public function setUp() { + parent::setUp(); + $this->_session_java_mars + ->setDateDebut('2014-06-01') + ->setDateLimiteFin('2014-06-01') + ->setDateLimiteDebut('2014-05-15') + ->assertSave(); + $this->dispatch('/opac/abonne/inscrire-session/id/32'); + } + + + /** @test */ + public function inscrireSessionShouldNotCallSave() { + $this->assertEmpty(Class_SessionActivityInscription::findAllBy(['session_activity_id' => 32, + 'stagiaire_id' => $this->_amadou->getId()])); + } + + /** @test */ + public function responseShouldRedirectToActivities() { + $this->assertRedirectTo('/activities'); + } + + + /** @test */ + public function notificationShouldContainsSessionNotOpen() { + $this->assertFlashMessengerContentContains('Date d\'inscription : du 15 mai 2014 au 01 juin 2014'); + } } + class AbonneControllerActivitiesAmadouInscritSessionFebruaryJavaOpenTest extends AbstractAbonneControllerActivitiesTestCase { protected $_mails; @@ -1028,7 +1088,7 @@ class AbonneControllerActivitiesInscriptionRedirectionTest extends AbstractAbonn /** @test */ public function redirectOnAbonnePagesIfNoRedirectUrl() { - $this->assertRedirectTo(Class_Url::absolute('/abonne/activities')); + $this->assertRedirectTo('/abonne/activities-registered'); } @@ -1269,4 +1329,4 @@ class AbonneControllerActivitiesWrongIdsTest extends AbstractAbonneControllerAct $this->dispatch('/opac/abonne/desinscrire-session/id/9999'); $this->assertRedirectTo('/abonne/activities'); } -} \ No newline at end of file +} diff --git a/tests/application/modules/opac/controllers/ActivitiesControllerTest.php b/tests/application/modules/opac/controllers/ActivitiesControllerTest.php index b6b9b194b855dd70dd519cf2d6d6fd0f570acaef..2c5c031f45fbb1c96c67aa69b73db1df7738e0a7 100644 --- a/tests/application/modules/opac/controllers/ActivitiesControllerTest.php +++ b/tests/application/modules/opac/controllers/ActivitiesControllerTest.php @@ -20,6 +20,7 @@ */ abstract class AbstractActivitiesControllerTestCase extends AbstractControllerTestCase { + public function setup() { parent::setup(); @@ -37,7 +38,7 @@ abstract class AbstractActivitiesControllerTestCase extends AbstractControllerTe ['id' => 1, 'activity' => $activity, 'date_debut' => '2014-07-10', - 'date_limite_inscription' => '2014-07-01', + 'date_limite_fin' => '2014-07-01', 'effectif_min' => 1, 'effectif_max' => 1, 'stagiaires' => []]); @@ -46,7 +47,7 @@ abstract class AbstractActivitiesControllerTestCase extends AbstractControllerTe ['id' => 1, 'activity' => $activity, 'date_debut' => '2014-07-10', - 'date_limite_inscription' => '2014-07-01', + 'date_limite_fin' => '2014-07-01', 'effectif_min' => 1, 'effectif_max' => 10, 'stagiaires' => []]); @@ -71,13 +72,13 @@ abstract class AbstractActivitiesControllerTestCase extends AbstractControllerTe 'date_debut' => '2015-02-10', 'date_fin' => '2015-02-20', 'stagiaires' => [], - 'date_limite_inscription' => '2015-01-20']); + 'date_limite_fin' => '2015-01-20']); $session_subscription_exhausted = $this->fixture('Class_SessionActivity', ['id' => 1, 'activity' => $activity, 'date_debut' => '2014-07-10', - 'date_limite_inscription' => '2014-01-10', + 'date_limite_fin' => '2014-01-10', 'effectif_min' => 1, 'effectif_max' => 10, 'stagiaires' => []]); @@ -94,10 +95,12 @@ abstract class AbstractActivitiesControllerTestCase extends AbstractControllerTe -class ActivitiesControllerActivitiesSessionFevrierJavaTest extends AbstractActivitiesControllerTestCase { +class ActivitiesControllerActivitiesSessionFevrierJavaTest + extends AbstractActivitiesControllerTestCase { + public function setUp() { parent::setUp(); - $this->dispatch('/opac/activities/detail-session/id/31', true); + $this->dispatch('/opac/activities/detail-session/id/31'); } @@ -131,6 +134,53 @@ class ActivitiesControllerActivitiesSessionFevrierJavaTest extends AbstractActiv +class ActivitiesControllerActivitiesSessionFevrierJavaLimiteInscriptionTest + extends AbstractActivitiesControllerTestCase { + + public function setUp() { + parent::setUp(); + } + + + /** @test */ + public function ddShouldContainsDateLimiteFin() { + Class_SessionActivity::find(31) + ->setDateLimiteDebut('') + ->setDateLimiteFin('') + ->save(); + $this->dispatch('/opac/activities/detail-session/id/31'); + $this->assertContains('<dt>Date limite d\'inscription</dt><dd>10 février 2015</dd>', + $this->_response->getBody()); + } + + + /** @test */ + public function ddShouldContainsDateLimiteDebut01_02_2015EtFin10_02_2015() { + Class_SessionActivity::find(31) + ->setDateLimiteDebut('2015-02-01') + ->setDateLimiteFin('') + ->save(); + $this->dispatch('/opac/activities/detail-session/id/31'); + $this->assertContains('<dt>Date d\'inscription</dt><dd>du 01 février 2015 au 10 février 2015</dd>', + $this->_response->getBody()); + } + + + /** @test */ + public function ddShouldContainsDateLimiteDebut01_02_2015EtFin09_02_2015() { + Class_SessionActivity::find(31) + ->setDateLimiteDebut('2015-02-01') + ->setDateLimiteFin('2015-02-09') + ->save(); + $this->dispatch('/opac/activities/detail-session/id/31'); + $this->assertContains('<dt>Date d\'inscription</dt><dd>du 01 février 2015 au 09 février 2015</dd>', + $this->_response->getBody()); + } +} + + + + class ActivitiesControllerAnonymousTest extends AbstractActivitiesControllerTestCase { public function setUp() { parent::setUp(); @@ -141,7 +191,7 @@ class ActivitiesControllerAnonymousTest extends AbstractActivitiesControllerTest /** @test */ public function sessionShouldDisplaySubscribeTime() { $this->assertXPathContentContains('//tbody//tr/td/span', - 'Date de limite d\'inscription:'); + 'Date limite d\'inscription :'); } } @@ -158,4 +208,4 @@ class ActivitiesControllerActivitiesSessionJuilletPythonDetailRetourFicheTest ex public function pageShouldContainsAButtontoGoBackToFicheAbonne() { $this->assertXPathContentContains('//a[contains(@href, "abonne/fiche")]', 'Retour', $this->_response->getBody()); } -} \ No newline at end of file +} diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerPergameTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerPergameTest.php index 10a7b8eb8e2f947e571484e972100f3725e4e6e0..28ca59b2a9960adbe58a03aaa05a3dd7fdf94ab8 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerPergameTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerPergameTest.php @@ -92,8 +92,7 @@ class NoticeAjaxControllerPergameItemNoDefaultLabelTest /** @test */ public function availabilityLabelShouldBeEmprunte() { $this->assertXPathContentContains('//td[contains(@class, "dispo")]', - 'emprunt', - $this->_response->getBody()); + utf8_encode('En prêt')); } } diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index 536b4bd457d6e44dc6ee01a5920070543046485f..01f749a69cb719e76ba668421e0245e066e380f9 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -2172,7 +2172,7 @@ class ProfilOptionsControllerWithActivityWidgetAndNoLoggedUserTest extends Abstr 'contenu' => 'dogfighting tricks', 'date_debut' => '2014-05-02', 'date_fin' => '2014-05-30', - 'date_limite_inscription' => '2011-01-01', + 'date_limite_fin' => '2011-01-01', 'stagiaires' => [], 'effectif_max' => 0, 'effectif_min' => 0])]) @@ -2188,7 +2188,7 @@ class ProfilOptionsControllerWithActivityWidgetAndNoLoggedUserTest extends Abstr 'contenu' => 'dogfighting aim', 'date_debut' => '2014-05-10', 'date_fin' => '2014-05-30', - 'date_limite_inscription' => '2014-05-08', + 'date_limite_fin' => '2014-05-08', 'stagiaires' => [], 'effectif_max' => 10, 'effectif_min' => 1])]) @@ -2274,7 +2274,7 @@ class ProfilOptionsControllerWithActivityExpiredTest extends AbstractControllerT 'objectif' => 'dogfighting tricks', 'date_debut' => '2014-05-02', 'date_fin' => '2014-05-30', - 'date_limite_inscription' => '2014-04-30', + 'date_limite_fin' => '2014-04-30', 'stagiaires' => [], 'effectif_max' => 0, 'effectif_min' => 0])]) diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index d02ba956e8265778f2a80f807476cee857b8b6a7..79645272b510634388b16fae9d3ce9c95553b8a6 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -2433,7 +2433,7 @@ class UpgradeDB_361_Test extends UpgradeDBTestCase { /** @test */ public function idOrigineLengthShouldBe255() { - $this->assertFieldType('album','id_origine', 'varchar(255)'); + $this->assertFieldType('album','id_origine', 'varchar(255)'); } } @@ -3119,9 +3119,9 @@ class UpgradeDB_384_Test extends UpgradeDBTestCase { $this->assertEquals('2004-11-23',current($this->query("select naissance from bib_admin_users where nom='testupgrade384_bidulo4'")->fetch())); - } + } - /** @test */ + /** @test */ public function withNaissanceDateShouldSetNaissanceToDate() { $this->assertEquals('2004-11-23',current($this->query("select naissance from bib_admin_users where nom='testupgrade384_bidulo3'")->fetch())); } @@ -3663,3 +3663,38 @@ class UpgradeDB_402_Test extends UpgradeDBTestCase { $this->assertFieldType('harvest_log', 'type_doc', 'varchar(255)'); } } + + + + +class UpgradeDB_403_Test extends UpgradeDBTestCase { + public function prepare() { + $this->dropFieldFrom('session_activity', 'everybody_can_subscribe'); + $this->dropFieldFrom('session_activity', 'date_limite_debut'); + $this->dropFieldFrom('session_activity', 'age_child_min'); + $this->silentQuery('ALTER TABLE `session_activity` CHANGE `date_limite_fin` `date_limite_inscription` date NOT NULL'); + } + + + /** @test */ + public function sessionActivityShouldContainsColumnEverybodyCanSubscribeBoolean() { + $this->assertFieldType('session_activity', 'everybody_can_subscribe', 'tinyint(1)'); + } + + + /** @test */ + public function sessionActivityShouldContainsAgeChildMinColumn() { + $this->assertFieldType('session_activity', 'age_child_min', 'int(11) unsigned'); + } + + /** @test */ + public function sessionActivityShouldContainsColumnDateLimiteDebutAsDate() { + $this->assertFieldType('session_activity', 'date_limite_debut', 'date'); + } + + + /** @test */ + public function sessionActivityShouldContainsColumnDateLimiteFinAsDate() { + $this->assertFieldType('session_activity', 'date_limite_fin', 'date'); + } +} diff --git a/tests/library/Class/ActivityTest.php b/tests/library/Class/ActivityTest.php index 04c14b435a03966ec1571e83e2abb2ab072c03b1..de06b0370264bf905ddbbc5b44029756764cb843 100644 --- a/tests/library/Class/ActivityTest.php +++ b/tests/library/Class/ActivityTest.php @@ -71,7 +71,7 @@ class ActivitySmalltalkWithTwoSessionsTest extends ModelTestCase { ->setActivityId(3) ->setDateDebut('2009-01-05') ->setDateFin('2009-01-07') - ->setDateLimiteInscription('0000-00-00') + ->setDateLimiteFin('0000-00-00') ->setEffectifMin(1) ->setEffectifMax(3) ->setLieuId(74), @@ -141,8 +141,8 @@ class ActivitySmalltalkWithTwoSessionsTest extends ModelTestCase { /** @test */ - public function sessionJanvierDateLimiteInscriptionShouldReturnNull() { - $this->assertEquals(null, $this->_session_janvier->getDateLimiteInscription()); + public function sessionJanvierDateLimiteFinShouldReturnNull() { + $this->assertEquals(null, $this->_session_janvier->getDateLimiteFin()); } @@ -153,8 +153,8 @@ class ActivitySmalltalkWithTwoSessionsTest extends ModelTestCase { /** @test */ - public function sessionJanvierHasDateLimiteInscriptionShouldReturnFalse() { - $this->assertFalse($this->_session_janvier->hasDateLimiteInscription()); + public function sessionJanvierHasDateLimiteFinShouldReturnFalse() { + $this->assertFalse($this->_session_janvier->hasDateLimiteFin()); } @@ -206,7 +206,7 @@ class ActivitySmalltalkWithTwoSessionsTest extends ModelTestCase { /** @test */ public function sessionJanvierShouldBeValid() { $this->_session_janvier - ->setDateLimiteInscription('2009-01-04') + ->setDateLimiteFin('2009-01-04') ->assertSave(); $this->assertTrue($this->_session_janvier->isValid(), implode(',', $this->_session_janvier->getErrors())); diff --git a/tests/library/ZendAfi/View/Helper/Accueil/ActivitiesWidgetTest.php b/tests/library/ZendAfi/View/Helper/Accueil/ActivitiesWidgetTest.php index e8f1ba9fcce78b867803dc814bbbefb0d15c99de..9f747bc598390c6a35db7eb9b8d863883e1acf35 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/ActivitiesWidgetTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/ActivitiesWidgetTest.php @@ -98,14 +98,14 @@ class ZendAfi_View_Helper_Accueil_ActivitiesWidgetWithLoggedSIGBUserTest extends $activity->setSessions([$this->fixture('Class_SessionActivity', ['id' => 2, 'activity' => $activity, - 'date_limite_inscription' => '2014-06-01', + 'date_limite_fin' => '2014-06-01', 'date_debut' => '2014-06-02', 'date_fin' => '2014-06-10']), $this->fixture('Class_SessionActivity', ['id' => 1, 'activity' => $activity, - 'date_limite_inscription' => '2014-06-01', + 'date_limite_fin' => '2014-06-01', 'date_debut' => '2014-06-01', 'date_fin' => '2014-06-10'])]) ->assertSave(); @@ -157,7 +157,7 @@ class ZendAfi_View_Helper_Accueil_ActivitiesWidgetWithDateSubscriptionPastTest e 'activity' => $activity, 'date_debut' => '2014-06-01', 'date_fin' => '2014-06-10', - 'date_limite_inscription' => '2014-01-01'])]) + 'date_limite_fin' => '2014-01-01'])]) ->assertSave(); $this->renderWidget( @@ -190,7 +190,7 @@ class ZendAfi_View_Helper_Accueil_ActivitiesWidgetWithNoLoggedUserTest extends Z ['id' => 1, 'activity' => $activity, 'date_debut' => '2014-06-01', - 'date_limite_inscription' => '2014-05-01', + 'date_limite_fin' => '2014-05-01', 'date_fin' => '2014-06-10'])]) ->assertSave(); @@ -223,7 +223,7 @@ class ZendAfi_View_Helper_Accueil_ActivitiesWidgetWithInvisibleActivityTest exte ['id' => 1, 'activity' => $activity, 'date_debut' => '2014-06-01', - 'date_limite_inscription' => '2014-05-01', + 'date_limite_fin' => '2014-05-01', 'date_fin' => '2014-06-10'])]) ->assertSave(); @@ -257,7 +257,7 @@ class ZendAfi_View_Helper_Accueil_ActivitiesWidgetWithDeletedActivitiesInPrefere ['id' => 1, 'activity' => $activity, 'date_debut' => '2014-06-01', - 'date_limite_inscription' => '2014-05-01', + 'date_limite_fin' => '2014-05-01', 'date_fin' => '2014-06-10'])]) ->assertSave(); @@ -327,14 +327,14 @@ class ZendAfi_View_Helper_Accueil_SortAndDisplayActivitiesWidgetTest ['id' => $id+1, 'activity' => $activity, 'date_debut' => $date_session.'-01', - 'date_limite_inscription' => $date_session.'-01', + 'date_limite_fin' => $date_session.'-01', 'date_fin' => $date_session.'-04']), $this->fixture('Class_SessionActivity', ['id' => $id+2, 'activity' => $activity, 'date_debut' => $date_session2.'-08', - 'date_limite_inscription' => $date_session2 . '-08']) + 'date_limite_fin' => $date_session2 . '-08']) ]) ->assertSave(); diff --git a/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php b/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php index 5a16dfddb49fc3bee03e7755c67919e1cbc30515..e8ead610f535a9d029d827f052b02e879e1ed68b 100644 --- a/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php +++ b/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php @@ -109,7 +109,7 @@ abstract class AbonneControllerWithQuotasTestCase extends AbstractControllerTest 'lieu' => $this->_gallice_cafe, 'date_debut' => '2015-01-10', 'date_fin' => '2015-01-10', - 'date_limite_inscription' => '2015-01-10', + 'date_limite_fin' => '2015-01-10', 'stagiaires' => []]); $this->_session_smalltalk_juillet = $this @@ -123,7 +123,7 @@ abstract class AbonneControllerWithQuotasTestCase extends AbstractControllerTest 'stagiaires' => [], 'date_debut' => '2014-07-11', 'date_fin' => '2014-07-15', - 'date_limite_inscription' => '2014-07-11']); + 'date_limite_fin' => '2014-07-11']); $this->_learn_smalltalk ->setSessions([$this->_session_smalltalk_janvier, @@ -147,7 +147,7 @@ abstract class AbonneControllerWithQuotasTestCase extends AbstractControllerTest 'date_debut' => '2015-02-10', 'date_fin' => '2015-02-20', 'stagiaires' => [], - 'date_limite_inscription' => '2015-01-20']); + 'date_limite_fin' => '2015-01-20']); $this->_session_java_fevrier->setArticle($this->fixture('Class_Article', ['id' => 10, @@ -168,7 +168,7 @@ abstract class AbonneControllerWithQuotasTestCase extends AbstractControllerTest 'lieu' => $this->_gallice_cafe, 'date_debut' => '2015-03-01', 'stagiaires' => [], - 'date_limite_inscription' => '2015-03-01']); + 'date_limite_fin' => '2015-03-01']); $this->_session_java_septembre = $this->fixture('Class_SessionActivity', ['id' => 30, @@ -180,7 +180,7 @@ abstract class AbonneControllerWithQuotasTestCase extends AbstractControllerTest 'date_fin' => '2014-09-10', 'stagiaires' => [], 'lieu' => $this->_gallice_cafe, - 'date_limite_inscription' => '2014-09-10']); + 'date_limite_fin' => '2014-09-10']); $this->_session_java_septembre->beAnnule(); $this->_learn_java @@ -200,7 +200,7 @@ abstract class AbonneControllerWithQuotasTestCase extends AbstractControllerTest 'activity' => $this->_learn_python, 'date_debut' => '2014-07-10', 'date_fin' => '2014-07-14', - 'date_limite_inscription' => '2014-04-29', + 'date_limite_fin' => '2014-04-29', 'contenu' => 'Introduction a la syntaxe', 'objectif' => 'Ecrire un premier programme', 'effectif_min' => 1, @@ -243,6 +243,18 @@ abstract class AbonneControllerWithQuotasTestCase extends AbstractControllerTest 'children' => 1]); $this->_amadou->setSessionActivityInscriptions([$inscription_amadou_python]); + + + $this->fixture('Class_CustomField_Meta', + ['id' => 1, + 'label' => 'Noms et prénoms', + 'field_type' => Class_CustomField_Meta::TEXT_AREA]); + + $this->fixture('Class_CustomField', + ['id' => 1, + 'meta_id' => 1, + 'priority' => 1, + 'model' => 'SessionActivityInscription']); } } @@ -335,6 +347,12 @@ class Activities_AbonneControllerWithQuotasEditSessionActionTest public function inputChildrenShouldHaveValueOneAndMaxTwelve() { $this->assertXPath('//input[@name="children"][@value="1"][@max="12"]'); } + + + /** @test */ + public function formShouldContainsTextAreaForCustomFieldOne() { + $this->assertXPath('//textarea[@id="field_1"]'); + } } @@ -426,7 +444,8 @@ class Activities_AbonneControllerWithQuotasRegisterSessionTest ->setEffectifMax(5) ->setEffectifChildMax(15) ->setEffectifInscriptionMax(5) - ->setEffectifInscriptionChildMax(15); + ->setEffectifInscriptionChildMax(15) + ->setAgeChildMax(12); $inscription = Class_SessionActivityInscription::newInstance(['session_activity_id' => 31, 'adults' => 1, @@ -458,6 +477,55 @@ class Activities_AbonneControllerWithQuotasRegisterSessionTest +class Activities_AbonneControllerWithQuotasOpenSessionSubscriptionWithoutRigthsTest + extends AbonneControllerWithQuotasTestCase { + + public function setUp() { + parent::setUp(); + $katsiana = $this->fixture(Class_Users::class, + ['id' => 4, + 'login' => 'katsiana', + 'password' => 'ilovecats']); + ZendAfi_Auth::getInstance()->logUser($katsiana); + + Class_AdminVar::set('ACTIVITY_ALLOW_SUBSCRIPTIONS_FOR_ALL', 1); + Class_SessionActivity::find(31)->setEverybodyCanSubscribe(true) + ->assertSave(); + } + + + /** @test */ + public function withoutRigthSuivreActivityShouldBeAbleToRegisterSessionsOpenedToEverybody() { + $this->dispatch('/opac/abonne/inscrire-session/id/31'); + $this->assertXPath('//form[@action="/abonne/inscrire-session/id/31"]'); + } + + + /** @test */ + public function disblingAdminVarAllowSubscriptionsForAllShouldPreventFromSubscribing() { + Class_AdminVar::set('ACTIVITY_ALLOW_SUBSCRIPTIONS_FOR_ALL', 0); + $this->dispatch('/opac/abonne/inscrire-session/id/31'); + $this->assertFlashMessengerContentContains('Vous n\'avez pas les droits'); + } + + + /** @test */ + public function pageAbonneActivitiesShouldContainsSessionLearnJava() { + $this->dispatch('/opac/abonne/activities/'); + $this->assertXPath('//table[@id="available_sessions"]//td[text()="Learn Java"]'); + } + + + /** @test */ + public function pageAbonneFicheShouldContainsLinkToAbonneActivities() { + $this->dispatch('/opac/abonne/fiche'); + $this->assertXPath('//a[@class="formations activities"][@href="/abonne/activities"]'); + } +} + + + + abstract class AbonneControllerWithQuotasRegisterSessionPostTestCase extends AbonneControllerWithQuotasTestCase { @@ -496,7 +564,8 @@ class Activities_AbonneControllerWithQuotasRegisterSessionPostTest ->setEffectifMax(10) ->setEffectifChildMax(20) ->setEffectifInscriptionMax(5) - ->setEffectifInscriptionChildMax(15); + ->setEffectifInscriptionChildMax(15) + ->setAgeChildMax(12); $this->_postAdultsAndChildren(1, 3); } @@ -543,6 +612,25 @@ class Activities_AbonneControllerWithQuotasRegisterSessionPostTest +class Activities_AbonneControllerWithQuotasRegisterPostFromPageInscrireSessionTest + extends AbonneControllerWithQuotasRegisterSessionPostTestCase { + + public function setUp() { + parent::setUp(); + $_SERVER['HTTP_REFERER'] = '/abonne/inscrire-session/id/31'; + $this->_postAdultsAndChildren(1, 0); + } + + + /** @test */ + public function responseShouldRedirectToActivitiesRegistered() { + $this->assertRedirectTo('/abonne/activities-registered'); + } +} + + + + class Activities_AbonneControllerWithQuotasRegisterSessionZerosPostTest extends AbonneControllerWithQuotasRegisterSessionPostTestCase { @@ -552,7 +640,8 @@ class Activities_AbonneControllerWithQuotasRegisterSessionZerosPostTest ->setEffectifMax(10) ->setEffectifChildMax(20) ->setEffectifInscriptionMax(5) - ->setEffectifInscriptionChildMax(15); + ->setEffectifInscriptionChildMax(15) + ->setAgeChildMax(12); $this->_postAdultsAndChildren(0, 0); } @@ -576,7 +665,8 @@ class Activities_AbonneControllerWithQuotasRegisterSessionMaxQuotasErrosPostTest ->setEffectifInscriptionMax(1) ->setEffectifInscriptionChildMax(2) ->setEffectifMax(10) - ->setEffectifChildMax(20); + ->setEffectifChildMax(20) + ->setAgeChildMax(12); $this->_postAdultsAndChildren(2, 3); } @@ -663,10 +753,12 @@ class Activities_AbonneControllerWithQuotasRegisterSessionWithNoMoreAdultsPostTe public function setUp() { parent::setUp(); $this->_session_java_fevrier + ->setEffectifMin(1) ->setEffectifInscriptionMax(1) ->setEffectifInscriptionChildMax(2) ->setEffectifMax(1) - ->setEffectifChildMax(2); + ->setEffectifChildMax(2) + ->setAgeChildMax(12); $this->_alreadyRegisteredAdultsAndChildren(1, 1) ->_postAdultsAndChildren(1, 2); @@ -674,14 +766,14 @@ class Activities_AbonneControllerWithQuotasRegisterSessionWithNoMoreAdultsPostTe /** @test */ - public function pageShouldContainsNoMoreAdultsRoom() { - $this->assertXPathContentContains('//span', 'Aucune place adulte disponible'); + public function inputAdultLabelShouldContainsNoMoreAdultsRoom() { + $this->assertXPathContentContains('//label[@for="adults"]', 'Aucune place adulte disponible'); } /** @test */ - public function inputAdultsShouldNotDisplay() { - $this->assertNotXPath('//input[@name="adults"]'); + public function inputAdultsShouldBeDisabled() { + $this->assertXPath('//input[@name="adults"][@disabled="disabled"]'); } @@ -709,7 +801,8 @@ class Activities_AbonneControllerWithQuotasRegisterSessionWithNoMoreChildrenPost ->setEffectifInscriptionMax(2) ->setEffectifInscriptionChildMax(3) ->setEffectifMax(2) - ->setEffectifChildMax(3); + ->setEffectifChildMax(3) + ->setAgeChildMax(12); $this->_alreadyRegisteredAdultsAndChildren(1, 3) ->_postAdultsAndChildren(2, 2); @@ -717,14 +810,14 @@ class Activities_AbonneControllerWithQuotasRegisterSessionWithNoMoreChildrenPost /** @test */ - public function pageShouldContainsNoMoreChildrenRoom() { - $this->assertXPathContentContains('//span', 'Aucune place enfant disponible'); + public function inputChildrenLabelShouldContainsNoMoreChildrenRoom() { + $this->assertXPathContentContains('//label[@for="children"]', 'Aucune place enfant disponible'); } /** @test */ - public function inputChildrenShouldNotDisplay() { - $this->assertNotXPath('//input[@name="children"]'); + public function inputChildrenShouldBeDisabled() { + $this->assertXPath('//input[@name="children"][@disabled="disabled"]'); } diff --git a/tests/scenarios/Activities/AdminControllerWithQuotasTest.php b/tests/scenarios/Activities/AdminControllerWithQuotasTest.php index ba87312794057089eb838bfa8709a1ff26cd237a..5af316a5cd8d43b615448a3269667d287b9d9a51 100644 --- a/tests/scenarios/Activities/AdminControllerWithQuotasTest.php +++ b/tests/scenarios/Activities/AdminControllerWithQuotasTest.php @@ -206,12 +206,13 @@ class Activities_AdminControllerWithQuotasInscriptionLegacyTest -class Activities_AdminControllerWithQuotasInscriptionOngletEffectifTest +class Activities_AdminControllerWithQuotasInputFieldsTest extends AdminControllerWithQuotasTestCase { + public function setUp() { parent::setUp(); - $this->dispatch('/admin/session-activity/inscriptions/id/32/search_session_activity_subscription_status/all'); + $this->dispatch('/admin/session-activity/edit/id/32'); } @@ -222,7 +223,8 @@ class Activities_AdminControllerWithQuotasInscriptionOngletEffectifTest ['effectif_child_max'], ['effectif_inscription_max'], ['effectif_inscription_child_max'], - ['age_child_max']]; + ['age_child_max'], + ['age_child_min']]; } @@ -230,11 +232,59 @@ class Activities_AdminControllerWithQuotasInscriptionOngletEffectifTest * @test * @dataProvider quotasElements */ - public function withQuotasFormShouldContainsElement($element) { - $this->dispatch('/admin/session-activity/edit/id/32'); + public function formShouldContainsQuotasElement($element) { $this->assertXPath('//fieldset[@id="fieldset-quotas"]//input[@name="' . $element . '"][@required="required"][@type="number"][@min="0"]'); } + + + /** @test */ + public function formShouldNotContainsInputEverybodyCanSubscribe() { + $this->assertNotXPath('//input[@name="everybody_can_subscribe"]'); + } +} + + + + +class Activities_AdminControllerWithQuotasAndACTIVITY_ALLOW_SUBSCRIPTIONS_FOR_ALLTest + extends AdminControllerWithQuotasTestCase { + + public function setUp() { + parent::setUp(); + Class_AdminVar::set('ACTIVITY_ALLOW_SUBSCRIPTIONS_FOR_ALL', 1); + } + + + /** @test */ + public function formShouldContainsInputEverybodyCanSubscribeInFieldSetSessionDefaultUnchecked() { + $this->dispatch('/admin/session-activity/edit/id/32'); + $this->assertXPath('//fieldset[@id="fieldset-session"]//input[@name="everybody_can_subscribe"][not(@checked)]'); + } + + + /** @test */ + public function postEverybody_can_subscribeWithValueOneShouldSaveItInSession() { + $this->postDispatch('/admin/session-activity/edit/id/32', + ['everybody_can_subscribe' => '1']); + + $this->assertTrue(Class_SessionActivity::find(32)->isEverybodyCanSubscribe()); + } + + + /** @test */ + public function sessionWhereEverybodyCanSubscribeShouldNotDisplayWarningMessageOnStagiaireWithoutRight() { + $katsiana = $this->fixture(Class_Users::class, + ['id' => 4, + 'login' => 'katsiana', + 'password' => 'ilovecats']); + Class_SessionActivity::find(32) + ->setEverybodyCanSubscribe(true) + ->addStagiaire($katsiana) + ->assertSave(); + $this->dispatch('/admin/session-activity/edit/id/32'); + $this->assertNotXPath('//div[contains(@class, "activities")]//div[@class="error"]'); + } } @@ -311,6 +361,17 @@ class Activities_AdminControllerWithQuotasInscriptionInvalidPostTest } + /** @test */ + public function pageShouldContainsAgeChildMinMustBeLowerThanAgeChildMax() { + $this->postDispatch('admin/session-activity/edit/id/32', ['effectif_inscription_child_max' => 5, + 'effectif_child_max' => 10, + 'age_child_max' => 10, + 'age_child_min' => 12]); + $this->assertXPathContentContains('//ul[@class="errors"]', + 'L\'âge minimum doit être inférieur à l\'âge maximum pour les enfants'); + } + + /** @test */ public function pageShouldContainsInscriptionMaxAdultesRequired() { $this->postDispatch('/admin/session-activity/edit/id/32', @@ -332,18 +393,38 @@ class Activities_AdminControllerWithQuotasInscriptionInvalidPostTest -class Activities_AdminControllerWithQuotasInscriptionExportTest +abstract class AdminControllerWithQuotasInscriptionExportTestCase extends AdminControllerWithQuotasTestCase { + protected $_session_activity_export; + public function setUp() { parent::setUp(); - Class_SessionActivity::find(32) - ->resetAttendees() + + $this->_session_activity_export = Class_SessionActivity::find(32); + $this->_updateSessionActivity(); + $this->_session_activity_export->resetAttendees() ->assertSave(); + $this->dispatch('/admin/session-activity/exportinscriptions/id/32'); } + protected function _updateSessionActivity() { + } +} + + + + +class Activities_AdminControllerWithQuotasInscriptionExportTest + extends AdminControllerWithQuotasInscriptionExportTestCase { + + public function setUp() { + parent::setUp(); + } + + /** @test */ public function exportShouldContainsEffectif6_30() { $this->assertContains('Effectif;6-30', $this->_response->getBody()); @@ -360,4 +441,26 @@ class Activities_AdminControllerWithQuotasInscriptionExportTest public function exportShouldContainsAdultsAndChildrenNumber() { $this->assertContains('Barroca;Patrick;Pat;user@server.org;;1;2', $this->_response->getBody()); } -} \ No newline at end of file +} + + + + +class Activities_AdminControllerWithQuotasInscriptionAndAgeChildMinExportTest + extends AdminControllerWithQuotasInscriptionExportTestCase { + + public function setUp() { + parent::setUp(); + } + + + protected function _updateSessionActivity() { + $this->_session_activity_export->setAgeChildMin(3); + } + + + /** @test */ + public function exportShouldContainsAgeMinAndMaxChildren() { + $this->assertContains('Enfants (âge compris entre 3 et 5)', $this->_response->getBody()); + } +} diff --git a/tests/scenarios/Activities/WidgetWithQuotasTest.php b/tests/scenarios/Activities/WidgetWithQuotasTest.php index 2eeff4650e4663bcb0b32fb1ca1fb663c81d9790..7963fab1062f548f11a0a8fbe9f8e208d093e2e1 100644 --- a/tests/scenarios/Activities/WidgetWithQuotasTest.php +++ b/tests/scenarios/Activities/WidgetWithQuotasTest.php @@ -71,7 +71,7 @@ class Activities_WidgetWithQuotasDisplayTest extends ViewHelperTestCase { ['id' => $id + 1, 'activity' => $activity, 'date_debut' => $date_session . '-01', - 'date_limite_inscription' => $date_session . '-01', + 'date_limite_fin' => $date_session . '-01', 'date_fin' => $date_session . '-04', 'effectif_inscription_max' => 2, 'effectif_inscription_child_max' => 2, @@ -108,4 +108,10 @@ class Activities_WidgetWithQuotasDisplayTest extends ViewHelperTestCase { public function activitieShouldBeDisplayedByYear() { $this->assertXPathContentContains($this->_html, '//h2[1]', '2010'); } + + + /** @test */ + public function dateLimitInscriptionShouldBe2016_04_01() { + $this->assertXPathContentContains($this->_html, '//dd[@class="training_informations"]', 'Date limite d\'inscription : 01 avril 2016'); + } } diff --git a/tests/scenarios/Templates/PolygoneTemplateAbonneAgendaTest.php b/tests/scenarios/Templates/PolygoneTemplateAbonneAgendaTest.php index 13d93977be2adee9a0b90339cbbac83e8561b89f..82a50c011ac19a3003ffe5506f4ed353f315cca4 100644 --- a/tests/scenarios/Templates/PolygoneTemplateAbonneAgendaTest.php +++ b/tests/scenarios/Templates/PolygoneTemplateAbonneAgendaTest.php @@ -113,7 +113,7 @@ abstract class PolygoneTemplateAbonneAgendaTestCase extends AbstractControllerTe 'lieu' => $this->_gallice_cafe, 'date_debut' => '2021-01-10', 'date_fin' => '2021-01-10', - 'date_limite_inscription' => '2021-01-10', + 'date_limite_fin' => '2021-01-10', 'stagiaires' => []]); $this->_session_smalltalk_juillet = $this @@ -126,7 +126,7 @@ abstract class PolygoneTemplateAbonneAgendaTestCase extends AbstractControllerTe 'stagiaires' => [], 'date_debut' => '2020-07-11', 'date_fin' => '2020-07-15', - 'date_limite_inscription' => '2020-07-11']); + 'date_limite_fin' => '2020-07-11']); $this->_learn_smalltalk ->setSessions([$this->_session_smalltalk_janvier, @@ -150,7 +150,7 @@ abstract class PolygoneTemplateAbonneAgendaTestCase extends AbstractControllerTe 'date_debut' => '2021-02-10', 'date_fin' => '2021-02-20', 'stagiaires' => [], - 'date_limite_inscription' => '2021-01-20']); + 'date_limite_fin' => '2021-01-20']); $this->_session_java_mars = $this->fixture('Class_SessionActivity', ['id' => 32, @@ -165,7 +165,7 @@ abstract class PolygoneTemplateAbonneAgendaTestCase extends AbstractControllerTe 'lieu' => $this->_gallice_cafe, 'date_debut' => '2021-03-01', 'stagiaires' => [$this->_amadou], - 'date_limite_inscription' => '2021-03-01']); + 'date_limite_fin' => '2021-03-01']); $this->_session_java_mars ->getSessionActivityInscriptions()[0]->setAdults(1) @@ -180,7 +180,7 @@ abstract class PolygoneTemplateAbonneAgendaTestCase extends AbstractControllerTe 'date_fin' => '2020-09-10', 'stagiaires' => [], 'lieu' => $this->_gallice_cafe, - 'date_limite_inscription' => '2020-09-10']); + 'date_limite_fin' => '2020-09-10']); $this->_learn_java ->setSessions([$this->_session_java_mars, @@ -200,7 +200,7 @@ abstract class PolygoneTemplateAbonneAgendaTestCase extends AbstractControllerTe 'activity' => $this->_learn_python, 'date_debut' => '2020-07-10', 'date_fin' => '2020-07-14', - 'date_limite_inscription' => '2020-07-10', + 'date_limite_fin' => '2020-07-10', 'contenu' => 'Ok', 'objectif' => 'Ecrire un premier programme', 'effectif_min' => 1, diff --git a/tests/scenarios/Templates/TemplatesAdminProfileTest.php b/tests/scenarios/Templates/TemplatesAdminProfileTest.php index c055186caff552ac9b0723538aede92605dfa627..57f55ec1aa36d7aef415b40b38a01872c0c5b467 100644 --- a/tests/scenarios/Templates/TemplatesAdminProfileTest.php +++ b/tests/scenarios/Templates/TemplatesAdminProfileTest.php @@ -89,4 +89,39 @@ class TemplatesAdminProfilePostEditTest extends Admin_AbstractControllerTestCase public function postHeaderCssAlternateCssShouldUpdateProfileOne() { $this->assertEquals('/userfiles/css/alternate.css', Class_Profil::find(1)->getHeaderCss()); } -} \ No newline at end of file +} + + + + +class TemplatesAdminProfileProprietesTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $this->_buildTemplateProfil(['id' => 1, + 'libelle' => 'Proprietes' + ]); + $this->dispatch('/admin/profil/proprietes/id_profil/1'); + } + + + /** @test */ + public function pageShouldLinkToModuleNoticeExemplaires() { + $this->assertXPath('//a[@href="/admin/modulesnotice/exemplaires/id_profil/1"]'); + } + + + /** @test */ + public function pageShouldLinkToSimpleSearch() { + $this->assertXPath('//a[@href="/admin/widget/edit-action/id/recherche_resultat_simple/id_profil/1"]'); + } + + + /** @test */ + public function pageLinkShouldHaveLabelConfigurationDuResultatDeRecherche() { + $this->assertXPathContentContains('//td', + 'Configuration du résultat de recherche'); + } +} diff --git a/tests/scenarios/Templates/TemplatesAuthRegisterTest.php b/tests/scenarios/Templates/TemplatesAuthRegisterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..771b0131a29c61149bb2a23c3fea77e43eac1a6c --- /dev/null +++ b/tests/scenarios/Templates/TemplatesAuthRegisterTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 TemplatesAuthRegisterFormTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $this->_buildTemplateProfil(['id' => 1, + 'libelle' => 'Authentification']); + + $this->dispatch('/admin/widget/edit-action/id/auth_register/id_profil/1'); + } + + + /** @test */ + public function pageShouldContainsTextAreaRegisterHelp() { + $this->assertXPath('//textarea[@name="register_help"]'); + } + + + /** @test */ + public function pageShouldContainsInputTitre() { + $this->assertXPath('//input[@name="titre"]'); + } + + + /** @test */ + public function textareaShouldContainsRegisterConfirm() { + $this->assertXPath('//textarea[@name="register_confirm"]'); + } + + +} + + + + +class TemplatesAuthRegisterPostDispatchTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + $this->_buildTemplateProfil(['id' => 1, + 'libelle' => 'Authentification']); + + $this->postDispatch('/admin/widget/edit-action/id/auth_register/id_profil/1', + ['register_help' => 'Do it please', + 'titre' => 'Register', + 'register_confirm' => 'Done' + ]); + } + + + /** @test */ + public function profilShouldContainsNewValues() { + $this->assertArraySubset(['register_help' => 'Do it please', + 'titre' => 'Register', + 'register_confirm' => 'Done' + ], + Class_Profil::find(1)->getCfgModulesPreferences('auth', 'register')); + } +}