X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FAdmin%2FPage%2FJob.php;h=9d9d31699d7a987e40e44b6044da6189597b5aff;hb=43cbbe29eae642e90bc1b98a49d15ab8c415b3e9;hp=25e6c0a2fb0fba6d0d6da60e94ea843374ccf14e;hpb=47cc54d5bdce1a28eb813390ac932fe18f79b619;p=civicrm-core.git diff --git a/CRM/Admin/Page/Job.php b/CRM/Admin/Page/Job.php index 25e6c0a2fb..9d9d31699d 100644 --- a/CRM/Admin/Page/Job.php +++ b/CRM/Admin/Page/Job.php @@ -1,7 +1,7 @@ 'action=delete&id=%%id%%', 'title' => ts('Delete Scheduled Job'), ), + CRM_Core_Action::COPY => array( + 'name' => ts('Copy'), + 'url' => 'civicrm/admin/job', + 'qs' => 'action=copy&id=%%id%%', + 'title' => ts('Copy Scheduled Job'), + ), ); } return self::$_links; @@ -128,11 +134,25 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { $this, FALSE, 0 ); + // FIXME: Why are we comparing an integer with a string here? if ($this->_action == 'export') { $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/job', 'reset=1')); } + if (($this->_action & CRM_Core_Action::COPY) && (!empty($this->_id))) { + try { + $jobResult = civicrm_api3('Job', 'clone', array('id' => $this->_id)); + if ($jobResult['count'] > 0) { + CRM_Core_Session::setStatus($jobResult['values'][$jobResult['id']]['name'], ts('Job copied successfully'), 'success'); + } + CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/job', 'reset=1')); + } + catch (Exception $e) { + CRM_Core_Session::setStatus(ts('Failed to copy job'), 'Error'); + } + } + return parent::run(); }