2001-09-02 01:32:40 +02:00
< ? php
/************************************************************************** \
2004-01-27 00:26:19 +01:00
* eGroupWare - account administration *
* http :// www . egroupware . org *
2003-08-28 16:16:30 +02:00
* -------------------------------------------- *
2001-09-02 01:32:40 +02:00
* This program is free software ; you can redistribute it and / or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation ; either version 2 of the License , or ( at your *
* option ) any later version . *
\ **************************************************************************/
2001-09-04 05:29:36 +02:00
/* $Id$ */
2001-09-02 01:32:40 +02:00
class uiaccounts
{
2005-02-28 17:12:31 +01:00
//(regis) maybe some of them should be deleted?
2007-03-09 13:07:15 +01:00
var $public_functions = array (
2003-08-28 16:16:30 +02:00
'list_groups' => True ,
'list_users' => True ,
'add_group' => True ,
'add_user' => True ,
'delete_group' => True ,
'delete_user' => True ,
'edit_user' => True ,
'edit_user_hook' => True ,
'edit_group' => True ,
'view_user' => True ,
2005-02-28 17:12:31 +01:00
'edit_group_hook' => True ,
2003-09-24 18:48:04 +02:00
'edit_view_user_hook' => True ,
2007-03-09 13:09:54 +01:00
'group_manager' => True ,
'set_group_managers' => True
2001-09-02 01:32:40 +02:00
);
2013-06-25 18:37:44 +02:00
/**
* Instance of boaccounts
* @ var boaccounts
*/
2001-09-02 01:32:40 +02:00
var $bo ;
var $nextmatchs ;
2004-08-28 15:48:32 +02:00
var $apps_with_acl = array (
'todo' => True ,
'calendar' => True ,
'projects' => True ,
'infolog' => True ,
2008-04-18 14:38:17 +02:00
'filemanager' => array (
'menuaction' => 'filemanager.filemanager_ui.file' ,
'path' => '/home/$account_lid' ,
'tabs' => 'eacl' ,
'popup' => '495x400' ,
),
2004-08-28 15:48:32 +02:00
'tts' => True ,
'bookmarks' => True ,
'img' => True ,
'phpbrain' => True ,
2005-06-14 09:44:36 +02:00
'projectmanager' => True ,
2007-03-09 13:07:15 +01:00
'timesheet' => True
2004-08-28 15:48:32 +02:00
);
2001-09-02 01:32:40 +02:00
2013-06-25 18:37:44 +02:00
function __construct ()
2001-09-02 01:32:40 +02:00
{
2005-10-14 19:03:16 +02:00
$this -> bo =& CreateObject ( 'admin.boaccounts' );
$this -> nextmatchs =& CreateObject ( 'phpgwapi.nextmatchs' );
2001-11-17 04:09:19 +01:00
@ set_time_limit ( 300 );
2007-03-09 13:07:15 +01:00
/* Moved from bo class */
if ( get_magic_quotes_gpc ()) // deal with magic_quotes_gpc On
{
$_POST = $this -> array_stripslashes ( $_POST );
}
2008-06-27 12:03:14 +02:00
foreach ( $GLOBALS [ 'egw' ] -> hooks -> process ( 'group_acl' , '' , true ) as $app => $data )
{
if ( $data ) $this -> apps_with_acl [ $app ] = $data ;
}
2001-09-02 01:32:40 +02:00
}
function row_action ( $action , $type , $account_id )
{
2005-10-14 19:03:16 +02:00
return '<a href="' . $GLOBALS [ 'egw' ] -> link ( '/index.php' , Array (
2001-12-21 04:41:06 +01:00
'menuaction' => 'admin.uiaccounts.' . $action . '_' . $type ,
'account_id' => $account_id
)) . '"> ' . lang ( $action ) . ' </a>' ;
2001-09-02 01:32:40 +02:00
}
2001-09-03 04:58:25 +02:00
function list_groups ()
{
2006-12-06 16:15:42 +01:00
$query_types = array (
'all' => 'all fields' ,
'lid' => 'LoginID' ,
'start' => 'start with' ,
2007-03-09 13:07:15 +01:00
'exact' => 'exact'
2006-12-06 16:15:42 +01:00
);
2006-12-15 11:41:33 +01:00
2005-10-14 19:03:16 +02:00
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 1 , 'admin' ))
2003-04-27 21:28:13 +02:00
{
2005-10-14 19:03:16 +02:00
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw' ] -> link ( '/admin/index.php' ));
2001-09-04 06:26:51 +02:00
}
2001-09-03 04:58:25 +02:00
2003-04-07 00:29:57 +02:00
$GLOBALS [ 'cd' ] = ( $_GET [ 'cd' ] ? $_GET [ 'cd' ] : 0 );
2004-04-04 20:59:12 +02:00
2006-12-06 16:15:42 +01:00
if ( isset ( $_REQUEST [ 'query' ]))
2004-04-04 20:59:12 +02:00
{
// limit query to limit characters
2010-03-21 10:37:52 +01:00
//if(preg_match('/^[a-z_0-9]+$/i',$_REQUEST['query']))
2006-12-06 16:15:42 +01:00
$GLOBALS [ 'query' ] = $_REQUEST [ 'query' ];
2004-04-04 20:59:12 +02:00
}
2006-12-15 11:41:33 +01:00
2004-04-04 20:59:12 +02:00
if ( isset ( $_POST [ 'start' ]))
{
$start = ( int ) $_POST [ 'start' ];
}
else
{
$start = 0 ;
}
2006-12-06 16:15:42 +01:00
switch ( $_REQUEST [ 'order' ])
2004-04-04 20:59:12 +02:00
{
case 'account_lid' :
2006-12-06 16:15:42 +01:00
$order = $_REQUEST [ 'order' ];
2004-04-04 20:59:12 +02:00
break ;
default :
$order = 'account_lid' ;
break ;
}
2006-12-06 16:15:42 +01:00
switch ( $_REQUEST [ 'sort' ])
2004-04-04 20:59:12 +02:00
{
case 'ASC' :
case 'DESC' :
2006-12-06 16:15:42 +01:00
$sort = $_REQUEST [ 'sort' ];
2004-04-04 20:59:12 +02:00
break ;
default :
$sort = 'ASC' ;
break ;
}
2006-12-15 11:41:33 +01:00
2005-10-14 19:03:16 +02:00
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'egw_info' ][ 'apps' ][ 'admin' ][ 'title' ] . ' - ' .
2004-05-19 08:05:01 +02:00
lang ( 'User groups' );
2013-06-25 18:37:44 +02:00
common :: egw_header ();
2001-09-03 04:58:25 +02:00
2005-10-14 19:03:16 +02:00
$p =& CreateObject ( 'phpgwapi.Template' , EGW_APP_TPL );
2003-08-28 16:16:30 +02:00
$p -> set_file (
array (
'groups' => 'groups.tpl'
)
);
$p -> set_block ( 'groups' , 'list' , 'list' );
$p -> set_block ( 'groups' , 'row' , 'row' );
$p -> set_block ( 'groups' , 'row_empty' , 'row_empty' );
2006-12-06 16:15:42 +01:00
$p -> set_block ( 'list' , 'letter_search' , 'letter_search_cells' );
2003-04-23 23:52:22 +02:00
2006-12-06 16:15:42 +01:00
$search_param = array (
'type' => 'groups' ,
'start' => $start ,
'sort' => $sort ,
'order' => $order ,
2007-03-09 13:07:15 +01:00
'query_type' => $_REQUEST [ 'query_type' ]
2006-12-06 16:15:42 +01:00
);
//_debug_array($search_param);
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 2 , 'admin' ))
2001-09-04 06:26:51 +02:00
{
2006-12-06 16:15:42 +01:00
$search_param [ 'query' ] = $GLOBALS [ 'query' ];
2001-09-04 06:26:51 +02:00
}
2006-12-06 16:15:42 +01:00
$account_info = $GLOBALS [ 'egw' ] -> accounts -> search ( $search_param );
2005-10-14 19:03:16 +02:00
$total = $GLOBALS [ 'egw' ] -> accounts -> total ;
2003-08-28 16:16:30 +02:00
2006-12-06 16:15:42 +01:00
$link_data = array (
'menuaction' => 'admin.uiaccounts.list_groups' ,
//'group_id' => $_REQUEST['group_id'],
'query_type' => $_REQUEST [ 'query_type' ],
'query' => $GLOBALS [ 'query' ],
);
2003-08-28 16:16:30 +02:00
$var = Array (
2006-12-06 16:15:42 +01:00
'left_next_matchs' => $this -> nextmatchs -> left ( '/index.php' , $start , $total , $link_data ),
'right_next_matchs' => $this -> nextmatchs -> right ( '/index.php' , $start , $total , $link_data ),
2004-05-19 08:05:01 +02:00
'lang_groups' => lang ( '%1 - %2 of %3 user groups' , $start + 1 , $start + count ( $account_info ), $total ),
2006-12-06 16:15:42 +01:00
'sort_name' => $this -> nextmatchs -> show_sort_order ( $sort , 'account_lid' , $order , '/index.php' , lang ( 'name' ), $link_data ),
2003-08-28 16:16:30 +02:00
'header_edit' => lang ( 'Edit' ),
2006-12-06 16:15:42 +01:00
'header_delete' => lang ( 'Delete' ),
'lang_search' => lang ( 'search' ) // KL 20061128 Text fr den Suchbutton hinzugefeugt
2001-12-21 04:41:06 +01:00
);
2003-08-28 16:16:30 +02:00
$p -> set_var ( $var );
2001-09-03 04:58:25 +02:00
2003-08-28 16:16:30 +02:00
if ( ! count ( $account_info ) || ! $total )
{
$p -> set_var ( 'message' , lang ( 'No matches found' ));
$p -> parse ( 'rows' , 'row_empty' , True );
2001-09-03 04:58:25 +02:00
}
2003-08-28 16:16:30 +02:00
else
{
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 8 , 'admin' ))
2003-08-28 16:16:30 +02:00
{
$can_view = True ;
}
2001-09-04 06:26:51 +02:00
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 16 , 'admin' ))
2003-08-28 16:16:30 +02:00
{
$can_edit = True ;
}
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 32 , 'admin' ))
2003-08-28 16:16:30 +02:00
{
$can_delete = True ;
}
2004-05-19 08:05:01 +02:00
foreach ( $account_info as $account )
2003-08-28 16:16:30 +02:00
{
$var = Array (
2005-07-06 04:26:44 +02:00
'class' => $this -> nextmatchs -> alternate_row_color ( '' , True ),
2003-08-28 16:16:30 +02:00
'group_name' => ( ! $account [ 'account_lid' ] ? ' ' : $account [ 'account_lid' ]),
'delete_link' => $this -> row_action ( 'delete' , 'group' , $account [ 'account_id' ])
);
$p -> set_var ( $var );
if ( $can_edit )
{
$p -> set_var ( 'edit_link' , $this -> row_action ( 'edit' , 'group' , $account [ 'account_id' ]));
}
else
{
$p -> set_var ( 'edit_link' , ' ' );
}
if ( $can_delete )
{
$p -> set_var ( 'delete_link' , $this -> row_action ( 'delete' , 'group' , $account [ 'account_id' ]));
}
else
{
$p -> set_var ( 'delete_link' , ' ' );
}
2003-04-23 03:08:32 +02:00
2003-08-28 16:16:30 +02:00
$p -> fp ( 'rows' , 'row' , True );
}
}
2006-12-15 11:41:33 +01:00
2006-12-06 16:15:42 +01:00
$link_data += array (
'order' => $order ,
2007-03-09 13:07:15 +01:00
'sort' => $sort
2006-12-06 16:15:42 +01:00
);
$p -> set_var ( array (
2008-03-25 17:37:37 +01:00
'query' => html :: htmlspecialchars ( $GLOBALS [ 'query' ]),
'query_type' => is_array ( $query_types ) ? html :: select ( 'query_type' , $_REQUEST [ 'query_type' ], $query_types ) : '' ,
2006-12-06 16:15:42 +01:00
//'lang_group' => lang('group'),
//'group' => $uiaccountsel->selection('group_id','admin_uiaccount_listusers_group_id',$_REQUEST['group_id'],'groups',0,False,'','this.form.submit();',lang('all')),
'accounts_url' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , $link_data ),
));
$letters = lang ( 'alphabet' );
$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' );
$link_data [ 'query_type' ] = 'start' ;
foreach ( $letters as $letter )
{
$link_data [ 'query' ] = $letter ;
$p -> set_var ( array (
'letter' => $letter ,
'link' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , $link_data ),
2011-03-30 10:18:06 +02:00
'class' => $GLOBALS [ 'query' ] == $letter && $_REQUEST [ 'query_type' ] == 'start' ? 'lettersearch_active' : 'lettersearch' ,
2006-12-06 16:15:42 +01:00
));
$p -> fp ( 'letter_search_cells' , 'letter_search' , True );
}
unset ( $link_data [ 'query' ]);
unset ( $link_data [ 'query_type' ]);
$p -> set_var ( array (
'letter' => lang ( 'all' ),
'link' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , $link_data ),
2011-03-30 10:18:06 +02:00
'class' => $_REQUEST [ 'query_type' ] != 'start' || ! in_array ( $GLOBALS [ 'query' ], $letters ) ? 'lettersearch_active' : 'lettersearch' ,
2006-12-06 16:15:42 +01:00
));
$p -> fp ( 'letter_search_cells' , 'letter_search' , True );
2006-12-15 11:41:33 +01:00
2003-08-28 16:16:30 +02:00
$var = Array (
2005-10-14 19:03:16 +02:00
'new_action' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.add_group' ),
'search_action' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_groups' )
2003-04-23 03:08:32 +02:00
);
2003-08-28 16:16:30 +02:00
$p -> set_var ( $var );
2001-09-03 04:58:25 +02:00
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 4 , 'admin' ))
2003-08-28 16:16:30 +02:00
{
$p -> set_var ( 'input_add' , '<input type="submit" value="' . lang ( 'Add' ) . '">' );
}
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 2 , 'admin' ))
2001-09-04 03:12:13 +02:00
{
2004-05-19 08:05:01 +02:00
$p -> set_var ( 'input_search' , lang ( 'Search' ) . ' <input name="query" value="' . htmlspecialchars ( stripslashes ( $GLOBALS [ 'query' ])) . '">' );
2003-04-27 21:28:13 +02:00
}
2003-08-28 16:16:30 +02:00
$p -> pfp ( 'out' , 'list' );
}
function list_users ( $param_cd = '' )
{
2005-10-14 19:03:16 +02:00
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 1 , 'admin' ))
2003-04-27 21:28:13 +02:00
{
2008-03-25 17:37:37 +01:00
$GLOBALS [ 'egw' ] -> redirect_link ( '/admin/index.php' );
2004-07-04 19:33:13 +02:00
}
2001-11-16 05:09:21 +01:00
if ( $param_cd )
2001-09-02 01:32:40 +02:00
{
$cd = $param_cd ;
}
2004-07-04 19:33:13 +02:00
if ( isset ( $_REQUEST [ 'query' ]))
2003-08-28 16:16:30 +02:00
{
2006-10-28 11:38:20 +02:00
$GLOBALS [ 'query' ] = $_REQUEST [ 'query' ];
2003-08-28 16:16:30 +02:00
}
2004-07-04 19:33:13 +02:00
if ( isset ( $_REQUEST [ 'start' ]))
2003-08-28 16:16:30 +02:00
{
2004-07-04 19:33:13 +02:00
$start = ( int ) $_REQUEST [ 'start' ];
2003-08-28 16:16:30 +02:00
}
else
{
$start = 0 ;
}
2003-04-23 03:08:32 +02:00
2004-07-04 19:33:13 +02:00
switch ( $_REQUEST [ 'order' ])
2003-04-07 00:29:57 +02:00
{
2004-04-04 20:59:12 +02:00
case 'account_lastname' :
case 'account_firstname' :
case 'account_lid' :
2004-07-04 19:33:13 +02:00
case 'account_email' :
$order = $_REQUEST [ 'order' ];
2004-04-04 20:59:12 +02:00
break ;
default :
$order = 'account_lid' ;
break ;
2003-04-07 00:29:57 +02:00
}
2004-04-04 20:59:12 +02:00
2004-07-04 19:33:13 +02:00
switch ( $_REQUEST [ 'sort' ])
2003-04-07 00:29:57 +02:00
{
2004-04-04 20:59:12 +02:00
case 'ASC' :
case 'DESC' :
2004-07-04 19:33:13 +02:00
$sort = $_REQUEST [ 'sort' ];
2004-04-04 20:59:12 +02:00
break ;
default :
$sort = 'ASC' ;
break ;
2003-04-07 00:29:57 +02:00
}
2004-04-04 20:59:12 +02:00
2005-10-14 19:03:16 +02:00
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]);
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'app_header' ] = $GLOBALS [ 'egw_info' ][ 'apps' ][ 'admin' ][ 'title' ] . ' - ' .
2004-05-19 08:05:01 +02:00
lang ( 'User accounts' );
2013-06-25 18:37:44 +02:00
common :: egw_header ();
2001-09-02 01:32:40 +02:00
2005-10-14 19:03:16 +02:00
$p =& CreateObject ( 'phpgwapi.Template' , EGW_APP_TPL );
2003-04-23 23:52:22 +02:00
2003-08-28 16:16:30 +02:00
$p -> set_file (
Array (
2004-07-04 19:33:13 +02:00
'list' => 'accounts.tpl'
2003-08-28 16:16:30 +02:00
)
);
2004-07-04 19:33:13 +02:00
$p -> set_block ( 'list' , 'row' , 'rows' );
2006-10-28 11:38:20 +02:00
$p -> set_block ( 'list' , 'row_empty' , 'no_rows' );
2004-07-04 19:33:13 +02:00
$p -> set_block ( 'list' , 'letter_search' , 'letter_search_cells' );
$search_param = array (
2005-12-15 00:27:17 +01:00
'type' => ( int ) $_REQUEST [ 'group_id' ] ? $_REQUEST [ 'group_id' ] : 'accounts' ,
2004-07-04 19:33:13 +02:00
'start' => $start ,
'sort' => $sort ,
'order' => $order ,
'query_type' => $_REQUEST [ 'query_type' ],
2013-01-25 14:21:31 +01:00
'active' => false , // false = return inactive and expired accounts too
2004-07-04 19:33:13 +02:00
);
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 2 , 'admin' ))
2001-09-04 06:26:51 +02:00
{
2004-07-04 19:33:13 +02:00
$search_param [ 'query' ] = $GLOBALS [ 'query' ];
2001-09-04 06:26:51 +02:00
}
2005-10-14 19:03:16 +02:00
$account_info = $GLOBALS [ 'egw' ] -> accounts -> search ( $search_param );
$total = $GLOBALS [ 'egw' ] -> accounts -> total ;
2008-04-18 14:38:17 +02:00
2004-07-04 19:33:13 +02:00
$link_data = array (
'menuaction' => 'admin.uiaccounts.list_users' ,
'group_id' => $_REQUEST [ 'group_id' ],
'query_type' => $_REQUEST [ 'query_type' ],
2006-10-28 11:38:20 +02:00
'query' => $GLOBALS [ 'query' ],
2004-07-04 19:33:13 +02:00
);
2005-10-14 19:03:16 +02:00
$uiaccountsel =& CreateObject ( 'phpgwapi.uiaccountsel' );
2004-07-04 19:33:13 +02:00
$p -> set_var ( array (
'left_next_matchs' => $this -> nextmatchs -> left ( '/index.php' , $start , $total , $link_data ),
2013-06-25 18:37:44 +02:00
'lang_showing' => ( $_REQUEST [ 'group_id' ] ? common :: grab_owner_name ( $_REQUEST [ 'group_id' ]) . ': ' : '' ) .
2006-10-28 11:38:20 +02:00
( $GLOBALS [ 'query' ] ? lang ( " Search %1 '%2' " , lang ( $uiaccountsel -> query_types [ $_REQUEST [ 'query_type' ]]),
2008-03-25 17:37:37 +01:00
html :: htmlspecialchars ( $GLOBALS [ 'query' ])) . ': ' : '' )
2004-07-04 19:33:13 +02:00
. $this -> nextmatchs -> show_hits ( $total , $start ),
'right_next_matchs' => $this -> nextmatchs -> right ( '/index.php' , $start , $total , $link_data ),
'lang_loginid' => $this -> nextmatchs -> show_sort_order ( $sort , 'account_lid' , $order , '/index.php' , lang ( 'LoginID' ), $link_data ),
'lang_lastname' => $this -> nextmatchs -> show_sort_order ( $sort , 'account_lastname' , $order , '/index.php' , lang ( 'last name' ), $link_data ),
'lang_firstname' => $this -> nextmatchs -> show_sort_order ( $sort , 'account_firstname' , $order , '/index.php' , lang ( 'first name' ), $link_data ),
'lang_email' => $this -> nextmatchs -> show_sort_order ( $sort , 'account_email' , $order , '/index.php' , lang ( 'email' ), $link_data ),
2008-04-10 11:08:51 +02:00
'lang_account_active' => lang ( 'Account active' ) . " <br> " . lang ( 'Created' ) . " <br> " . lang ( 'Modified' ),
2003-08-28 16:16:30 +02:00
'lang_edit' => lang ( 'edit' ),
'lang_delete' => lang ( 'delete' ),
'lang_view' => lang ( 'view' ),
'lang_search' => lang ( 'search' )
2004-07-04 19:33:13 +02:00
));
$link_data += array (
'order' => $order ,
'sort' => $sort ,
2001-09-02 01:32:40 +02:00
);
2004-07-04 19:33:13 +02:00
$p -> set_var ( array (
2008-03-25 17:37:37 +01:00
'query' => html :: htmlspecialchars ( $GLOBALS [ 'query' ]),
'query_type' => is_array ( $uiaccountsel -> query_types ) ? html :: select ( 'query_type' , $_REQUEST [ 'query_type' ], $uiaccountsel -> query_types ) : '' ,
2004-07-04 19:33:13 +02:00
'lang_group' => lang ( 'group' ),
'group' => $uiaccountsel -> selection ( 'group_id' , 'admin_uiaccount_listusers_group_id' , $_REQUEST [ 'group_id' ], 'groups' , 0 , False , '' , 'this.form.submit();' , lang ( 'all' )),
2005-10-14 19:03:16 +02:00
'accounts_url' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , $link_data ),
2004-07-04 19:33:13 +02:00
));
$letters = lang ( 'alphabet' );
$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' );
$link_data [ 'query_type' ] = 'start' ;
foreach ( $letters as $letter )
{
$link_data [ 'query' ] = $letter ;
$p -> set_var ( array (
'letter' => $letter ,
2005-10-14 19:03:16 +02:00
'link' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , $link_data ),
2011-03-30 10:18:06 +02:00
'class' => $GLOBALS [ 'query' ] == $letter && $_REQUEST [ 'query_type' ] == 'start' ? 'lettersearch_active' : 'lettersearch' ,
2004-07-04 19:33:13 +02:00
));
$p -> fp ( 'letter_search_cells' , 'letter_search' , True );
}
unset ( $link_data [ 'query' ]);
unset ( $link_data [ 'query_type' ]);
$p -> set_var ( array (
'letter' => lang ( 'all' ),
2005-10-14 19:03:16 +02:00
'link' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , $link_data ),
2011-03-30 10:18:06 +02:00
'class' => $_REQUEST [ 'query_type' ] != 'start' || ! in_array ( $GLOBALS [ 'query' ], $letters ) ? 'lettersearch_active' : 'lettersearch' ,
2004-07-04 19:33:13 +02:00
));
$p -> fp ( 'letter_search_cells' , 'letter_search' , True );
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 4 , 'admin' ))
2003-08-28 16:16:30 +02:00
{
2005-10-14 19:03:16 +02:00
$p -> set_var ( 'new_action' , $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.add_user' ));
2003-11-05 11:35:53 +01:00
$p -> set_var ( 'input_add' , '<input type="submit" value="' . lang ( 'Add' ) . '">' );
2001-09-04 03:12:13 +02:00
}
2003-08-28 16:16:30 +02:00
if ( ! count ( $account_info ) || ! $total )
2003-04-23 03:08:32 +02:00
{
2003-08-28 16:16:30 +02:00
$p -> set_var ( 'message' , lang ( 'No matches found' ));
$p -> parse ( 'rows' , 'row_empty' , True );
}
else
{
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 8 , 'admin' ))
2003-08-28 16:16:30 +02:00
{
$can_view = True ;
}
2003-04-23 03:08:32 +02:00
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 16 , 'admin' ))
2003-04-23 03:08:32 +02:00
{
2003-08-28 16:16:30 +02:00
$can_edit = True ;
2003-04-23 03:08:32 +02:00
}
2003-08-28 16:16:30 +02:00
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 32 , 'admin' ))
2003-08-28 16:16:30 +02:00
{
$can_delete = True ;
}
2004-07-04 19:33:13 +02:00
foreach ( $account_info as $account )
2003-04-23 03:08:32 +02:00
{
2004-07-04 19:33:13 +02:00
$p -> set_var ( 'class' , $this -> nextmatchs -> alternate_row_color ( '' , True ));
2008-04-10 11:08:51 +02:00
if ( $account [ 'account_status' ] == 'A' )
{
$account [ 'account_status' ] = lang ( 'Enabled' );
}
else
{
$account [ 'account_status' ] = '<font color="red">' . lang ( 'Disabled' ) . '</font>' ;
}
2008-04-18 14:38:17 +02:00
if ( isset ( $account [ 'account_created' ]))
2013-06-25 18:37:44 +02:00
$account [ 'account_status' ] .= '<br>' . common :: show_date ( $account [ 'account_created' ], $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ]);
2008-04-18 14:38:17 +02:00
if ( isset ( $account [ 'account_modified' ]))
2013-06-25 18:37:44 +02:00
$account [ 'account_status' ] .= '<br>' . common :: show_date ( $account [ 'account_modified' ], $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'dateformat' ]);
2008-04-10 11:08:51 +02:00
2003-08-28 16:16:30 +02:00
2004-07-04 19:33:13 +02:00
$p -> set_var ( $account );
2003-08-28 16:16:30 +02:00
if ( $can_edit )
{
$p -> set_var ( 'row_edit' , $this -> row_action ( 'edit' , 'user' , $account [ 'account_id' ]));
}
else
2003-04-23 03:08:32 +02:00
{
2003-08-28 16:16:30 +02:00
$p -> set_var ( 'row_edit' , ' ' );
2003-04-23 03:08:32 +02:00
}
2003-08-28 16:16:30 +02:00
if ( $can_delete )
2003-04-23 03:08:32 +02:00
{
2005-10-14 19:03:16 +02:00
$p -> set_var ( 'row_delete' ,( $GLOBALS [ 'egw_info' ][ 'user' ][ 'userid' ] != $account [ 'account_lid' ] ? $this -> row_action ( 'delete' , 'user' , $account [ 'account_id' ]) : ' ' ));
2003-08-28 16:16:30 +02:00
}
else
{
$p -> set_var ( 'row_delete' , ' ' );
2003-04-23 03:08:32 +02:00
}
2003-08-28 16:16:30 +02:00
if ( $can_view )
2003-04-23 03:08:32 +02:00
{
2003-08-28 16:16:30 +02:00
$p -> set_var ( 'row_view' , $this -> row_action ( 'view' , 'user' , $account [ 'account_id' ]));
2003-04-23 03:08:32 +02:00
}
else
{
2003-08-28 16:16:30 +02:00
$p -> set_var ( 'row_view' , ' ' );
2003-04-23 03:08:32 +02:00
}
2003-08-28 16:16:30 +02:00
$p -> parse ( 'rows' , 'row' , True );
2003-04-23 03:08:32 +02:00
}
2003-08-28 16:16:30 +02:00
} // End else
$p -> pfp ( 'out' , 'list' );
}
2003-04-23 03:08:32 +02:00
2003-08-28 16:16:30 +02:00
function add_group ()
{
2005-10-14 19:03:16 +02:00
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 4 , 'admin' ))
2003-04-23 03:08:32 +02:00
{
2003-08-28 16:16:30 +02:00
$this -> list_groups ();
return False ;
2001-09-04 06:26:51 +02:00
}
2007-03-09 13:07:15 +01:00
if ( $_POST [ 'edit' ])
{
$group_permissions = ( $_POST [ 'account_apps' ] ? $_POST [ 'account_apps' ] : Array ());
$account_apps = Array ();
foreach ( $group_permissions as $key => $value )
{
if ( $value )
{
$account_apps [ $key ] = True ;
}
}
@ reset ( $account_apps );
$group_info = Array (
'account_id' => ( $_POST [ 'account_id' ] ? ( int ) $_POST [ 'account_id' ] : 0 ),
'account_name' => ( $_POST [ 'account_name' ] ? $_POST [ 'account_name' ] : '' ),
'account_user' => $_POST [ 'account_user' ],
'account_apps' => $account_apps ,
'account_email' => $_POST [ 'account_email' ]
);
$errors = $this -> bo -> add_group ( $group_info );
if ( is_array ( $errors ))
{
$this -> create_edit_group ( $group_info , $errors );
2013-06-25 18:37:44 +02:00
common :: egw_exit ();
2007-03-09 13:07:15 +01:00
}
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_groups' ));
}
else
{
$group_info = Array (
'account_id' => $_GET [ 'account_id' ],
'account_name' => '' ,
'account_user' => Array (),
'account_apps' => Array ()
2003-08-28 16:16:30 +02:00
);
2007-03-09 13:07:15 +01:00
$this -> create_edit_group ( $group_info );
}
2003-08-28 16:16:30 +02:00
}
2001-09-03 04:58:25 +02:00
2003-08-28 16:16:30 +02:00
function add_user ()
{
2013-06-25 18:37:44 +02:00
return $this -> edit_user ( '' , '' , 4 );
2003-08-28 16:16:30 +02:00
}
function delete_group ()
{
2005-10-14 19:03:16 +02:00
if ( $_POST [ 'no' ] || $_POST [ 'yes' ] || !@ isset ( $_GET [ 'account_id' ]) || !@ $_GET [ 'account_id' ] || $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 32 , 'admin' ))
2003-08-28 16:16:30 +02:00
{
if ( $_POST [ 'yes' ])
{
2007-03-09 13:07:15 +01:00
$this -> bo -> delete_group ( $_POST [ 'account_id' ]);
2003-08-28 16:16:30 +02:00
}
2007-03-09 13:07:15 +01:00
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_groups' ));
2001-09-03 04:58:25 +02:00
}
2003-04-23 03:08:32 +02:00
2005-10-14 19:03:16 +02:00
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]);
2008-03-25 17:37:37 +01:00
2013-06-25 18:37:44 +02:00
common :: egw_header ();
2003-08-28 16:16:30 +02:00
2005-10-14 19:03:16 +02:00
$p =& CreateObject ( 'phpgwapi.Template' , EGW_APP_TPL );
2003-08-28 16:16:30 +02:00
$p -> set_file (
Array (
'body' => 'delete_common.tpl' ,
'message_row' => 'message_row.tpl' ,
'form_button' => 'form_button_script.tpl'
)
2003-04-23 03:08:32 +02:00
);
2003-08-28 16:16:30 +02:00
$p -> set_var ( 'message_display' , lang ( 'Are you sure you want to delete this group ?' ));
$p -> parse ( 'messages' , 'message_row' );
2003-04-23 03:08:32 +02:00
2006-06-07 01:42:56 +02:00
if (( $old_group_list = $GLOBALS [ 'egw' ] -> accounts -> memberships (( int ) $_GET [ 'account_id' ], true )))
2001-09-03 04:58:25 +02:00
{
2005-10-14 19:03:16 +02:00
$group_name = $GLOBALS [ 'egw' ] -> accounts -> id2name ( $_GET [ 'account_id' ]);
2003-04-23 03:08:32 +02:00
2003-08-28 16:16:30 +02:00
$p -> set_var ( 'message_display' , '<br>' );
$p -> parse ( 'messages' , 'message_row' , True );
2003-04-23 03:08:32 +02:00
2003-08-28 16:16:30 +02:00
$user_list = '' ;
while ( list (, $id ) = each ( $old_group_list ))
2003-04-23 03:08:32 +02:00
{
2005-10-14 19:03:16 +02:00
$user_list .= '<a href="' . $GLOBALS [ 'egw' ] -> link ( '/index.php' ,
2003-08-28 16:16:30 +02:00
Array (
'menuaction' => 'admin.uiaccounts.edit_user' ,
'account_id' => $id
)
2013-06-25 18:37:44 +02:00
) . '">' . common :: grab_owner_name ( $id ) . '</a><br>' ;
2003-04-23 03:08:32 +02:00
}
2003-08-28 16:16:30 +02:00
$p -> set_var ( 'message_display' , $user_list );
$p -> parse ( 'messages' , 'message_row' , True );
$p -> set_var ( 'message_display' , lang ( " Sorry, the above users are still a member of the group %1 " , $group_name )
. '.<br>' . lang ( 'They must be removed before you can continue' ) . '.<br>' . lang ( 'Remove all users from this group' ) . '?' );
$p -> parse ( 'messages' , 'message_row' , True );
2003-04-23 03:08:32 +02:00
}
2001-09-03 04:58:25 +02:00
2003-08-28 16:16:30 +02:00
$var = Array (
2005-10-14 19:03:16 +02:00
'form_action' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.delete_group' ),
2003-08-28 16:16:30 +02:00
'hidden_vars' => '<input type="hidden" name="account_id" value="' . $_GET [ 'account_id' ] . '">' ,
'yes' => lang ( 'Yes' ),
'no' => lang ( 'No' )
);
$p -> set_var ( $var );
/*
$p -> parse ( 'yes' , 'form_button' );
2003-04-23 03:08:32 +02:00
2003-08-28 16:16:30 +02:00
$var = Array (
'submit_button' => lang ( 'Submit' ),
2005-10-14 19:03:16 +02:00
'action_url_button' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_groups' ),
2003-08-28 16:16:30 +02:00
'action_text_button' => ' ' . lang ( 'No' ),
'action_confirm_button' => '' ,
'action_extra_field' => ''
);
$p -> set_var ( $var );
$p -> parse ( 'no' , 'form_button' );
*/
$p -> pparse ( 'phpgw_body' , 'body' );
}
function delete_user ()
{
2007-05-07 10:06:03 +02:00
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 32 , 'admin' ) || $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_id' ] == $_GET [ 'account_id' ] ||
$_POST [ 'cancel' ])
2003-04-23 03:08:32 +02:00
{
2007-03-09 13:07:15 +01:00
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_users' ));
}
if ( $_POST [ 'delete_account' ])
{
$this -> bo -> delete_user ( $_POST [ 'account_id' ], $_POST [ 'new_owner' ]);
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_users' ));
2003-08-28 16:16:30 +02:00
}
2006-12-15 11:41:33 +01:00
2005-10-14 19:03:16 +02:00
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]);
2013-06-25 18:37:44 +02:00
common :: egw_header ();
2003-04-23 03:08:32 +02:00
2005-10-14 19:03:16 +02:00
$t =& CreateObject ( 'phpgwapi.Template' , EGW_APP_TPL );
2003-08-28 16:16:30 +02:00
$t -> set_file (
Array (
'form' => 'delete_account.tpl'
)
2003-04-23 03:08:32 +02:00
);
2003-08-28 16:16:30 +02:00
$var = Array (
2007-03-09 13:07:15 +01:00
'form_action' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.delete_user' ),
2003-08-28 16:16:30 +02:00
'account_id' => $_GET [ 'account_id' ]
2003-04-23 03:08:32 +02:00
);
2003-08-28 16:16:30 +02:00
// the account can have special chars/white spaces, if it is a ldap dn
$account_id = rawurlencode ( $_GET [ 'account_id' ]);
2003-04-23 03:08:32 +02:00
2003-08-28 16:16:30 +02:00
$var [ 'lang_new_owner' ] = lang ( 'Who would you like to transfer ALL records owned by the deleted user to?' );
2008-03-06 10:03:27 +01:00
$accountsel = new uiaccountsel ();
$var [ 'new_owner_select' ] = $accountsel -> selection ( 'new_owner' , 'new_owner' , array ( '' ), 'accounts' , 0 , $account_id , 'size="15"' , '' , lang ( 'Delete all records' ));
2003-08-28 16:16:30 +02:00
$var [ 'cancel' ] = lang ( 'cancel' );
$var [ 'delete' ] = lang ( 'delete' );
$t -> set_var ( $var );
$t -> pparse ( 'out' , 'form' );
2001-09-03 04:58:25 +02:00
}
2005-02-28 17:12:31 +01:00
// (regis) why only for users, it works with groups as well so I add it
// I use it on the workflow app to add monitoring rights for some users
// and we could have history of connexions for members groups.
function edit_group_hook () // (regis) why only for users, it works with groups as well so I add it
{
if ( $_GET [ 'account_id' ] && // can't set it on add
2005-10-14 19:03:16 +02:00
! $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 64 , 'admin' )) // no rights to set ACL-rights
2005-02-28 17:12:31 +01:00
{
$GLOBALS [ 'menuData' ][] = array (
'description' => 'ACL Rights' ,
'url' => '/index.php' ,
'extradata' => 'menuaction=admin.uiaclmanager.list_apps'
);
}
}
2003-08-28 16:16:30 +02:00
function edit_group ( $cd = '' , $account_id = '' )
2001-09-02 01:32:40 +02:00
{
2005-10-14 19:03:16 +02:00
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 16 , 'admin' ))
2003-04-27 02:17:58 +02:00
{
2007-03-09 13:07:15 +01:00
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_groups' ));
2003-04-27 02:17:58 +02:00
}
2007-03-09 13:07:15 +01:00
if ( $_POST [ 'edit' ])
2001-09-02 01:32:40 +02:00
{
2007-03-09 13:07:15 +01:00
$group_permissions = ( $_POST [ 'account_apps' ] ? $_POST [ 'account_apps' ] : Array ());
$account_apps = Array ();
foreach ( $group_permissions as $key => $value )
{
if ( $value )
{
$account_apps [ $key ] = True ;
}
}
@ reset ( $account_apps );
2008-04-18 14:38:17 +02:00
2007-03-09 13:07:15 +01:00
$group_info = Array (
'account_id' => ( $_POST [ 'account_id' ] ? ( int ) $_POST [ 'account_id' ] : 0 ),
'account_name' => ( $_POST [ 'account_name' ] ? $_POST [ 'account_name' ] : '' ),
'account_user' => $_POST [ 'account_user' ],
'account_apps' => $account_apps ,
'account_email' => $_POST [ 'account_email' ]
);
$errors = $this -> bo -> edit_group ( $group_info );
if ( is_array ( $errors ))
{
$this -> create_edit_group ( $group_info , $errors );
2013-06-25 18:37:44 +02:00
common :: egw_exit ();
2007-03-09 13:07:15 +01:00
}
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_groups' ));
2003-04-27 02:17:58 +02:00
}
2003-08-28 16:16:30 +02:00
else
2001-09-02 01:32:40 +02:00
{
2007-03-09 13:07:15 +01:00
$cdid = $cd ;
settype ( $cd , 'integer' );
$cd = ( $_GET [ 'cd' ] ? $_GET [ 'cd' ] : ( int ) $cdid );
2001-09-02 01:32:40 +02:00
2007-03-09 13:07:15 +01:00
$accountid = $account_id ;
settype ( $account_id , 'integer' );
$account_id = ( $_GET [ 'account_id' ] ? $_GET [ 'account_id' ] : ( int ) $accountid );
// todo
// not needed if i use the same file for new groups too
if ( ! $account_id )
{
$this -> list_groups ();
}
else
{
$group_info = Array (
'account_id' => ( int ) $_GET [ 'account_id' ],
'account_name' => $GLOBALS [ 'egw' ] -> accounts -> id2name ( $_GET [ 'account_id' ]),
2013-01-25 14:21:31 +01:00
'account_user' => $GLOBALS [ 'egw' ] -> accounts -> members ( $_GET [ 'account_id' ], false , false ),
2007-03-09 13:07:15 +01:00
'account_apps' => $this -> bo -> load_group_apps ( $_GET [ 'account_id' ])
);
$this -> create_edit_group ( $group_info );
}
2001-09-02 01:32:40 +02:00
}
2003-08-28 16:16:30 +02:00
}
2001-09-02 01:32:40 +02:00
2003-08-28 16:16:30 +02:00
function edit_view_user_hook ()
{
2005-10-14 19:03:16 +02:00
if ( ! $GLOBALS [ 'egw' ] -> acl -> check ( 'current_sessions_access' , 1 , 'admin' )) // no rights to view
2001-09-02 01:32:40 +02:00
{
2003-08-28 16:16:30 +02:00
$GLOBALS [ 'menuData' ][] = array (
'description' => 'Login History' ,
'url' => '/index.php' ,
2009-04-27 12:31:23 +02:00
'extradata' => 'menuaction=admin.admin_accesslog.index'
2003-08-28 16:16:30 +02:00
);
2001-09-02 01:32:40 +02:00
}
2003-08-28 16:16:30 +02:00
// not sure if this realy belongs here, or only in edit_user
if ( $_GET [ 'account_id' ] && // can't set it on add
2007-03-09 13:07:15 +01:00
! $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 64 , 'admin' )) // no rights to set ACL-rights
2001-09-02 01:32:40 +02:00
{
2003-08-28 16:16:30 +02:00
$GLOBALS [ 'menuData' ][] = array (
'description' => 'ACL Rights' ,
'url' => '/index.php' ,
'extradata' => 'menuaction=admin.uiaclmanager.list_apps'
2003-04-27 02:17:58 +02:00
);
2003-04-28 01:16:15 +02:00
}
2008-08-07 12:31:54 +02:00
2004-08-26 00:29:28 +02:00
// NDEE210804
// added for different way of handling ldap entries inside account manager
// we show this only, if accounts are stored in ldap
2006-12-15 11:41:33 +01:00
/* just doublicated EMailAdmin functionality
2005-10-14 19:03:16 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'account_repository' ] == " ldap " )
2004-08-26 00:29:28 +02:00
{
$GLOBALS [ 'menuData' ][] = array (
'description' => 'LDAP-MGR' ,
'url' => '/index.php' ,
'extradata' => 'menuaction=admin.uildap_mgr.editUserData'
);
}
2006-06-23 03:28:47 +02:00
*/
2004-08-26 00:29:28 +02:00
//NDEE
2003-08-28 16:16:30 +02:00
}
2003-04-27 02:17:58 +02:00
2013-06-25 18:37:44 +02:00
function edit_user ( $cd = '' , $account_id = '' , $required_account_access = 16 )
2003-08-28 16:16:30 +02:00
{
2013-06-25 18:37:44 +02:00
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , $required_account_access , 'admin' ) || isset ( $_POST [ 'cancel' ]))
2003-04-28 01:16:15 +02:00
{
2003-08-28 16:16:30 +02:00
$this -> list_users ();
return False ;
2001-09-02 01:32:40 +02:00
}
2007-03-09 13:07:15 +01:00
if ( $_POST [ 'submit' ])
2003-04-27 02:17:58 +02:00
{
2007-03-09 13:07:15 +01:00
if ( ! ( $email = $_POST [ 'account_email' ]))
{
2013-06-25 18:37:44 +02:00
$email = common :: email_address ( $_POST [ 'account_firstname' ], $_POST [ 'account_lastname' ], $_POST [ 'account_lid' ]);
2007-03-09 13:07:15 +01:00
}
$userData = array (
2013-06-25 18:37:44 +02:00
'account_type' => 'u' ,
2009-02-16 09:22:22 +01:00
'account_lid' => $_POST [ 'account_lid' ],
2007-03-09 13:07:15 +01:00
'account_firstname' => $_POST [ 'account_firstname' ],
'account_lastname' => $_POST [ 'account_lastname' ],
'account_passwd' => $_POST [ 'account_passwd' ],
'account_status' => ( $_POST [ 'account_status' ] ? 'A' : '' ),
'old_loginid' => ( $_GET [ 'old_loginid' ] ? rawurldecode ( $_GET [ 'old_loginid' ]) : '' ),
'account_id' => ( $_GET [ 'account_id' ] ? $_GET [ 'account_id' ] : 0 ),
'account_passwd_2' => $_POST [ 'account_passwd_2' ],
'account_groups' => $_POST [ 'account_groups' ],
'account_primary_group' => $_POST [ 'account_primary_group' ],
'anonymous' => $_POST [ 'anonymous' ],
'changepassword' => $_POST [ 'changepassword' ],
2010-09-22 11:48:27 +02:00
'mustchangepassword' => $_POST [ 'mustchangepassword' ],
2007-03-09 13:07:15 +01:00
'account_permissions' => $_POST [ 'account_permissions' ],
'homedirectory' => $_POST [ 'homedirectory' ],
'loginshell' => $_POST [ 'loginshell' ],
'account_expires_never' => $_POST [ 'never_expires' ],
'account_email' => $email ,
/* 'file_space' => $_POST['account_file_space_number'] . "-" . $_POST['account_file_space_type'] */
);
2011-03-30 09:54:29 +02:00
if ( $userData [ 'mustchangepassword' ])
2010-09-22 11:48:27 +02:00
{
$userData [ 'account_lastpwd_change' ] = 0 ;
}
else
{
$accountid = $account_id ;
settype ( $account_id , 'integer' );
$account_id = ( int )( $_GET [ 'account_id' ] ? $_GET [ 'account_id' ] : $accountid );
2010-10-25 17:30:01 +02:00
//echo '<br>#'.$account_id.'#<br>';
$prevVal = $GLOBALS [ 'egw' ] -> accounts -> id2name ( $account_id , 'account_lastpwd_change' );
2011-03-30 09:54:29 +02:00
//echo '<br>#'.$prevVal.'#<br>'; // previous Value was forced password change by admin
2010-10-25 17:30:01 +02:00
if ( isset ( $prevVal ) && $prevVal == 0 ) $userData [ 'account_lastpwd_change' ] = egw_time :: to ( 'now' , 'ts' );
2010-09-22 11:48:27 +02:00
}
2007-03-09 13:07:15 +01:00
if ( $userData [ 'account_primary_group' ] && ( ! isset ( $userData [ 'account_groups' ]) || ! in_array ( $userData [ 'account_primary_group' ], $userData [ 'account_groups' ])))
{
$userData [ 'account_groups' ][] = ( int ) $userData [ 'account_primary_group' ];
}
if ( $_POST [ 'expires' ] !== '' && ! $_POST [ 'never_expires' ])
{
2013-06-25 18:37:44 +02:00
$jscal = new jscalendar ( False );
2007-03-09 13:07:15 +01:00
$userData += $jscal -> input2date ( $_POST [ 'expires' ], False , 'account_expires_day' , 'account_expires_month' , 'account_expires_year' );
}
2013-06-25 18:37:44 +02:00
$errors = $this -> bo -> edit_user ( $userData , $required_account_access );
2007-04-26 15:54:21 +02:00
2007-03-09 13:07:15 +01:00
if ( !@ is_array ( $errors ))
{
// check if would create a menu
// if we do, we can't return to the users list, because
// there are also some other plugins
if ( ! ExecMethod ( 'admin.uimenuclass.createHTMLCode' , 'edit_user' ))
{
2007-04-26 15:54:21 +02:00
$GLOBALS [ 'egw' ] -> redirect_link ( '/index.php' , array ( // without redirect changes happen only in the next page-view!
'menuaction' => 'admin.uiaccounts.list_users'
));
2007-03-09 13:07:15 +01:00
}
else
{
if ( $userData [ 'account_id' ] == $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_id' ])
{
$GLOBALS [ 'egw' ] -> redirect_link ( '/index.php' , array ( // without redirect changes happen only in the next page-view!
'menuaction' => 'admin.uiaccounts.edit_user' ,
'account_id' => $_GET [ 'account_id' ]
));
}
2007-04-26 15:54:21 +02:00
$this -> create_edit_user ( $userData [ 'account_id' ]);
2007-03-09 13:07:15 +01:00
}
}
else
{
$this -> create_edit_user ( $userData [ 'account_id' ], $userData , $errors );
}
2003-04-27 02:17:58 +02:00
}
2003-08-28 16:16:30 +02:00
else
2003-04-27 02:17:58 +02:00
{
2007-03-09 13:07:15 +01:00
$cdid = $cd ;
settype ( $cd , 'integer' );
$cd = ( $_GET [ 'cd' ] ? $_GET [ 'cd' ] : ( int ) $cdid );
$accountid = $account_id ;
settype ( $account_id , 'integer' );
$account_id = ( int )( $_GET [ 'account_id' ] ? $_GET [ 'account_id' ] : $accountid );
2013-06-26 12:48:37 +02:00
$this -> create_edit_user ( $account_id );
2003-04-27 02:17:58 +02:00
}
}
function view_user ()
{
2005-10-14 19:03:16 +02:00
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'account_access' , 8 , 'admin' ) || ! $_GET [ 'account_id' ])
2003-04-27 02:17:58 +02:00
{
$this -> list_users ();
return False ;
}
2005-10-14 19:03:16 +02:00
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]);
2013-06-25 18:37:44 +02:00
common :: egw_header ();
2003-04-27 02:17:58 +02:00
2005-10-14 19:03:16 +02:00
$t =& CreateObject ( 'phpgwapi.Template' , EGW_APP_TPL );
2003-04-27 02:17:58 +02:00
$t -> set_unknowns ( 'remove' );
$t -> set_file (
Array (
'account' => 'account_form.tpl'
)
);
$t -> set_block ( 'account' , 'form' , 'form' );
$t -> set_block ( 'account' , 'form_logininfo' );
$t -> set_block ( 'account' , 'link_row' );
$var = Array (
2005-10-14 19:03:16 +02:00
'tr_color1' => $GLOBALS [ 'egw_info' ][ 'theme' ][ 'row_on' ],
'tr_color2' => $GLOBALS [ 'egw_info' ][ 'theme' ][ 'row_off' ],
2003-04-27 02:17:58 +02:00
'lang_action' => lang ( 'View user account' ),
'lang_loginid' => lang ( 'LoginID' ),
'lang_account_active' => lang ( 'Account active' ),
'lang_lastname' => lang ( 'Last Name' ),
'lang_groups' => lang ( 'Groups' ),
2003-08-28 16:16:30 +02:00
'lang_anonymous' => lang ( 'Anonymous user (not shown in list sessions)' ),
'lang_changepassword' => lang ( 'Can change password' ),
2010-09-22 11:48:27 +02:00
'lang_mustchangepassword' => lang ( 'Must change password upon next login' ),
2003-04-27 02:17:58 +02:00
'lang_firstname' => lang ( 'First Name' ),
'lang_lastlogin' => lang ( 'Last login' ),
'lang_lastloginfrom' => lang ( 'Last login from' ),
2010-04-27 19:23:30 +02:00
'lang_expires' => lang ( 'Expires' ),
'lang_app' => lang ( 'application' ),
'lang_acl' => lang ( 'enabled' ),
2003-04-27 02:17:58 +02:00
);
$t -> parse ( 'password_fields' , 'form_logininfo' , True );
2013-04-23 15:47:20 +02:00
// invalidate account, before reading it, to code with changed to DB or LDAP outside EGw
accounts :: cache_invalidate (( int ) $_GET [ 'account_id' ]);
$userData = $GLOBALS [ 'egw' ] -> accounts -> read (( int ) $_GET [ 'account_id' ], 'u' );
2003-04-27 02:17:58 +02:00
$var [ 'account_lid' ] = $userData [ 'account_lid' ];
$var [ 'account_firstname' ] = $userData [ 'firstname' ];
$var [ 'account_lastname' ] = $userData [ 'lastname' ];
2005-10-14 19:03:16 +02:00
$acl =& CreateObject ( 'phpgwapi.acl' ,( int ) $_GET [ 'account_id' ]);
2003-08-28 16:16:30 +02:00
$var [ 'anonymous' ] = $acl -> check ( 'anonymous' , 1 , 'phpgwapi' ) ? ' X' : ' ' ;
2006-06-23 03:28:47 +02:00
$var [ 'changepassword' ] = ! $acl -> check ( 'nopasswordchange' , 1 , 'preferences' ) ? ' X' : ' ' ;
2011-03-16 14:26:32 +01:00
if ( ! isset ( $auth )) $auth =& CreateObject ( 'phpgwapi.auth' );
$accLPWDC = $auth -> getLastPwdChange ( $userData [ 'account_lid' ]);
if ( $accLPWC !== false ) $userData [ 'account_lastpwd_change' ] = $accLPWDC ;
2011-03-16 17:26:02 +01:00
$var [ 'mustchangepassword' ] = ( isset ( $userData [ 'account_lastpwd_change' ]) && (( is_string ( $userData [ 'account_lastpwd_change' ]) && $userData [ 'account_lastpwd_change' ] === " 0 " ) || ( is_int ( $userData [ 'account_lastpwd_change' ]) && $userData [ 'account_lastpwd_change' ] === 0 )) ? ' X' : ' ' );
2003-08-28 16:16:30 +02:00
unset ( $acl );
2013-06-26 12:48:37 +02:00
if ( $userData [ 'account_status' ])
2003-04-27 02:17:58 +02:00
{
$var [ 'account_status' ] = lang ( 'Enabled' );
}
else
{
$var [ 'account_status' ] = '<b>' . lang ( 'Disabled' ) . '</b>' ;
}
2013-06-25 18:37:44 +02:00
if ( isset ( $userData [ 'account_created' ])) $var [ 'account_status' ] .= '<br>' . lang ( 'Created' ) . ': ' . common :: show_date ( $userData [ 'account_created' ]);
if ( isset ( $userData [ 'account_modified' ])) $var [ 'account_status' ] .= '<br>' . lang ( 'Modified' ) . ': ' . common :: show_date ( $userData [ 'account_modified' ]);
2008-04-10 11:08:51 +02:00
2003-04-27 02:17:58 +02:00
// Last login time
if ( $userData [ 'lastlogin' ])
{
2013-06-25 18:37:44 +02:00
$var [ 'account_lastlogin' ] = common :: show_date ( $userData [ 'lastlogin' ]);
2003-04-27 02:17:58 +02:00
}
else
{
$var [ 'account_lastlogin' ] = lang ( 'Never' );
}
// Last login IP
if ( $userData [ 'lastloginfrom' ])
{
$var [ 'account_lastloginfrom' ] = $userData [ 'lastloginfrom' ];
}
else
{
$var [ 'account_lastloginfrom' ] = lang ( 'Never' );
}
// Account expires
if ( $userData [ 'expires' ] != - 1 )
{
2013-06-25 18:37:44 +02:00
$var [ 'input_expires' ] = common :: show_date ( $userData [ 'expires' ]);
2003-04-27 02:17:58 +02:00
}
else
{
$var [ 'input_expires' ] = lang ( 'Never' );
}
// Find out which groups they are members of
2013-04-23 15:47:20 +02:00
$usergroups = $GLOBALS [ 'egw' ] -> accounts -> membership (( int ) $_GET [ 'account_id' ]);
2003-12-20 19:51:51 +01:00
if ( !@ is_array ( $usergroups ))
2003-04-27 02:17:58 +02:00
{
$var [ 'groups_select' ] = lang ( 'None' );
}
else
{
while ( list (, $group ) = each ( $usergroups ))
{
$group_names [] = $group [ 'account_name' ];
}
2003-08-28 16:16:30 +02:00
$var [ 'groups_select' ] = implode ( ', ' , $group_names );
2003-04-27 02:17:58 +02:00
}
$account_lastlogin = $userData [ 'account_lastlogin' ];
$account_lastloginfrom = $userData [ 'account_lastloginfrom' ];
$account_status = $userData [ 'account_status' ];
// create list of available app
$i = 0 ;
2003-12-20 19:51:51 +01:00
2005-10-14 19:03:16 +02:00
$availableApps = $GLOBALS [ 'egw_info' ][ 'apps' ];
2006-12-15 11:41:33 +01:00
foreach ( $availableApps as $app => $data )
2003-04-27 02:17:58 +02:00
{
2010-04-27 19:23:30 +02:00
if ( ! $data [ 'enabled' ] || ! $data [ 'status' ] || $data [ 'status' ] == 3 )
2003-04-27 02:17:58 +02:00
{
2010-04-27 19:23:30 +02:00
unset ( $availableApps [ $app ]); // do NOT show disabled apps, or our API (status = 3)
2003-04-27 02:17:58 +02:00
}
}
2010-04-27 19:23:30 +02:00
uasort ( $availableApps , create_function ( '$a,$b' , 'return strcasecmp($a["title"],$b["title"]);' ));
foreach ( $availableApps as $app => $data )
{
$perm_display [] = array (
'appName' => $app ,
'title' => $data [ 'title' ],
);
}
2003-04-27 02:17:58 +02:00
// create apps output
2005-10-14 19:03:16 +02:00
$apps =& CreateObject ( 'phpgwapi.applications' ,( int ) $_GET [ 'account_id' ]);
2003-04-27 02:17:58 +02:00
$db_perms = $apps -> read_account_specific ();
@ reset ( $db_perms );
2003-08-28 16:16:30 +02:00
for ( $i = 0 ; $i < count ( $perm_display ); $i ++ )
2001-09-02 01:32:40 +02:00
{
2003-08-28 16:16:30 +02:00
if ( $perm_display [ $i ][ 'title' ])
2001-09-02 01:32:40 +02:00
{
2003-08-28 16:16:30 +02:00
$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' : ' ' ));
2001-09-02 01:32:40 +02:00
}
2001-12-21 04:41:06 +01:00
$i ++ ;
2001-09-02 01:32:40 +02:00
2003-08-28 16:16:30 +02:00
if ( $perm_display [ $i ][ 'title' ])
2001-09-02 01:32:40 +02:00
{
2003-08-28 16:16:30 +02:00
$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' : ' ' ));
2001-09-02 01:32:40 +02:00
}
else
{
$part2 = '<td colspan="2"> </td>' ;
}
2001-12-21 04:41:06 +01:00
2010-04-27 19:23:30 +02:00
$appRightsOutput .= sprintf ( " <tr class= \" %s \" > $part1 $part2 </tr> \n " , $this -> nextmatchs -> alternate_row_color ( '' , true ));
2001-09-02 01:32:40 +02:00
}
2003-04-27 02:17:58 +02:00
$var [ 'permissions_list' ] = $appRightsOutput ;
2001-09-02 01:32:40 +02:00
2001-12-21 04:41:06 +01:00
// create the menu on the left, if needed
2005-10-14 19:03:16 +02:00
// $menuClass =& CreateObject('admin.uimenuclass');
2001-12-27 16:14:02 +01:00
// This is now using ExecMethod()
2003-04-27 02:17:58 +02:00
$var [ 'rows' ] = ExecMethod ( 'admin.uimenuclass.createHTMLCode' , 'view_user' );
$t -> set_var ( $var );
$t -> pfp ( 'out' , 'form' );
}
2003-08-28 16:16:30 +02:00
function group_manager ( $cd = '' , $account_id = '' )
2003-04-27 02:17:58 +02:00
{
2005-10-14 19:03:16 +02:00
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 16 , 'admin' ))
2003-04-27 02:17:58 +02:00
{
2003-08-28 16:16:30 +02:00
$this -> list_groups ();
return False ;
2003-04-27 02:17:58 +02:00
}
2003-08-28 16:16:30 +02:00
$cdid = $cd ;
settype ( $cd , 'integer' );
2003-12-20 19:51:51 +01:00
$cd = ( $_GET [ 'cd' ] ? $_GET [ 'cd' ] : ( int ) $cdid );
2003-08-28 16:16:30 +02:00
$accountid = $account_id ;
settype ( $account_id , 'integer' );
2003-12-20 19:51:51 +01:00
$account_id = ( int )( $_GET [ 'account_id' ] ? $_GET [ 'account_id' ] : $accountid );
2006-12-15 11:41:33 +01:00
2003-08-28 16:16:30 +02:00
// todo
// not needed if i use the same file for new groups too
if ( ! $account_id )
2003-04-27 02:17:58 +02:00
{
2003-08-28 16:16:30 +02:00
$this -> list_groups ();
2003-04-27 02:17:58 +02:00
}
2003-08-28 16:16:30 +02:00
else
{
$group_info = Array (
2003-12-20 19:51:51 +01:00
'account_id' => ( int ) $_GET [ 'account_id' ],
2005-10-14 19:03:16 +02:00
'account_name' => $GLOBALS [ 'egw' ] -> accounts -> id2name ( $_GET [ 'account_id' ]),
'account_user' => $GLOBALS [ 'egw' ] -> accounts -> member ( $_GET [ 'account_id' ]),
2003-08-28 16:16:30 +02:00
'account_managers' => $this -> bo -> load_group_managers ( $_GET [ 'account_id' ])
);
2003-04-27 02:17:58 +02:00
2003-08-28 16:16:30 +02:00
$this -> edit_group_managers ( $group_info );
}
}
function create_edit_group ( $group_info , $_errors = '' )
{
2005-10-14 19:03:16 +02:00
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]);
2013-06-25 18:37:44 +02:00
common :: egw_header ();
2003-08-28 16:16:30 +02:00
2005-10-14 19:03:16 +02:00
$p =& CreateObject ( 'phpgwapi.Template' , EGW_APP_TPL );
2003-08-28 16:16:30 +02:00
$p -> set_file ( Array ( 'edit' => 'group_form.tpl' ));
$p -> set_block ( 'edit' , 'select' );
$p -> set_block ( 'edit' , 'popwin' );
2013-04-23 15:47:20 +02:00
// invalidate account, before reading it, to code with changed to DB or LDAP outside EGw
accounts :: cache_invalidate (( int ) $_GET [ 'account_id' ]);
$group_repository = $GLOBALS [ 'egw' ] -> accounts -> read (( int ) $_GET [ 'account_id' ], 'u' );
2003-08-28 16:16:30 +02:00
2005-12-02 15:06:25 +01:00
$p -> set_var ( 'accounts' , $GLOBALS [ 'egw' ] -> uiaccountsel -> selection ( 'account_user[]' , 'admin_uiaccounts_user' , $group_info [ 'account_user' ], 'accounts' , min ( 3 + count ( $group_info [ 'account_user' ]), 10 ), false , 'style="width: 300px;"' ));
2003-08-28 16:16:30 +02:00
$var = Array (
2007-03-09 13:07:15 +01:00
'form_action' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.' . ( $group_info [ 'account_id' ] ? 'edit' : 'add' ) . '_group' ),
2003-08-28 16:16:30 +02:00
'hidden_vars' => '<input type="hidden" name="account_id" value="' . $group_info [ 'account_id' ] . '">' ,
'lang_group_name' => lang ( 'group name' ),
'group_name_value' => $group_info [ 'account_name' ],
'lang_include_user' => lang ( 'Select users for inclusion' ),
2013-06-25 18:37:44 +02:00
'error' => ( ! $_errors ? '' : '<center>' . common :: error_list ( $_errors ) . '</center>' ),
2003-08-28 16:16:30 +02:00
'lang_permissions' => lang ( 'Permissions this group has' )
);
$p -> set_var ( $var );
if ( ! $group_repository [ 'file_space' ])
{
2005-10-14 19:03:16 +02:00
$group_repository [ 'file_space' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'vfs_default_account_size_number' ] . " - " . $GLOBALS [ 'egw_info' ][ 'server' ][ 'vfs_default_account_size_type' ];
2003-08-28 16:16:30 +02:00
}
/*
$file_space_array = explode ( '-' , $group_repository [ 'file_space' ]);
$account_file_space_types = array ( 'gb' , 'mb' , 'kb' , 'b' );
while ( list ( $num , $type ) = each ( $account_file_space_types ))
{
$account_file_space_select .= '<option value="' . $type . '"' . ( $type == $file_space_array [ 1 ] ? ' selected' : '' ) . '>' . strtoupper ( $type ) . '</option>' . " \n " ;
}
$p -> set_var ( 'lang_file_space' , lang ( 'File space' ));
$p -> set_var ( 'account_file_space' , '<input type=text name="account_file_space_number" value="' . trim ( $file_space_array [ 0 ]) . '" size="7">' );
$p -> set_var ( 'account_file_space_select' , '<select name="account_file_space_type">' . " \n " . $account_file_space_select . '</select>' . " \n " );
*/
2012-11-16 11:36:34 +01:00
// if EGroupware manages a mail server, allow setting an email address for groups
if ( $group_repository [ 'mailAllowed' ] && $GLOBALS [ 'egw_info' ][ 'apps' ][ 'emailadmin' ] &&
$GLOBALS [ 'egw_info' ][ 'apps' ][ 'felamimail' ])
2006-10-11 23:58:58 +02:00
{
2012-11-19 14:53:15 +01:00
if (( $default_profile_id = emailadmin_bo :: getDefaultProfileID ()))
2012-11-16 11:36:34 +01:00
{
2012-11-19 14:53:15 +01:00
$bofelamimail = felamimail_bo :: forceEAProfileLoad ( $default_profile_id );
2012-11-16 11:36:34 +01:00
$ogServer = $bofelamimail -> mailPreferences -> getOutgoingServer ( $default_profile_id );
//error_log(__METHOD__."() default_profile_id = $default_profile_id, get_class(ogServer)=".get_class($ogServer));
if ( ! in_array ( get_class ( $ogServer ), array ( 'defaultsmtp' , 'emailadmin_smtp' )))
{
$p -> set_var ( array (
'lang_email' => lang ( 'Email' ),
'email' => html :: input ( 'account_email' , $group_repository [ 'account_email' ], '' , ' style="width: 100%;"' ),
));
}
2012-11-19 16:56:57 +01:00
emailadmin_bo :: unsetCachedObjects ( $default_profile_id );
2012-11-16 11:36:34 +01:00
}
2006-10-11 23:58:58 +02:00
}
2010-04-27 19:23:30 +02:00
$availableApps = $GLOBALS [ 'egw_info' ][ 'apps' ];
foreach ( $availableApps as $app => $data )
2003-08-28 16:16:30 +02:00
{
2011-03-30 09:54:29 +02:00
if ( ! $data [ 'enabled' ] || ! $data [ 'status' ] || $data [ 'status' ] == 3 || $app == 'home' )
2003-04-27 02:17:58 +02:00
{
2010-04-27 19:23:30 +02:00
unset ( $availableApps [ $app ]); // do NOT show disabled apps, or our API (status = 3)
2003-04-27 02:17:58 +02:00
}
2003-08-28 16:16:30 +02:00
}
2010-04-27 19:23:30 +02:00
uasort ( $availableApps , create_function ( '$a,$b' , 'return strcasecmp($a["title"],$b["title"]);' ));
foreach ( $availableApps as $app => $data )
{
$perm_display [] = Array (
$app ,
$data [ 'title' ]
);
}
unset ( $app ); unset ( $data );
2003-04-27 02:17:58 +02:00
2004-08-28 15:48:32 +02:00
$perm_html = '<td width="35%">' . lang ( 'Application' ) . '</td><td width="15%">' . lang ( 'enabled' ) . ' / ' . lang ( 'ACL' ) . '</td>' ;
$perm_html = '<tr class="th">' .
2003-08-28 16:16:30 +02:00
$perm_html . $perm_html . " </tr> \n " ;
2006-12-15 11:41:33 +01:00
2005-10-14 19:03:16 +02:00
$tr_color = $GLOBALS [ 'egw_info' ][ 'theme' ][ 'row_off' ];
2003-08-28 16:16:30 +02:00
for ( $i = 0 ; $i < count ( $perm_display ); $i ++ )
{
$app = $perm_display [ $i ][ 0 ];
if ( ! ( $i & 1 ))
{
2005-07-06 04:26:44 +02:00
$tr_class = $this -> nextmatchs -> alternate_row_color ( '' , True );
$perm_html .= '<tr class="' . $tr_class . '">' ;
2003-08-28 16:16:30 +02:00
}
2008-04-18 14:38:17 +02:00
$acl_action = self :: _acl_action ( $app , $group_info [ 'account_id' ], $group_info [ 'account_name' ], $options );
2004-08-28 15:48:32 +02:00
$perm_html .= '<td>' . $perm_display [ $i ][ 1 ] . '</td>'
. '<td><input type="checkbox" name="account_apps['
. $perm_display [ $i ][ 0 ] . ']" value="True"' . ( $group_info [ 'account_apps' ][ $app ] ? ' checked' : '' ) . '> '
2008-04-18 14:38:17 +02:00
. ( $acl_action ? '<a href="' . $acl_action . '"' . $options
2013-06-25 18:37:44 +02:00
. '><img src="' . common :: image ( 'phpgwapi' , 'edit' ) . '" border="0" hspace="3" align="absmiddle" title="'
2004-03-23 14:45:23 +01:00
. lang ( 'Grant Access' ) . ': ' . lang ( " edit group ACL's " ) . '"></a>' : ' ' ) . '</td>' . ( $i & 1 ? '</tr>' : '' ) . " \n " ;
2003-08-28 16:16:30 +02:00
}
if ( $i & 1 )
{
$perm_html .= '<td colspan="4"> </td></tr>' ;
2003-04-27 02:17:58 +02:00
}
2003-08-28 16:16:30 +02:00
$var = Array (
'permissions_list' => $perm_html ,
'lang_submit_button' => lang ( 'submit changes' )
);
$p -> set_var ( $var );
// create the menu on the left, if needed
$p -> set_var ( 'rows' , ExecMethod ( 'admin.uimenuclass.createHTMLCode' , 'group_manager' ));
$p -> set_var ( 'select' , '' );
$p -> set_var ( 'popwin' , '' );
$p -> pfp ( 'out' , 'edit' );
2003-04-27 02:17:58 +02:00
}
2008-04-18 14:38:17 +02:00
private function _acl_action ( $app , $account_id , $account_lid , & $options )
{
$options = '' ;
if ( ! ( $acl_action = $this -> apps_with_acl [ $app ]) || ! $account_id )
{
return false ;
}
if ( $acl_action === true )
{
$acl_action = array (
'menuaction' => 'preferences.uiaclprefs.index' ,
'acl_app' => '$app' ,
'owner' => '$account_id' ,
);
}
$replacements = array (
'$app' => $app ,
'$account_id' => $account_id ,
'$account_lid' => $account_lid ,
);
foreach ( $acl_action as $name => & $value )
{
$value = str_replace ( array_keys ( $replacements ), array_values ( $replacements ), $value );
}
if ( $acl_action [ 'popup' ])
{
list ( $w , $h ) = explode ( 'x' , $acl_action [ 'popup' ]);
$options = ' onclick="window.open(this,this.target,\'width=' . ( int ) $w . ',height=' . ( int ) $h . ',location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;"' ;
unset ( $acl_action [ 'popup' ]);
}
return $GLOBALS [ 'egw' ] -> link ( '/index.php' , $acl_action );
}
2003-08-28 16:16:30 +02:00
function create_edit_user ( $_account_id , $_userData = '' , $_errors = '' )
2003-04-27 02:17:58 +02:00
{
2010-09-22 11:48:27 +02:00
//_debug_array($_userData);
2006-04-16 14:31:00 +02:00
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'include_xajax' ] = true ;
2006-12-15 11:41:33 +01:00
2005-10-14 19:03:16 +02:00
$jscal =& CreateObject ( 'phpgwapi.jscalendar' );
2003-08-28 16:16:30 +02:00
2005-10-14 19:03:16 +02:00
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]);
2006-12-15 11:41:33 +01:00
2013-06-25 18:37:44 +02:00
common :: egw_header ();
2003-04-27 02:17:58 +02:00
2005-10-14 19:03:16 +02:00
$t =& CreateObject ( 'phpgwapi.Template' , EGW_APP_TPL );
2003-08-28 16:16:30 +02:00
$t -> set_unknowns ( 'remove' );
2013-06-25 18:37:44 +02:00
$t -> set_file ( array ( 'account' => 'account_form.tpl' ));
$t -> set_block ( 'account' , 'ldap_extra' );
if ( ! $GLOBALS [ 'egw_info' ][ 'server' ][ 'ldap_extra_attributes' ] || $GLOBALS [ 'egw_info' ][ 'server' ][ 'account_repository' ] != 'ldap' )
2003-08-28 16:16:30 +02:00
{
2013-06-25 18:37:44 +02:00
$t -> set_var ( 'ldap_extra' , '' );
2003-08-28 16:16:30 +02:00
}
$t -> set_block ( 'account' , 'form' , 'form' );
$t -> set_block ( 'account' , 'form_passwordinfo' , 'form_passwordinfo' );
$t -> set_block ( 'account' , 'form_buttons_' , 'form_buttons_' );
$t -> set_block ( 'account' , 'link_row' , 'link_row' );
2006-12-15 11:41:33 +01:00
$theme = $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ];
2005-10-14 19:03:16 +02:00
$t -> set_var ( 'icon_create_edit' , '<img src="' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . '/admin/templates/' . $theme . '/images/useradm.gif">' );
2006-12-15 11:41:33 +01:00
2006-04-30 14:18:47 +02:00
//print_debug('Type : '.gettype($_userData).'<br>_userData(size) = "'.$_userData.'"('.strlen($_userData).')');
2003-08-28 16:16:30 +02:00
if ( is_array ( $_userData ))
{
$userData = Array ();
$userData = $_userData ;
@ reset ( $userData [ 'account_groups' ]);
while ( list ( $key , $value ) = @ each ( $userData [ 'account_groups' ]))
{
$userGroups [ $key ][ 'account_id' ] = $value ;
}
2013-06-25 18:37:44 +02:00
$allGroups = $GLOBALS [ 'egw' ] -> accounts -> get_list ( 'groups' );
2003-08-28 16:16:30 +02:00
}
elseif ( is_string ( $_userData ) && $_userData == '' )
{
if ( $_account_id )
{
2013-04-24 15:05:37 +02:00
// invalidate account, before reading it, to cope with changes to DB or LDAP outside EGw
accounts :: cache_invalidate (( int ) $_account_id );
$userData = $GLOBALS [ 'egw' ] -> accounts -> read (( int ) $_account_id , 'u' );
$userGroups = $GLOBALS [ 'egw' ] -> accounts -> membership ( $_account_id );
2005-10-14 19:03:16 +02:00
$acl =& CreateObject ( 'phpgwapi.acl' , $_account_id );
2003-08-28 16:16:30 +02:00
$acl -> read_repository ();
$userData [ 'anonymous' ] = $acl -> check ( 'anonymous' , 1 , 'phpgwapi' );
2006-06-23 03:28:47 +02:00
$userData [ 'changepassword' ] = ! $acl -> check ( 'nopasswordchange' , 1 , 'preferences' );
2011-03-16 14:26:32 +01:00
if ( ! isset ( $auth )) $auth =& CreateObject ( 'phpgwapi.auth' );
$accLPWDC = $auth -> getLastPwdChange ( $userData [ 'account_lid' ]);
if ( $accLPWC !== false ) $userData [ 'account_lastpwd_change' ] = $accLPWDC ;
2011-03-16 17:26:02 +01:00
$userData [ 'mustchangepassword' ] = ( isset ( $userData [ 'account_lastpwd_change' ]) && (( is_string ( $userData [ 'account_lastpwd_change' ]) && $userData [ 'account_lastpwd_change' ] === " 0 " ) || ( is_int ( $userData [ 'account_lastpwd_change' ]) && $userData [ 'account_lastpwd_change' ] === 0 )) ? true : false );
2003-08-28 16:16:30 +02:00
unset ( $acl );
}
else
{
$userData = Array ();
2013-06-26 12:48:37 +02:00
$userData [ 'account_status' ] = 'A' ;
2003-08-28 16:16:30 +02:00
$userGroups = Array ();
$userData [ 'anonymous' ] = False ;
2011-10-06 17:46:43 +02:00
$userData [ 'changepassword' ] = ( bool ) $GLOBALS [ 'egw_info' ][ 'server' ][ 'change_pwd_every_x_days' ];
2010-09-22 11:48:27 +02:00
$userData [ 'mustchangepassword' ] = false ;
2003-08-28 16:16:30 +02:00
}
2013-04-24 15:05:37 +02:00
$allGroups = $GLOBALS [ 'egw' ] -> accounts -> get_list ( 'groups' );
2003-08-28 16:16:30 +02:00
}
2007-03-09 13:07:15 +01:00
$page_params [ 'menuaction' ] = 'admin.uiaccounts.' . ( $_account_id ? 'edit' : 'add' ) . '_user' ;
2003-08-28 16:16:30 +02:00
if ( $_account_id )
{
$page_params [ 'account_id' ] = $_account_id ;
$page_params [ 'old_loginid' ] = rawurlencode ( $userData [ 'account_lid' ]);
}
2003-04-27 02:17:58 +02:00
$var = Array (
2005-10-14 19:03:16 +02:00
'form_action' => $GLOBALS [ 'egw' ] -> link ( '/index.php' , $page_params ),
2013-06-25 18:37:44 +02:00
'error_messages' => ( ! $_errors ? '' : '<div style="color: red; font-style: italics">' . common :: error_list ( $_errors ) . '</div>' ),
2005-10-14 19:03:16 +02:00
'th_bg' => $GLOBALS [ 'egw_info' ][ 'theme' ][ 'th_bg' ],
'tr_color1' => $GLOBALS [ 'egw_info' ][ 'theme' ][ 'row_on' ],
'tr_color2' => $GLOBALS [ 'egw_info' ][ 'theme' ][ 'row_off' ],
2005-01-28 21:12:28 +01:00
'lang_action' => ( $_account_id ? lang ( 'Edit user account' ) : lang ( 'Add new account' )),
'lang_loginid' => lang ( 'LoginID' ),
'lang_account_active' => lang ( 'Account active' ),
'lang_email' => lang ( 'email' ),
'lang_password' => lang ( 'Password' ),
2003-08-28 16:16:30 +02:00
'lang_reenter_password' => lang ( 'Re-Enter Password' ),
2005-01-28 21:12:28 +01:00
'lang_lastname' => lang ( 'Last Name' ),
'lang_groups' => lang ( 'Groups' ),
2003-09-13 16:09:41 +02:00
'lang_primary_group' => lang ( 'primary Group' ),
2005-01-28 21:12:28 +01:00
'lang_expires' => lang ( 'Expires' ),
'lang_firstname' => lang ( 'First Name' ),
'lang_anonymous' => lang ( 'Anonymous User (not shown in list sessions)' ),
'lang_changepassword' => lang ( 'Can change password' ),
2010-09-22 11:48:27 +02:00
'lang_mustchangepassword' => lang ( 'Must change password upon next login' ),
2006-04-16 14:31:00 +02:00
'lang_button' => ( $_account_id ? lang ( 'Save' ) : lang ( 'Add' )),
'lang_passwds_unequal' => lang ( 'The two passwords are not the same' ),
2013-06-25 18:37:44 +02:00
'lang_cancel' => lang ( 'Cancel' ),
'cancel_action' => " document.location=' " . egw :: link ( '/index.php' , array ( 'menuaction' => 'admin.uiaccounts.list_users' )) . " '; " ,
2005-01-28 21:12:28 +01:00
/* 'lang_file_space' => lang('File Space') */
2003-04-27 02:17:58 +02:00
);
2003-08-28 16:16:30 +02:00
$t -> set_var ( $var );
$t -> parse ( 'form_buttons' , 'form_buttons_' , True );
2003-04-27 02:17:58 +02:00
2007-03-09 13:07:15 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'ldap_extra_attributes' ])
{
2003-08-28 16:16:30 +02:00
$lang_homedir = lang ( 'home directory' );
$lang_shell = lang ( 'login shell' );
2009-12-09 09:23:04 +01:00
$homedirectory = '<input name="homedirectory" id="homedirectory" value="' . ( $_account_id ? $userData [ 'homedirectory' ] : $GLOBALS [ 'egw_info' ][ 'server' ][ 'ldap_account_home' ] . $account_lid ) . '">' ;
2003-08-28 16:16:30 +02:00
$loginshell = '<input name="loginshell" value="'
2005-10-14 19:03:16 +02:00
. ( $_account_id ? $userData [ 'loginshell' ] : $GLOBALS [ 'egw_info' ][ 'server' ][ 'ldap_account_shell' ])
2003-08-28 16:16:30 +02:00
. '">' ;
}
else
{
$lang_homedir = '' ;
$lang_shell = '' ;
$homedirectory = '' ;
$loginshell = '' ;
}
$account_file_space = '' ;
/*
if ( ! $userData [ 'file_space' ])
{
2005-10-14 19:03:16 +02:00
$userData [ 'file_space' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'vfs_default_account_size_number' ] . " - " . $GLOBALS [ 'egw_info' ][ 'server' ][ 'vfs_default_account_size_type' ];
2003-08-28 16:16:30 +02:00
}
$file_space_array = explode ( '-' , $userData [ 'file_space' ]);
$account_file_space_number = $file_space_array [ 0 ];
$account_file_space_type = $file_space_array [ 1 ];
$account_file_space_type_selected [ $account_file_space_type ] = ' selected' ;
2003-04-27 02:17:58 +02:00
2003-08-28 16:16:30 +02:00
$account_file_space = '<input type=text name="account_file_space_number" value="' . trim ( $account_file_space_number ) . '" size="7">' ;
$account_file_space_select = '<select name="account_file_space_type">' ;
$account_file_space_types = array ( 'gb' , 'mb' , 'kb' , 'b' );
while ( list ( $num , $type ) = each ( $account_file_space_types ))
2003-04-27 02:17:58 +02:00
{
2003-08-28 16:16:30 +02:00
$account_file_space_select .= '<option value="' . $type . '"' . $account_file_space_type_selected [ $type ] . '>' . strtoupper ( $type ) . '</option>' ;
2003-04-27 02:17:58 +02:00
}
2003-08-28 16:16:30 +02:00
$account_file_space_select .= '</select>' ;
$var = Array (
'lang_file_space' => 'File space' ,
'account_file_space' => $account_file_space ,
'account_file_space_select' => $account_file_space_select
);
2003-04-27 02:17:58 +02:00
$t -> set_var ( $var );
2003-08-28 16:16:30 +02:00
*/
2004-01-12 07:22:20 +01:00
$accountPrefix = '' ;
2005-10-14 19:03:16 +02:00
if ( isset ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'account_prefix' ]))
2004-01-12 07:22:20 +01:00
{
2005-10-14 19:03:16 +02:00
$accountPrefix = $GLOBALS [ 'egw_info' ][ 'server' ][ 'account_prefix' ];
2004-01-12 07:22:20 +01:00
if ( preg_match ( " /^ $accountPrefix (.*)/i " , $userData [ 'account_lid' ], $matches ))
{
$userData [ 'account_lid' ] = $matches [ 1 ];
}
}
2003-08-28 16:16:30 +02:00
$var = Array (
2005-01-28 21:12:28 +01:00
'input_expires' => $jscal -> input ( 'expires' , $userData [ 'expires' ] < 0 ? '' : ( $userData [ 'expires' ] ? $userData [ 'expires' ] : time () + ( 60 * 60 * 24 * 7 ))),
'lang_never' => lang ( 'Never' ),
2006-04-30 14:18:47 +02:00
'account_lid' => $accountPrefix . '<input id="account" onchange="check_account_email(this.id);" name="account_lid" maxlength="64" value="' . $userData [ 'account_lid' ] . '">' ,
2005-01-28 21:12:28 +01:00
'lang_homedir' => $lang_homedir ,
'lang_shell' => $lang_shell ,
'homedirectory' => $homedirectory ,
'loginshell' => $loginshell ,
'anonymous' => '<input type="checkbox" name="anonymous" value="1"' . ( $userData [ 'anonymous' ] ? ' checked' : '' ) . '>' ,
'changepassword' => '<input type="checkbox" name="changepassword" value="1"' . ( $userData [ 'changepassword' ] ? ' checked' : '' ) . '>' ,
2010-09-22 11:48:27 +02:00
'mustchangepassword' => '<input type="checkbox" name="mustchangepassword" value="1"' . ( $userData [ 'mustchangepassword' ] ? ' checked' : '' ) . '>' ,
2013-06-26 12:48:37 +02:00
'account_status' => '<input type="checkbox" name="account_status" value="A"' . ( $userData [ 'account_status' ] ? ' checked' : '' ) . '>' ,
2013-06-25 18:37:44 +02:00
'account_firstname' => '<input id="firstname" onchange="check_account_email(this.id);" name="account_firstname" maxlength="50" value="' . $userData [ 'account_firstname' ] . '">' ,
'account_lastname' => '<input id="lastname" onchange="check_account_email(this.id);" name="account_lastname" maxlength="50" value="' . $userData [ 'account_lastname' ] . '">' ,
'account_email' => '<input id="email" onchange="email_set=0; check_account_email(this.id);" name="account_email" size="32" maxlength="100" value="' . $userData [ 'account_email' ] . '">' ,
2004-07-12 21:54:44 +02:00
'account_passwd' => $userData [ 'account_passwd' ],
'account_passwd_2' => $userData [ 'account_passwd_2' ],
2006-04-16 14:31:00 +02:00
'account_file_space' => $account_file_space ,
2007-03-09 13:07:15 +01:00
'account_id' => ( int ) $userData [ 'account_id' ]
2003-08-28 16:16:30 +02:00
);
2013-06-25 18:37:44 +02:00
if ( isset ( $userData [ 'account_created' ])) $var [ 'account_status' ] .= '<br>' . lang ( 'Created' ) . ': ' . common :: show_date ( $userData [ 'account_created' ]);
if ( isset ( $userData [ 'account_modified' ])) $var [ 'account_status' ] .= '<br>' . lang ( 'Modified' ) . ': ' . common :: show_date ( $userData [ 'account_modified' ]);
2008-04-10 12:21:51 +02:00
2003-04-27 02:17:58 +02:00
2003-08-28 16:16:30 +02:00
if ( $userData [ 'expires' ] == - 1 )
2003-04-27 02:17:58 +02:00
{
2003-08-28 16:16:30 +02:00
$var [ 'never_expires' ] = '<input type="checkbox" name="never_expires" value="True" checked>' ;
}
else
{
$var [ 'never_expires' ] = '<input type="checkbox" name="never_expires" value="True">' ;
2003-04-27 02:17:58 +02:00
}
2003-08-28 16:16:30 +02:00
$t -> set_var ( $var );
$t -> parse ( 'password_fields' , 'form_passwordinfo' , True );
2003-04-27 02:17:58 +02:00
2006-12-19 14:24:09 +01:00
// set primary group to default, if there is no primary group set; this may fail, if no group "Default" exists
if ( ! $userData [ 'account_primary_group' ])
{
2013-05-21 20:03:44 +02:00
$userData [ 'account_primary_group' ] = @ $userGroups [ 0 ][ 'account_id' ] ?
@ $userGroups [ 0 ][ 'account_id' ] : $GLOBALS [ 'egw' ] -> accounts -> name2id ( 'Default' );
2006-12-19 14:24:09 +01:00
}
2006-12-15 11:41:33 +01:00
// prepare the allGroups array for use with the checkbox-multiselect use
$allGroupsBuff = array ();
while ( list ( $key , $value ) = each ( $allGroups ))
{
2006-12-19 14:24:09 +01:00
$allGroupsBuff [ strtolower ( $value [ 'account_lid' ])] = $value ;
2006-12-15 11:41:33 +01:00
}
// sort alphabetical
ksort ( $allGroupsBuff );
$allGroupsSorted = array ();
while ( list ( $key , $value ) = each ( $allGroupsBuff ))
{
2006-12-19 14:24:09 +01:00
$allGroupsSorted [ $value [ 'account_id' ]] = $value [ 'account_lid' ];
$primary_group_select .= '<option value="' . $value [ 'account_id' ] . '"' ;
if ( $value [ 'account_id' ] == $userData [ 'account_primary_group' ])
{
$primary_group_select .= ' selected="1"' ;
}
$primary_group_select .= '>' . $value [ 'account_lid' ] . '</option>' . " \n " ;
2006-12-15 11:41:33 +01:00
}
//prepare the userGroups Array for use with the checkbox-multiselect use -> selarray
$selarray = array ();
while ( list ( $key , $value ) = each ( $userGroups ))
{
array_push ( $selarray , $value [ 'account_id' ]);
}
2008-03-25 17:37:37 +01:00
$t -> set_var ( 'groups_select' , '<div id="groupselector">' . html :: checkbox_multiselect ( 'account_groups[]' , $selarray , $allGroupsSorted , true , '' , min ( 3 + count ( $allGroupsSorted ), 10 ), ' style="width: 300px; text-align:left" ' ) . '</div>' );
2003-09-13 16:09:41 +02:00
2003-08-28 16:16:30 +02:00
/* create list of available apps */
2005-10-14 19:03:16 +02:00
$apps =& CreateObject ( 'phpgwapi.applications' , $_account_id );
2003-08-28 16:16:30 +02:00
$db_perms = $apps -> read_account_specific ();
2005-10-14 19:03:16 +02:00
$availableApps = $GLOBALS [ 'egw_info' ][ 'apps' ];
2010-04-27 19:23:30 +02:00
foreach ( $availableApps as $app => $data )
{
2011-03-30 09:54:29 +02:00
if ( ! $data [ 'enabled' ] || ! $data [ 'status' ] || $data [ 'status' ] == 3 || $app == 'home' )
2010-04-27 19:23:30 +02:00
{
unset ( $availableApps [ $app ]); // do NOT show disabled apps, or our API (status = 3)
}
}
2003-10-06 01:16:03 +02:00
uasort ( $availableApps , create_function ( '$a,$b' , 'return strcasecmp($a["title"],$b["title"]);' ));
2003-04-27 02:17:58 +02:00
2003-08-28 16:16:30 +02:00
$appRightsOutput = '' ;
2003-10-06 01:16:03 +02:00
$i = 0 ;
foreach ( $availableApps as $app => $data )
2003-08-28 16:16:30 +02:00
{
2004-08-28 15:48:32 +02:00
$checked = ( @ $userData [ 'account_permissions' ][ $app ] || @ $db_perms [ $app ]) && $_account_id ? ' checked="1"' : '' ;
2008-04-18 14:38:17 +02:00
$acl_action = self :: _acl_action ( $app , $_account_id , $userData [ 'account_lid' ], $options );
2004-08-28 15:48:32 +02:00
$part [ $i & 1 ] = sprintf ( '<td>%s</td><td><input type="checkbox" name="account_permissions[%s]" value="True"%s>' ,
2006-12-15 11:41:33 +01:00
$data [ 'title' ], $app , $checked ) .
2008-04-18 14:38:17 +02:00
( $acl_action ? '<a href="' . $acl_action . '"' . $options
2013-06-25 18:37:44 +02:00
. '><img src="' . common :: image ( 'phpgwapi' , 'edit' ) . '" border="0" hspace="3" align="absmiddle" title="'
2004-08-28 15:48:32 +02:00
. lang ( 'Grant Access' ) . '"></a>' : ' ' ) . '</td>' ;
2003-08-28 16:16:30 +02:00
if ( $i & 1 )
{
2010-04-27 19:23:30 +02:00
$appRightsOutput .= sprintf ( '<tr class="%s">%s%s</tr>' , $this -> nextmatchs -> alternate_row_color ( '' , true ), $part [ 0 ], $part [ 1 ]);
2003-08-28 16:16:30 +02:00
}
2003-10-06 01:16:03 +02:00
++ $i ;
}
if ( $i & 1 )
{
2004-08-28 15:48:32 +02:00
$part [ 1 ] = '<td colspan="3"> </td>' ;
2010-04-27 19:23:30 +02:00
$appRightsOutput .= sprintf ( '<tr class="%s">%s%s</tr>' , $this -> nextmatchs -> alternate_row_color ( '' , true ), $part [ 0 ], $part [ 1 ]);
2003-04-27 02:17:58 +02:00
}
2003-08-28 16:16:30 +02:00
2005-01-03 11:41:07 +01:00
$var = Array (
2006-12-15 11:41:33 +01:00
// KL 20061211 groups_select is already set
//'groups_select'
//=> '<div id="groupselector">' .
//"\n".$groups_select. '</div>' . "\n",
2005-01-03 11:41:07 +01:00
'primary_group_select'
2006-12-15 11:41:33 +01:00
=> ' < select
name = " account_primary_group " > '."\n".$primary_group_select.' </
2005-01-03 11:41:07 +01:00
select > ' . " \n " ,
2007-03-09 13:07:15 +01:00
'permissions_list' => $appRightsOutput ,
2005-01-03 11:41:07 +01:00
'lang_app' => lang ( 'application' ),
'lang_acl' => lang ( 'enabled' ) . ' / ' . lang ( 'ACL' ),
);
/*
2003-08-28 16:16:30 +02:00
$var = Array (
2003-12-20 19:51:51 +01:00
'groups_select'
2003-09-13 16:09:41 +02:00
=> '<select name="account_groups[]" multiple>' . " \n " . $groups_select . '</select>' . " \n " ,
2006-12-15 11:41:33 +01:00
'primary_group_select'
2003-09-13 16:09:41 +02:00
=> '<select name="account_primary_group">' . " \n " . $primary_group_select . '</select>' . " \n " ,
2006-12-15 11:41:33 +01:00
'permissions_list'
2004-08-28 15:48:32 +02:00
=> $appRightsOutput ,
'lang_app' => lang ( 'application' ),
'lang_acl' => lang ( 'enabled' ) . ' / ' . lang ( 'ACL' ),
2003-08-28 16:16:30 +02:00
);
2005-01-03 11:41:07 +01:00
2005-01-03 16:05:56 +01:00
*/
2003-08-28 16:16:30 +02:00
$t -> set_var ( $var );
// create the menu on the left, if needed
2005-10-14 19:03:16 +02:00
// $menuClass =& CreateObject('admin.uimenuclass');
2003-08-28 16:16:30 +02:00
// This is now using ExecMethod()
$GLOBALS [ 'account_id' ] = $_account_id ;
2013-06-26 21:55:20 +02:00
$t -> set_var ( 'rows' , $_account_id ? ExecMethod2 ( 'admin.uimenuclass.createHTMLCode' , 'edit_user' , $_account_id ) : '' );
2003-08-28 16:16:30 +02:00
echo $t -> fp ( 'out' , 'form' );
2001-09-02 01:32:40 +02:00
}
2002-01-10 19:18:44 +01:00
2006-04-16 14:31:00 +02:00
function ajax_check_account_email ( $first , $last , $account_lid , $account_id , $email , $id )
{
2009-06-08 18:21:14 +02:00
$response = new xajaxResponse ();
2006-04-16 14:31:00 +02:00
if ( ! $email )
{
2013-06-25 18:37:44 +02:00
$response -> addAssign ( 'email' , 'value' , common :: email_address ( $first , $last , $account_lid ));
2006-04-16 14:31:00 +02:00
}
$id_account_lid = ( int ) $GLOBALS [ 'egw' ] -> accounts -> name2id ( $account_lid );
if ( $id == 'account' && $id_account_lid && $id_account_lid != ( int ) $account_id )
{
$response -> addScript ( " alert(' " . addslashes ( lang ( 'That loginid has already been taken' ) . ': ' . $account_lid ) . " '); document.getElementById('account').value=' " .
( $account_id ? $GLOBALS [ 'egw' ] -> accounts -> id2name ( $account_id ) : '' ) . " '; document.getElementById('account').focus(); " );
}
2009-12-09 09:23:04 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'ldap_extra_attributes' ] &&
( $home = $GLOBALS [ 'egw_info' ][ 'server' ][ 'ldap_account_home' ]) && $home != '/dev/null' )
{
$response -> addAssign ( 'homedirectory' , 'value' , $home . '/' . $account_lid );
}
2006-04-16 14:31:00 +02:00
return $response -> getXML ();
}
2006-12-15 11:41:33 +01:00
2002-01-10 19:18:44 +01:00
function edit_group_managers ( $group_info , $_errors = '' )
{
2005-10-14 19:03:16 +02:00
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 16 , 'admin' ))
2002-01-10 19:18:44 +01:00
{
$this -> list_groups ();
return False ;
}
2005-10-14 19:03:16 +02:00
$accounts =& CreateObject ( 'phpgwapi.accounts' , $group_info [ 'account_id' ], 'u' );
2002-01-10 19:18:44 +01:00
$account_list = $accounts -> member ( $group_info [ 'account_id' ]);
$user_list = '' ;
while ( list ( $key , $entry ) = each ( $account_list ))
{
$user_list .= '<option value="' . $entry [ 'account_id' ] . '"'
2003-12-20 19:51:51 +01:00
. $group_info [ 'account_managers' ][( int ) $entry [ 'account_id' ]] . '>'
2013-06-25 18:37:44 +02:00
. common :: grab_owner_name ( $entry [ 'account_id' ])
2002-01-10 19:18:44 +01:00
. '</option>' . " \n " ;
}
2005-10-14 19:03:16 +02:00
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'noheader' ]);
unset ( $GLOBALS [ 'egw_info' ][ 'flags' ][ 'nonavbar' ]);
2013-06-25 18:37:44 +02:00
common :: egw_header ();
2002-01-10 19:18:44 +01:00
2005-10-14 19:03:16 +02:00
$t =& CreateObject ( 'phpgwapi.Template' , EGW_APP_TPL );
2002-01-10 19:18:44 +01:00
$t -> set_unknowns ( 'remove' );
$t -> set_file (
Array (
2003-12-20 19:51:51 +01:00
'manager' => 'group_manager.tpl'
2002-01-10 19:18:44 +01:00
)
);
$t -> set_block ( 'manager' , 'form' , 'form' );
$t -> set_block ( 'manager' , 'link_row' , 'link_row' );
2005-10-14 19:03:16 +02:00
$var [ 'th_bg' ] = $GLOBALS [ 'egw_info' ][ 'user' ][ 'theme' ][ 'th_bg' ];
2002-01-10 19:18:44 +01:00
$var [ 'lang_group' ] = lang ( 'Group' );
$var [ 'group_name' ] = $group_info [ 'account_name' ];
2005-10-14 19:03:16 +02:00
$var [ 'tr_color1' ] = $GLOBALS [ 'egw_info' ][ 'user' ][ 'theme' ][ 'row_on' ];
2007-03-09 13:07:15 +01:00
$var [ 'form_action' ] = $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.set_group_managers' );
2002-01-10 19:18:44 +01:00
$var [ 'hidden' ] = '<input type="hidden" name="account_id" value="' . $group_info [ 'account_id' ] . '">' ;
$var [ 'lang_select_managers' ] = lang ( 'Select Group Managers' );
$var [ 'group_members' ] = '<select name="managers[]" size="' . ( count ( $account_list ) < 5 ? count ( $account_list ) : 5 ) . '" multiple>' . $user_list . '</select>' ;
$var [ 'form_buttons' ] = '<tr align="center"><td colspan="2"><input type="submit" name="submit" value="' . lang ( 'Submit' ) . '"> '
. '<input type="submit" name="cancel" value="' . lang ( 'Cancel' ) . '"><td></tr>' ;
$t -> set_var ( $var );
// create the menu on the left, if needed
$t -> set_var ( 'rows' , ExecMethod ( 'admin.uimenuclass.createHTMLCode' , 'edit_group' ));
$t -> pfp ( 'out' , 'form' );
}
2007-03-09 13:07:15 +01:00
function set_group_managers ()
{
if ( $GLOBALS [ 'egw' ] -> acl -> check ( 'group_access' , 16 , 'admin' ) || $_POST [ 'cancel' ])
{
2008-03-25 17:37:37 +01:00
$GLOBALS [ 'egw' ] -> redirect_link ( '/index.php' , 'menuaction=admin.uiaccounts.list_groups' );
2013-06-25 18:37:44 +02:00
common :: egw_exit ();
2007-03-09 13:07:15 +01:00
}
elseif ( $_POST [ 'submit' ])
{
$acl =& CreateObject ( 'phpgwapi.acl' ,( int ) $_POST [ 'account_id' ]);
$users = $GLOBALS [ 'egw' ] -> accounts -> member ( $_POST [ 'account_id' ]);
@ reset ( $users );
while ( $managers && list ( $key , $user ) = each ( $users ))
{
$acl -> add_repository ( 'phpgw_group' ,( int ) $_POST [ 'account_id' ], $user [ 'account_id' ], 1 );
}
$managers = $_POST [ 'managers' ];
@ reset ( $managers );
while ( $managers && list ( $key , $manager ) = each ( $managers ))
{
$acl -> add_repository ( 'phpgw_group' ,( int ) $_POST [ 'account_id' ], $manager ,( 1 + EGW_ACL_GROUP_MANAGERS ));
}
}
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw' ] -> link ( '/index.php' , 'menuaction=admin.uiaccounts.list_groups' ));
2013-06-25 18:37:44 +02:00
common :: egw_exit ();
2007-03-09 13:07:15 +01:00
}
/**
* applies stripslashes recursively on each element of an array
*
* @ param array & $var
* @ return array
*/
function array_stripslashes ( $var )
{
if ( ! is_array ( $var ))
{
return stripslashes ( $var );
}
foreach ( $var as $key => $val )
{
$var [ $key ] = is_array ( $val ) ? $this -> array_stripslashes ( $val ) : stripslashes ( $val );
}
return $var ;
}
2001-09-02 01:32:40 +02:00
}
2007-03-09 13:07:15 +01:00
?>