/**
 * Retrieve one or more contacts, given a set of search params
 *
 * @param  mixed[]  (reference ) input parameters
 * @param  bool  follow the pre-2.2.3 behavior of this function
 *
 * @return array (reference )        array of properties, if error an array with an error id and error message
 * @static void
 * @access public
 */
function civicrm_contact_get(&$params, $deprecated_behavior = FALSE)
{
    _civicrm_initialize();
    if ($deprecated_behavior) {
        return _civicrm_contact_get_deprecated($params);
    }
    // fix for CRM-7384 cater for soft deleted contacts
    $params['contact_is_deleted'] = 0;
    if (isset($params['showAll'])) {
        if (strtolower($params['showAll']) == "active") {
            $params['contact_is_deleted'] = 0;
        }
        if (strtolower($params['showAll']) == "trash") {
            $params['contact_is_deleted'] = 1;
        }
        if (strtolower($params['showAll']) == "all" && isset($params['contact_is_deleted'])) {
            unset($params['contact_is_deleted']);
        }
    }
    $inputParams = array();
    $returnProperties = array();
    $otherVars = array('sort', 'offset', 'rowCount', 'smartGroupCache');
    $sort = NULL;
    $offset = 0;
    $rowCount = 25;
    $smartGroupCache = FALSE;
    foreach ($params as $n => $v) {
        if (substr($n, 0, 6) == 'return') {
            $returnProperties[substr($n, 7)] = $v;
        } elseif (in_array($n, $otherVars)) {
            ${$n} = $v;
        } else {
            $inputParams[$n] = $v;
        }
    }
    if (empty($returnProperties)) {
        $returnProperties = NULL;
    }
    require_once 'CRM/Contact/BAO/Query.php';
    $newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
    list($contacts, $options) = CRM_Contact_BAO_Query::apiQuery($newParams, $returnProperties, NULL, $sort, $offset, $rowCount, $smartGroupCache);
    return $contacts;
}
Example #2
0
/**
 * Retrieve one or more contacts, given a set of search params
 *
 * @param  mixed[]  (reference ) input parameters
 * @param  bool  follow the pre-2.2.3 behavior of this function
 *
 * @return array (reference )        array of properties, if error an array with an error id and error message
 * @static void
 * @access public
 */
function civicrm_contact_get(&$params, $deprecated_behavior = false)
{
    _civicrm_initialize();
    if ($deprecated_behavior) {
        return _civicrm_contact_get_deprecated($params);
    }
    $inputParams = array();
    $returnProperties = array();
    $otherVars = array('sort', 'offset', 'rowCount', 'smartGroupCache');
    $sort = null;
    $offset = 0;
    $rowCount = 25;
    $smartGroupCache = false;
    foreach ($params as $n => $v) {
        if (substr($n, 0, 6) == 'return') {
            $returnProperties[substr($n, 7)] = $v;
        } elseif (in_array($n, $otherVars)) {
            ${$n} = $v;
        } else {
            $inputParams[$n] = $v;
        }
    }
    if (empty($returnProperties)) {
        $returnProperties = null;
    }
    require_once 'CRM/Contact/BAO/Query.php';
    $newParams =& CRM_Contact_BAO_Query::convertFormValues($inputParams);
    list($contacts, $options) = CRM_Contact_BAO_Query::apiQuery($newParams, $returnProperties, null, $sort, $offset, $rowCount, $smartGroupCache);
    return $contacts;
}