2002-04-30 22:22:54 +00:00
|
|
|
<?php
|
|
|
|
|
2002-09-27 06:12:50 +00:00
|
|
|
// This file contains support functions for display and editing
|
|
|
|
// preferences (global and project).
|
2002-05-29 23:25:21 +00:00
|
|
|
// Preferences are represented in two ways:
|
|
|
|
// - As a PHP structure (usually called $prefs)
|
2003-02-21 01:38:16 +00:00
|
|
|
// This has fields run_on_batteries, etc.
|
2002-12-19 05:11:25 +00:00
|
|
|
// The fields "project_specific" is raw XML
|
2002-05-29 23:25:21 +00:00
|
|
|
// - As XML (usually called $prefs_xml)
|
|
|
|
//
|
|
|
|
// This XML has the general structure
|
2002-09-27 06:12:50 +00:00
|
|
|
// <global_preferences>
|
2003-02-21 01:38:16 +00:00
|
|
|
// <run_if_user_active/>
|
2002-06-01 20:26:21 +00:00
|
|
|
// <low_water_days>1.3</low_water_days>
|
2002-05-29 23:25:21 +00:00
|
|
|
// ...
|
2002-09-27 06:12:50 +00:00
|
|
|
// </global_preferences>
|
|
|
|
//
|
|
|
|
// and
|
|
|
|
//
|
|
|
|
// <project_preferences>
|
|
|
|
// <resource_share>4</resource_share>
|
2002-09-26 05:57:10 +00:00
|
|
|
// <project-specific>
|
2002-05-29 23:25:21 +00:00
|
|
|
// ... (arbitrary project-specific XML)
|
2002-09-26 05:57:10 +00:00
|
|
|
// </project-specific>
|
2002-09-27 06:12:50 +00:00
|
|
|
// <send_email/>
|
|
|
|
// <show_email/>
|
|
|
|
// </project_preferences>
|
2002-05-29 23:25:21 +00:00
|
|
|
|
2002-12-19 05:11:25 +00:00
|
|
|
// Various functions are defined below for converting between these forms,
|
|
|
|
// and also to/from HTML form elements
|
|
|
|
|
|
|
|
// First: functions to parse preferences XML into a struct
|
|
|
|
|
|
|
|
include_once("project_specific_prefs.inc");
|
|
|
|
|
2002-05-29 23:25:21 +00:00
|
|
|
global $text;
|
|
|
|
global $parse_result;
|
|
|
|
global $in_project_specific;
|
|
|
|
|
2002-09-27 06:12:50 +00:00
|
|
|
// the following will parse either global or project prefs
|
|
|
|
// TODO: split up into separate functions
|
|
|
|
//
|
2002-05-29 23:25:21 +00:00
|
|
|
function element_start($parser, $name, $attrs) {
|
|
|
|
global $text;
|
|
|
|
global $project;
|
|
|
|
global $in_project_specific;
|
|
|
|
|
|
|
|
switch($name) {
|
|
|
|
case "project_specific":
|
|
|
|
$in_project_specific = 1;
|
|
|
|
$text = "";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if ($in_project_specific) {
|
|
|
|
$text= $text."<$name>";
|
|
|
|
} else {
|
|
|
|
$text = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function element_end($parser, $name) {
|
|
|
|
global $text;
|
|
|
|
global $parse_result;
|
|
|
|
global $in_project_specific;
|
|
|
|
|
|
|
|
switch($name) {
|
|
|
|
case "project_specific":
|
2002-09-27 17:42:30 +00:00
|
|
|
$parse_result->project_specific = $text;
|
2002-05-29 23:25:21 +00:00
|
|
|
$in_project_specific = false;
|
|
|
|
break;
|
2003-02-21 01:38:16 +00:00
|
|
|
case "run_on_batteries":
|
|
|
|
$parse_result->run_on_batteries = true;
|
2002-05-29 23:25:21 +00:00
|
|
|
break;
|
2003-02-21 01:38:16 +00:00
|
|
|
case "run_if_user_active":
|
|
|
|
$parse_result->run_if_user_active = true;
|
2002-05-29 23:25:21 +00:00
|
|
|
break;
|
|
|
|
case "confirm_before_connecting":
|
|
|
|
$parse_result->confirm_before_connecting = 1;
|
|
|
|
break;
|
2002-06-01 20:26:21 +00:00
|
|
|
case "low_water_days":
|
|
|
|
$parse_result->low_water_days = $text;
|
2002-05-29 23:25:21 +00:00
|
|
|
break;
|
2002-06-01 20:26:21 +00:00
|
|
|
case "high_water_days":
|
|
|
|
$parse_result->high_water_days = $text;
|
2002-05-29 23:25:21 +00:00
|
|
|
break;
|
|
|
|
case "disk_max_used_gb":
|
|
|
|
$parse_result->disk_max_used_gb = $text;
|
|
|
|
break;
|
|
|
|
case "disk_max_used_pct":
|
|
|
|
$parse_result->disk_max_used_pct = $text;
|
|
|
|
break;
|
|
|
|
case "disk_min_free_gb":
|
|
|
|
$parse_result->disk_min_free_gb = $text;
|
|
|
|
break;
|
|
|
|
case "resource_share":
|
2002-09-27 17:42:30 +00:00
|
|
|
$parse_result->resource_share = $text;
|
2002-05-29 23:25:21 +00:00
|
|
|
break;
|
|
|
|
case "show_email":
|
2003-02-14 22:35:35 +00:00
|
|
|
$parse_result->show_email = true;
|
2002-05-29 23:25:21 +00:00
|
|
|
break;
|
|
|
|
case "send_email":
|
2003-02-14 22:35:35 +00:00
|
|
|
$parse_result->send_email = true;
|
2002-05-29 23:25:21 +00:00
|
|
|
break;
|
2002-12-19 05:11:25 +00:00
|
|
|
case "mod_time":
|
|
|
|
$parse_result->mod_time = $text;
|
|
|
|
break;
|
2002-09-27 06:12:50 +00:00
|
|
|
case "global_preferences":
|
|
|
|
break;
|
|
|
|
case "project_preferences":
|
2002-05-29 23:25:21 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if ($in_project_specific) {
|
|
|
|
$text = $text."</$name>\n";
|
|
|
|
} else {
|
|
|
|
echo "Unknown tag: $name\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function char_handler($parser, $x) {
|
|
|
|
global $text;
|
|
|
|
$text = $text.$x;
|
|
|
|
}
|
|
|
|
|
2003-02-14 22:35:35 +00:00
|
|
|
// state of prefs for new users
|
|
|
|
//
|
2003-02-07 09:00:35 +00:00
|
|
|
function default_prefs() {
|
|
|
|
$p = null;
|
2003-02-21 01:38:16 +00:00
|
|
|
$p->run_on_batteries = false;
|
|
|
|
$p->run_if_user_active = false;
|
2003-02-07 09:00:35 +00:00
|
|
|
$p->confirm_before_connecting = 0;
|
|
|
|
$p->low_water_days = 1;
|
|
|
|
$p->high_water_days = 3;
|
2003-02-08 02:06:35 +00:00
|
|
|
$p->disk_max_used_gb = 100;
|
2003-02-07 09:00:35 +00:00
|
|
|
$p->disk_max_used_pct = 50;
|
|
|
|
$p->disk_min_free_gb = 1;
|
|
|
|
|
|
|
|
$p->resource_share = 100;
|
2003-02-14 22:35:35 +00:00
|
|
|
$p->show_email = false;
|
|
|
|
$p->send_email = true;
|
2003-02-07 09:00:35 +00:00
|
|
|
return $p;
|
|
|
|
}
|
|
|
|
|
2003-02-14 22:35:35 +00:00
|
|
|
// state of prefs before parsing
|
|
|
|
//
|
|
|
|
function initial_prefs() {
|
|
|
|
$p = default_prefs;
|
|
|
|
$p->show_email = false;
|
|
|
|
$p->send_email = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// parse prefs (either global or project) from XML to a struct
|
|
|
|
//
|
2002-05-29 23:25:21 +00:00
|
|
|
function prefs_parse($prefs_xml) {
|
|
|
|
global $parse_result;
|
2002-12-19 05:11:25 +00:00
|
|
|
|
2003-02-14 22:35:35 +00:00
|
|
|
$parse_result = initial_prefs();
|
2002-09-27 06:12:50 +00:00
|
|
|
|
2002-05-29 23:25:21 +00:00
|
|
|
$xml_parser = xml_parser_create();
|
|
|
|
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
|
|
|
|
xml_set_element_handler($xml_parser, "element_start", "element_end");
|
|
|
|
xml_set_character_data_handler($xml_parser, "char_handler");
|
|
|
|
xml_parse($xml_parser, $prefs_xml, 1);
|
|
|
|
return $parse_result;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
//
|
2002-09-27 06:12:50 +00:00
|
|
|
// display preference subsets, with Edit buttons
|
2002-05-29 23:25:21 +00:00
|
|
|
//
|
2002-09-27 06:12:50 +00:00
|
|
|
function prefs_show_global($prefs) {
|
2003-02-21 01:38:16 +00:00
|
|
|
row2a("Work if computer on batteries:", $prefs->run_on_batteries?"Yes":"No");
|
|
|
|
row2a("Work if computer in use:", $prefs->run_if_user_active?"Yes":"No");
|
|
|
|
row2a("Confirm before connecting to network:", $prefs->confirm_before_connecting?"Yes":"No");
|
2003-02-08 02:06:35 +00:00
|
|
|
row2a("Minimum amount of work to buffer:", "$prefs->low_water_days days");
|
|
|
|
row2a("Maximum amount of work to buffer:", "$prefs->high_water_days days");
|
|
|
|
row2a("Maximum disk space to use:", "$prefs->disk_max_used_gb GB");
|
|
|
|
row2a("Minimum disk space to leave free:", "$prefs->disk_min_free_gb GB");
|
|
|
|
row2a("Maximum % of disk allowed to used:", "$prefs->disk_max_used_pct %");
|
|
|
|
}
|
|
|
|
|
|
|
|
function prefs_show_resource($prefs) {
|
2003-02-18 23:07:48 +00:00
|
|
|
row2(
|
|
|
|
"Resource share:
|
|
|
|
<br><font size=-1>If you participate in multiple BOINC projects, this is the proportion of your resources used by ".PROJECT."</font>",
|
|
|
|
$prefs->resource_share
|
|
|
|
);
|
2003-02-08 02:06:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function prefs_show_email($prefs) {
|
2003-02-18 23:07:48 +00:00
|
|
|
row2("Should ".PROJECT." send you email newsletters?", $prefs->send_email?"Yes":"No");
|
|
|
|
row2("Should ".PROJECT." show your email address on its web site?", $prefs->show_email?"Yes":"No");
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
|
|
|
|
2002-09-26 05:57:10 +00:00
|
|
|
function prefs_show_project($prefs) {
|
2002-12-19 05:11:25 +00:00
|
|
|
project_specific_prefs_show($prefs);
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
|
|
|
|
2002-09-27 17:42:30 +00:00
|
|
|
function print_prefs_display($user) {
|
2003-02-08 02:06:35 +00:00
|
|
|
echo "<table width=580 cellpadding=4>\n";
|
|
|
|
$global_prefs = prefs_parse($user->global_prefs);
|
|
|
|
$project_prefs = prefs_parse($user->project_prefs);
|
|
|
|
$project_specific_prefs = project_specific_prefs_parse($project_prefs->project_specific);
|
|
|
|
|
2003-02-18 23:07:48 +00:00
|
|
|
echo "<tr><td colspan=2><b>".PROJECT." preferences</b></td></tr>\n";
|
2003-02-08 02:06:35 +00:00
|
|
|
prefs_show_resource($project_prefs);
|
|
|
|
prefs_show_project($project_specific_prefs);
|
2003-02-14 22:35:35 +00:00
|
|
|
prefs_show_email($project_prefs);
|
2003-02-21 01:38:16 +00:00
|
|
|
venue_show($user);
|
2003-02-18 23:07:48 +00:00
|
|
|
echo "<tr><td><a href=prefs_edit_project_form.php>Edit ".PROJECT." preferences</a></td></tr>\n";
|
|
|
|
echo "<tr><td colspan=2><hr></td></tr>\n";
|
|
|
|
echo "<tr><td colspan=2><b>BOINC preferences</b></font>
|
|
|
|
<br><font size=-1>These apply to all BOINC projects in which you participate</font></td></tr>\n";
|
2003-02-08 02:06:35 +00:00
|
|
|
prefs_show_global($global_prefs);
|
2003-02-18 23:07:48 +00:00
|
|
|
echo "<tr><td><a href=prefs_edit_global_form.php>Edit BOINC preferences</a></td></tr>\n";
|
2003-02-08 02:06:35 +00:00
|
|
|
echo "</table>";
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Functions to display preference subsets as forms
|
|
|
|
//
|
2003-02-18 23:07:48 +00:00
|
|
|
function prefs_form_global($user, $prefs) {
|
|
|
|
echo "<tr>
|
|
|
|
<td align=right>Should ".PROJECT." run while the computer is on battery power?
|
2003-02-07 09:00:35 +00:00
|
|
|
<br><font size=-1>(This matters only for portable computers)</font>
|
|
|
|
</td><td valign=top>
|
|
|
|
";
|
2003-02-21 01:38:16 +00:00
|
|
|
printf("Yes <input type=radio name=run_on_batteries value=yes %s>\n", $prefs->run_on_batteries?"checked":"");
|
|
|
|
printf("No <input type=radio name=run_on_batteries value=no %s>\n", $prefs->run_on_batteries?"":"checked");
|
2003-02-07 09:00:35 +00:00
|
|
|
echo "</td></tr>
|
|
|
|
<tr>
|
|
|
|
<td align=right>Should ".PROJECT." run while you're using the computer?
|
|
|
|
</td><td valign=top>
|
|
|
|
";
|
2003-02-21 01:38:16 +00:00
|
|
|
printf("Yes <input type=radio name=run_if_user_active value=yes %s>\n", $prefs->run_if_user_active?"checked":"");
|
|
|
|
printf("No <input type=radio name=run_if_user_active value=no %s>\n", $prefs->run_if_user_active?"":"checked");
|
2003-02-07 09:00:35 +00:00
|
|
|
echo "</td></tr>
|
|
|
|
<tr>
|
2003-02-18 23:07:48 +00:00
|
|
|
<td align=right>Ask you before connecting to Internet?
|
2003-02-07 09:00:35 +00:00
|
|
|
<br><font size=-1>(This matters only if you use a modem)</font>
|
|
|
|
</td><td valign=top>
|
|
|
|
";
|
|
|
|
printf("Yes <input type=radio name=confirm_before_connecting %s>\n", $prefs->confirm_before_connecting?"checked":"");
|
|
|
|
printf("No <input type=radio name=confirm_before_connecting %s>\n", $prefs->confirm_before_connecting?"":"checked");
|
|
|
|
echo "</td></tr>
|
|
|
|
<tr>
|
|
|
|
<td align=right>Keep enough to work on disk to last between
|
|
|
|
</td><td>
|
|
|
|
<input size=5 name=low_water_days value='$prefs->low_water_days'>
|
|
|
|
and
|
|
|
|
<input size=5 name=high_water_days value='$prefs->high_water_days'> days
|
|
|
|
</td></tr>
|
|
|
|
<tr><td colspan=2>
|
|
|
|
You can limit the disk space used by ".PROJECT." in three different ways:
|
|
|
|
</td></tr>
|
|
|
|
<tr>
|
|
|
|
<td align=right valign=top>Use no more than</td>
|
|
|
|
<td><input size=7 name=disk_max_used_gb value='$prefs->disk_max_used_gb'> Gbytes</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align=right valign=top>Leave at least</td>
|
|
|
|
<td><input size=7 name=disk_min_free_gb value='$prefs->disk_min_free_gb'> Gbytes free</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td align=right valign=top>Use no more than</td>
|
|
|
|
<td><input size=5 name=disk_max_used_pct value='$prefs->disk_max_used_pct'> % of total space</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2003-02-18 23:07:48 +00:00
|
|
|
function prefs_form_email($prefs) {
|
|
|
|
echo "<tr>
|
2003-02-08 02:06:35 +00:00
|
|
|
<td align=right>Should ".PROJECT." send you email newsletters?</td><td>
|
|
|
|
";
|
2003-02-21 01:38:16 +00:00
|
|
|
printf("Yes <input type=radio name=send_email value=yes %s>\n", $prefs->send_email?"checked":"");
|
|
|
|
printf("No <input type=radio name=send_email value=no %s>\n", $prefs->send_email?"":"checked");
|
2003-02-08 02:06:35 +00:00
|
|
|
echo " </td></tr><tr>
|
|
|
|
<td align=right>Should ".PROJECT." show your email address on its web site?</td><td>
|
|
|
|
";
|
2003-02-21 01:38:16 +00:00
|
|
|
printf("Yes <input type=radio name=show_email value=yes %s>\n", $prefs->show_email?"checked":"");
|
|
|
|
printf("No <input type=radio name=show_email value=no %s>\n", $prefs->show_email?"":"checked");
|
2003-02-08 02:06:35 +00:00
|
|
|
echo" </td></tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2003-02-18 23:07:48 +00:00
|
|
|
function prefs_form_resource($prefs) {
|
|
|
|
echo "<tr>
|
|
|
|
<td width=50% valign=top align=right><b>Resource share:</b>
|
|
|
|
<font size=-1><br>The proportion of your computer's resources
|
|
|
|
(processing time and disk space)
|
|
|
|
allocated to ".PROJECT."
|
|
|
|
relative to the other BOINC projects in which you participate.
|
|
|
|
The default is 100.
|
|
|
|
For example, if you participate in two projects and
|
|
|
|
give them resource shares of 100 and 200,
|
|
|
|
the first will get 1/3 of our resources and the second will get 2/3.
|
|
|
|
</font></td>
|
|
|
|
<td valign=top><input name=resource_share value='$prefs->resource_share'></td>
|
2003-02-07 09:00:35 +00:00
|
|
|
";
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2003-02-18 23:07:48 +00:00
|
|
|
function prefs_form_project($prefs_xml) {
|
2003-02-07 09:00:35 +00:00
|
|
|
$prefs = project_specific_prefs_parse($prefs_xml);
|
|
|
|
project_specific_prefs_edit($prefs);
|
2003-02-18 23:07:48 +00:00
|
|
|
}
|
|
|
|
|
2003-02-21 01:38:16 +00:00
|
|
|
function venue_show($user) {
|
|
|
|
echo "<tr><td>Venue</td><td>$user->venue</td></tr>\n";
|
|
|
|
}
|
|
|
|
|
2003-02-18 23:07:48 +00:00
|
|
|
function venue_form($user) {
|
2003-02-21 01:38:16 +00:00
|
|
|
if ($user->venue == "home") $h = "selected";
|
|
|
|
if ($user->venue == "work") $w = "selected";
|
|
|
|
if ($user->venue == "school") $s = "selected";
|
2003-02-18 23:07:48 +00:00
|
|
|
echo "<tr><td align=right>Computer location</td><td>
|
|
|
|
<select name=venue>
|
2003-02-21 01:38:16 +00:00
|
|
|
<option value=home $h>Home
|
|
|
|
<option value=work $w>Work
|
|
|
|
<option value=school $s>School
|
2003-02-18 23:07:48 +00:00
|
|
|
</select>
|
|
|
|
</td></tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
function venue_parse(&$user) {
|
|
|
|
parse_str(getenv("QUERY_STRING"));
|
|
|
|
$user->venue = $venue;
|
|
|
|
}
|
|
|
|
|
|
|
|
function venue_update($user) {
|
|
|
|
mysql_query("update user set venue='$user->venue' where id=$user->id");
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Functions to parse form elements, modifying a preferences structure
|
|
|
|
//
|
2002-09-27 06:12:50 +00:00
|
|
|
function prefs_global_parse_form(&$prefs) {
|
2002-05-29 23:25:21 +00:00
|
|
|
parse_str(getenv("QUERY_STRING"));
|
2003-02-21 01:38:16 +00:00
|
|
|
$prefs->run_on_batteries = ($run_on_batteries == "yes");
|
|
|
|
$prefs->run_if_user_active = ($run_if_user_active == "yes");
|
2002-05-29 23:25:21 +00:00
|
|
|
$prefs->confirm_before_connecting = isset($confirm_before_connecting)?1:0;
|
2002-06-01 20:26:21 +00:00
|
|
|
$prefs->low_water_days = $low_water_days;
|
|
|
|
$prefs->high_water_days = $high_water_days;
|
2002-05-29 23:25:21 +00:00
|
|
|
$prefs->disk_max_used_gb = $disk_max_used_gb;
|
|
|
|
$prefs->disk_max_used_pct = $disk_max_used_pct;
|
|
|
|
$prefs->disk_min_free_gb = $disk_min_free_gb;
|
|
|
|
}
|
|
|
|
|
2003-02-07 09:00:35 +00:00
|
|
|
function prefs_resource_parse_form(&$prefs) {
|
2002-05-29 23:25:21 +00:00
|
|
|
parse_str(getenv("QUERY_STRING"));
|
2002-09-27 06:12:50 +00:00
|
|
|
$prefs->resource_share = $resource_share;
|
2003-02-07 09:00:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-08 02:06:35 +00:00
|
|
|
function prefs_email_parse_form(&$prefs) {
|
|
|
|
parse_str(getenv("QUERY_STRING"));
|
2003-02-21 01:38:16 +00:00
|
|
|
$prefs->send_email = ($send_email == "yes");
|
|
|
|
$prefs->show_email = ($show_email == "yes");
|
2003-02-08 02:06:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-07 09:00:35 +00:00
|
|
|
function prefs_project_parse_form(&$prefs) {
|
2002-12-19 05:11:25 +00:00
|
|
|
$prefs->project_specific = project_specific_prefs_parse_form();
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
|
|
|
|
2003-02-07 09:00:35 +00:00
|
|
|
|
2002-05-29 23:25:21 +00:00
|
|
|
////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// convert prefs from structure to XML
|
|
|
|
//
|
2002-09-27 06:12:50 +00:00
|
|
|
function global_prefs_make_xml($prefs) {
|
|
|
|
$xml = "<global_preferences>\n";
|
2002-09-29 00:32:11 +00:00
|
|
|
$now = time();
|
2003-02-07 09:00:35 +00:00
|
|
|
$xml = $xml."<mod_time>$now</mod_time>\n";
|
2003-02-21 01:38:16 +00:00
|
|
|
if ($prefs->run_on_batteries) {
|
|
|
|
$xml = $xml."<run_on_batteries/>\n";
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
2003-02-21 01:38:16 +00:00
|
|
|
if ($prefs->run_if_user_active) {
|
|
|
|
$xml = $xml."<run_if_user_active/>\n";
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
|
|
|
if ($prefs->confirm_before_connecting) {
|
2003-02-07 09:00:35 +00:00
|
|
|
$xml = $xml."<confirm_before_connecting/>\n";
|
2003-02-04 01:17:56 +00:00
|
|
|
}
|
2003-02-18 23:07:48 +00:00
|
|
|
$xml = $xml
|
|
|
|
."<low_water_days>$prefs->low_water_days</low_water_days>\n"
|
|
|
|
."<high_water_days>$prefs->high_water_days</high_water_days>\n";
|
|
|
|
$xml = $xml
|
|
|
|
."<disk_max_used_gb>$prefs->disk_max_used_gb</disk_max_used_gb>\n"
|
|
|
|
."<disk_max_used_pct>$prefs->disk_max_used_pct</disk_max_used_pct>\n"
|
|
|
|
."<disk_min_free_gb>$prefs->disk_min_free_gb</disk_min_free_gb>\n";
|
2002-09-27 06:12:50 +00:00
|
|
|
$xml = $xml."</global_preferences>\n";
|
2002-05-29 23:25:21 +00:00
|
|
|
return $xml;
|
|
|
|
}
|
|
|
|
|
2002-09-27 06:12:50 +00:00
|
|
|
function project_prefs_make_xml($prefs) {
|
|
|
|
$xml = "<project_preferences>\n";
|
2003-02-21 01:38:16 +00:00
|
|
|
if ($prefs->show_email == 1) {
|
2003-02-14 22:35:35 +00:00
|
|
|
$xml = $xml."<show_email/>\n";
|
|
|
|
}
|
2003-02-21 01:38:16 +00:00
|
|
|
if ($prefs->send_email == 1) {
|
2003-02-14 22:35:35 +00:00
|
|
|
$xml = $xml."<send_email/>\n";
|
|
|
|
}
|
2002-09-27 17:42:30 +00:00
|
|
|
$xml = $xml
|
|
|
|
."<resource_share>$prefs->resource_share</resource_share>\n"
|
2003-02-14 22:35:35 +00:00
|
|
|
."<project_specific>\n$prefs->project_specific</project_specific>\n";
|
2002-09-27 06:12:50 +00:00
|
|
|
$xml = $xml."</project_preferences>\n";
|
2002-09-27 17:42:30 +00:00
|
|
|
return $xml;
|
2002-09-27 06:12:50 +00:00
|
|
|
}
|
|
|
|
|
2002-05-29 23:25:21 +00:00
|
|
|
////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Update user's prefs in database, from a given structure
|
|
|
|
//
|
2002-12-19 05:11:25 +00:00
|
|
|
function global_prefs_update(&$user, $prefs) {
|
2002-09-27 06:12:50 +00:00
|
|
|
$prefs_xml = global_prefs_make_xml($prefs);
|
2002-09-29 00:32:11 +00:00
|
|
|
mysql_query("update user set global_prefs='$prefs_xml' where id=$user->id");
|
2002-09-27 17:42:30 +00:00
|
|
|
$user->global_prefs = $prefs_xml;
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
|
|
|
|
2002-12-19 05:11:25 +00:00
|
|
|
function project_prefs_update(&$user, $prefs) {
|
2002-09-27 06:12:50 +00:00
|
|
|
$prefs_xml = project_prefs_make_xml($prefs);
|
|
|
|
mysql_query("update user set project_prefs='$prefs_xml' where id=$user->id");
|
2002-09-27 17:42:30 +00:00
|
|
|
$user->project_prefs = $prefs_xml;
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
?>
|