2222// - Admin (if privileged user)
2323// - manage batches
2424// view status, get output files, abort, retire
25- // - toggle 'use only my computers'
25+ // - set 'use only my computers'
2626
2727require_once ("../inc/submit_db.inc " );
2828require_once ("../inc/util.inc " );
@@ -222,9 +222,7 @@ function show_batches($batches, $limit, $user, $app) {
222222 show_aborted ($ batches , $ limit , $ user , $ app );
223223}
224224
225- // the job submission "home page":
226- // show the user's in-progress and completed batches,
227- // and a button for creating a new batch
225+ // show links to per-app job submission forms
228226//
229227function handle_main ($ user ) {
230228 global $ web_apps ;
@@ -233,76 +231,53 @@ function handle_main($user) {
233231 error_page ("Ask the project admins for permission to submit jobs " );
234232 }
235233
236- page_head ("Job submission " );
234+ page_head ("Submit jobs " );
237235
238- if (isset ($ web_apps ) && $ web_apps ) {
236+ if (! empty ($ web_apps )) {
239237 // show links to per-app job submission pages
240238 //
241- echo " <h3>Submit jobs</h3>
242- <ul>
243- " ;
244- foreach ($ web_apps as $ appname => $ web_app ) {
245- $ appname = BoincDb:: escape_string ( $ appname );
246- $ app = BoincApp:: lookup ( " name=' $ appname ' " );
247- if (! $ app ) error_page ( " bad web app name: $ appname " );
248- $ usa = BoincUserSubmitApp:: lookup ( " user_id= $ user -> id and app_id= $ app -> id " );
249- if ( $ usa || $ user_submit -> submit_all ) {
250- echo " <li> <a href= $ web_app -> submit_url > $ app -> user_friendly_name </a> " ;
251- }
239+ foreach ( $ web_apps as $ area => $ apps ) {
240+ panel ( $ area ,
241+ function () use ( $ apps ) {
242+ foreach ($ apps as $ app ) {
243+ echo sprintf (
244+ ' <a href=%s><img width=100 src=%s></a> ' ,
245+ $ app [ 1 ], $ app [ 2 ]
246+ );
247+ }
248+ }
249+ );
252250 }
253- echo "</ul> \n" ;
254- }
255-
256- echo '<h3>Where your jobs run</h3> ' ;
257- if ($ user ->seti_id ) {
258- echo "<p>
259- Jobs you submit can run only on your computers.
260- <p>
261- " ;
262- show_button (
263- 'submit.php?action=toggle_loc ' ,
264- 'Allow them to run on any computer. '
265- );
266- } else {
267- echo "<p>
268- Jobs you submit can run on any computer.
269- <p>
270- " ;
271- show_button (
272- 'submit.php?action=toggle_loc ' ,
273- 'Allow them to run only on your computers. '
274- );
275251 }
276252
277- // show links to admin pages if relevant
278- //
279- $ usas = BoincUserSubmitApp:: enum ( " user_id= $ user -> id " );
280- $ app_admin = false ;
281- foreach ( $ usas as $ usa ) {
282- if ( $ usa -> manage ) {
283- $ app_admin = true ;
284- break ;
285- }
286- }
287- if ( $ user_submit -> manage_all || $ app_admin ) {
288- echo " <h3>Administer job submission</h3> \n" ;
289- show_button ( ' submit.php?action=admin ' , ' Administer ' );
290- }
253+ form_start ( ' submit.php ' );
254+ form_input_hidden ( ' action ' , ' update_only_own ' );
255+ form_radio_buttons (
256+ ' Jobs you submit can run ' , ' only_own ' ,
257+ [
258+ [ 0 , ' on any computer ' ],
259+ [ 1 , ' only on your computers ' ]
260+ ],
261+ $ user -> seti_id
262+ );
263+ form_submit ( ' Update ' );
264+ form_end () ;
265+ page_tail ( );
266+ }
291267
268+ function handle_show_status ($ user ) {
269+ page_head ("Job status " );
292270 $ batches = BoincBatch::enum ("user_id = $ user ->id order by id desc " );
293271 get_batches_params ($ batches );
294272 show_batches ($ batches , PAGE_SIZE , $ user , null );
295273
296274 page_tail ();
297275}
298276
299- function handle_toggle_loc ($ user ) {
300- if ($ user ->seti_id ) {
301- $ user ->update ('seti_id=0 ' );
302- } else {
303- $ user ->update ('seti_id=1 ' );
304- }
305- handle_main ($ user );
277+ function handle_update_only_own ($ user ) {
278+ $ val = get_int ('only_own ' );
279+ $ user ->update ("seti_id= $ val " );
280+ header ("Location: submit.php " );
306281}
307282
308283// show links for everything the user has admin access to
@@ -482,7 +457,7 @@ function handle_query_batch($user) {
482457 $ owner = BoincUser::lookup_id ($ batch ->user_id );
483458 }
484459
485- $ web_app = get_web_app ($ app );
460+ $ is_assim_move = is_assim_move ($ app );
486461
487462 page_head ("Batch $ batch_id " );
488463 text_start (800 );
@@ -510,15 +485,15 @@ function handle_query_batch($user) {
510485 }
511486 row2 ("GFLOP/hours, estimated " , number_format (credit_to_gflop_hours ($ batch ->credit_estimate ), 2 ));
512487 row2 ("GFLOP/hours, actual " , number_format (credit_to_gflop_hours ($ batch ->credit_canonical ), 2 ));
513- if (!$ web_app -> assim_move ) {
488+ if (!$ is_assim_move ) {
514489 row2 ("Total size of output files " ,
515490 size_string (batch_output_file_size ($ batch ->id ))
516491 );
517492 }
518493 end_table ();
519494 echo "<p> " ;
520495
521- if ($ web_app -> assim_move ) {
496+ if ($ is_assim_move ) {
522497 $ url = "get_output3.php?action=get_batch&batch_id= $ batch ->id " ;
523498 } else {
524499 $ url = "get_output2.php?cmd=batch&batch_id= $ batch ->id " ;
@@ -552,7 +527,7 @@ function handle_query_batch($user) {
552527 "Name <br><small>click for details</small> " ,
553528 "status "
554529 ];
555- if (!$ web_app -> assim_move ) {
530+ if (!$ is_assim_move ) {
556531 $ x [] = "Download Results " ;
557532 }
558533 row_heading_array ($ x );
@@ -573,7 +548,7 @@ function handle_query_batch($user) {
573548 "<a href=submit.php?action=query_job&wuid= $ wu ->id > $ wu ->name </a> " ,
574549 $ y ,
575550 ];
576- if (!$ web_app -> assim_move ) {
551+ if (!$ is_assim_move ) {
577552 $ x [] = $ text ;
578553 }
579554 row_array ($ x );
@@ -584,19 +559,21 @@ function handle_query_batch($user) {
584559 page_tail ();
585560}
586561
587- // get the 'web app' structure (from project.inc) for the given app.
588- // This says what output file scheme it uses and what the submit page URL is.
589- // If not listed, return a default structure
562+ // Does the assimilator for the given app move output files
563+ // to a results/<batchid>/ directory?
564+ // This info is stored in the $web_apps data structure in project.inc
590565//
591- function get_web_app ($ app ) {
566+ function is_assim_move ($ app ) {
592567 global $ web_apps ;
593- if (isset ($ web_apps ) && array_key_exists ($ app ->name , $ web_apps )) {
594- return $ web_apps [$ app ->name ];
568+ if (empty ($ web_apps )) return false ;
569+ foreach ($ web_apps as $ name => $ apps ) {
570+ foreach ($ apps as $ web_app ) {
571+ if ($ web_app [0 ] == $ app ->name ) {
572+ return $ web_app [3 ];
573+ }
574+ }
595575 }
596- $ x = new StdClass ;
597- $ x ->submit_url = null ;
598- $ x ->assim_move = false ;
599- return $ x ;
576+ return false ;
600577}
601578
602579// show the details of a job, including links to see the output files
@@ -607,7 +584,7 @@ function handle_query_job($user) {
607584 if (!$ wu ) error_page ("no such job " );
608585
609586 $ app = BoincApp::lookup_id ($ wu ->appid );
610- $ web_app = get_web_app ($ app );
587+ $ is_assim_move = is_assim_move ($ app );
611588
612589 page_head ("Job ' $ wu ->name ' " );
613590 text_start (800 );
@@ -638,7 +615,7 @@ function handle_query_job($user) {
638615 $ phys_names = get_outfile_phys_names ($ result );
639616 $ log_names = get_outfile_log_names ($ result );
640617 for ($ i =0 ; $ i <count ($ phys_names ); $ i ++) {
641- if ($ web_app -> assim_move ) {
618+ if ($ is_assim_move ) {
642619 // file is in
643620 // project/results/<batchid>/<wu_name>__file_<log_name>
644621 $ path = sprintf ('results/%s/%s__file_%s ' ,
@@ -844,7 +821,8 @@ function handle_show_all($user) {
844821case 'retire_batch ' : handle_retire_batch ($ user ); break ;
845822case 'retire_multi ' : handle_retire_multi ($ user ); break ;
846823case 'show_all ' : handle_show_all ($ user ); break ;
847- case 'toggle_loc ' : handle_toggle_loc ($ user ); break ;
824+ case 'status ' : handle_show_status ($ user ); break ;
825+ case 'update_only_own ' : handle_update_only_own ($ user ); break ;
848826default :
849827 error_page ("no such action $ action " );
850828}
0 commit comments