[2] | 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 |
---|
[5928] | 76 | if(preg_match('/^[a-z_0-9]+$/i',$_POST['query'])) |
---|
[2] | 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 |
---|
[5928] | 244 | if(preg_match('/^[a-z_0-9]+$/i',$_REQUEST['query'])) |
---|
[2] | 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 = ''; |
---|
[7655] | 583 | for($i=0;$i<$c_users;++$i) |
---|
[2] | 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']; |
---|
[7655] | 808 | ++$i; |
---|
[2] | 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 | |
---|
[7673] | 818 | $perm_display_count = count($perm_display); |
---|
| 819 | for ($i=0;$i<$perm_display_count;++$i) |
---|
[2] | 820 | { |
---|
| 821 | if ($perm_display[$i]['title']) |
---|
| 822 | { |
---|
| 823 | $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':' ')); |
---|
| 824 | } |
---|
| 825 | |
---|
[7655] | 826 | ++$i; |
---|
[2] | 827 | |
---|
| 828 | if ($perm_display[$i]['title']) |
---|
| 829 | { |
---|
| 830 | $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':' ')); |
---|
| 831 | } |
---|
| 832 | else |
---|
| 833 | { |
---|
| 834 | $part2 = '<td colspan="2"> </td>'; |
---|
| 835 | } |
---|
| 836 | |
---|
| 837 | $appRightsOutput .= sprintf("<tr bgcolor=\"%s\">$part1$part2</tr>\n",$GLOBALS['phpgw_info']['theme']['row_on']); |
---|
| 838 | } |
---|
| 839 | |
---|
| 840 | $var['permissions_list'] = $appRightsOutput; |
---|
| 841 | |
---|
| 842 | // create the menu on the left, if needed |
---|
| 843 | // $menuClass = CreateObject('admin.uimenuclass'); |
---|
| 844 | // This is now using ExecMethod() |
---|
| 845 | $var['rows'] = ExecMethod('admin.uimenuclass.createHTMLCode','view_user'); |
---|
| 846 | $t->set_var($var); |
---|
| 847 | $t->pfp('out','form'); |
---|
| 848 | } |
---|
| 849 | |
---|
| 850 | function group_manager($cd='',$account_id='') |
---|
| 851 | { |
---|
| 852 | if ($GLOBALS['phpgw']->acl->check('group_access',16,'admin')) |
---|
| 853 | { |
---|
| 854 | $this->list_groups(); |
---|
| 855 | return False; |
---|
| 856 | } |
---|
| 857 | |
---|
| 858 | $cdid = $cd; |
---|
| 859 | settype($cd,'integer'); |
---|
| 860 | $cd = ($_GET['cd']?$_GET['cd']:(int)$cdid); |
---|
| 861 | |
---|
| 862 | $accountid = $account_id; |
---|
| 863 | settype($account_id,'integer'); |
---|
| 864 | $account_id = (int)($_GET['account_id'] ? $_GET['account_id'] : $accountid); |
---|
| 865 | |
---|
| 866 | // todo |
---|
| 867 | // not needed if i use the same file for new groups too |
---|
| 868 | if (! $account_id) |
---|
| 869 | { |
---|
| 870 | $this->list_groups(); |
---|
| 871 | } |
---|
| 872 | else |
---|
| 873 | { |
---|
| 874 | $group_info = Array( |
---|
| 875 | 'account_id' => (int)$_GET['account_id'], |
---|
| 876 | 'account_name' => $GLOBALS['phpgw']->accounts->id2name($_GET['account_id']), |
---|
| 877 | 'account_user' => $GLOBALS['phpgw']->accounts->member($_GET['account_id']), |
---|
| 878 | 'account_managers' => $this->bo->load_group_managers($_GET['account_id']) |
---|
| 879 | ); |
---|
| 880 | |
---|
| 881 | $this->edit_group_managers($group_info); |
---|
| 882 | } |
---|
| 883 | } |
---|
| 884 | |
---|
| 885 | function create_edit_group($group_info,$_errors='') |
---|
| 886 | { |
---|
| 887 | $sbox = createobject('phpgwapi.sbox'); |
---|
| 888 | |
---|
| 889 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 890 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 891 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
| 892 | { |
---|
| 893 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
| 894 | } |
---|
| 895 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
| 896 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 897 | $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 898 | $p->set_file(Array('edit' => 'group_form.tpl')); |
---|
| 899 | $p->set_block('edit','select'); |
---|
| 900 | $p->set_block('edit','popwin'); |
---|
| 901 | |
---|
| 902 | $accounts = CreateObject('phpgwapi.accounts',$group_info['account_id'],'g'); |
---|
| 903 | |
---|
| 904 | if (!is_object($GLOBALS['phpgw']->uiaccountsel)) |
---|
| 905 | { |
---|
| 906 | $GLOBALS['phpgw']->uiaccountsel = CreateObject('phpgwapi.uiaccountsel'); |
---|
| 907 | } |
---|
| 908 | $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))); |
---|
| 909 | |
---|
| 910 | $var = Array( |
---|
| 911 | 'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.'.($group_info['account_id']?'edit':'add').'_group'), |
---|
| 912 | 'hidden_vars' => '<input type="hidden" name="account_id" value="' . $group_info['account_id'] . '">', |
---|
| 913 | 'lang_group_name' => lang('group name'), |
---|
| 914 | 'group_name_value' => $group_info['account_name'], |
---|
| 915 | 'lang_include_user' => lang('Select users for inclusion'), |
---|
| 916 | 'error' => (!$_errors?'':'<center>'.$GLOBALS['phpgw']->common->error_list($_errors).'</center>'), |
---|
| 917 | 'lang_permissions' => lang('Permissions this group has') |
---|
| 918 | ); |
---|
| 919 | $p->set_var($var); |
---|
| 920 | |
---|
| 921 | $group_repository = $accounts->read_repository(); |
---|
| 922 | if (!$group_repository['file_space']) |
---|
| 923 | { |
---|
| 924 | $group_repository['file_space'] = $GLOBALS['phpgw_info']['server']['vfs_default_account_size_number'] . "-" . $GLOBALS['phpgw_info']['server']['vfs_default_account_size_type']; |
---|
| 925 | } |
---|
| 926 | /* |
---|
| 927 | $file_space_array = explode ('-', $group_repository['file_space']); |
---|
| 928 | $account_file_space_types = array ('gb', 'mb', 'kb', 'b'); |
---|
| 929 | while (list ($num, $type) = each ($account_file_space_types)) |
---|
| 930 | { |
---|
| 931 | $account_file_space_select .= '<option value="'.$type.'"'.($type==$file_space_array[1]?' selected':'').'>'.strtoupper ($type).'</option>'."\n"; |
---|
| 932 | } |
---|
| 933 | $p->set_var ('lang_file_space', lang('File space')); |
---|
| 934 | $p->set_var ('account_file_space', '<input type=text name="account_file_space_number" value="'.trim($file_space_array[0]).'" size="7">'); |
---|
| 935 | $p->set_var ('account_file_space_select','<select name="account_file_space_type">'."\n".$account_file_space_select.'</select>'."\n"); |
---|
| 936 | */ |
---|
| 937 | |
---|
| 938 | reset($GLOBALS['phpgw_info']['apps']); |
---|
| 939 | $sorted_apps = $GLOBALS['phpgw_info']['apps']; |
---|
| 940 | @asort($sorted_apps); |
---|
| 941 | @reset($sorted_apps); |
---|
| 942 | while ($permission = each($sorted_apps)) |
---|
| 943 | { |
---|
| 944 | if ($permission[1]['enabled'] && $permission[1]['status'] != 3) |
---|
| 945 | { |
---|
| 946 | $perm_display[] = Array( |
---|
| 947 | $permission[0], |
---|
| 948 | $permission[1]['title'] |
---|
| 949 | ); |
---|
| 950 | } |
---|
| 951 | } |
---|
| 952 | |
---|
| 953 | $perm_html = '<td width="35%">'.lang('Application').'</td><td width="15%">'.lang('enabled').' / '.lang('ACL').'</td>'; |
---|
| 954 | $perm_html = '<tr class="th">'. |
---|
| 955 | $perm_html.$perm_html."</tr>\n"; |
---|
| 956 | |
---|
| 957 | $tr_color = $GLOBALS['phpgw_info']['theme']['row_off']; |
---|
[7673] | 958 | $perm_display_count = count($perm_display); |
---|
| 959 | for ($i=0;$i < $perm_display_count;++$i) |
---|
[2] | 960 | { |
---|
| 961 | $app = $perm_display[$i][0]; |
---|
| 962 | if(!($i & 1)) |
---|
| 963 | { |
---|
| 964 | $tr_color = $this->nextmatchs->alternate_row_color(); |
---|
| 965 | $perm_html .= '<tr bgcolor="'.$tr_color.'">'; |
---|
| 966 | } |
---|
| 967 | $perm_html .= '<td>' . $perm_display[$i][1] . '</td>' |
---|
| 968 | . '<td><input type="checkbox" name="account_apps[' |
---|
| 969 | . $perm_display[$i][0] . ']" value="True"'.($group_info['account_apps'][$app]?' checked':'').'> ' |
---|
| 970 | . ($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']) |
---|
| 971 | . '"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','edit').'" border="0" hspace="3" align="absmiddle" title="' |
---|
| 972 | . lang('Grant Access').': '.lang("edit group ACL's").'"></a>':' ').'</td>'.($i & 1?'</tr>':'')."\n"; |
---|
| 973 | } |
---|
| 974 | if($i & 1) |
---|
| 975 | { |
---|
| 976 | $perm_html .= '<td colspan="4"> </td></tr>'; |
---|
| 977 | } |
---|
| 978 | |
---|
| 979 | $var = Array( |
---|
| 980 | 'permissions_list' => $perm_html, |
---|
| 981 | 'lang_submit_button' => lang('submit changes') |
---|
| 982 | ); |
---|
| 983 | $p->set_var($var); |
---|
| 984 | |
---|
| 985 | // create the menu on the left, if needed |
---|
| 986 | $p->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','group_manager')); |
---|
| 987 | |
---|
| 988 | $p->set_var('select',''); |
---|
| 989 | $p->set_var('popwin',''); |
---|
| 990 | $p->pfp('out','edit'); |
---|
| 991 | |
---|
| 992 | } |
---|
| 993 | |
---|
| 994 | function create_edit_user($_account_id,$_userData='',$_errors='') |
---|
| 995 | { |
---|
| 996 | $sbox = createobject('phpgwapi.sbox'); |
---|
| 997 | $jscal = CreateObject('phpgwapi.jscalendar'); |
---|
| 998 | |
---|
| 999 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 1000 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 1001 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
| 1002 | { |
---|
| 1003 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
| 1004 | } |
---|
| 1005 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
| 1006 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 1007 | |
---|
| 1008 | $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 1009 | $t->set_unknowns('remove'); |
---|
| 1010 | |
---|
| 1011 | if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'] && ($GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap')) |
---|
| 1012 | { |
---|
| 1013 | $t->set_file(array('account' => 'account_form_ldap.tpl')); |
---|
| 1014 | } |
---|
| 1015 | else |
---|
| 1016 | { |
---|
| 1017 | $t->set_file(array('account' => 'account_form.tpl')); |
---|
| 1018 | } |
---|
| 1019 | $t->set_block('account','form','form'); |
---|
| 1020 | $t->set_block('account','form_passwordinfo','form_passwordinfo'); |
---|
| 1021 | $t->set_block('account','form_buttons_','form_buttons_'); |
---|
| 1022 | $t->set_block('account','link_row','link_row'); |
---|
| 1023 | |
---|
| 1024 | print_debug('Type : '.gettype($_userData).'<br>_userData(size) = "'.$_userData.'"('.strlen($_userData).')'); |
---|
| 1025 | if (is_array($_userData)) |
---|
| 1026 | { |
---|
| 1027 | $userData = Array(); |
---|
| 1028 | $userData=$_userData; |
---|
| 1029 | $userData['firstname'] = $userData['account_firstname']; |
---|
| 1030 | $userData['lastname'] = $userData['account_lastname']; |
---|
| 1031 | @reset($userData['account_groups']); |
---|
| 1032 | while (list($key, $value) = @each($userData['account_groups'])) |
---|
| 1033 | { |
---|
| 1034 | $userGroups[$key]['account_id'] = $value; |
---|
| 1035 | } |
---|
| 1036 | |
---|
| 1037 | $account = CreateObject('phpgwapi.accounts'); |
---|
| 1038 | $allGroups = $account->get_list('groups'); |
---|
| 1039 | } |
---|
| 1040 | elseif(is_string($_userData) && $_userData=='') |
---|
| 1041 | { |
---|
| 1042 | if($_account_id) |
---|
| 1043 | { |
---|
| 1044 | $account = CreateObject('phpgwapi.accounts',(int)$_account_id,'u'); |
---|
| 1045 | $userData = $account->read_repository(); |
---|
| 1046 | $userGroups = $account->membership($_account_id); |
---|
| 1047 | $acl = CreateObject('phpgwapi.acl',$_account_id); |
---|
| 1048 | $acl->read_repository(); |
---|
| 1049 | $userData['anonymous'] = $acl->check('anonymous',1,'phpgwapi'); |
---|
| 1050 | $userData['changepassword'] = $acl->check('changepassword',0xFFFF,'preferences'); |
---|
| 1051 | unset($acl); |
---|
| 1052 | } |
---|
| 1053 | else |
---|
| 1054 | { |
---|
| 1055 | $account = CreateObject('phpgwapi.accounts'); |
---|
| 1056 | $userData = Array(); |
---|
| 1057 | $userData['status'] = 'A'; |
---|
| 1058 | $userGroups = Array(); |
---|
| 1059 | $userData['anonymous'] = False; |
---|
| 1060 | $userData['changepassword'] = True; |
---|
| 1061 | } |
---|
| 1062 | $allGroups = $account->get_list('groups'); |
---|
| 1063 | } |
---|
| 1064 | $page_params['menuaction'] = 'admin.boaccounts.'.($_account_id?'edit':'add').'_user'; |
---|
| 1065 | if($_account_id) |
---|
| 1066 | { |
---|
| 1067 | $page_params['account_id'] = $_account_id; |
---|
| 1068 | $page_params['old_loginid'] = rawurlencode($userData['account_lid']); |
---|
| 1069 | } |
---|
| 1070 | |
---|
| 1071 | $var = Array( |
---|
| 1072 | 'form_action' => $GLOBALS['phpgw']->link('/index.php',$page_params), |
---|
| 1073 | 'error_messages' => (!$_errors?'':'<center>'.$GLOBALS['phpgw']->common->error_list($_errors).'</center>'), |
---|
| 1074 | 'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'], |
---|
| 1075 | 'tr_color1' => $GLOBALS['phpgw_info']['theme']['row_on'], |
---|
| 1076 | 'tr_color2' => $GLOBALS['phpgw_info']['theme']['row_off'], |
---|
| 1077 | 'lang_action' => ($_account_id?lang('Edit user account'):lang('Add new account')), |
---|
| 1078 | 'lang_loginid' => lang('LoginID'), |
---|
| 1079 | 'lang_account_active' => lang('Account active'), |
---|
| 1080 | 'lang_email' => lang('email'), |
---|
| 1081 | 'lang_password' => lang('Password'), |
---|
| 1082 | 'lang_reenter_password' => lang('Re-Enter Password'), |
---|
| 1083 | 'lang_lastname' => lang('Last Name'), |
---|
| 1084 | 'lang_groups' => lang('Groups'), |
---|
| 1085 | 'lang_primary_group' => lang('primary Group'), |
---|
| 1086 | 'lang_expires' => lang('Expires'), |
---|
| 1087 | 'lang_firstname' => lang('First Name'), |
---|
| 1088 | 'lang_anonymous' => lang('Anonymous User (not shown in list sessions)'), |
---|
| 1089 | 'lang_changepassword' => lang('Can change password'), |
---|
| 1090 | 'lang_button' => ($_account_id?lang('Save'):lang('Add')) |
---|
| 1091 | /* 'lang_file_space' => lang('File Space') */ |
---|
| 1092 | ); |
---|
| 1093 | $t->set_var($var); |
---|
| 1094 | $t->parse('form_buttons','form_buttons_',True); |
---|
| 1095 | |
---|
| 1096 | if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes']) { |
---|
| 1097 | $lang_homedir = lang('home directory'); |
---|
| 1098 | $lang_shell = lang('login shell'); |
---|
| 1099 | $homedirectory = '<input name="homedirectory" value="' |
---|
| 1100 | . ($_account_id?$userData['homedirectory']:$GLOBALS['phpgw_info']['server']['ldap_account_home'].$account_lid) |
---|
| 1101 | . '">'; |
---|
| 1102 | $loginshell = '<input name="loginshell" value="' |
---|
| 1103 | . ($_account_id?$userData['loginshell']:$GLOBALS['phpgw_info']['server']['ldap_account_shell']) |
---|
| 1104 | . '">'; |
---|
| 1105 | } |
---|
| 1106 | else |
---|
| 1107 | { |
---|
| 1108 | $lang_homedir = ''; |
---|
| 1109 | $lang_shell = ''; |
---|
| 1110 | $homedirectory = ''; |
---|
| 1111 | $loginshell = ''; |
---|
| 1112 | } |
---|
| 1113 | $account_file_space = ''; |
---|
| 1114 | /* |
---|
| 1115 | if (!$userData['file_space']) |
---|
| 1116 | { |
---|
| 1117 | $userData['file_space'] = $GLOBALS['phpgw_info']['server']['vfs_default_account_size_number'] . "-" . $GLOBALS['phpgw_info']['server']['vfs_default_account_size_type']; |
---|
| 1118 | } |
---|
| 1119 | $file_space_array = explode ('-', $userData['file_space']); |
---|
| 1120 | $account_file_space_number = $file_space_array[0]; |
---|
| 1121 | $account_file_space_type = $file_space_array[1]; |
---|
| 1122 | $account_file_space_type_selected[$account_file_space_type] = ' selected'; |
---|
| 1123 | |
---|
| 1124 | $account_file_space = '<input type=text name="account_file_space_number" value="' . trim($account_file_space_number) . '" size="7">'; |
---|
| 1125 | $account_file_space_select ='<select name="account_file_space_type">'; |
---|
| 1126 | $account_file_space_types = array ('gb', 'mb', 'kb', 'b'); |
---|
| 1127 | while (list ($num, $type) = each ($account_file_space_types)) |
---|
| 1128 | { |
---|
| 1129 | $account_file_space_select .= '<option value="'.$type.'"' . $account_file_space_type_selected[$type] . '>' . strtoupper ($type) . '</option>'; |
---|
| 1130 | } |
---|
| 1131 | $account_file_space_select .= '</select>'; |
---|
| 1132 | |
---|
| 1133 | $var = Array( |
---|
| 1134 | 'lang_file_space' => 'File space', |
---|
| 1135 | 'account_file_space' => $account_file_space, |
---|
| 1136 | 'account_file_space_select' => $account_file_space_select |
---|
| 1137 | ); |
---|
| 1138 | $t->set_var($var); |
---|
| 1139 | */ |
---|
| 1140 | $accountPrefix = ''; |
---|
| 1141 | if(isset($GLOBALS['phpgw_info']['server']['account_prefix'])) |
---|
| 1142 | { |
---|
| 1143 | $accountPrefix = $GLOBALS['phpgw_info']['server']['account_prefix']; |
---|
| 1144 | if (preg_match ("/^$accountPrefix(.*)/i", $userData['account_lid'], $matches)) |
---|
| 1145 | { |
---|
| 1146 | $userData['account_lid'] = $matches[1]; |
---|
| 1147 | } |
---|
| 1148 | } |
---|
| 1149 | $var = Array( |
---|
| 1150 | 'input_expires' => $jscal->input('expires',$userData['expires']<0?'':($userData['expires']?$userData['expires']:time()+(60*60*24*7))), |
---|
| 1151 | 'lang_never' => lang('Never'), |
---|
| 1152 | 'account_lid' => $accountPrefix.'<input name="account_lid" value="' . $userData['account_lid'] . '">', |
---|
| 1153 | 'lang_homedir' => $lang_homedir, |
---|
| 1154 | 'lang_shell' => $lang_shell, |
---|
| 1155 | 'homedirectory' => $homedirectory, |
---|
| 1156 | 'loginshell' => $loginshell, |
---|
| 1157 | 'anonymous' => '<input type="checkbox" name="anonymous" value="1"'.($userData['anonymous'] ? ' checked' : '').'>', |
---|
| 1158 | 'changepassword'=> '<input type="checkbox" name="changepassword" value="1"'.($userData['changepassword'] ? ' checked' : '').'>', |
---|
| 1159 | 'account_status' => '<input type="checkbox" name="account_status" value="A"'.($userData['status']?' checked':'').'>', |
---|
| 1160 | 'account_firstname' => '<input name="account_firstname" value="' . $userData['firstname'] . '">', |
---|
| 1161 | 'account_lastname' => '<input name="account_lastname" value="' . $userData['lastname'] . '">', |
---|
| 1162 | 'account_email' => '<input name="account_email" size="32" value="' . $userData['email'] . '">', |
---|
| 1163 | 'account_passwd' => $userData['account_passwd'], |
---|
| 1164 | 'account_passwd_2' => $userData['account_passwd_2'], |
---|
| 1165 | 'account_file_space' => $account_file_space |
---|
| 1166 | ); |
---|
| 1167 | |
---|
| 1168 | if($userData['expires'] == -1) |
---|
| 1169 | { |
---|
| 1170 | $var['never_expires'] = '<input type="checkbox" name="never_expires" value="True" checked>'; |
---|
| 1171 | } |
---|
| 1172 | else |
---|
| 1173 | { |
---|
| 1174 | $var['never_expires'] = '<input type="checkbox" name="never_expires" value="True">'; |
---|
| 1175 | } |
---|
| 1176 | |
---|
| 1177 | $t->set_var($var); |
---|
| 1178 | $t->parse('password_fields','form_passwordinfo',True); |
---|
| 1179 | |
---|
| 1180 | $groups_select = ''; |
---|
| 1181 | $primary_group_select = ''; |
---|
| 1182 | reset($allGroups); |
---|
| 1183 | while (list($key,$value) = each($allGroups)) |
---|
| 1184 | { |
---|
| 1185 | $groups_select .= '<option value="' . $value['account_id'] . '"'; |
---|
[7673] | 1186 | $userGroups_count = count($userGroups); |
---|
| 1187 | for ($i=0; $i<$userGroups_count; ++$i) |
---|
[2] | 1188 | { |
---|
| 1189 | /* print "Los1:".$userData["account_id"].$userGroups[$i]['account_id']." : ".$value['account_id']."<br>"; */ |
---|
| 1190 | if (@$userGroups[$i]['account_id'] == $value['account_id']) |
---|
| 1191 | { |
---|
| 1192 | $groups_select .= ' selected'; |
---|
| 1193 | } |
---|
| 1194 | } |
---|
| 1195 | $groups_select .= '>' . $value['account_lid'] . '</option>'."\n"; |
---|
| 1196 | } |
---|
| 1197 | |
---|
| 1198 | if (!$userData['account_primary_group']) |
---|
| 1199 | { |
---|
| 1200 | $userData['account_primary_group'] = @$userGroups[0]['account_id'] ? @$userGroups[0]['account_id'] : $account->name2id('Default'); |
---|
| 1201 | } |
---|
| 1202 | foreach($allGroups as $key => $value) |
---|
| 1203 | { |
---|
| 1204 | # print "<br>$key =>"; |
---|
| 1205 | # _debug_array($userGroups); |
---|
| 1206 | $primary_group_select .= '<option value="' . $value['account_id'] . '"'; |
---|
| 1207 | #print $value['account_id'].''.$value['account_primary_group'] |
---|
| 1208 | if ($value['account_id'] == $userData['account_primary_group']) |
---|
| 1209 | { |
---|
| 1210 | $primary_group_select .= ' selected="1"'; |
---|
| 1211 | } |
---|
| 1212 | $primary_group_select .= '>' . $value['account_lid'] . '</option>'."\n"; |
---|
| 1213 | } |
---|
| 1214 | |
---|
| 1215 | /* create list of available apps */ |
---|
| 1216 | $apps = CreateObject('phpgwapi.applications',$_account_id); |
---|
| 1217 | $db_perms = $apps->read_account_specific(); |
---|
| 1218 | |
---|
| 1219 | $availableApps = $GLOBALS['phpgw_info']['apps']; |
---|
| 1220 | uasort($availableApps,create_function('$a,$b','return strcasecmp($a["title"],$b["title"]);')); |
---|
| 1221 | |
---|
| 1222 | $appRightsOutput = ''; |
---|
| 1223 | $i = 0; |
---|
| 1224 | foreach($availableApps as $app => $data) |
---|
| 1225 | { |
---|
| 1226 | if (!$data['enabled'] || $data['status'] == 3) |
---|
| 1227 | { |
---|
| 1228 | continue; |
---|
| 1229 | } |
---|
| 1230 | $checked = (@$userData['account_permissions'][$app] || @$db_perms[$app]) && $_account_id ? ' checked="1"' : ''; |
---|
| 1231 | $part[$i&1] = sprintf('<td>%s</td><td><input type="checkbox" name="account_permissions[%s]" value="True"%s>', |
---|
| 1232 | $data['title'],$app,$checked). |
---|
| 1233 | ($this->apps_with_acl[$app] && $_account_id?'<a href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$app.'&owner='.$_account_id) |
---|
| 1234 | . '"><img src="'.$GLOBALS['phpgw']->common->image('phpgwapi','edit').'" border="0" hspace="3" align="absmiddle" title="' |
---|
| 1235 | . lang('Grant Access').'"></a>':' ').'</td>'; |
---|
| 1236 | |
---|
| 1237 | if ($i & 1) |
---|
| 1238 | { |
---|
| 1239 | $appRightsOutput .= sprintf('<tr bgcolor="%s">%s%s</tr>',$this->nextmatchs->alternate_row_color(), $part[0], $part[1]); |
---|
| 1240 | } |
---|
| 1241 | ++$i; |
---|
| 1242 | } |
---|
| 1243 | if ($i & 1) |
---|
| 1244 | { |
---|
| 1245 | $part[1] = '<td colspan="3"> </td>'; |
---|
| 1246 | $appRightsOutput .= sprintf('<tr bgcolor="%s">%s%s</tr>',$this->nextmatchs->alternate_row_color(), $part[0], $part[1]); |
---|
| 1247 | } |
---|
| 1248 | |
---|
| 1249 | $var = Array( |
---|
| 1250 | 'groups_select' |
---|
| 1251 | => '<select name="account_groups[]" multiple>'."\n".$groups_select.'</select>'."\n", |
---|
| 1252 | 'primary_group_select' |
---|
| 1253 | => '<select name="account_primary_group">'."\n".$primary_group_select.'</select>'."\n", |
---|
| 1254 | 'permissions_list' |
---|
| 1255 | => $appRightsOutput, |
---|
| 1256 | 'lang_app' => lang('application'), |
---|
| 1257 | 'lang_acl' => lang('enabled').' / '.lang('ACL'), |
---|
| 1258 | ); |
---|
| 1259 | $t->set_var($var); |
---|
| 1260 | |
---|
| 1261 | // create the menu on the left, if needed |
---|
| 1262 | // $menuClass = CreateObject('admin.uimenuclass'); |
---|
| 1263 | // This is now using ExecMethod() |
---|
| 1264 | $GLOBALS['account_id'] = $_account_id; |
---|
| 1265 | $t->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','edit_user')); |
---|
| 1266 | |
---|
| 1267 | echo $t->fp('out','form'); |
---|
| 1268 | } |
---|
| 1269 | |
---|
| 1270 | function edit_group_managers($group_info,$_errors='') |
---|
| 1271 | { |
---|
| 1272 | if ($GLOBALS['phpgw']->acl->check('group_access',16,'admin')) |
---|
| 1273 | { |
---|
| 1274 | $this->list_groups(); |
---|
| 1275 | return False; |
---|
| 1276 | } |
---|
| 1277 | |
---|
| 1278 | $accounts = CreateObject('phpgwapi.accounts',$group_info['account_id'],'u'); |
---|
| 1279 | $account_list = $accounts->member($group_info['account_id']); |
---|
| 1280 | $user_list = ''; |
---|
| 1281 | while (list($key,$entry) = each($account_list)) |
---|
| 1282 | { |
---|
| 1283 | $user_list .= '<option value="' . $entry['account_id'] . '"' |
---|
| 1284 | . $group_info['account_managers'][(int)$entry['account_id']] . '>' |
---|
| 1285 | . $GLOBALS['phpgw']->common->grab_owner_name($entry['account_id']) |
---|
| 1286 | . '</option>'."\n"; |
---|
| 1287 | } |
---|
| 1288 | |
---|
| 1289 | unset($GLOBALS['phpgw_info']['flags']['noheader']); |
---|
| 1290 | unset($GLOBALS['phpgw_info']['flags']['nonavbar']); |
---|
| 1291 | if(!@is_object($GLOBALS['phpgw']->js)) |
---|
| 1292 | { |
---|
| 1293 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
| 1294 | } |
---|
| 1295 | $GLOBALS['phpgw']->js->validate_file('jscode','openwindow','admin'); |
---|
| 1296 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 1297 | |
---|
| 1298 | $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
| 1299 | $t->set_unknowns('remove'); |
---|
| 1300 | |
---|
| 1301 | $t->set_file( |
---|
| 1302 | Array( |
---|
| 1303 | 'manager' =>'group_manager.tpl' |
---|
| 1304 | ) |
---|
| 1305 | ); |
---|
| 1306 | |
---|
| 1307 | $t->set_block('manager','form','form'); |
---|
| 1308 | $t->set_block('manager','link_row','link_row'); |
---|
| 1309 | |
---|
| 1310 | $var['th_bg'] = $GLOBALS['phpgw_info']['user']['theme']['th_bg']; |
---|
| 1311 | $var['lang_group'] = lang('Group'); |
---|
| 1312 | $var['group_name'] = $group_info['account_name']; |
---|
| 1313 | $var['tr_color1'] = $GLOBALS['phpgw_info']['user']['theme']['row_on']; |
---|
| 1314 | $var['form_action'] = $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.set_group_managers'); |
---|
| 1315 | $var['hidden'] = '<input type="hidden" name="account_id" value="'.$group_info['account_id'].'">'; |
---|
| 1316 | $var['lang_select_managers'] = lang('Select Group Managers'); |
---|
| 1317 | $var['group_members'] = '<select name="managers[]" size="'.(count($account_list)<5?count($account_list):5).'" multiple>'.$user_list.'</select>'; |
---|
| 1318 | $var['form_buttons'] = '<tr align="center"><td colspan="2"><input type="submit" name="submit" value="'.lang('Submit').'"> ' |
---|
| 1319 | . '<input type="submit" name="cancel" value="'.lang('Cancel').'"><td></tr>'; |
---|
| 1320 | $t->set_var($var); |
---|
| 1321 | |
---|
| 1322 | // create the menu on the left, if needed |
---|
| 1323 | $t->set_var('rows',ExecMethod('admin.uimenuclass.createHTMLCode','edit_group')); |
---|
| 1324 | |
---|
| 1325 | $t->pfp('out','form'); |
---|
| 1326 | } |
---|
| 1327 | } |
---|
| 1328 | ?> |
---|