Name: $app->name
Short name: $app->short_name
Description: $app->description
Created: ".date_str($app->create_time)." "; if ($app->hidden) { show_button("bossa_admin.php?action=unhide&app_id=$app->id", "Unhide", "Unhide this app"); } else { show_button("bossa_admin.php?action=hide&app_id=$app->id", "Hide", "Hide this app"); } echo "
"; show_button("bossa_admin.php?action=show_jobs&app_id=$app->id", "Show jobs", "Show jobs"); echo "
Create new jobs
"; } function show_apps() { $apps = BossaApp::enum(); start_table(); row1("Existing apps", 2); table_header("Name/description", ""); foreach ($apps as $app) { show_bapp($app); } end_table(); } function add_app_form() { echo "
"; start_table(); row1("Add app"); row2( "Name
Visible to users
", "" ); row2( "Short name
Used in file and function names - no spaces or special characters
", "" ); row2( "Description
Visible to users
", "" ); row2( "Min confidence sum for consensus", "" ); row2( "Min confidence fraction for consensus", "" ); row2("Max job instances", ""); row2("Name of Bolt training course", ""); row2("", ""); end_table(); echo "
"; } function user_settings() { global $user; $flags = $user->bossa->flags; echo "
"; start_table(); row1("User settings"); $x = ($flags&BOLT_FLAGS_SHOW_ALL)?"checked":""; row2("Show hidden apps?", ""); $x = ($flags&BOLT_FLAGS_DEBUG)?"checked":""; row2("Show debugging output?", ""); row2("", ""); end_table(); echo "
"; } function show_all() { admin_page_head("Bossa administration"); show_apps(); echo "

"; add_app_form(); echo "

"; user_settings(); admin_page_tail(); } function show_jobs($app_id) { $app = BossaApp::lookup_id($app_id); echo "

Jobs for $app->name

"; $jobs = BossaJob::enum("app_id=$app_id"); foreach ($jobs as $job) { echo "
\n";
        print_r($job);
        echo "
\n"; echo " id>Show instances
"; } } function show_insts($job_id) { echo "

Job instances

"; $jis = BossaJobInst::enum("job_id=$job_id"); foreach ($jis as $ji) { echo "
\n";
        print_r($ji);
        echo "

\n"; } } $user = get_logged_in_user(); BossaUser::lookup($user); $action = get_str('action', true); switch ($action) { case 'add_app': $name = BossaDb::escape_string(get_str('app_name')); $short_name = get_str('short_name'); $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'); $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; } $now = time(); $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"); } Header('Location: bossa_admin.php'); exit(); case 'update_user': $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; Header('Location: bossa_admin.php'); exit(); case 'show_jobs': $app_id = $_GET['app_id']; show_jobs($app_id); exit(); case 'show_insts': $job_id = $_GET['job_id']; show_insts($job_id); 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"); } Header('Location: bossa_admin.php'); ?>