From a4cd873e8b51a836611770de485c3d46053f2be2 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 13 Dec 2019 07:08:34 +1100 Subject: [PATCH] Include the job name and job details on the popup notice and also on the form asking if your sure about executing it Allow disabled jobs to be executed and fix copy --- CRM/Admin/Form/Job.php | 19 +++++++++++++++++-- CRM/Admin/Page/Job.php | 8 +++++++- templates/CRM/Admin/Form/Job.tpl | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CRM/Admin/Form/Job.php b/CRM/Admin/Form/Job.php index 1a1c4fb88b..e304420e0c 100644 --- a/CRM/Admin/Form/Job.php +++ b/CRM/Admin/Form/Job.php @@ -55,7 +55,8 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { return; } - if ($this->_action & CRM_Core_Action::VIEW) { + if ($this->_action & CRM_Core_Action::VIEW) { + $this->assign('jobName', self::getJobName($this->_id)); $this->addButtons([ [ 'type' => 'submit', @@ -192,7 +193,8 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { if ($this->_action & CRM_Core_Action::VIEW) { $jm = new CRM_Core_JobManager(); $jm->executeJobById($this->_id); - CRM_Core_Session::setStatus(ts('Selected Scheduled Job has been executed. See the log for details.'), ts("Executed"), "success"); + $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')); return; } @@ -248,4 +250,17 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { } + /** + * Get the API action aka Job Name for this scheduled job + * @param int $id - Id of the stored Job + * + * @return string + */ + private static function getJobName($id) { + $entity = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Job', $id, 'api_entity'); + $action = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Job', $id, 'api_action'); + $name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Job', $id, 'name'); + return $name . ' (' . $entity . '.' . $action . ')'; + } + } diff --git a/CRM/Admin/Page/Job.php b/CRM/Admin/Page/Job.php index 2ef02df9c6..9d785c876b 100644 --- a/CRM/Admin/Page/Job.php +++ b/CRM/Admin/Page/Job.php @@ -111,6 +111,13 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { ); CRM_Utils_System::appendBreadCrumb($breadCrumb); + $this->_id = CRM_Utils_Request::retrieve('id', 'String', + $this, FALSE, 0 + ); + $this->_action = CRM_Utils_Request::retrieve('action', 'String', + $this, FALSE, 0 + ); + if (($this->_action & CRM_Core_Action::COPY) && (!empty($this->_id))) { try { $jobResult = civicrm_api3('Job', 'clone', array('id' => $this->_id)); @@ -153,7 +160,6 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { $action -= CRM_Core_Action::ENABLE; } else { - $action -= CRM_Core_Action::VIEW; $action -= CRM_Core_Action::DISABLE; } diff --git a/templates/CRM/Admin/Form/Job.tpl b/templates/CRM/Admin/Form/Job.tpl index 98c05f30b5..0fb95d4655 100644 --- a/templates/CRM/Admin/Form/Job.tpl +++ b/templates/CRM/Admin/Form/Job.tpl @@ -20,7 +20,7 @@ {elseif $action eq 4}
- {ts}Are you sure you would like to execute this job?{/ts} + {ts 1=$jobName}Are you sure you would like to execute %1 job?{/ts}
{else} -- 2.25.1