5da438e636e34473cde4a93c72f476e5102292b7
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.6 |
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2014 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
30 * File for the CiviCRM APIv3 domain functions
32 * @package CiviCRM_APIv3
33 * @subpackage API_Domain
35 * @copyright CiviCRM LLC (c) 2004-2014
36 * @version $Id: Domain.php 30171 2010-10-14 09:11:27Z mover $
41 * Flush all system caches
43 * @param array $params
45 * - triggers: bool, whether to drop/create SQL triggers; default: FALSE
46 * - session: bool, whether to reset the CiviCRM session data; defaul: FALSE
49 * true if success, else false
52 * @example SystemFlush.php
55 function civicrm_api3_system_flush($params) {
56 CRM_Core_Invoke
::rebuildMenuAndCaches(
57 CRM_Utils_Array
::value('triggers', $params, FALSE),
58 CRM_Utils_Array
::value('session', $params, FALSE)
60 return civicrm_api3_create_success();
64 * Adjust Metadata for Flush action
66 * The metadata is used for setting defaults, documentation & validation
67 * @param array $params
68 * Array or parameters determined by getfields.
70 function _civicrm_api3_system_flush_spec(&$params) {
71 $params['triggers'] = array('title' => 'rebuild triggers (boolean)');
72 $params['session'] = array('title' => 'refresh sessions (boolean)');
76 * System.Check API specification (optional)
77 * This is used for documentation and validation.
80 * Description of fields supported by this API call.
82 * @see http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
84 function _civicrm_api3_system_check_spec(&$spec) {
85 // $spec['magicword']['api.required'] = 1;
91 * @param array $params
93 * API result descriptor; return items are alert codes/messages
94 * @see civicrm_api3_create_success
95 * @see civicrm_api3_create_error
96 * @throws API_Exception
98 function civicrm_api3_system_check($params) {
99 $returnValues = array();
100 foreach (CRM_Utils_Check
::singleton()->checkAll() as $message) {
101 $returnValues[] = $message->toArray();
104 // Spec: civicrm_api3_create_success($values = 1, $params = array(), $entity = NULL, $action = NULL)
105 return civicrm_api3_create_success($returnValues, $params, 'System', 'Check');
109 * @param array $params
113 function civicrm_api3_system_log($params) {
114 $log = new CRM_Utils_SystemLogger();
115 // this part means fields with separate db storage are accepted as params which kind of seems more intuitive to me
116 // because I felt like not doing this required a bunch of explanation in the spec function - but perhaps other won't see it as helpful?
117 if (!isset($params['context'])) {
118 $params['context'] = array();
120 $specialFields = array('contact_id', 'hostname');
121 foreach ($specialFields as $specialField) {
122 if (isset($params[$specialField]) && !isset($params['context'])) {
123 $params['context'][$specialField] = $params[$specialField];
126 $returnValues = $log->log($params['level'], $params['message'], $params['context']);
127 return civicrm_api3_create_success($returnValues, $params, 'System', 'Log');
131 * Metadata for log function
132 * @param array $params
134 function _civicrm_api3_system_log_spec(&$params) {
135 $params['level'] = array(
136 'title' => 'Log Level',
137 'description' => 'Log level as described in PSR3 (info, debug, warning etc)',
138 'type' => CRM_Utils_Type
::T_STRING
,
139 'api.required' => TRUE,
141 $params['message'] = array(
142 'title' => 'Log Message',
143 'description' => 'Standardised message string, you can also ',
144 'type' => CRM_Utils_Type
::T_STRING
,
145 'api.required' => TRUE,
147 $params['context'] = array(
148 'title' => 'Log Context',
149 'description' => 'An array of additional data to store.',
150 'type' => CRM_Utils_Type
::T_LONGTEXT
,
151 'api.default' => array(),
153 $params['contact_id'] = array(
154 'title' => 'Log Contact ID',
155 'description' => 'Optional ID of relevant contact',
156 'type' => CRM_Utils_Type
::T_INT
,
158 $params['hostname'] = array(
159 'title' => 'Log Hostname',
160 'description' => 'Optional name of host',
161 'type' => CRM_Utils_Type
::T_STRING
,
168 * @param arary $params
170 function civicrm_api3_system_get($params) {
171 $returnValues = array(
173 'version' => CRM_Utils_System
::version(),
177 return civicrm_api3_create_success($returnValues, $params, 'System', 'get');