<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* Handle a create event.
*
* @param array $params
- * @param array $ids
- *
- * @return array
- * API Success Array
+ * @return array API Success Array
+ * API Success Array
+ * @throws \API_Exception
+ * @throws \Civi\API\Exception\UnauthorizedException
*/
-function civicrm_api3_mailing_create($params, $ids = array()) {
+function civicrm_api3_mailing_create($params) {
if (CRM_Mailing_Info::workflowEnabled()) {
if (!CRM_Core_Permission::check('create mailings')) {
throw new \Civi\API\Exception\UnauthorizedException("This system uses advanced CiviMail workflows which require additional permissions");
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
+/**
+ * @param array $params
+ * @return array
+ * @throws \API_Exception
+ */
function civicrm_api3_mailing_get_token($params) {
if (!array_key_exists("usage", $params)) {
throw new API_Exception('Mandatory keys missing from params array: entity');
* Handle a delete event.
*
* @param array $params
- * @param array $ids
*
* @return array
* API Success Array
*/
-function civicrm_api3_mailing_delete($params, $ids = array()) {
+function civicrm_api3_mailing_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
+/**
+ * @param array $spec
+ */
function _civicrm_api3_mailing_submit_spec(&$spec) {
$mailingFields = CRM_Mailing_DAO_Mailing::fields();
$spec['id'] = $mailingFields['id'];
return civicrm_api3_create_success($params);
}
else {
- throw new API_Exception(ts('Queue event could not be found'),'no_queue_event
+ throw new API_Exception(ts('Queue event could not be found'), 'no_queue_event
');
}
}
return civicrm_api3_create_success($params);
}
+/**
+ * @param array $params
+ * @return array
+ * @throws \API_Exception
+ */
function civicrm_api3_mailing_preview($params) {
civicrm_api3_verify_mandatory($params,
'CRM_Mailing_DAO_Mailing',
));
}
+/**
+ * @param array $spec
+ */
function _civicrm_api3_mailing_send_test_spec(&$spec) {
$spec['test_group']['title'] = 'Test Group ID';
$spec['test_email']['title'] = 'Test Email Address';
}
+/**
+ * @param array $params
+ * @return array
+ * @throws \API_Exception
+ * @throws \CiviCRM_API3_Exception
+ */
function civicrm_api3_mailing_send_test($params) {
if (!array_key_exists('test_group', $params) && !array_key_exists('test_email', $params)) {
throw new API_Exception("Mandatory key(s) missing from params array: test_group and/or test_email field are required");
$params['date']['title'] = 'Date';
}
+/**
+ * @param array $params
+ * @return array
+ * @throws \API_Exception
+ */
function civicrm_api3_mailing_stats($params) {
civicrm_api3_verify_mandatory($params,
'CRM_Mailing_DAO_MailingJob',
switch ($detail) {
case 'Delivered':
$stats[$params['mailing_id']] += array(
- $detail => CRM_Mailing_Event_BAO_Delivered::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date']),
+ $detail => CRM_Mailing_Event_BAO_Delivered::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date']),
);
break;
case 'Bounces':
$stats[$params['mailing_id']] += array(
- $detail => CRM_Mailing_Event_BAO_Bounce::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date']),
+ $detail => CRM_Mailing_Event_BAO_Bounce::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date']),
);
break;
case 'Unsubscribers':
$stats[$params['mailing_id']] += array(
- $detail => CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, NULL, $params['date']),
+ $detail => CRM_Mailing_Event_BAO_Unsubscribe::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, NULL, $params['date']),
);
break;
case 'Unique Clicks':
$stats[$params['mailing_id']] += array(
- $detail => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, NULL, $params['date']),
+ $detail => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, NULL, $params['date']),
);
break;
case 'Opened':
$stats[$params['mailing_id']] += array(
- $detail => CRM_Mailing_Event_BAO_Opened::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date']),
+ $detail => CRM_Mailing_Event_BAO_Opened::getTotalCount($params['mailing_id'], $params['job_id'], FALSE, $params['date']),
);
break;
}
* Fix the reset dates on the email record based on when a mail was last delivered
* We only consider mailings that were completed and finished in the last 3 to 7 days
* Both the min and max days can be set via the params
+ * @param array $params
+ * @return array
*/
function civicrm_api3_mailing_update_email_resetdate($params) {
CRM_Mailing_Event_BAO_Delivered::updateEmailResetDate(