1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - account administration * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * -------------------------------------------- * |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | \**************************************************************************/ |
---|
11 | |
---|
12 | class uiaccounts |
---|
13 | { |
---|
14 | var $public_functions = array |
---|
15 | ( |
---|
16 | 'list_groups' => True, |
---|
17 | 'list_users' => True, |
---|
18 | 'add_group' => True, |
---|
19 | 'add_user' => True, |
---|
20 | 'delete_group' => True, |
---|
21 | 'delete_user' => True, |
---|
22 | 'edit_user' => True, |
---|
23 | 'edit_user_hook' => True, |
---|
24 | 'edit_group' => True, |
---|
25 | 'view_user' => True, |
---|
26 | 'edit_view_user_hook' => True, |
---|
27 | 'group_manager' => True, |
---|
28 | ); |
---|
29 | |
---|
30 | var $bo; |
---|
31 | var $nextmatchs; |
---|
32 | var $apps_with_acl = array( |
---|
33 | 'addressbook' => True, |
---|
34 | 'todo' => True, |
---|
35 | 'calendar' => True, |
---|
36 | 'notes' => True, |
---|
37 | 'projects' => True, |
---|
38 | 'phonelog' => True, |
---|
39 | 'infolog' => True, |
---|
40 | 'filemanager' => True, |
---|
41 | 'tts' => True, |
---|
42 | 'bookmarks' => True, |
---|
43 | 'img' => True, |
---|
44 | 'netsaint' => True, |
---|
45 | 'inv' => True, |
---|
46 | 'phpbrain' => True, |
---|
47 | ); |
---|
48 | |
---|
49 | function uiaccounts() |
---|
50 | { |
---|
51 | $this->bo = createobject('admin.boaccounts'); |
---|
52 | $this->nextmatchs = createobject('phpgwapi.nextmatchs'); |
---|
53 | @set_time_limit(300); |
---|
54 | } |
---|
55 | |
---|
56 | function row_action($action,$type,$account_id) |
---|
57 | { |
---|
58 | return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array( |
---|
59 | 'menuaction' => 'admin.uiaccounts.'.$action.'_'.$type, |
---|
60 | 'account_id' => $account_id |
---|
61 | )).'"> '.lang($action).' </a>'; |
---|
62 | } |
---|
63 | |
---|
64 | function list_groups() |
---|
65 | { |
---|
66 | if ($GLOBALS['phpgw']->acl->check('group_access',1,'admin')) |
---|
67 | { |
---|
68 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php')); |
---|
69 | } |
---|
70 | |
---|
71 | $GLOBALS['cd'] = ($_GET['cd']?$_GET['cd']:0); |
---|
72 | |
---|
73 | if(isset($_POST['query'])) |
---|
74 | { |
---|
75 | // limit query to limit characters |
---|
76 | if(eregi('^[a-z_0-9]+$',$_POST['query'])) |
---|
77 | $GLOBALS['query'] = $_POST['query']; |
---|
78 | } |
---|
79 | |
---|
80 | if(isset($_POST['start'])) |
---|
81 | { |
---|
82 | $start = (int)$_POST['start']; |
---|
83 | } |
---|
84 | else |
---|
85 | { |
---|
86 | $start = 0; |
---|
87 | } |
---|
88 | |
---|
89 | switch($_GET['order']) |
---|
90 | { |
---|
91 | case 'account_lid': |
---|
92 | $order = $_GET['order']; |
---|
93 | break; |
---|
94 | default: |
---|
95 | $order = 'account_lid'; |
---|
96 | break; |
---|
97 | } |
---|
98 | |
---|
99 | switch($_GET['sort']) |
---|
100 | { |
---|
101 | case 'ASC': |
---|
102 | case 'DESC': |
---|
103 | $sort = $_GET['sort']; |
---|
104 | break; |
---|
105 | default: |
---|
106 | $sort = 'ASC'; |
---|
107 | break; |
---|
108 | } |
---|
109 | |
---|
110 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
111 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
112 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
113 | { |
---|
114 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
115 | } |
---|
116 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
117 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['admin']['title'].' - '. |
---|
118 | lang('User groups'); |
---|
119 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
120 | |
---|
121 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
122 | $p->set_file( |
---|
123 | array( |
---|
124 | 'groups' => 'groups.tpl' |
---|
125 | ) |
---|
126 | ); |
---|
127 | $p->set_block('groups','list','list'); |
---|
128 | $p->set_block('groups','row','row'); |
---|
129 | $p->set_block('groups','row_empty','row_empty'); |
---|
130 | |
---|
131 | if (! $GLOBALS['phpgw']->acl->check('account_access',2,'admin')) |
---|
132 | { |
---|
133 | $account_info = $GLOBALS['phpgw']->accounts->get_list('groups',$start,$sort, $order, $GLOBALS['query']); |
---|
134 | } |
---|
135 | else |
---|
136 | { |
---|
137 | $account_info = $GLOBALS['phpgw']->accounts->get_list('groups',$start,$sort, $order); |
---|
138 | } |
---|
139 | $total = $GLOBALS['phpgw']->accounts->total; |
---|
140 | |
---|
141 | $var = Array( |
---|
142 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
143 | 'left_next_matchs' => $this->nextmatchs->left('/index.php',$start,$total,'menuaction=admin.uiaccounts.list_groups'), |
---|
144 | 'right_next_matchs' => $this->nextmatchs->right('/index.php',$start,$total,'menuaction=admin.uiaccounts.list_groups'), |
---|
145 | 'lang_groups' => lang('%1 - %2 of %3 user groups',$start+1,$start+count($account_info),$total), |
---|
146 | 'sort_name' => $this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('name'),'menuaction=admin.uiaccounts.list_groups'), |
---|
147 | 'header_edit' => lang('Edit'), |
---|
148 | 'header_delete' => lang('Delete') |
---|
149 | ); |
---|
150 | $p->set_var($var); |
---|
151 | |
---|
152 | if (!count($account_info) || !$total) |
---|
153 | { |
---|
154 | $p->set_var('message',lang('No matches found')); |
---|
155 | $p->parse('rows','row_empty',True); |
---|
156 | } |
---|
157 | else |
---|
158 | { |
---|
159 | if (! $GLOBALS['phpgw']->acl->check('group_access',8,'admin')) |
---|
160 | { |
---|
161 | $can_view = True; |
---|
162 | } |
---|
163 | |
---|
164 | if (! $GLOBALS['phpgw']->acl->check('group_access',16,'admin')) |
---|
165 | { |
---|
166 | $can_edit = True; |
---|
167 | } |
---|
168 | |
---|
169 | if (! $GLOBALS['phpgw']->acl->check('group_access',32,'admin')) |
---|
170 | { |
---|
171 | $can_delete = True; |
---|
172 | } |
---|
173 | |
---|
174 | foreach($account_info as $account) |
---|
175 | { |
---|
176 | $tr_color = $this->nextmatchs->alternate_row_color($tr_color); |
---|
177 | $var = Array( |
---|
178 | 'tr_color' => $tr_color, |
---|
179 | 'group_name' => (!$account['account_lid']?' ':$account['account_lid']), |
---|
180 | 'delete_link' => $this->row_action('delete','group',$account['account_id']) |
---|
181 | ); |
---|
182 | $p->set_var($var); |
---|
183 | |
---|
184 | if ($can_edit) |
---|
185 | { |
---|
186 | $p->set_var('edit_link',$this->row_action('edit','group',$account['account_id'])); |
---|
187 | } |
---|
188 | else |
---|
189 | { |
---|
190 | $p->set_var('edit_link',' '); |
---|
191 | } |
---|
192 | |
---|
193 | if ($can_delete) |
---|
194 | { |
---|
195 | $p->set_var('delete_link',$this->row_action('delete','group',$account['account_id'])); |
---|
196 | } |
---|
197 | else |
---|
198 | { |
---|
199 | $p->set_var('delete_link',' '); |
---|
200 | } |
---|
201 | |
---|
202 | $p->fp('rows','row',True); |
---|
203 | |
---|
204 | } |
---|
205 | } |
---|
206 | $var = Array( |
---|
207 | 'new_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.add_group'), |
---|
208 | 'search_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups') |
---|
209 | ); |
---|
210 | $p->set_var($var); |
---|
211 | |
---|
212 | if (! $GLOBALS['phpgw']->acl->check('group_access',4,'admin')) |
---|
213 | { |
---|
214 | $p->set_var('input_add','<input type="submit" value="' . lang('Add') . '">'); |
---|
215 | } |
---|
216 | |
---|
217 | if (! $GLOBALS['phpgw']->acl->check('group_access',2,'admin')) |
---|
218 | { |
---|
219 | $p->set_var('input_search',lang('Search') . ' <input name="query" value="'.htmlspecialchars(stripslashes($GLOBALS['query'])).'">'); |
---|
220 | } |
---|
221 | |
---|
222 | $p->pfp('out','list'); |
---|
223 | } |
---|
224 | |
---|
225 | function list_users($param_cd='') |
---|
226 | { |
---|
227 | if ($GLOBALS['phpgw']->acl->check('account_access',1,'admin')) |
---|
228 | { |
---|
229 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/admin/index.php')); |
---|
230 | } |
---|
231 | if (!is_object($GLOBALS['phpgw']->html)) |
---|
232 | { |
---|
233 | $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); |
---|
234 | } |
---|
235 | |
---|
236 | if($param_cd) |
---|
237 | { |
---|
238 | $cd = $param_cd; |
---|
239 | } |
---|
240 | |
---|
241 | if(isset($_REQUEST['query'])) |
---|
242 | { |
---|
243 | // limit query to limit characters |
---|
244 | if(eregi('^[a-z_0-9]+$',$_REQUEST['query'])) |
---|
245 | $GLOBALS['query'] = $_REQUEST['query']; |
---|
246 | } |
---|
247 | |
---|
248 | if(isset($_REQUEST['start'])) |
---|
249 | { |
---|
250 | $start = (int)$_REQUEST['start']; |
---|
251 | } |
---|
252 | else |
---|
253 | { |
---|
254 | $start = 0; |
---|
255 | } |
---|
256 | |
---|
257 | switch($_REQUEST['order']) |
---|
258 | { |
---|
259 | case 'account_lastname': |
---|
260 | case 'account_firstname': |
---|
261 | case 'account_lid': |
---|
262 | case 'account_email': |
---|
263 | $order = $_REQUEST['order']; |
---|
264 | break; |
---|
265 | default: |
---|
266 | $order = 'account_lid'; |
---|
267 | break; |
---|
268 | } |
---|
269 | |
---|
270 | switch($_REQUEST['sort']) |
---|
271 | { |
---|
272 | case 'ASC': |
---|
273 | case 'DESC': |
---|
274 | $sort = $_REQUEST['sort']; |
---|
275 | break; |
---|
276 | default: |
---|
277 | $sort = 'ASC'; |
---|
278 | break; |
---|
279 | } |
---|
280 | |
---|
281 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
282 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
283 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
284 | { |
---|
285 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
286 | } |
---|
287 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
288 | $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['admin']['title'].' - '. |
---|
289 | lang('User accounts'); |
---|
290 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
291 | |
---|
292 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
293 | |
---|
294 | $p->set_file( |
---|
295 | Array( |
---|
296 | 'list' => 'accounts.tpl' |
---|
297 | ) |
---|
298 | ); |
---|
299 | $p->set_block('list','row','rows'); |
---|
300 | $p->set_block('list','row_empty','row_empty'); |
---|
301 | $p->set_block('list','letter_search','letter_search_cells'); |
---|
302 | |
---|
303 | $search_param = array( |
---|
304 | 'type' => (int)$_REQUEST['group_id'] > 0 ? $_REQUEST['group_id'] : 'accounts', |
---|
305 | 'start' => $start, |
---|
306 | 'sort' => $sort, |
---|
307 | 'order' => $order, |
---|
308 | 'query_type' => $_REQUEST['query_type'], |
---|
309 | ); |
---|
310 | if (!$GLOBALS['phpgw']->acl->check('account_access',2,'admin')) |
---|
311 | { |
---|
312 | $search_param['query'] = $GLOBALS['query']; |
---|
313 | } |
---|
314 | $account_info = $GLOBALS['phpgw']->accounts->search($search_param); |
---|
315 | $total = $GLOBALS['phpgw']->accounts->total; |
---|
316 | |
---|
317 | $link_data = array( |
---|
318 | 'menuaction' => 'admin.uiaccounts.list_users', |
---|
319 | 'group_id' => $_REQUEST['group_id'], |
---|
320 | 'query_type' => $_REQUEST['query_type'], |
---|
321 | ); |
---|
322 | $uiaccountsel = CreateObject('phpgwapi.uiaccountsel'); |
---|
323 | $p->set_var(array( |
---|
324 | 'left_next_matchs' => $this->nextmatchs->left('/index.php',$start,$total,$link_data), |
---|
325 | 'lang_showing' => ($_REQUEST['group_id'] ? $GLOBALS['phpgw']->common->grab_owner_name($_REQUEST['group_id']).': ' : ''). |
---|
326 | ($GLOBALS['query'] ? lang("Search %1 '%2'",lang($uiaccountsel->query_types[$_REQUEST['query_type']]),$GLOBALS['query']).': ' : '') |
---|
327 | .$this->nextmatchs->show_hits($total,$start), |
---|
328 | 'right_next_matchs' => $this->nextmatchs->right('/index.php',$start,$total,$link_data), |
---|
329 | 'lang_loginid' => $this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('LoginID'),$link_data), |
---|
330 | 'lang_lastname' => $this->nextmatchs->show_sort_order($sort,'account_lastname',$order,'/index.php',lang('last name'),$link_data), |
---|
331 | 'lang_firstname' => $this->nextmatchs->show_sort_order($sort,'account_firstname',$order,'/index.php',lang('first name'),$link_data), |
---|
332 | 'lang_email' => $this->nextmatchs->show_sort_order($sort,'account_email',$order,'/index.php',lang('email'),$link_data), |
---|
333 | 'lang_edit' => lang('edit'), |
---|
334 | 'lang_delete' => lang('delete'), |
---|
335 | 'lang_view' => lang('view'), |
---|
336 | 'lang_search' => lang('search') |
---|
337 | )); |
---|
338 | $link_data += array( |
---|
339 | 'order' => $order, |
---|
340 | 'sort' => $sort, |
---|
341 | ); |
---|
342 | $p->set_var(array( |
---|
343 | 'query_type' => is_array($uiaccountsel->query_types) ? $GLOBALS['phpgw']->html->select('query_type',$_REQUEST['query_type'],$uiaccountsel->query_types) : '', |
---|
344 | 'lang_group' => lang('group'), |
---|
345 | 'group' => $uiaccountsel->selection('group_id','admin_uiaccount_listusers_group_id',$_REQUEST['group_id'],'groups',0,False,'','this.form.submit();',lang('all')), |
---|
346 | 'accounts_url' => $GLOBALS['phpgw']->link('/index.php',$link_data), |
---|
347 | )); |
---|
348 | $letters = lang('alphabet'); |
---|
349 | $letters = explode(',',substr($letters,-1) != '*' ? $letters : 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z'); |
---|
350 | $link_data['query_type'] = 'start'; |
---|
351 | foreach($letters as $letter) |
---|
352 | { |
---|
353 | $link_data['query'] = $letter; |
---|
354 | $p->set_var(array( |
---|
355 | 'letter' => $letter, |
---|
356 | 'link' => $GLOBALS['phpgw']->link('/index.php',$link_data), |
---|
357 | 'class' => $GLOBALS['query'] == $letter && $_REQUEST['query_type'] == 'start' ? 'letter_box_active' : 'letter_box', |
---|
358 | )); |
---|
359 | $p->fp('letter_search_cells','letter_search',True); |
---|
360 | } |
---|
361 | unset($link_data['query']); |
---|
362 | unset($link_data['query_type']); |
---|
363 | $p->set_var(array( |
---|
364 | 'letter' => lang('all'), |
---|
365 | 'link' => $GLOBALS['phpgw']->link('/index.php',$link_data), |
---|
366 | 'class' => $_REQUEST['query_type'] != 'start' || !in_array($GLOBALS['query'],$letters) ? 'letter_box_active' : 'letter_box', |
---|
367 | )); |
---|
368 | $p->fp('letter_search_cells','letter_search',True); |
---|
369 | |
---|
370 | if (! $GLOBALS['phpgw']->acl->check('account_access',4,'admin')) |
---|
371 | { |
---|
372 | $p->set_var('new_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.add_user')); |
---|
373 | $p->set_var('input_add','<input type="submit" value="' . lang('Add') . '">'); |
---|
374 | } |
---|
375 | |
---|
376 | if (!count($account_info) || !$total) |
---|
377 | { |
---|
378 | $p->set_var('message',lang('No matches found')); |
---|
379 | $p->parse('rows','row_empty',True); |
---|
380 | } |
---|
381 | else |
---|
382 | { |
---|
383 | if (! $GLOBALS['phpgw']->acl->check('account_access',8,'admin')) |
---|
384 | { |
---|
385 | $can_view = True; |
---|
386 | } |
---|
387 | |
---|
388 | if (! $GLOBALS['phpgw']->acl->check('account_access',16,'admin')) |
---|
389 | { |
---|
390 | $can_edit = True; |
---|
391 | } |
---|
392 | |
---|
393 | if (! $GLOBALS['phpgw']->acl->check('account_access',32,'admin')) |
---|
394 | { |
---|
395 | $can_delete = True; |
---|
396 | } |
---|
397 | |
---|
398 | foreach($account_info as $account) |
---|
399 | { |
---|
400 | $p->set_var('class',$this->nextmatchs->alternate_row_color('',True)); |
---|
401 | |
---|
402 | $p->set_var($account); |
---|
403 | |
---|
404 | if ($can_edit) |
---|
405 | { |
---|
406 | $p->set_var('row_edit',$this->row_action('edit','user',$account['account_id'])); |
---|
407 | } |
---|
408 | else |
---|
409 | { |
---|
410 | $p->set_var('row_edit',' '); |
---|
411 | } |
---|
412 | |
---|
413 | if ($can_delete) |
---|
414 | { |
---|
415 | $p->set_var('row_delete',($GLOBALS['phpgw_info']['user']['userid'] != $account['account_lid']?$this->row_action('delete','user',$account['account_id']):' ')); |
---|
416 | } |
---|
417 | else |
---|
418 | { |
---|
419 | $p->set_var('row_delete',' '); |
---|
420 | } |
---|
421 | |
---|
422 | if ($can_view) |
---|
423 | { |
---|
424 | $p->set_var('row_view',$this->row_action('view','user',$account['account_id'])); |
---|
425 | } |
---|
426 | else |
---|
427 | { |
---|
428 | $p->set_var('row_view',' '); |
---|
429 | } |
---|
430 | $p->parse('rows','row',True); |
---|
431 | } |
---|
432 | } // End else |
---|
433 | $p->pfp('out','list'); |
---|
434 | } |
---|
435 | |
---|
436 | function add_group() |
---|
437 | { |
---|
438 | if ($GLOBALS['phpgw']->acl->check('group_access',4,'admin')) |
---|
439 | { |
---|
440 | $this->list_groups(); |
---|
441 | return False; |
---|
442 | } |
---|
443 | |
---|
444 | $group_info = Array( |
---|
445 | 'account_id' => $_GET['account_id'], |
---|
446 | 'account_name' => '', |
---|
447 | 'account_user' => Array(), |
---|
448 | 'account_apps' => Array() |
---|
449 | ); |
---|
450 | $this->create_edit_group($group_info); |
---|
451 | } |
---|
452 | |
---|
453 | function add_user() |
---|
454 | { |
---|
455 | if ($GLOBALS['phpgw']->acl->check('account_access',4,'admin')) |
---|
456 | { |
---|
457 | $this->list_users(); |
---|
458 | } |
---|
459 | else |
---|
460 | { |
---|
461 | $this->create_edit_user(0); |
---|
462 | } |
---|
463 | } |
---|
464 | |
---|
465 | function delete_group() |
---|
466 | { |
---|
467 | if ($_POST['no'] || $_POST['yes'] || !@isset($_GET['account_id']) || !@$_GET['account_id'] || $GLOBALS['phpgw']->acl->check('group_access',32,'admin')) |
---|
468 | { |
---|
469 | if ($_POST['yes']) |
---|
470 | { |
---|
471 | $this->bo->delete_group(); |
---|
472 | } |
---|
473 | $this->list_groups(); |
---|
474 | return False; |
---|
475 | } |
---|
476 | |
---|
477 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
478 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
479 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
480 | { |
---|
481 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
482 | } |
---|
483 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
484 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
485 | |
---|
486 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
487 | $p->set_file( |
---|
488 | Array( |
---|
489 | 'body' => 'delete_common.tpl', |
---|
490 | 'message_row' => 'message_row.tpl', |
---|
491 | 'form_button' => 'form_button_script.tpl' |
---|
492 | ) |
---|
493 | ); |
---|
494 | |
---|
495 | $p->set_var('message_display',lang('Are you sure you want to delete this group ?')); |
---|
496 | $p->parse('messages','message_row'); |
---|
497 | |
---|
498 | $old_group_list = $GLOBALS['phpgw']->acl->get_ids_for_location((int)$_GET['account_id'],1,'phpgw_group'); |
---|
499 | |
---|
500 | if($old_group_list) |
---|
501 | { |
---|
502 | $group_name = $GLOBALS['phpgw']->accounts->id2name($_GET['account_id']); |
---|
503 | |
---|
504 | $p->set_var('message_display','<br>'); |
---|
505 | $p->parse('messages','message_row',True); |
---|
506 | |
---|
507 | $user_list = ''; |
---|
508 | while (list(,$id) = each($old_group_list)) |
---|
509 | { |
---|
510 | $user_list .= '<a href="' . $GLOBALS['phpgw']->link('/index.php', |
---|
511 | Array( |
---|
512 | 'menuaction' => 'admin.uiaccounts.edit_user', |
---|
513 | 'account_id' => $id |
---|
514 | ) |
---|
515 | ) . '">' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</a><br>'; |
---|
516 | } |
---|
517 | $p->set_var('message_display',$user_list); |
---|
518 | $p->parse('messages','message_row',True); |
---|
519 | |
---|
520 | $p->set_var('message_display',lang("Sorry, the above users are still a member of the group %1",$group_name) |
---|
521 | . '.<br>' . lang('They must be removed before you can continue'). '.<br>' . lang('Remove all users from this group').'?'); |
---|
522 | $p->parse('messages','message_row',True); |
---|
523 | } |
---|
524 | |
---|
525 | $var = Array( |
---|
526 | 'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.delete_group'), |
---|
527 | 'hidden_vars' => '<input type="hidden" name="account_id" value="'.$_GET['account_id'].'">', |
---|
528 | 'yes' => lang('Yes'), |
---|
529 | 'no' => lang('No') |
---|
530 | ); |
---|
531 | $p->set_var($var); |
---|
532 | /* |
---|
533 | $p->parse('yes','form_button'); |
---|
534 | |
---|
535 | $var = Array( |
---|
536 | 'submit_button' => lang('Submit'), |
---|
537 | 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'), |
---|
538 | 'action_text_button' => ' '.lang('No'), |
---|
539 | 'action_confirm_button' => '', |
---|
540 | 'action_extra_field' => '' |
---|
541 | ); |
---|
542 | $p->set_var($var); |
---|
543 | $p->parse('no','form_button'); |
---|
544 | */ |
---|
545 | $p->pparse('phpgw_body','body'); |
---|
546 | } |
---|
547 | |
---|
548 | function delete_user() |
---|
549 | { |
---|
550 | if ($GLOBALS['phpgw']->acl->check('account_access',32,'admin') || $GLOBALS['phpgw_info']['user']['account_id'] == $_GET['account_id']) |
---|
551 | { |
---|
552 | $this->list_users(); |
---|
553 | return False; |
---|
554 | } |
---|
555 | |
---|
556 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
557 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
558 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
559 | { |
---|
560 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
561 | } |
---|
562 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
563 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
564 | |
---|
565 | $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
566 | $t->set_file( |
---|
567 | Array( |
---|
568 | 'form' => 'delete_account.tpl' |
---|
569 | ) |
---|
570 | ); |
---|
571 | $var = Array( |
---|
572 | 'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.delete_user'), |
---|
573 | 'account_id' => $_GET['account_id'] |
---|
574 | ); |
---|
575 | |
---|
576 | // the account can have special chars/white spaces, if it is a ldap dn |
---|
577 | $account_id = rawurlencode($_GET['account_id']); |
---|
578 | |
---|
579 | // Find out who the new owner is of the deleted users records... |
---|
580 | $users = $GLOBALS['phpgw']->accounts->get_list('accounts'); |
---|
581 | $c_users = count($users); |
---|
582 | $str = ''; |
---|
583 | for($i=0;$i<$c_users;$i++) |
---|
584 | { |
---|
585 | $str .= '<option value='.$users[$i]['account_id'].'>'.$GLOBALS['phpgw']->common->display_fullname($users[$i]['account_lid'],$users[$i]['account_firstname'],$users[$i]['account_lastname']).'</option>'."\n"; |
---|
586 | } |
---|
587 | $var['lang_new_owner'] = lang('Who would you like to transfer ALL records owned by the deleted user to?'); |
---|
588 | $var['new_owner_select'] = '<select name="new_owner" size="5">'."\n".'<option value=0 selected>'.lang('Delete All Records').'</option>'."\n".$str.'</select>'."\n"; |
---|
589 | $var['cancel'] = lang('cancel'); |
---|
590 | $var['delete'] = lang('delete'); |
---|
591 | $t->set_var($var); |
---|
592 | $t->pparse('out','form'); |
---|
593 | } |
---|
594 | |
---|
595 | function edit_group($cd='',$account_id='') |
---|
596 | { |
---|
597 | if ($GLOBALS['phpgw']->acl->check('group_access',16,'admin')) |
---|
598 | { |
---|
599 | $this->list_groups(); |
---|
600 | return False; |
---|
601 | } |
---|
602 | |
---|
603 | $cdid = $cd; |
---|
604 | settype($cd,'integer'); |
---|
605 | $cd = ($_GET['cd']?$_GET['cd']:(int)$cdid); |
---|
606 | |
---|
607 | $accountid = $account_id; |
---|
608 | settype($account_id,'integer'); |
---|
609 | $account_id = ($_GET['account_id'] ? $_GET['account_id'] : (int)$accountid); |
---|
610 | |
---|
611 | // todo |
---|
612 | // not needed if i use the same file for new groups too |
---|
613 | if (! $account_id) |
---|
614 | { |
---|
615 | $this->list_groups(); |
---|
616 | } |
---|
617 | else |
---|
618 | { |
---|
619 | $group_info = Array( |
---|
620 | 'account_id' => (int)$_GET['account_id'], |
---|
621 | 'account_name' => $GLOBALS['phpgw']->accounts->id2name($_GET['account_id']), |
---|
622 | 'account_user' => $this->bo->load_group_users($_GET['account_id']), |
---|
623 | 'account_apps' => $this->bo->load_group_apps($_GET['account_id']) |
---|
624 | ); |
---|
625 | $this->create_edit_group($group_info); |
---|
626 | } |
---|
627 | } |
---|
628 | |
---|
629 | function edit_view_user_hook() |
---|
630 | { |
---|
631 | if (!$GLOBALS['phpgw']->acl->check('current_sessions_access',1,'admin')) // no rights to view |
---|
632 | { |
---|
633 | $GLOBALS['menuData'][] = array( |
---|
634 | 'description' => 'Login History', |
---|
635 | 'url' => '/index.php', |
---|
636 | 'extradata' => 'menuaction=admin.uiaccess_history.list_history' |
---|
637 | ); |
---|
638 | } |
---|
639 | // not sure if this realy belongs here, or only in edit_user |
---|
640 | if ($_GET['account_id'] && // can't set it on add |
---|
641 | !$GLOBALS['phpgw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights |
---|
642 | { |
---|
643 | $GLOBALS['menuData'][] = array( |
---|
644 | 'description' => 'ACL Rights', |
---|
645 | 'url' => '/index.php', |
---|
646 | 'extradata' => 'menuaction=admin.uiaclmanager.list_apps' |
---|
647 | ); |
---|
648 | } |
---|
649 | } |
---|
650 | |
---|
651 | function edit_user($cd='',$account_id='') |
---|
652 | { |
---|
653 | if ($GLOBALS['phpgw']->acl->check('account_access',16,'admin')) |
---|
654 | { |
---|
655 | $this->list_users(); |
---|
656 | return False; |
---|
657 | } |
---|
658 | |
---|
659 | $cdid = $cd; |
---|
660 | settype($cd,'integer'); |
---|
661 | $cd = ($_GET['cd']?$_GET['cd']:(int)$cdid); |
---|
662 | |
---|
663 | $accountid = $account_id; |
---|
664 | settype($account_id,'integer'); |
---|
665 | $account_id = (int)($_GET['account_id'] ? $_GET['account_id'] : $accountid); |
---|
666 | |
---|
667 | // todo |
---|
668 | // not needed if i use the same file for new users too |
---|
669 | if (! $account_id) |
---|
670 | { |
---|
671 | $this->list_users(); |
---|
672 | return False; |
---|
673 | } |
---|
674 | else |
---|
675 | { |
---|
676 | $this->create_edit_user($account_id); |
---|
677 | } |
---|
678 | } |
---|
679 | |
---|
680 | function view_user() |
---|
681 | { |
---|
682 | if ($GLOBALS['phpgw']->acl->check('account_access',8,'admin') || ! $_GET['account_id']) |
---|
683 | { |
---|
684 | $this->list_users(); |
---|
685 | return False; |
---|
686 | } |
---|
687 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
688 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
689 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
690 | { |
---|
691 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
692 | } |
---|
693 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
694 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
695 | |
---|
696 | $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
697 | $t->set_unknowns('remove'); |
---|
698 | $t->set_file( |
---|
699 | Array( |
---|
700 | 'account' => 'account_form.tpl' |
---|
701 | ) |
---|
702 | ); |
---|
703 | $t->set_block('account','form','form'); |
---|
704 | $t->set_block('account','form_logininfo'); |
---|
705 | $t->set_block('account','link_row'); |
---|
706 | |
---|
707 | $var = Array( |
---|
708 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
709 | 'tr_color1' => $GLOBALS['phpgw_info']['theme']['row_on'], |
---|
710 | 'tr_color2' => $GLOBALS['phpgw_info']['theme']['row_off'], |
---|
711 | 'lang_action' => lang('View user account'), |
---|
712 | 'lang_loginid' => lang('LoginID'), |
---|
713 | 'lang_account_active' => lang('Account active'), |
---|
714 | 'lang_lastname' => lang('Last Name'), |
---|
715 | 'lang_groups' => lang('Groups'), |
---|
716 | 'lang_anonymous' => lang('Anonymous user (not shown in list sessions)'), |
---|
717 | 'lang_changepassword'=> lang('Can change password'), |
---|
718 | 'lang_firstname' => lang('First Name'), |
---|
719 | 'lang_lastlogin' => lang('Last login'), |
---|
720 | 'lang_lastloginfrom' => lang('Last login from'), |
---|
721 | 'lang_expires' => lang('Expires') |
---|
722 | ); |
---|
723 | |
---|
724 | $t->parse('password_fields','form_logininfo',True); |
---|
725 | |
---|
726 | $account = CreateObject('phpgwapi.accounts',(int)$_GET['account_id'],'u'); |
---|
727 | $userData = $account->read_repository(); |
---|
728 | |
---|
729 | $var['account_lid'] = $userData['account_lid']; |
---|
730 | $var['account_firstname'] = $userData['firstname']; |
---|
731 | $var['account_lastname'] = $userData['lastname']; |
---|
732 | |
---|
733 | $acl = CreateObject('phpgwapi.acl',(int)$_GET['account_id']); |
---|
734 | $var['anonymous'] = $acl->check('anonymous',1,'phpgwapi') ? ' X' : ' '; |
---|
735 | $var['changepassword'] = $acl->check('changepassword',0xFFFF,'preferences') ? ' X' : ' '; |
---|
736 | unset($acl); |
---|
737 | |
---|
738 | if ($userData['status']) |
---|
739 | { |
---|
740 | $var['account_status'] = lang('Enabled'); |
---|
741 | } |
---|
742 | else |
---|
743 | { |
---|
744 | $var['account_status'] = '<b>' . lang('Disabled') . '</b>'; |
---|
745 | } |
---|
746 | |
---|
747 | // Last login time |
---|
748 | if ($userData['lastlogin']) |
---|
749 | { |
---|
750 | $var['account_lastlogin'] = $GLOBALS['phpgw']->common->show_date($userData['lastlogin']); |
---|
751 | } |
---|
752 | else |
---|
753 | { |
---|
754 | $var['account_lastlogin'] = lang('Never'); |
---|
755 | } |
---|
756 | |
---|
757 | // Last login IP |
---|
758 | if ($userData['lastloginfrom']) |
---|
759 | { |
---|
760 | $var['account_lastloginfrom'] = $userData['lastloginfrom']; |
---|
761 | } |
---|
762 | else |
---|
763 | { |
---|
764 | $var['account_lastloginfrom'] = lang('Never'); |
---|
765 | } |
---|
766 | |
---|
767 | // Account expires |
---|
768 | if ($userData['expires'] != -1) |
---|
769 | { |
---|
770 | $var['input_expires'] = $GLOBALS['phpgw']->common->show_date($userData['expires']); |
---|
771 | } |
---|
772 | else |
---|
773 | { |
---|
774 | $var['input_expires'] = lang('Never'); |
---|
775 | } |
---|
776 | |
---|
777 | // Find out which groups they are members of |
---|
778 | $usergroups = $account->membership((int)$_GET['account_id']); |
---|
779 | if(!@is_array($usergroups)) |
---|
780 | { |
---|
781 | $var['groups_select'] = lang('None'); |
---|
782 | } |
---|
783 | else |
---|
784 | { |
---|
785 | while (list(,$group) = each($usergroups)) |
---|
786 | { |
---|
787 | $group_names[] = $group['account_name']; |
---|
788 | } |
---|
789 | $var['groups_select'] = implode(', ',$group_names); |
---|
790 | } |
---|
791 | |
---|
792 | $account_lastlogin = $userData['account_lastlogin']; |
---|
793 | $account_lastloginfrom = $userData['account_lastloginfrom']; |
---|
794 | $account_status = $userData['account_status']; |
---|
795 | |
---|
796 | // create list of available app |
---|
797 | $i = 0; |
---|
798 | |
---|
799 | $availableApps = $GLOBALS['phpgw_info']['apps']; |
---|
800 | @asort($availableApps); |
---|
801 | @reset($availableApps); |
---|
802 | foreach($availableApps as $app => $data) |
---|
803 | { |
---|
804 | if ($data['enabled'] && $data['status'] != 2) |
---|
805 | { |
---|
806 | $perm_display[$i]['appName'] = $app; |
---|
807 | $perm_display[$i]['title'] = $data['title']; |
---|
808 | $i++; |
---|
809 | } |
---|
810 | } |
---|
811 | |
---|
812 | // create apps output |
---|
813 | $apps = CreateObject('phpgwapi.applications',(int)$_GET['account_id']); |
---|
814 | $db_perms = $apps->read_account_specific(); |
---|
815 | |
---|
816 | @reset($db_perms); |
---|
817 | |
---|
818 | for ($i=0;$i<count($perm_display);$i++) |
---|
819 | { |
---|
820 | if ($perm_display[$i]['title']) |
---|
821 | { |
---|
822 | $part1 = sprintf("<td>%s</td><td>%s</td>",$perm_display[$i]['title'],($_userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?' X':' ')); |
---|
823 | } |
---|
824 | |
---|
825 | $i++; |
---|
826 | |
---|
827 | if ($perm_display[$i]['title']) |
---|
828 | { |
---|
829 | $part2 = sprintf("<td>%s</td><td>%s</td>",$perm_display[$i]['title'],($_userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?' X':' ')); |
---|
830 | } |
---|
831 | else |
---|
832 | { |
---|
833 | $part2 = '<td colspan="2"> </td>'; |
---|
834 | } |
---|
835 | |
---|
836 | $appRightsOutput .= sprintf("<tr bgcolor=\"%s\">$part1$part2</tr>\n",$GLOBALS['phpgw_info']['theme']['row_on']); |
---|
837 | } |
---|
838 | |
---|
839 | $var['permissions_list'] = $appRightsOutput; |
---|
840 | |
---|
841 | // create the menu on the left, if needed |
---|
842 | // $menuClass = CreateObject('admin.uimenuclass'); |
---|
843 | // This is now using ExecMethod() |
---|
844 | $var['rows'] = ExecMethod('admin.uimenuclass.createHTMLCode','view_user'); |
---|
845 | $t->set_var($var); |
---|
846 | $t->pfp('out','form'); |
---|
847 | } |
---|
848 | |
---|
849 | function group_manager($cd='',$account_id='') |
---|
850 | { |
---|
851 | if ($GLOBALS['phpgw']->acl->check('group_access',16,'admin')) |
---|
852 | { |
---|
853 | $this->list_groups(); |
---|
854 | return False; |
---|
855 | } |
---|
856 | |
---|
857 | $cdid = $cd; |
---|
858 | settype($cd,'integer'); |
---|
859 | $cd = ($_GET['cd']?$_GET['cd']:(int)$cdid); |
---|
860 | |
---|
861 | $accountid = $account_id; |
---|
862 | settype($account_id,'integer'); |
---|
863 | $account_id = (int)($_GET['account_id'] ? $_GET['account_id'] : $accountid); |
---|
864 | |
---|
865 | // todo |
---|
866 | // not needed if i use the same file for new groups too |
---|
867 | if (! $account_id) |
---|
868 | { |
---|
869 | $this->list_groups(); |
---|
870 | } |
---|
871 | else |
---|
872 | { |
---|
873 | $group_info = Array( |
---|
874 | 'account_id' => (int)$_GET['account_id'], |
---|
875 | 'account_name' => $GLOBALS['phpgw']->accounts->id2name($_GET['account_id']), |
---|
876 | 'account_user' => $GLOBALS['phpgw']->accounts->member($_GET['account_id']), |
---|
877 | 'account_managers' => $this->bo->load_group_managers($_GET['account_id']) |
---|
878 | ); |
---|
879 | |
---|
880 | $this->edit_group_managers($group_info); |
---|
881 | } |
---|
882 | } |
---|
883 | |
---|
884 | function create_edit_group($group_info,$_errors='') |
---|
885 | { |
---|
886 | $sbox = createobject('phpgwapi.sbox'); |
---|
887 | |
---|
888 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
889 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
890 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
891 | { |
---|
892 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
893 | } |
---|
894 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
895 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
896 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
897 | $p->set_file(Array('edit' => 'group_form.tpl')); |
---|
898 | $p->set_block('edit','select'); |
---|
899 | $p->set_block('edit','popwin'); |
---|
900 | |
---|
901 | $accounts = CreateObject('phpgwapi.accounts',$group_info['account_id'],'g'); |
---|
902 | |
---|
903 | if (!is_object($GLOBALS['phpgw']->uiaccountsel)) |
---|
904 | { |
---|
905 | $GLOBALS['phpgw']->uiaccountsel = CreateObject('phpgwapi.uiaccountsel'); |
---|
906 | } |
---|
907 | $p->set_var('accounts',$GLOBALS['phpgw']->uiaccountsel->selection('account_user[]','admin_uiaccounts_user',$group_info['account_user'],'accounts',min(3+count($group_info['account_user']),10))); |
---|
908 | |
---|
909 | $var = Array( |
---|
910 | 'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.'.($group_info['account_id']?'edit':'add').'_group'), |
---|
911 | 'hidden_vars' => '<input type="hidden" name="account_id" value="' . $group_info['account_id'] . '">', |
---|
912 | 'lang_group_name' => lang('group name'), |
---|
913 | 'group_name_value' => $group_info['account_name'], |
---|
914 | 'lang_include_user' => lang('Select users for inclusion'), |
---|
915 | 'error' => (!$_errors?'':'<center>'.$GLOBALS['phpgw']->common->error_list($_errors).'</center>'), |
---|
916 | 'lang_permissions' => lang('Permissions this group has') |
---|
917 | ); |
---|
918 | $p->set_var($var); |
---|
919 | |
---|
920 | $group_repository = $accounts->read_repository(); |
---|
921 | if (!$group_repository['file_space']) |
---|
922 | { |
---|
923 | $group_repository['file_space'] = $GLOBALS['phpgw_info']['server']['vfs_default_account_size_number'] . "-" . $GLOBALS['phpgw_info']['server']['vfs_default_account_size_type']; |
---|
924 | } |
---|
925 | /* |
---|
926 | $file_space_array = explode ('-', $group_repository['file_space']); |
---|
927 | $account_file_space_types = array ('gb', 'mb', 'kb', 'b'); |
---|
928 | while (list ($num, $type) = each ($account_file_space_types)) |
---|
929 | { |
---|
930 | $account_file_space_select .= '<option value="'.$type.'"'.($type==$file_space_array[1]?' selected':'').'>'.strtoupper ($type).'</option>'."\n"; |
---|
931 | } |
---|
932 | $p->set_var ('lang_file_space', lang('File space')); |
---|
933 | $p->set_var ('account_file_space', '<input type=text name="account_file_space_number" value="'.trim($file_space_array[0]).'" size="7">'); |
---|
934 | $p->set_var ('account_file_space_select','<select name="account_file_space_type">'."\n".$account_file_space_select.'</select>'."\n"); |
---|
935 | */ |
---|
936 | |
---|
937 | reset($GLOBALS['phpgw_info']['apps']); |
---|
938 | $sorted_apps = $GLOBALS['phpgw_info']['apps']; |
---|
939 | @asort($sorted_apps); |
---|
940 | @reset($sorted_apps); |
---|
941 | while ($permission = each($sorted_apps)) |
---|
942 | { |
---|
943 | if ($permission[1]['enabled'] && $permission[1]['status'] != 3) |
---|
944 | { |
---|
945 | $perm_display[] = Array( |
---|
946 | $permission[0], |
---|
947 | $permission[1]['title'] |
---|
948 | ); |
---|
949 | } |
---|
950 | } |
---|
951 | |
---|
952 | $perm_html = '<td width="35%">'.lang('Application').'</td><td width="15%">'.lang('enabled').' / '.lang('ACL').'</td>'; |
---|
953 | $perm_html = '<tr class="th">'. |
---|
954 | $perm_html.$perm_html."</tr>\n"; |
---|
955 | |
---|
956 | $tr_color = $GLOBALS['phpgw_info']['theme']['row_off']; |
---|
957 | for ($i=0;$i < count($perm_display);$i++) |
---|
958 | { |
---|
959 | $app = $perm_display[$i][0]; |
---|
960 | if(!($i & 1)) |
---|
961 | { |
---|
962 | $tr_color = $this->nextmatchs->alternate_row_color(); |
---|
963 | $perm_html .= '<tr bgcolor="'.$tr_color.'">'; |
---|
964 | } |
---|
965 | $perm_html .= '<td>' . $perm_display[$i][1] . '</td>' |
---|
966 | . '<td><input type="checkbox" name="account_apps[' |
---|
967 | . $perm_display[$i][0] . ']" value="True"'.($group_info['account_apps'][$app]?' checked':'').'> ' |
---|
968 | . ($this->apps_with_acl[$app] && $group_info['account_id']?'<a href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$app.'&owner='.$group_info['account_id']) |
---|
969 | . '"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','edit').'" border="0" hspace="3" align="absmiddle" title="' |
---|
970 | . lang('Grant Access').': '.lang("edit group ACL's").'"></a>':' ').'</td>'.($i & 1?'</tr>':'')."\n"; |
---|
971 | } |
---|
972 | if($i & 1) |
---|
973 | { |
---|
974 | $perm_html .= '<td colspan="4"> </td></tr>'; |
---|
975 | } |
---|
976 | |
---|
977 | $var = Array( |
---|
978 | 'permissions_list' => $perm_html, |
---|
979 | 'lang_submit_button' => lang('submit changes') |
---|
980 | ); |
---|
981 | $p->set_var($var); |
---|
982 | |
---|
983 | // create the menu on the left, if needed |
---|
984 | $p->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','group_manager')); |
---|
985 | |
---|
986 | $p->set_var('select',''); |
---|
987 | $p->set_var('popwin',''); |
---|
988 | $p->pfp('out','edit'); |
---|
989 | |
---|
990 | } |
---|
991 | |
---|
992 | function create_edit_user($_account_id,$_userData='',$_errors='') |
---|
993 | { |
---|
994 | $sbox = createobject('phpgwapi.sbox'); |
---|
995 | $jscal = CreateObject('phpgwapi.jscalendar'); |
---|
996 | |
---|
997 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
998 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
999 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
1000 | { |
---|
1001 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
1002 | } |
---|
1003 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
1004 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
1005 | |
---|
1006 | $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
1007 | $t->set_unknowns('remove'); |
---|
1008 | |
---|
1009 | if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'] && ($GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap')) |
---|
1010 | { |
---|
1011 | $t->set_file(array('account' => 'account_form_ldap.tpl')); |
---|
1012 | } |
---|
1013 | else |
---|
1014 | { |
---|
1015 | $t->set_file(array('account' => 'account_form.tpl')); |
---|
1016 | } |
---|
1017 | $t->set_block('account','form','form'); |
---|
1018 | $t->set_block('account','form_passwordinfo','form_passwordinfo'); |
---|
1019 | $t->set_block('account','form_buttons_','form_buttons_'); |
---|
1020 | $t->set_block('account','link_row','link_row'); |
---|
1021 | |
---|
1022 | print_debug('Type : '.gettype($_userData).'<br>_userData(size) = "'.$_userData.'"('.strlen($_userData).')'); |
---|
1023 | if (is_array($_userData)) |
---|
1024 | { |
---|
1025 | $userData = Array(); |
---|
1026 | $userData=$_userData; |
---|
1027 | $userData['firstname'] = $userData['account_firstname']; |
---|
1028 | $userData['lastname'] = $userData['account_lastname']; |
---|
1029 | @reset($userData['account_groups']); |
---|
1030 | while (list($key, $value) = @each($userData['account_groups'])) |
---|
1031 | { |
---|
1032 | $userGroups[$key]['account_id'] = $value; |
---|
1033 | } |
---|
1034 | |
---|
1035 | $account = CreateObject('phpgwapi.accounts'); |
---|
1036 | $allGroups = $account->get_list('groups'); |
---|
1037 | } |
---|
1038 | elseif(is_string($_userData) && $_userData=='') |
---|
1039 | { |
---|
1040 | if($_account_id) |
---|
1041 | { |
---|
1042 | $account = CreateObject('phpgwapi.accounts',(int)$_account_id,'u'); |
---|
1043 | $userData = $account->read_repository(); |
---|
1044 | $userGroups = $account->membership($_account_id); |
---|
1045 | $acl = CreateObject('phpgwapi.acl',$_account_id); |
---|
1046 | $acl->read_repository(); |
---|
1047 | $userData['anonymous'] = $acl->check('anonymous',1,'phpgwapi'); |
---|
1048 | $userData['changepassword'] = $acl->check('changepassword',0xFFFF,'preferences'); |
---|
1049 | unset($acl); |
---|
1050 | } |
---|
1051 | else |
---|
1052 | { |
---|
1053 | $account = CreateObject('phpgwapi.accounts'); |
---|
1054 | $userData = Array(); |
---|
1055 | $userData['status'] = 'A'; |
---|
1056 | $userGroups = Array(); |
---|
1057 | $userData['anonymous'] = False; |
---|
1058 | $userData['changepassword'] = True; |
---|
1059 | } |
---|
1060 | $allGroups = $account->get_list('groups'); |
---|
1061 | } |
---|
1062 | $page_params['menuaction'] = 'admin.boaccounts.'.($_account_id?'edit':'add').'_user'; |
---|
1063 | if($_account_id) |
---|
1064 | { |
---|
1065 | $page_params['account_id'] = $_account_id; |
---|
1066 | $page_params['old_loginid'] = rawurlencode($userData['account_lid']); |
---|
1067 | } |
---|
1068 | |
---|
1069 | $var = Array( |
---|
1070 | 'form_action' => $GLOBALS['phpgw']->link('/index.php',$page_params), |
---|
1071 | 'error_messages' => (!$_errors?'':'<center>'.$GLOBALS['phpgw']->common->error_list($_errors).'</center>'), |
---|
1072 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
1073 | 'tr_color1' => $GLOBALS['phpgw_info']['theme']['row_on'], |
---|
1074 | 'tr_color2' => $GLOBALS['phpgw_info']['theme']['row_off'], |
---|
1075 | 'lang_action' => ($_account_id?lang('Edit user account'):lang('Add new account')), |
---|
1076 | 'lang_loginid' => lang('LoginID'), |
---|
1077 | 'lang_account_active' => lang('Account active'), |
---|
1078 | 'lang_email' => lang('email'), |
---|
1079 | 'lang_password' => lang('Password'), |
---|
1080 | 'lang_reenter_password' => lang('Re-Enter Password'), |
---|
1081 | 'lang_lastname' => lang('Last Name'), |
---|
1082 | 'lang_groups' => lang('Groups'), |
---|
1083 | 'lang_primary_group' => lang('primary Group'), |
---|
1084 | 'lang_expires' => lang('Expires'), |
---|
1085 | 'lang_firstname' => lang('First Name'), |
---|
1086 | 'lang_anonymous' => lang('Anonymous User (not shown in list sessions)'), |
---|
1087 | 'lang_changepassword' => lang('Can change password'), |
---|
1088 | 'lang_button' => ($_account_id?lang('Save'):lang('Add')) |
---|
1089 | /* 'lang_file_space' => lang('File Space') */ |
---|
1090 | ); |
---|
1091 | $t->set_var($var); |
---|
1092 | $t->parse('form_buttons','form_buttons_',True); |
---|
1093 | |
---|
1094 | if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes']) { |
---|
1095 | $lang_homedir = lang('home directory'); |
---|
1096 | $lang_shell = lang('login shell'); |
---|
1097 | $homedirectory = '<input name="homedirectory" value="' |
---|
1098 | . ($_account_id?$userData['homedirectory']:$GLOBALS['phpgw_info']['server']['ldap_account_home'].$account_lid) |
---|
1099 | . '">'; |
---|
1100 | $loginshell = '<input name="loginshell" value="' |
---|
1101 | . ($_account_id?$userData['loginshell']:$GLOBALS['phpgw_info']['server']['ldap_account_shell']) |
---|
1102 | . '">'; |
---|
1103 | } |
---|
1104 | else |
---|
1105 | { |
---|
1106 | $lang_homedir = ''; |
---|
1107 | $lang_shell = ''; |
---|
1108 | $homedirectory = ''; |
---|
1109 | $loginshell = ''; |
---|
1110 | } |
---|
1111 | $account_file_space = ''; |
---|
1112 | /* |
---|
1113 | if (!$userData['file_space']) |
---|
1114 | { |
---|
1115 | $userData['file_space'] = $GLOBALS['phpgw_info']['server']['vfs_default_account_size_number'] . "-" . $GLOBALS['phpgw_info']['server']['vfs_default_account_size_type']; |
---|
1116 | } |
---|
1117 | $file_space_array = explode ('-', $userData['file_space']); |
---|
1118 | $account_file_space_number = $file_space_array[0]; |
---|
1119 | $account_file_space_type = $file_space_array[1]; |
---|
1120 | $account_file_space_type_selected[$account_file_space_type] = ' selected'; |
---|
1121 | |
---|
1122 | $account_file_space = '<input type=text name="account_file_space_number" value="' . trim($account_file_space_number) . '" size="7">'; |
---|
1123 | $account_file_space_select ='<select name="account_file_space_type">'; |
---|
1124 | $account_file_space_types = array ('gb', 'mb', 'kb', 'b'); |
---|
1125 | while (list ($num, $type) = each ($account_file_space_types)) |
---|
1126 | { |
---|
1127 | $account_file_space_select .= '<option value="'.$type.'"' . $account_file_space_type_selected[$type] . '>' . strtoupper ($type) . '</option>'; |
---|
1128 | } |
---|
1129 | $account_file_space_select .= '</select>'; |
---|
1130 | |
---|
1131 | $var = Array( |
---|
1132 | 'lang_file_space' => 'File space', |
---|
1133 | 'account_file_space' => $account_file_space, |
---|
1134 | 'account_file_space_select' => $account_file_space_select |
---|
1135 | ); |
---|
1136 | $t->set_var($var); |
---|
1137 | */ |
---|
1138 | $accountPrefix = ''; |
---|
1139 | if(isset($GLOBALS['phpgw_info']['server']['account_prefix'])) |
---|
1140 | { |
---|
1141 | $accountPrefix = $GLOBALS['phpgw_info']['server']['account_prefix']; |
---|
1142 | if (preg_match ("/^$accountPrefix(.*)/i", $userData['account_lid'], $matches)) |
---|
1143 | { |
---|
1144 | $userData['account_lid'] = $matches[1]; |
---|
1145 | } |
---|
1146 | } |
---|
1147 | $var = Array( |
---|
1148 | 'input_expires' => $jscal->input('expires',$userData['expires']<0?'':($userData['expires']?$userData['expires']:time()+(60*60*24*7))), |
---|
1149 | 'lang_never' => lang('Never'), |
---|
1150 | 'account_lid' => $accountPrefix.'<input name="account_lid" value="' . $userData['account_lid'] . '">', |
---|
1151 | 'lang_homedir' => $lang_homedir, |
---|
1152 | 'lang_shell' => $lang_shell, |
---|
1153 | 'homedirectory' => $homedirectory, |
---|
1154 | 'loginshell' => $loginshell, |
---|
1155 | 'anonymous' => '<input type="checkbox" name="anonymous" value="1"'.($userData['anonymous'] ? ' checked' : '').'>', |
---|
1156 | 'changepassword'=> '<input type="checkbox" name="changepassword" value="1"'.($userData['changepassword'] ? ' checked' : '').'>', |
---|
1157 | 'account_status' => '<input type="checkbox" name="account_status" value="A"'.($userData['status']?' checked':'').'>', |
---|
1158 | 'account_firstname' => '<input name="account_firstname" value="' . $userData['firstname'] . '">', |
---|
1159 | 'account_lastname' => '<input name="account_lastname" value="' . $userData['lastname'] . '">', |
---|
1160 | 'account_email' => '<input name="account_email" size="32" value="' . $userData['email'] . '">', |
---|
1161 | 'account_passwd' => $userData['account_passwd'], |
---|
1162 | 'account_passwd_2' => $userData['account_passwd_2'], |
---|
1163 | 'account_file_space' => $account_file_space |
---|
1164 | ); |
---|
1165 | |
---|
1166 | if($userData['expires'] == -1) |
---|
1167 | { |
---|
1168 | $var['never_expires'] = '<input type="checkbox" name="never_expires" value="True" checked>'; |
---|
1169 | } |
---|
1170 | else |
---|
1171 | { |
---|
1172 | $var['never_expires'] = '<input type="checkbox" name="never_expires" value="True">'; |
---|
1173 | } |
---|
1174 | |
---|
1175 | $t->set_var($var); |
---|
1176 | $t->parse('password_fields','form_passwordinfo',True); |
---|
1177 | |
---|
1178 | $groups_select = ''; |
---|
1179 | $primary_group_select = ''; |
---|
1180 | reset($allGroups); |
---|
1181 | while (list($key,$value) = each($allGroups)) |
---|
1182 | { |
---|
1183 | $groups_select .= '<option value="' . $value['account_id'] . '"'; |
---|
1184 | for ($i=0; $i<count($userGroups); $i++) |
---|
1185 | { |
---|
1186 | /* print "Los1:".$userData["account_id"].$userGroups[$i]['account_id']." : ".$value['account_id']."<br>"; */ |
---|
1187 | if (@$userGroups[$i]['account_id'] == $value['account_id']) |
---|
1188 | { |
---|
1189 | $groups_select .= ' selected'; |
---|
1190 | } |
---|
1191 | } |
---|
1192 | $groups_select .= '>' . $value['account_lid'] . '</option>'."\n"; |
---|
1193 | } |
---|
1194 | |
---|
1195 | if (!$userData['account_primary_group']) |
---|
1196 | { |
---|
1197 | $userData['account_primary_group'] = @$userGroups[0]['account_id'] ? @$userGroups[0]['account_id'] : $account->name2id('Default'); |
---|
1198 | } |
---|
1199 | foreach($allGroups as $key => $value) |
---|
1200 | { |
---|
1201 | # print "<br>$key =>"; |
---|
1202 | # _debug_array($userGroups); |
---|
1203 | $primary_group_select .= '<option value="' . $value['account_id'] . '"'; |
---|
1204 | #print $value['account_id'].''.$value['account_primary_group'] |
---|
1205 | if ($value['account_id'] == $userData['account_primary_group']) |
---|
1206 | { |
---|
1207 | $primary_group_select .= ' selected="1"'; |
---|
1208 | } |
---|
1209 | $primary_group_select .= '>' . $value['account_lid'] . '</option>'."\n"; |
---|
1210 | } |
---|
1211 | |
---|
1212 | /* create list of available apps */ |
---|
1213 | $apps = CreateObject('phpgwapi.applications',$_account_id); |
---|
1214 | $db_perms = $apps->read_account_specific(); |
---|
1215 | |
---|
1216 | $availableApps = $GLOBALS['phpgw_info']['apps']; |
---|
1217 | uasort($availableApps,create_function('$a,$b','return strcasecmp($a["title"],$b["title"]);')); |
---|
1218 | |
---|
1219 | $appRightsOutput = ''; |
---|
1220 | $i = 0; |
---|
1221 | foreach($availableApps as $app => $data) |
---|
1222 | { |
---|
1223 | if (!$data['enabled'] || $data['status'] == 3) |
---|
1224 | { |
---|
1225 | continue; |
---|
1226 | } |
---|
1227 | $checked = (@$userData['account_permissions'][$app] || @$db_perms[$app]) && $_account_id ? ' checked="1"' : ''; |
---|
1228 | $part[$i&1] = sprintf('<td>%s</td><td><input type="checkbox" name="account_permissions[%s]" value="True"%s>', |
---|
1229 | $data['title'],$app,$checked). |
---|
1230 | ($this->apps_with_acl[$app] && $_account_id?'<a href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$app.'&owner='.$_account_id) |
---|
1231 | . '"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','edit').'" border="0" hspace="3" align="absmiddle" title="' |
---|
1232 | . lang('Grant Access').'"></a>':' ').'</td>'; |
---|
1233 | |
---|
1234 | if ($i & 1) |
---|
1235 | { |
---|
1236 | $appRightsOutput .= sprintf('<tr bgcolor="%s">%s%s</tr>',$this->nextmatchs->alternate_row_color(), $part[0], $part[1]); |
---|
1237 | } |
---|
1238 | ++$i; |
---|
1239 | } |
---|
1240 | if ($i & 1) |
---|
1241 | { |
---|
1242 | $part[1] = '<td colspan="3"> </td>'; |
---|
1243 | $appRightsOutput .= sprintf('<tr bgcolor="%s">%s%s</tr>',$this->nextmatchs->alternate_row_color(), $part[0], $part[1]); |
---|
1244 | } |
---|
1245 | |
---|
1246 | $var = Array( |
---|
1247 | 'groups_select' |
---|
1248 | => '<select name="account_groups[]" multiple>'."\n".$groups_select.'</select>'."\n", |
---|
1249 | 'primary_group_select' |
---|
1250 | => '<select name="account_primary_group">'."\n".$primary_group_select.'</select>'."\n", |
---|
1251 | 'permissions_list' |
---|
1252 | => $appRightsOutput, |
---|
1253 | 'lang_app' => lang('application'), |
---|
1254 | 'lang_acl' => lang('enabled').' / '.lang('ACL'), |
---|
1255 | ); |
---|
1256 | $t->set_var($var); |
---|
1257 | |
---|
1258 | // create the menu on the left, if needed |
---|
1259 | // $menuClass = CreateObject('admin.uimenuclass'); |
---|
1260 | // This is now using ExecMethod() |
---|
1261 | $GLOBALS['account_id'] = $_account_id; |
---|
1262 | $t->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','edit_user')); |
---|
1263 | |
---|
1264 | echo $t->fp('out','form'); |
---|
1265 | } |
---|
1266 | |
---|
1267 | function edit_group_managers($group_info,$_errors='') |
---|
1268 | { |
---|
1269 | if ($GLOBALS['phpgw']->acl->check('group_access',16,'admin')) |
---|
1270 | { |
---|
1271 | $this->list_groups(); |
---|
1272 | return False; |
---|
1273 | } |
---|
1274 | |
---|
1275 | $accounts = CreateObject('phpgwapi.accounts',$group_info['account_id'],'u'); |
---|
1276 | $account_list = $accounts->member($group_info['account_id']); |
---|
1277 | $user_list = ''; |
---|
1278 | while (list($key,$entry) = each($account_list)) |
---|
1279 | { |
---|
1280 | $user_list .= '<option value="' . $entry['account_id'] . '"' |
---|
1281 | . $group_info['account_managers'][(int)$entry['account_id']] . '>' |
---|
1282 | . $GLOBALS['phpgw']->common->grab_owner_name($entry['account_id']) |
---|
1283 | . '</option>'."\n"; |
---|
1284 | } |
---|
1285 | |
---|
1286 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
1287 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
1288 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
1289 | { |
---|
1290 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
1291 | } |
---|
1292 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
1293 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
1294 | |
---|
1295 | $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
1296 | $t->set_unknowns('remove'); |
---|
1297 | |
---|
1298 | $t->set_file( |
---|
1299 | Array( |
---|
1300 | 'manager' =>'group_manager.tpl' |
---|
1301 | ) |
---|
1302 | ); |
---|
1303 | |
---|
1304 | $t->set_block('manager','form','form'); |
---|
1305 | $t->set_block('manager','link_row','link_row'); |
---|
1306 | |
---|
1307 | $var['th_bg'] = $GLOBALS['phpgw_info']['user']['theme']['th_bg']; |
---|
1308 | $var['lang_group'] = lang('Group'); |
---|
1309 | $var['group_name'] = $group_info['account_name']; |
---|
1310 | $var['tr_color1'] = $GLOBALS['phpgw_info']['user']['theme']['row_on']; |
---|
1311 | $var['form_action'] = $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.set_group_managers'); |
---|
1312 | $var['hidden'] = '<input type="hidden" name="account_id" value="'.$group_info['account_id'].'">'; |
---|
1313 | $var['lang_select_managers'] = lang('Select Group Managers'); |
---|
1314 | $var['group_members'] = '<select name="managers[]" size="'.(count($account_list)<5?count($account_list):5).'" multiple>'.$user_list.'</select>'; |
---|
1315 | $var['form_buttons'] = '<tr align="center"><td colspan="2"><input type="submit" name="submit" value="'.lang('Submit').'"> ' |
---|
1316 | . '<input type="submit" name="cancel" value="'.lang('Cancel').'"><td></tr>'; |
---|
1317 | $t->set_var($var); |
---|
1318 | |
---|
1319 | // create the menu on the left, if needed |
---|
1320 | $t->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','edit_group')); |
---|
1321 | |
---|
1322 | $t->pfp('out','form'); |
---|
1323 | } |
---|
1324 | } |
---|
1325 | ?> |
---|