From cff86269d976fd59f0e38da1330a4c908a5bb03e Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Wed, 12 Apr 2023 17:53:38 +0100 Subject: [PATCH] Scheduled Jobs - add dedicated url's for add, edit/delete to facilitate replacing search page with SearchKit --- CRM/Admin/Form/Job.php | 11 +++++++++-- CRM/Admin/Page/Job.php | 8 ++++---- CRM/Admin/Page/JobLog.php | 2 +- CRM/Core/DAO/Job.php | 13 ++++++++++++- CRM/Core/xml/Menu/Admin.xml | 18 ++++++++++++++++++ templates/CRM/Admin/Page/Job.tpl | 6 +++--- xml/schema/Core/Job.xml | 5 +++++ 7 files changed, 52 insertions(+), 11 deletions(-) diff --git a/CRM/Admin/Form/Job.php b/CRM/Admin/Form/Job.php index 3a53bf9ddf..e99f96f734 100644 --- a/CRM/Admin/Form/Job.php +++ b/CRM/Admin/Form/Job.php @@ -34,13 +34,13 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { $this->setTitle(ts('Manage - Scheduled Jobs')); if ($this->_id) { - $refreshURL = CRM_Utils_System::url('civicrm/admin/job', + $refreshURL = CRM_Utils_System::url('civicrm/admin/job/edit', "reset=1&action=update&id={$this->_id}", FALSE, NULL, FALSE ); } else { - $refreshURL = CRM_Utils_System::url('civicrm/admin/job', + $refreshURL = CRM_Utils_System::url('civicrm/admin/job/add', "reset=1&action=add", FALSE, NULL, FALSE ); @@ -49,6 +49,13 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { $this->assign('refreshURL', $refreshURL); } + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Job'; + } + /** * Build the form object. * diff --git a/CRM/Admin/Page/Job.php b/CRM/Admin/Page/Job.php index 0beb9c218b..80ba5524ab 100644 --- a/CRM/Admin/Page/Job.php +++ b/CRM/Admin/Page/Job.php @@ -54,13 +54,13 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { ], CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), - 'url' => 'civicrm/admin/job', + 'url' => 'civicrm/admin/job/edit', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Scheduled Job'), ], CRM_Core_Action::VIEW => [ 'name' => ts('Execute Now'), - 'url' => 'civicrm/admin/job', + 'url' => 'civicrm/admin/job/edit', 'qs' => 'action=view&id=%%id%%&reset=1', 'title' => ts('Execute Scheduled Job Now'), ], @@ -76,13 +76,13 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { ], CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), - 'url' => 'civicrm/admin/job', + 'url' => 'civicrm/admin/job/edit', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete Scheduled Job'), ], CRM_Core_Action::COPY => [ 'name' => ts('Copy'), - 'url' => 'civicrm/admin/job', + 'url' => 'civicrm/admin/job/edit', 'qs' => 'action=copy&id=%%id%%', 'title' => ts('Copy Scheduled Job'), ], diff --git a/CRM/Admin/Page/JobLog.php b/CRM/Admin/Page/JobLog.php index 5fbf7c5959..2bee42ccf6 100644 --- a/CRM/Admin/Page/JobLog.php +++ b/CRM/Admin/Page/JobLog.php @@ -80,7 +80,7 @@ class CRM_Admin_Page_JobLog extends CRM_Core_Page_Basic { 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); + $jobRunUrl = CRM_Utils_System::url('civicrm/admin/job/edit', 'action=view&reset=1&context=joblog&id=' . $jid); $this->assign('jobRunUrl', $jobRunUrl); } else { diff --git a/CRM/Core/DAO/Job.php b/CRM/Core/DAO/Job.php index 3520d7afab..e8875e7c31 100644 --- a/CRM/Core/DAO/Job.php +++ b/CRM/Core/DAO/Job.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/Job.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:512bc14536dfd40680e4de831c8991e9) + * (GenCodeChecksum:402e95e8458a1f584023aee6f7fc87f5) */ /** @@ -30,6 +30,17 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO { */ public static $_log = FALSE; + /** + * Paths for accessing this entity in the UI. + * + * @var string[] + */ + protected static $_paths = [ + 'add' => 'civicrm/admin/job/add?reset=1&action=add', + 'delete' => 'civicrm/admin/job/edit?reset=1&action=delete&id=[id]', + 'update' => 'civicrm/admin/job/edit?reset=1&action=edit&id=[id]', + ]; + /** * Job ID * diff --git a/CRM/Core/xml/Menu/Admin.xml b/CRM/Core/xml/Menu/Admin.xml index 3922edb13c..fc29dd479e 100644 --- a/CRM/Core/xml/Menu/Admin.xml +++ b/CRM/Core/xml/Menu/Admin.xml @@ -587,6 +587,24 @@ System Settings 1370 + + civicrm/admin/job/add + Add Scheduled Job + Add a periodially running task. + CRM_Admin_Page_Job + access CiviCRM,administer CiviCRM system + System Settings + 1371 + + + civicrm/admin/job/edit + Edit Scheduled Job + Edit a periodially running task. + CRM_Admin_Page_Job + access CiviCRM,administer CiviCRM system + System Settings + 1372 + civicrm/admin/joblog Scheduled Jobs Log diff --git a/templates/CRM/Admin/Page/Job.tpl b/templates/CRM/Admin/Page/Job.tpl index 2ba136f5d7..57d54e6692 100644 --- a/templates/CRM/Admin/Page/Job.tpl +++ b/templates/CRM/Admin/Page/Job.tpl @@ -22,7 +22,7 @@ {if $action ne 1 and $action ne 2} {/if} @@ -57,7 +57,7 @@ {if $action ne 1 and $action ne 2} {/if} @@ -68,7 +68,7 @@ {ts}There are no jobs configured.{/ts} {/if} diff --git a/xml/schema/Core/Job.xml b/xml/schema/Core/Job.xml index c01173f08e..8fe650a489 100644 --- a/xml/schema/Core/Job.xml +++ b/xml/schema/Core/Job.xml @@ -7,6 +7,11 @@ Scheduled job. 4.1 false + + civicrm/admin/job/add?reset=1&action=add + civicrm/admin/job/edit?reset=1&action=delete&id=[id] + civicrm/admin/job/edit?reset=1&action=edit&id=[id] + id Job ID -- 2.25.1