From: Matthew Wire Date: Fri, 17 Jan 2020 19:04:00 +0000 (+0000) Subject: Add an 'Execute Now' button to the job log X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ed2ee15ab71cad13aaeb0abf1de12c6b9185a7c8;p=civicrm-core.git Add an 'Execute Now' button to the job log --- diff --git a/CRM/Admin/Form/Job.php b/CRM/Admin/Form/Job.php index 65bb09710e..dec88aeeab 100644 --- a/CRM/Admin/Form/Job.php +++ b/CRM/Admin/Form/Job.php @@ -24,6 +24,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { public function preProcess() { parent::preProcess(); + $this->setContext(); CRM_Utils_System::setTitle(ts('Manage - Scheduled Jobs')); @@ -194,7 +195,15 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { $jm->executeJobById($this->_id); $jobName = self::getJobName($this->_id); CRM_Core_Session::setStatus(ts('%1 Scheduled Job has been executed. See the log for details.', [1 => $jobName]), ts("Executed"), "success"); - CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/job', 'reset=1')); + + if ($this->getContext() === 'joblog') { + // If we were triggered via the joblog form redirect back there when we finish + $redirectUrl = CRM_Utils_System::url('civicrm/admin/joblog', 'reset=1&jid=' . $this->_id); + } + else { + $redirectUrl = CRM_Utils_System::url('civicrm/admin/job', 'reset=1'); + } + CRM_Utils_System::redirect($redirectUrl); return; } diff --git a/CRM/Admin/Page/Job.php b/CRM/Admin/Page/Job.php index 2164d2b7ce..5a8d30767c 100644 --- a/CRM/Admin/Page/Job.php +++ b/CRM/Admin/Page/Job.php @@ -117,6 +117,9 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0 ); + $this->_context = CRM_Utils_Request::retrieve('context', 'String', + $this, FALSE, 0 + ); if (($this->_action & CRM_Core_Action::COPY) && (!empty($this->_id))) { try { diff --git a/CRM/Admin/Page/JobLog.php b/CRM/Admin/Page/JobLog.php index c7b1226535..e31a52558d 100644 --- a/CRM/Admin/Page/JobLog.php +++ b/CRM/Admin/Page/JobLog.php @@ -73,17 +73,17 @@ class CRM_Admin_Page_JobLog extends CRM_Core_Page_Basic { * Browse all jobs. */ public function browse() { - $jid = CRM_Utils_Request::retrieve('jid', 'Positive', $this); + $jid = CRM_Utils_Request::retrieve('jid', 'Positive'); $sj = new CRM_Core_JobManager(); - $jobName = NULL; if ($jid) { $jobName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Job', $jid); + $this->assign('jobName', $jobName); + $jobRunUrl = CRM_Utils_System::url('civicrm/admin/job', 'action=view&reset=1&context=joblog&id=' . $jid); + $this->assign('jobRunUrl', $jobRunUrl); } - $this->assign('jobName', $jobName); - $dao = new CRM_Core_DAO_JobLog(); $dao->orderBy('id desc'); diff --git a/templates/CRM/Admin/Page/JobLog.tpl b/templates/CRM/Admin/Page/JobLog.tpl index 367b0f5b1b..ca3bac9e55 100644 --- a/templates/CRM/Admin/Page/JobLog.tpl +++ b/templates/CRM/Admin/Page/JobLog.tpl @@ -19,6 +19,9 @@ {if $rows} @@ -60,5 +63,8 @@