Elgg
Version master
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
engine
classes
Elgg
Menus
AdminUsersBulk.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Elgg\Menus
;
4
5
use
Elgg\Menu\MenuItems
;
6
use
Elgg\Menu\PreparedMenu
;
7
use
Elgg\Menu\MenuSection
;
8
15
class
AdminUsersBulk
{
16
24
public
static
function
registerActions
(\
Elgg
\
Event
$event) {
25
if
(!
elgg_is_admin_logged_in
()) {
26
return
;
27
}
28
29
/* @var $return MenuItems */
30
$return = $event->getValue();
31
32
if
((
bool
) $event->getParam(
'show_ban'
,
true
)) {
33
$return[] =
\ElggMenuItem::factory
([
34
'name'
=>
'ban'
,
35
'icon'
=>
'ban'
,
36
'text'
=>
elgg_echo
(
'ban'
),
37
'href'
=>
elgg_generate_action_url
(
'admin/user/bulk/ban'
, [],
false
),
38
'priority'
=> 100,
39
]);
40
}
41
42
if
((
bool
) $event->getParam(
'show_unban'
,
true
)) {
43
$return[] =
\ElggMenuItem::factory
([
44
'name'
=>
'unban'
,
45
'icon'
=>
'ban'
,
46
'text'
=>
elgg_echo
(
'unban'
),
47
'href'
=>
elgg_generate_action_url
(
'admin/user/bulk/unban'
, [],
false
),
48
'priority'
=> 200,
49
]);
50
}
51
52
if
((
bool
) $event->getParam(
'show_validate'
,
false
)) {
53
$return[] =
\ElggMenuItem::factory
([
54
'icon'
=>
'check'
,
55
'name'
=>
'validate'
,
56
'text'
=>
elgg_echo
(
'validate'
),
57
'href'
=>
elgg_generate_action_url
(
'admin/user/bulk/validate'
),
58
'priority'
=> 400,
59
]);
60
}
61
62
if
((
bool
) $event->getParam(
'show_delete'
,
true
)) {
63
$return[] =
\ElggMenuItem::factory
([
64
'name'
=>
'delete'
,
65
'icon'
=>
'delete'
,
66
'text'
=>
elgg_echo
(
'delete'
),
67
'href'
=>
elgg_generate_action_url
(
'admin/user/bulk/delete'
, [],
false
),
68
'confirm'
=>
elgg_echo
(
'deleteconfirm:plural'
),
69
'priority'
=> 900,
70
'link_class'
=> [
'elgg-button-delete'
],
71
]);
72
}
73
74
return
$return;
75
}
76
84
public
static
function
disableItems
(\
Elgg
\
Event
$event): ?
PreparedMenu
{
85
$menu
= $event->getValue();
86
if
(!
$menu
instanceof
PreparedMenu
) {
87
return
null;
88
}
89
90
$disable =
function
(
\ElggMenuItem
$menu_item) use (&$disable) {
91
if
(!empty($menu_item->getHref())) {
92
$menu_item->disabled =
true
;
93
}
94
95
foreach
($menu_item->getChildren() as $child) {
96
$disable($child);
97
}
98
};
99
100
/* @var $section MenuSection */
101
foreach
(
$menu
as
$section
) {
102
/* @var $menu_item \ElggMenuItem */
103
foreach
($section as $menu_item) {
104
$disable($menu_item);
105
}
106
}
107
108
return
$menu
;
109
}
110
}
elgg_generate_action_url
elgg_generate_action_url(string $action, array $query=[], bool $add_csrf_tokens=true)
Generate an action URL.
Definition:
pagehandler.php:197
Elgg\Menus\AdminUsersBulk\disableItems
static disableItems(\Elgg\Event $event)
Disable all items which have a href.
Definition:
AdminUsersBulk.php:84
elgg_is_admin_logged_in
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition:
sessions.php:52
$section
$section
Definition:
section.php:30
Elgg\Menus\AdminUsersBulk\registerActions
static registerActions(\Elgg\Event $event)
Add the bulk actions.
Definition:
AdminUsersBulk.php:24
elgg_echo
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition:
languages.php:17
ElggMenuItem\factory
static factory(array $options)
Create an ElggMenuItem from an associative array.
Definition:
ElggMenuItem.php:130
Elgg\Menus\AdminUsersBulk
Register menu items to the bulk actions for users.
Definition:
AdminUsersBulk.php:15
ElggMenuItem
Elgg Menu Item.
Definition:
ElggMenuItem.php:14
MenuItems
Elgg
Definition:
ActionsService.php:3
Elgg\Menus
Definition:
AdminControlPanel.php:3
Elgg\Menu\PreparedMenu
Represents a menu that has been broken down into sections, with menu hierarchy trees setup...
Definition:
PreparedMenu.php:11
$menu
$menu
Form body for setting up site menu.
Definition:
save.php:7
MenuSection
PreparedMenu
Elgg\Event
Models an event passed to event handlers.
Definition:
Event.php:11
Generated on Sat Dec 21 2024 00:02:52 for Elgg by
1.8.11