Change around the format of the preference table to use serialize() and unserialize()

This commit is contained in:
jengo 2000-12-13 15:19:03 +00:00
parent 14c9701005
commit 3a42ea8a5b
11 changed files with 80 additions and 59 deletions

View File

@ -26,13 +26,16 @@
}
if (! $totalerrors) {
$phpgw->common->preferences_delete("byapp",$phpgw_info["user"]["account_id"],"addressbook");
while ($pref = each($ab_selected)) {
$phpgw->common->preferences_add($phpgw_info["user"]["account_id"],$pref[0],"addressbook","addressbook_" . $pref[1]);
$phpgw->preferences->change($phpgw_info["user"]["account_id"],$pref[0],"addressbook","addressbook_" . $pref[1]);
}
if ($mainscreen_showbirthdays) {
$phpgw->common->preferences_add($phpgw_info["user"]["account_id"],"mainscreen_showbirthdays","addressbook");
$phpgw->preferences->change($phpgw_info["user"]["account_id"],"mainscreen_showbirthdays","addressbook");
} else {
$phpgw->preferences->delete("addressbook","mainscreen_showbirthdays");
}
$phpgw->preferences->commit();
Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/preferences/index.php"));
}
}

View File

@ -18,16 +18,17 @@
include("../header.inc.php");
if ($submit) {
$phpgw->preferences->preferences_delete("byapp",$phpgw_info["user"]["account_id"],"calendar");
$phpgw->preferences->preferences_delete("byappvar",$phpgw_info["user"]["account_id"],"common|defaultcalendar");
$phpgw->preferences->preferences_add($phpgw_info["user"]["account_id"],"weekdaystarts","calendar");
$phpgw->preferences->preferences_add($phpgw_info["user"]["account_id"],"workdaystarts","calendar");
$phpgw->preferences->preferences_add($phpgw_info["user"]["account_id"],"workdayends","calendar");
$phpgw->preferences->preferences_add($phpgw_info["user"]["account_id"],"defaultcalendar","common");
$phpgw->preferences->change($phpgw_info["user"]["account_id"],"weekdaystarts","calendar");
$phpgw->preferences->change($phpgw_info["user"]["account_id"],"workdaystarts","calendar");
$phpgw->preferences->change($phpgw_info["user"]["account_id"],"workdayends","calendar");
$phpgw->preferences->change($phpgw_info["user"]["account_id"],"defaultcalendar","common");
if ($mainscreen_showevents) {
$phpgw->preferences->preferences_add($phpgw_info["user"]["account_id"],"mainscreen_showevents","calendar");
$phpgw->preferences->change($phpgw_info["user"]["account_id"],"mainscreen_showevents","calendar");
} else {
$phpgw->preferences->delete("calendar","mainscreen_showevents");
}
$phpgw->preferences->commit();
Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/preferences/index.php"));
exit;
}

View File

@ -64,10 +64,10 @@
exit;
}
$phpgw->common->read_preferences("addressbook");
$phpgw->common->read_preferences("email");
$phpgw->common->read_preferences("calendar");
$phpgw->common->read_preferences("stocks");
// $phpgw->preferences->read_preferences("addressbook");
// $phpgw->preferences->read_preferences("email");
// $phpgw->preferences->read_preferences("calendar");
// $phpgw->preferences->read_preferences("stocks");
$phpgw->db->query("select app_version from applications where app_name='admin'",__LINE__,__FILE__);
$phpgw->db->next_record();

View File

@ -17,16 +17,15 @@
include("../header.inc.php");
if ($ntheme) {
$theme = $ntheme;
$phpgw->preferences->preferences_update($phpgw_info["user"]["account_id"],"theme","common");
$phpgw->preferences->change($phpgw_info["user"]["account_id"],"theme","common",$ntheme);
$phpgw->preferences->commit();
Header("location: " . $phpgw->link("changetheme.php"));
exit;
}
$dh = opendir($phpgw_info["server"]["server_root"] . "/themes");
while ($file = readdir($dh)) {
# if ($file != "." && $file != ".." && $file != "CVS") {
if ( eregi( "\.theme$", $file ) ) {
if (eregi("\.theme$", $file)) {
$installed_themes[] = substr($file,0,strpos($file,"."));
}
}

View File

@ -129,17 +129,9 @@
<td>
<select name="settings[lang]">
<?php
$phpgw->db->query("select preference_value from preferences where preference_owner='"
. $phpgw_info["user"]["account_id"] . "' and preference_name='lang' and "
. "preference_appname='common'",__LINE__,__FILE__);
$phpgw->db->next_record();
if ($phpgw->db->f("preference_value") == "") {
$phpgw_info["user"]["preferences"]["common"]["lang"] = "en";
}
$lang_select[$phpgw_info["user"]["preferences"]["common"]["lang"]] = " selected";
$strSql = "SELECT lang_id, lang_name FROM languages WHERE available = 'Yes'";
$phpgw->db->query($strSql);
$phpgw->db->query("SELECT lang_id, lang_name FROM languages WHERE available = 'Yes'",__LINE__,__FILE__);
while ($phpgw->db->next_record()) {
echo "<option value=\"" . $phpgw->db->f("lang_id") . "\"";
if ($phpgw_info["user"]["preferences"]["common"]["lang"]) {
@ -156,7 +148,6 @@
</td>
</tr>
<?php
// This one is specialized, so we do it manually
if ($phpgw_info["user"]["apps"]["admin"]) {
echo '<tr><td>' . lang("show current users on navigation bar") . '</td><td>'
. '<input type="checkbox" name="show_currentusers" value="True"';
@ -210,23 +201,19 @@
<?php
$phpgw->common->phpgw_footer();
} else {
$phpgw->preferences->preferences_delete("byappnotheme",$phpgw_info["user"]["account_id"],"common");
$phpgw->db->lock("preferences");
//$phpgw->preferences->preferences_delete("byappnotheme",$phpgw_info["user"]["account_id"],"common");
while ($setting = each($settings)) {
$phpgw->preferences->preferences_add($phpgw_info["user"]["account_id"],$setting[0],"common",$setting[1]);
$phpgw->preferences->change($phpgw_info["user"]["account_id"],$setting[0],"common",$setting[1]);
}
// This one is specialized, so we do it manually
if ($phpgw_info["user"]["apps"]["admin"]) {
if ($show_currentusers) {
$phpgw->preferences->preferences_add($phpgw_info["user"]["account_id"],"show_currentusers","common");
$phpgw->preferences->change($phpgw_info["user"]["account_id"],"show_currentusers","common");
}
}
$phpgw->db->unlock();
if ($phpgw_info["server"]["useframes"] != "never") {
Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/index.php"));
exit;

View File

@ -13,7 +13,7 @@
function add_default_server_config(){
global $db, $phpgw_info, $currentver;
$phpgw_info["server"]["default_tplset"] = "default";
$phpgw_info["server"]["temp_dir"]="/path/to/tmp";
$phpgw_info["server"]["files_dir"]="/path/to/phpgroupware/files";
@ -48,7 +48,9 @@
$phpgw_info["server"]["nntp_login_username"]="";
$phpgw_info["server"]["nntp_login_password"]="";
$db->query("insert into config values("' . serialize($s) . '")");
$db->query("insert into config values('" . serialize($phpgw_info["server"]) . "')");
// I disabled a lot of this for temp. (jengo)
/* $db->query("insert into config (config_name, config_value) values ('default_tplset', 'default')");
$db->query("insert into config (config_name, config_value) values ('temp_dir', '/path/to/tmp')");
@ -85,7 +87,7 @@
$db->query("insert into config (config_name, config_value) values ('showpoweredbyon', 'bottom')");
$db->query("insert into config (config_name, config_value) values ('htmlcompliant', 'False')");
$db->query("insert into config (config_name, config_value) values ('checkfornewversion', 'False')");
$db->query("insert into config (config_name, config_value) values ('freshinstall', 'True')"); */
$db->query("insert into config (config_name, config_value) values ('freshinstall', 'True')");
}
if ($useglobalconfigsettings == "on"){
@ -132,10 +134,11 @@
echo " </tr>\n";
echo "</table>\n";
add_default_server_config();
}
}else{
add_default_server_config();
}
}else{ */
}
add_default_server_config();
// }
include($phpgw_info["server"]["server_root"] . "/setup/sql/default_applications.inc.php");

View File

@ -54,13 +54,11 @@
)";
$db->query($sql);
$sql = "CREATE TABLE preferences (
preference_owner varchar(20),
preference_name varchar(50),
preference_value varchar(50),
preference_appname varchar(50)
$sql = "create table preferences (
preference_owner int,
preference_value text
)";
$db->query($sql);
$db->query($sql);
$sql = "CREATE TABLE phpgw_sessions (
session_id varchar(255) NOT NULL,
@ -289,7 +287,7 @@
)";
$db->query($sql);
$currentver = "0.9.7";
$currentver = "0.9.8pre3";
$oldversion = $currentver;
update_version_table();
?>

View File

@ -739,11 +739,27 @@
$currentver = "0.9.8pre2";
update_version_table();
}
if ($currentver == "0.9.8pre1") {
if ($currentver == "0.9.8pre2") {
// upgrade code starts here
$db->query("select * from preferences order by preference_owner");
while ($db->next_record()) {
$t[$db->f("preference_owner")][$db->f("preference_appname")][$db->f("preference_var")] = $db->f("preference_value");
}
$db->query("drop table preferences");
$sql = "create table preferences (
preference_owner int,
preference_value text
)";
$db->query($sql);
while ($tt = each($t)) {
$db->query("insert into preferences values ('$tt[0]','" . serialize($tt[1]) . "'");
}
// upgrade code ends here
$currentver = "0.9.8pre2";
$currentver = "0.9.8pre3";
update_version_table();
}
if ($oldversion != $currentver){

View File

@ -91,10 +91,8 @@
$db->query($sql);
$sql = "create table preferences (
preference_owner varchar(20),
preference_name varchar(50),
preference_value varchar(50),
preference_appname varchar(50)
preference_owner int,
preference_value text
)";
$db->query($sql);
@ -261,7 +259,7 @@
)";
$db->query($sql);
$currentver = "0.9.7";
$currentver = "0.9.8pre3";
$oldversion = $currentver;
update_version_table();
?>

View File

@ -752,11 +752,27 @@
$currentver = "0.9.8pre2";
update_version_table();
}
if ($currentver == "0.9.8pre1") {
if ($currentver == "0.9.8pre2") {
// upgrade code starts here
$db->query("select * from preferences order by preference_owner");
while ($db->next_record()) {
$t[$db->f("preference_owner")][$db->f("preference_appname")][$db->f("preference_var")] = $db->f("preference_value");
}
$db->query("drop table preferences");
$sql = "create table preferences (
preference_owner int,
preference_value text
)";
$db->query($sql);
while ($tt = each($t)) {
$db->query("insert into preferences values ('$tt[0]','" . serialize($tt[1]) . "'");
}
// upgrade code ends here
$currentver = "0.9.8pre2";
$currentver = "0.9.8pre3";
update_version_table();
}
if ($oldversion != $currentver){

View File

@ -11,5 +11,5 @@
/* $Id$ */
$phpgw_info["server"]["version"] = "0.9.8pre2";
$phpgw_info["server"]["version"] = "0.9.8pre3";
$phpgw_info["server"]["current_header_version"] = "1.5";