Esempio n. 1
0
/**
 * Creates or modifies a Cxn row.
 *
 * @param array $params
 *   Array with keys:
 *   - id, cxn_guid OR app_guid: string.
 *   - is_active: boolean.
 *   - options: JSON
 * @return page
 * @throws Exception
 */
function civicrm_api3_cxn_create($params)
{
    $result = "";
    try {
        // get the ID
        if (!empty($params['id'])) {
            $cxnId = $params['id'];
        } else {
            $cxnId = _civicrm_api3_cxn_parseCxnId($params);
        }
        // see if it's sth to update
        if (isset($params['options']) || isset($params['is_active'])) {
            $dao = new CRM_Cxn_DAO_Cxn();
            $dao->id = $cxnId;
            if ($dao->find()) {
                if (isset($params['is_active'])) {
                    $dao->is_active = (int) $params['is_active'];
                }
                if (isset($params['options'])) {
                    $dao->options = $params['options'];
                }
                $result = $dao->save();
            }
        }
        return civicrm_api3_create_success($result, $params, 'Cxn', 'create');
    } catch (Exception $ex) {
        throw $ex;
    }
}
Esempio n. 2
0
/**
 *
 * @param array $params
 *   Array with keys:
 *   - cxn_guid OR app_guid: string.
 *   - page: string.
 * @return array
 * @throws Exception
 */
function civicrm_api3_cxn_getlink($params)
{
    $cxnId = _civicrm_api3_cxn_parseCxnId($params);
    $appMeta = CRM_Cxn_BAO_Cxn::getAppMeta($cxnId);
    if (empty($params['page']) || !is_string($params['page'])) {
        throw new API_Exception("Invalid page");
    }
    /** @var \Civi\Cxn\Rpc\RegistrationClient $client */
    $client = \Civi::service('cxn_reg_client');
    return $client->call($appMeta, 'Cxn', 'getlink', array('page' => $params['page']));
}
Esempio n. 3
0
/**
 *
 * @param array $params
 * @return array
 * @throws Exception
 */
function civicrm_api3_cxn_getcfg($params)
{
    $result = array('CIVICRM_CXN_CA' => defined('CIVICRM_CXN_CA') ? CIVICRM_CXN_CA : NULL, 'CIVICRM_CXN_VIA' => defined('CIVICRM_CXN_VIA') ? CIVICRM_CXN_VIA : NULL, 'CIVICRM_CXN_APPS_URL' => defined('CIVICRM_CXN_APPS_URL') ? CIVICRM_CXN_APPS_URL : NULL, 'siteCallbackUrl' => CRM_Cxn_BAO_Cxn::getSiteCallbackUrl());
    return civicrm_api3_create_success($result);
    $cxnId = _civicrm_api3_cxn_parseCxnId($params);
    $appMeta = CRM_Cxn_BAO_Cxn::getAppMeta($cxnId);
    if (empty($params['page']) || !is_string($params['page'])) {
        throw new API_Exception("Invalid page");
    }
    /** @var \Civi\Cxn\Rpc\RegistrationClient $client */
    $client = \Civi\Core\Container::singleton()->get('cxn_reg_client');
    return $client->call($appMeta, 'Cxn', 'getlink', array('page' => $params['page']));
}