Commit 6e3228b0 authored by Patrick Barroca's avatar Patrick Barroca 🐧

hotline #106864 : forbid dedicated groups edition and deletion

parent abd5c251
Pipeline #9717 passed with stage
in 44 minutes and 10 seconds
- ticket #106864 : Newsletter : Il n'est plus possible de modifier ou supprimer le groupe manuel dédié à chaque newsletter
\ No newline at end of file
......@@ -175,6 +175,16 @@ class ZendAfi_Controller_Plugin_Manager_UserGroup extends ZendAfi_Controller_Plu
}
protected function _canEdit($model) {
return !$model->isDedicated();
}
protected function _canDelete($model) {
return !$model->isDedicated();
}
protected function _getPost($key = null, $default = null) {
$post = $this->_request->getPost();
if(!isset($post[ZendAfi_Form_Admin_UserGroup::RIGHTS_PERMISSIONS]))
......@@ -261,25 +271,33 @@ class ZendAfi_Controller_Plugin_Manager_UserGroup extends ZendAfi_Controller_Plu
protected function _getLeafsActions($model) {
return [
['url' => '/admin/usergroup/editmembers/id/%s',
'icon' => 'users',
'label' => $this->_('Membres'),
'caption' => 'formatedCount'
],
['url' => '/admin/usergroup/edit/id/%s',
'icon' => 'edit',
'label' => $this->_('Modifier'),
],
['url' => '/admin/usergroup/delete/id/%s',
'icon' => 'delete',
'label' => $this->_('Supprimer'),
'anchorOptions' => [
'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer ce groupe ?')"
]]
];
$actions = [['url' => '/admin/usergroup/editmembers/id/%s',
'icon' => 'users',
'label' => $this->_('Membres'),
'caption' => 'formatedCount'
]];
if ($model->isDedicatedTo(Class_Newsletter::class)) {
$actions[] = ['url' => '/admin/newsletter/edit-subscribers/id/' . $model->getModelId(),
'icon' => 'back',
'label' => $this->_('Retour aux destinataires de la lettres')];
return $actions;
}
return array_merge($actions,
[
['url' => '/admin/usergroup/edit/id/%s',
'icon' => 'edit',
'label' => $this->_('Modifier'),
],
['url' => '/admin/usergroup/delete/id/%s',
'icon' => 'delete',
'label' => $this->_('Supprimer'),
'anchorOptions' => [
'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer ce groupe ?')"
]]
]);
}
}
?>
\ No newline at end of file
......@@ -1465,4 +1465,112 @@ class Admin_UserGroupControllerEditMembersWithPaginationAsAutomaticUserGroupTest
public function nb29UsersShouldBeDisplay() {
$this->assertXPathContentContains('//div','29 utilisateurs', $this->_response->getBody());
}
}
\ No newline at end of file
}
class Admin_UserGroupControllerEditMembersNewsletterDedicatedUserGroupTest
extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setup() {
parent::setup();
$this->fixture('Class_UserGroup',
['id' => 1,
'libelle' => 'Group',
'group_type' => Class_UserGroup::TYPE_MANUAL,
'model_class' => Class_Newsletter::class,
'model_id' => 35]);
$this->dispatch('admin/usergroup/editmembers/id/1');
}
/** @test */
public function editLinkShouldNotBePresent() {
$this->assertNotXPath('//a[contains(@href, "/admin/usergroup/edit/id/1")]');
}
/** @test */
public function deleteLinkShouldNotBePresent() {
$this->assertNotXPath('//a[contains(@href, "/admin/usergroup/delete/id/1")]');
}
/** @test */
public function backToNewsletterLinkShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/admin/newsletter/edit-subscribers/id/35")]');
}
}
class Admin_UserGroupControllerEditNewsletterDedicatedUserGroupTest
extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setup() {
parent::setup();
$this->fixture('Class_UserGroup',
['id' => 1,
'libelle' => 'Group',
'group_type' => Class_UserGroup::TYPE_MANUAL,
'model_class' => Class_Newsletter::class,
'model_id' => 35]);
$this->dispatch('admin/usergroup/edit/id/1');
}
/** @test */
public function shouldRedirect() {
$this->assertRedirect();
}
/** @test */
public function messageShouldBeNotAllowed() {
$this->assertFlashMessengerContentContains('Vous n\'avez pas la permission');
}
}
class Admin_UserGroupControllerDeleteNewsletterDedicatedUserGroupTest
extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setup() {
parent::setup();
$this->fixture('Class_UserGroup',
['id' => 1,
'libelle' => 'Group',
'group_type' => Class_UserGroup::TYPE_MANUAL,
'model_class' => Class_Newsletter::class,
'model_id' => 35]);
$this->dispatch('admin/usergroup/delete/id/1');
}
/** @test */
public function shouldRedirect() {
$this->assertRedirect();
}
/** @test */
public function messageShouldBeNotAllowed() {
$this->assertFlashMessengerContentContains('Vous n\'avez pas la permission');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment