|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Zikula package. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright Zikula Foundation - http://zikula.org/ |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Zikula\GroupsModule\Menu; |
|
13
|
|
|
|
|
14
|
|
|
use Knp\Menu\FactoryInterface; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
|
17
|
|
|
use Zikula\Common\Translator\TranslatorTrait; |
|
18
|
|
|
|
|
19
|
|
|
class AdminActionsMenu implements ContainerAwareInterface |
|
20
|
|
|
{ |
|
21
|
|
|
use ContainerAwareTrait; |
|
22
|
|
|
use TranslatorTrait; |
|
23
|
|
|
|
|
24
|
|
|
public function setTranslator($translator) |
|
25
|
|
|
{ |
|
26
|
|
|
$this->translator = $translator; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function menu(FactoryInterface $factory, array $options) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->setTranslator($this->container->get('translator')); |
|
32
|
|
|
$permissionApi = $this->container->get('zikula_permissions_module.api.permission'); |
|
33
|
|
|
$defaultGroup = $this->container->get('zikula_extensions_module.api.variable')->get('ZikulaGroupsModule', 'defaultgroup'); |
|
34
|
|
|
$primaryAdminGroup = $this->container->get('zikula_extensions_module.api.variable')->get('ZikulaGroupsModule', 'primaryadmingroup', 2); |
|
35
|
|
|
$gid = $options['group']->getGid(); |
|
36
|
|
|
$routeParams = ['gid' => $gid]; |
|
37
|
|
|
$menu = $factory->createItem('adminActions'); |
|
38
|
|
|
$menu->setChildrenAttribute('class', 'list-inline'); |
|
39
|
|
|
$menu->addChild($this->__f('Edit ":name" group', [':name' => $options['group']->getName()]), [ |
|
40
|
|
|
'route' => 'zikulagroupsmodule_group_edit', |
|
41
|
|
|
'routeParameters' => $routeParams, |
|
42
|
|
|
])->setAttribute('icon', 'fa fa-pencil'); |
|
43
|
|
|
if ($permissionApi->hasPermission('ZikulaGroupsModule::', $gid . '::', ACCESS_DELETE) |
|
44
|
|
|
&& $gid != $defaultGroup && $gid != $primaryAdminGroup) { |
|
45
|
|
|
$menu->addChild($this->__f('Delete ":name" group', [':name' => $options['group']->getName()]), [ |
|
46
|
|
|
'route' => 'zikulagroupsmodule_group_remove', |
|
47
|
|
|
'routeParameters' => $routeParams, |
|
48
|
|
|
])->setAttribute('icon', 'fa fa-trash-o'); |
|
49
|
|
|
} |
|
50
|
|
|
$menu->addChild($this->__('Group membership'), [ |
|
51
|
|
|
'route' => 'zikulagroupsmodule_membershipadministration_list', |
|
52
|
|
|
'routeParameters' => $routeParams, |
|
53
|
|
|
])->setAttribute('icon', 'fa fa-users'); |
|
54
|
|
|
|
|
55
|
|
|
return $menu; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|