17 require_once SQ_SYSTEM_ROOT.
'/core/hipo/hipo_job.inc';
38 var $_queued_jobs = Array();
73 if (!isset($this->ho) || get_class($this->ho) !=
'Hipo_Backend_Outputter') {
74 require_once SQ_SYSTEM_ROOT.
'/core/hipo/hipo_backend_outputter.inc';
94 if (empty($this->_jobs[$code_name])) {
101 $bind_vars[
'code_name'] = $code_name;
103 $hipo_vars = Array();
104 if (!empty($hipo_vars_all) && isset($hipo_vars_all[0])) {
105 $hipo_vars = $hipo_vars_all[0];
107 }
catch (Exception $e) {
108 throw new Exception(
'Unable to get HIPO job from code name: '.$code_name.$e->getMessage());
111 if (!isset($hipo_vars[
'job_type']) || empty($hipo_vars[
'job_type'])) {
115 $job_type = strtolower($hipo_vars[
'job_type']);
117 $vars = unserialize($hipo_vars[
'hipo_vars']);
118 if (empty($vars[
'job_dir'])) {
119 $job_dir = SQ_SYSTEM_ROOT.
'/core/hipo/jobs';
121 $job_dir = $vars[
'job_dir'];
126 require_once $job_dir.
'/'.$job_type.
'.inc';
128 $this->_jobs[$code_name] =
new $job_type($code_name);
130 if (!$this->_jobs[$code_name]->code_name) {
138 return $this->_jobs[$code_name];
159 $job = $this->
getJob($code_name);
164 unset($this->_jobs[$code_name]);
183 $hipo = $this->
getJob($code_name);
184 if (is_null($hipo))
return '';
186 if ($hipo->complete()) {
188 return $hipo->getOption(
'on_complete_url');
190 return current_protocol().
'://'.$_SERVER[
'HTTP_HOST'].$_SERVER[
'PHP_SELF'].
'?SQ_ACTION=hipo&hipo_source_code_name='.$hipo->source_code_name;
204 if (empty($_GET[
'hipo_source_code_name'])) {
205 trigger_localised_error(
'HIPO0058', E_USER_WARNING);
209 $source_job = $this->
getJob($_GET[
'hipo_source_code_name']);
210 if (is_null($source_job)) {
212 if (empty($_POST[
'aborting_hipo'])) {
213 trigger_localised_error(
'HIPO0057', E_USER_WARNING, $_GET[
'hipo_source_code_name']);
222 if (!empty($_POST[
'cancel_hipo'])) {
223 if ($source_job->abort()) {
224 $_POST[
'aborting_hipo'] = $source_job->code_name;
225 $_POST[
'aborting_hipo_url'] = $source_job->getOption(
'on_complete_url');
230 if (!empty($_GET[
'return_to_herder'])) {
231 $source_job->_options[
'on_complete_url'] =
'./?SQ_BACKEND_PAGE=main&backend_section=hipo_herder';
236 if (!$source_job->process()) {
238 $o->setFormData(
'',
'');
240 $source_job->_paintErrorReport();
244 $source_job->abort();
262 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
264 if (empty($_GET[
'hipo_source_code_name'])) {
265 trigger_localised_error(
'HIPO0058', E_USER_WARNING);
269 $source_job = $this->
getJob($_GET[
'hipo_source_code_name']);
270 if (is_null($source_job) && empty($_POST[
'aborting_hipo'])) {
271 trigger_localised_error(
'HIPO0057', E_USER_WARNING, $_GET[
'hipo_source_code_name']);
277 if (!is_null($source_job) && $source_job->complete() && !empty($source_job->_hipo_vars[
'errors'])) {
279 $o->setFormData(
'main_form',
'');
281 $source_job->paint($o);
290 $form_name =
'main_form';
294 if (is_null($source_job)) {
295 $url = $_POST[
'aborting_hipo_url'];
296 $onload =
'self.location = "'.$url.
'";';
299 $status_msg =
'HIPO Aborted';
302 $auto_step = $source_job->autoStep();
303 $percent_done = $source_job->percentDone();
305 if ($source_job->complete()) {
306 $onload =
'self.location = "'.$url.
'";';
308 $delay = ($source_job->getRunningMode() ==
'server');
309 $onload =
'document.'.$form_name.
'.submit();';
311 $status_msg = $source_job->complete() ? translate(
'hipo_complete', $source_job->getHipoName()) : translate(
'hipo_progress', $source_job->getHipoName());
315 $o->setFormData($form_name, $url);
319 <script language=
"JavaScript" type=
"text/javascript">
320 function next_page() {
321 <?php echo str_replace(
'\\',
'\\\\', $onload); ?>
324 function send_abort() {
325 if (ON_LOAD_TIME_OUT != null) {
326 clearTimeout(ON_LOAD_TIME_OUT);
328 if (confirm(js_translate(
'confirm_cancel'))) {
329 document.<?php echo $form_name; ?>.cancel_hipo.value =
"1";
330 document.<?php echo $form_name; ?>.submit();
333 if (!is_null($source_job) && $source_job->getRunningMode() ==
'server') {
336 ?>alert(js_translate(
'action_cannot_be_performed'));<?php
346 $o->addOnLoad(
'ON_LOAD_TIME_OUT = setTimeout("next_page();", 2000);');
348 $o->addOnLoad(
'ON_LOAD_TIME_OUT = setTimeout("next_page();", 100);');
353 <table border=
"0" cellspacing=
"0" cellpadding=
"0" width=
"500">
355 <td
class=
"sq-hipo-header">
356 <table
class=
"sq-hipo-header">
358 <td valign=
"middle" width=
"100%"><img src=
"<?php echo sq_web_path('lib').'/web/images/icons/hipo.gif'; ?>" width=
"71" height=
"26" alt=
"Powered by Highly Intensive Processing Object (HIPO) Technology" /></td>
361 <td
class=
"sq-hipo-header">
362 <?php
HIPO_Job::paintProgressBar($percent_done, $status_msg,
'sq-hipo-header-progress-bar-label',
'sq-hipo-header-progress-bar-percent',
'sq-hipo-header-progress-bar-main',
'sq-hipo-header-progress-bar-done'); ?>
369 <td
class=
"sq-hipo-main" valign=
"top">
371 $buttons_to_print = Array();
374 if (empty($_POST[
'aborting_hipo'])) {
378 $source_job->paint($o);
381 if (!$source_job->complete()) {
384 hidden_field(
'cancel_hipo', (empty($_POST[
'cancel_hipo'])) ? 0 : ((
int) $_POST[
'cancel_hipo'] + 1));
385 $allow_cancel = $source_job->_steps[$source_job->_hipo_vars[
'current_step']][
'allow_cancel'];
387 $buttons_to_print[
'cancel'] = Array(
'value' =>
'Cancel',
'action' =>
'send_abort();');
394 $button_text = ($source_job->complete()) ?
'Finish' :
'Next >>';
395 $buttons_to_print[
'next'] = Array(
'value' => $button_text,
'action' =>
'next_page();');
401 hidden_field(
'aborting_hipo', $_POST[
'aborting_hipo']);
402 hidden_field(
'aborting_hipo_url', $_POST[
'aborting_hipo_url']);
406 if (is_null($source_job)) {
407 echo translate(
'hipo_abort_complete');
410 echo translate(
'hipo_aborting');
411 $button_text =
'Next >>';
417 $buttons_to_print[
'next'] = Array(
'value' => $button_text,
'action' =>
'next_page();');
422 if (count($buttons_to_print)) {
426 if (isset($source_job->_hipo_vars[
'no_next']) && $source_job->_hipo_vars[
'no_next']) {
432 <table border=
"0" width=
"100%" cellspacing=
"2" cellpadding=
"1">
434 <td width=
"100%"> </td>
436 foreach ($buttons_to_print as $btn_code => $btn_data) {
437 ?><td valign=
"top" align=
"center"><?php
439 if ($btn_code ==
'next') {
442 normal_button($btn_code, $btn_data[
'value'], $btn_data[
'action'],
'class="sq-hipo-button-enabled", accesskey="n""');
445 normal_button($btn_code, $btn_data[
'value'], $btn_data[
'action'],
'class="sq-hipo-button-enabled"');
481 $this->_tmp[
'prepared_server'] = Array();
483 if (empty($input_data[
'userid'])) {
484 $output_data[
'result'] =
'error';
485 $output_data[
'msg'] =
'userid not supplied on Input Data';
489 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($input_data[
'userid']);
490 if (is_null($user) || !$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($user)) {
491 $output_data[
'result'] =
'error';
492 $output_data[
'msg'] =
'Unable to find User #'.$input_data[
'userid'].
' to run as or unable to set them to the current user';
496 if (empty($input_data[
'source_code_name'])) {
497 $output_data[
'result'] =
'error';
498 $output_data[
'msg'] =
'source_code_name not supplied on Input Data';
502 $source_job = $this->
getJob($input_data[
'source_code_name']);
503 if (is_null($source_job)) {
504 $output_data[
'result'] =
'error';
505 $output_data[
'msg'] =
'Unable to find a source job with the codename "'.$input_data[
'source_code_name'].
'"';
509 if (!$source_job->setRunningMode(
'server', $taskid)) {
510 $output_data[
'result'] =
'error';
511 $output_data[
'msg'] =
'Unable to set the running mode to server for "'.$source_job->code_name.
'"';
515 $this->_tmp[
'prepared_server'][
'source_code_name'] = $source_job->code_name;
517 pcntl_signal(SIGTERM, Array(&$this,
'serverSigHandler'));
518 pcntl_signal(SIGINT, Array(&$this,
'serverSigHandler'));
520 $output_data[
'result'] =
'ack';
544 if (empty($this->_tmp[
'prepared_server'])) {
548 $source_job = $this->
getJob($this->_tmp[
'prepared_server'][
'source_code_name']);
549 if (is_null($source_job)) {
550 trigger_localised_error(
'HIPO0057', E_USER_WARNING, $this->_tmp[
'prepared_server'][
'source_code_name']);
554 if ($source_job->uses_trans) {
555 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
556 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
559 $this->_tmp[
'processing_server'] = TRUE;
562 while (!$source_job->complete() && $source_job->getRunningMode() ==
'server') {
563 if (!$source_job->process()) {
569 unset($this->_tmp[
'prepared_server']);
570 unset($this->_tmp[
'processing_server']);
572 if ($source_job->uses_trans) {
574 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
576 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
578 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
603 if (!empty($this->_tmp[
'processing_server'])) {
604 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db');
605 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
606 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
608 if (!empty($this->_tmp[
'prepared_server'])) {
609 $source_job = $this->
getJob($this->_tmp[
'prepared_server'][
'source_code_name']);
610 if (!is_null($source_job)) $source_job->abort();
614 trigger_localised_error(
'HIPO0056', E_USER_NOTICE, $signo);
634 function queueHipo($job_type, $vars=Array(), $on_complete_url=
'', $job_dir=
'')
636 if (empty($on_complete_url)) {
637 $on_complete_url = $_SERVER[
'REQUEST_URI'];
639 if (empty($job_dir)) {
640 $job_dir = SQ_SYSTEM_ROOT.
'/core/hipo/jobs';
645 require_once $job_dir.
'/'.$job_type.
'.inc';
646 $init_hipo =
new $job_type();
647 $init_hipo->setRunningVars($vars);
650 if (!$init_hipo->prepare())
return FALSE;
651 $init_hipo->_hipo_vars[
'job_dir'] = $job_dir;
652 $job_threshold = $init_hipo->getThresholdPercentageRequired();
656 if ($job_threshold > 0) {
657 if (($this->threshold + $job_threshold) <= SQ_HIPO_TOTAL_THRESHOLD) {
658 $this->threshold += $job_threshold;
659 $init_hipo->_steps = $init_hipo->getInitialStepData();
660 return $init_hipo->freestyle();
664 $init_hipo->setOption(
'on_complete_url', $on_complete_url);
669 $hipo_code = $init_hipo->getCodeName();
670 if (isset($this->_queued_jobs[$GLOBALS[
'SQ_SYSTEM']->currentUserId()])) {
671 if (in_array($hipo_code, $this->_queued_jobs[$GLOBALS[
'SQ_SYSTEM']->currentUserId()])) {
676 if (!$init_hipo->initialise())
return FALSE;
678 $this->_queued_jobs[$GLOBALS[
'SQ_SYSTEM']->currentUserId()][] = $hipo_code;
698 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
699 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
702 $bind_vars[
'current_user'] = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
704 }
catch (Exception $e) {
705 throw new Exception(
'Unable to get current queued jobs for user: '.$GLOBALS[
'SQ_SYSTEM']->currentUserId().
' due to database error: '.$e->getMessage());
709 if (empty($queued_jobs)) {
710 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
711 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
715 $job_codes = Array();
717 for ($i = 0; $i < count($queued_jobs); $i++) {
718 $job_data = $queued_jobs[$i];
719 $job = $this->
getJob($job_data[
'code_name']);
720 $job_codes[] = $job_data[
'code_name'];
722 if (isset($queued_jobs[($i+1)])) {
723 $next_url = $this->
getProcessURL($queued_jobs[($i+1)][
'code_name']);
724 $job->setOption(
'on_complete_url', $next_url);
726 trigger_localised_error(
'HIPO0055', E_USER_WARNING);
727 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
728 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
731 }
else if (!empty($on_complete_url)) {
732 $job->setOption(
'on_complete_url', $on_complete_url);
734 trigger_localised_error(
'HIPO0055', E_USER_WARNING);
735 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
736 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
746 'code_names' => $job_codes,
749 }
catch (Exception $e) {
750 throw new Exception(
'Unable to update HIPO jobs table due to database error: '.$e->getMessage());
753 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
754 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
773 if (empty($job_dir)) {
774 $job_dir = SQ_SYSTEM_ROOT.
'/core/hipo/jobs';
777 require_once $job_dir.
'/'.$job_type.
'.inc';
778 $init_hipo =
new $job_type();
779 $init_hipo->setRunningVars($vars);
780 $init_hipo->_steps = $init_hipo->getInitialStepData();
783 if (!$init_hipo->prepare())
return FALSE;
784 set_error_handler(Array(&$init_hipo,
'_errorHandler'));
785 $init_hipo->freestyle();
786 restore_error_handler();
787 return $init_hipo->getErrors();
803 if ($job_dir == SQ_SYSTEM_ROOT.
'/core/hipo/jobs') {
810 if (strpos($job_dir, str_replace(
'\\',
'/', SQ_CORE_PACKAGE_PATH)) !== FALSE) {
811 $GLOBALS[
'SQ_SYSTEM']->lm->includePackageStrings(
'__core__');
813 $stripped_dir = str_replace(str_replace(
'\\',
'/', SQ_PACKAGES_PATH).
'/',
'', $job_dir);
814 $package = substr($stripped_dir, 0, strpos($stripped_dir,
'/'));
815 $GLOBALS[
'SQ_SYSTEM']->lm->includePackageStrings($package);
832 $hipo_admin = $GLOBALS[
'SQ_SYSTEM']->userRoot() || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin();
833 $current_user_id = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
835 $lock = $GLOBALS[
'SQ_SYSTEM']->getLockInfo(get_class_lower($this));
836 $have_lock = (!empty($lock) && ($current_user_id == $lock[
'userid']));
840 if (!empty($_POST[
'herder_posted'])) {
842 if ($have_lock && !empty($_POST[
'process_form']) && !empty($_POST[
'force_kill'])) {
844 foreach ($_POST[
'force_kill'] as $source_code_name) {
845 $source_job = $this->
getJob($source_code_name);
846 if (is_null($source_job))
continue;
851 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($source_job->userid);
852 if (is_null($user))
continue;
853 $GLOBALS[
'SQ_SYSTEM']->setCurrentUser($user);
854 $source_job->abort();
855 $GLOBALS[
'SQ_SYSTEM']->restoreCurrentUser();
856 }
else if ($source_job->userid == $current_user_id) {
857 $source_job->abort();
862 $message_body .=
'FORCE KILL '.$source_code_name.
"\n";
866 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
868 'hipo_code_name' => $source_code_name,
870 $message = $ms->newMessage(Array(),
'hipo.force_kill', $msg_reps);
876 if ($have_lock && !empty($_POST[
'process_form']) && !empty($_POST[
'remove_job'])) {
877 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db3');
878 $db = $GLOBALS[
'SQ_SYSTEM']->db;
880 $jobs_to_remove = Array();
881 foreach ($_POST[
'remove_job'] as $code_name) {
884 $sql =
'DELETE FROM sq_hipo_job
885 WHERE code_name IN ('.implode(
',', $jobs_to_remove).
')';
889 }
catch (Exception $e) {
890 throw new Exception(
'Unable to delete HIPO job(s) due to database error: '.$e->getMessage());
892 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
895 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
896 foreach ($_POST[
'remove_job'] as $code_name) {
898 'hipo_code_name' => $code_name,
900 $message = $ms->newMessage(Array(),
'hipo.orphan_kill', $msg_reps);
906 if (!empty($_POST[
'sq_lock_release']) || !empty($_POST[
'sq_lock_release_manual'])) {
907 $GLOBALS[
'SQ_SYSTEM']->releaseLock(get_class_lower($this));
911 if (!empty($_POST[
'sq_lock_acquire'])) {
912 $GLOBALS[
'SQ_SYSTEM']->acquireLock(get_class_lower($this));
916 $lock = $GLOBALS[
'SQ_SYSTEM']->getLockInfo(get_class_lower($this));
917 $have_lock = (!empty($lock) && ($current_user_id == $lock[
'userid']));
921 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
922 $o->setHeading(
'HIPO Herder', sq_get_icon($o->filesPath(
'/images/icons/header/hipo_herder.png'), 20, 20,
'HIPO Icon'));
923 $o->setPageTitle(
'HIPO Herder');
924 $o->addHiddenField(
'herder_posted',
'1');
928 $o->openSection(translate(
'locking_/_editing'));
931 <table border=
"0" cellspacing=
"3" cellpadding=
"1">
934 <?php sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/'.((empty($lock)) ?
'un' :
'').
'locked.png', 16, 16); ?>
937 <p
class=
"sq-lock-message">
942 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($lock[
'userid']);
946 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
947 $expires_in = easy_time_total(($lock[
'expires'] - $now), TRUE);
948 if (!$expires_in) $expires_in =
'1 second';
949 $expires_in = translate(
'due_to_expire', $expires_in);
951 echo translate(
'release_lock', translate(
'release_lock_button'), translate(
'hipo_herder'));
957 echo translate(
'acquire_lock', translate(
'acquire_lock_button'), translate(
'hipo_herder'));
962 submit_button(
'sq_lock_release_manual', translate(
'release_lock_button'),
'set_hidden_field("process_form", "0");',
'accesskey="r"');
965 submit_button(
'sq_lock_acquire', translate(
'acquire_lock_button'),
'set_hidden_field("process_form", "0");',
'accesskey="a"');
975 $o->openSection(translate(
'current_hipo_jobs'));
976 $o->openField(
'',
'new_line');
978 $source_jobs = Array();
980 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db3');
982 $sql =
'SELECT source_code_name, code_name, job_type
987 $sql .=
' WHERE userid = :current_user_id';
995 }
catch (Exception $e) {
996 throw new Exception(
'Unable to get HIPO jobs for user: '.$current_user_id.
' due to database error: '.$e->getMessage());
998 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
999 foreach ($result as $key => $row) {
1000 $source_code_name = ($row[
'source_code_name'] == $row[
'code_name']) ?
'' : $row[
'source_code_name'];
1001 if (!isset($source_jobs[$source_code_name])) {
1002 $source_jobs[$source_code_name] = Array();
1004 $source_jobs[$source_code_name][$row[
'code_name']] = $row[
'job_type'];
1007 if (empty($source_jobs[
''])) {
1008 echo translate(
'hipo_currently_no_jobs');
1012 <table
class=
"sq-backend-table">
1017 <td
class=
"sq-backend-table-header" style=
"width: 30px;"><?php echo translate(
'hipo_herder_resume'); ?></td>
1021 <td
class=
"sq-backend-table-header"><?php echo translate(
'hipo_herder_job_type'); ?></td>
1022 <td
class=
"sq-backend-table-header"><?php echo translate(
'owner'); ?></td>
1023 <td
class=
"sq-backend-table-header"><?php echo translate(
'hipo_last_updated'); ?></td>
1024 <td
class=
"sq-backend-table-header" style=
"text-align: center;"><?php echo translate(
'percent_complete'); ?></td>
1028 <td
class=
"sq-backend-table-header" style=
"text-align: center;"><?php echo translate(
'delete_question'); ?></td>
1035 $current_user_id = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
1036 foreach ($source_jobs[
''] as $source_code_name => $source_job_type) {
1037 $source_job = $this->
getJob($source_code_name);
1038 if (is_null($source_job))
continue;
1044 <td
class=
"sq-backend-table-cell" style=
"text-align: center;">
1050 if (($source_job->userid === $current_user_id) || $GLOBALS[
'SQ_SYSTEM']->userRoot() || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin()) {
1052 <p style=
"text-align:center"><a href=
"./?SQ_ACTION=hipo&hipo_source_code_name=<?php echo $source_code_name; ?>&return_to_herder=1" style=
"text-decoration: none;"><img style=
"border: none;" src=
"<?php echo sq_web_path('lib'); ?>/web/images/hipo_resume.png" title=
"<?php echo translate('hipo_herder_continue'); ?>" alt=
"Resume <?php echo $source_code_name; ?>" /></a> <a href=
"#" onclick=
"var result = window.open('./?SQ_ACTION=hipo&hipo_source_code_name=<?php echo $source_code_name; ?>', 'hipo_job<?php echo $source_code_name; ?>', 'width=650,height=400,scrollbars=1,toolbar=0,menubar=0,location=0,resizable=1');return false;" style=
"text-decoration: none;" ><img style=
"border: none;" src=
"<?php echo sq_web_path('lib'); ?>/web/images/hipo_resume_popup.png" title=
"<?php echo translate('hipo_herder_continue'); ?>" alt=
"Resume <?php echo $source_code_name; ?>" /></a></p>
1060 <td
class=
"sq-backend-table-cell">
1061 <?php echo ucwords(str_replace(
'_',
' ', $source_job_type)); ?>
1063 <td
class=
"sq-backend-table-cell">
1065 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($source_job->userid);
1066 echo $user->name.
' (Id #'.$user->id.
')';
1069 <td
class=
"sq-backend-table-cell">
1070 <?php echo easy_time_total($source_job->last_updated - $now, TRUE); ?>
1073 <td
class=
"sq-backend-table-cell" style=
"text-align: center;">
1074 <?php echo $source_job->percentDone(); ?>%
1079 <td
class=
"sq-backend-table-cell" style=
"text-align: center;">
1080 <?php check_box(
'force_kill[]', $source_job->code_name); ?>
1088 if (!empty($source_jobs[$source_code_name])) {
1089 foreach ($source_jobs[$source_code_name] as $code_name => $job_type) {
1090 $job = $this->
getJob($code_name);
1091 if (is_null($job))
continue;
1094 <td
class=
"sq-backend-table-cell">
1097 <td
class=
"sq-backend-table-cell">
1098 <?php echo ucwords(str_replace(
'_',
' ', $job_type)); ?>
1100 <td
class=
"sq-backend-table-cell">
1103 <td
class=
"sq-backend-table-cell">
1104 <?php echo easy_time_total($source_job->last_updated - $now, TRUE); ?>
1106 <td
class=
"sq-backend-table-cell" style=
"text-align: center;">
1107 <?php echo $job->percentDone(); ?>%
1109 <td
class=
"sq-backend-table-cell" style=
"text-align: center;">
1128 $o->openSection(translate(
'orphaned_hipo_jobs'));
1129 $o->openField(
'',
'new_line');
1131 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db3');
1134 $sql =
'SELECT code_name, source_code_name, job_type, userid, last_updated
1136 WHERE source_code_name NOT IN (SELECT code_name FROM sq_hipo_job)';
1140 $sql .=
' AND userid = :current_user_id';
1149 }
catch (Exception $e) {
1150 throw new Exception(
'Unable to get orphaned jobs for user: '.$current_user_id.
' due to database error: '.$e->getMessage());
1153 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1156 if (empty($orphaned_jobs)) {
1157 echo translate(
'hipo_currently_no_oprhaned_jobs');
1160 <table
class=
"sq-backend-table">
1162 <td
class=
"sq-backend-table-header"><?php echo translate(
'hipo_herder_job_type'); ?></td>
1163 <td
class=
"sq-backend-table-header"><?php echo translate(
'hipo_herder_parent_job_type'); ?></td>
1164 <td
class=
"sq-backend-table-header"><?php echo translate(
'owner'); ?></td>
1165 <td
class=
"sq-backend-table-header"><?php echo translate(
'hipo_last_updated'); ?></td>
1169 <td
class=
"sq-backend-table-header" style=
"text-align: center;"><?php echo translate(
'delete_question'); ?></td>
1180 foreach ($orphaned_jobs as $job_info) {
1183 <td><?php echo ucwords(str_replace(
'_',
' ', $job_info[
'job_type'])); ?></td>
1185 $parent_job_type = reset(explode(
'-', $job_info[
'source_code_name']));
1186 echo ucwords(str_replace(
'_',
' ', $parent_job_type));
1189 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($job_info[
'userid']);
1190 echo $user->name.
' (Id #'.$user->id.
')';
1194 echo easy_time_total(strtotime($job_info[
'last_updated']) - $now, TRUE);
1199 <td
class=
"sq-backend-table-cell" style=
"text-align: center;">
1200 <?php check_box(
'remove_job[]', $job_info[
'code_name']); ?>
1213 if ($have_lock) $o->commitButton(
'', TRUE);
1229 $bind_vars[
'userid'] = $userid;
1231 }
catch (Exception $e) {
1232 throw new Exception(
'Failed to get HIPO jobs for user due to database error: '.$e->getMessage());
1236 for ($i = 0; $i < count($jobsforuser); $i++) {
1237 $source_job = $this->
getJob($jobsforuser[$i][
'code_name']);
1238 $jobsforuser[$i][
'percent_done'] = $source_job->percentDone();
1240 return $jobsforuser;