2007-10-18 21:43:25 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-10-18 21:43:25 +00:00
|
|
|
|
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/bossa_db.inc");
|
|
|
|
|
2008-07-14 19:13:19 +00:00
|
|
|
function bossa_job_create(
|
2008-07-15 21:43:45 +00:00
|
|
|
$app_id, $batch_id, $info, $calibration
|
2008-07-14 19:13:19 +00:00
|
|
|
) {
|
2008-07-13 04:26:23 +00:00
|
|
|
$job = new BossaJob;
|
|
|
|
$info = serialize($info);
|
2008-07-15 21:43:45 +00:00
|
|
|
if ($calibration) {
|
|
|
|
$priority = drand();
|
|
|
|
$c = 1;
|
|
|
|
} else {
|
|
|
|
$priority = 1;
|
|
|
|
$c = 0;
|
|
|
|
}
|
2008-07-13 04:26:23 +00:00
|
|
|
|
|
|
|
$now = time();
|
|
|
|
$int_max = 2147483647;
|
2008-07-15 21:43:45 +00:00
|
|
|
$clause = "(create_time, app_id, batch_id, state, info, calibration, priority_0) values ($now, $app_id, $batch_id, 1, '$info', $c, $priority)";
|
2008-07-13 04:26:23 +00:00
|
|
|
return $job->insert($clause);
|
|
|
|
}
|
|
|
|
|
2008-07-15 21:43:45 +00:00
|
|
|
function bossa_batch_create($appid, $name, $calibration) {
|
2008-07-14 22:32:20 +00:00
|
|
|
$now = time();
|
2008-07-15 21:43:45 +00:00
|
|
|
$c = $calibration?"1":"0";
|
|
|
|
return BossaBatch::insert("(create_time, app_id, name, calibration) values ($now, $appid, '$name', $c)");
|
2008-07-13 04:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function bossa_app_lookup($name) {
|
2013-01-08 03:40:20 +00:00
|
|
|
$name = BoincDb::escape_string($name);
|
2008-07-13 04:26:23 +00:00
|
|
|
$app = BossaApp::lookup("short_name='$name'");
|
|
|
|
if (!$app) return 0;
|
|
|
|
return $app->id;
|
|
|
|
}
|
|
|
|
|
2008-07-31 18:28:49 +00:00
|
|
|
function bossa_lookup_job($instid, &$job, &$inst, &$user) {
|
|
|
|
$inst = BossaJobInst::lookup_id($instid);
|
|
|
|
if (!$inst) return false;
|
|
|
|
$job = BossaJob::lookup_id($inst->job_id);
|
|
|
|
$user = BoincUser::lookup_id($inst->user_id);
|
|
|
|
BossaUser::lookup($user);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-10-18 21:43:25 +00:00
|
|
|
?>
|