small fixes for new users and group edits

This commit is contained in:
skeeter 2000-12-29 03:05:30 +00:00
parent b150a2a1c4
commit 1e4f1ecc8b
3 changed files with 20 additions and 37 deletions

View File

@ -38,52 +38,36 @@
} }
if (! $error) { if (! $error) {
$phpgw->db->lock(array("accounts","groups")); // $phpgw->db->lock(array("accounts","groups","preferences","config","applications","phpgw_hooks","phpgw_sessions"));
$phpgw->db->query("SELECT group_apps FROM groups WHERE group_id=".$group_id,__FILE__,__LINE__);
$phpgw->db->next_record();
$apps_before = $phpgw->db->f("group_apps");
$phpgw->accounts->add_app($n_group_permissions); $phpgw->accounts->add_app($n_group_permissions);
$apps_after = $phpgw->accounts->add_app("",True); $apps_after = explode(":",$phpgw->accounts->add_app("",True));
if($apps_before <> $apps_after) {
$after_apps = explode(":",$apps_after);
for ($i=1;$i<=count($after_apps);$i++) {
if (!strpos(" ".$apps_before." ",$after_apps)) {
$new_apps[] = $after_apps[$i];
}
}
}
$phpgw->db->query("update groups set group_name='$n_group', group_apps='" . $apps_after $phpgw->db->query("update groups set group_name='$n_group', group_apps='" . $apps_after
. "' where group_id=$group_id"); . "' where group_id=$group_id");
$phpgw->db->query("SELECT group_id FROM groups WHERE group_name='$n_group'");
$phpgw->db->next_record();
$group_con = $phpgw->db->f("group_id");
for ($i=0; $i<count($n_users);$i++) { for ($i=0; $i<count($n_users);$i++) {
$phpgw->db->query("SELECT account_groups FROM accounts WHERE account_id=".$n_users[$i]); $phpgw->db->query("SELECT account_groups FROM accounts WHERE account_id=".$n_users[$i]);
$phpgw->db->next_record(); $phpgw->db->next_record();
if(strpos($phpgw->db->f("account_groups"),$group_con.":0,") == 0) { if(strpos($phpgw->db->f("account_groups"),$group_id.":0,") == 0) {
$user_groups = $phpgw->db->f("account_groups") . ",$group_con:0,"; $user_groups = $phpgw->db->f("account_groups") . ",$group_id:0,";
$user_groups = ereg_replace(",,",",",$user_groups); $user_groups = ereg_replace(",,",",",$user_groups);
$phpgw->db->query("UPDATE accounts SET account_groups='$user_groups' WHERE account_id=".$n_users[$i]); $phpgw->db->query("UPDATE accounts SET account_groups='$user_groups' WHERE account_id=".$n_users[$i]);
} }
// 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)) { $pref = new preferences(intval($n_users[$i]));
$pref = new preferences($n_users[$i]); $docommit = False;
$docommit = False; for ($j=1;$j<=count($apps_after);$j++) {
for ($j=0;$j<count($new_apps);$j++) { if (!$pref->preferences[$apps_after[$j]]) {
if (!$pref->preferences[$new_apps[$j]]) { $phpgw->common->hook_single("add_def_pref", $apps_after[$j]);
$phpgw->common->hook_single("add_def_pref", $new_apps[$j]); $docommit = True;
$docommit = True;
}
}
if ($docommit) {
$pref->commit();
} }
} }
if ($docommit) {
$pref->commit();
}
} }
$sep = $phpgw->common->filesystem_separator(); $sep = $phpgw->common->filesystem_separator();
@ -100,7 +84,7 @@
$cd = 33; $cd = 33;
} }
$phpgw->db->unlock(); // $phpgw->db->unlock();
Header("Location: " . $phpgw->link("groups.php","cd=$cd")); Header("Location: " . $phpgw->link("groups.php","cd=$cd"));
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();

View File

@ -66,9 +66,7 @@
$phpgw->db->query("SELECT account_permissions FROM accounts WHERE account_lid='$n_loginid'",__LINE__,__FILE__); $phpgw->db->query("SELECT account_permissions FROM accounts WHERE account_lid='$n_loginid'",__LINE__,__FILE__);
$phpgw->db->next_record(); $phpgw->db->next_record();
$apps = explode(":",$phpgw->db->f("account_permissions")); $apps = explode(":",$phpgw->db->f("account_permissions"));
$phpgw->db->query("SELECT account_id FROM accounts WHERE account_lid='".$n_loginid."'"); $pref = new preferences($n_loginid);
$phpgw->db->next_record();
$pref = new preferences($phpgw->db->f("account_id"));
$phpgw->common->hook_single("add_def_pref", "admin"); $phpgw->common->hook_single("add_def_pref", "admin");
for ($i=1;$i<sizeof($apps) - 1;$i++) { for ($i=1;$i<sizeof($apps) - 1;$i++) {
$phpgw->common->hook_single("add_def_pref", $apps[$i]); $phpgw->common->hook_single("add_def_pref", $apps[$i]);

View File

@ -196,7 +196,7 @@
var $account_id; var $account_id;
var $preferences; var $preferences;
function preferences($account_id=0) function preferences($account_id)
{ {
global $phpgw; global $phpgw;
@ -205,18 +205,19 @@
if (is_long($account_id) && $account_id) { if (is_long($account_id) && $account_id) {
$this->account_id = $account_id; $this->account_id = $account_id;
} elseif(is_string($account_id)) { } elseif(is_string($account_id)) {
$db2->query("SELECT account_id FROM accounts WHERE account_lid='".$account_id."'"); $db2->query("SELECT account_id FROM accounts WHERE account_lid='".$account_id."'",__LINE__,__FILE__);
if($db2->num_rows()) { if($db2->num_rows()) {
$db2->next_record(); $db2->next_record();
$this->account_id = $db2->f("account_id"); $this->account_id = $db2->f("account_id");
} else {
$load_pref = False;
} }
} else { } else {
$load_pref = False; $load_pref = False;
} }
if ($load_pref) { if ($load_pref) {
$db2->query("select preference_value from preferences where preference_owner='" $db2->query("SELECT preference_value FROM preferences WHERE preference_owner=".$this->account_id,__LINE__,__FILE__);
. $this->account_id . "'",__LINE__,__FILE__);
$db2->next_record(); $db2->next_record();
$this->preferences = unserialize($db2->f("preference_value")); $this->preferences = unserialize($db2->f("preference_value"));
} }