| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
| 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 | +--------------------------------------------------------------------+ |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * |
| 30 | * @package CRM |
| 31 | * @copyright CiviCRM LLC (c) 2004-2017 |
| 32 | */ |
| 33 | |
| 34 | /** |
| 35 | * Page for displaying list of jobs. |
| 36 | */ |
| 37 | class CRM_Admin_Page_JobLog extends CRM_Core_Page_Basic { |
| 38 | |
| 39 | /** |
| 40 | * The action links that we need to display for the browse screen. |
| 41 | * |
| 42 | * @var array |
| 43 | */ |
| 44 | static $_links = NULL; |
| 45 | |
| 46 | /** |
| 47 | * Get BAO Name. |
| 48 | * |
| 49 | * @return string |
| 50 | * Classname of BAO. |
| 51 | */ |
| 52 | public function getBAOName() { |
| 53 | return 'CRM_Core_BAO_Job'; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Get action Links. |
| 58 | * |
| 59 | * @return array |
| 60 | * (reference) of action links |
| 61 | */ |
| 62 | public function &links() { |
| 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. |
| 72 | */ |
| 73 | public function run() { |
| 74 | // set title and breadcrumb |
| 75 | CRM_Utils_System::setTitle(ts('Settings - Scheduled Jobs Log')); |
| 76 | $breadCrumb = array( |
| 77 | array( |
| 78 | 'title' => ts('Administration'), |
| 79 | 'url' => CRM_Utils_System::url('civicrm/admin', |
| 80 | 'reset=1' |
| 81 | ), |
| 82 | ), |
| 83 | ); |
| 84 | CRM_Utils_System::appendBreadCrumb($breadCrumb); |
| 85 | return parent::run(); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Browse all jobs. |
| 90 | * |
| 91 | * @param null $action |
| 92 | */ |
| 93 | public function browse($action = NULL) { |
| 94 | |
| 95 | $jid = CRM_Utils_Request::retrieve('jid', 'Positive', $this); |
| 96 | |
| 97 | $sj = new CRM_Core_JobManager(); |
| 98 | |
| 99 | $jobName = NULL; |
| 100 | if ($jid) { |
| 101 | $jobName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Job', $jid); |
| 102 | } |
| 103 | |
| 104 | $this->assign('jobName', $jobName); |
| 105 | |
| 106 | $dao = new CRM_Core_DAO_JobLog(); |
| 107 | $dao->orderBy('id desc'); |
| 108 | |
| 109 | // limit to last 1000 records |
| 110 | $dao->limit(1000); |
| 111 | |
| 112 | if ($jid) { |
| 113 | $dao->job_id = $jid; |
| 114 | } |
| 115 | $dao->find(); |
| 116 | |
| 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 | /** |
| 129 | * Get name of edit form. |
| 130 | * |
| 131 | * @return string |
| 132 | * Classname of edit form. |
| 133 | */ |
| 134 | public function editForm() { |
| 135 | return 'CRM_Admin_Form_Job'; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Get edit form name. |
| 140 | * |
| 141 | * @return string |
| 142 | * name of this page. |
| 143 | */ |
| 144 | public function editName() { |
| 145 | return 'Scheduled Jobs'; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Get user context. |
| 150 | * |
| 151 | * @param null $mode |
| 152 | * |
| 153 | * @return string |
| 154 | * user context. |
| 155 | */ |
| 156 | public function userContext($mode = NULL) { |
| 157 | return 'civicrm/admin/job'; |
| 158 | } |
| 159 | |
| 160 | } |