boinc/html/inc/bolt_util.inc

55 lines
1.6 KiB
PHP
Raw Normal View History

<?php
function info_incomplete($user) {
if (!$user->bolt->birth_year) return true;
if (!$user->bolt->sex) return true;
return false;
}
function birth_year_select($user) {
$this_year = date("Y");
$x = "<select name=birth_year>\n";
for ($i=$this_year-100; $i<$this_year; $i++) {
$s = ($i == $user->bolt->birth_year)?"selected":"";
$x .= "<option value=$i $s>$i</option>\n";
}
$s = (!$user->bolt->birth_year)?"selected":"";
$x .= "<option value=$0 $s>Unspecified</option>\n";
$x .= "</select>\n";
return $x;
}
function sex_select($user) {
$x = "<select name=sex>\n";
$s = ($user->bolt->sex == 0)?"selected":"";
$x .= "<option value=0 $s>Unspecified</option>\n";
$s = ($user->bolt->sex == 1)?"selected":"";
$x .= "<option value=1 $s>Male</option>\n";
$s = ($user->bolt->sex == 2)?"selected":"";
$x .= "<option value=2 $s>Female</option>\n";
$x .= "</select>\n";
return $x;
}
function request_info($user, $course) {
page_head("About you");
echo "
You may optionally tell us some facts about yourself.
This information will help us improve this course,
and will be kept private.
<p>
<form action=bolt_sched.php>
<input type=hidden name=action value=update_info>
<input type=hidden name=course_id value=$course->id>
";
start_table();
row2("Birth year", birth_year_select($user));
row2("Sex", sex_select($user));
row2("", "<input type=submit value=OK>");
end_table();
echo "</form>\n";
page_tail();
}
?>