2008-02-11 23:38:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once("../inc/bossa_db.inc");
|
2008-02-15 15:25:44 +00:00
|
|
|
require_once("../inc/bolt_db.inc");
|
2008-02-11 23:38:31 +00:00
|
|
|
require_once("../inc/util_ops.inc");
|
|
|
|
|
|
|
|
function show_bapp($app) {
|
|
|
|
echo "<tr>
|
2008-02-12 20:33:05 +00:00
|
|
|
<td>Name: $app->name<br>
|
|
|
|
Short name: $app->short_name<br>
|
|
|
|
Description: $app->description<br>
|
|
|
|
Created: ".date_str($app->create_time)."
|
|
|
|
</td>
|
2008-02-11 23:38:31 +00:00
|
|
|
<td>
|
|
|
|
";
|
|
|
|
if ($app->hidden) {
|
2008-02-13 04:25:52 +00:00
|
|
|
show_button("bossa_admin.php?action=unhide&app_id=$app->id", "Unhide", "Unhide this app");
|
2008-02-11 23:38:31 +00:00
|
|
|
} else {
|
2008-02-13 04:25:52 +00:00
|
|
|
show_button("bossa_admin.php?action=hide&app_id=$app->id", "Hide", "Hide this app");
|
2008-02-11 23:38:31 +00:00
|
|
|
}
|
2008-02-15 15:25:44 +00:00
|
|
|
echo "<br>";
|
|
|
|
show_button("bossa_admin.php?action=show_jobs&app_id=$app->id", "Show jobs", "Show jobs");
|
|
|
|
echo "<br><form action=".$app->short_name."_workgen.php>
|
|
|
|
Create <input name=njobs size=5> new jobs
|
|
|
|
<input type=submit value=OK>
|
|
|
|
</form>
|
|
|
|
";
|
2008-02-11 23:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_apps() {
|
|
|
|
$apps = BossaApp::enum();
|
|
|
|
start_table();
|
2008-02-13 04:25:52 +00:00
|
|
|
row1("Existing apps", 2);
|
|
|
|
table_header("Name/description", "");
|
2008-02-11 23:38:31 +00:00
|
|
|
foreach ($apps as $app) {
|
|
|
|
show_bapp($app);
|
|
|
|
}
|
|
|
|
end_table();
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_app_form() {
|
|
|
|
echo "
|
2008-02-13 04:25:52 +00:00
|
|
|
<form action=bossa_admin.php method=get>
|
2008-03-03 19:33:32 +00:00
|
|
|
<input type=hidden name=action value=add_app>
|
2008-02-11 23:38:31 +00:00
|
|
|
";
|
|
|
|
start_table();
|
|
|
|
row1("Add app");
|
2008-02-13 19:02:44 +00:00
|
|
|
row2(
|
|
|
|
"Name<span class=note><br>Visible to users</span>",
|
|
|
|
"<input name=app_name>"
|
|
|
|
);
|
|
|
|
row2(
|
|
|
|
"Short name<span class=note><br>Used in file and function names - no spaces or special characters</span>",
|
|
|
|
"<input name=short_name>"
|
|
|
|
);
|
|
|
|
row2(
|
|
|
|
"Description<span class=note><br>Visible to users</span>",
|
|
|
|
"<textarea name=description cols=60></textarea>"
|
|
|
|
);
|
|
|
|
row2(
|
|
|
|
"Min confidence sum for consensus",
|
|
|
|
"<input name=min_conf_sum value=2>"
|
|
|
|
);
|
|
|
|
row2(
|
|
|
|
"Min confidence fraction for consensus",
|
|
|
|
"<input name=min_conf_frac value=\"0.5\">"
|
|
|
|
);
|
2008-02-12 20:33:05 +00:00
|
|
|
row2("Max job instances", "<input name=max_instances value=5>");
|
2008-02-13 19:02:44 +00:00
|
|
|
row2("Name of Bolt training course", "<input name=training_course>");
|
2008-03-03 19:33:32 +00:00
|
|
|
row2("", "<input type=submit submit value=\"Create app\">");
|
2008-02-11 23:38:31 +00:00
|
|
|
end_table();
|
|
|
|
echo "</form>";
|
|
|
|
}
|
|
|
|
|
|
|
|
function user_settings() {
|
|
|
|
global $user;
|
|
|
|
$flags = $user->bossa->flags;
|
2008-03-03 19:33:32 +00:00
|
|
|
echo "<form action=bossa_admin.php method=get>
|
|
|
|
<input type=hidden name=action value=update_user>
|
|
|
|
";
|
2008-02-11 23:38:31 +00:00
|
|
|
start_table();
|
|
|
|
row1("User settings");
|
|
|
|
$x = ($flags&BOLT_FLAGS_SHOW_ALL)?"checked":"";
|
|
|
|
row2("Show hidden apps?", "<input type=checkbox name=show_all $x>");
|
|
|
|
$x = ($flags&BOLT_FLAGS_DEBUG)?"checked":"";
|
|
|
|
row2("Show debugging output?", "<input type=checkbox name=debug $x>");
|
2008-03-03 19:33:32 +00:00
|
|
|
row2("", "<input type=submit value=\"Update user\">");
|
2008-02-11 23:38:31 +00:00
|
|
|
end_table();
|
|
|
|
echo "</form>";
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_all() {
|
2008-02-15 15:25:44 +00:00
|
|
|
admin_page_head("Bossa administration");
|
2008-02-11 23:38:31 +00:00
|
|
|
show_apps();
|
|
|
|
echo "<p>";
|
|
|
|
add_app_form();
|
|
|
|
echo "<p>";
|
|
|
|
user_settings();
|
|
|
|
admin_page_tail();
|
|
|
|
}
|
|
|
|
|
2008-02-13 04:25:52 +00:00
|
|
|
function show_jobs($app_id) {
|
|
|
|
$app = BossaApp::lookup_id($app_id);
|
2008-02-15 15:25:44 +00:00
|
|
|
echo "<h2>Jobs for $app->name</h2>";
|
2008-02-13 04:25:52 +00:00
|
|
|
$jobs = BossaJob::enum("app_id=$app_id");
|
|
|
|
foreach ($jobs as $job) {
|
|
|
|
echo "<pre>\n";
|
|
|
|
print_r($job);
|
|
|
|
echo "</pre>\n";
|
|
|
|
echo "
|
2008-02-15 15:25:44 +00:00
|
|
|
<a href=bossa_admin.php?action=show_insts&job_id=$job->id>Show instances</a>
|
2008-02-13 04:25:52 +00:00
|
|
|
<hr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_insts($job_id) {
|
|
|
|
echo "<h2>Job instances</h2>";
|
|
|
|
$jis = BossaJobInst::enum("job_id=$job_id");
|
|
|
|
foreach ($jis as $ji) {
|
|
|
|
echo "<pre>\n";
|
|
|
|
print_r($ji);
|
|
|
|
echo "</pre><hr>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-11 23:38:31 +00:00
|
|
|
$user = get_logged_in_user();
|
2008-03-03 19:33:32 +00:00
|
|
|
BossaUser::lookup($user);
|
2008-02-11 23:38:31 +00:00
|
|
|
|
2008-02-15 15:25:44 +00:00
|
|
|
$action = get_str('action', true);
|
|
|
|
switch ($action) {
|
2008-03-03 19:33:32 +00:00
|
|
|
case 'add_app':
|
2008-02-11 23:38:31 +00:00
|
|
|
$name = BossaDb::escape_string(get_str('app_name'));
|
2008-02-13 04:25:52 +00:00
|
|
|
$short_name = get_str('short_name');
|
2008-02-11 23:38:31 +00:00
|
|
|
$description = BossaDb::escape_string(get_str('description'));
|
|
|
|
$min_conf_sum = get_str('min_conf_sum');
|
|
|
|
$min_conf_frac = get_str('min_conf_frac');
|
|
|
|
$max_instances = get_str('max_instances');
|
2008-02-13 19:02:44 +00:00
|
|
|
$training_course = get_str('training_course');
|
|
|
|
if (strlen($training_course)) {
|
|
|
|
$course = BoltCourse::lookup_name($training_course);
|
|
|
|
if (!$course) {
|
|
|
|
error_page("No course named $training_course");
|
|
|
|
}
|
|
|
|
$courseid = $course->id;
|
|
|
|
} else {
|
|
|
|
$courseid = 0;
|
|
|
|
}
|
2008-02-11 23:38:31 +00:00
|
|
|
$now = time();
|
2008-02-13 19:02:44 +00:00
|
|
|
$app_id = BossaApp::insert("(create_time, name, short_name, description, min_conf_sum, min_conf_frac, max_instances, bolt_course_id) values ($now, '$name', '$short_name', '$description', $min_conf_sum, $min_conf_frac, $max_instances, $courseid)");
|
|
|
|
if ($courseid) {
|
|
|
|
$course->update("bossa_app_id=$app_id");
|
|
|
|
}
|
2008-02-13 04:25:52 +00:00
|
|
|
Header('Location: bossa_admin.php');
|
2008-02-11 23:38:31 +00:00
|
|
|
exit();
|
2008-03-03 19:33:32 +00:00
|
|
|
case 'update_user':
|
2008-02-11 23:38:31 +00:00
|
|
|
$flags = 0;
|
|
|
|
if (get_str('show_all', true)) $flags |= BOLT_FLAGS_SHOW_ALL;
|
|
|
|
if (get_str('debug', true)) $flags |= BOLT_FLAGS_DEBUG;
|
|
|
|
$user->bossa->update("flags=$flags");
|
|
|
|
$user->bossa->flags = $flags;
|
2008-02-13 04:25:52 +00:00
|
|
|
Header('Location: bossa_admin.php');
|
2008-02-11 23:38:31 +00:00
|
|
|
exit();
|
2008-02-15 15:25:44 +00:00
|
|
|
case 'show_jobs':
|
2008-02-13 04:25:52 +00:00
|
|
|
$app_id = $_GET['app_id'];
|
|
|
|
show_jobs($app_id);
|
2008-02-15 15:25:44 +00:00
|
|
|
exit();
|
|
|
|
case 'show_insts':
|
2008-02-13 04:25:52 +00:00
|
|
|
$job_id = $_GET['job_id'];
|
|
|
|
show_insts($job_id);
|
2008-02-15 15:25:44 +00:00
|
|
|
exit();
|
|
|
|
case 'hide':
|
|
|
|
$app_id = get_int('app_id');
|
|
|
|
$app = BossaApp::lookup_id($app_id);
|
|
|
|
if (!$app) error_page("no such app");
|
|
|
|
$app->update("hidden=1");
|
|
|
|
break;
|
|
|
|
case 'unhide':
|
|
|
|
$app_id = get_int('app_id');
|
|
|
|
$app = BossaApp::lookup_id($app_id);
|
|
|
|
if (!$app) error_page("no such app");
|
|
|
|
$app->update("hidden=0");
|
|
|
|
break;
|
|
|
|
case '':
|
|
|
|
show_all();
|
|
|
|
exit();
|
|
|
|
default:
|
|
|
|
error_page("unknown action $action");
|
2008-02-11 23:38:31 +00:00
|
|
|
}
|
2008-02-15 15:25:44 +00:00
|
|
|
Header('Location: bossa_admin.php');
|
2008-02-11 23:38:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
?>
|