This commit is contained in:
ceb 2003-04-27 23:16:15 +00:00
parent 265ab3f48e
commit 4f6fc8d85a
7 changed files with 391 additions and 511 deletions

View File

@ -17,11 +17,10 @@
var $public_functions = array
(
'add_group' => True,
'add_user' => True,
'delete_group' => True,
'delete_user' => True,
'edit_group' => True,
'edit_user' => True,
'save_user' => True,
'set_group_managers' => True
);
@ -96,93 +95,6 @@
return False;
}
function delete_group($account_id)
{
if ($GLOBALS['phpgw']->acl->check('group_access',32,'admin'))
{
return False;
}
$GLOBALS['phpgw']->db->lock(array
(
'phpgw_accounts',
'phpgw_acl'
)
);
$old_group_list = $GLOBALS['phpgw']->acl->get_ids_for_location($account_id,1,'phpgw_group');
@reset($old_group_list);
while($old_group_list && $id = each($old_group_list))
{
$GLOBALS['phpgw']->acl->delete_repository('phpgw_group',$account_id,intval($id[1]));
$GLOBALS['phpgw']->session->delete_cache(intval($id[1]));
}
$GLOBALS['phpgw']->acl->delete_repository('%%','run',$account_id);
if (! @rmdir($GLOBALS['phpgw_info']['server']['files_dir'].SEP.'groups'.SEP.$GLOBALS['phpgw']->accounts->id2name($account_id)))
{
$cd = 38;
}
else
{
$cd = 32;
}
$GLOBALS['phpgw']->accounts->delete($account_id);
$GLOBALS['phpgw']->db->unlock();
}
function delete_user()
{
if (isset($GLOBALS['HTTP_POST_VARS']['cancel']) || $GLOBALS['phpgw']->acl->check('account_access',32,'admin'))
{
ExecMethod('admin.uiaccounts.list_users');
return False;
}
elseif($GLOBALS['HTTP_POST_VARS']['delete_account'])
{
$accountid = $GLOBALS['HTTP_POST_VARS']['account_id'];
settype($account_id,'integer');
$account_id = get_account_id($accountid);
$lid = $GLOBALS['phpgw']->accounts->id2name($account_id);
$db = $GLOBALS['phpgw']->db;
$db->query('SELECT app_name,app_order FROM phpgw_applications WHERE app_enabled!=0 ORDER BY app_order',__LINE__,__FILE__);
if($db->num_rows())
{
while($db->next_record())
{
$appname = $db->f('app_name');
if($appname <> 'admin')
{
$GLOBALS['phpgw']->hooks->single('deleteaccount', $appname);
}
}
}
$GLOBALS['phpgw']->hooks->single('deleteaccount','preferences');
$GLOBALS['phpgw']->hooks->single('deleteaccount','admin');
$GLOBALS['hook_values']['account_id'] = $account_id;
$GLOBALS['phpgw']->hooks->process('deleteaccount');
$basedir = $GLOBALS['phpgw_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($values)
{
@ -295,60 +207,6 @@
$GLOBALS['phpgw']->db->unlock();
}
function add_user($values)
{
if ($GLOBALS['phpgw']->acl->check('account_access',4,'admin'))
{
return False;
}
if ($GLOBALS['HTTP_POST_VARS']['submit'])
{
$userData = array(
'account_type' => 'u',
'account_lid' => $GLOBALS['HTTP_POST_VARS']['account_lid'],
'account_firstname' => $GLOBALS['HTTP_POST_VARS']['account_firstname'],
'account_lastname' => $GLOBALS['HTTP_POST_VARS']['account_lastname'],
'account_passwd' => $GLOBALS['HTTP_POST_VARS']['account_passwd'],
'status' => ($GLOBALS['HTTP_POST_VARS']['account_status'] ? 'A' : ''),
'account_status' => ($GLOBALS['HTTP_POST_VARS']['account_status'] ? 'A' : ''),
'old_loginid' => ($GLOBALS['HTTP_GET_VARS']['old_loginid']?rawurldecode($GLOBALS['HTTP_GET_VARS']['old_loginid']):''),
'account_id' => ($GLOBALS['HTTP_GET_VARS']['account_id']?$GLOBALS['HTTP_GET_VARS']['account_id']:0),
'account_passwd_2' => $GLOBALS['HTTP_POST_VARS']['account_passwd_2'],
'account_groups' => $GLOBALS['HTTP_POST_VARS']['account_groups'],
'account_permissions' => $GLOBALS['HTTP_POST_VARS']['account_permissions'],
'homedirectory' => $GLOBALS['HTTP_POST_VARS']['homedirectory'],
'loginshell' => $GLOBALS['HTTP_POST_VARS']['loginshell'],
'account_expires_month' => $GLOBALS['HTTP_POST_VARS']['account_expires_month'],
'account_expires_day' => $GLOBALS['HTTP_POST_VARS']['account_expires_day'],
'account_expires_year' => $GLOBALS['HTTP_POST_VARS']['account_expires_year'],
'account_expires_never' => $GLOBALS['HTTP_POST_VARS']['never_expires']
/* 'file_space' => $GLOBALS['HTTP_POST_VARS']['account_file_space_number'] . "-" . $GLOBALS['HTTP_POST_VARS']['account_file_space_type'] */
);
if (!$errors = $this->validate_user($userData))
{
$this->so->add_user($userData);
$GLOBALS['hook_values']['account_lid'] = $userData['account_lid'];
$GLOBALS['hook_values']['account_id'] = $userData['account_id'];
$GLOBALS['hook_values']['new_passwd'] = $userData['account_passwd'];
$GLOBALS['phpgw']->hooks->process('addaccount');
ExecMethod('admin.uiaccounts.list_users');
return False;
}
else
{
$ui = createobject('admin.uiaccounts');
$ui->create_edit_user($userData['account_id'],$userData,$errors);
}
}
else
{
ExecMethod('admin.uiaccounts.list_users');
return False;
}
}
function edit_group($values)
{
if ($GLOBALS['phpgw']->acl->check('group_access',16,'admin'))
@ -514,61 +372,129 @@
$GLOBALS['phpgw']->db->unlock();
}
function edit_user()
function save_user($values)
{
if ($GLOBALS['phpgw']->acl->check('account_access',16,'admin'))
if (is_array($values))
{
return False;
}
if($values['expires_never'])
{
$values['expires'] = $values['account_expires'] = -1;
}
else
{
$values['expires'] = $values['account_expires'] = mktime(2,0,0,$values['account_expires_month'],$values['account_expires_day'],$values['account_expires_year']);
}
if ($GLOBALS['HTTP_POST_VARS']['submit'])
{
$userData = array(
'account_lid' => $GLOBALS['HTTP_POST_VARS']['account_lid'],
'firstname' => $GLOBALS['HTTP_POST_VARS']['account_firstname'],
'lastname' => $GLOBALS['HTTP_POST_VARS']['account_lastname'],
'account_passwd' => $GLOBALS['HTTP_POST_VARS']['account_passwd'],
'status' => ($GLOBALS['HTTP_POST_VARS']['account_status'] ? 'A' : ''),
'account_status' => ($GLOBALS['HTTP_POST_VARS']['account_status'] ? 'A' : ''),
'old_loginid' => ($GLOBALS['HTTP_GET_VARS']['old_loginid']?rawurldecode($GLOBALS['HTTP_GET_VARS']['old_loginid']):''),
'account_id' => ($GLOBALS['HTTP_GET_VARS']['account_id']?$GLOBALS['HTTP_GET_VARS']['account_id']:0),
'account_passwd_2' => $GLOBALS['HTTP_POST_VARS']['account_passwd_2'],
'account_groups' => $GLOBALS['HTTP_POST_VARS']['account_groups'],
'account_permissions' => $GLOBALS['HTTP_POST_VARS']['account_permissions'],
'homedirectory' => $GLOBALS['HTTP_POST_VARS']['homedirectory'],
'loginshell' => $GLOBALS['HTTP_POST_VARS']['loginshell'],
'account_expires_month' => $GLOBALS['HTTP_POST_VARS']['account_expires_month'],
'account_expires_day' => $GLOBALS['HTTP_POST_VARS']['account_expires_day'],
'account_expires_year' => $GLOBALS['HTTP_POST_VARS']['account_expires_year'],
'account_expires_never' => $GLOBALS['HTTP_POST_VARS']['never_expires']
$userData = array
(
'account_type' => 'u',
'account_lid' => $values['account_lid'],
'account_firstname' => $values['account_firstname'],
'account_lastname' => $values['account_lastname'],
'account_passwd' => $values['account_passwd'],
'status' => ($values['account_status'] ? 'A' : ''),
'account_status' => ($values['account_status'] ? 'A' : ''),
'old_loginid' => ($values['old_loginid']?rawurldecode($GLOBALS['HTTP_GET_VARS']['old_loginid']):''),
'account_id' => ($values['account_id']?$GLOBALS['HTTP_GET_VARS']['account_id']:0),
'account_passwd_2' => $values['account_passwd_2'],
'account_groups' => $values['account_groups'],
'account_permissions' => $values['account_permissions'],
'homedirectory' => $values['homedirectory'],
'loginshell' => $values['loginshell'],
'account_expires_month' => $values['account_expires_month'],
'account_expires_day' => $values['account_expires_day'],
'account_expires_year' => $values['account_expires_year'],
'account_expires_never' => $values['expires'],
'expires' => $values['expires'],
'account_expires' => $values['expires']
/* 'file_space' => $GLOBALS['HTTP_POST_VARS']['account_file_space_number'] . "-" . $GLOBALS['HTTP_POST_VARS']['account_file_space_type'] */
);
if (!$errors = $this->validate_user($userData))
if ($values['account_id'])
{
$this->save_user($userData);
// check if would create a menu
$userData['account_id'] = $values['account_id'];
$this->update_user($userData);
/* 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'))
{
ExecMethod('admin.uiaccounts.list_users');
return False;
}
else
{
ExecMethod('admin.uiaccounts.edit_user',$GLOBALS['HTTP_GET_VARS']['account_id']);
return False;
}
}*/
}
else
{
$ui = createobject('admin.uiaccounts');
$ui->create_edit_user($userData['account_id'],$userData,$errors);
$account_id = $this->so->add_user($userData);
$GLOBALS['hook_values']['account_lid'] = $userData['account_lid'];
$GLOBALS['hook_values']['account_id'] = $account_id; //$userData['account_id'];
$GLOBALS['hook_values']['new_passwd'] = $userData['account_passwd'];
$GLOBALS['phpgw']->hooks->process('addaccount');
}
}
}
/* stores the userdata */
function update_user($userData)
{
$account = CreateObject('phpgwapi.accounts',$userData['account_id'],'u');
$account->update_data($userData);
$account->save_repository();
if ($userData['account_passwd'])
{
$auth = CreateObject('phpgwapi.auth');
$auth->change_password($old_passwd,$userData['account_passwd'],$userData['account_id']);
$GLOBALS['hook_values']['account_id'] = $userData['account_id'];
$GLOBALS['hook_values']['old_passwd'] = $old_passwd;
$GLOBALS['hook_values']['new_passwd'] = $userData['account_passwd'];
$GLOBALS['phpgw']->hooks->process('changepassword');
}
$apps = CreateObject('phpgwapi.applications',array(intval($userData['account_id']),'u'));
$apps->account_id = $userData['account_id'];
if ($_userData['account_permissions'])
{
while($app = each($userData['account_permissions']))
{
if($app[1])
{
$apps->add($app[0]);
}
}
}
$apps->save_repository();
$account = CreateObject('phpgwapi.accounts',$userData['account_id'],'u');
$allGroups = $account->get_list('groups');
if ($userData['account_groups'])
{
reset($userData['account_groups']);
while (list($key,$value) = each($userData['account_groups']))
{
$newGroups[$value] = $value;
}
}
$acl = CreateObject('phpgwapi.acl',$userData['account_id']);
reset($allGroups);
while (list($key,$groupData) = each($allGroups))
{
/* print "$key,". $groupData['account_id'] ."<br>";*/
/* print "$key,". $userData['account_groups'][1] ."<br>"; */
if ($newGroups[$groupData['account_id']])
{
$acl->add_repository('phpgw_group',$groupData['account_id'],$userData['account_id'],1);
}
else
{
$acl->delete_repository('phpgw_group',$groupData['account_id'],$userData['account_id']);
}
}
$GLOBALS['phpgw']->session->delete_cache(intval($userData['account_id']));
}
function set_group_managers()
{
if($GLOBALS['phpgw']->acl->check('group_access',16,'admin') || $GLOBALS['HTTP_POST_VARS']['cancel'])
@ -604,9 +530,9 @@
$group = CreateObject('phpgwapi.accounts',$values['account_id'],'g');
$group->read_repository();
if ($GLOBALS['phpgw']->acl->check('group_access',4,'admin'))
if (!$values['account_id'] && $GLOBALS['phpgw']->acl->check('group_access',4,'admin'))
{
$error[] = lang('no permission to create groups');
$error[] = lang('no permission to add groups');
}
if(!$values['account_name'])
@ -638,45 +564,44 @@
returns FALSE if the data are correct
otherwise the error array
*/
function validate_user(&$_userData)
function validate_user($values)
{
$totalerrors = 0;
if (!$values['account_id'] && $GLOBALS['phpgw']->acl->check('account_access',4,'admin'))
{
$error[] = lang('no permission to add users');
}
/*
if ($GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap' && ! $allow_long_loginids)
if ($GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap' && ! $values['allow_long_loginids'])
{
if (strlen($_userData['account_lid']) > 8)
if (strlen($values['account_lid']) > 8)
{
$error[$totalerrors] = lang('The loginid can not be more then 8 characters');
$totalerrors++;
$error[] = lang('The loginid can not be more then 8 characters');
}
}
*/
if (!$_userData['account_lid'])
if (!$values['account_lid'])
{
$error[$totalerrors] = lang('You must enter a loginid');
$totalerrors++;
$error[] = lang('You must enter a loginid');
}
if ($_userData['old_loginid'] != $_userData['account_lid'])
if ($values['old_loginid'] != $values['account_lid'])
{
if ($GLOBALS['phpgw']->accounts->exists($_userData['account_lid']))
if ($GLOBALS['phpgw']->accounts->exists($values['account_lid']))
{
$error[$totalerrors] = lang('That loginid has already been taken');
$totalerrors++;
$error[] = lang('That loginid has already been taken');
}
}
if ($_userData['account_passwd'] || $_userData['account_passwd_2'])
if ($values['account_passwd'] || $values['account_passwd_2'])
{
if ($_userData['account_passwd'] != $_userData['account_passwd_2'])
if ($values['account_passwd'] != $values['account_passwd_2'])
{
$error[$totalerrors] = lang('The two passwords are not the same');
$totalerrors++;
$error[] = lang('The two passwords are not the same');
}
$temp_msgbox_data = $GLOBALS['phpgw_info']['flags']['msgbox_data'];
/* $temp_msgbox_data = $GLOBALS['phpgw_info']['flags']['msgbox_data'];
unset($GLOBALS['phpgw_info']['flags']['msgbox_data']);
if(!sanitize($_userData['account_passwd'],'password'))
{
@ -688,40 +613,20 @@
}
}
$GLOBALS['phpgw_info']['flags']['msgbox_data'] = $temp_msgbox_data;
unset($temp_msgbox_data);
unset($temp_msgbox_data); */
}
if (!count($_userData['account_permissions']) && !count($_userData['account_groups']))
if (!count($values['account_permissions']) && !count($values['account_groups']))
{
$error[$totalerrors] = lang('You must add at least 1 permission or group to this account');
$totalerrors++;
$error[] = lang('You must add at least 1 permission or group to this account');
}
if ($_userData['account_expires_month'] || $_userData['account_expires_day'] || $_userData['account_expires_year'] || $_userData['account_expires_never'])
if ($values['account_expires_month'] || $values['account_expires_day'] || $values['account_expires_year'] || $values['account_expires_never'])
{
if($_userData['account_expires_never'])
if (! checkdate($values['account_expires_month'],$values['account_expires_day'],$values['account_expires_year']))
{
$_userData['expires'] = -1;
$_userData['account_expires'] = $_userData['expires'];
$error[] = lang('You have entered an invalid expiration date');
}
else
{
if (! checkdate($_userData['account_expires_month'],$_userData['account_expires_day'],$_userData['account_expires_year']))
{
$error[$totalerrors] = lang('You have entered an invalid expiration date');
$totalerrors++;
}
else
{
$_userData['expires'] = mktime(2,0,0,$_userData['account_expires_month'],$_userData['account_expires_day'],$_userData['account_expires_year']);
$_userData['account_expires'] = $_userData['expires'];
}
}
}
else
{
$_userData['expires'] = -1;
$_userData['account_expires'] = $_userData['expires'];
}
/*
@ -733,77 +638,99 @@
}
*/
if ($totalerrors == 0)
{
return FALSE;
}
else
if (is_array($error))
{
return $error;
}
}
/* stores the userdata */
function save_user($_userData)
function delete_group($account_id)
{
$account = CreateObject('phpgwapi.accounts',$_userData['account_id'],'u');
$account->update_data($_userData);
$account->save_repository();
if ($_userData['account_passwd'])
if ($GLOBALS['phpgw']->acl->check('group_access',32,'admin'))
{
$auth = CreateObject('phpgwapi.auth');
$auth->change_password($old_passwd, $_userData['account_passwd'], $_userData['account_id']);
$GLOBALS['hook_values']['account_id'] = $_userData['account_id'];
$GLOBALS['hook_values']['old_passwd'] = $old_passwd;
$GLOBALS['hook_values']['new_passwd'] = $_userData['account_passwd'];
$GLOBALS['phpgw']->hooks->process('changepassword');
return False;
}
$apps = CreateObject('phpgwapi.applications',array(intval($_userData['account_id']),'u'));
$GLOBALS['phpgw']->db->lock(array
(
'phpgw_accounts',
'phpgw_acl'
)
);
$apps->account_id = $_userData['account_id'];
if ($_userData['account_permissions'])
$old_group_list = $GLOBALS['phpgw']->acl->get_ids_for_location($account_id,1,'phpgw_group');
@reset($old_group_list);
while($old_group_list && $id = each($old_group_list))
{
while($app = each($_userData['account_permissions']))
$GLOBALS['phpgw']->acl->delete_repository('phpgw_group',$account_id,intval($id[1]));
$GLOBALS['phpgw']->session->delete_cache(intval($id[1]));
}
$GLOBALS['phpgw']->acl->delete_repository('%%','run',$account_id);
if (! @rmdir($GLOBALS['phpgw_info']['server']['files_dir'].SEP.'groups'.SEP.$GLOBALS['phpgw']->accounts->id2name($account_id)))
{
$cd = 38;
}
else
{
$cd = 32;
}
$GLOBALS['phpgw']->accounts->delete($account_id);
$GLOBALS['phpgw']->db->unlock();
}
function delete_user()
{
if (isset($GLOBALS['HTTP_POST_VARS']['cancel']) || $GLOBALS['phpgw']->acl->check('account_access',32,'admin'))
{
ExecMethod('admin.uiaccounts.list_users');
return False;
}
elseif($GLOBALS['HTTP_POST_VARS']['delete_account'])
{
$accountid = $GLOBALS['HTTP_POST_VARS']['account_id'];
settype($account_id,'integer');
$account_id = get_account_id($accountid);
$lid = $GLOBALS['phpgw']->accounts->id2name($account_id);
$db = $GLOBALS['phpgw']->db;
$db->query('SELECT app_name,app_order FROM phpgw_applications WHERE app_enabled!=0 ORDER BY app_order',__LINE__,__FILE__);
if($db->num_rows())
{
if($app[1])
while($db->next_record())
{
$apps->add($app[0]);
$appname = $db->f('app_name');
if($appname <> 'admin')
{
$GLOBALS['phpgw']->hooks->single('deleteaccount', $appname);
}
}
}
}
$apps->save_repository();
$account = CreateObject('phpgwapi.accounts',$_userData['account_id'],'u');
$allGroups = $account->get_list('groups');
$GLOBALS['phpgw']->hooks->single('deleteaccount','preferences');
$GLOBALS['phpgw']->hooks->single('deleteaccount','admin');
if ($_userData['account_groups'])
{
reset($_userData['account_groups']);
while (list($key,$value) = each($_userData['account_groups']))
$GLOBALS['hook_values']['account_id'] = $account_id;
$GLOBALS['phpgw']->hooks->process('deleteaccount');
$basedir = $GLOBALS['phpgw_info']['server']['files_dir'] . SEP . 'users' . SEP;
if (! @rmdir($basedir . $lid))
{
$newGroups[$value] = $value;
}
}
$acl = CreateObject('phpgwapi.acl',$_userData['account_id']);
reset($allGroups);
while (list($key,$groupData) = each($allGroups))
{
/* print "$key,". $groupData['account_id'] ."<br>";*/
/* print "$key,". $_userData['account_groups'][1] ."<br>"; */
if ($newGroups[$groupData['account_id']])
{
$acl->add_repository('phpgw_group',$groupData['account_id'],$_userData['account_id'],1);
$cd = 34;
}
else
{
$acl->delete_repository('phpgw_group',$groupData['account_id'],$_userData['account_id']);
$cd = 29;
}
ExecMethod('admin.uiaccounts.list_users');
return False;
}
$GLOBALS['phpgw']->session->delete_cache(intval($_userData['account_id']));
}
function load_group_users($account_id)

View File

@ -19,9 +19,10 @@
function add_user($userData)
{
$userData['account_expires'] = $userData['expires'];
$GLOBALS['phpgw']->db->lock(
Array(
$GLOBALS['phpgw']->db->lock
(
array
(
'phpgw_accounts',
'phpgw_nextid',
'phpgw_preferences',

View File

@ -293,7 +293,7 @@
if (is_array($error))
{
$error_list = $GLOBALS['phpgw']->common->error_list($error);
}
else
{
@ -364,7 +364,6 @@
$account_list = $accounts->get_list('accounts');
$account_num = count($account_list);
$user_list = '';
while (list($key,$entry) = each($account_list))
{
$user_list[] = array
@ -446,12 +445,12 @@
$data = array
(
'msgbox_data' => $error_list,
'edit_url' => $GLOBALS['phpgw']->link('/index.php',$link_data),
'account_id' => $group_info['account_id'],
'lang_account_name' => lang('group name'),
'value_account_name' => $group_info['account_name'],
'lang_include_user' => lang('select users for inclusion'),
'error' => (!$_errors?'':$GLOBALS['phpgw']->common->error_list($_errors)),
'select_size' => ($account_num < 5?$account_num:5),
'user_list' => $user_list,
'lang_permissions' => lang('permissions this group has'),
@ -471,13 +470,11 @@
function edit_user()
{
$cd = get_var('cd',array('GET'));
$account_id = get_var('account_id',array('GET','POST'));
$values = get_var('values',array('POST'));
$account_groups = get_var('account_groups',array('POST'));
$account_apps = get_var('account_apps',array('POST'));
_debug_array($values);
$cd = get_var('cd',array('GET'));
$account_id = get_var('account_id',array('GET','POST'));
$values = get_var('values',array('POST'));
$account_groups = get_var('account_groups',array('POST'));
$account_permissions = get_var('account_permissions',array('POST'));
if ($values['cancel'] || (!$account_id && $GLOBALS['phpgw']->acl->check('account_access',4,'admin')) || ($account_id && $GLOBALS['phpgw']->acl->check('account_access',16,'admin')))
{
@ -494,34 +491,30 @@
if ($values['save'])
{
if (is_array($account_groups))
{
$values['account_groups'] = $account_groups;
}
if (is_array($account_permissions))
{
$values['account_permissions'] = $account_permissions;
}
$error = $this->bo->validate_user($values);
if (is_array($error))
{
$error_list = $GLOBALS['phpgw']->common->error_list($error);
}
else
{
if (is_array($account_groups))
if ($account_id)
{
$values['account_groups'] = $account_groups;
}
if (is_array($account_permissions))
{
$values['account_permissions'] = $account_permissions;
}
if ($values['account_id'])
{
$this->bo->edit_user($values);
$account_id = $values['account_id'];
}
else
{
$this->bo->add_user($values);
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_user'));
$values['account_id'] = $account_id;
}
$this->bo->save_user($values);
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=admin.uiaccounts.list_users');
}
}
@ -546,50 +539,34 @@
);
}
if (is_array($_userData))
if($account_id)
{
$userData = Array();
$userData=$_userData;
@reset($userData['account_groups']);
while (list($key, $value) = @each($userData['account_groups']))
{
$userGroups[$key]['account_id'] = $value;
}
$account = CreateObject('phpgwapi.accounts');
$allGroups = $account->get_list('groups');
$account = CreateObject('phpgwapi.accounts',intval($account_id),'u');
$userData = $account->read_repository();
$userGroups = $account->membership($account_id);
}
elseif(is_string($_userData) && $_userData=='')
else
{
if($_account_id)
{
$account = CreateObject('phpgwapi.accounts',intval($_account_id),'u');
$userData = $account->read_repository();
$userGroups = $account->membership($_account_id);
}
else
{
$account = CreateObject('phpgwapi.accounts');
$userData = Array();
$userData['status'] = 'A';
$userGroups = Array();
}
$allGroups = $account->get_list('groups');
$account = CreateObject('phpgwapi.accounts');
$userData = Array();
$userData['status'] = 'A';
$userGroups = Array();
}
$allGroups = $account->get_list('groups');
if ($userData['expires'] == -1)
{
$userData['account_expires_month'] = 0;
$userData['account_expires_day'] = 0;
$userData['account_expires_year'] = 0;
}
else
{
/* Change this to be an admin/setup setting. For now, default to expire one week from today. */
$time_var = time() + (60*60*24*7);
$userData['account_expires_month'] = date('m',$userData['expires'] > 0 ? $userData['expires'] : $time_var);
$userData['account_expires_day'] = date('d',$userData['expires'] > 0 ? $userData['expires'] : $time_var);
$userData['account_expires_year'] = date('Y',$userData['expires'] > 0 ? $userData['expires'] : $time_var);
}
if ($userData['expires'] == -1)
{
$userData['account_expires_month'] = 0;
$userData['account_expires_day'] = 0;
$userData['account_expires_year'] = 0;
}
else
{
/* Change this to be an admin/setup setting. For now, default to expire one week from today. */
$time_var = time() + (60*60*24*7);
$userData['account_expires_month'] = date('m',$userData['expires'] > 0 ? $userData['expires'] : $time_var);
$userData['account_expires_day'] = date('d',$userData['expires'] > 0 ? $userData['expires'] : $time_var);
$userData['account_expires_year'] = date('Y',$userData['expires'] > 0 ? $userData['expires'] : $time_var);
}
if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
@ -597,10 +574,10 @@
$lang_homedir = lang('home directory');
$lang_shell = lang('login shell');
$homedirectory = '<input name="homedirectory" value="'
. ($_account_id?$userData['homedirectory']:$GLOBALS['phpgw_info']['server']['ldap_account_home'].SEP.$account_lid)
. ($account_id?$userData['homedirectory']:$GLOBALS['phpgw_info']['server']['ldap_account_home'].SEP.$account_lid)
. '">';
$loginshell = '<input name="loginshell" value="'
. ($_account_id?$userData['loginshell']:$GLOBALS['phpgw_info']['server']['ldap_account_shell'])
. ($account_id?$userData['loginshell']:$GLOBALS['phpgw_info']['server']['ldap_account_shell'])
. '">';
}
@ -635,7 +612,6 @@
$t->set_var($var);
*/
$groups_select = '';
reset($allGroups);
while (list($key,$value) = each($allGroups))
{
@ -644,20 +620,22 @@
'account_id' => $value['account_id'],
'account_lid' => $value['account_lid']
);
}
for ($i=0; $i<count($userGroups); $i++)
for ($i=0;$i<count($userGroups);$i++)
{
for($j=0;$j<count($group_list);$j++)
{
/* print "Los1:".$userData["account_id"].$userGroups[$i]['account_id']." : ".$value['account_id']."<br>"; */
if (@$userGroups[$i]['account_id'] == $value['account_id'])
if ($userGroups[$i]['account_id'] == $group_list[$j]['account_id'])
{
$group_list[]['selected'] = 'yes';
$group_list[$j]['selected'] = 'yes';
}
}
}
/* create list of available apps */
$i = 0;
$apps = CreateObject('phpgwapi.applications',$_account_id);
$apps = CreateObject('phpgwapi.applications',$account_id);
$db_perms = $apps->read_account_specific();
@reset($GLOBALS['phpgw_info']['apps']);
@ -696,6 +674,7 @@
$data = array
(
'msgbox_data' => $error_list,
'edit_url' => $GLOBALS['phpgw']->link('/index.php',$page_params),
'lang_lid' => lang('loginid'),
'lang_account_active' => lang('account active'),
@ -720,7 +699,7 @@
'account_lastname' => $userData['lastname'],
'account_passwd' => $account_passwd,
'account_passwd_2' => $account_passwd_2,
'expires' => (($userData['expires'] == -1)?'yes':''),
'expires_never' => (($userData['expires'] == -1)?'yes':''),
'group_list' => $group_list,
'app_list' => $app_list
);

View File

@ -92,6 +92,17 @@
'global_cats' => $global_cats
);
if ($_POST['add'])
{
$link_data['menuaction'] = 'admin.uicategories.edit';
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
}
if ($_POST['done'])
{
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=admin.iumainscreen.mainscreen');
}
if ($GLOBALS['appname'])
{
$GLOBALS['phpgw_info']['flags']['app_header'] = lang($GLOBALS['appname']) . '&nbsp;' . lang('global categories') . ': ' . lang('category list');
@ -211,17 +222,16 @@
);
}
$link_data['menuaction'] = 'admin.uicategories.edit';
$link_data['menuaction'] = 'admin.uicategories.index';
$link_data['parent'] = '';
$cat_add[] = array
(
'lang_add' => lang('add'),
'lang_add_statustext' => lang('add a category'),
'add_url' => $GLOBALS['phpgw']->link('/index.php',$link_data),
'action_url' => $GLOBALS['phpgw']->link('/index.php',$link_data),
'lang_done' => lang('done'),
'lang_done_statustext' => lang('return to admin mainscreen'),
'done_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uimainscreen.mainscreen')
'lang_done_statustext' => lang('return to admin mainscreen')
);
$link_data['menuaction'] = 'admin.uicategories.index';
@ -254,13 +264,22 @@
$parent = get_var('parent',array('GET'));
$values = get_var('values',array('POST'));
if ($values['save'])
$link_data = array
(
'menuaction' => 'admin.uicategories.index',
'appname' => $GLOBALS['appname'],
'global_cats' => $global_cats
);
if ($values['cancel'])
{
if (is_array($values))
{
$values['cat_id'] = $this->cat_id;
$values['access'] = 'public';
}
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
}
if ($values['save'] || $values['apply'])
{
$values['cat_id'] = $this->cat_id;
$values['access'] = 'public';
$error = $this->bo->check_values($values);
if (is_array($error))
@ -270,27 +289,26 @@
else
{
$this->cat_id = $this->bo->save_cat($values);
$message = lang('Category %1 has been saved !',$values['name']);
if ($values['apply'])
{
$message = lang('Category %1 has been saved !',$values['name']);
}
else
{
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
}
}
}
if (!$this->cat_id)
if ($this->cat_id)
{
$function = lang('add category');
$action = 'add';
}
else
{
$action = 'edit';
$function = lang('edit category');
$cats = $this->bo->cats->return_single($this->cat_id);
$parent = $cats['parent'];
}
if ($GLOBALS['appname'])
{
$GLOBALS['phpgw_info']['flags']['app_header'] = lang($GLOBALS['appname']) . '&nbsp;' . lang('global categories') . ': ' . $function;
$GLOBALS['phpgw_info']['flags']['app_header'] = lang($GLOBALS['appname']) . '&nbsp;' . lang('global categories') . ': ' . ($this->cat_id?lang('edit category'):lang('add category'));
}
else
{
@ -308,31 +326,22 @@
$GLOBALS['phpgw']->template->set_var('title_categories',lang('Edit global category'));
}
$link_data = array
(
'menuaction' => 'admin.uicategories.index',
'appname' => $GLOBALS['appname'],
'global_cats' => $global_cats
);
$data = array
(
'action' => $action,
'done_url' => $GLOBALS['phpgw']->link('/index.php',$link_data),
'lang_name' => lang('name'),
'lang_descr' => lang('description'),
'lang_parent' => lang('parent category'),
'old_parent' => $cats['parent'],
'lang_save' => lang('save'),
'lang_done' => lang('done'),
'lang_delete' => lang('delete'),
'lang_reset' => lang('reset'),
'lang_apply' => lang('apply'),
'lang_cancel' => lang('cancel'),
'value_name' => $GLOBALS['phpgw']->strip_html($cats['name']),
'value_descr' => $GLOBALS['phpgw']->strip_html($cats['descr']),
'message' => $message,
'lang_content_statustext' => lang('Enter a description for the category'),
'lang_done_statustext' => lang('Back to the list'),
'lang_save_statustext' => lang('Save the category'),
'lang_content_statustext' => lang('enter a description for the category'),
'lang_cancel_statustext' => lang('leave the category untouched and return back to the list'),
'lang_save_statustext' => lang('save the category and return back to the list'),
'lang_apply_statustext' => lang('save the category'),
'lang_no_cat' => lang('no category'),
'lang_cat_statustext' => lang('Select the parent category. If this is a main category select NO CATEGORY'),
'select_name' => 'values[parent]',
@ -345,7 +354,6 @@
$link_data['cat_id'] = $this->cat_id;
}
$data['edit_url'] = $GLOBALS['phpgw']->link('/index.php',$link_data);
$data['delete_url'] = $GLOBALS['phpgw']->link('/index.php',$link_data);
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('cat_edit' => $data));
}
@ -354,15 +362,6 @@
{
$global_cats = get_var('global_cats',array('POST','GET'));
if ($GLOBALS['appname'])
{
$GLOBALS['phpgw_info']['flags']['app_header'] = lang($GLOBALS['appname']) . '&nbsp;' . lang('global categories') . ': ' . lang('delete category');
}
else
{
$GLOBALS['phpgw_info']['flags']['app_header'] = lang('global categories') . ': ' . lang('delete category');
}
$link_data = array
(
'menuaction' => 'admin.uicategories.index',
@ -370,24 +369,24 @@
'global_cats' => $global_cats
);
if (!$this->cat_id)
if ($_POST['cancel'] || !$this->cat_id)
{
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
}
if (get_var('confirm',array('POST')))
if ($_POST['delete'])
{
if (get_var('subs',array('POST')))
if ($_POST['subs'])
{
switch (get_var('subs',array('POST')))
switch ($_POST['subs'])
{
case 'move':
$this->bo->delete(array('cat_id' => $this->cat_id, 'modify_subs' => True));
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
break;
case 'drop':
$this->bo->delete(array('cat_id' => $this->cat_id, 'drop_subs' => True));
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
break;
default:
$error_msg = lang('Please choose one of the methods to handle the subcategories');
@ -397,26 +396,19 @@
else
{
$this->bo->delete(array('cat_id' => $this->cat_id));
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
}
}
$GLOBALS['phpgw']->xslttpl->add_file(array($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 'app_delete'));
if ($GLOBALS['appname'])
{
$type = 'noglobalapp';
}
else
{
$type = 'noglobal';
}
$GLOBALS['phpgw_info']['flags']['app_header'] = ($GLOBALS['appname']?lang($GLOBALS['appname']) . '&nbsp;':'') . lang('global categories') . ': ' . lang('delete category');
$type = ($GLOBALS['appname']?'noglobalapp':'noglobal');
$apps_cats = $this->bo->exists(array('type' => $type,
'cat_name' => '',
'cat_id' => $this->cat_id));
if ($apps_cats)
{
$lang_confirm_msg = lang('This category is currently being used by applications as a parent category. ')
@ -443,16 +435,15 @@
$data = array
(
'done_url' => $GLOBALS['phpgw']->link('/index.php',$link_data),
'lang_confirm_msg' => $lang_confirm_msg,
'lang_yes' => lang('yes'),
'subs' => $subs,
'lang_sub_select_move' => $lang_sub_select_move,
'lang_sub_select_drop' => $lang_sub_select_drop,
'lang_yes_statustext' => lang('Delete the entry'),
'lang_no_statustext' => lang('Back to the list'),
'lang_no' => lang('no'),
'lang_error_msg' => $error_msg
'lang_delete_msg' => $lang_confirm_msg,
'lang_delete' => lang('delete'),
'subs' => $subs,
'lang_sub_select_move' => $lang_sub_select_move,
'lang_sub_select_drop' => $lang_sub_select_drop,
'lang_delete_statustext' => lang('delete the category'),
'lang_cancel_statustext' => lang('do NOT delete the category and return back to the list'),
'lang_cancel' => lang('cancel'),
'lang_error_msg' => $error_msg
);
$link_data['menuaction'] = 'admin.uicategories.delete';

View File

@ -96,35 +96,30 @@
<!-- BEGIN cat_add -->
<xsl:template match="cat_add">
<tr>
<td height="50" valign="bottom">
<xsl:variable name="add_url"><xsl:value-of select="add_url"/></xsl:variable>
<xsl:variable name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
<form method="post" action="{$add_url}">
<input type="submit" name="add" value="{$lang_add}" onMouseout="window.status='';return true;">
<xsl:attribute name="onMouseover">
<xsl:text>window.status='</xsl:text>
<xsl:value-of select="lang_add_statustext"/>
<xsl:text>'; return true;</xsl:text>
</xsl:attribute>
</input>
</form>
<tr height="50" valign="bottom">
<xsl:variable name="action_url"><xsl:value-of select="action_url"/></xsl:variable>
<form method="post" action="{$action_url}">
<td colspan="2">
<xsl:variable name="lang_add"><xsl:value-of select="lang_add"/></xsl:variable>
<input type="submit" name="add" value="{$lang_add}" onMouseout="window.status='';return true;">
<xsl:attribute name="onMouseover">
<xsl:text>window.status='</xsl:text>
<xsl:value-of select="lang_add_statustext"/>
<xsl:text>'; return true;</xsl:text>
</xsl:attribute>
</input>
</td>
</tr>
<tr>
<td height="50" valign="bottom">
<xsl:variable name="done_url"><xsl:value-of select="done_url"/></xsl:variable>
<xsl:variable name="lang_done"><xsl:value-of select="lang_done"/></xsl:variable>
<form method="post" action="{$done_url}">
<input type="submit" name="done" value="{$lang_done}" onMouseout="window.status='';return true;">
<xsl:attribute name="onMouseover">
<xsl:text>window.status='</xsl:text>
<xsl:value-of select="lang_done_statustext"/>
<xsl:text>'; return true;</xsl:text>
</xsl:attribute>
</input>
</form>
<td colspan="3" align="right">
<xsl:variable name="lang_done"><xsl:value-of select="lang_done"/></xsl:variable>
<input type="submit" name="done" value="{$lang_done}" onMouseout="window.status='';return true;">
<xsl:attribute name="onMouseover">
<xsl:text>window.status='</xsl:text>
<xsl:value-of select="lang_done_statustext"/>
<xsl:text>'; return true;</xsl:text>
</xsl:attribute>
</input>
</td>
</form>
</tr>
</xsl:template>
@ -135,14 +130,14 @@
<xsl:template match="cat_edit">
<table cellpadding="2" cellspacing="2" align="center">
<tr>
<td colspan="2" align="center">
<td colspan="3" align="center">
<xsl:value-of select="message"/>
</td>
</tr>
<xsl:variable name="edit_url" select="edit_url"/>
<form method="post" action="{$edit_url}">
<tr>
<td width="23%">
<td width="23%" colspan="2">
<xsl:value-of select="lang_parent"/>
</td>
<td width="77%">
@ -150,7 +145,7 @@
</td>
</tr>
<tr>
<td><xsl:value-of select="lang_name"/>:</td>
<td colspan="2"><xsl:value-of select="lang_name"/>:</td>
<td><input name="values[name]" size="50" onMouseout="window.status='';return true;">
<xsl:attribute name="onMouseover">
<xsl:text>window.status='</xsl:text>
@ -164,7 +159,7 @@
</td>
</tr>
<tr>
<td valign="top"><xsl:value-of select="lang_descr"/>:</td>
<td colspan="2" valign="top"><xsl:value-of select="lang_descr"/>:</td>
<td><textarea cols="60" rows="10" name="values[descr]" wrap="virtual" onMouseout="window.status='';return true;">
<xsl:attribute name="onMouseover">
<xsl:text>window.status='</xsl:text>
@ -176,7 +171,7 @@
</td>
</tr>
<tr height="50">
<tr height="50" valign="bottom">
<td>
<xsl:variable name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
<xsl:variable name="old_parent"><xsl:value-of select="old_parent"/></xsl:variable>
@ -190,46 +185,26 @@
</input>
</td>
<td>
<xsl:choose>
<xsl:when test="action = 'add'">
<xsl:variable name="lang_reset" select="lang_reset"/>
<input type="reset" name="reset" value="{$lang_reset}"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>&nbsp;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="lang_apply" select="lang_apply"/>
<input type="reset" name="values[apply]" value="{$lang_apply}" onMouseout="window.status='';return true;">
<xsl:attribute name="onMouseover">
<xsl:text>window.status='</xsl:text>
<xsl:value-of select="lang_apply_statustext"/>
<xsl:text>'; return true;</xsl:text>
</xsl:attribute>
</input>
</td>
<td align="right">
<xsl:variable name="lang_cancel"><xsl:value-of select="lang_cancel"/></xsl:variable>
<input type="submit" name="values[cancel]" value="{$lang_cancel}" onMouseout="window.status='';return true;">
<xsl:attribute name="onMouseover">
<xsl:text>window.status='</xsl:text>
<xsl:value-of select="lang_cancel_statustext"/>
<xsl:text>'; return true;</xsl:text>
</xsl:attribute>
</input>
</td>
</tr>
</form>
<tr>
<td>
<xsl:variable name="done_url"><xsl:value-of select="done_url"/></xsl:variable>
<xsl:variable name="lang_done"><xsl:value-of select="lang_done"/></xsl:variable>
<form method="post" action="{$done_url}">
<input type="submit" name="values[done]" value="{$lang_done}" onMouseout="window.status='';return true;">
<xsl:attribute name="onMouseover">
<xsl:text>window.status='</xsl:text>
<xsl:value-of select="lang_done_statustext"/>
<xsl:text>'; return true;</xsl:text>
</xsl:attribute>
</input>
</form>
</td>
<td>
<xsl:choose>
<xsl:when test="action = 'edit'">
<xsl:variable name="delete_url"><xsl:value-of select="delete_url"/></xsl:variable>
<xsl:variable name="lang_delete"><xsl:value-of select="lang_delete"/></xsl:variable>
<form method="POST" action="{$delete_url}">
<input type="submit" name="values[delete]" value="{$lang_delete}"/>
</form>
</xsl:when>
<xsl:otherwise>
<xsl:text>&nbsp;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</table>
</xsl:template>

View File

@ -120,9 +120,13 @@
<xsl:template match="group_edit">
<table border="0" cellpadding="2" cellspacing="2" align="center" width="79%">
<tr>
<td><xsl:value-of select="error"/></td>
</tr>
<xsl:choose>
<xsl:when test="msgbox_data != ''">
<tr>
<td align="center"><xsl:call-template name="msgbox"/></td>
</tr>
</xsl:when>
</xsl:choose>
<tr>
<td valign="top">
<!-- {rows} -->

View File

@ -132,9 +132,13 @@
<xsl:template match="account_edit">
<table border="0" cellpadding="2" cellspacing="2" align="center" width="95%">
<tr>
<td><xsl:value-of select="error"/></td>
</tr>
<xsl:choose>
<xsl:when test="msgbox_data != ''">
<tr>
<td align="center" colspan="2"><xsl:call-template name="msgbox"/></td>
</tr>
</xsl:when>
</xsl:choose>
<tr>
<td valign="top">
<!-- {rows} -->
@ -149,7 +153,6 @@
<xsl:variable name="account_lastname" select="account_lastname"/>
<xsl:variable name="account_passwd" select="account_passwd"/>
<xsl:variable name="account_passwd_2" select="account_passwd_2"/>
<input type="hidden" name="values[account_id]" value="{$account_id}"/>
<tr class="row_on">
<td width="25%"><xsl:value-of select="lang_lid"/></td>
<td width="25%"><input type="text" name="values[account_lid]" value="{$account_lid}"/></td>
@ -198,11 +201,11 @@
<td><xsl:value-of select="lang_never"/></td>
<td>
<xsl:choose>
<xsl:when test="never_expires = 'yes'">
<input type="checkbox" name="values[never_expires]" value="True" checked="checked"/>
<xsl:when test="expires_never = 'yes'">
<input type="checkbox" name="values[expires_never]" value="True" checked="checked"/>
</xsl:when>
<xsl:otherwise>
<input type="checkbox" name="values[never_expires]" value="True"/>
<input type="checkbox" name="values[expires_never]" value="True"/>
</xsl:otherwise>
</xsl:choose>
</td>
@ -244,10 +247,10 @@
<xsl:variable name="account_id" select="account_id"/>
<xsl:choose>
<xsl:when test="selected != ''">
<option value="{$account_id}" selected="selected"><xsl:value-of select="account_name"/></option>
<option value="{$account_id}" selected="selected"><xsl:value-of select="account_lid"/></option>
</xsl:when>
<xsl:otherwise>
<option value="{$account_id}"><xsl:value-of select="account_name"/></option>
<option value="{$account_id}"><xsl:value-of select="account_lid"/></option>
</xsl:otherwise>
</xsl:choose>
</xsl:template>