Merge pull request #12549 from civicrm/5.4
[civicrm-core.git] / CRM / Admin / Page / JobLog.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
8c9251b3 6 | Copyright CiviCRM LLC (c) 2004-2018 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
8c9251b3 31 * @copyright CiviCRM LLC (c) 2004-2018
6a488035
TO
32 */
33
34/**
ce064e4f 35 * Page for displaying list of jobs.
6a488035
TO
36 */
37class CRM_Admin_Page_JobLog extends CRM_Core_Page_Basic {
38
39 /**
eceb18cc 40 * The action links that we need to display for the browse screen.
6a488035
TO
41 *
42 * @var array
6a488035
TO
43 */
44 static $_links = NULL;
45
46 /**
eceb18cc 47 * Get BAO Name.
6a488035 48 *
a6c01b45
CW
49 * @return string
50 * Classname of BAO.
6a488035 51 */
00be9182 52 public function getBAOName() {
6a488035
TO
53 return 'CRM_Core_BAO_Job';
54 }
55
56 /**
eceb18cc 57 * Get action Links.
6a488035 58 *
a6c01b45
CW
59 * @return array
60 * (reference) of action links
6a488035 61 */
00be9182 62 public function &links() {
6a488035
TO
63 return self::$_links;
64 }
65
66 /**
67 * Run the page.
68 *
69 * This method is called after the page is created. It checks for the
70 * type of action and executes that action.
71 * Finally it calls the parent's run method.
6a488035 72 */
00be9182 73 public function run() {
6a488035
TO
74 // set title and breadcrumb
75 CRM_Utils_System::setTitle(ts('Settings - Scheduled Jobs Log'));
353ffa53
TO
76 $breadCrumb = array(
77 array(
78 'title' => ts('Administration'),
6a488035
TO
79 'url' => CRM_Utils_System::url('civicrm/admin',
80 'reset=1'
81 ),
389bcebf 82 ),
353ffa53 83 );
6a488035
TO
84 CRM_Utils_System::appendBreadCrumb($breadCrumb);
85 return parent::run();
86 }
87
88 /**
89 * Browse all jobs.
90 *
dd244018 91 * @param null $action
6a488035 92 */
00be9182 93 public function browse($action = NULL) {
6a488035
TO
94
95 $jid = CRM_Utils_Request::retrieve('jid', 'Positive', $this);
96
97 $sj = new CRM_Core_JobManager();
98
99 $jobName = NULL;
5e99888b 100 if ($jid) {
389bcebf 101 $jobName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Job', $jid);
6a488035
TO
102 }
103
104 $this->assign('jobName', $jobName);
105
106 $dao = new CRM_Core_DAO_JobLog();
107 $dao->orderBy('id desc');
5e99888b
DL
108
109 // limit to last 1000 records
110 $dao->limit(1000);
111
112 if ($jid) {
6a488035
TO
113 $dao->job_id = $jid;
114 }
115 $dao->find();
5e99888b 116
6a488035
TO
117 $rows = array();
118 while ($dao->fetch()) {
119 unset($row);
120 CRM_Core_DAO::storeValues($dao, $row);
121 $rows[$dao->id] = $row;
122 }
123 $this->assign('rows', $rows);
124
125 $this->assign('jobId', $jid);
126 }
127
128 /**
eceb18cc 129 * Get name of edit form.
6a488035 130 *
a6c01b45
CW
131 * @return string
132 * Classname of edit form.
6a488035 133 */
00be9182 134 public function editForm() {
6a488035
TO
135 return 'CRM_Admin_Form_Job';
136 }
137
138 /**
eceb18cc 139 * Get edit form name.
6a488035 140 *
a6c01b45
CW
141 * @return string
142 * name of this page.
6a488035 143 */
00be9182 144 public function editName() {
6a488035
TO
145 return 'Scheduled Jobs';
146 }
147
148 /**
149 * Get user context.
150 *
da6b46f4
EM
151 * @param null $mode
152 *
a6c01b45
CW
153 * @return string
154 * user context.
6a488035 155 */
00be9182 156 public function userContext($mode = NULL) {
6a488035
TO
157 return 'civicrm/admin/job';
158 }
96025800 159
6a488035 160}