Skip to content
Snippets Groups Projects
Commit 8a5e21c4 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

rel #18027 : default permission to create category enable creation of root categories in a library

parent ff21ed21
Branches
Tags
2 merge requests!715Master,!696Dev#20351 articles admin as list
......@@ -58,34 +58,46 @@ class Admin_CmsController extends ZendAfi_Controller_Action {
array_unshift($bibs, $this->_bib);
}
$add_link_builder = function($bib) {
return $this->view
->tag('a',
$this->view->tag('img', null, ['src' => URL_ADMIN_IMG . 'ico/add_cat.gif'])
. $this->view->_(' Ajouter une catégorie'),
['href' => $this->view->url(['module' => 'admin',
'controller' => 'cms-category',
'action' => 'add',
'id_bib' => $bib->getId()], null, true)])
. '  ' . $this->view
->tag('a',
$this->view->tag('img', null,
['src' => URL_ADMIN_IMG . 'picto/groupes_16.png'])
. $this->view->_(' Permissions par défaut'),
['href' => $this->view->url(['module' => 'admin',
'controller' => 'bib',
'action' => 'permissions',
'id' => $bib->getId()], null, true)]);
$add_link_builder = function($bib, $identity) {
$links = [];
if ($identity->isRoleMoreThanModoPortail()
|| $identity->hasPermissionOn(Class_Permission::createArticleCategory(),
$bib)) {
$label = $this->view->tag('img', null,
['src' => URL_ADMIN_IMG . 'ico/add_cat.gif'])
. $this->view->_(' Ajouter une catégorie');
$links[] = $this->view
->tag('a', $label,
['href' => $this->view->url(['module' => 'admin',
'controller' => 'cms-category',
'action' => 'add',
'id_bib' => $bib->getId()],
null, true)]);
}
if ($identity->isRoleMoreThanModoPortail()) {
$label = $this->view->tag('img', null,
['src' => URL_ADMIN_IMG . 'picto/groupes_16.png'])
. $this->view->_(' Permissions par défaut');
$links[] = $this->view->tag('a', $label,
['href' => $this->view->url(['module' => 'admin',
'controller' => 'bib',
'action' => 'permissions',
'id' => $bib->getId()],
null, true)]);
}
return implode('  ', $links);
};
$identity = Class_Users::getIdentity();
$datas_closure = function($bib) use ($add_link_builder, $identity) {
$data = ['bib'=> $bib, 'containers' => $bib->getArticleCategories()];
if (!$identity->isRoleMoreThanModoPortail())
return $data;
$data['add_link'] = $add_link_builder($bib);
if ($links = $add_link_builder($bib, $identity))
$data['add_link'] = $links;
return $data;
};
......
......@@ -309,9 +309,6 @@ class CmsControllerPermissionsCategoryGivesArticlesTest
/**
* Permissions should be the same as when given on category
*/
class CmsControllerPermissionsWithDefaultPermissionsTest
extends CmsControllerPermissionsWithPermissionsTestCase {
public function setUp() {
......@@ -321,6 +318,13 @@ class CmsControllerPermissionsWithDefaultPermissionsTest
Class_Permission::createArticle()->permitTo($group, $this->annecy);
Class_Permission::createArticleCategory()->permitTo($group, $this->annecy);
}
/** @test */
public function shouldViewAddRootCategoryLink() {
$this->dispatch('admin/cms', true);
$this->assertXPath('//a[contains(@href, "cms-category/add/id_bib/")]');
}
}
......
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