.
// functions for display and editing project preferences
// Preferences are represented in two ways:
// - As a PHP structure (usually called $prefs)
// The field "project_specific" is plain XML
// - As XML (usually called $prefs_xml)
//
// This XML has the general structure
//
//
"
.tra("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3. %2")
."",
"resource_share",
new NUM_SPEC("", 0, 9999999, 100)
),
);
if (!empty($accelerate_gpu_apps_pref)) {
$project_pref_descs[] = new PREF_BOOL(
tra("Accelerate GPU tasks by dedicating a CPU to each one?"),
"accelerate_gpu_apps",
false
);
}
if ($app_types->cpu) {
$project_pref_descs[] = new PREF_BOOL (
tra("Use CPU")
."
"
.tra("Enforced by version 6.10+")
."",
"no_cpu",
false,
true
);
}
if ($app_types->ati) {
$project_pref_descs[] = new PREF_BOOL (
tra("Use ATI GPU")
."
"
.tra("Enforced by version 6.10+")
."",
"no_ati",
false,
true
);
}
if ($app_types->cuda) {
$project_pref_descs[] = new PREF_BOOL (
tra("Use NVIDIA GPU")
."
"
.tra("Enforced by version 6.10+")
."",
"no_cuda",
false,
true
);
}
if ($app_types->intel_gpu) {
$project_pref_descs[] = new PREF_BOOL (
tra("Use Intel GPU")
."
"
.tra("Enforced by version 7.2+")
."",
"no_intel_gpu",
false,
true
);
}
if (project_has_beta()) {
$project_pref_descs[] = new PREF_BOOL(
tra("Run test applications?")
."
"
.tra("This helps us develop applications, but may cause jobs to fail on your computer")
."",
"allow_beta_work",
false
);
}
if (defined("EMAIL_FROM")) {
$x = "
"
.tra("Emails will be sent from %1; make sure your spam filter accepts this address.", EMAIL_FROM)
."";
} else {
$x = "";
}
$privacy_pref_descs = array (
new PREF_BOOL(
tra("Is it OK for %1 and your team (if any) to email you?", PROJECT).$x,
"send_email",
true,
false
),
new PREF_BOOL(
tra("Should %1 show your computers on its web site?", PROJECT),
"show_hosts",
true,
false
),
);
global $text;
global $parse_result;
global $top_parse_result;
global $in_project_specific;
global $venue_name;
// functions to parse preferences XML into a struct
//
function element_start_project($parser, $name, $attrs) {
global $top_parse_result;
global $parse_result;
global $text;
global $in_project_specific;
global $venue_name;
switch($name) {
case "venue":
$venue_name = $attrs["name"];
$top_parse_result = $parse_result;
$parse_result = default_prefs_project();
break;
case "project_specific":
$in_project_specific = 1;
$text = "";
break;
default:
if ($in_project_specific) {
$text= $text."<$name>";
} else {
$text = "";
}
}
}
function element_end_project($parser, $name) {
global $text;
global $parse_result;
global $in_project_specific;
global $top_parse_result;
global $venue_name;
global $project_pref_descs;
foreach($project_pref_descs as $p) {
if ($p->xml_parse($parse_result, $name, $text)) {
return;
}
}
switch($name) {
case "venue":
$top_parse_result->$venue_name = $parse_result;
$parse_result = $top_parse_result;
break;
case "project_specific":
$parse_result->project_specific = $text;
$in_project_specific = false;
break;
case "project_preferences":
break;
default:
if ($in_project_specific) {
$text = $text."$name>";
} else {
//echo "Unknown tag: $name\n";
}
}
}
function default_prefs_project() {
global $project_pref_descs;
$p = new StdClass;
foreach ($project_pref_descs as $pref) {
$pref->set_default($p);
}
$p->project_specific = project_specific_prefs_default();
return $p;
}
// parse prefs from XML to a struct
//
function prefs_parse_project($prefs_xml) {
global $parse_result;
$parse_result = default_prefs_project();
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
xml_set_element_handler($xml_parser, "element_start_project", "element_end_project");
xml_set_character_data_handler($xml_parser, "char_handler");
xml_parse($xml_parser, $prefs_xml, 1);
return $parse_result;
}
function prefs_show_project($prefs, $columns=false) {
global $project_pref_descs;
if ($columns) {
foreach ($project_pref_descs as $p) {
$p->show_cols($prefs);
}
} else {
foreach ($project_pref_descs as $p) {
$p->show($prefs);
}
}
}
function prefs_show_privacy($user, $columns) {
global $privacy_pref_descs;
if ($columns) {
foreach ($privacy_pref_descs as $p) {
$p->show_cols($user);
}
} else {
foreach ($privacy_pref_descs as $p) {
$p->show($user);
}
}
}
function prefs_show_project_specific($prefs, $columns=false) {
if ($columns) {
$project_specific_prefs = project_specific_prefs_parse($prefs->project_specific);
$project_specific_prefs->home = isset($prefs->home) ? project_specific_prefs_parse($prefs->home->project_specific) : "";
$project_specific_prefs->work = isset($prefs->work) ? project_specific_prefs_parse($prefs->work->project_specific) : "";
$project_specific_prefs->school = isset($prefs->school) ? project_specific_prefs_parse($prefs->school->project_specific) : "";
} else {
$project_specific_prefs = project_specific_prefs_parse($prefs->project_specific);
}
project_specific_prefs_show($project_specific_prefs, $columns);
}
function print_prefs_display_project($user, $columns=false) {
$project_prefs = prefs_parse_project($user->project_prefs);
start_table();
$switch_link = " ".tra("(Switch View)")."";
if ($columns) {
row1(tra("Combined preferences").$switch_link, 2, "heading");
echo "