fixes for new preferences class

This commit is contained in:
skeeter 2000-12-27 15:07:14 +00:00
parent 1f29754cc0
commit f3abbd9ae4
8 changed files with 55 additions and 73 deletions

View File

@ -1,5 +1,6 @@
<?php
$phpgw->preferences->add_newuser("addressbook","company","addressbook_True");
$phpgw->preferences->add_newuser("addressbook","lastname","addressbook_True");
$phpgw->preferences->add_newuser("addressbook","firstname","addressbook_True");
global $pref;
$pref->change("addressbook","company","addressbook_True");
$pref->change("addressbook","lastname","addressbook_True");
$pref->change("addressbook","firstname","addressbook_True");
?>

View File

@ -97,30 +97,18 @@
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"]) {
$phpgw->db->query("SELECT preference_value FROM preferences WHERE preference_owner='$users_account_id'",__FILE__,__LINE__);
$phpgw->db->next_record();
$phpgw_newuser["user"]["preferences"] = unserialize($phpgw->db->f("preference_value"));
} else {
$phpgw_newuser["user"]["preferences"] = $phpgw_info["user"]["preferences"];
}
$pref = new preferences($phpgw->db->f("account_id"));
$docommit = False;
for ($j=0;$j<count($new_apps);$j++) {
if (! @$phpgw_newuser["user"]["preferences"][$new_apps[$j]]) {
if (! @$pref->preferences[$new_apps[$j]]) {
$phpgw->common->hook_single("add_def_pref", $new_apps[$j]);
$docommit = True;
}
}
if ($docommit) {
if ($account_id <> $phpgw_info["user"]["account_id"]) {
// $phpgw->preferences->commit_user($users_account_id);
} else {
$phpgw_info["user"]["preferences"] = $phpgw_newuser["user"]["preferences"];
unset($phpgw_newuser);
$phpgw->preferences->commit();
}
$pref->commit();
}
}

View File

@ -50,7 +50,7 @@
$after_apps = explode(":",$apps_after);
for ($i=1;$i<=count($after_apps);$i++) {
if (!strpos(" ".$apps_before." ",$after_apps)) {
$new_apps[] = $after_apps;
$new_apps[] = $after_apps[$i];
}
}
}
@ -63,37 +63,25 @@
for ($i=0; $i<count($n_users);$i++) {
$phpgw->db->query("SELECT account_groups FROM accounts WHERE account_id=".$n_users[$i]);
$phpgw->db->next_record();
$user_groups = $phpgw->db->f("account_groups") . ",$group_con:0,";
$user_groups = ereg_replace(",,",",",$user_groups);
$phpgw->db->query("UPDATE accounts SET account_groups='$user_groups' WHERE account_id=".$n_users[$i]);
if(strpos($phpgw->db->f("account_groups"),$group_con.":0,") == 0) {
$user_groups = $phpgw->db->f("account_groups") . ",$group_con:0,";
$user_groups = ereg_replace(",,",",",$user_groups);
$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..
// This is smart enough to know if previous preferences were selected, use them.
if (count($new_apps)) {
if ($n_users[$i] <> $phpgw_info["user"]["account_id"]) {
if(is_array($phpgw_newuser)) unset($phpgw_newuser);
$phpgw->db->query("SELECT preference_value FROM preferences WHERE preference_owner=".$n_users[$i],__FILE__,__LINE__);
$phpgw->db->next_record();
$phpgw_newuser["user"]["preferences"] = unserialize($phpgw->db->f("preference_value"));
} else {
$phpgw_newuser["user"]["preferences"] = $phpgw_info["user"]["preferences"];
}
$pref = new preferences($n_users[$i]);
$docommit = False;
for ($j=0;$j<count($new_apps);$j++) {
if (!$phpgw_newuser["user"]["preferences"][$new_apps[$j]]) {
if (!$pref->preferences[$new_apps[$j]]) {
$phpgw->common->hook_single("add_def_pref", $new_apps[$j]);
$docommit = True;
}
}
if ($docommit) {
if ($n_users[$i] <> $phpgw_info["user"]["account_id"]) {
$phpgw->preferences->commit_user($n_users[$i]);
} else {
$phpgw_info["user"]["preferences"] = $phpgw_newuser["user"]["preferences"];
unset($phpgw_newuser);
$phpgw->preferences->commit();
}
$pref->commit();
}
}
}

View File

@ -1,8 +1,9 @@
<?php
// $phpgw->preferences->add_newuser("common","maxmatchs","15");
// $phpgw->preferences->add_newuser("common","theme","default");
// $phpgw->preferences->add_newuser("common","tz_offset","0");
// $phpgw->preferences->add_newuser("common","dateformat","m/d/Y");
// $phpgw->preferences->add_newuser("common","timeformat","12");
// $phpgw->preferences->add_newuser("common","lang","en");
global $pref;
$pref->change("common","maxmatchs","15");
$pref->change("common","theme","default");
$pref->change("common","tz_offset","0");
$pref->change("common","dateformat","m/d/Y");
$pref->change("common","timeformat","12");
$pref->change("common","lang","en");
?>

View File

@ -66,11 +66,14 @@
$phpgw->db->query("SELECT account_permissions FROM accounts WHERE account_lid='$n_loginid'",__LINE__,__FILE__);
$phpgw->db->next_record();
$apps = explode(":",$phpgw->db->f("account_permissions"));
$phpgw->db->query("SELECT account_id FROM accounts WHERE account_lid='".$n_loginid."'");
$phpgw->db->next_record();
$pref = new preferences($phpgw->db->f("account_id"));
$phpgw->common->hook_single("add_def_pref", "admin");
for ($i=1;$i<sizeof($apps) - 1;$i++) {
$phpgw->common->hook_single("add_def_pref", $apps[$i]);
}
$phpgw->preferences->commit_newuser($n_loginid);
$pref->commit();
Header("Location: " . $phpgw->link("accounts.php","cd=$cd"));
$phpgw->common->phpgw_exit();
}

View File

@ -60,23 +60,6 @@
. addslashes($n_app_name) . "','" . addslashes($n_app_title) . "','"
. "$n_app_status','$app_order')",__LINE__,__FILE__);
$phpgw->db->query("SELECT preference_owner, preference_value FROM preferences");
if ($phpgw->db->num_rows()) {
while ($phpgw->db->next_record()) {
if ($phpgw->db->f("preference_owner") != $phpgw_info["user"]["account_id"]) {
$phpgw_newuser["user"]["preferences"] = unserialize($phpgw->db->f("preference_value"));
if (!$phpgw_newuser["user"]["preferences"][$n_app_name]) {
$phpgw->common->hook_single("add_def_pref", $n_app_name);
$phpgw->preferences->commit_user($phpgw->db->f("preference_owner"));
}
} elseif(!$phpgw_info["user"]["preferences"][$n_app_name]) {
$phpgw->common->hook_single("add_def_pref", $n_app_name);
$phpgw_info["user"]["preferences"][$n_app_name] = $phpgw_newuser["user"]["preferences"][$n_app_name];
unset($phpgw_newuser);
$phpgw->preferences->commit();
}
}
}
Header("Location: " . $phpgw->link("applications.php"));
$phpgw->common->phpgw_exit();
} else {

View File

@ -35,13 +35,18 @@
if (! $error) {
$phpgw->db->lock(array("accounts","groups"));
$phpgw->accounts->add_app($n_group_permissions);
$phpgw->accounts->add_app($n_group_permissions);
$apps = $phpgw->accounts->add_app("",True)
$phpgw->db->query("INSERT INTO groups (group_name,group_apps) VALUES "
. "('$n_group','"
. $phpgw->accounts->add_app("",True) . "')");
. $apps . "')");
$phpgw->db->query("SELECT group_id FROM groups WHERE group_name='$n_group'");
$phpgw->db->next_record();
$group_con = $phpgw->db->f("group_id");
$after_apps = explode(":",$apps);
for ($i=1;$i<=count($after_apps);$i++) {
$new_apps[] = $after_apps[$i];
}
for ($i=0; $i<count($n_users);$i++) {
$phpgw->db->query("SELECT account_groups FROM accounts WHERE account_id=".$n_users[$i]);
@ -50,6 +55,18 @@
$user_groups = ereg_replace(",,",",",$user_groups);
$phpgw->db->query("UPDATE accounts SET account_groups='$user_groups' WHERE account_id=".$n_users[$i]);
$pref = new preferences($n_users[$i]);
$docommit = False;
for ($j=0;$j<count($new_apps);$j++) {
if (!$pref->preferences[$new_apps[$j]]) {
$phpgw->common->hook_single("add_def_pref", $new_apps[$j]);
$docommit = True;
}
}
if ($docommit) {
$pref->commit();
}
}
$sep = $phpgw->common->filesystem_separator();

View File

@ -1,8 +1,9 @@
<?php
$phpgw->preferences->add_newuser("calendar","weekstarts","Monday");
$phpgw->preferences->add_newuser("calendar","workdaystarts","9");
$phpgw->preferences->add_newuser("calendar","workdayends","17");
$phpgw->preferences->add_newuser("calendar","defaultcalendar","index.php");
$phpgw->preferences->add_newuser("calendar","defaultfilter","all");
$phpgw->preferences->add_newuser("calendar","mainscreen_showevents","Y");
global $pref;
$pref->change("calendar","weekstarts","Monday");
$pref->change("calendar","workdaystarts","9");
$pref->change("calendar","workdayends","17");
$pref->change("calendar","defaultcalendar","index.php");
$pref->change("calendar","defaultfilter","all");
$pref->change("calendar","mainscreen_showevents","Y");
?>