. // Interface for project-wide functions: // - control user quotas and permissions to submit jobs // - create apps require_once("../inc/submit_db.inc"); require_once("../inc/util.inc"); function user_row($u) { $user = BoincUser::lookup_id($u->user_id); echo "
"; show_button("manage_project.php?action=add_form", "Add user", "Allow a new user to submit jobs" ); $us = BoincUserSubmit::enum(""); start_table(); table_header("User", "Can submit jobs for", "Quota"); foreach ($us as $u) { user_row($u); } end_table(); page_tail(); } function handle_edit_form() { $user_id = get_int('user_id'); $user = BoincUser::lookup_id($user_id); $usub = BoincUserSubmit::lookup_userid($user_id); page_head("Permissions for $user->name"); echo " $user->name is allowed to submit jobs for:
Return to project-wide management functions "; page_tail(); } function handle_edit_action() { $user_id = get_int('user_id'); $us = BoincUserSubmit::lookup_userid($user_id); if (!$us) error_page("user not found"); BoincUserSubmitApp::delete_user($user_id); $submit_all = get_str('submit_all'); if ($submit_all) { $us->update("submit_all=1"); } else { $us->update("submit_all=0"); $apps = BoincApp::enum("deprecated=0"); foreach ($apps as $app) { $x = "app_$app->id"; if (get_str($x, true)) { BoincUserSubmitApp::insert("(user_id, app_id) values ($user_id, $app->id)"); } } } $quota = (double) get_str('quota'); if ($quota != $us->quota) { $us->update("quota=$quota"); } page_head("Update successful"); echo "Return to project-wide management functions"; page_tail(); } function handle_add_form() { page_head("Add user"); echo "
"; page_tail(); } function handle_add_action() { $user_id = get_int('user_id'); $user = BoincUser::lookup_id($user_id); if (!$user) error_page("no such user"); $us = BoincUserSubmit::lookup_userid($user_id); if (!$us) { if (!BoincUserSubmit::insert("(user_id) values ($user_id)")) { error_page("Insert failed"); } } header("Location: manage_project.php?action=edit_form&user_id=$user_id"); } $user = get_logged_in_user(); $bus = BoincUserSubmit::lookup_userid($user->id); if (!$bus) { die("no access"); } $action = get_str('action', true); switch ($action) { case 'list': case '': handle_list(); break; case 'add_form': handle_add_form(); break; case 'add_action': handle_add_action(); break; case 'edit_form': handle_edit_form(); break; case 'edit_action': handle_edit_action(); break; default: error_page("unknown action: $action"); } ?>