diff --git a/db/db.h b/db/db.h index fd21e0c9c1..4e205ce156 100644 --- a/db/db.h +++ b/db/db.h @@ -32,9 +32,17 @@ // Maximum allowed size for SQL based blobs (Binary Large Object) #define MAX_BLOB_SIZE 4096 +// represents the project as a whole. +// There is only of these per DB +// struct PROJECT { int id; - char name[256]; + char short_name[256]; + // used as directory name and part of DB name of server side, + // so no spaces or special chars + char long_name[256]; + // shown on client side, e.g. in GUI + // can contain spaces etc. }; // A compilation target, i.e. a architecture/OS combination. diff --git a/db/db_mysql.C b/db/db_mysql.C index 997b439f2c..fba8932368 100644 --- a/db/db_mysql.C +++ b/db/db_mysql.C @@ -95,9 +95,10 @@ void BOINC_MYSQL_DB::struct_to_str(void* vp, char* q, int type) { case TYPE_PROJECT: prp = (PROJECT*)vp; sprintf(q, - "id=%d, name='%s'", + "id=%d, short_name='%s', long_name='%s'", prp->id, - prp->name + prp->short_name, + prp->long_name ); break; case TYPE_PLATFORM: @@ -335,7 +336,8 @@ void BOINC_MYSQL_DB::row_to_struct(MYSQL_ROW& r, void* vp, int type) { prp = (PROJECT*)vp; memset(prp, 0, sizeof(PROJECT)); prp->id = atoi(r[i++]); - strcpy2(prp->name, r[i++]); + strcpy2(prp->short_name, r[i++]); + strcpy2(prp->long_name, r[i++]); break; case TYPE_PLATFORM: pp = (PLATFORM*)vp; diff --git a/db/schema.sql b/db/schema.sql index 3bb60825a0..6cd9dcf8f3 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -2,7 +2,8 @@ use BOINC_DB_NAME create table project ( id integer not null auto_increment, - name varchar(254) not null, + short_name varchar(254) not null, + long_name varchar(254) not null, primary key (id) ); diff --git a/html/user/prefs.inc b/html/user/prefs.inc index a7ca37c3c2..7aa7954d97 100644 --- a/html/user/prefs.inc +++ b/html/user/prefs.inc @@ -97,10 +97,10 @@ function element_end($parser, $name) { $parse_result->resource_share = $text; break; case "show_email": - $parse_result->show_email = $text; + $parse_result->show_email = true; break; case "send_email": - $parse_result->send_email = $text; + $parse_result->send_email = true; break; case "mod_time": $parse_result->mod_time = $text; @@ -123,6 +123,8 @@ function char_handler($parser, $x) { $text = $text.$x; } +// state of prefs for new users +// function default_prefs() { $p = null; $p->dont_run_on_batteries = 1; @@ -135,15 +137,25 @@ function default_prefs() { $p->disk_min_free_gb = 1; $p->resource_share = 100; - $p->show_email = 0; - $p->send_email = 1; + $p->show_email = false; + $p->send_email = true; return $p; } +// 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 +// function prefs_parse($prefs_xml) { global $parse_result; - $parse_result = default_prefs(); + $parse_result = initial_prefs(); $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0); @@ -216,7 +228,7 @@ function print_prefs_display($user) { prefs_show_resource($project_prefs); prefs_show_project($project_specific_prefs); - prefs_show_email($global_prefs); + prefs_show_email($project_prefs); prefs_show_global($global_prefs); echo ""; } @@ -390,9 +402,15 @@ function global_prefs_make_xml($prefs) { function project_prefs_make_xml($prefs) { $xml = "\n"; + if ($prefs->show_email) { + $xml = $xml."\n"; + } + if ($prefs->send_email) { + $xml = $xml."\n"; + } $xml = $xml ."$prefs->resource_share\n" - ."\n$prefs->project_specific\n\n"; + ."\n$prefs->project_specific\n"; $xml = $xml."\n"; return $xml; } diff --git a/sched/server_types.C b/sched/server_types.C index 730a685072..b9a088a077 100644 --- a/sched/server_types.C +++ b/sched/server_types.C @@ -134,19 +134,19 @@ int SCHEDULER_REPLY::write(FILE* fout) { if (nucleus_only) goto end; fprintf(fout, - "%s\n", - gproject.name + "%s\n", + gproject.long_name ); fprintf(fout, - "%s\n" - "%f\n" - "%f\n" - "%d\n", - user.name, - user.total_credit, - user.expavg_credit, - user.create_time + "%s\n" + "%f\n" + "%f\n" + "%d\n", + user.name, + user.total_credit, + user.expavg_credit, + user.create_time ); if (hostid) { @@ -159,7 +159,7 @@ int SCHEDULER_REPLY::write(FILE* fout) { host.total_credit, host.expavg_credit, host.create_time - ); + ); } if (send_global_prefs) {