|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* EGroupware Admin: Hooks |
|
4
|
|
|
* |
|
5
|
|
|
* @link http://www.egroupware.org |
|
6
|
|
|
* @author Stefan Becker <StefanBecker-AT-outdoor-training.de> |
|
7
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
|
8
|
|
|
* @package admin |
|
9
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
10
|
|
|
* @version $Id$ |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
use EGroupware\Api; |
|
14
|
|
|
use EGroupware\Api\Egw; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Static hooks for admin application |
|
18
|
|
|
*/ |
|
19
|
|
|
class admin_hooks |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Functions callable via menuaction |
|
23
|
|
|
* |
|
24
|
|
|
* @var array |
|
25
|
|
|
*/ |
|
26
|
|
|
var $public_functions = array( |
|
27
|
|
|
'ajax_clear_cache' => True, |
|
28
|
|
|
); |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* hooks to build projectmanager's sidebox-menu |
|
32
|
|
|
* |
|
33
|
|
|
* @param string/array $args hook args |
|
|
|
|
|
|
34
|
|
|
*/ |
|
35
|
|
|
static function all_hooks($args) |
|
36
|
|
|
{ |
|
37
|
|
|
unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
|
38
|
|
|
|
|
39
|
|
|
$appname = 'admin'; |
|
40
|
|
|
$location = is_array($args) ? $args['location'] : $args; |
|
41
|
|
|
|
|
42
|
|
|
if ($location == 'sidebox_menu') |
|
43
|
|
|
{ |
|
44
|
|
|
// Destination div for folder tree |
|
45
|
|
|
$file[] = array( |
|
|
|
|
|
|
46
|
|
|
'no_lang' => true, |
|
47
|
|
|
// Tree has about 20 leaves (or more) in it, but the sidebox starts |
|
48
|
|
|
// with no content. Set some minimum height to make sure scrolling is triggered. |
|
49
|
|
|
'text' => '<div id="admin_tree_target" class="admin_tree" style="min-height:20em"/>', |
|
50
|
|
|
'link' => false, |
|
51
|
|
|
'icon' => false |
|
52
|
|
|
); |
|
53
|
|
|
display_sidebox($appname,lang('Admin'),$file); |
|
|
|
|
|
|
54
|
|
|
return; |
|
55
|
|
|
} |
|
56
|
|
|
if ($GLOBALS['egw_info']['user']['apps']['admin']) |
|
57
|
|
|
{ |
|
58
|
|
|
|
|
59
|
|
|
if (! $GLOBALS['egw']->acl->check('site_config_acce',1,'admin')) |
|
60
|
|
|
{ |
|
61
|
|
|
$file['Site Configuration'] = Egw::link('/index.php','menuaction=admin.admin_config.index&appname=admin&ajax=true'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
if (! $GLOBALS['egw']->acl->check('account_access',1,'admin')) |
|
65
|
|
|
{ |
|
66
|
|
|
$file['User Accounts'] = array( |
|
67
|
|
|
'id' => '/accounts', |
|
68
|
|
|
'icon' => Api\Image::find('addressbook', 'accounts'), |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
if (! $GLOBALS['egw']->acl->check('account_access',16,'admin')) |
|
73
|
|
|
{ |
|
74
|
|
|
$file['Bulk password reset'] = Egw::link('/index.php','menuaction=admin.admin_passwordreset.index&ajax=true'); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
if (! $GLOBALS['egw']->acl->check('group_access',1,'admin')) |
|
78
|
|
|
{ |
|
79
|
|
|
$file['User Groups'] = array( |
|
80
|
|
|
'id' => '/groups', |
|
81
|
|
|
'icon' => Api\Image::find('addressbook', 'group'), |
|
82
|
|
|
'child' => 1, |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
if (! $GLOBALS['egw']->acl->check('global_categorie',1,'admin')) |
|
87
|
|
|
{ |
|
88
|
|
|
$file['Global Categories'] = Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=phpgw&ajax=true'); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
if (!$GLOBALS['egw']->acl->check('mainscreen_messa',1,'admin') || !$GLOBALS['egw']->acl->check('mainscreen_messa',2,'admin')) |
|
92
|
|
|
{ |
|
93
|
|
|
$file['Change Login Screen Message'] = Egw::link('/index.php','menuaction=admin.admin_messages.index'); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
if (! $GLOBALS['egw']->acl->check('current_sessions',1,'admin')) |
|
97
|
|
|
{ |
|
98
|
|
|
$file['View Sessions'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.sessions&ajax=true'); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
if (! $GLOBALS['egw']->acl->check('access_log_acces',1,'admin')) |
|
102
|
|
|
{ |
|
103
|
|
|
$file['View Access Log'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.index&ajax=true'); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/* disable old EGroupware error_log, as it is not used anymore |
|
107
|
|
|
if (! $GLOBALS['egw']->acl->check('error_log_access',1,'admin')) |
|
108
|
|
|
{ |
|
109
|
|
|
$file['View Error Log'] = Egw::link('/index.php','menuaction=admin.uilog.list_log'); |
|
110
|
|
|
}*/ |
|
111
|
|
|
|
|
112
|
|
|
if (! $GLOBALS['egw']->acl->check('applications_acc',16,'admin')) |
|
113
|
|
|
{ |
|
114
|
|
|
$file['Clear cache and register hooks'] = array( |
|
115
|
|
|
'id' => 'admin/clear_cache', |
|
116
|
|
|
'no_lang' => true, |
|
117
|
|
|
'link' => "javascript:app.admin.clear_cache();", |
|
118
|
|
|
); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
if (! $GLOBALS['egw']->acl->check('asyncservice_acc',1,'admin')) |
|
122
|
|
|
{ |
|
123
|
|
|
$file['Asynchronous timed services'] = Egw::link('/index.php','menuaction=admin.admin_asyncservice.index'); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
if (! $GLOBALS['egw']->acl->check('db_backup_access',1,'admin')) |
|
127
|
|
|
{ |
|
128
|
|
|
$file['DB backup and restore'] = Egw::link('/index.php','menuaction=admin.admin_db_backup.index'); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
if (! $GLOBALS['egw']->acl->check('info_access',1,'admin')) |
|
132
|
|
|
{ |
|
133
|
|
|
$file['phpInfo'] = "javascript:egw.openPopup('" . Egw::link('/admin/phpinfo.php','',false) . "',960,600,'phpinfoWindow')"; |
|
134
|
|
|
} |
|
135
|
|
|
$file['Admin queue and history'] = Egw::link('/index.php','menuaction=admin.admin_cmds.index&ajax=true'); |
|
136
|
|
|
$file['Remote administration instances'] = Egw::link('/index.php','menuaction=admin.admin_cmds.remotes&ajax=true'); |
|
137
|
|
|
$file['Custom translation'] = Egw::link('/index.php','menuaction=admin.admin_customtranslation.index'); |
|
138
|
|
|
$file['Changelog and versions'] = Egw::link('/index.php','menuaction=api.EGroupware\\Api\\Framework\\About.index&ajax=true'); |
|
139
|
|
|
|
|
140
|
|
|
$file['Submit statistic information'] = Egw::link('/index.php','menuaction=admin.admin_statistics.submit'); |
|
141
|
|
|
|
|
142
|
|
|
if ($location == 'admin') |
|
143
|
|
|
{ |
|
144
|
|
|
display_section($appname,$file); |
|
145
|
|
|
} |
|
146
|
|
|
else |
|
147
|
|
|
{ |
|
148
|
|
|
foreach($file as &$url) |
|
149
|
|
|
{ |
|
150
|
|
|
if (is_array($url) && $url['link']) $url = $url['link']; |
|
151
|
|
|
} |
|
152
|
|
|
display_sidebox($appname,lang('Admin'),$file); |
|
|
|
|
|
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* Clears instance cache (and thereby also refreshes hooks) |
|
159
|
|
|
*/ |
|
160
|
|
|
function ajax_clear_cache() |
|
161
|
|
|
{ |
|
162
|
|
|
if ($GLOBALS['egw']->acl->check('applications_acc',16,'admin')) |
|
163
|
|
|
{ |
|
164
|
|
|
$GLOBALS['egw']->redirect_link('/index.php'); |
|
165
|
|
|
} |
|
166
|
|
|
Api\Cache::flush(Api\Cache::INSTANCE, !empty($_GET['errored']) ? "all" : null); |
|
167
|
|
|
|
|
168
|
|
|
Api\Image::invalidate(); |
|
169
|
|
|
|
|
170
|
|
|
if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) // Egw object in setup is limited |
|
171
|
|
|
{ |
|
172
|
|
|
$GLOBALS['egw']->invalidate_session_cache(); // in case with cache the egw_info array in the session |
|
173
|
|
|
} |
|
174
|
|
|
// allow apps to hook into "Admin >> Clear cache and register hooks" |
|
175
|
|
|
Api\Hooks::process('clear_cache', array(), true); |
|
176
|
|
|
|
|
177
|
|
|
Api\Json\Response::get()->apply('egw.message', array(lang('Done'), 'success')); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* Actions for context menu of users |
|
182
|
|
|
* |
|
183
|
|
|
* @return array of actions |
|
184
|
|
|
*/ |
|
185
|
|
|
public static function edit_user() |
|
186
|
|
|
{ |
|
187
|
|
|
$actions = array(); |
|
188
|
|
|
|
|
189
|
|
|
$actions[] = array( |
|
190
|
|
|
'id' => 'acl', |
|
191
|
|
|
'caption' => 'Access control', |
|
192
|
|
|
'url' => 'menuaction=admin.admin_acl.index&account_id=$id', |
|
193
|
|
|
'popup' => '900x450', |
|
194
|
|
|
'icon' => 'lock', |
|
195
|
|
|
); |
|
196
|
|
|
|
|
197
|
|
|
if (!$GLOBALS['egw']->acl->check('current_sessions',1,'admin')) // no rights to view |
|
198
|
|
|
{ |
|
199
|
|
|
$actions[] = array( |
|
200
|
|
|
'description' => 'Login History', |
|
201
|
|
|
'url' => '/index.php', |
|
202
|
|
|
'extradata' => 'menuaction=admin.admin_accesslog.index', |
|
203
|
|
|
'icon' => 'timesheet', |
|
204
|
|
|
); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights |
|
208
|
|
|
{ |
|
209
|
|
|
$actions[] = array( |
|
210
|
|
|
'description' => 'Deny access', |
|
211
|
|
|
'url' => '/index.php', |
|
212
|
|
|
'extradata' => 'menuaction=admin.admin_denyaccess.list_apps', |
|
213
|
|
|
'icon' => 'cancel', |
|
214
|
|
|
); |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
// currently no way to deny Admins access to administrate mail |
|
218
|
|
|
// we could add a deny check as for other admin functionality |
|
219
|
|
|
{ |
|
220
|
|
|
$actions[] = array( |
|
221
|
|
|
'id' => 'mail_account', |
|
222
|
|
|
'caption' => 'mail account', |
|
223
|
|
|
'url' => 'menuaction=admin.admin_mail.edit&account_id=$id', |
|
224
|
|
|
'popup' => '720x530', |
|
225
|
|
|
'icon' => 'mail/navbar', |
|
226
|
|
|
); |
|
227
|
|
|
|
|
228
|
|
|
$emailadmin = Api\Mail\Account::get_default(); |
|
229
|
|
|
if ($emailadmin->acc_smtp_type && $emailadmin->acc_smtp_type !== 'EGroupware\Api\Mail\Smtp') |
|
230
|
|
|
{ |
|
231
|
|
|
$actions[] = array ( |
|
232
|
|
|
'id' => 'mail_activeAccounts', |
|
233
|
|
|
'caption' => '(de)activate mail accounts', |
|
234
|
|
|
'icon' => 'mail/navbar', |
|
235
|
|
|
'children' => array ( |
|
236
|
|
|
'active' => array ( |
|
237
|
|
|
'caption' => 'activate', |
|
238
|
|
|
'onExecute' => 'javaScript:app.admin.emailadminActiveAccounts', |
|
239
|
|
|
'icon' => 'check', |
|
240
|
|
|
'allowOnMultiple' => true |
|
241
|
|
|
), |
|
242
|
|
|
'inactive' => array ( |
|
243
|
|
|
'caption' => 'deactivate', |
|
244
|
|
|
'onExecute' => 'javaScript:app.admin.emailadminActiveAccounts', |
|
245
|
|
|
'icon' => 'bullet', |
|
246
|
|
|
'allowOnMultiple' => true |
|
247
|
|
|
) |
|
248
|
|
|
) |
|
249
|
|
|
); |
|
250
|
|
|
} |
|
251
|
|
|
} |
|
252
|
|
|
return $actions; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* Called before displaying site configuration |
|
257
|
|
|
* |
|
258
|
|
|
* @param array $config |
|
259
|
|
|
* @return array with additional Api\Config to merge |
|
260
|
|
|
*/ |
|
261
|
|
|
public static function config(array $config) |
|
262
|
|
|
{ |
|
263
|
|
|
$ret = array(); |
|
264
|
|
|
if (empty($config['fw_mobile_app_list'])) |
|
265
|
|
|
{ |
|
266
|
|
|
$ret['fw_mobile_app_list'] = Api\Framework\Ajax::DEFAULT_MOBILE_APPS; |
|
267
|
|
|
} |
|
268
|
|
|
return $ret; |
|
269
|
|
|
} |
|
270
|
|
|
} |
|
271
|
|
|
|