+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*/
/**
- * File for the CiviCRM APIv3 contact and mailing functions
+ * This api exposes CiviCRM contact and mailing.
*
* @package CiviCRM_APIv3
- * @subpackage API_MailingContact
- *
- * @copyright CiviCRM LLC (c) 2004-2014
- * @version $Id$
- *
*/
/**
- * Get all the mailings and details that a contact was involved with
+ * Get all the mailings and details that a contact was involved with.
*
* @param array $params
- * Input parameters.
- * - key: contact_id, value: int - required
- * - key: type, value: Delivered | Bounced - optional, defaults to Delivered
- * - Future extensions will include: Opened, Clicked, Forwarded
+ * Input parameters - see _spec for details (returned by getfields)
*
* @return array
* API result
- * @static void
- * @access public
- * @example CRM/Mailing/BAO/Mailing.php
- *
*/
function civicrm_api3_mailing_contact_get($params) {
return civicrm_api3_create_success(_civicrm_api3_mailing_contact_getresults($params, FALSE));
}
+
/**
- * This is a wrapper for the functions that return the results from the 'quasi-entity'
- * mailing contact
+ * This is a wrapper for the functions that return the results from the 'quasi-entity' mailing contact.
+ *
* @param array $params
* @param bool $count
+ *
* @throws Exception
*/
function _civicrm_api3_mailing_contact_getresults($params, $count) {
if (empty($params['type'])) {
- //ie. because the api is an anomoly & passing in id is not valid
+ //ie. because the api is an anomaly & passing in id is not valid
throw new Exception('This api call does not accept api as a parameter');
}
- $options = _civicrm_api3_get_options_from_params($params, TRUE,'contribution','get');
+ $options = _civicrm_api3_get_options_from_params($params, TRUE, 'contribution', 'get');
$fnName = '_civicrm_api3_mailing_contact_get_' . strtolower($params['type']);
return $fnName(
$params['contact_id'],
$count
);
}
+
/**
- * Adjust Metadata for Get action
+ * Adjust Metadata for Get action.
*
* @param array $params
- * Array or parameters determined by getfields.
+ * Array of parameters determined by getfields.
*/
function _civicrm_api3_mailing_contact_get_spec(&$params) {
- $params['contact_id']['api.required'] = 1;
- $params['contact_id']['title'] = 'Contact ID';
+ $params['contact_id'] = array(
+ 'api.required' => 1,
+ 'title' => 'Contact ID',
+ 'type' => CRM_Utils_Type::T_INT,
+ );
+
$params['type'] = array(
'api.default' => 'Delivered',
- 'title' => 'Type',// doesn't really explain the field - but not sure I understand it to explain it better
+ 'title' => 'Type', // doesn't really explain the field - but not sure I understand it to explain it better
'type' => CRM_Utils_Type::T_STRING,
'options' => array(
'Delivered' => 'Delivered',
}
/**
- * @param $type
+ * Helper function for mailing contact queries.
+ *
* @param int $contactID
* @param $offset
* @param $limit
* @return array
*/
function _civicrm_api3_mailing_contact_query(
- $type,
$contactID,
$offset,
$limit,
);
$dao = CRM_Core_DAO::executeQuery($sql, $qParams);
- $params = array(
- 'type' => $type,
- 'contact_id' => $contactID,
- );
-
$results = $dao->N;
}
else {
}
/**
+ * Get delivered mailing contacts.
+ *
* @param int $contactID
* @param $offset
* @param $limit
";
return _civicrm_api3_mailing_contact_query(
- 'Delivered',
$contactID,
$offset,
$limit,
}
/**
+ * Get bounced mailing contact records.
+ *
* @param int $contactID
* @param $offset
* @param $limit
";
return _civicrm_api3_mailing_contact_query(
- 'Bounced',
$contactID,
$offset,
$limit,
}
/**
- * Get count of all the mailings that a contact was involved with
+ * Get count of all the mailings that a contact was involved with.
*
* @param array $params
- * Input parameters.
- * - key: contact_id, value: int - required
- * - key: type, value: Delivered | Bounced - optional, defaults to Delivered
- * - Future extensions will include: Opened, Clicked, Forwarded
+ * Input parameters per getfields
*
* @return array
* API result
- * @static void
- * @access public
- * @example CRM/Mailing/BAO/Mailing.php
- *
*/
function civicrm_api3_mailing_contact_getcount($params) {
return _civicrm_api3_mailing_contact_getresults($params, TRUE);