First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,92 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
* Class CRM_Cxn_ApiRouter
*
* The ApiRouter receives an incoming API request from CiviConnect,
* validates it, configures permissions, and sends it to the API layer.
*/
class CRM_Cxn_ApiRouter {
/**
* @param array $cxn
* @param string $entity
* @param string $action
* @param array $params
* @return mixed
*/
public static function route($cxn, $entity, $action, $params) {
$SUPER_PERM = array('administer CiviCRM');
require_once 'api/v3/utils.php';
// FIXME: Shouldn't the X-Forwarded-Proto check be part of CRM_Utils_System::isSSL()?
if (Civi::settings()->get('enableSSL') &&
!CRM_Utils_System::isSSL() &&
strtolower(CRM_Utils_Array::value('X_FORWARDED_PROTO', CRM_Utils_System::getRequestHeaders())) != 'https'
) {
return civicrm_api3_create_error('System policy requires HTTPS.');
}
// Note: $cxn and cxnId are authenticated before router is called.
$dao = new CRM_Cxn_DAO_Cxn();
$dao->cxn_id = $cxn['cxnId'];
if (empty($cxn['cxnId']) || !$dao->find(TRUE) || !$dao->cxn_id) {
return civicrm_api3_create_error('Failed to lookup connection authorizations.');
}
if (!$dao->is_active) {
return civicrm_api3_create_error('Connection is inactive.');
}
if (!is_string($entity) || !is_string($action) || !is_array($params)) {
return civicrm_api3_create_error('API parameters are malformed.');
}
if (
empty($cxn['perm']['api'])
|| !is_array($cxn['perm']['api'])
|| empty($cxn['perm']['grant'])
|| !(is_array($cxn['perm']['grant']) || is_string($cxn['perm']['grant']))
) {
return civicrm_api3_create_error('Connection has no permissions.');
}
$whitelist = \Civi\API\WhitelistRule::createAll($cxn['perm']['api']);
\Civi::service('dispatcher')
->addSubscriber(new \Civi\API\Subscriber\WhitelistSubscriber($whitelist));
CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp();
if ($cxn['perm']['grant'] === '*') {
CRM_Core_Config::singleton()->userPermissionTemp->grant($SUPER_PERM);
}
else {
CRM_Core_Config::singleton()->userPermissionTemp->grant($cxn['perm']['grant']);
}
$params['check_permissions'] = 'whitelist';
return civicrm_api($entity, $action, $params);
}
}

View file

@ -0,0 +1,191 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
use Civi\Cxn\Rpc\Constants;
use Civi\Cxn\Rpc\DefaultCertificateValidator;
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* This class helps to manage connections to third-party apps.
*/
class CRM_Cxn_BAO_Cxn extends CRM_Cxn_DAO_Cxn {
/**
* Determine the current site's callback URL.
*
* @return string
*/
public static function getSiteCallbackUrl() {
$config = CRM_Core_Config::singleton();
if (preg_match('/^(http|https):/', $config->resourceBase)) {
$civiUrl = $config->resourceBase;
}
else {
$civiUrl = rtrim(CRM_Utils_System::baseURL(), '/') . '/' . ltrim($config->resourceBase, '/');
}
// In practice, this may not be necessary, but we want to prevent
// edge-cases that downgrade security-level below system policy.
if (Civi::settings()->get('enableSSL')) {
$civiUrl = preg_replace('/^http:/', 'https:', $civiUrl);
}
return rtrim($civiUrl, '/') . '/extern/cxn.php';
}
/**
* Update the AppMeta for any existing connections.
*
* @param array $appMeta
* @throws \Civi\Cxn\Rpc\Exception\CxnException
*/
public static function updateAppMeta($appMeta) {
\Civi\Cxn\Rpc\AppMeta::validate($appMeta);
CRM_Core_DAO::executeQuery('UPDATE civicrm_cxn SET app_meta = %1 WHERE app_guid = %2', array(
1 => array(json_encode($appMeta), 'String'),
2 => array($appMeta['appId'], 'String'),
));
}
/**
* Get the AppMeta for an existing connection.
*
* @param string $cxnId
* @return array
* @throws \Civi\Cxn\Rpc\Exception\CxnException
*/
public static function getAppMeta($cxnId) {
$appMetaJson = CRM_Core_DAO::getFieldValue('CRM_Cxn_DAO_Cxn', $cxnId, 'app_meta', 'cxn_guid', TRUE);
$appMeta = json_decode($appMetaJson, TRUE);
\Civi\Cxn\Rpc\AppMeta::validate($appMeta);
return $appMeta;
}
/**
* Parse the CIVICRM_CXN_CA constant. It may have the following
* values:
* - 'CiviRootCA'|undefined -- Use the production civicrm.org root CA
* - 'CiviTestRootCA' -- Use the test civicrm.org root CA
* - 'none' -- Do not perform any certificate verification.
*
* This constant is emphatically *not* exposed through Civi's "Settings"
* system (or any other runtime-editable datastore). Manipulating
* this setting can expose the system to man-in-the-middle attacks,
* and allowing runtime manipulation would create a new vector
* for escalating privileges. This setting must only be manipulated
* by developers and sysadmins who already have full privileges
* to edit the source.
*
* @return string|NULL
* The PEM-encoded root certificate. NULL if verification is disabled.
* @throws CRM_Core_Exception
*/
public static function getCACert() {
if (!defined('CIVICRM_CXN_CA') || CIVICRM_CXN_CA === 'CiviRootCA') {
$file = Constants::getCert();
}
elseif (CIVICRM_CXN_CA === 'CiviTestRootCA') {
$file = Constants::getTestCert();
}
elseif (CIVICRM_CXN_CA === 'none') {
return NULL;
}
else {
throw new \CRM_Core_Exception("CIVICRM_CXN_CA is invalid.");
}
$content = file_get_contents($file);
if (empty($content)) {
// Fail hard. Returning an empty value is not acceptable.
throw new \CRM_Core_Exception("Error loading CA certificate: $file");
}
return $content;
}
/**
* Construct a client for performing registration actions.
*
* @return \Civi\Cxn\Rpc\RegistrationClient
* @throws CRM_Core_Exception
*/
public static function createRegistrationClient() {
$cxnStore = new \CRM_Cxn_CiviCxnStore();
$viaPort = defined('CIVICRM_CXN_VIA') ? CIVICRM_CXN_VIA : NULL;
$client = new \Civi\Cxn\Rpc\RegistrationClient(
$cxnStore, \CRM_Cxn_BAO_Cxn::getSiteCallbackUrl(), $viaPort);
$client->setLog(new \CRM_Utils_SystemLogger());
$client->setCertValidator(self::createCertificateValidator());
$client->setHttp(CRM_Cxn_CiviCxnHttp::singleton());
return $client;
}
/**
* Construct a server for handling API requests.
*
* @return \Civi\Cxn\Rpc\ApiServer
*/
public static function createApiServer() {
$cxnStore = new CRM_Cxn_CiviCxnStore();
$apiServer = new \Civi\Cxn\Rpc\ApiServer($cxnStore);
$apiServer->setLog(new CRM_Utils_SystemLogger());
$apiServer->setCertValidator(self::createCertificateValidator());
$apiServer->setHttp(CRM_Cxn_CiviCxnHttp::singleton());
$apiServer->setRouter(array('CRM_Cxn_ApiRouter', 'route'));
return $apiServer;
}
/**
* @return DefaultCertificateValidator
* @throws CRM_Core_Exception
*/
public static function createCertificateValidator() {
$caCert = self::getCACert();
if ($caCert === NULL) {
return new DefaultCertificateValidator(
NULL,
NULL,
NULL,
NULL
);
}
else {
return new DefaultCertificateValidator(
$caCert,
DefaultCertificateValidator::AUTOLOAD,
DefaultCertificateValidator::AUTOLOAD,
CRM_Cxn_CiviCxnHttp::singleton()
);
}
}
}

View file

@ -0,0 +1,109 @@
<?php
/**
* Class CRM_Cxn_CiviCxnHttp
*
* This extends the PhpHttp client used by CiviConnect and adds:
* - Force-cache support for GET requests
* - Compliance with SSL policy
*/
class CRM_Cxn_CiviCxnHttp extends \Civi\Cxn\Rpc\Http\PhpHttp {
protected static $singleton = NULL;
/**
* @var CRM_Utils_Cache_Interface|null
*/
protected $cache;
/**
* @param bool $fresh
* @return CRM_Cxn_CiviCxnHttp
*/
public static function singleton($fresh = FALSE) {
if (self::$singleton === NULL || $fresh) {
$cache = CRM_Utils_Cache::create(array(
'name' => 'CiviCxnHttp',
'type' => Civi::settings()->get('debug_enabled') ? 'ArrayCache' : array('SqlGroup', 'ArrayCache'),
'prefetch' => FALSE,
));
self::$singleton = new CRM_Cxn_CiviCxnHttp($cache);
}
return self::$singleton;
}
/**
* @param CRM_Utils_Cache_Interface|NULL $cache
* The cache data store.
*/
public function __construct($cache) {
$this->cache = $cache;
}
/**
* @param string $verb
* @param string $url
* @param string $blob
* @param array $headers
* Array of headers (e.g. "Content-type" => "text/plain").
* @return array
* array($headers, $blob, $code)
*/
public function send($verb, $url, $blob, $headers = array()) {
$lowVerb = strtolower($verb);
if ($lowVerb === 'get' && $this->cache) {
$cachePath = 'get/' . md5($url);
$cacheLine = $this->cache->get($cachePath);
if ($cacheLine && $cacheLine['expires'] > CRM_Utils_Time::getTimeRaw()) {
return $cacheLine['data'];
}
}
$result = parent::send($verb, $url, $blob, $headers);
if ($lowVerb === 'get' && $this->cache) {
$expires = CRM_Utils_Http::parseExpiration($result[0]);
if ($expires !== NULL) {
$cachePath = 'get/' . md5($url);
$cacheLine = array(
'url' => $url,
'expires' => $expires,
'data' => $result,
);
$this->cache->set($cachePath, $cacheLine);
}
}
return $result;
}
/**
* Create stream options.
*
* @param string $verb
* @param string $url
* @param string $blob
* @param array $headers
*
* @return array
* @throws \Exception
*/
protected function createStreamOpts($verb, $url, $blob, $headers) {
$result = parent::createStreamOpts($verb, $url, $blob, $headers);
$caConfig = CA_Config_Stream::probe(array(
'verify_peer' => (bool) Civi::settings()->get('verifySSL'),
));
if ($caConfig->isEnableSSL()) {
$result['ssl'] = $caConfig->toStreamOptions();
}
if (!$caConfig->isEnableSSL() && preg_match('/^https:/', $url)) {
CRM_Core_Error::fatal('Cannot fetch document - system does not support SSL');
}
return $result;
}
}

View file

@ -0,0 +1,123 @@
<?php
/**
* Class CRM_Cxn_CiviCxnStore
*/
class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface {
protected $cxns = array();
/**
* @inheritDoc
*/
public function getAll() {
if (!$this->cxns) {
$this->cxns = array();
$dao = new CRM_Cxn_DAO_Cxn();
$dao->find();
while ($dao->fetch()) {
$cxn = $this->convertDaoToCxn($dao);
$this->cxns[$cxn['cxnId']] = $cxn;
}
}
return $this->cxns;
}
/**
* @inheritDoc
*/
public function getByCxnId($cxnId) {
if (isset($this->cxns[$cxnId])) {
return $this->cxns[$cxnId];
}
$dao = new CRM_Cxn_DAO_Cxn();
$dao->cxn_guid = $cxnId;
if ($dao->find(TRUE)) {
$this->cxns[$cxnId] = $this->convertDaoToCxn($dao);
return $this->cxns[$cxnId];
}
else {
return NULL;
}
}
/**
* @inheritDoc
*/
public function getByAppId($appId) {
$dao = new CRM_Cxn_DAO_Cxn();
$dao->app_guid = $appId;
if ($dao->find(TRUE)) {
$this->cxns[$dao->cxn_guid] = $this->convertDaoToCxn($dao);
return $this->cxns[$dao->cxn_guid];
}
else {
return NULL;
}
}
/**
* @inheritDoc
*/
public function add($cxn) {
$dao = new CRM_Cxn_DAO_Cxn();
$dao->cxn_guid = $cxn['cxnId'];
$dao->find(TRUE);
$this->convertCxnToDao($cxn, $dao);
$dao->save();
$sql = '
UPDATE civicrm_cxn SET created_date = modified_date
WHERE created_date IS NULL
AND cxn_guid = %1
';
CRM_Core_DAO::executeQuery($sql, array(
1 => array($cxn['cxnId'], 'String'),
));
$this->cxns[$cxn['cxnId']] = $cxn;
}
/**
* @inheritDoc
*/
public function remove($cxnId) {
CRM_Core_DAO::executeQuery('DELETE FROM civicrm_cxn WHERE cxn_guid = %1', array(
1 => array($cxnId, 'String'),
));
unset($this->cxns[$cxnId]);
}
/**
* @param CRM_Cxn_DAO_Cxn $dao
* @return array
* Array-encoded connection details.
*/
protected function convertDaoToCxn($dao) {
$appMeta = json_decode($dao->app_meta, TRUE);
return array(
'cxnId' => $dao->cxn_guid,
'secret' => $dao->secret,
'appId' => $dao->app_guid,
'appUrl' => $appMeta['appUrl'],
'siteUrl' => CRM_Cxn_BAO_Cxn::getSiteCallbackUrl(),
'perm' => json_decode($dao->perm, TRUE),
);
}
/**
* @param array $cxn
* Array-encoded connection details.
* @param CRM_Cxn_DAO_Cxn $dao
*/
protected function convertCxnToDao($cxn, $dao) {
$dao->cxn_guid = $cxn['cxnId'];
$dao->secret = $cxn['secret'];
$dao->app_guid = $cxn['appId'];
$dao->perm = json_encode($cxn['perm']);
// Note: we don't save siteUrl because it's more correct to regenerate on-demand.
// Note: we don't save appUrl, but other processes will update appMeta.
}
}

View file

@ -0,0 +1,337 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*
* Generated from xml/schema/CRM/Cxn/Cxn.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:7837c80596c2e6d8682a48cffcb6a4d3)
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
/**
* CRM_Cxn_DAO_Cxn constructor.
*/
class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
/**
* Static instance to hold the table name.
*
* @var string
*/
static $_tableName = 'civicrm_cxn';
/**
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
* @var boolean
*/
static $_log = false;
/**
* Connection ID
*
* @var int unsigned
*/
public $id;
/**
* Application GUID
*
* @var string
*/
public $app_guid;
/**
* Application Metadata (JSON)
*
* @var text
*/
public $app_meta;
/**
* Connection GUID
*
* @var string
*/
public $cxn_guid;
/**
* Shared secret
*
* @var text
*/
public $secret;
/**
* Permissions approved for the service (JSON)
*
* @var text
*/
public $perm;
/**
* Options for the service (JSON)
*
* @var text
*/
public $options;
/**
* Is connection currently enabled?
*
* @var boolean
*/
public $is_active;
/**
* When was the connection was created.
*
* @var timestamp
*/
public $created_date;
/**
* When the connection was created or modified.
*
* @var timestamp
*/
public $modified_date;
/**
* The last time the application metadata was fetched.
*
* @var timestamp
*/
public $fetched_date;
/**
* Class constructor.
*/
function __construct() {
$this->__table = 'civicrm_cxn';
parent::__construct();
}
/**
* Returns all the column names of this table
*
* @return array
*/
static function &fields() {
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
Civi::$statics[__CLASS__]['fields'] = array(
'id' => array(
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Connection ID') ,
'description' => 'Connection ID',
'required' => true,
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'app_guid' => array(
'name' => 'app_guid',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Application GUID') ,
'description' => 'Application GUID',
'maxlength' => 128,
'size' => CRM_Utils_Type::HUGE,
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'app_meta' => array(
'name' => 'app_meta',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Application Metadata (JSON)') ,
'description' => 'Application Metadata (JSON)',
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'cxn_guid' => array(
'name' => 'cxn_guid',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Connection GUID') ,
'description' => 'Connection GUID',
'maxlength' => 128,
'size' => CRM_Utils_Type::HUGE,
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'secret' => array(
'name' => 'secret',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Secret') ,
'description' => 'Shared secret',
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'perm' => array(
'name' => 'perm',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Perm') ,
'description' => 'Permissions approved for the service (JSON)',
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'options' => array(
'name' => 'options',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Options') ,
'description' => 'Options for the service (JSON)',
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'is_active' => array(
'name' => 'is_active',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => ts('Is Active') ,
'description' => 'Is connection currently enabled?',
'default' => '1',
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'created_date' => array(
'name' => 'created_date',
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => ts('Created Date') ,
'description' => 'When was the connection was created.',
'required' => false,
'default' => 'NULL',
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'modified_date' => array(
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => ts('Modified Date') ,
'description' => 'When the connection was created or modified.',
'required' => false,
'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
'fetched_date' => array(
'name' => 'fetched_date',
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => ts('Fetched Date') ,
'description' => 'The last time the application metadata was fetched.',
'required' => false,
'default' => 'NULL',
'table_name' => 'civicrm_cxn',
'entity' => 'Cxn',
'bao' => 'CRM_Cxn_BAO_Cxn',
'localizable' => 0,
) ,
);
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
return Civi::$statics[__CLASS__]['fields'];
}
/**
* Return a mapping from field-name to the corresponding key (as used in fields()).
*
* @return array
* Array(string $name => string $uniqueName).
*/
static function &fieldKeys() {
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
}
return Civi::$statics[__CLASS__]['fieldKeys'];
}
/**
* Returns the names of this table
*
* @return string
*/
static function getTableName() {
return self::$_tableName;
}
/**
* Returns if this table needs to be logged
*
* @return boolean
*/
function getLog() {
return self::$_log;
}
/**
* Returns the list of fields that can be imported
*
* @param bool $prefix
*
* @return array
*/
static function &import($prefix = false) {
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'cxn', $prefix, array());
return $r;
}
/**
* Returns the list of fields that can be exported
*
* @param bool $prefix
*
* @return array
*/
static function &export($prefix = false) {
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'cxn', $prefix, array());
return $r;
}
/**
* Returns the list of indices
*/
public static function indices($localize = TRUE) {
$indices = array(
'UI_appid' => array(
'name' => 'UI_appid',
'field' => array(
0 => 'app_guid',
) ,
'localizable' => false,
'unique' => true,
'sig' => 'civicrm_cxn::1::app_guid',
) ,
'UI_keypair_cxnid' => array(
'name' => 'UI_keypair_cxnid',
'field' => array(
0 => 'cxn_guid',
) ,
'localizable' => false,
'unique' => true,
'sig' => 'civicrm_cxn::1::cxn_guid',
) ,
);
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
}