. // Display and Manage BOINC Application Versions // // This page presents a form with information about application versions. // Some of the fields can be changed. // // Eric Myers - 4 June 2006 // @(#) $Id$ // TODO - code cleanup and use new DB interface require_once('../inc/util_ops.inc'); db_init(); $warnings = ""; // process form input for changes // function do_updates() { global $warnings; $apps = BoincApp::enum(""); foreach ($apps as $app) { $id = $app->id; // Change deprecated status? // $field = "deprecated_".$id; $new_v = (post_str($field, true)=='on') ? 1 : 0; $old_v = $app->deprecated; if ($new_v != $old_v ) { $app->update("deprecated=$new_v"); } $field = "weight_".$id; $new_v = $_POST[$field] + 0; $old_v = $app->weight; if ($new_v != $old_v ) { $app->update("weight=$new_v"); } $field = "homogeneous_redundancy_".$id; $new_v = $_POST[$field]; $old_v = $app->homogeneous_redundancy; if ($new_v != $old_v ) { $app->update("homogeneous_redundancy=$new_v"); } $field = "homogeneous_app_version_".$id; $new_v = (post_str($field, true)=='on') ? 1 : 0; $old_v = $app->homogeneous_app_version; if ($new_v != $old_v ) { $app->update("homogeneous_app_version=$new_v"); } $field = "non_cpu_intensive_".$id; $new_v = (post_str($field, true)=='on') ? 1 : 0; $old_v = $app->non_cpu_intensive; if ($new_v != $old_v ) { $app->update("non_cpu_intensive=$new_v"); } $field = "beta_".$id; $new_v = (post_str($field, true)=='on') ? 1 : 0; $old_v = $app->beta; if ($new_v != $old_v ) { $app->update("beta=$new_v"); } } // Adding a new application if (post_str('add_app', true)) { $name = mysql_real_escape_string($_POST['add_name']); $user_friendly_name = mysql_real_escape_string($_POST['add_user_friendly_name']); if (empty($name) || empty($user_friendly_name) ) { $warnings .= "

To add a new application please supply both a brief name and a longer 'user-friendly' name.

"; } else { $now = time(); $cmd = "INSERT INTO app (name,user_friendly_name,create_time) ". "VALUES ('$name', '$user_friendly_name',$now)"; $warnings .= "

$cmd
\n"; mysql_query($cmd); } } } function show_form($updated) { global $warnings; admin_page_head("Manage Applications"); echo $warnings; if ($updated) { echo "Updates were done.

You must stop and restart the project for these changes to take effect. "; } $self=$_SERVER['PHP_SELF']; echo "

Edit applications

"; start_table(); table_header( "ID", "Name and description
Click for details", "Created", "weight
details", "homogeneous redundancy type
details", "homogeneous app version?
details", "deprecated?", "Non-CPU-intensive?", "Beta?" ); $total_weight = mysql_query('SELECT SUM(weight) AS total_weight FROM app WHERE deprecated=0'); $total_weight = mysql_fetch_assoc($total_weight); $total_weight = $total_weight['total_weight']; $q="SELECT * FROM app ORDER BY id"; $result = mysql_query($q); $Nrow=mysql_num_rows($result); for ($j=1; $j<=$Nrow; $j++){ $item = mysql_fetch_object($result); $id = $item->id; // grey-out deprecated versions $f1=$f2=''; if($item->deprecated==1) { $f1 = ""; $f2 = ""; } echo " "; echo " $f1 $id $f2\n"; $name = $item->name; $full_name = $item->user_friendly_name; echo " $f1$name
$full_name $f2\n"; $time = $item->create_time; echo " $f1 " .date_str($time)."$f2\n"; $field = "weight_".$id; $v = $item->weight; echo " \n"; $field = "homogeneous_redundancy_".$id; $v = $item->homogeneous_redundancy; echo " "; $field = "homogeneous_app_version_".$id; $v = ''; if ($item->homogeneous_app_version) $v=' CHECKED '; echo " "; $field = "deprecated_".$id; $v = ''; if ($item->deprecated) $v = ' CHECKED '; echo " "; $field = "non_cpu_intensive_".$id; $v = ''; if ($item->non_cpu_intensive) $v = ' CHECKED '; echo " "; $field = "beta_".$id; $v = ''; if ($item->beta) $v = ' CHECKED '; echo " "; echo " "; } mysql_free_result($result); echo ""; end_table(); // Entry form to create a new application // echo"

Add an application

To add an application enter the short name and description ('user friendly name') below. You can then edit the application when it appears in the table above.

\n"; start_table("align='center' "); echo "Name Description   \n"; echo " \n"; end_table(); echo "

\n"; admin_page_tail(); } if( !empty($_POST) ) { do_updates(); show_form(true); } else { show_form(false); } //Generated automatically - do not edit $cvs_version_tracker[]="\$Id$"; ?>