function tripal_core_preprocess_tripal_core_job_view
1.x jobs.inc | tripal_core_preprocess_tripal_core_job_view(&$variables) |
Registers variables for the tripal_core_job_view themeing function
Parameters
$variables: An array containing all variables supplied to this template
Related topics
File
- tripal_core/
includes/ jobs.inc, line 168 - Contains functions related to the display of Tripal jobs in a Tripal website.
Code
function tripal_core_preprocess_tripal_core_job_view(&$variables) {
// get the job record
$job_id = $variables['job_id'];
$sql =
"SELECT TJ.job_id,TJ.uid,TJ.job_name,TJ.modulename,TJ.progress,
TJ.status as job_status, TJ,submit_date,TJ.start_time,
TJ.end_time,TJ.priority,U.name as username,TJ.arguments,
TJ.callback,TJ.error_msg,TJ.pid
FROM {tripal_jobs} TJ
INNER JOIN users U on TJ.uid = U.uid
WHERE TJ.job_id = %d";
$job = db_fetch_object(db_query($sql, $job_id));
// we do not know what the arguments are for and we want to provide a
// meaningful description to the end-user. So we use a callback function
// deinfed in the module that created the job to describe in an array
// the arguments provided. If the callback fails then just use the
// arguments as they are
$args = preg_split("/::/", $job->arguments);
$arg_hook = $job->modulename . "_job_describe_args";
if (is_callable($arg_hook)) {
$new_args = call_user_func_array($arg_hook, array($job->callback, $args));
if (is_array($new_args) and count($new_args)) {
$job->arguments = $new_args;
}
else {
$job->arguments = $args;
}
}
else {
$job->arguments = $args;
}
// make our start and end times more legible
$job->submit_date = tripal_jobs_get_submit_date($job);
$job->start_time = tripal_jobs_get_start_time($job);
$job->end_time = tripal_jobs_get_end_time($job);
// add the job to the variables that get exported to the template
$variables['job'] = $job;
}