Started fixing edit account

This commit is contained in:
jengo 2000-12-26 06:30:51 +00:00
parent 7cea5beeb0
commit d30890881a
4 changed files with 96 additions and 90 deletions

View File

@ -54,7 +54,7 @@
} }
if (! $totalerrors) { if (! $totalerrors) {
$phpgw->db->query("SELECT account_permissions FROM accounts WHERE account_id = ".$account_id); $phpgw->db->query("SELECT account_permissions FROM accounts WHERE account_lid='" . $old_loginid . "'",__LINE__,__FILE__);
$phpgw->db->next_record(); $phpgw->db->next_record();
$apps_before = $phpgw->db->f("account_permissions"); $apps_before = $phpgw->db->f("account_permissions");
@ -79,11 +79,18 @@
"old_loginid" => $old_loginid, "account_id" => rawurldecode($account_id), "old_loginid" => $old_loginid, "account_id" => rawurldecode($account_id),
"groups" => $phpgw->accounts->groups_array_to_string($n_groups))); "groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
// If the user is logged in, it will force a refresh of the session_info
$phpgw->db->query("update phpgw_sessions set session_info='' where session_lid='$new_loginid@" . $phpgw_info["user"]["domain"] . "'",__LINE__,__FILE__);
// The following sets any default preferences needed for new applications.. // The following sets any default preferences needed for new applications..
// This is smart enough to know if previous preferences were selected, use them. // This is smart enough to know if previous preferences were selected, use them.
if (count($new_apps)) { if (count($new_apps)) {
$phpgw->db->query("select account_id from accounts where account_lid='$new_loginid'",__LINE__,__FILE__);
$phpgw->db->next_record();
$users_account_id = $phpgw->db->f("account_id");
if ($account_id <> $phpgw_info["user"]["account_id"]) { if ($account_id <> $phpgw_info["user"]["account_id"]) {
$phpgw->db->query("SELECT preference_value FROM preferences WHERE preference_owner=".$account_id,__FILE__,__LINE__); $phpgw->db->query("SELECT preference_value FROM preferences WHERE preference_owner='$users_account_id'",__FILE__,__LINE__);
$phpgw->db->next_record(); $phpgw->db->next_record();
$phpgw_newuser["user"]["preferences"] = unserialize($phpgw->db->f("preference_value")); $phpgw_newuser["user"]["preferences"] = unserialize($phpgw->db->f("preference_value"));
} else { } else {
@ -98,7 +105,7 @@
} }
if ($docommit) { if ($docommit) {
if ($account_id <> $phpgw_info["user"]["account_id"]) { if ($account_id <> $phpgw_info["user"]["account_id"]) {
$phpgw->preferences->commit_user($account_id); $phpgw->preferences->commit_user($users_account_id);
} else { } else {
$phpgw_info["user"]["preferences"] = $phpgw_newuser["user"]["preferences"]; $phpgw_info["user"]["preferences"] = $phpgw_newuser["user"]["preferences"];
unset($phpgw_newuser); unset($phpgw_newuser);
@ -149,10 +156,11 @@
$phpgw->template->set_var("n_loginid_value",$n_loginid); $phpgw->template->set_var("n_loginid_value",$n_loginid);
$phpgw->template->set_var("lang_account_active",lang("Account active")); $phpgw->template->set_var("lang_account_active",lang("Account active"));
if ($userData["status"]) if ($userData["status"]) {
$phpgw->template->set_var("account_checked","checked"); $phpgw->template->set_var("account_checked","checked");
else } else {
$phpgw->template->set_var("account_checked",""); $phpgw->template->set_var("account_checked","");
}
$phpgw->template->set_var("lang_password",lang("Password")); $phpgw->template->set_var("lang_password",lang("Password"));
$phpgw->template->set_var("n_passwd_value",$n_passwd); $phpgw->template->set_var("n_passwd_value",$n_passwd);

View File

@ -197,14 +197,14 @@
. addslashes($account_info["lastname"]) . "','" . $phpgw->accounts->add_app("",True) . addslashes($account_info["lastname"]) . "','" . $phpgw->accounts->add_app("",True)
. "','" . $account_info["groups"] . "','A',0)"; . "','" . $account_info["groups"] . "','A',0)";
$phpgw->db->query($sql); $phpgw->db->query($sql,__LINE__,__FILE__);
$phpgw->db->unlock(); $phpgw->db->unlock();
$sep = $phpgw->common->filesystem_separator(); $sep = $phpgw->common->filesystem_separator();
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep; $basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
if (! mkdir($basedir . $account_info["loginid"], 0707)) { if (! @mkdir($basedir . $account_info["loginid"], 0707)) {
$cd = 36; $cd = 36;
} else { } else {
$cd = 28; $cd = 28;
@ -215,7 +215,7 @@
function account_edit($account_info) function account_edit($account_info)
{ {
global $phpgw, $phpgw_info, $ldap; global $phpgw, $phpgw_info, $ldap, $new_loginid;
// This is just until the API fully handles reading the LDAP account info. // This is just until the API fully handles reading the LDAP account info.
@ -229,7 +229,7 @@
$entry["mail"] = $account_info["loginid"] . "@" . $phpgw_info["server"]["mail_suffix"]; $entry["mail"] = $account_info["loginid"] . "@" . $phpgw_info["server"]["mail_suffix"];
$phpgw->db->query("update accounts set account_lid='" . $account_info["loginid"] . "' " $phpgw->db->query("update accounts set account_lid='" . $account_info["loginid"] . "' "
. "where account_lid='" . $account_info["old_loginid"] . "'"); . "where account_lid='" . $account_info["old_loginid"] . "'",__LINE__,__FILE__);
} }
if ($account_info["passwd"]) { if ($account_info["passwd"]) {
@ -237,7 +237,7 @@
// Update the sessions table. (The user might be logged in) // Update the sessions table. (The user might be logged in)
$phpgw->db->query("update sessions set session_pwd='" . $phpgw->common->encrypt($n_passwd) . "' " $phpgw->db->query("update sessions set session_pwd='" . $phpgw->common->encrypt($n_passwd) . "' "
. "where session_lid='$lid'"); . "where session_lid='$lid'",__LINE__,__FILE__);
} }
while ($permission = each($account_info["permissions"])) { while ($permission = each($account_info["permissions"])) {
@ -256,15 +256,16 @@
$dn = $account_info["account_id"]; $dn = $account_info["account_id"];
@ldap_modify($ldap, $dn, $entry); @ldap_modify($ldap, $dn, $entry);
$phpgw->db->query("update accounts set account_firstname='". $account_info["firstname"] ."', $phpgw->db->query("update accounts set account_firstname='". $account_info["firstname"] ."',"
account_lastname='". $account_info["lastname"] ."', . "account_lastname='". $account_info["lastname"] ."',"
account_permissions='". $phpgw->accounts->add_app("",True) . "', . "account_permissions='". $phpgw->accounts->add_app("",True) . "', "
account_status='". $account_info["account_status"] . "', . "account_status='". $account_info["account_status"] . "', "
account_groups='". $account_info["groups"] . "' . "account_groups='". $account_info["groups"] . "'"
where account_lid='" . $account_info["loginid"]. "'"); . "where account_lid='" . $account_info["loginid"]. "'",__LINE__,__FILE__);
$cd = 27; $cd = 27;
$new_loginid = $account_info["loginid"];
if ($account_info["old_loginid"] != $account_info["loginid"]) { if ($account_info["old_loginid"] != $account_info["loginid"]) {
$sep = $phpgw->common->filesystem_separator(); $sep = $phpgw->common->filesystem_separator();
@ -302,7 +303,7 @@
// set $account_id to uidnumber for sql // set $account_id to uidnumber for sql
$account_id = $allValues[0]["uidnumber"][0]; $account_id = $allValues[0]["uidnumber"][0];
$phpgw->db->query("select account_lid from accounts where account_id=$account_id"); $phpgw->db->query("select account_lid from accounts where account_id=$account_id",__LINE__,__FILE__);
$phpgw->db->next_record(); $phpgw->db->next_record();
$lid = $phpgw->db->f(0); $lid = $phpgw->db->f(0);
@ -312,10 +313,10 @@
$phpgw->db->lock($table_locks); $phpgw->db->lock($table_locks);
$phpgw->db->query("delete from todo where todo_owner='".$account_id."'"); $phpgw->db->query("delete from todo where todo_owner='".$account_id."'",__LINE__,__FILE__);
$phpgw->db->query("delete from addressbook where ab_owner='".$account_id."'"); $phpgw->db->query("delete from addressbook where ab_owner='".$account_id."'",__LINE__,__FILE__);
$phpgw->db->query("delete from accounts where account_id='".$account_id."'"); $phpgw->db->query("delete from accounts where account_id='".$account_id."'",__LINE__,__FILE__);
$phpgw->db->query("delete from preferences where preference_owner='".$account_id."'"); $phpgw->db->query("delete from preferences where preference_owner='".$account_id."'",__LINE__,__FILE__);
$phpgw->db->unlock(); $phpgw->db->unlock();

View File

@ -180,7 +180,6 @@
if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];} if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];}
include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_".$phpgw_info["server"]["account_repository"].".inc.php"); include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php"); include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php");
$this->auth = new auth; $this->auth = new auth;
$this->session = new sessions; $this->session = new sessions;
}else{ }else{
@ -199,9 +198,9 @@
include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php"); include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php");
$this->auth = new auth; $this->auth = new auth;
} }
$this->accounts = new accounts;
$this->translation = new translation; $this->translation = new translation;
$this->common = new common; $this->common = new common;
$this->accounts = new accounts;
$this->preferences = new preferences; $this->preferences = new preferences;
$this->acl = new acl; $this->acl = new acl;
$this->hooks = new hooks; $this->hooks = new hooks;
@ -300,7 +299,6 @@
return $phpgw->translation->translate($key); return $phpgw->translation->translate($key);
} }
} }
/**************************************************************************\ /**************************************************************************\
* Our API class ends here * * Our API class ends here *

View File

@ -264,10 +264,9 @@
$db = $phpgw->db; $db = $phpgw->db;
$db->lock(array("preferences")); $db->lock(array("preferences"));
$db->query("SELECT * FROM preferences WHERE preference_owner=".$id); $db->query("SELECT * FROM preferences WHERE preference_owner='$id'",__LINE__,__FILE__);
if($db->num_rows()) { if($db->num_rows()) {
$db->query("UPDATE preferences SET preference_value = '" $db->query("UPDATE preferences SET preference_value = '". serialize($phpgw_newuser["user"]["preferences"])
. serialize($phpgw_newuser["user"]["preferences"])
. "' WHERE preference_owner=".$id,__LINE__,__FILE__); . "' WHERE preference_owner=".$id,__LINE__,__FILE__);
} else { } else {
$db->query("insert into preferences (preference_owner,preference_value) values (" $db->query("insert into preferences (preference_owner,preference_value) values ("