From 7d3bc3e3cf3565d66ecff7250c62d4b6c7efc2f8 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 24 Sep 2012 06:35:38 +0000 Subject: [PATCH] - web: add global prefs reset button - change default disk prefs to: - no absolute limit on disk usage (we need to work with future disks) - keep 100 MB min free space - use up to 90% of total space svn path=/trunk/boinc/; revision=26141 --- checkin_notes | 16 ++++++++++++ html/inc/prefs.inc | 28 ++++++++++++--------- html/user/prefs.php | 20 +++++++++++++-- html/user/prefs_default.php | 49 +++++++++++++++++++++++++++++++++++++ lib/prefs.cpp | 4 +-- 5 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 html/user/prefs_default.php diff --git a/checkin_notes b/checkin_notes index 198b58b2a3..17b9bdf736 100644 --- a/checkin_notes +++ b/checkin_notes @@ -6047,3 +6047,19 @@ David 22 Sept 2012 cs_statefile.cpp script/ boinc-client.in + +David 23 Sept 2012 + - web: add global prefs reset button + - change default disk prefs to: + - no absolute limit on disk usage (we need to work with future disks) + - keep 100 MB min free space + - use up to 90% of total space + + html/ + user/ + prefs_default.php (new) + prefs.php + inc/ + prefs.inc + lib/ + prefs.cpp diff --git a/html/inc/prefs.inc b/html/inc/prefs.inc index a3ba79ece5..74c295bf2c 100644 --- a/html/inc/prefs.inc +++ b/html/inc/prefs.inc @@ -408,9 +408,9 @@ function get_disk_space_config() { $dp->disk_max_used_pct = parse_config($config, ""); $dp->disk_min_free_gb = parse_config($config, ""); // set some defaults if not found - if (!$dp->disk_max_used_gb) $dp->disk_max_used_gb = 100; // 100 gb - if (!$dp->disk_max_used_pct) $dp->disk_max_used_pct = 50; // 50 percent - if (!$dp->disk_min_free_gb) $dp->disk_min_free_gb=.001; // 1 megabyte + if (!$dp->disk_max_used_gb) $dp->disk_max_used_gb = 0; // no limit + if (!$dp->disk_max_used_pct) $dp->disk_max_used_pct = 90; // 90 percent + if (!$dp->disk_min_free_gb) $dp->disk_min_free_gb=.1; // 100 MB // set mininimum free space scheduler allows // - depends on which scheduler is running $dp->new_sched_flag = 1; @@ -584,7 +584,7 @@ function default_prefs_project() { global $project_pref_descs; $p = null; - foreach($project_pref_descs as $pref) { + foreach ($project_pref_descs as $pref) { $pref->set_default($p); } $p->project_specific = project_specific_prefs_default(); @@ -814,7 +814,10 @@ function prefs_display_venue($prefs, $venue, $subset) { prefs_show_project($x); prefs_show_project_specific($x); } - row2("
", "".tra("Edit preferences")." | ".tra("Remove").""); + row2("
", + "".tra("Edit preferences")." + | ".tra("Remove")." + "); end_table(); echo "\n"; } else { @@ -889,7 +892,9 @@ function print_prefs_display_global($user, $columns=false) { start_table(); prefs_show_global($global_prefs); $tokens = url_tokens($user->authenticator); - row2("
", "".tra("Edit preferences").""); + row2("
", + "".tra("Edit preferences")." + "); end_table(); echo "\n"; @@ -1170,12 +1175,10 @@ function global_prefs_update(&$user, $prefs) { $query = "update user set global_prefs='$prefs_xml' where id=$user->id"; $retval = mysql_query($query); if (!$retval) { - echo tra("Update failed: ").htmlspecialchars($query)."\n"; - echo mysql_error(); - exit(); + return 1; } $user->global_prefs = $prefs_xml; - return $retval; + return 0; } function project_prefs_update(&$user, $prefs) { @@ -1184,8 +1187,11 @@ function project_prefs_update(&$user, $prefs) { $show_hosts = $user->show_hosts?1:0; $query = "update user set project_prefs='$prefs_xml', send_email=$send_email, show_hosts=$show_hosts where id=$user->id"; $retval = mysql_query($query); + if (!$retval) { + return 1; + } $user->project_prefs = $prefs_xml; - return $retval; + return 0; } ?> diff --git a/html/user/prefs.php b/html/user/prefs.php index bd055e6d0a..f94017d1b7 100644 --- a/html/user/prefs.php +++ b/html/user/prefs.php @@ -20,8 +20,6 @@ require_once("../inc/db.inc"); require_once("../inc/util.inc"); require_once("../inc/prefs.inc"); -check_get_args(array("subset", "cols", "updated")); - db_init(); $user = get_logged_in_user(); @@ -29,6 +27,7 @@ $user = get_logged_in_user(); $subset = get_str("subset"); $columns = get_int("cols", true); $updated = get_int("updated", true); +$defaults = get_int("defaults", true); page_head(tra("%1 preferences", subset_name($subset))); if (isset($updated)) { @@ -40,11 +39,28 @@ if (isset($updated)) {

"; } +if (isset($defaults)) { + echo "

+ ".tra("Your preferences have been reset to the defaults, and + will take effect when your computer communicates with %1 + or you issue the %2Update%3 command from the BOINC Manager.", + PROJECT, "", "")." +

+ "; +} if ($subset == "global") { print_prefs_display_global($user, $columns); + if (!$defaults) { + show_button( + "prefs_default.php", + "Restore defaults", + "Restore default preferences" + ); + } } else { print_prefs_display_project($user, $columns); } + page_tail(); $cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit diff --git a/html/user/prefs_default.php b/html/user/prefs_default.php new file mode 100644 index 0000000000..5cdf8a62b7 --- /dev/null +++ b/html/user/prefs_default.php @@ -0,0 +1,49 @@ +. + +// reset user's preferences to the defaults + +require_once("../inc/util.inc"); +require_once("../inc/prefs.inc"); + +$confirmed = get_int("confirmed", true); +$user = get_logged_in_user(); + +if (!$confirmed) { + page_head("Confirm reset preferences"); + echo " + You have requested restoring your computing preferences + to the default settings. + Your current preferences will be discarded. + Do you really want to do this? +
+ "; + show_button("prefs_default.php?confirmed=1", "Yes", "Restore default preferences"); + show_button("prefs.php", "No", "Keep current preferences"); + page_tail(); +} else { + $prefs = default_prefs_global(); + $retval = global_prefs_update($user, $prefs); + if ($retval) { + error_page("Couldn't restore default preferences."); + } else { + Header("Location: prefs.php?subset=global&defaults=1$c"); + } +} + +?> diff --git a/lib/prefs.cpp b/lib/prefs.cpp index 5d232e3d22..d383945fea 100644 --- a/lib/prefs.cpp +++ b/lib/prefs.cpp @@ -225,8 +225,8 @@ void GLOBAL_PREFS::defaults() { max_ncpus = 0; cpu_scheduling_period_minutes = 60; disk_interval = 60; - disk_max_used_gb = 10; - disk_max_used_pct = 50; + disk_max_used_gb = 0; + disk_max_used_pct = 90; disk_min_free_gb = 0.1; vm_max_used_frac = 0.75; ram_max_used_busy_frac = 0.5;