diff --git a/VERSIONS_HOTLINE/59093 b/VERSIONS_HOTLINE/59093 new file mode 100644 index 0000000000000000000000000000000000000000..a751f8ce6d81552565f0f11db4b2e3e4f166ed58 --- /dev/null +++ b/VERSIONS_HOTLINE/59093 @@ -0,0 +1 @@ + - ticket #59093 : Administration : correction du paramétrage de la bannière. \ No newline at end of file diff --git a/VERSIONS_HOTLINE/64607 b/VERSIONS_HOTLINE/64607 new file mode 100644 index 0000000000000000000000000000000000000000..a48c41783251ca5c52f57482c2e84a1c9600d160 --- /dev/null +++ b/VERSIONS_HOTLINE/64607 @@ -0,0 +1,2 @@ + - ticket #64607 : Administration : correction du glisser déposer du composant de sélection des articles. + \ No newline at end of file diff --git a/VERSIONS_HOTLINE/64837 b/VERSIONS_HOTLINE/64837 new file mode 100644 index 0000000000000000000000000000000000000000..af6e0758d29f4a12f6d4b186907f2c7248e0892a --- /dev/null +++ b/VERSIONS_HOTLINE/64837 @@ -0,0 +1 @@ + - ticket #64837 : Administration : correction des droits de suppresion des boites. diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php index e1ff46101d805ceef360ecab3298cbee535cae8f..ebbbe07871febf4c2dd668f21f35e7056d51b775 100644 --- a/application/modules/admin/controllers/IndexController.php +++ b/application/modules/admin/controllers/IndexController.php @@ -158,4 +158,22 @@ class Admin_IndexController extends ZendAfi_Controller_Action { $this->_helper->notify($message); $this->_redirect('admin/index/update-skin'); } + + + public function becomeAction() { + if(!Class_Users::getIdentity()->isSuperAdmin()) { + $this->_helper->notify($this->_('Vous n\'avez pas les droits suffisants pour utiliser cette fonctionnalité.')); + return $this->_redirectToIndex(); + } + + if(!$user = Class_Users::find($this->_getParam('id', null))) { + $this->_helper->notify($this->_('Utilisateur invalide')); + return $this->_redirectToIndex(); + } + + ZendAfi_Auth::getInstance()->logUser($user); + $this->_helper->notify($this->_('Vous êtes maintenant connecté avec l\'utilisateur "%s"', + $user->getNomComplet())); + $this->_redirectToIndex(); + } } \ No newline at end of file diff --git a/application/modules/admin/controllers/ProfilController.php b/application/modules/admin/controllers/ProfilController.php index a237994c51688428b9f3984736c8365056a7422e..71b4ebc5b5c3b89d08b94a22a2d921638000d3d4 100644 --- a/application/modules/admin/controllers/ProfilController.php +++ b/application/modules/admin/controllers/ProfilController.php @@ -299,10 +299,7 @@ class Admin_ProfilController extends ZendAfi_Controller_Action { $profil->updateModuleConfigAccueil($id_module, $module_config); } - if(!$profil->hasParentProfil()) - $enreg = $this->setBannerWidget($profil, $enreg); - - $this->purgeBannerWidget($profil, $enreg); + $enreg = $this->_updateBannerWidgets($profil, $enreg); if($profil->setCfgAccueil($enreg)->save()) { $this->_helper->notify($this->view->_('Page ' . $profil->getLibelle() . ' sauvegardée')); @@ -314,26 +311,20 @@ class Admin_ProfilController extends ZendAfi_Controller_Action { } - protected function purgeBannerWidget($profil, $enreg) { + protected function _updateBannerWidgets($profil, $enreg) { if(!$parent_profil = $profil->getParentProfil()) - return; - - $local_banner_widgets = array_keys($parent_profil->getBannerBoxes()); + return $this->_injectDefaultsBannerWidgets($profil, $enreg); $temp_profil = (new Class_Profil())->setCfgAccueil($enreg); - $enreg_banner_widgets = array_keys($temp_profil->getBannerBoxes()); - - if(!$to_delete = array_diff($local_banner_widgets, $enreg_banner_widgets)) - return ; - - foreach($to_delete as $id) - $parent_profil->removeBoiteFromDiv($id, Class_Profil::DIV_BANNIERE); + $parent_profil + ->setBannerBoxes($temp_profil->getBannerBoxes()) + ->save(); - return $parent_profil->save(); + return $enreg; } - protected function setBannerWidget($profil, $enreg) { + protected function _injectDefaultsBannerWidgets($profil, $enreg) { $required_widgets = $this->getSearchAndLoginWidget($profil->getBoitesDivision(Class_Profil::DIV_BANNIERE)); foreach( $required_widgets as $id => $module) { if(!array_key_exists($id, $enreg['modules'])) { diff --git a/application/modules/admin/views/scripts/users/index.phtml b/application/modules/admin/views/scripts/users/index.phtml index 25072612d2a4aaee996c7a49ed623697121d1da2..aca988264f97563a108ce870efbf6764711e2b9f 100644 --- a/application/modules/admin/views/scripts/users/index.phtml +++ b/application/modules/admin/views/scripts/users/index.phtml @@ -6,6 +6,7 @@ if(Class_Users::getIdentity()->isAdmin()) $double_finder = (new Class_User_DbDoubleFinder); $has_double = $double_finder->hasDouble(); + echo $this->button( (new Class_Entity()) ->setText($this->_('Gérer les doublons')) @@ -22,7 +23,6 @@ echo $this->button( 'users'), ['style' => 'filter: invert();']))); - echo $this->Admin_SearchUsers($this->users, $this->total, $this->form, diff --git a/library/Class/Profil.php b/library/Class/Profil.php index 35651c82cbebf5abf5f92eeff13c2905b1b49cfa..45e271a74a230bf6799468ac5053eee5c437f385 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -751,6 +751,21 @@ class Class_Profil extends Storm_Model_Abstract { } + public function setBannerBoxes($widgets) { + $cfg_accueil = $this->getCfgAccueilAsArray(); + foreach ($cfg_accueil['modules'] as $id => $module) { + if ($module['division'] == self::DIV_BANNIERE) + unset($cfg_accueil['modules'][$id]); + } + + foreach($widgets as $id => $config) + $cfg_accueil['modules'][$id] = $config; + + $this->setCfgAccueil($cfg_accueil); + return $this; + } + + /** @return array */ public function getLocalModuleAccueilConfig($id_module) { $cfg_accueil = $this->getCfgAccueilAsArray(); diff --git a/library/ZendAfi/Controller/Plugin/Manager/User.php b/library/ZendAfi/Controller/Plugin/Manager/User.php index 40fd1f0d35f295c02cada011f1291acf45c05961..f7ffaa8e1380207eebaae48df23cedaaba3b5fde 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/User.php +++ b/library/ZendAfi/Controller/Plugin/Manager/User.php @@ -63,45 +63,53 @@ class ZendAfi_Controller_Plugin_Manager_User extends ZendAfi_Controller_Plugin_M 'condition' => function ($model) { return (new Class_User_DbDoubleFinder())->hasDoubleFor($model); } - ] - ]; - } + ], + ['url' => ['module' => 'admin', + 'controller' => 'index', + 'action' => 'become', + 'id' => '%s'], + 'icon' => 'users', + 'condition' => function() { return Class_Users::getIdentity()->isSuperAdmin();}, + 'label' => $this->_('Se connecter avec l\'identité')] + ]; +} - protected function _getPost() { - $post = $this->_request->getPost(); - $post['user_groups'] = array_filter( - array_map(function($id) { return Class_UserGroup::find((int)$id);}, - explode('-', $this->_getParam('user_group_ids',''))) - ); - unset($post['id_categories']); +protected function _getPost() { + $post = $this->_request->getPost(); + $post['user_groups'] = array_filter( + array_map(function($id) { return Class_UserGroup::find((int)$id);}, + explode('-', $this->_getParam('user_group_ids',''))) + ); - return $post; - } + unset($post['id_categories']); + return $post; +} - protected function _getFormValues($model) { - $array_model=parent::_getFormValues($model); - $array_model['user_group_ids']=implode('-',array_map(function($group) { return $group->getId();},$model->getUserGroups())); - return $array_model; - } +protected function _getFormValues($model) { + $array_model=parent::_getFormValues($model); + $array_model['user_group_ids']=implode('-',array_map(function($group) { return $group->getId();},$model->getUserGroups())); + + return $array_model; +} - protected function _setupFormAndSave($model) { - if ($this->_request->isPost()) - $model->updateSIGBOnSave(); +protected function _setupFormAndSave($model) { + if ($this->_request->isPost()) + $model->updateSIGBOnSave(); - try { - return parent::_setupFormAndSave($model); - } catch (Exception $e) { - $this->_helper->notify($e->getMessage()); - } + try { + return parent::_setupFormAndSave($model); + } catch (Exception $e) { + $this->_helper->notify($e->getMessage()); } +} - protected function _canEdit($model) { - return $model->getRoleLevel() <= Class_Users::getIdentity()->getRoleLevel(); - } +protected function _canEdit($model) { + return $model->getRoleLevel() <= Class_Users::getIdentity()->getRoleLevel(); +} } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/FonctionsAdmin.php b/library/ZendAfi/View/Helper/FonctionsAdmin.php index 8edcbcd89944885cb3bf0cf54aae32c2f9be3c47..1cc51cdb9f77122664bc779c996de5794c7abdc3 100644 --- a/library/ZendAfi/View/Helper/FonctionsAdmin.php +++ b/library/ZendAfi/View/Helper/FonctionsAdmin.php @@ -27,8 +27,9 @@ class ZendAfi_View_Helper_FonctionsAdmin extends ZendAfi_View_Helper_BaseHelper $id_module, $_current_skin; - public function fonctionsAdmin($id_module=0, $type_module=false, $division=null, $extended_actions=[]) { - $this->id_profil = Class_Profil::getCurrentProfil()->getId(); + public function fonctionsAdmin($id_module = 0, $type_module = false, $division = null, $extended_actions = []) { + $profile = Class_Profil::getCurrentProfil(); + $this->id_profil = $profile->getId(); $this->type_module = $type_module; $this->id_module = $id_module; $this->division = $division; @@ -36,7 +37,7 @@ class ZendAfi_View_Helper_FonctionsAdmin extends ZendAfi_View_Helper_BaseHelper $actions = [$this->_extended($extended_actions)]; - if (Class_Users::isCurrentUserCanConfigFront()) + if (Class_Users::isCurrentUserAllowedToEditProfile($profile)) $actions = array_merge($actions, [$this->_config(), $this->_versions(), diff --git a/library/ZendAfi/View/Helper/FonctionsAdmin/Boite.php b/library/ZendAfi/View/Helper/FonctionsAdmin/Boite.php index 184e37485a7e5d2dd7ae14fcebbd9bfddf43d3e8..698b9ac66298dbfe87a93a0e32c7fd6c641557d2 100644 --- a/library/ZendAfi/View/Helper/FonctionsAdmin/Boite.php +++ b/library/ZendAfi/View/Helper/FonctionsAdmin/Boite.php @@ -20,6 +20,12 @@ */ class ZendAfi_View_Helper_FonctionsAdmin_Boite extends ZendAfi_View_Helper_FonctionsAdmin { + public function getConfig($id_module = 0, $type_module = false, $division = null, $extended_actions = []) { + parent::fonctionsAdmin($id_module, $type_module, $division, $extended_actions); + return $this->_config(); + } + + protected function getPopupUrlParams() { return ['module' => 'admin', 'controller' => 'widget', diff --git a/library/ZendAfi/View/Helper/ProfileComposition.php b/library/ZendAfi/View/Helper/ProfileComposition.php index 88e7b6c050758e423c74072b98bcc7f2e4cf1227..188a59bee39d8ccd8480ba7af9323aaab0eddc10 100644 --- a/library/ZendAfi/View/Helper/ProfileComposition.php +++ b/library/ZendAfi/View/Helper/ProfileComposition.php @@ -73,22 +73,10 @@ class ZendAfi_View_Helper_ProfileComposition extends ZendAfi_View_Helper_BaseHel } - protected function _getItemModule($type_module, $module, $preferences = '', $id_module = 0) { - $anchor = ''; - - if($id_module) - $anchor = $this->view->tagAnchor($this->view->url(['module' => 'admin', - 'controller' => 'widget', - 'action' => 'edit-widget', - 'id' => $id_module, - 'id_profil' => Class_Profil::getCurrentProfil()->getId()], null, true), - Class_Admin_Skin::current()->renderActionIconOn('edit', - $this->view, - ['alt' => $this->_('Propriétés')]), - ['title' => $this->_('Propriétés'), - 'data-popup' => 'true']); - - return $this->_tag('li', $module . $anchor, ['data-value' => $type_module . '-' . $id_module]); + protected function _getItemModule($type, $label, $id = 0, $anchor = '') { + return $this->_tag('li', + $label . $anchor, + ['data-value' => $type . '-' . $id]); } @@ -110,8 +98,12 @@ class ZendAfi_View_Helper_ProfileComposition extends ZendAfi_View_Helper_BaseHel protected function _getBannerColumn() { - return $this->_getDivisionColumn(4, $this->_('Banniere')); - } + return $this->_getDivisionColumn(4, $this->_('Banniere') + . $this->view->tagImg(Class_Admin_Skin::current()->getIconUrl('actions', + 'help'), + ['title' => $this->_('Attention. Cette division est partagée entre toutes les pages du profil.'), + 'style' => 'margin:0 0 -3px 5px;cursor: help;'])); + } protected function _getSideColumn() { @@ -147,11 +139,15 @@ class ZendAfi_View_Helper_ProfileComposition extends ZendAfi_View_Helper_BaseHel $html = ''; $modules = $profil->getBoitesDivision($division); + $helper = $this->view->getHelper('FonctionsAdmin_Boite'); foreach($modules as $id_module => $module) $html .= $this->_getItemModule($module['type_module'], Class_Systeme_ModulesAccueil::moduleByCode($module['type_module'])->getLibelle(), - $module['preferences'], - $id_module); + $id_module, + $helper->getConfig($id_module, + $module['type_module'], + $division)); + return $html; } } \ No newline at end of file diff --git a/public/admin/js/treeselect/treeselect.js b/public/admin/js/treeselect/treeselect.js index 1927395e9f12a8f612b83673c9fad67524ce5ed6..2776030d80db042c2a3b8a8ee0b5d2984ab8ecae 100644 --- a/public/admin/js/treeselect/treeselect.js +++ b/public/admin/js/treeselect/treeselect.js @@ -1,10 +1,10 @@ (function($) { - + $.widget("ui.treeselect", { options: { datas: [] }, - + disableMultipleSelection: function () { this.multiple_selection=false; @@ -14,29 +14,29 @@ _create: function(){ var self=this; - this.multiple_selection = true; + this.multiple_selection = true; this.element.addClass('ui-widget ui-helper-reset'); this.container = $("<div class='ui-treeselect ui-widget-content ui-corner-all'></div>"). - appendTo(this.element); + appendTo(this.element); - this.searchInput = - $("<div class='ui-treeselect-search'>"+ - "<span>Rechercher: </span><input type='textfield' size='50'></input>"+ - "</div>"). - appendTo(this.container). - find('input').keyup(function(event){ - self._onSearchInputChange($(this).val()); - }).end(); + this.searchInput = + $("<div class='ui-treeselect-search'>"+ + "<span>Rechercher: </span><input type='textfield' size='50'></input>"+ + "</div>"). + appendTo(this.container). + find('input').keyup(function(event){ + self._onSearchInputChange($(this).val()); + }).end(); this.itemsTree = ($("<div class='ui-treeselect-items-tree' />")). - appendTo(this.container); + appendTo(this.container); - this.selectedItems = - $("<div class='ui-treeselect-selected-items'>"+ - "<div class='ui-treeselect-selected-items-inner ui-widget-content ui-corner-all'>"+ - "<ul></ul></div></div>"). - appendTo(this.container). - find("ul"); + this.selectedItems = + $("<div class='ui-treeselect-selected-items'>"+ + "<div class='ui-treeselect-selected-items-inner ui-widget-content ui-corner-all'>"+ + "<ul></ul></div></div>"). + appendTo(this.container). + find("ul"); this._createDataTree(); this._initialize(); @@ -71,32 +71,32 @@ var self = this; $.each(items, function(index, item) { - var item_li=self.mkli(item, parent, 'item'). - children('a'); + var item_li=self.mkli(item, parent, 'item'). + children('a'); }); - + }, mkli: function(catOrItem, parent, type){ var self = this; return $("<li class='ui-treeselect-"+type+"'>"+ - this._addCheckbox(catOrItem)+ - "<a class='ui-state-default' href='#' title='" + catOrItem.label.replace("'", "'") + "'>" + - this._addIco(catOrItem)+ - catOrItem.label+ - "</a>" + - "</li>"). - data("label", catOrItem.label). - data("type", type). - data("elid", catOrItem.id). - appendTo(parent). - children('a').hover( - function (event) { - self._onMouseEntersLI($(event.target).parent()); - }, - function (event) { - self._onMouseExitsLI($(event.target).parent()); - }).end(); + this._addCheckbox(catOrItem)+ + "<a class='ui-state-default' href='#' title='" + catOrItem.label.replace("'", "'") + "'>" + + this._addIco(catOrItem)+ + catOrItem.label+ + "</a>" + + "</li>"). + data("label", catOrItem.label). + data("type", type). + data("elid", catOrItem.id). + appendTo(parent). + children('a').hover( + function (event) { + self._onMouseEntersLI($(event.target).parent()); + }, + function (event) { + self._onMouseExitsLI($(event.target).parent()); + }).end(); }, @@ -107,22 +107,22 @@ var self = this; $.each(categories, function(index, cat) { - var cat_li = self.mkli(cat, parent, 'category'); - - if ((cat.categories.length + cat.items.length) == 0) { - cat_li.addClass('ui-treeselect-empty-category'); - return; - } - - - var cat_ul = $("<ul></ul>").appendTo(cat_li); - self._addCategoriesTo(cat.categories, cat_ul); - - - $.each(cat.items, function(index, item){ - self.mkli(item, cat_ul, 'item'). - children('a'); - }); + var cat_li = self.mkli(cat, parent, 'category'); + + if ((cat.categories.length + cat.items.length) == 0) { + cat_li.addClass('ui-treeselect-empty-category'); + return; + } + + + var cat_ul = $("<ul></ul>").appendTo(cat_li); + self._addCategoriesTo(cat.categories, cat_ul); + + + $.each(cat.items, function(index, item){ + self.mkli(item, cat_ul, 'item'). + children('a'); + }); }); }, @@ -131,32 +131,32 @@ var anchor = li.children('a'); if(anchor.size()) - anchor.data('on_mouse_enter_classes', anchor[0].className); + anchor.data('on_mouse_enter_classes', anchor[0].className); anchor. - addClass("ui-state-hover"). - removeClass("ui-state-default"). - removeClass("ui-state-highlight"). - removeClass("ui-state-active"); + addClass("ui-state-hover"). + removeClass("ui-state-default"). + removeClass("ui-state-highlight"). + removeClass("ui-state-active"); if (li.parents('.ui-treeselect-selected-items').length == 0) return; - var hint = - $('<div class="hint ui-widget ui-corner-all ui-state-active" style="display:none"/>'). - hide(). - appendTo(li); + var hint = + $('<div class="hint ui-widget ui-corner-all ui-state-active" style="display:none"/>'). + hide(). + appendTo(li); hint.delay(1000).fadeIn('fast'); - + var sourceLI = this._findConnectedIn(li, this.itemsTree); this._getAnchorTreeFor(sourceLI). - slice(0, -1). - each(function(index, element){ - hint = $("<li>"+$(element).text()+"</li>"). - appendTo($("<ul></ul>")). - appendTo(hint); - }); + slice(0, -1). + each(function(index, element){ + hint = $("<li>"+$(element).text()+"</li>"). + appendTo($("<ul></ul>")). + appendTo(hint); + }); }, @@ -164,9 +164,9 @@ var anchor = li.children('a'); anchor. - addClass(anchor.data('on_mouse_enter_classes')). - removeData('on_mouse_enter_classes'). - removeClass("ui-state-hover"); + addClass(anchor.data('on_mouse_enter_classes')). + removeData('on_mouse_enter_classes'). + removeClass("ui-state-hover"); this.selectedItems.find('.hint').remove(); @@ -176,86 +176,87 @@ _createDataTree: function(){ var self = this; $.each(this.options.datas, function(index, cat) { - cat = self._initDataOptions(cat); - - $("<h4><a href='#'>"+cat.label+"</a></h4>"). - appendTo(self.itemsTree); - - var ul = $("<div style='padding:0px' class='cat_"+cat.id+"'></div>"). - appendTo(self.itemsTree). - append('<ul></ul>'). - children()[0]; - - self._addCategoriesTo(cat.categories, ul); - self._addItemsTo(cat.items,ul); + cat = self._initDataOptions(cat); + + $("<h4><a href='#'>"+cat.label+"</a></h4>"). + appendTo(self.itemsTree); + + var ul = $("<div style='padding:0px' class='cat_"+cat.id+"'></div>"). + appendTo(self.itemsTree). + append('<ul></ul>'). + children()[0]; + + self._addCategoriesTo(cat.categories, ul); + self._addItemsTo(cat.items,ul); }); }, - + _initDataOptions: function(categorieOrItem){ var self = this; if(undefined==categorieOrItem.options) - categorieOrItem.options = []; - + categorieOrItem.options = []; + $.each(categorieOrItem.categories, function(index,cat){ - self._initDataOptions(cat); + self._initDataOptions(cat); }); $.each(categorieOrItem.items, function(index,item){ - if(undefined==item.options) - item.options = []; + if(undefined==item.options) + item.options = []; }); - + return categorieOrItem; }, - _initAccordion: function(){ - this.itemsTree.accordion({collapsible: true, - beforeActivate: function(event, ui) { - if (ui.newHeader[0]) { - var currHeader = ui.newHeader; - var currContent = currHeader.next('.ui-accordion-content'); - } else { - var currHeader = ui.oldHeader; - var currContent = currHeader.next('.ui-accordion-content'); - } - var isPanelSelected = currHeader.attr('aria-selected') == 'true'; - var isPanelHighlight = currHeader.hasClass('ui-state-highlight'); - currHeader - .toggleClass('ui-corner-all', isPanelSelected) - .toggleClass('accordion-header-active ui-state-active ui-corner-top', !isPanelSelected) - .attr('aria-selected', ((!isPanelSelected).toString())); + _initAccordion: function(){ + this.itemsTree.accordion({collapsible: true, + beforeActivate: function(event, ui) { + if (ui.newHeader[0]) { + var currHeader= ui.newHeader; + var currContent = currHeader.next('.ui-accordion-content'); + } else { + var currHeader= ui.oldHeader; + var currContent = currHeader.next('.ui-accordion-content'); + } + var isPanelSelected = currHeader.attr('aria-selected') == 'true'; + var isPanelHighlight = currHeader.hasClass('ui-state-highlight'); + currHeader + .toggleClass('ui-corner-all', isPanelSelected) + .toggleClass('accordion-header-active ui-state-active ui-corner-top', !isPanelSelected) + .attr('aria-selected', ((!isPanelSelected).toString())); - currContent.toggleClass('accordion-content-active', !isPanelSelected) + currContent.toggleClass('accordion-content-active', !isPanelSelected) - if(isPanelSelected && isPanelHighlight) { - self._hideAll(); - return false; - } + if(isPanelSelected && isPanelHighlight) { + self._hideAll(); + return false; + } - if (isPanelSelected) { - currContent.slideUp(); - return false; - } - - currContent.slideDown(); - return false; - }} - ); + if (isPanelSelected) { + currContent.slideUp(); + return false; + } + + currContent.slideDown(); + return false; + }} + ); }, _initSortable: function(){ var self=this; this.selectedItems. - addClass("sortable"). - sortable({ - cursor:'crosshair', - opacity: 0.8, - start: function(event, ui) {$(this).find('.hint').remove();} - }); + addClass("sortable"). + sortable({ + cursor:'crosshair', + opacity: 0.8, + start: function(event, ui) {$(this).find('.hint').remove();}, + stop: function(event, ui) {$(this).closest('form').find('input').first().change();} + }); }, @@ -263,42 +264,42 @@ var self=this; this.itemsTree.find('li').each( - function(index, li){ - $(li).data('sid', index);}); - + function(index, li){ + $(li).data('sid', index);}); + this.itemsTree.change( - function(event){ - self._onSelectionChange($(event.target).parent()); - event.stopPropagation();}); + function(event){ + self._onSelectionChange($(event.target).parent()); + event.stopPropagation();}); this.itemsTree.find('li>ul').css("display","none"); this.itemsTree.click( - function(event){ - var $target = $(event.target); - if ($target.is("a>*")) $target = $target.parent(); - if ($target.is("a")) { - event.stopPropagation(); - event.preventDefault(); - $target.closest('li').find('li').show(); - $target.siblings('ul').find('ul').hide(); - $target.siblings('ul').toggle('fast'); - }}) + function(event){ + var $target = $(event.target); + if ($target.is("a>*")) $target = $target.parent(); + if ($target.is("a")) { + event.stopPropagation(); + event.preventDefault(); + $target.closest('li').find('li').show(); + $target.siblings('ul').find('ul').hide(); + $target.siblings('ul').toggle('fast'); + }}) }, _findConnectedIn: function(li, items) { var sid = li.data('sid'); - return items.find('li').filter(function(index) { - return $(this).data('sid') == sid; + return items.find('li').filter(function(index) { + return $(this).data('sid') == sid; }); }, _deselect: function(li) { this._findConnectedIn(li, this.selectedItems). - hide('fast', function(){ - $(this).remove()}); - + hide('fast', function(){ + $(this).remove()}); + li.children('input').removeAttr('checked'); li.find("li input").removeAttr('disabled'); li.children('a').removeClass('ui-state-active'); @@ -312,7 +313,7 @@ if (parent.length == 0) return; if (parent.find('li>input:checked').length==0) { - this._setInactive(parent); + this._setInactive(parent); } }, @@ -320,10 +321,10 @@ _deselectAll: function() { var self = this; this.itemsTree.find('li.ui-treeselect-category').each( function() { - self._deselect($(this)); + self._deselect($(this)); }); this.itemsTree.find('li.ui-treeselect-item').each( function() { - self._deselect($(this)); + self._deselect($(this)); }); }, @@ -332,49 +333,49 @@ var self = this; if (!this.multiple_selection) - this._deselectAll(); + this._deselectAll(); li.children('input').attr('checked', 'checked'); - + var selectedLI = $("<li>"+ - "<a href='#'>"+ - li.find('a').html()+ - "</a></li>"). - appendTo(self.selectedItems). - data(li.data()). - children('a'). - addClass('ui-state-default'). - addClass(li[0].className). - hover( - function (event) { - self._onMouseEntersLI($(event.target).parent()); - }, - function (event) { - self._onMouseExitsLI($(event.target).parent()); - } - ).end(). - click( - function(event){ - event.preventDefault(); - if ($(event.target).is('a.ui-state-highlight')) { - $(event.target).removeClass("ui-state-highlight"); - $(event.target).removeClass("ui-state-active"); - $(event.target).addClass("ui-state-default"); - return self._hideAll(); - } - if ($(event.target).is('a')) - self._highlightSelected($(event.target).parent()); - }); + "<a href='#'>"+ + li.find('a').html()+ + "</a></li>"). + appendTo(self.selectedItems). + data(li.data()). + children('a'). + addClass('ui-state-default'). + addClass(li[0].className). + hover( + function (event) { + self._onMouseEntersLI($(event.target).parent()); + }, + function (event) { + self._onMouseExitsLI($(event.target).parent()); + } + ).end(). + click( + function(event){ + event.preventDefault(); + if ($(event.target).is('a.ui-state-highlight')) { + $(event.target).removeClass("ui-state-highlight"); + $(event.target).removeClass("ui-state-active"); + $(event.target).addClass("ui-state-default"); + return self._hideAll(); + } + if ($(event.target).is('a')) + self._highlightSelected($(event.target).parent()); + }); $("<div class='remove_button'/>"). - appendTo(selectedLI). - click(function(event){ - self._deselect( - self._findConnectedIn($(event.target).parent(), - self.itemsTree)); - self.itemsTree.closest('form').find('input').first().change(); - }); - + appendTo(selectedLI). + click(function(event){ + self._deselect( + self._findConnectedIn($(event.target).parent(), + self.itemsTree)); + self.itemsTree.closest('form').find('input').first().change(); + }); + li.parents('li').andSelf().children('a').addClass('ui-state-active'); this._disableChildren(li); @@ -383,16 +384,16 @@ _disableChildren: function(li) { var self = this; - + if(!this.multiple_selection) - return false; + return false; - li.find("li>input").each( - function(index, checkbox) { - self._deselect($(checkbox).parent()); - $(checkbox). - attr('disabled', true). - removeAttr('checked'); }); + li.find("li>input").each( + function(index, checkbox) { + self._deselect($(checkbox).parent()); + $(checkbox). + attr('disabled', true). + removeAttr('checked'); }); }, @@ -400,20 +401,20 @@ this.itemsTree.closest('form').find('input').first().change(); this._turnHighlightOff(); if (li.children('input').is(':checked')) { - this._select(li); + this._select(li); } else { - this._deselect(li); - this._setInactive(li); + this._deselect(li); + this._setInactive(li); } - + this.selectedItems.sortable('refresh'); }, _turnHighlightOff: function() { this.container.find('.ui-state-highlight'). - removeClass("ui-state-highlight"). - filter('li a, h3'). - addClass("ui-state-default"); + removeClass("ui-state-highlight"). + filter('li a, h3'). + addClass("ui-state-default"); }, @@ -436,15 +437,15 @@ lis.parents("ul").show(); this.itemsTree.find('ul li').hide(); this.itemsTree.find('> div').hide(); - + var self = this; lis.each(function(index, li) { - self._getAnchorTreeFor($(li)). - addClass("ui-state-highlight"). - removeClass("ui-state-default"); - $(li).show(); - $(li).parents('li').show(); - $(li).closest('div').show(); + self._getAnchorTreeFor($(li)). + addClass("ui-state-highlight"). + removeClass("ui-state-default"); + $(li).show(); + $(li).parents('li').show(); + $(li).closest('div').show(); }); }, @@ -462,8 +463,8 @@ _onSearchInputChange: function(searchText) { if (searchText=="") { - this._hideAll(); - return; + this._hideAll(); + return; } accentsTidy = function(s){ @@ -473,19 +474,19 @@ r = r.replace(new RegExp("ç", 'g'),"c"); r = r.replace(new RegExp("[èéêë]", 'g'),"e"); r = r.replace(new RegExp("[ìÃîï]", 'g'),"i"); - r = r.replace(new RegExp("ñ", 'g'),"n"); + r = r.replace(new RegExp("ñ", 'g'),"n"); r = r.replace(new RegExp("[òóôõö]", 'g'),"o"); r = r.replace(new RegExp("Å“", 'g'),"oe"); r = r.replace(new RegExp("[ùúûü]", 'g'),"u"); r = r.replace(new RegExp("[ýÿ]", 'g'),"y"); return r; }; - + searchText = accentsTidy(searchText); var re = new RegExp('\\b' + searchText, 'gi'); var matches = this.itemsTree.find('li, h3').filter(function() { - return re.test(accentsTidy($(this).text())); + return re.test(accentsTidy($(this).text())); }); this._highlightItems(matches); matches.parents(".ui-accordion-content").show(); @@ -494,12 +495,12 @@ _selectByIdAndType: function(ids, type) { var self = this; - jQuery.each(ids, function(index, id) { - self.itemsTree.find('li').each(function(index, li) { - var listitem = $(li); - if ((listitem.data('elid') == id) && (listitem.data('type') == type)) - self._select($(li)); - }); + jQuery.each(ids, function(index, id) { + self.itemsTree.find('li').each(function(index, li) { + var listitem = $(li); + if ((listitem.data('elid') == id) && (listitem.data('type') == type)) + self._select($(li)); + }); }); }, @@ -507,10 +508,10 @@ _getSelectedDataByType: function(type) { var datas = []; this.selectedItems.find('li').each(function(index,li){ - if ($(li).data('type') == type) { - datas.push({"id": $(li).data('elid'), - "label": $(li).data('label')}); - } + if ($(li).data('type') == type) { + datas.push({"id": $(li).data('elid'), + "label": $(li).data('label')}); + } }); return datas; }, @@ -539,20 +540,20 @@ readSelection: function(callback) { callback( - this._getSelectedDataByType('item'), - this._getSelectedDataByType('category')); + this._getSelectedDataByType('item'), + this._getSelectedDataByType('category')); }, toggleVisibility: function(visible) { if (visible) { - var self = this; - this.element.show('fast', - function() { - self.itemsTree.children('div').height('auto'); - }); + var self = this; + this.element.show('fast', + function() { + self.itemsTree.children('div').height('auto'); + }); } else { - this.element.hide('fast'); + this.element.hide('fast'); } } })})(jQuery); diff --git a/tests/application/modules/admin/controllers/IndexControllerTest.php b/tests/application/modules/admin/controllers/IndexControllerTest.php index 2048ab5cd3f6ee83224948946465396182977005..1655497088cd74d12acce6fd88886bc96b29b8f2 100644 --- a/tests/application/modules/admin/controllers/IndexControllerTest.php +++ b/tests/application/modules/admin/controllers/IndexControllerTest.php @@ -466,4 +466,35 @@ class Admin_IndexControllerAdminvarActionTest extends Admin_AbstractControllerTe public function varNewsletterUnsubscribeTextShouldBeLienPourSeDesinscrire() { $this->assertXPathContentContains('//tr[@data-adminvar="NEWSLETTER_UNSUBSCRIBE_TEXT"]//td', 'Lien pour se '); } +} + + + + +class IndexControllerBecomeActionTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Users', + ['id' => 78, + 'login' => 'test78', + 'password' => 'pwd']); + + $this->dispatch('/admin/index/become/id/78', true); + } + + + /** @test */ + public function shouldRedirect() { + $this->assertRedirect(); + } + + + /** @test */ + public function logedUserShouldBeTest78() { + $this->assertEquals(78, Class_Users::getIdentity()->getId()); + } } \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/ProfilControllerPageAccueilTest.php b/tests/application/modules/admin/controllers/ProfilControllerPageAccueilTest.php index 9931104ce771449a219e74114e4eb3a183a90482..cd32bc47141854effc0ef3278868578b317779d6 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerPageAccueilTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerPageAccueilTest.php @@ -110,6 +110,12 @@ class Admin_ProfilControllerPageAccueilJeunesseTest extends Admin_ProfilControll } + /** @test */ + public function bannerHelpImgShouldBePresent() { + $this->assertXPath('//img[contains(@title, "Attention. Cette division est partagée entre toutes les pages du profil.")]'); + } + + /** @test **/ public function boxFiveFlotantShouldBePresent() { $this->assertXPath('//div[@data-division="5"]'); @@ -691,29 +697,37 @@ class Admin_ProfilControllerPageAccueilClearBannerFromChildTest extends Admin_Ab parent::setUp(); $this->fixture('Class_Profil', ['id' => 712, 'libelle' => 'Parent profile', - 'cfg_accueil' => 'a:4:{s:7:"modules";a:12:{i:5;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:8:{s:4:"menu";s:3:"1-V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"1";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:7:"Valider";s:7:"Valider";s:0:"";s:0:"";}}i:2;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:16:{s:5:"titre";s:14:"ne_pas_toucher";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:1:"1";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:1:"0";s:8:"rss_avis";s:1:"0";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:10:"boite_vide";s:11:"style_liste";s:4:"none";s:13:"styles_reload";s:1:"0";s:7:"Valider";s:7:"Valider";s:0:"";s:0:"";}}i:4;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:7;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:1;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:3;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:8;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:9;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:10;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:3:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:11;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:3:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:12;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:2:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";}}i:6;a:3:{s:11:"type_module";s:5:"LOGIN";s:11:"preferences";a:16:{s:5:"titre";s:18:"Mon compte lecteur";s:14:"titre_connecte";s:0:"";s:11:"identifiant";s:12:"N° de carte";s:19:"identifiant_exemple";s:0:"";s:12:"mot_de_passe";s:19:"Année de naissance";s:20:"mot_de_passe_exemple";s:0:"";s:14:"lien_connexion";s:12:"Se connecter";s:24:"lien_mot_de_passe_oublie";s:25:"» Mot de passe oublié ?";s:17:"lien_creer_compte";s:16:"» S\'enregistrer";s:16:"message_connecte";s:9:"Bienvenue";s:11:"lien_compte";s:10:"Mon compte";s:17:"lien_deconnection";s:15:"Se déconnecter";s:16:"autocomplete_off";s:1:"1";s:15:"profil_redirect";s:0:"";s:22:"profil_logout_redirect";s:0:"";s:5:"boite";s:21:"boite_banniere_droite";}s:8:"division";s:1:"4";}}s:14:"use_parent_css";s:1:"1";s:7:"sitemap";s:1:"1";s:8:"page_css";s:0:"";}']); + 'cfg_accueil' => 'a:4:{s:7:"modules";a:8:{i:2;a:3:{s:8:"division";s:1:"4";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:3;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:1;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:4;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:8;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:5;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:10;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:3:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:11;a:3:{s:8:"division";s:1:"4";s:11:"type_module";s:5:"LOGIN";s:11:"preferences";a:17:{s:5:"titre";s:18:"Mon compte lecteur";s:14:"titre_connecte";s:0:"";s:11:"identifiant";s:12:"N° de carte";s:19:"identifiant_exemple";s:0:"";s:12:"mot_de_passe";s:19:"Année de naissance";s:20:"mot_de_passe_exemple";s:0:"";s:14:"lien_connexion";s:12:"Se connecter";s:24:"lien_mot_de_passe_oublie";s:25:"» Mot de passe oublié ?";s:17:"lien_creer_compte";s:16:"» S\'enregistrer";s:16:"message_connecte";s:9:"Bienvenue";s:11:"lien_compte";s:10:"Mon compte";s:17:"lien_deconnection";s:15:"Se déconnecter";s:16:"autocomplete_off";s:1:"1";s:15:"profil_redirect";s:0:"";s:22:"profil_logout_redirect";s:0:"";s:5:"boite";s:21:"boite_banniere_droite";s:0:"";s:0:"";}}}s:14:"use_parent_css";s:1:"1";s:7:"sitemap";s:1:"1";s:8:"page_css";s:0:"";}']); $this->fixture('Class_Profil', ['id' => 713, 'parent_id' => 712, 'id_site' => 0, 'libelle' => 'My page', - 'cfg_accueil' => 'a:4:{s:7:"modules";a:8:{i:2;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:3;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:1;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:4;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:8;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:5;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:10;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:3:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:11;a:3:{s:8:"division";s:1:"4";s:11:"type_module";s:5:"LOGIN";s:11:"preferences";a:17:{s:5:"titre";s:18:"Mon compte lecteur";s:14:"titre_connecte";s:0:"";s:11:"identifiant";s:12:"N° de carte";s:19:"identifiant_exemple";s:0:"";s:12:"mot_de_passe";s:19:"Année de naissance";s:20:"mot_de_passe_exemple";s:0:"";s:14:"lien_connexion";s:12:"Se connecter";s:24:"lien_mot_de_passe_oublie";s:25:"» Mot de passe oublié ?";s:17:"lien_creer_compte";s:16:"» S\'enregistrer";s:16:"message_connecte";s:9:"Bienvenue";s:11:"lien_compte";s:10:"Mon compte";s:17:"lien_deconnection";s:15:"Se déconnecter";s:16:"autocomplete_off";s:1:"1";s:15:"profil_redirect";s:0:"";s:22:"profil_logout_redirect";s:0:"";s:5:"boite";s:21:"boite_banniere_droite";s:0:"";s:0:"";}}}s:14:"use_parent_css";s:1:"1";s:7:"sitemap";s:1:"1";s:8:"page_css";s:0:"";}', - ]); + 'cfg_accueil' => 'a:4:{s:7:"modules";a:8:{i:2;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:3;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:4:"NEWS";s:11:"preferences";a:13:{s:5:"titre";s:8:"Articles";s:8:"type_aff";s:1:"1";s:12:"id_categorie";s:0:"";s:8:"id_items";s:0:"";s:6:"nb_aff";s:1:"1";s:10:"nb_analyse";s:1:"5";s:13:"display_order";s:9:"Selection";s:19:"display_titles_only";s:0:"";s:8:"rss_avis";s:1:"1";s:14:"op_largeur_img";s:3:"200";s:16:"op_hauteur_boite";s:3:"400";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:1;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:4;a:3:{s:8:"division";s:1:"1";s:11:"type_module";s:7:"KIOSQUE";s:11:"preferences";a:23:{s:5:"titre";s:7:"Kiosque";s:11:"style_liste";s:10:"slide_show";s:10:"nb_notices";s:2:"20";s:8:"only_img";s:1:"1";s:9:"aleatoire";s:1:"1";s:3:"tri";s:1:"1";s:10:"nb_analyse";s:2:"50";s:14:"op_hauteur_img";s:1:"0";s:13:"op_transition";s:0:"";s:14:"op_largeur_img";s:1:"0";s:16:"op_hauteur_boite";s:1:"0";s:11:"op_captions";s:1:"0";s:11:"op_autoplay";s:1:"0";s:10:"op_visible";s:1:"0";s:8:"op_speed";s:1:"0";s:7:"op_auto";s:1:"0";s:9:"op_scroll";s:1:"1";s:8:"rss_avis";s:1:"1";s:12:"id_catalogue";s:1:"0";s:9:"id_panier";s:1:"0";s:15:"profil_redirect";s:0:"";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:8;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:5;a:3:{s:8:"division";s:1:"2";s:11:"type_module";s:13:"MENU_VERTICAL";s:11:"preferences";a:7:{s:4:"menu";s:1:"V";s:14:"afficher_titre";s:1:"1";s:11:"menu_deplie";s:1:"0";s:8:"new_html";s:1:"0";s:5:"boite";s:0:"";s:5:"titre";s:0:"";s:0:"";s:0:"";}}i:10;a:3:{s:8:"division";s:1:"3";s:11:"type_module";s:6:"PANIER";s:11:"preferences";a:3:{s:5:"titre";s:6:"Panier";s:5:"boite";s:0:"";s:0:"";s:0:"";}}i:11;a:3:{s:8:"division";s:1:"4";s:11:"type_module";s:5:"LOGIN";s:11:"preferences";a:17:{s:5:"titre";s:18:"Mon compte lecteur";s:14:"titre_connecte";s:0:"";s:11:"identifiant";s:12:"N° de carte";s:19:"identifiant_exemple";s:0:"";s:12:"mot_de_passe";s:19:"Année de naissance";s:20:"mot_de_passe_exemple";s:0:"";s:14:"lien_connexion";s:12:"Se connecter";s:24:"lien_mot_de_passe_oublie";s:25:"» Mot de passe oublié ?";s:17:"lien_creer_compte";s:16:"» S\'enregistrer";s:16:"message_connecte";s:9:"Bienvenue";s:11:"lien_compte";s:10:"Mon compte";s:17:"lien_deconnection";s:15:"Se déconnecter";s:16:"autocomplete_off";s:1:"1";s:15:"profil_redirect";s:0:"";s:22:"profil_logout_redirect";s:0:"";s:5:"boite";s:21:"boite_banniere_droite";s:0:"";s:0:"";}}}s:14:"use_parent_css";s:1:"1";s:7:"sitemap";s:1:"1";s:8:"page_css";s:0:"";}']); $this->fixture('Class_AdminVar',['id'=>'MENU_BOITE', 'valeur' => 1]); + } - $cfg_module = "box3|new|PANIER|;box4|6|LOGIN|titre=Mon compte lecteur---titre_connecte=---identifiant=N° de carte---identifiant_exemple=---mot_de_passe=Année de naissance---mot_de_passe_exemple=---lien_connexion=Se connecter---lien_mot_de_passe_oublie=» Mot de passe oublié ?---lien_creer_compte=» S'enregistrer---message_connecte=Bienvenue---lien_compte=Mon compte---lien_deconnection=Se déconnecter---autocomplete_off=1---profil_redirect=---profil_logout_redirect=---boite=boite_banniere_droite---"; + /** @test */ + public function profile712BannerShouldBeEmpty() { $this->postDispatch('/admin/profil/accueil/id_profil/713', ['libelle' => 'test', 'division1' => 'NEWS-2;NEWS-3;KIOSQUE-1;KIOSQUE-4;', 'division2' => 'MENU_VERTICAL-5;CALENDAR-0', 'division3' => 'PANIER-10;PANIER-0', 'division4' => '']); + + $this->assertEmpty(Class_Profil::find(712)->getBannerBoxes()); } /** @test */ - public function profile712BannerShouldBeEmpty() { - $this->assertEmpty(Class_Profil::find(712)->getBannerBoxes()); + public function profile712BannerShouldBeReordered() { + $this->postDispatch('/admin/profil/accueil/id_profil/713', ['libelle' => 'test', + 'division1' => 'NEWS-3;KIOSQUE-1;KIOSQUE-4;', + 'division2' => 'MENU_VERTICAL-5;CALENDAR-0', + 'division3' => 'PANIER-10;PANIER-0', + 'division4' => 'LOGIN-11;NEWS-2;']); + $this->assertEquals([11, 2], array_keys(Class_Profil::find(712)->getBannerBoxes())); } } \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/UsersControllerTest.php b/tests/application/modules/admin/controllers/UsersControllerTest.php index c1d09857f9f967336a5f9ebc744e74c422a705eb..f35f8b3441c1a7d1f87b29208e7be765bcabf376 100644 --- a/tests/application/modules/admin/controllers/UsersControllerTest.php +++ b/tests/application/modules/admin/controllers/UsersControllerTest.php @@ -782,6 +782,7 @@ class UsersControllerReferentIndexTest extends UsersControllerWithMarcusTestCase + class UsersControllerAddActionPostTest extends UsersControllerWithMarcusTestCase { public function setUp() { parent::setUp(); @@ -1716,7 +1717,6 @@ class UsersControllerManageDoubleMergeWithMultipleSourcesTest extends UsersContr class UsersControllerIndexWithDoubleTest extends UsersControllerDoubleTestCase { - public function setUp() { parent::setUp(); $this->dispatch('/admin/users/index', true); @@ -1746,3 +1746,28 @@ class UsersControllerIndexWithDoubleTest extends UsersControllerDoubleTestCase { $this->assertNotXPath('//td//a[contains(@href, "/admin/users/manage-double-user/id_user/123")]'); } } + + + + +class UsersControllerWithSuperAdminTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + ZendAfi_Auth::getInstance() + ->logUser($this->fixture('Class_Users', + ['id' => 1, + 'login' => 'tom', + 'password' => 'rom', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); + $this->dispatch('/admin/users/index', true); + } + + + /** @test */ + public function linkToBecomeTimShouldBePresent() { + $this->assertXPath('//a[contains(@href, "/admin/index/become/")]', $this->_response->getBody()); + } +} diff --git a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php index e1ef547edbcc43141c530bafd4ee9e4962070631..05f9dbef3a49bac11cf8f8c4f01eba54ffa9bf57 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php @@ -188,6 +188,13 @@ class ZendAfi_View_Helper_Accueil_KiosqueCubeAsRedacteurWithCatalogueTest extend '//a[contains(@href, "admin/catalogue/add/id_catalogue/89/id_module/3")]', $this->_html); } + + + /** @test */ + public function linkToEditWidgetShouldNotBePresent() { + $this->assertNotXPath($this->_html, + '//a[contains(@href, "/admin/widget")]'); + } } diff --git a/tests/library/ZendAfi/View/Helper/Admin/FonctionsAdminTest.php b/tests/library/ZendAfi/View/Helper/Admin/FonctionsAdminTest.php new file mode 100644 index 0000000000000000000000000000000000000000..57040b6dc8e89e91766602ef024c5e0d549fed72 --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/Admin/FonctionsAdminTest.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class FonctionsAdminHelperTest extends ViewHelperTestCase { + protected $_content; + + + public function setUp() { + parent::setUp(); + + Class_Profil::setCurrentProfil($this->fixture('Class_Profil', + ['id' => 56, + 'libelle' => 'test'])); + + $this->helper = new ZendAfi_View_Helper_FonctionsAdmin(); + $this->helper->setView($this->view); + } + + + /** @test */ + public function contentShouldContainsTest() { + ZendAfi_Auth::getInstance() + ->logUser($this->fixture('Class_Users', + ['id' => 89, + 'login' => 'test89', + 'password' => 'password', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); + $this->_content = $this->helper->fonctionsAdmin(0, false, null, [function() {return 'test';}]); + $this->assertContains('test', $this->_content); + } + + + /** @test */ + public function contentShouldBeEmpty() { + ZendAfi_Auth::getInstance() + ->logUser($this->fixture('Class_Users', + ['id' => 89, + 'login' => 'test89', + 'password' => 'password', + 'id_site' => 1, + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ADMIN_BIB])); + + $this->_content = $this->helper->fonctionsAdmin(); + $this->assertEquals('', $this->_content); + } +} \ No newline at end of file