mirror of https://github.com/BOINC/boinc.git
project-specific prefs
svn path=/trunk/boinc/; revision=777
This commit is contained in:
parent
c176a94462
commit
c781418118
|
@ -2707,3 +2707,23 @@ Seth Dec 18 2002
|
|||
wingui_listctrl.cpp,h (new)
|
||||
wingui_pictrl.cpp,h (new)
|
||||
|
||||
David Dec 18 2002
|
||||
- Have account create action redirect to a different page
|
||||
so you don't get "Repost form data" if you go back to it
|
||||
- Added full support for project-specific preferences.
|
||||
Logic is encapsulated in project_specific_prefs.inc.
|
||||
The example lets you choose color scheme
|
||||
(Tahiti Sunset, Desert Sands)
|
||||
|
||||
html_user/
|
||||
account_created.php (new)
|
||||
project_specific_prefs.inc (new)
|
||||
create_account_action.php
|
||||
prefs.inc
|
||||
prefs.php
|
||||
prefs_edit_global_form.php
|
||||
prefs_edit_project_action.php
|
||||
prefs_edit_project_form.php
|
||||
util.inc
|
||||
lib/
|
||||
countries.C,h
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
include_once("util.inc");
|
||||
|
||||
page_head("Account created");
|
||||
echo "Your account has been created,
|
||||
and an <b>account key</b> is being emailed to you.
|
||||
<p>
|
||||
<b>If you are already running the BOINC client:</b>
|
||||
<blockquote>
|
||||
Select the <b>Add Project</b> command in the BOINC client.
|
||||
Enter the project URL and your account key.
|
||||
</blockquote>
|
||||
<b>If you aren't running the BOINC client:</b>
|
||||
<blockquote>
|
||||
<a href=download.php>Download the BOINC client</a>.
|
||||
Install and run the client.
|
||||
Enter the project URL and your account key.
|
||||
</blockquote>
|
||||
<p>
|
||||
Your account initially has default <b>preferences</b>
|
||||
(limits on CPU, disk and network usage).
|
||||
<a href=prefs.php>View or edit these preferences</a>.
|
||||
";
|
||||
|
||||
send_auth_email($new_email_addr, $authenticator);
|
||||
|
||||
page_tail();
|
||||
|
||||
?>
|
|
@ -53,19 +53,8 @@ function show_error($str) {
|
|||
if (!$result) {
|
||||
show_error("Couldn't create account");
|
||||
}
|
||||
page_head("Account created");
|
||||
echo "Your account has been created,
|
||||
and an <b>account key</b> is being emailed to you.
|
||||
<p>
|
||||
If you don't already have it,
|
||||
<a href=download.php>download the BOINC client</a>.
|
||||
Install and run the client, and give it your account key.
|
||||
<p>
|
||||
If you're already running the BOINC client,
|
||||
select the <b>Add Project</b> command
|
||||
and give it your account key.
|
||||
<p>";
|
||||
|
||||
send_auth_email($new_email_addr, $authenticator);
|
||||
// In success case, redirect to a fixed page so that user can
|
||||
// return to it without getting "Repost form data" stuff
|
||||
|
||||
page_tail();
|
||||
Header("Location: account_created.php");
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
// preferences (global and project).
|
||||
// Preferences are represented in two ways:
|
||||
// - As a PHP structure (usually called $prefs)
|
||||
// This has fields dont_run_on_batteries, etc.
|
||||
// The fields "project_specific" is raw XML
|
||||
// - As XML (usually called $prefs_xml)
|
||||
// Various functions are defined below for converting between these forms,
|
||||
// and also to/from HTML form elements
|
||||
|
||||
// functions to parse preferences XML into a struct
|
||||
//
|
||||
// This XML has the general structure
|
||||
// <global_preferences>
|
||||
|
@ -28,6 +26,13 @@
|
|||
// <show_email/>
|
||||
// </project_preferences>
|
||||
|
||||
// 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");
|
||||
|
||||
global $text;
|
||||
global $parse_result;
|
||||
global $in_project_specific;
|
||||
|
@ -97,6 +102,9 @@ function element_end($parser, $name) {
|
|||
case "send_email":
|
||||
$parse_result->send_email = $text;
|
||||
break;
|
||||
case "mod_time":
|
||||
$parse_result->mod_time = $text;
|
||||
break;
|
||||
case "global_preferences":
|
||||
break;
|
||||
case "project_preferences":
|
||||
|
@ -117,7 +125,7 @@ function char_handler($parser, $x) {
|
|||
|
||||
function prefs_parse($prefs_xml) {
|
||||
global $parse_result;
|
||||
|
||||
|
||||
$parse_result = null;
|
||||
$parse_result->dont_run_on_batteries = 0;
|
||||
$parse_result->dont_run_if_user_active = 0;
|
||||
|
@ -148,7 +156,8 @@ function prefs_show_global($prefs) {
|
|||
|
||||
echo "<p>";
|
||||
echo "<table width=580 cellpadding=4>\n";
|
||||
echo "<tr>".TD2.LG_FONT."<b>Global preferences:</b></font></td></tr>\n";
|
||||
echo "<tr>".TD2.LG_FONT."<b>Global preferences</b></font>
|
||||
<br><font size=-1>These apply to all BOINC projects in which you participate</font></td></tr>\n";
|
||||
if ($prefs->dont_run_on_batteries) {
|
||||
$batteries = "No";
|
||||
} else {
|
||||
|
@ -182,9 +191,11 @@ function prefs_show_global($prefs) {
|
|||
function prefs_show_project($prefs) {
|
||||
echo "<p>";
|
||||
echo "<table width=580 cellpadding=4>\n";
|
||||
echo "<tr>".TD2.LG_FONT."<b>Project preferences:</b></font></td></tr>\n";
|
||||
echo "<tr>".TD2.LG_FONT."<b>Project preferences</b></font>
|
||||
<br><font size=-1>These apply only to this project</font></td></tr>\n";
|
||||
row2a("<b>Resource Share: </b>", $prefs->resource_share);
|
||||
row2a("<b>Project Specific Preferences: </b>", htmlspecialchars($prefs->project_specific));
|
||||
$prefs = project_specific_prefs_parse($prefs);
|
||||
project_specific_prefs_show($prefs);
|
||||
echo "<tr><td><a href=prefs_edit_project_form.php>Edit project preferences</a></td></tr>\n";
|
||||
echo "</table>";
|
||||
}
|
||||
|
@ -199,63 +210,62 @@ function print_prefs_display($user) {
|
|||
// Functions to display preference subsets as forms
|
||||
//
|
||||
function prefs_form_global($user, $prefs) {
|
||||
echo "<form action=prefs_edit_global_action.php>\n";
|
||||
echo " <table cellpadding=6>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align=right><b>Don't run if computer is on batteries</b></td>\n";
|
||||
echo "<form action=prefs_edit_global_action.php>\n
|
||||
<table cellpadding=6>\n
|
||||
<tr>\n
|
||||
<td align=right>Don't run if computer is on batteries</td>\n";
|
||||
printf(" <td><input type=checkbox name=dont_run_on_batteries %s></td>\n", $prefs->dont_run_on_batteries?"checked":"");
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align=right><b>Don't run if user is active</b></td>\n";
|
||||
echo " </tr>\n
|
||||
<tr>\n
|
||||
<td align=right>Don't run if user is active</td>\n";
|
||||
printf(" <td><input type=checkbox name=dont_run_if_user_active %s></td>\n", $prefs->dont_run_if_user_active?"checked":"");
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align=right><b>Confirm before connecting</b></td>\n";
|
||||
echo " </tr>\n
|
||||
<tr>\n
|
||||
<td align=right>Confirm before connecting</td>\n";
|
||||
printf(" <td><input type=checkbox name=confirm_before_connecting %s></td>\n", $prefs->confirm_before_connecting?"checked":"");
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align=right><b>Minimum amount of work to buffer (days)</b></td>\n";
|
||||
printf(" <td><input size=5 name=low_water_days value='$prefs->low_water_days'></td>\n");
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align=right><b>Maximum amount of work to buffer (days)</b></td>\n";
|
||||
printf(" <td><input size=5 name=high_water_days value='$prefs->high_water_days'></td>\n");
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align=right><b>Maximum disk space allowed<br>to be used for BOINC (in GB)</b></td>\n";
|
||||
echo " <td><input size=7 name=disk_max_used_gb value='$prefs->disk_max_used_gb'></td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align=right><b>Minimum disk space to leave<br>free (in GB)</b></td>\n";
|
||||
echo " <td><input size=7 name=disk_min_free_gb value='$prefs->disk_min_free_gb'></td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align=right><b>Maximum % of disk space to<br>use for BOINC</b></td>\n";
|
||||
echo " <td><input size=5 name=disk_max_used_pct value='$prefs->disk_max_used_pct'></td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " </table>\n";
|
||||
echo " <input type=submit value=\"Edit Preferences\">\n";
|
||||
echo "</form>\n";
|
||||
echo " </tr>\n
|
||||
<tr>\n
|
||||
<td align=right>Minimum amount of work to buffer</td>\n";
|
||||
printf(" <td><input size=5 name=low_water_days value='$prefs->low_water_days'> days</td>\n");
|
||||
echo " </tr>\n
|
||||
<tr>\n
|
||||
<td align=right>Maximum amount of work to buffer</td>\n";
|
||||
printf(" <td><input size=5 name=high_water_days value='$prefs->high_water_days'> days</td>\n");
|
||||
echo " </tr>\n
|
||||
<tr>\n
|
||||
<td align=right>Maximum disk space allowed<br>to be used for BOINC</td>\n
|
||||
<td><input size=7 name=disk_max_used_gb value='$prefs->disk_max_used_gb'> Gbytes</td>\n
|
||||
</tr>\n
|
||||
<tr>\n
|
||||
<td align=right>Minimum disk space to leave free</td>\n
|
||||
<td><input size=7 name=disk_min_free_gb value='$prefs->disk_min_free_gb'> Gbytes</td>\n
|
||||
</tr>\n
|
||||
<tr>\n
|
||||
<td align=right>Maximum % of disk space to<br>use for BOINC</td>\n
|
||||
<td><input size=5 name=disk_max_used_pct value='$prefs->disk_max_used_pct'></td>\n
|
||||
</tr>\n
|
||||
</table>\n
|
||||
<input type=submit value=\"Edit Preferences\">\n
|
||||
</form>\n";
|
||||
}
|
||||
|
||||
function prefs_form_project($prefs) {
|
||||
echo "<form action=prefs_edit_project_action.php>\n";
|
||||
echo " <table cellpadding=6>\n";
|
||||
echo " <tr>\n";
|
||||
|
||||
echo " <td align=right><b>Resource share:</b><br><font size=-1> (If projects";
|
||||
echo " compete for resources,<br>this is the fraction of resources you<br>choose to";
|
||||
echo " allocate to this project.)</font></td>\n";
|
||||
|
||||
echo " <td><input name=resource_share value='$prefs->resource_share'></td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align=right><b>Project-specific preferences:</b></td>\n";
|
||||
echo " <td><input name=project_specific value='$prefs->project_specific'></td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " <tr><td><br></td><td><input type=submit value=OK></td></tr>\n";
|
||||
echo " </table>\n";
|
||||
echo " </form>\n";
|
||||
echo "<form action=prefs_edit_project_action.php>\n
|
||||
<table cellpadding=6>\n
|
||||
<tr>\n
|
||||
<td align=right><b>Resource share:</b><br><font size=-1>
|
||||
If you participate in multiple projects,
|
||||
<br>this is the proportion of resources
|
||||
<br>allocated to this project.
|
||||
</font></td>\n
|
||||
<td><input name=resource_share value='$prefs->resource_share'></td>\n
|
||||
</tr>\n";
|
||||
$prefs = project_specific_prefs_parse($prefs);
|
||||
project_specific_prefs_edit($prefs);
|
||||
echo "
|
||||
<tr><td><br></td><td><input type=submit value=OK></td></tr>\n
|
||||
</table>\n
|
||||
</form>\n";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
@ -277,7 +287,7 @@ function prefs_global_parse_form(&$prefs) {
|
|||
function prefs_project_parse_form(&$prefs) {
|
||||
parse_str(getenv("QUERY_STRING"));
|
||||
$prefs->resource_share = $resource_share;
|
||||
$prefs->project_specific = $project_specific;
|
||||
$prefs->project_specific = project_specific_prefs_parse_form();
|
||||
}
|
||||
|
||||
|
||||
|
@ -322,13 +332,13 @@ function project_prefs_make_xml($prefs) {
|
|||
//
|
||||
// Update user's prefs in database, from a given structure
|
||||
//
|
||||
function global_prefs_update($user, $prefs) {
|
||||
function global_prefs_update(&$user, $prefs) {
|
||||
$prefs_xml = global_prefs_make_xml($prefs);
|
||||
mysql_query("update user set global_prefs='$prefs_xml' where id=$user->id");
|
||||
$user->global_prefs = $prefs_xml;
|
||||
}
|
||||
|
||||
function project_prefs_update($user, $prefs) {
|
||||
function project_prefs_update(&$user, $prefs) {
|
||||
$prefs_xml = project_prefs_make_xml($prefs);
|
||||
mysql_query("update user set project_prefs='$prefs_xml' where id=$user->id");
|
||||
$user->project_prefs = $prefs_xml;
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
$user = get_user_from_auth($authenticator);
|
||||
require_login($user);
|
||||
|
||||
page_head("Preferences");
|
||||
print_prefs_display($user);
|
||||
page_tail();
|
||||
page_head("Preferences");
|
||||
print_prefs_display($user);
|
||||
page_tail();
|
||||
|
||||
?>
|
||||
|
|
|
@ -13,7 +13,7 @@ if ($user == NULL) {
|
|||
exit();
|
||||
}
|
||||
page_head("Edit Global Preferences");
|
||||
$prefs = prefs_parse($user->prefs);
|
||||
$prefs = prefs_parse($user->global_prefs);
|
||||
prefs_form_global($user, $prefs);
|
||||
echo "<a href=prefs.php>Back to preferences</a>\n";
|
||||
echo "<p>\n";
|
||||
|
|
|
@ -13,6 +13,7 @@ if ($user == NULL) {
|
|||
exit();
|
||||
}
|
||||
|
||||
no_cache();
|
||||
page_head("Preferences");
|
||||
$prefs = prefs_parse($user->project_prefs);
|
||||
prefs_project_parse_form($prefs);
|
||||
|
|
|
@ -14,8 +14,8 @@ if ($user == NULL) {
|
|||
}
|
||||
page_head("Edit project preferences");
|
||||
parse_str(getenv("QUERY_STRING"));
|
||||
$prefs = prefs_parse($user->prefs);
|
||||
prefs_form_project($prefs->project, "prefs_edit_project_action.php");
|
||||
$prefs = prefs_parse($user->project_prefs);
|
||||
prefs_form_project($prefs);
|
||||
echo "<p>\n";
|
||||
page_tail();
|
||||
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
// Functions to display and edit project-specific prefs go here
|
||||
|
||||
// The code here is a sample. Projects must supply their own.
|
||||
|
||||
function option($name, $val) {
|
||||
if ($name == $val) {
|
||||
$x = "selected";
|
||||
} else {
|
||||
$x = "";
|
||||
}
|
||||
echo "<option name='$name' $x>$name\n";
|
||||
}
|
||||
|
||||
// given struct, show form for editing
|
||||
//
|
||||
function project_specific_prefs_edit($prefs) {
|
||||
$x = $prefs->color_scheme;
|
||||
echo "<tr>\n
|
||||
<td align=right>Color scheme:</td>\n
|
||||
<td>\n
|
||||
<select name=color_scheme>\n";
|
||||
option("Tahiti Sunset", $x);
|
||||
option("Desert Sands", $x);
|
||||
echo "
|
||||
</select>\n
|
||||
</td>\n
|
||||
</tr>";
|
||||
}
|
||||
|
||||
// QUERY_STRING has already been parsed into variables.
|
||||
// Return XML version of project-specific prefs
|
||||
//
|
||||
function project_specific_prefs_parse_form() {
|
||||
parse_str(getenv("QUERY_STRING"));
|
||||
return "<color_scheme>$color_scheme</color_scheme>";
|
||||
}
|
||||
|
||||
// show non-editable version of prefs
|
||||
//
|
||||
function project_specific_prefs_show($prefs) {
|
||||
echo "<tr>\n
|
||||
<td><b>Color scheme:</b></td>\n
|
||||
<td>$prefs->color_scheme</td>\n
|
||||
</tr>\n";
|
||||
}
|
||||
|
||||
// parse XML, fill in struct
|
||||
//
|
||||
function project_specific_prefs_parse($prefs) {
|
||||
$xml = $prefs->project_specific;
|
||||
$prefs->color_scheme = parse_element($xml, "<color_scheme>");
|
||||
return $prefs;
|
||||
}
|
|
@ -82,11 +82,11 @@ function page_head($title) {
|
|||
|
||||
function page_tail() {
|
||||
|
||||
echo "<br><br><a href=index.php>Return to main ".PROJECT." page</a><br>\n";
|
||||
echo "<br><hr><center><a href=index.php>Return to main ".PROJECT." page</a><br>\n";
|
||||
|
||||
// put your copyright notice etc. here
|
||||
|
||||
echo "<hr>Copyright (c) 2002 Sample Project\n";
|
||||
echo "<br><br>Copyright (c) 2002 ".PROJECT."</center>\n";
|
||||
}
|
||||
|
||||
function date_str($when) {
|
||||
|
@ -164,4 +164,13 @@ function parse_config($tag) {
|
|||
return $element;
|
||||
}
|
||||
|
||||
// Call this if for dynamic pages
|
||||
//
|
||||
function no_cache() {
|
||||
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
|
||||
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
||||
header ("Pragma: no-cache"); // HTTP/1.0
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "countries.h"
|
||||
|
||||
char *countries[NUM_COUNTRIES] = {
|
||||
"None",
|
||||
"United States",
|
||||
"Afghanistan",
|
||||
"Albania",
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define NUM_COUNTRIES 226
|
||||
#define NUM_COUNTRIES 227
|
||||
extern char *countries[NUM_COUNTRIES];
|
||||
|
|
Loading…
Reference in New Issue