diff --git a/application/modules/admin/controllers/CmsController.php b/application/modules/admin/controllers/CmsController.php index cd79ccf4c6accfd4ac00b5b66b81756f3f161b5c..1a9d96a3e4ec8372dd5ccc93c2d1aa27faeef9eb 100644 --- a/application/modules/admin/controllers/CmsController.php +++ b/application/modules/admin/controllers/CmsController.php @@ -361,8 +361,24 @@ class Admin_CmsController extends ZendAfi_Controller_Action { protected function _sendMailToValidators($article) { $mail = new ZendAfi_Mail('utf8'); - $mails = array_filter(array_map(function($user) {return $user->getMail();}, - Class_Permission::validateArticle()->getUsers())); + $categorie = $article->getCategorie(); + $validate_article = Class_Permission::getWorkflow(Class_Article::STATUS_VALIDATED); + + $groups = array_filter(Class_Permission::validateArticle()->getGroups(), + function ($group) use ($categorie, $validate_article) + { + return $group->hasPermissionOn($validate_article, $categorie); + }); + + $mails = []; + foreach($groups as $group) { + $mails = array_merge($mails, + array_filter(array_map(function($user) + { + return $user->getMail(); + }, + $group->getUsers()))); + } if (empty($mails)) return; diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php index 5faa3b69ad7f7c78f97748effb89915b02ff6752..dc3d37f50d784fe0ba429a1854fe6da1dfbe14d3 100644 --- a/tests/application/modules/admin/controllers/CmsControllerTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerTest.php @@ -31,7 +31,8 @@ abstract class CmsControllerTestCase extends Admin_AbstractControllerTestCase { $_bernard, $_group_testing, $_group_admin, - $_cat_a_la_une; + $_cat_a_la_une, + $_cat_atelier; public function setUp() { @@ -155,6 +156,11 @@ abstract class CmsControllerTestCase extends Admin_AbstractControllerTestCase { $this->root_category = $this->fixture('Class_ArticleCategorie', ['id' => 1, 'libelle' => 'Root']); + $this->_cat_atelier = $this->fixture('Class_ArticleCategorie', + ['id' => 42, + 'libelle' => 'Atelier', + 'parent_categorie' => $this->root_category]); + $this->_cat_a_la_une = $this->fixture('Class_ArticleCategorie', ['id' => 23, 'libelle' => 'A la Une', @@ -1721,6 +1727,8 @@ class CmsControllerNewsAddActionPostWithWorkflowTest Class_Permission::validateArticle()->denyTo($this->_group_admin, $this->_cat_a_la_une); + Class_Permission::validateArticle()->permitTo($this->_group_admin, + $this->_cat_atelier); $this->postDispatch('/admin/cms/add/id_cat/23', $data); $this->assertEmpty($this->mock_transport->getSentMails());