mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:18:57 +01:00
Cleaned up much of the admin section, new account is now working and fixed a few problems with edit account. delete account still doesn't work
This commit is contained in:
parent
385a94f09e
commit
05d6bdbf64
@ -12,80 +12,94 @@
|
||||
/* $Id$ */
|
||||
|
||||
$phpgw_info = array();
|
||||
$phpgw_info["flags"] = array("currentapp" => "admin", "enable_nextmatchs_class" => True);
|
||||
include("../header.inc.php");
|
||||
include(PHPGW_APP_INC . "/accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
|
||||
$phpgw_info['flags'] = array('currentapp' => 'admin', 'enable_nextmatchs_class' => True);
|
||||
include('../header.inc.php');
|
||||
include(PHPGW_APP_INC . '/accounts_' . $phpgw_info['server']['account_repository'] . '.inc.php');
|
||||
|
||||
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
|
||||
|
||||
$p->set_file(array("list" => "accounts.tpl",
|
||||
"row" => "accounts_row.tpl"));
|
||||
$p->set_file(array(
|
||||
'list' => 'accounts.tpl',
|
||||
'row' => 'accounts_row.tpl',
|
||||
'empty_row' => 'accounts_row_empty.tpl'
|
||||
));
|
||||
|
||||
$total = account_total();
|
||||
|
||||
$p->set_var("bg_color",$phpgw_info["theme"]["bg_color"]);
|
||||
$p->set_var("th_bg",$phpgw_info["theme"]["th_bg"]);
|
||||
$p->set_var('bg_color',$phpgw_info['theme']['bg_color']);
|
||||
$p->set_var('th_bg',$phpgw_info['theme']['th_bg']);
|
||||
|
||||
$p->set_var("left_next_matchs",$phpgw->nextmatchs->left("accounts.php",$start,$total));
|
||||
$p->set_var("lang_user_accounts",lang("user accounts"));
|
||||
$p->set_var("right_next_matchs",$phpgw->nextmatchs->right("accounts.php",$start,$total));
|
||||
$p->set_var('left_next_matchs',$phpgw->nextmatchs->left('accounts.php',$start,$total));
|
||||
$p->set_var('lang_user_accounts',lang('user accounts'));
|
||||
$p->set_var('right_next_matchs',$phpgw->nextmatchs->right('accounts.php',$start,$total));
|
||||
|
||||
$p->set_var("lang_loginid",$phpgw->nextmatchs->show_sort_order($sort,"account_lid",$order,"accounts.php",lang("LoginID")));
|
||||
$p->set_var("lang_lastname",$phpgw->nextmatchs->show_sort_order($sort,"account_lastname",$order,"accounts.php",lang("last name")));
|
||||
$p->set_var("lang_firstname",$phpgw->nextmatchs->show_sort_order($sort,"account_firstname",$order,"accounts.php",lang("first name")));
|
||||
$p->set_var('lang_loginid',$phpgw->nextmatchs->show_sort_order($sort,'account_lid',$order,'accounts.php',lang('LoginID')));
|
||||
$p->set_var('lang_lastname',$phpgw->nextmatchs->show_sort_order($sort,'account_lastname',$order,'accounts.php',lang('last name')));
|
||||
$p->set_var('lang_firstname',$phpgw->nextmatchs->show_sort_order($sort,'account_firstname',$order,'accounts.php',lang('first name')));
|
||||
|
||||
$p->set_var("lang_edit",lang("Edit"));
|
||||
$p->set_var("lang_delete",lang("Delete"));
|
||||
$p->set_var("lang_view",lang("View"));
|
||||
$p->set_var('lang_edit',lang('Edit'));
|
||||
$p->set_var('lang_delete',lang('Delete'));
|
||||
$p->set_var('lang_view',lang('View'));
|
||||
|
||||
$account_info = account_read($method,$start,$sort,$order);
|
||||
$account_info = $phpgw->accounts->get_list('accounts',$start,$sort, $order, $query);
|
||||
|
||||
while (list($null,$account) = each($account_info)) {
|
||||
// while (list($key) = each($account_info[0])) {
|
||||
// for ($i=0; $i<count($account_info);$i++) {
|
||||
// echo "<br>0: " . $account_info[1][$key];
|
||||
// echo "<br>1: " . $a[2];
|
||||
// echo "<br>2: " . $b[1];
|
||||
if (! count($account_info))
|
||||
{
|
||||
$p->set_var('message',lang('No matchs found'));
|
||||
$p->parse('rows','empty_row',True);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$lastname = $account["account_lastname"];
|
||||
$firstname = $account["account_firstname"];
|
||||
$account_id = $account["account_id"];
|
||||
$loginid = $account["account_lid"];
|
||||
while (list($null,$account) = each($account_info))
|
||||
{
|
||||
|
||||
$lastname = $account['account_lastname'];
|
||||
$firstname = $account['account_firstname'];
|
||||
$account_id = $account['account_id'];
|
||||
$loginid = $account['account_lid'];
|
||||
|
||||
$phpgw->nextmatchs->template_alternate_row_color(&$p);
|
||||
|
||||
if (! $lastname)
|
||||
{
|
||||
$lastname = ' ';
|
||||
}
|
||||
|
||||
if (! $firstname)
|
||||
{
|
||||
$firstname = ' ';
|
||||
}
|
||||
|
||||
$p->set_var('row_loginid',$loginid);
|
||||
$p->set_var('row_firstname',$firstname);
|
||||
$p->set_var('row_lastname',$lastname);
|
||||
$p->set_var('row_edit','<a href="'.$phpgw->link('editaccount.php','account_id='
|
||||
. $account_id) . '"> ' . lang('Edit') . ' </a>');
|
||||
|
||||
if ($phpgw_info['user']['userid'] != $account['account_lid'])
|
||||
{
|
||||
$p->set_var('row_delete','<a href="' . $phpgw->link('deleteaccount.php','account_id='
|
||||
. $account_id) . '"> '.lang('Delete').' </a>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$p->set_var('row_delete',' ');
|
||||
}
|
||||
|
||||
$p->set_var('row_view','<a href="' . $phpgw->link("viewaccount.php", "account_id="
|
||||
. $account_id) . '"> ' . lang("View") . ' </a>');
|
||||
|
||||
$p->parse('rows','row',True);
|
||||
}
|
||||
} // End else
|
||||
|
||||
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
||||
$p->set_var("tr_color",$tr_color);
|
||||
$p->set_var('actionurl',$phpgw->link("newaccount.php"));
|
||||
$p->set_var('accounts_url',$phpgw->link("accounts.php"));
|
||||
$p->set_var('lang_add',lang("add"));
|
||||
$p->set_var('lang_search',lang("search"));
|
||||
|
||||
// $lastname = $account["account_lastname"];
|
||||
// $firstname = $account["account_firstname"];
|
||||
$p->pparse('out','list');
|
||||
|
||||
if (! $lastname) $lastname = ' ';
|
||||
if (! $firstname) $firstname = ' ';
|
||||
|
||||
$p->set_var("row_loginid",$loginid);
|
||||
$p->set_var("row_firstname",$firstname);
|
||||
$p->set_var("row_lastname",$lastname);
|
||||
$p->set_var("row_edit",'<a href="'.$phpgw->link("editaccount.php","account_id="
|
||||
. $account_id) . '"> ' . lang("Edit") . ' </a>');
|
||||
|
||||
if ($phpgw_info["user"]["userid"] != $account["account_lid"]) {
|
||||
$p->set_var("row_delete",'<a href="' . $phpgw->link("deleteaccount.php",'account_id='
|
||||
. $account_id) . '"> '.lang("Delete").' </a>');
|
||||
} else {
|
||||
$p->set_var("row_delete"," ");
|
||||
}
|
||||
|
||||
$p->set_var("row_view",'<a href="' . $phpgw->link("viewaccount.php", "account_id="
|
||||
. $account_id) . '"> ' . lang("View") . ' </a>');
|
||||
|
||||
$p->parse("rows","row",True);
|
||||
}
|
||||
|
||||
$p->set_var("actionurl",$phpgw->link("newaccount.php"));
|
||||
$p->set_var("lang_add",lang("add"));
|
||||
$p->set_var("lang_search",lang("search"));
|
||||
|
||||
$p->pparse("out","list");
|
||||
|
||||
account_close();
|
||||
$phpgw->common->phpgw_footer();
|
||||
$phpgw->common->phpgw_footer();
|
||||
?>
|
||||
|
@ -103,11 +103,11 @@
|
||||
|
||||
if ($userData["status"])
|
||||
{
|
||||
$t->set_var("account_checked","checked");
|
||||
$t->set_var('account_status','checked');
|
||||
}
|
||||
else
|
||||
{
|
||||
$t->set_var("account_checked","");
|
||||
$t->set_var('account_status','');
|
||||
}
|
||||
$t->set_var("n_firstname_value",$userData["firstname"]);
|
||||
$t->set_var("n_lastname_value",$userData["lastname"]);
|
||||
|
@ -52,110 +52,105 @@
|
||||
$error[$totalerrors++] = "<br>" . lang("You must add at least 1 permission or group to this account");
|
||||
}
|
||||
|
||||
if (account_exsists($n_loginid)) {
|
||||
if ($phpgw->accounts->exists($n_loginid)) {
|
||||
$error[$totalerrors++] = lang("That loginid has already been taken");
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$phpgw->db->lock(array("accounts","preferences","phpgw_sessions","phpgw_acl","applications"));
|
||||
if (! $error)
|
||||
{
|
||||
$phpgw->db->lock(array(
|
||||
'phpgw_accounts',
|
||||
'phpgw_preferences',
|
||||
'phpgw_sessions',
|
||||
'phpgw_acl',
|
||||
'phpgw_applications'
|
||||
));
|
||||
$phpgw->accounts->create('u', $n_loginid, $n_passwd, $n_firstname, $n_lastname, $n_account_status);
|
||||
|
||||
$cd = account_add(array("loginid" => $n_loginid, "firstname" => $n_firstname,
|
||||
"lastname" => $n_lastname, "passwd" => $n_passwd));
|
||||
|
||||
$phpgw->db->query("SELECT account_id FROM accounts WHERE account_lid='$n_loginid'",__LINE__,__FILE__);
|
||||
$phpgw->db->next_record();
|
||||
$account_id = intval($phpgw->db->f("account_id"));
|
||||
$apps = CreateObject('phpgwapi.applications',array($account_id,'u'));
|
||||
$apps->read_installed_apps();
|
||||
$account_id = $phpgw->accounts->name2id($n_loginid);
|
||||
|
||||
// Read Group Apps
|
||||
if ($n_groups) {
|
||||
$apps->account_type = 'g';
|
||||
reset($n_groups);
|
||||
while($groups = each($n_groups)) {
|
||||
$apps->account_id = $groups[0];
|
||||
$old_app_groups = $apps->read_account_specific();
|
||||
@reset($old_app_groups);
|
||||
while($old_group_app = each($old_app_groups)) {
|
||||
if(!$apps_after[$old_group_app[0]]) {
|
||||
$apps_after[$old_group_app[0]] = $old_app_groups[$old_group_app[0]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$apps = CreateObject('phpgwapi.applications',array($account_id,'u'));
|
||||
$apps->read_installed_apps();
|
||||
|
||||
// Read Group Apps
|
||||
if ($n_groups)
|
||||
{
|
||||
$apps->account_type = 'g';
|
||||
reset($n_groups);
|
||||
while($groups = each($n_groups))
|
||||
{
|
||||
$apps->account_id = $groups[0];
|
||||
$old_app_groups = $apps->read_account_specific();
|
||||
@reset($old_app_groups);
|
||||
while($old_group_app = each($old_app_groups))
|
||||
{
|
||||
if (!$apps_after[$old_group_app[0]])
|
||||
{
|
||||
$apps_after[$old_group_app[0]] = $old_app_groups[$old_group_app[0]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$apps->account_type = 'u';
|
||||
$apps->account_id = $account_id;
|
||||
$apps->account_apps = Array(Array());
|
||||
@reset($new_permissions);
|
||||
while($app = each($new_permissions)) {
|
||||
if($app[1]) {
|
||||
$apps->add_app($app[0]);
|
||||
if(!$apps_after[$app[0]]) {
|
||||
$apps_after[] = $app[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
$apps->save_apps();
|
||||
$apps->account_type = 'u';
|
||||
$apps->account_id = $account_id;
|
||||
$apps->account_apps = Array(Array());
|
||||
@reset($new_permissions);
|
||||
while ($app = each($new_permissions))
|
||||
{
|
||||
if ($app[1])
|
||||
{
|
||||
$apps->add($app[0]);
|
||||
if (!$apps_after[$app[0]])
|
||||
{
|
||||
$apps_after[] = $app[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
$apps->save_repository();
|
||||
|
||||
// Assign user to groups
|
||||
for($i=0;$i<count($n_groups);$i++) {
|
||||
$phpgw->acl->add("phpgw_group",$n_groups[$i],$account_id,'u',1);
|
||||
}
|
||||
// Assign user to groups
|
||||
for ($i=0;$i<count($n_groups);$i++)
|
||||
{
|
||||
$phpgw->acl->add_repository('phpgw_group',$n_groups[$i],$account_id,'u',1);
|
||||
}
|
||||
|
||||
$pref = CreateObject('phpgwapi.preferences',$account_id);
|
||||
$phpgw->common->hook_single("add_def_pref", "admin");
|
||||
while($apps = each($apps_after)) {
|
||||
if($apps[0]<>"admin")
|
||||
$phpgw->common->hook_single("add_def_pref", $apps[0]);
|
||||
}
|
||||
$pref->commit();
|
||||
$pref = CreateObject('phpgwapi.preferences',$account_id);
|
||||
$phpgw->common->hook_single('add_def_pref','admin');
|
||||
while ($apps = each($apps_after))
|
||||
{
|
||||
if ($apps[0] != 'admin')
|
||||
{
|
||||
$phpgw->common->hook_single('add_def_pref', $apps[0]);
|
||||
}
|
||||
}
|
||||
$pref->save_repository(False);
|
||||
|
||||
$apps->account_apps = Array(Array());
|
||||
$apps_after = Array(Array());
|
||||
$apps->account_apps = Array(Array());
|
||||
$apps_after = Array(Array());
|
||||
|
||||
// Read new Group ID's
|
||||
$new_groups = $phpgw->accounts->read_groups($account_id);
|
||||
// Read new Group Apps
|
||||
if ($new_groups) {
|
||||
$apps->account_type = 'g';
|
||||
reset($new_groups);
|
||||
while($groups = each($new_groups)) {
|
||||
$apps->account_id = intval($groups[0]);
|
||||
$new_app_groups = $apps->read_account_specific();
|
||||
@reset($new_app_groups);
|
||||
while($new_group_app = each($new_app_groups)) {
|
||||
if(!$apps_after[$new_group_app[0]]) {
|
||||
$apps_after[$new_group_app[0]] = $new_app_groups[$new_group_app[0]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$phpgw->db->unlock();
|
||||
|
||||
$apps->account_type = 'u';
|
||||
$apps->account_id = $account_id;
|
||||
$new_app_user = $apps->read_account_specific();
|
||||
while($new_user_app = each($new_app_user)) {
|
||||
if(!$apps_after[$new_user_app[0]]) {
|
||||
$apps_after[$new_user_app[0]] = $new_app_user[$new_user_app[0]];
|
||||
}
|
||||
}
|
||||
|
||||
// start inlcuding other admin tools
|
||||
/* // start inlcuding other admin tools
|
||||
while($app = each($apps_after))
|
||||
{
|
||||
$phpgw->common->hook_single('add_user_data', $value);
|
||||
}
|
||||
|
||||
*/
|
||||
Header('Location: ' . $phpgw->link('accounts.php','cd='.$cd));
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = 'A';
|
||||
}
|
||||
|
||||
$phpgw->template->set_file(array("form" => "account_form.tpl"));
|
||||
$phpgw->template->set_file(array('form' => 'account_form.tpl'));
|
||||
$phpgw->template->set_unknowns('remove');
|
||||
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
|
||||
$phpgw->template->set_var("lang_action",lang("Add new account"));
|
||||
|
||||
@ -171,6 +166,12 @@
|
||||
|
||||
$phpgw->template->set_var("form_action",$phpgw->link("newaccount.php"));
|
||||
$phpgw->template->set_var("lang_loginid",lang("LoginID"));
|
||||
|
||||
if ($status)
|
||||
{
|
||||
$phpgw->template->set_var('account_status',' checked');
|
||||
}
|
||||
|
||||
$phpgw->template->set_var("n_loginid_value",$n_loginid);
|
||||
|
||||
$phpgw->template->set_var("lang_account_active",lang("Account active"));
|
||||
@ -188,17 +189,21 @@
|
||||
$phpgw->template->set_var("n_lastname_value",$n_lastname);
|
||||
|
||||
$phpgw->template->set_var("lang_groups",lang("Groups"));
|
||||
$group_select = '<select name="n_groups[]" multiple>';
|
||||
$phpgw->db->query("select * from groups");
|
||||
while ($phpgw->db->next_record()) {
|
||||
$group_select .= "<option value=\"" . $phpgw->db->f("group_id") . "\"";
|
||||
if ($n_groups[$phpgw->db->f("group_id")]) {
|
||||
$group_select .= " selected";
|
||||
}
|
||||
$group_select .= ">" . $phpgw->db->f("group_name") . "</option>";
|
||||
}
|
||||
$group_select .= "</select>";
|
||||
$phpgw->template->set_var("groups_select",$group_select);
|
||||
|
||||
|
||||
// groups list
|
||||
$groups_select = '<select name="n_groups[]" multiple>';
|
||||
|
||||
$groups = $phpgw->accounts->get_list('groups');
|
||||
|
||||
while (list(,$group) = each($groups))
|
||||
{
|
||||
$groups_select .= '<option value="' . $group['account_id'] . '"';
|
||||
$groups_select .= ">" . $group["account_lid"] . "</option>\n";
|
||||
}
|
||||
$groups_select .= '</select>';
|
||||
$phpgw->template->set_var('groups_select',$groups_select);
|
||||
// end groups list
|
||||
|
||||
$phpgw->template->set_var("","");
|
||||
$i = 0;
|
||||
@ -257,7 +262,7 @@
|
||||
if (!$includedSomething) $phpgw->template->set_var("gui_hooks","");
|
||||
|
||||
$phpgw->template->set_var("lang_button",Lang("Add"));
|
||||
$phpgw->template->pparse("out","form");
|
||||
echo $phpgw->template->finish($phpgw->template->parse("out","form"));
|
||||
|
||||
account_close();
|
||||
$phpgw->common->phpgw_footer();
|
||||
|
@ -56,13 +56,19 @@
|
||||
$apps = CreateObject('phpgwapi.applications',intval($group_id));
|
||||
$apps->update_data(Array());
|
||||
@reset($n_group_permissions);
|
||||
while($app = each($n_group_permissions)) {
|
||||
if($app[1]) {
|
||||
$apps->add($app[0]);
|
||||
$new_apps[] = $app[0];
|
||||
}
|
||||
}
|
||||
$apps->save_repository();
|
||||
|
||||
if (count($n_group_permissions))
|
||||
{
|
||||
while($app = each($n_group_permissions))
|
||||
{
|
||||
if ($app[1])
|
||||
{
|
||||
$apps->add($app[0]);
|
||||
$new_apps[] = $app[0];
|
||||
}
|
||||
}
|
||||
$apps->save_repository();
|
||||
}
|
||||
|
||||
$acl = CreateObject('phpgwapi.acl',$group_id);
|
||||
$acl->read_repository();
|
||||
|
@ -12,7 +12,7 @@
|
||||
<td>{lang_loginid}</td>
|
||||
<td><input name="account_lid" value="{n_loginid_value}"></td>
|
||||
<td colspan="2" align="center">
|
||||
{lang_account_active}: <input type="checkbox" name="status" value="A" {account_checked}>
|
||||
{lang_account_active}: <input type="checkbox" name="status" value="A"{account_status}>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
<input type="submit" value="{lang_add}"></form>
|
||||
</td>
|
||||
<td align="right">
|
||||
<form action="accounts.php">
|
||||
<form method="POST" action="{accounts_url}">
|
||||
{lang_search}
|
||||
<input name="query">
|
||||
</form>
|
||||
|
6
admin/templates/default/accounts_row_empty.tpl
Normal file
6
admin/templates/default/accounts_row_empty.tpl
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
<!-- BEGIN row -->
|
||||
<tr>
|
||||
<td colspan="5" align="center">{message}</td>
|
||||
</tr>
|
||||
<!-- END row -->
|
@ -10,17 +10,17 @@
|
||||
|
||||
<tr bgcolor="{tr_color1}">
|
||||
<td>{lang_loginid}</td>
|
||||
<td><input name="n_loginid" value="{n_loginid_value}"></td>
|
||||
<td><input name="account_lid" value="{n_loginid_value}"></td>
|
||||
<td colspan="2" align="center">
|
||||
{lang_account_active}: <input type="checkbox" name="n_account_status" value="A" {account_checked}>
|
||||
{lang_account_active}: <input type="checkbox" name="status" value="A"{account_status}>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr bgcolor="{tr_color2}">
|
||||
<td>{lang_firstname}</td>
|
||||
<td><input name="n_firstname" value="{n_firstname_value}"></td>
|
||||
<td><input name="firstname" value="{n_firstname_value}"></td>
|
||||
<td>{lang_lastname}</td>
|
||||
<td><input name="n_lastname" value="{n_lastname_value}"></td>
|
||||
<td><input name="lastname" value="{n_lastname_value}"></td>
|
||||
</tr>
|
||||
|
||||
<tr bgcolor="{tr_color1}">
|
||||
|
@ -31,7 +31,7 @@
|
||||
<input type="submit" value="{lang_add}"></form>
|
||||
</td>
|
||||
<td align="right">
|
||||
<form action="accounts.php">
|
||||
<form method="POST" action="{accounts_url}">
|
||||
{lang_search}
|
||||
<input name="query">
|
||||
</form>
|
||||
|
6
admin/templates/verdilak/accounts_row_empty.tpl
Normal file
6
admin/templates/verdilak/accounts_row_empty.tpl
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
<!-- BEGIN row -->
|
||||
<tr>
|
||||
<td colspan="5" align="center">{message}</td>
|
||||
</tr>
|
||||
<!-- END row -->
|
Loading…
Reference in New Issue
Block a user