forked from extern/egroupware
More work on the SQL version of the admin section, editing accounts is now working
This commit is contained in:
parent
f9fe837aa5
commit
b592122f3c
@ -17,9 +17,14 @@
|
||||
$phpgw_info["flags"]["disable_message_class"] = True;
|
||||
$phpgw_info["flags"]["disable_send_class"] = True;
|
||||
include("../header.inc.php");
|
||||
if (! $account_id)
|
||||
Header("Location: " . $phpgw->link("accounts.php"));
|
||||
include($phpgw_info["server"]["server_root"] . "/admin/inc/accounts_"
|
||||
. $phpgw_info["server"]["auth_type"] . ".inc.php");
|
||||
|
||||
if (! $account_id) {
|
||||
Header("Location: " . $phpgw->link("accounts.php"));
|
||||
}
|
||||
|
||||
// This function is gonna go soon. (jengo)
|
||||
function change_owner($app,$table,$field,$new,$old)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
@ -30,30 +35,42 @@
|
||||
}
|
||||
|
||||
if ($submit) {
|
||||
$phpgw->db->query("select account_lid from accounts where account_id=$account_id");
|
||||
$phpgw->db->next_record();
|
||||
$lid = $phpgw->db->f("account_lid");
|
||||
if ($old_loginid != $n_loginid) {
|
||||
if (account_exsists($n_loginid)) {
|
||||
$error .= "<br>" . lang("That loginid has already been taken");
|
||||
}
|
||||
$c_loginid = $n_loginid;
|
||||
$n_loginid = $old_loginid;
|
||||
}
|
||||
|
||||
if ($n_passwd || $n_passwd_2) {
|
||||
if ($n_passwd != $n_passwd_2) {
|
||||
$error .= lang("The two passwords are not the same");
|
||||
}
|
||||
if (! $n_passwd){
|
||||
$error .= lang("You must enter a password");
|
||||
}
|
||||
}
|
||||
|
||||
if ($n_passwd || $n_passwd_2) {
|
||||
if ($n_passwd != $n_passwd_2){
|
||||
$error .= lang("The two passwords are not the same");
|
||||
}
|
||||
if (! $n_passwd){
|
||||
$error .= lang("You must enter a password");
|
||||
}
|
||||
}
|
||||
if (count($new_permissions) == 0){
|
||||
$error .= "<br>" . lang("You must add at least 1 permission to this account");
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
$cd = account_edit(array("loginid" => $n_loginid, "permissions" => $new_permissions,
|
||||
"firstname" => $n_firstname, "lastname" => $n_lastname,
|
||||
"passwd" => $n_passwd, "account_status" => $account_status,
|
||||
"c_loginid" => $c_loginid,
|
||||
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
|
||||
}
|
||||
|
||||
if ($lid != $n_loginid) {
|
||||
$phpgw->db->query("select account_lid from accounts where account_lid='$n_loginid'");
|
||||
if ($phpgw->db->num_rows() != 0) {
|
||||
$error .= "<br>" . lang("That loginid has already been taken");
|
||||
}
|
||||
}
|
||||
|
||||
// $phpgw->db->query("select account_lid from accounts where account_id=$account_id");
|
||||
// $phpgw->db->next_record();
|
||||
// $lid = $phpgw->db->f("account_lid");
|
||||
|
||||
if (count($new_permissions) == 0){
|
||||
$error .= "<br>" . lang("You must add at least 1 permission to this account");
|
||||
}
|
||||
if (! $error) {
|
||||
|
||||
/* if (! $error) {
|
||||
$phpgw->db->lock(array('accounts','preferences','sessions'));
|
||||
if ($n_passwd) {
|
||||
$phpgw->db->query("update accounts set account_pwd='" . md5($n_passwd) . "', "
|
||||
@ -66,12 +83,8 @@
|
||||
$phpgw->accounts->add_app($permission[0]);
|
||||
}
|
||||
}
|
||||
//$phpgw->permissions->add("hr");
|
||||
|
||||
if ($new_permissions["anonymous"] && ! $new_permissions["admin"]){
|
||||
$phpgw->accounts->add_app("anonymous");
|
||||
}
|
||||
if (! $n_account_status){
|
||||
if (! $n_account_status) {
|
||||
$n_account_status = "L";
|
||||
}
|
||||
$cd = 27;
|
||||
@ -108,7 +121,7 @@
|
||||
$phpgw->db->unlock();
|
||||
Header("Location: " . $phpgw->link("accounts.php", "cd=$cd"));
|
||||
exit;
|
||||
} // if ! $error
|
||||
} // if ! $error */
|
||||
} // if $submit
|
||||
|
||||
$phpgw->common->phpgw_header();
|
||||
@ -124,6 +137,7 @@
|
||||
?>
|
||||
<form method="POST" action="<?php echo $phpgw->link("editaccount.php"); ?>">
|
||||
<input type="hidden" name="account_id" value="<? echo $account_id; ?>">
|
||||
<input type="hidden" name="old_loginid" value="<? echo $phpgw->db->f("account_lid"); ?>">
|
||||
<?php
|
||||
if ($error) {
|
||||
echo "<center>" . lang("Error") . ":$error</center>";
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
function account_list($start,$sort,$order)
|
||||
function account_read($method,$start,$sort,$order)
|
||||
{
|
||||
|
||||
}
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
}
|
||||
|
||||
function account_edit($account_id,$account_info)
|
||||
function account_edit($account_info)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
function account_list($start,$sort,$order)
|
||||
function account_read($method,$start,$sort,$order)
|
||||
{
|
||||
|
||||
}
|
||||
@ -66,9 +66,71 @@
|
||||
return $cd;
|
||||
}
|
||||
|
||||
function account_edit($account_id,$account_info)
|
||||
function account_edit($account_info)
|
||||
{
|
||||
global $phpgw_info, $phpgw;
|
||||
|
||||
$phpgw->db->lock(array('accounts','preferences','sessions'));
|
||||
|
||||
if ($account_info["c_loginid"]) {
|
||||
$phpgw->db->query("update accounts set account_lid='" . $account_info["c_loginid"]
|
||||
. "' where account_lid='" . $account_info["loginid"] . "'");
|
||||
|
||||
$account_info["loginid"] = $account_info["c_loginid"];
|
||||
}
|
||||
|
||||
if ($account_info["passwd"]) {
|
||||
$phpgw->db->query("update accounts set account_pwd='" . md5($account_info["passwd"]) . "', "
|
||||
. "account_lastpwd_change='" . time() . "' where account_lid='"
|
||||
. $account_info["loginid"] . "'");
|
||||
$phpgw->db->query("update sessions set session_pwd='" . addslashes($account_info["passwd"])
|
||||
. "' where session_lid='" . $account_info["loginid"] . "'");
|
||||
}
|
||||
|
||||
while ($permission = each($account_info["permissions"])) {
|
||||
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
||||
$phpgw->accounts->add_app($permission[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $account_info["account_status"]) {
|
||||
$account_info["account_status"] = "L";
|
||||
}
|
||||
$cd = 27;
|
||||
|
||||
// If they changed there loginid, we need to change the owner in ALL
|
||||
// tables to reflect on the new one
|
||||
if ($lid != $account_info["loginid"]) {
|
||||
change_owner("","preferences","preference_owner",$account_info["loginid"],$lid);
|
||||
change_owner("addressbook","addressbook","ab_owner",$account_info["loginid"],$lid);
|
||||
change_owner("todo","todo","todo_owner",$account_info["loginid"],$lid);
|
||||
change_owner("","accounts","account_lid",$account_info["loginid"],$lid);
|
||||
change_owner("","sessions","session_lid",$account_info["loginid"],$lid);
|
||||
change_owner("calendar","webcal_entry","cal_create_by",$account_info["loginid"],$lid);
|
||||
change_owner("calendar","webcal_entry_user","cal_login",$account_info["loginid"],$lid);
|
||||
|
||||
if ($lid != $n_loginid) {
|
||||
$sep = $phpgw->common->filesystem_separator();
|
||||
|
||||
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
||||
|
||||
if (! @rename($basedir . $lid, $basedir . $account_info["loginid"])) {
|
||||
$cd = 35;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$phpgw->db->query("update accounts set account_firstname='"
|
||||
. addslashes($account_info["firstname"]) . "', account_lastname='"
|
||||
. addslashes($account_info["lastname"]) . "', account_permissions='"
|
||||
. $phpgw->accounts->add_app("",True) . "', account_status='"
|
||||
. $account_info["account_status"] . "', account_groups='"
|
||||
. $account_info["groups"] . "' where account_lid='" . $account_info["loginid"]
|
||||
. "'");
|
||||
|
||||
$phpgw->db->unlock();
|
||||
|
||||
return $cd;
|
||||
}
|
||||
|
||||
function account_delete($account_id)
|
||||
|
@ -11,8 +11,9 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True, "disable_message_class" => True,
|
||||
"disable_send_class" => True, "currentapp" => "admin");
|
||||
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True,
|
||||
"disable_message_class" => True, "disable_send_class" => True,
|
||||
"currentapp" => "admin");
|
||||
|
||||
include("../header.inc.php");
|
||||
include($phpgw_info["server"]["server_root"] . "/admin/inc/accounts_"
|
||||
|
Loading…
Reference in New Issue
Block a user