Updated to have all posts and gets go to the ui class. Bo class functions now take direct arguments and respond with true, false, or array of errors (for now).

This commit is contained in:
Miles Lott 2007-03-09 12:07:15 +00:00
parent c973715bc4
commit d274143269
3 changed files with 494 additions and 493 deletions

View File

@ -20,8 +20,7 @@
'delete_group' => True, 'delete_group' => True,
'delete_user' => True, 'delete_user' => True,
'edit_group' => True, 'edit_group' => True,
'edit_user' => True, 'edit_user' => True
'set_group_managers' => True
); );
var $xml_functions = array(); var $xml_functions = array();
@ -36,83 +35,21 @@
function boaccounts() function boaccounts()
{ {
$this->so =& CreateObject('admin.soaccounts'); $this->so =& CreateObject('admin.soaccounts');
if (get_magic_quotes_gpc()) // deal with magic_quotes_gpc On
{
$_POST = $this->array_stripslashes($_POST);
}
} }
/** function delete_group($account_id='')
* applies stripslashes recursivly on each element of an array
*
* @param array &$var
* @return array
*/
function array_stripslashes($var)
{ {
if (!is_array($var)) if(!$account_id || $GLOBALS['egw']->acl->check('group_access',32,'admin'))
{ {
return stripslashes($var);
}
foreach($var as $key => $val)
{
$var[$key] = is_array($val) ? $this->array_stripslashes($val) : stripslashes($val);
}
return $var;
}
function DONTlist_methods($_type='xmlrpc')
{
/*
This handles introspection or discovery by the logged in client,
in which case the input might be an array. The server always calls
this function to fill the server dispatch map using a string.
*/
if (is_array($_type))
{
$_type = $_type['type'] ? $_type['type'] : $_type[0];
}
switch($_type)
{
case 'xmlrpc':
$xml_functions = array(
'rpc_add_user' => array(
'function' => 'rpc_add_user',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Add a new account.')
),
'list_methods' => array(
'function' => 'list_methods',
'signature' => array(array(xmlrpcStruct,xmlrpcString)),
'docstring' => lang('Read this list of methods.')
)
);
return $xml_functions;
break;
case 'soap':
return $this->soap_functions;
break;
default:
return array();
break;
}
}
function delete_group()
{
if (!@isset($_POST['account_id']) || !@$_POST['account_id'] || $GLOBALS['egw']->acl->check('group_access',32,'admin'))
{
ExecMethod('admin.uiaccounts.list_groups');
return False; return False;
} }
$account_id = (int)$_POST['account_id']; $account_id = (int)$account_id;
// delete all acl (and memberships) of group // delete all acl (and memberships) of group
$GLOBALS['egw']->acl->delete_account($account_id); $GLOBALS['egw']->acl->delete_account($account_id);
if (! @rmdir($GLOBALS['egw_info']['server']['files_dir'].SEP.'groups'.SEP.$GLOBALS['egw']->accounts->id2name($account_id))) if(!@rmdir($GLOBALS['egw_info']['server']['files_dir'].SEP.'groups'.SEP.$GLOBALS['egw']->accounts->id2name($account_id)))
{ {
$cd = 38; $cd = 38;
} }
@ -123,81 +60,59 @@
$GLOBALS['egw']->accounts->delete($account_id); $GLOBALS['egw']->accounts->delete($account_id);
Header('Location: '.$GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups')); return True;
$GLOBALS['egw']->common->egw_exit();
} }
function delete_user() function delete_user($account_id='',$new_owner='')
{ {
if (isset($_POST['cancel']) || $GLOBALS['egw']->acl->check('account_access',32,'admin')) if(!$account_id || $GLOBALS['egw']->acl->check('account_access',32,'admin'))
{ {
ExecMethod('admin.uiaccounts.list_users');
return False;
}
elseif($_POST['delete_account'])
{
$accountid = $_POST['account_id'];
settype($account_id,'integer');
$account_id = get_account_id($accountid);
// make this information also in hook available
$lid = $GLOBALS['egw']->accounts->id2name($account_id);
$GLOBALS['hook_values'] = array(
'account_id' => $account_id,
'account_lid' => $lid,
'new_owner' => (int)$_POST['new_owner'],
'location' => 'deleteaccount',
);
// first all other apps, then preferences and admin
foreach(array_merge(array_diff(array_keys($GLOBALS['egw_info']['apps']),array('preferences','admin')),array('preferences','admin')) as $app)
{
$GLOBALS['egw']->hooks->single($GLOBALS['hook_values'],$app);
}
$basedir = $GLOBALS['egw_info']['server']['files_dir'] . SEP . 'users' . SEP;
if (! @rmdir($basedir . $lid))
{
$cd = 34;
}
else
{
$cd = 29;
}
ExecMethod('admin.uiaccounts.list_users');
return False;
}
}
function add_group()
{
if ($GLOBALS['egw']->acl->check('group_access',4,'admin'))
{
ExecMethod('admin.uiaccounts.list_groups');
return False; return False;
} }
$group_permissions = ($_POST['account_apps']?$_POST['account_apps']:Array()); $accountid = (int)$account_id;
$account_apps = Array(); $account_id = get_account_id($accountid);
@reset($group_permissions); // make this information also available in the hook
while(list($key,$value) = each($group_permissions)) $lid = $GLOBALS['egw']->accounts->id2name($account_id);
{
if($value)
{
$account_apps[$key] = True;
}
}
@reset($account_apps);
$group_info = Array( $GLOBALS['hook_values'] = array(
'account_id' => ($_POST['account_id']?(int)$_POST['account_id']:0), 'account_id' => $account_id,
'account_name' => ($_POST['account_name']?$_POST['account_name']:''), 'account_lid' => $lid,
'account_user' => $_POST['account_user'], 'new_owner' => (int)$new_owner,
'account_apps' => $account_apps 'location' => 'deleteaccount'
); );
// first all other apps, then preferences and admin
foreach(array_merge(array_diff(array_keys($GLOBALS['egw_info']['apps']),array('preferences','admin')),array('preferences','admin')) as $app)
{
$GLOBALS['egw']->hooks->single($GLOBALS['hook_values'],$app);
}
$this->validate_group($group_info); $basedir = $GLOBALS['egw_info']['server']['files_dir'] . SEP . 'users' . SEP;
if(!@rmdir($basedir . $lid))
{
$cd = 34;
}
else
{
$cd = 29;
}
return True;
}
function add_group($group_info)
{
if($GLOBALS['egw']->acl->check('group_access',4,'admin'))
{
return False;
}
$errors = $this->validate_group($group_info);
if(count($errors))
{
return $errors;
}
$group =& CreateObject('phpgwapi.accounts',$group_info['account_id'],'g'); $group =& CreateObject('phpgwapi.accounts',$group_info['account_id'],'g');
$group->acct_type = 'g'; $group->acct_type = 'g';
@ -210,11 +125,13 @@
'account_status' => 'A', 'account_status' => 'A',
'account_expires' => -1, 'account_expires' => -1,
// 'account_file_space' => $account_file_space_number . "-" . $account_file_space_type, // 'account_file_space' => $account_file_space_number . "-" . $account_file_space_type,
'account_email' => $_POST['account_email'], 'account_email' => $group_info['account_email'],
'account_members' => $group_info['account_user']
); );
$group_info['account_id'] = $group->create($account_info); $group_info['account_id'] = $group->create($account_info);
// do the following only if we got an id - the create succided
if ($group_info['account_id']) // do the following only if we got an id - the create succeeded
if($group_info['account_id'])
{ {
$group->set_members($group_info['account_user'],$group_info['account_id']); $group->set_members($group_info['account_user'],$group_info['account_id']);
@ -231,21 +148,20 @@
$basedir = $GLOBALS['egw_info']['server']['files_dir'] . SEP . 'groups' . SEP; $basedir = $GLOBALS['egw_info']['server']['files_dir'] . SEP . 'groups' . SEP;
$cd = 31; $cd = 31;
umask(000); umask(000);
if (! @mkdir ($basedir . $group_info['account_name'], 0707)) if(!@mkdir($basedir . $group_info['account_name'], 0707))
{ {
$cd = 37; $cd = 37;
} }
return True;
} }
ExecMethod('admin.uiaccounts.list_groups');
return False; return False;
} }
function add_user() function add_user($userData)
{ {
if ($GLOBALS['egw']->acl->check('account_access',4,'admin')) if($GLOBALS['egw']->acl->check('account_access',4,'admin'))
{ {
ExecMethod('admin.uiaccounts.list_users');
return False; return False;
} }
@ -254,117 +170,63 @@
{ {
$accountPrefix = $GLOBALS['egw_info']['server']['account_prefix']; $accountPrefix = $GLOBALS['egw_info']['server']['account_prefix'];
} }
if($accountPrefix)
if ($_POST['submit'])
{ {
if (!($email = $_POST['account_email'])) $userData['account_lid'] = $accountPrefix . $userData['account_lid'];
{ }
$email = $GLOBALS['egw']->common->email_address($_POST['account_firstname'],$_POST['account_lastname'],$_POST['account_lid']);
}
$userData = array(
'account_type' => 'u',
'account_lid' => $accountPrefix.$_POST['account_lid'],
'account_firstname' => $_POST['account_firstname'],
'account_lastname' => $_POST['account_lastname'],
'account_passwd' => $_POST['account_passwd'],
'status' => ($_POST['account_status'] ? 'A' : ''),
'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_primary_group' => $_POST['account_primary_group'],
'account_passwd_2' => $_POST['account_passwd_2'],
'account_groups' => $_POST['account_groups'],
'anonymous' => $_POST['anonymous'],
'changepassword' => $_POST['changepassword'],
'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'] */
);
// add the primary group, to the users other groups, if not already added // add the primary group, to the users other groups, if not already added
if(is_array($userData['account_groups'])) if(is_array($userData['account_groups']))
{
if(!in_array($userData['account_primary_group'],$userData['account_groups']))
{ {
if(!in_array($userData['account_primary_group'],$userData['account_groups'])) $userData['account_groups'][] = (int)$userData['account_primary_group'];
{
$userData['account_groups'][] = (int)$userData['account_primary_group'];
}
}
else
{
$userData['account_groups'] = array((int)$userData['account_primary_group']);
}
// when does the account expire
if ($_POST['expires'] !== '' && !$_POST['never_expires'])
{
$jscal =& CreateObject('phpgwapi.jscalendar',False);
$userData += $jscal->input2date($_POST['expires'],False,'account_expires_day','account_expires_month','account_expires_year');
}
// do we have all needed data??
if (!($errors = $this->validate_user($userData)) &&
($userData['account_id'] = $account_id = $this->so->add_user($userData))) // no error in the creation
{
if ($userData['anonymous'])
{
$GLOBALS['egw']->acl->add_repository('phpgwapi','anonymous',$account_id,1);
}
else
{
$GLOBALS['egw']->acl->delete_repository('phpgwapi','anonymous',$account_id);
}
// make this information for the hooks available
$GLOBALS['hook_values'] = $userData + array('new_passwd' => $userData['account_passwd']);
$GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array(
'location' => 'addaccount'
),False,True); // called for every app now, not only enabled ones
ExecMethod('admin.uiaccounts.list_users');
return False;
}
else
{
$ui =& CreateObject('admin.uiaccounts');
$ui->create_edit_user($userData['account_id'],$userData,$errors);
} }
} }
else else
{ {
ExecMethod('admin.uiaccounts.list_users'); $userData['account_groups'] = array((int)$userData['account_primary_group']);
return False;
} }
// do we have all needed data??
if(!($errors = $this->validate_user($userData)) &&
($userData['account_id'] = $account_id = $this->so->add_user($userData))) // no error in the creation
{
if($userData['anonymous'])
{
$GLOBALS['egw']->acl->add_repository('phpgwapi','anonymous',$account_id,1);
}
else
{
$GLOBALS['egw']->acl->delete_repository('phpgwapi','anonymous',$account_id);
}
// make this information for the hooks available
$GLOBALS['hook_values'] = $userData + array('new_passwd' => $userData['account_passwd']);
$GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array(
'location' => 'addaccount'
),False,True); // called for every app now, not only enabled ones
return True;
}
else
{
return $errors;
}
return False;
} }
function edit_group() function edit_group($group_info)
{ {
if ($GLOBALS['egw']->acl->check('group_access',16,'admin')) if($GLOBALS['egw']->acl->check('group_access',16,'admin'))
{ {
ExecMethod('admin.uiaccounts.list_groups');
return False; return False;
} }
$group_permissions = ($_POST['account_apps']?$_POST['account_apps']:Array()); $errors = $this->validate_group($group_info);
$account_apps = Array(); if(count($errors))
@reset($group_permissions);
while(list($key,$value) = each($group_permissions))
{ {
if($value) return $errors;
{
$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,
);
$this->validate_group($group_info);
$group =& CreateObject('phpgwapi.accounts',$group_info['account_id'],'g'); $group =& CreateObject('phpgwapi.accounts',$group_info['account_id'],'g');
$old_group_info = $group->read_repository(); $old_group_info = $group->read_repository();
@ -395,7 +257,7 @@
$group->data['firstname'] = $group_info['account_name']; $group->data['firstname'] = $group_info['account_name'];
$basedir = $GLOBALS['egw_info']['server']['files_dir'] . SEP . 'groups' . SEP; $basedir = $GLOBALS['egw_info']['server']['files_dir'] . SEP . 'groups' . SEP;
if (! @rename($basedir . $old_group_info['account_lid'], $basedir . $group_info['account_name'])) if(!@rename($basedir . $old_group_info['account_lid'], $basedir . $group_info['account_name']))
{ {
$cd = 39; $cd = 39;
} }
@ -413,7 +275,7 @@
// This is down here so we are sure to catch the acl changes // This is down here so we are sure to catch the acl changes
// for LDAP to update the memberuid attribute // for LDAP to update the memberuid attribute
$group->data['account_email'] = $_POST['account_email']; $group->data['account_email'] = $group_info['account_email'];
$group->save_repository(); $group->save_repository();
$GLOBALS['hook_values'] = $group_info; $GLOBALS['hook_values'] = $group_info;
@ -421,15 +283,13 @@
'location' => 'editgroup' 'location' => 'editgroup'
),False,True); // called for every app now, not only enabled ones) ),False,True); // called for every app now, not only enabled ones)
ExecMethod('admin.uiaccounts.list_groups'); return True;
return False;
} }
function edit_user() function edit_user($userData)
{ {
if ($GLOBALS['egw']->acl->check('account_access',16,'admin')) if($GLOBALS['egw']->acl->check('account_access',16,'admin'))
{ {
ExecMethod('admin.uiaccounts.list_users');
return False; return False;
} }
@ -439,110 +299,22 @@
$accountPrefix = $GLOBALS['egw_info']['server']['account_prefix']; $accountPrefix = $GLOBALS['egw_info']['server']['account_prefix'];
} }
if ($_POST['submit']) $errors = $this->validate_user($userData);
if(@is_array($errors))
{ {
if (!($email = $_POST['account_email'])) return $errors;
{
$email = $GLOBALS['egw']->common->email_address($_POST['account_firstname'],$_POST['account_lastname'],$_POST['account_lid']);
}
$userData = array(
'account_lid' => $accountPrefix.$_POST['account_lid'],
'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'],
'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'] */
);
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'])
{
$jscal =& CreateObject('phpgwapi.jscalendar',False);
$userData += $jscal->input2date($_POST['expires'],False,'account_expires_day','account_expires_month','account_expires_year');
}
if (!($errors = $this->validate_user($userData)))
{
$this->save_user($userData);
$GLOBALS['hook_values'] = $userData;
$GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array(
'location' => 'editaccount'
),False,True); // called for every app now, not only enabled ones)
// 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'))
{
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.list_users',
));
}
ExecMethod('admin.uiaccounts.list_users');
return False;
}
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'],
));
}
ExecMethod('admin.uiaccounts.edit_user',$_GET['account_id']);
return False;
}
}
else
{
$ui =& CreateObject('admin.uiaccounts');
$ui->create_edit_user($userData['account_id'],$userData,$errors);
}
} }
} else
function set_group_managers()
{
if($GLOBALS['egw']->acl->check('group_access',16,'admin') || $_POST['cancel'])
{ {
$GLOBALS['egw']->redirect($GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups')); $this->save_user($userData);
$GLOBALS['egw']->common->egw_exit(); $GLOBALS['hook_values'] = $userData;
} $GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array(
elseif($_POST['submit']) 'location' => 'editaccount'
{ ),False,True); // called for every app now, not only enabled ones)
$acl =& CreateObject('phpgwapi.acl',(int)$_POST['account_id']);
$users = $GLOBALS['egw']->accounts->member($_POST['account_id']); return True;
@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')); return True;
$GLOBALS['egw']->common->egw_exit();
} }
function validate_group($group_info) function validate_group($group_info)
@ -556,26 +328,29 @@
{ {
$errors[] = lang('You must enter a group name.'); $errors[] = lang('You must enter a group name.');
} }
/* For LDAP */
if(!$group_info['account_user'])
{
$errors[] = lang('You must select at least one group member.');
}
if($group_info['account_name'] != $group->id2name($group_info['account_id'])) if($group_info['account_name'] != $group->id2name($group_info['account_id']))
{ {
if ($group->exists($group_info['account_name'])) if($group->exists($group_info['account_name']))
{ {
$errors[] = lang('Sorry, that group name has already been taken.'); $errors[] = lang('Sorry, that group name has already been taken.');
} }
} }
/* /*
if (preg_match ("/\D/", $account_file_space_number)) if(preg_match("/\D/", $account_file_space_number))
{ {
$errors[] = lang ('File space must be an integer'); $errors[] = lang('File space must be an integer');
} }
*/ */
if(count($errors)) if(count($errors))
{ {
$ui =& CreateObject('admin.uiaccounts'); return $errors;
$ui->create_edit_group($group_info,$errors);
$GLOBALS['egw']->common->egw_exit();
} }
} }
@ -587,14 +362,14 @@
{ {
$totalerrors = 0; $totalerrors = 0;
if ($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' && if($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' &&
(!$_userData['account_lastname'] && !$_userData['lastname'])) (!$_userData['account_lastname'] && !$_userData['lastname']))
{ {
$error[$totalerrors] = lang('You must enter a lastname'); $error[$totalerrors] = lang('You must enter a lastname');
$totalerrors++; $totalerrors++;
} }
if (!$_userData['account_lid']) if(!$_userData['account_lid'])
{ {
$error[$totalerrors] = lang('You must enter a loginid'); $error[$totalerrors] = lang('You must enter a loginid');
$totalerrors++; $totalerrors++;
@ -606,11 +381,11 @@
$totalerrors++; $totalerrors++;
} }
if ($_userData['old_loginid'] != $_userData['account_lid']) if($_userData['old_loginid'] != $_userData['account_lid'])
{ {
if ($GLOBALS['egw']->accounts->exists($_userData['account_lid'])) if($GLOBALS['egw']->accounts->exists($_userData['account_lid']))
{ {
if ($GLOBALS['egw']->accounts->exists($_userData['account_lid']) && $GLOBALS['egw']->accounts->get_type($_userData['account_lid'])=='g') if($GLOBALS['egw']->accounts->exists($_userData['account_lid']) && $GLOBALS['egw']->accounts->get_type($_userData['account_lid'])=='g')
{ {
$error[$totalerrors] = lang('There already is a group with this name. Userid\'s can not have the same name as a groupid'); $error[$totalerrors] = lang('There already is a group with this name. Userid\'s can not have the same name as a groupid');
} }
@ -622,22 +397,22 @@
} }
} }
if ($_userData['account_passwd'] || $_userData['account_passwd_2']) if($_userData['account_passwd'] || $_userData['account_passwd_2'])
{ {
if ($_userData['account_passwd'] != $_userData['account_passwd_2']) if($_userData['account_passwd'] != $_userData['account_passwd_2'])
{ {
$error[$totalerrors] = lang('The two passwords are not the same'); $error[$totalerrors] = lang('The two passwords are not the same');
$totalerrors++; $totalerrors++;
} }
} }
if (!count($_userData['account_permissions']) && !count($_userData['account_groups'])) if(!count($_userData['account_permissions']) && !count($_userData['account_groups']))
{ {
$error[$totalerrors] = lang('You must add at least 1 permission or group to this account'); $error[$totalerrors] = lang('You must add at least 1 permission or group to this account');
$totalerrors++; $totalerrors++;
} }
if ($_userData['account_expires_month'] || $_userData['account_expires_day'] || $_userData['account_expires_year'] || $_userData['account_expires_never']) if($_userData['account_expires_month'] || $_userData['account_expires_day'] || $_userData['account_expires_year'] || $_userData['account_expires_never'])
{ {
if($_userData['account_expires_never']) if($_userData['account_expires_never'])
{ {
@ -646,7 +421,7 @@
} }
else else
{ {
if (! checkdate($_userData['account_expires_month'],$_userData['account_expires_day'],$_userData['account_expires_year'])) if(! checkdate($_userData['account_expires_month'],$_userData['account_expires_day'],$_userData['account_expires_year']))
{ {
$error[$totalerrors] = lang('You have entered an invalid expiration date'); $error[$totalerrors] = lang('You have entered an invalid expiration date');
$totalerrors++; $totalerrors++;
@ -665,17 +440,17 @@
} }
/* /*
$check_account_file_space = explode ('-', $_userData['file_space']); $check_account_file_space = explode('-', $_userData['file_space']);
if (preg_match ("/\D/", $check_account_file_space[0])) if(preg_match("/\D/", $check_account_file_space[0]))
{ {
$error[$totalerrors] = lang ('File space must be an integer'); $error[$totalerrors] = lang('File space must be an integer');
$totalerrors++; $totalerrors++;
} }
*/ */
if ($totalerrors == 0) if($totalerrors == 0)
{ {
return FALSE; return False;
} }
else else
{ {
@ -692,7 +467,7 @@
$account->set_memberships($_userData['account_groups'],$_userData['account_id']); $account->set_memberships($_userData['account_groups'],$_userData['account_id']);
if ($_userData['account_passwd']) if($_userData['account_passwd'])
{ {
$auth =& CreateObject('phpgwapi.auth'); $auth =& CreateObject('phpgwapi.auth');
$auth->change_password($old_passwd, $_userData['account_passwd'], $_userData['account_id']); $auth->change_password($old_passwd, $_userData['account_passwd'], $_userData['account_id']);
@ -706,7 +481,7 @@
} }
$apps =& CreateObject('phpgwapi.applications',(int)$_userData['account_id']); $apps =& CreateObject('phpgwapi.applications',(int)$_userData['account_id']);
if ($_userData['account_permissions']) if($_userData['account_permissions'])
{ {
foreach($_userData['account_permissions'] as $app => $enabled) foreach($_userData['account_permissions'] as $app => $enabled)
{ {
@ -719,7 +494,7 @@
$apps->save_repository(); $apps->save_repository();
$acl =& CreateObject('phpgwapi.acl',$_userData['account_id']); $acl =& CreateObject('phpgwapi.acl',$_userData['account_id']);
if ($_userData['anonymous']) if($_userData['anonymous'])
{ {
$acl->add_repository('phpgwapi','anonymous',$_userData['account_id'],1); $acl->add_repository('phpgwapi','anonymous',$_userData['account_id'],1);
} }
@ -727,7 +502,7 @@
{ {
$acl->delete_repository('phpgwapi','anonymous',$_userData['account_id']); $acl->delete_repository('phpgwapi','anonymous',$_userData['account_id']);
} }
if (!$_userData['changepassword']) if(!$_userData['changepassword'])
{ {
$GLOBALS['egw']->acl->add_repository('preferences','nopasswordchange',$_userData['account_id'],1); $GLOBALS['egw']->acl->add_repository('preferences','nopasswordchange',$_userData['account_id'],1);
} }
@ -750,7 +525,7 @@
$group_user = $temp_user; $group_user = $temp_user;
} }
$account_user = Array(); $account_user = Array();
while (list($key,$user) = each($group_user)) while(list($key,$user) = each($group_user))
{ {
$account_user[$user] = ' selected'; $account_user[$user] = ' selected';
} }
@ -777,7 +552,7 @@
{ {
exit; exit;
if (!$errors = $this->validate_user($data)) if(!$errors = $this->validate_user($data))
{ {
$result = $this->so->add_user($data); $result = $this->so->add_user($data);
} }

View File

@ -1,13 +1,13 @@
<?php <?php
/**************************************************************************\ /***************************************************************************\
* eGroupWare - account administration * * eGroupWare - account administration *
* http://www.egroupware.org * * http://www.egroupware.org *
* -------------------------------------------- * * -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it * * 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 * * 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 * * Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. * * option) any later version. *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
@ -19,7 +19,7 @@
function add_user($userData) function add_user($userData)
{ {
$userData['account_expires'] = $userData['expires']; $userData['account_expires'] = $userData['expires'];
if($userData['email'] != "") if($userData['email'] != "")
{ {
@ -34,27 +34,27 @@
$apps =& CreateObject('phpgwapi.applications',$userData['account_id']); $apps =& CreateObject('phpgwapi.applications',$userData['account_id']);
$apps->read_installed_apps(); $apps->read_installed_apps();
/* dont think this is still used -- RalfBecker 2006-06-03 /* dont think this is still used -- RalfBecker 2006-06-03
// Read Group Apps // Read Group Apps
if ($userData['account_groups']) if ($userData['account_groups'])
{ {
$apps->account_type = 'g'; $apps->account_type = 'g';
reset($userData['account_groups']); reset($userData['account_groups']);
while($groups = each($userData['account_groups'])) while($groups = each($userData['account_groups']))
{ {
$apps->account_id = $groups[0]; $apps->account_id = $groups[0];
$old_app_groups = $apps->read_account_specific(); $old_app_groups = $apps->read_account_specific();
@reset($old_app_groups); @reset($old_app_groups);
while($old_group_app = each($old_app_groups)) while($old_group_app = each($old_app_groups))
{ {
if (!$apps_after[$old_group_app[0]]) if (!$apps_after[$old_group_app[0]])
{ {
$apps_after[$old_group_app[0]] = $old_app_groups[$old_group_app[0]]; $apps_after[$old_group_app[0]] = $old_app_groups[$old_group_app[0]];
} }
} }
} }
} }
*/ */
$apps->account_type = 'u'; $apps->account_type = 'u';
$apps->account_id = $userData['account_id']; $apps->account_id = $userData['account_id'];
$apps->data = Array(Array()); $apps->data = Array(Array());
@ -67,12 +67,12 @@
if ($turned_on) if ($turned_on)
{ {
$apps->add($app); $apps->add($app);
/* dont think this is still used -- RalfBecker 2006-06-03 /* dont think this is still used -- RalfBecker 2006-06-03
if (!$apps_after[$app]) if (!$apps_after[$app])
{ {
$apps_after[] = $app; $apps_after[] = $app;
} }
*/ */
} }
} }
} }
@ -84,7 +84,7 @@
} }
$apps->account_apps = array(array()); $apps->account_apps = array(array());
// $apps_after = array(array()); // $apps_after = array(array());
return $userData['account_id']; return $userData['account_id'];
} }

View File

@ -13,8 +13,7 @@
class uiaccounts class uiaccounts
{ {
//(regis) maybe some of them should be deleted? //(regis) maybe some of them should be deleted?
var $public_functions = array var $public_functions = array(
(
'list_groups' => True, 'list_groups' => True,
'list_users' => True, 'list_users' => True,
'add_group' => True, 'add_group' => True,
@ -27,7 +26,7 @@
'view_user' => True, 'view_user' => True,
'edit_group_hook' => True, 'edit_group_hook' => True,
'edit_view_user_hook' => True, 'edit_view_user_hook' => True,
'group_manager' => True, 'group_manager' => True
); );
var $bo; var $bo;
@ -48,7 +47,7 @@
'inv' => True, 'inv' => True,
'phpbrain' => True, 'phpbrain' => True,
'projectmanager' => True, 'projectmanager' => True,
'timesheet' => true, 'timesheet' => True
); );
function uiaccounts() function uiaccounts()
@ -56,6 +55,11 @@
$this->bo =& CreateObject('admin.boaccounts'); $this->bo =& CreateObject('admin.boaccounts');
$this->nextmatchs =& CreateObject('phpgwapi.nextmatchs'); $this->nextmatchs =& CreateObject('phpgwapi.nextmatchs');
@set_time_limit(300); @set_time_limit(300);
/* Moved from bo class */
if (get_magic_quotes_gpc()) // deal with magic_quotes_gpc On
{
$_POST = $this->array_stripslashes($_POST);
}
} }
function row_action($action,$type,$account_id) function row_action($action,$type,$account_id)
@ -72,7 +76,7 @@
'all' => 'all fields', 'all' => 'all fields',
'lid' => 'LoginID', 'lid' => 'LoginID',
'start' => 'start with', 'start' => 'start with',
'exact' => 'exact', 'exact' => 'exact'
); );
if ($GLOBALS['egw']->acl->check('group_access',1,'admin')) if ($GLOBALS['egw']->acl->check('group_access',1,'admin'))
@ -145,7 +149,7 @@
'start' => $start, 'start' => $start,
'sort' => $sort, 'sort' => $sort,
'order' => $order, 'order' => $order,
'query_type' => $_REQUEST['query_type'], 'query_type' => $_REQUEST['query_type']
); );
//_debug_array($search_param); //_debug_array($search_param);
if (!$GLOBALS['egw']->acl->check('account_access',2,'admin')) if (!$GLOBALS['egw']->acl->check('account_access',2,'admin'))
@ -223,13 +227,12 @@
} }
$p->fp('rows','row',True); $p->fp('rows','row',True);
} }
} }
$link_data += array( $link_data += array(
'order' => $order, 'order' => $order,
'sort' => $sort, 'sort' => $sort
); );
$p->set_var(array( $p->set_var(array(
'query' => $GLOBALS['egw']->html->htmlspecialchars($GLOBALS['query']), 'query' => $GLOBALS['egw']->html->htmlspecialchars($GLOBALS['query']),
@ -497,13 +500,44 @@
return False; return False;
} }
$group_info = Array( if($_POST['edit'])
'account_id' => $_GET['account_id'], {
'account_name' => '', $group_permissions = ($_POST['account_apps']?$_POST['account_apps']:Array());
'account_user' => Array(), $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']
); );
$this->create_edit_group($group_info); $errors = $this->bo->add_group($group_info);
if(is_array($errors))
{
$this->create_edit_group($group_info,$errors);
$GLOBALS['egw']->common->egw_exit();
}
$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()
);
$this->create_edit_group($group_info);
}
} }
function add_user() function add_user()
@ -512,6 +546,51 @@
{ {
$this->list_users(); $this->list_users();
} }
if($_POST['submit'])
{
if(!($email = $_POST['account_email']))
{
$email = $GLOBALS['egw']->common->email_address($_POST['account_firstname'],$_POST['account_lastname'],$_POST['account_lid']);
}
$userData = array(
'account_type' => 'u',
'account_lid' => $accountPrefix . $_POST['account_lid'],
'account_firstname' => $_POST['account_firstname'],
'account_lastname' => $_POST['account_lastname'],
'account_passwd' => $_POST['account_passwd'],
'status' => ($_POST['account_status'] ? 'A' : ''),
'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_primary_group' => $_POST['account_primary_group'],
'account_passwd_2' => $_POST['account_passwd_2'],
'account_groups' => $_POST['account_groups'],
'anonymous' => $_POST['anonymous'],
'changepassword' => $_POST['changepassword'],
'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'] */
);
/* when does the account expire */
if ($_POST['expires'] !== '' && !$_POST['never_expires'])
{
$jscal =& CreateObject('phpgwapi.jscalendar',False);
$userData += $jscal->input2date($_POST['expires'],False,'account_expires_day','account_expires_month','account_expires_year');
}
$errors = $this->bo->add_user($userData);
if(is_array($errors))
{
$this->create_edit_user($userData,$errors);
$GLOBALS['egw']->common->egw_exit();
}
$GLOBALS['egw']->redirect($GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_users'));
}
else else
{ {
$this->create_edit_user(0); $this->create_edit_user(0);
@ -524,10 +603,9 @@
{ {
if ($_POST['yes']) if ($_POST['yes'])
{ {
$this->bo->delete_group(); $this->bo->delete_group($_POST['account_id']);
} }
$this->list_groups(); $GLOBALS['egw']->redirect($GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
return False;
} }
unset($GLOBALS['egw_info']['flags']['noheader']); unset($GLOBALS['egw_info']['flags']['noheader']);
@ -603,8 +681,12 @@
{ {
if ($GLOBALS['egw']->acl->check('account_access',32,'admin') || $GLOBALS['egw_info']['user']['account_id'] == $_GET['account_id']) if ($GLOBALS['egw']->acl->check('account_access',32,'admin') || $GLOBALS['egw_info']['user']['account_id'] == $_GET['account_id'])
{ {
$this->list_users(); $GLOBALS['egw']->redirect($GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_users'));
return False; }
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'));
} }
unset($GLOBALS['egw_info']['flags']['noheader']); unset($GLOBALS['egw_info']['flags']['noheader']);
@ -623,7 +705,7 @@
) )
); );
$var = Array( $var = Array(
'form_action' => $GLOBALS['egw']->link('/index.php','menuaction=admin.boaccounts.delete_user'), 'form_action' => $GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.delete_user'),
'account_id' => $_GET['account_id'] 'account_id' => $_GET['account_id']
); );
@ -660,42 +742,70 @@
'extradata' => 'menuaction=admin.uiaclmanager.list_apps' 'extradata' => 'menuaction=admin.uiaclmanager.list_apps'
); );
} }
} }
function edit_group($cd='',$account_id='') function edit_group($cd='',$account_id='')
{ {
if ($GLOBALS['egw']->acl->check('group_access',16,'admin')) if ($GLOBALS['egw']->acl->check('group_access',16,'admin'))
{ {
$this->list_groups(); $GLOBALS['egw']->redirect($GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
return False;
} }
$cdid = $cd; if($_POST['edit'])
settype($cd,'integer');
$cd = ($_GET['cd']?$_GET['cd']:(int)$cdid);
$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(); $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->edit_group($group_info);
if(is_array($errors))
{
$this->create_edit_group($group_info,$errors);
$GLOBALS['egw']->common->egw_exit();
}
$GLOBALS['egw']->redirect($GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
} }
else else
{ {
$group_info = Array( $cdid = $cd;
'account_id' => (int)$_GET['account_id'], settype($cd,'integer');
'account_name' => $GLOBALS['egw']->accounts->id2name($_GET['account_id']), $cd = ($_GET['cd']?$_GET['cd']:(int)$cdid);
'account_user' => $GLOBALS['egw']->accounts->members($_GET['account_id']),
'account_apps' => $this->bo->load_group_apps($_GET['account_id'])
);
$this->create_edit_group($group_info); $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']),
'account_user' => $GLOBALS['egw']->accounts->members($_GET['account_id']),
'account_apps' => $this->bo->load_group_apps($_GET['account_id'])
);
$this->create_edit_group($group_info);
}
} }
} }
@ -711,7 +821,7 @@
} }
// not sure if this realy belongs here, or only in edit_user // not sure if this realy belongs here, or only in edit_user
if ($_GET['account_id'] && // can't set it on add if ($_GET['account_id'] && // can't set it on add
!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights !$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights
{ {
$GLOBALS['menuData'][] = array( $GLOBALS['menuData'][] = array(
'description' => 'ACL Rights', 'description' => 'ACL Rights',
@ -734,36 +844,106 @@
} }
*/ */
//NDEE //NDEE
} }
function edit_user($cd='',$account_id='') function edit_user($cd='',$account_id='')
{ {
if ($GLOBALS['egw']->acl->check('account_access',16,'admin')) if($GLOBALS['egw']->acl->check('account_access',16,'admin'))
{ {
$this->list_users(); $this->list_users();
return False; return False;
} }
$cdid = $cd; if($_POST['submit'])
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);
// todo
// not needed if i use the same file for new users too
if (! $account_id)
{ {
$this->list_users(); if(!($email = $_POST['account_email']))
return False; {
$email = $GLOBALS['egw']->common->email_address($_POST['account_firstname'],$_POST['account_lastname'],$_POST['account_lid']);
}
$userData = array(
'account_lid' => $accountPrefix.$_POST['account_lid'],
'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'],
'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'] */
);
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'])
{
$jscal =& CreateObject('phpgwapi.jscalendar',False);
$userData += $jscal->input2date($_POST['expires'],False,'account_expires_day','account_expires_month','account_expires_year');
}
$errors = $this->bo->add_user($userData);
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'))
{
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.list_users'
));
}
// ExecMethod('admin.uiaccounts.list_users');
//return False;
}
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']
));
}
}
// $GLOBALS['egw']->redirect($GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_users'));
}
else
{
$this->create_edit_user($userData['account_id'],$userData,$errors);
}
} }
else else
{ {
$this->create_edit_user($account_id); $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);
// todo
// not needed if i use the same file for new users too
if(!$account_id)
{
$this->list_users();
return False;
}
else
{
$this->create_edit_user($account_id);
}
} }
} }
@ -995,7 +1175,7 @@
$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;"')); $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;"'));
$var = Array( $var = Array(
'form_action' => $GLOBALS['egw']->link('/index.php','menuaction=admin.boaccounts.'.($group_info['account_id']?'edit':'add').'_group'), 'form_action' => $GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.'.($group_info['account_id']?'edit':'add').'_group'),
'hidden_vars' => '<input type="hidden" name="account_id" value="' . $group_info['account_id'] . '">', 'hidden_vars' => '<input type="hidden" name="account_id" value="' . $group_info['account_id'] . '">',
'lang_group_name' => lang('group name'), 'lang_group_name' => lang('group name'),
'group_name_value' => $group_info['account_name'], 'group_name_value' => $group_info['account_name'],
@ -1081,7 +1261,6 @@
$p->set_var('select',''); $p->set_var('select','');
$p->set_var('popwin',''); $p->set_var('popwin','');
$p->pfp('out','edit'); $p->pfp('out','edit');
} }
function create_edit_user($_account_id,$_userData='',$_errors='') function create_edit_user($_account_id,$_userData='',$_errors='')
@ -1159,7 +1338,7 @@
} }
$allGroups = $account->get_list('groups'); $allGroups = $account->get_list('groups');
} }
$page_params['menuaction'] = 'admin.boaccounts.'.($_account_id?'edit':'add').'_user'; $page_params['menuaction'] = 'admin.uiaccounts.'.($_account_id?'edit':'add').'_user';
if($_account_id) if($_account_id)
{ {
$page_params['account_id'] = $_account_id; $page_params['account_id'] = $_account_id;
@ -1192,7 +1371,8 @@
$t->set_var($var); $t->set_var($var);
$t->parse('form_buttons','form_buttons_',True); $t->parse('form_buttons','form_buttons_',True);
if ($GLOBALS['egw_info']['server']['ldap_extra_attributes']) { if ($GLOBALS['egw_info']['server']['ldap_extra_attributes'])
{
$lang_homedir = lang('home directory'); $lang_homedir = lang('home directory');
$lang_shell = lang('login shell'); $lang_shell = lang('login shell');
$homedirectory = '<input name="homedirectory" value="'. ($_account_id?$userData['homedirectory']:$GLOBALS['egw_info']['server']['ldap_account_home'].$account_lid).'">'; $homedirectory = '<input name="homedirectory" value="'. ($_account_id?$userData['homedirectory']:$GLOBALS['egw_info']['server']['ldap_account_home'].$account_lid).'">';
@ -1260,7 +1440,7 @@
'account_passwd' => $userData['account_passwd'], 'account_passwd' => $userData['account_passwd'],
'account_passwd_2' => $userData['account_passwd_2'], 'account_passwd_2' => $userData['account_passwd_2'],
'account_file_space' => $account_file_space, 'account_file_space' => $account_file_space,
'account_id' => (int) $userData['account_id'], 'account_id' => (int) $userData['account_id']
); );
if($userData['expires'] == -1) if($userData['expires'] == -1)
@ -1350,8 +1530,7 @@
=> '<select => '<select
name="account_primary_group">'."\n".$primary_group_select.'</ name="account_primary_group">'."\n".$primary_group_select.'</
select>'."\n", select>'."\n",
'permissions_list' 'permissions_list' => $appRightsOutput,
=> $appRightsOutput,
'lang_app' => lang('application'), 'lang_app' => lang('application'),
'lang_acl' => lang('enabled').' / '.lang('ACL'), 'lang_acl' => lang('enabled').' / '.lang('ACL'),
); );
@ -1440,7 +1619,7 @@
$var['lang_group'] = lang('Group'); $var['lang_group'] = lang('Group');
$var['group_name'] = $group_info['account_name']; $var['group_name'] = $group_info['account_name'];
$var['tr_color1'] = $GLOBALS['egw_info']['user']['theme']['row_on']; $var['tr_color1'] = $GLOBALS['egw_info']['user']['theme']['row_on'];
$var['form_action'] = $GLOBALS['egw']->link('/index.php','menuaction=admin.boaccounts.set_group_managers'); $var['form_action'] = $GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.set_group_managers');
$var['hidden'] = '<input type="hidden" name="account_id" value="'.$group_info['account_id'].'">'; $var['hidden'] = '<input type="hidden" name="account_id" value="'.$group_info['account_id'].'">';
$var['lang_select_managers'] = lang('Select Group Managers'); $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['group_members'] = '<select name="managers[]" size="'.(count($account_list)<5?count($account_list):5).'" multiple>'.$user_list.'</select>';
@ -1453,5 +1632,52 @@
$t->pfp('out','form'); $t->pfp('out','form');
} }
function set_group_managers()
{
if($GLOBALS['egw']->acl->check('group_access',16,'admin') || $_POST['cancel'])
{
$GLOBALS['egw']->redirect($GLOBALS['egw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
$GLOBALS['egw']->common->egw_exit();
}
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'));
$GLOBALS['egw']->common->egw_exit();
}
/**
* 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;
}
} }
?> ?>