3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 * This api exposes functionality for interacting with the logging functionality.
31 * @package CiviCRM_APIv3
35 * Revert a log change.
37 * @param array $params
41 * @throws \API_Exception
42 * @throws \Civi\API\Exception\UnauthorizedException
44 function civicrm_api3_logging_revert($params) {
45 $schema = new CRM_Logging_Schema();
46 $reverter = new CRM_Logging_Reverter($params['log_conn_id'], CRM_Utils_Array
::value('log_date', $params));
47 $reverter->calculateDiffsFromLogConnAndDate($schema->getLogTablesForContact());
49 return civicrm_api3_create_success(1);
55 * @param array $params
57 * @throws \API_Exception
58 * @throws \Civi\API\Exception\UnauthorizedException
60 function _civicrm_api3_logging_revert_spec(&$params) {
61 $params['log_conn_id'] = array(
62 'title' => 'Logging Connection ID',
63 'type' => CRM_Utils_Type
::T_STRING
,
64 'api.required' => TRUE,
66 $params['log_date'] = array(
67 'title' => 'Logging Timestamp',
68 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
70 $params['interval'] = array(
71 'title' => ts('Interval (required if date is included)'),
72 'type' => CRM_Utils_Type
::T_STRING
,
73 'api.default' => '10 SECOND',
74 'description' => ts('Used when log_date is passed in'),
81 * @param array $params
85 * @throws \API_Exception
86 * @throws \Civi\API\Exception\UnauthorizedException
88 function civicrm_api3_logging_get($params) {
89 $schema = new CRM_Logging_Schema();
90 $interval = (empty($params['log_date'])) ?
NULL : $params['interval'];
91 $differ = new CRM_Logging_Differ($params['log_conn_id'], CRM_Utils_Array
::value('log_date', $params), $interval);
92 return civicrm_api3_create_success($differ->getAllChangesForConnection($schema->getLogTablesForContact()));
98 * @param array $params
100 * @throws \API_Exception
101 * @throws \Civi\API\Exception\UnauthorizedException
103 function _civicrm_api3_logging_get_spec(&$params) {
104 $params['log_conn_id'] = array(
105 'title' => 'Logging Connection ID',
106 'type' => CRM_Utils_Type
::T_STRING
,
107 'api.required' => TRUE,
109 $params['log_date'] = array(
110 'title' => 'Logging Timestamp',
111 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
113 $params['interval'] = array(
114 'title' => ts('Interval (required if date is included)'),
115 'type' => CRM_Utils_Type
::T_STRING
,
116 'api.default' => '10 SECOND',
117 'description' => ts('Used when log_date is passed in'),