Esempio n. 1
0
/**
 * Retrieve a set of activities, specific to given input params.
 *
 * @param  array  $params (reference ) input parameters.
 *
 * @return array (reference)  array of activities / error message.
 * @access public
 */
function civicrm_activity_contact_get($params)
{
    _civicrm_initialize();
    $contactId = CRM_Utils_Array::value('contact_id', $params);
    if (empty($contactId)) {
        return civicrm_create_error(ts("Required parameter not found"));
    }
    if (!is_numeric($contactId)) {
        return civicrm_create_error(ts("Invalid contact Id"));
    }
    $activities =& _civicrm_activities_get($contactId);
    if ($activities) {
        return civicrm_create_success($activities);
    } else {
        return civicrm_create_error(ts('Invalid Data'));
    }
}
/**
 * Retrieve a set of activities, specific to given input params.
 *
 * @param  array  $params (reference ) input parameters.
 *
 * @return array (reference)  array of activities / error message.
 * @access public
 */
function civicrm_activity_contact_get($params)
{
    _civicrm_initialize();
    $contactId = CRM_Utils_Array::value('contact_id', $params);
    if (empty($contactId)) {
        return civicrm_create_error(ts("Required parameter not found"));
    }
    //check if $contactId is valid
    if (!is_numeric($contactId) || !preg_match('/^\\d+$/', $contactId)) {
        return civicrm_create_error(ts("Invalid contact Id"));
    }
    $activities =& _civicrm_activities_get($contactId);
    //show success for empty $activities array
    if (empty($activities)) {
        return civicrm_create_success(ts("0 activity record matching input params"));
    }
    if ($activities) {
        return civicrm_create_success($activities);
    } else {
        return civicrm_create_error(ts('Invalid Data'));
    }
}