Exemplo n.º 1
0
/**
 *
 * This method allows to update Email Greetings, Postal Greetings and Addressee for a specific contact type.
 * IMPORTANT: You must first create valid option value before using via admin interface.
 * Check option lists for Email Greetings, Postal Greetings and Addressee
 *
 *                        id - Integer - greetings option group
 *
 * @param $params
 *
 * @return boolean        true if success, else false
 * @static
 * @access public
 */
function civicrm_api3_job_update_greeting($params)
{
    if (isset($params['ct']) && isset($params['gt'])) {
        $ct = $gt = array();
        $ct = explode(',', $params['ct']);
        $gt = explode(',', $params['gt']);
        foreach ($ct as $ctKey => $ctValue) {
            foreach ($gt as $gtKey => $gtValue) {
                $params['ct'] = trim($ctValue);
                $params['gt'] = trim($gtValue);
                $result[] = CRM_Contact_BAO_Contact_Utils::updateGreeting($params);
            }
        }
    } else {
        $result = CRM_Contact_BAO_Contact_Utils::updateGreeting($params);
    }
    foreach ($result as $resultKey => $resultValue) {
        if ($resultValue['is_error'] == 0) {
            //really we should rely on the exception mechanism here - but we need to test that before removing this line
            return civicrm_api3_create_success();
        } else {
            return civicrm_api3_create_error($resultValue['messages']);
        }
    }
}
Exemplo n.º 2
0
/**
 * This method allows to update Email Greetings, Postal Greetings and Addressee for a specific contact type.
 *
 * IMPORTANT: You must first create valid option value before using via admin interface.
 * Check option lists for Email Greetings, Postal Greetings and Addressee
 *
 * @todo - is this here by mistake or should it be added to _spec function :id - Integer - greetings option group.
 *
 * @param array $params
 *
 * @return array
 */
function civicrm_api3_job_update_greeting($params)
{
    if (isset($params['ct']) && isset($params['gt'])) {
        $ct = explode(',', $params['ct']);
        $gt = explode(',', $params['gt']);
        foreach ($ct as $ctKey => $ctValue) {
            foreach ($gt as $gtKey => $gtValue) {
                $params['ct'] = trim($ctValue);
                $params['gt'] = trim($gtValue);
                CRM_Contact_BAO_Contact_Utils::updateGreeting($params);
            }
        }
    } else {
        CRM_Contact_BAO_Contact_Utils::updateGreeting($params);
    }
    return civicrm_api3_create_success();
}
Exemplo n.º 3
0
/**
 *
 * This method allows to update Email Greetings, Postal Greetings and Addressee for a specific contact type.
 * IMPORTANT: You must first create valid option value before using via admin interface.
 * Check option lists for Email Greetings, Postal Greetings and Addressee
 *
 * @param  array   	  $params (reference ) input parameters
 *                        ct - String - ct=Individual or ct=Household or ct=Organization
 *                        gt - String - gt=email_greeting or gt=postal_greeting or gt=addressee
 *                        id - Integer - greetings option group
 *
 * @return boolean        true if success, else false
 * @static
 * @access public
 *
 */
function civicrm_api3_job_update_greeting($params)
{
    require_once 'CRM/Contact/BAO/Contact/Utils.php';
    civicrm_api3_verify_mandatory($params, NULL, array('ct', 'gt'));
    // fixme - use the wrapper & getfields to do this checking - advertise as an enum
    if (!in_array($params['ct'], array('Individual', 'Household', 'Organization'))) {
        return civicrm_api3_create_error(ts('Invalid contact type (ct) parameter value'));
    }
    if (!in_array($params['gt'], array('email_greeting', 'postal_greeting', 'addressee'))) {
        return civicrm_api3_create_error(ts('Invalid greeting type (gt) parameter value'));
    }
    $result = CRM_Contact_BAO_Contact_Utils::updateGreeting($params);
    if ($result['is_error'] == 0) {
        return civicrm_api3_create_success();
    } else {
        return civicrm_api3_create_error($result['messages']);
    }
}