本文整理汇总了PHP中CRM_Core_DAO_AllCoreTables类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_AllCoreTables类的具体用法?PHP CRM_Core_DAO_AllCoreTables怎么用?PHP CRM_Core_DAO_AllCoreTables使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_DAO_AllCoreTables类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEntityName
/**
* Attempts to retrieve the API entity name from any calling class.
*
* @param string|object $classNameOrObject
*
* @return string
* @throws CRM_Core_Exception
*/
static function getEntityName($classNameOrObject)
{
require_once 'api/api.php';
$className = is_string($classNameOrObject) ? $classNameOrObject : get_class($classNameOrObject);
// First try the obvious replacements
$daoName = str_replace(array('_BAO_', '_Form_', '_Page_'), '_DAO_', $className);
$shortName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
// If that didn't work, try a different pattern
if (!$shortName) {
list(, $parent, , $child) = explode('_', $className);
$daoName = "CRM_{$parent}_DAO_{$child}";
$shortName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
}
// If that didn't work, try a different pattern
if (!$shortName) {
$daoName = "CRM_{$parent}_DAO_{$parent}";
$shortName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
}
// If that didn't work, try a different pattern
if (!$shortName) {
$daoName = "CRM_Core_DAO_{$child}";
$shortName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
}
if (!$shortName) {
throw new CRM_Core_Exception('Could not find api name for supplied class');
}
return _civicrm_api_get_entity_name_from_camel($shortName);
}
示例2: getAllDAO
/**
* Get all DAO classes.
*/
public function getAllDAO()
{
$classList = CRM_Core_DAO_AllCoreTables::getClasses();
$return = array();
foreach ($classList as $class) {
$return[] = array($class);
}
return $return;
}
示例3: getAllDAO
/**
* Get all DAO classes.
*/
public function getAllDAO()
{
$this->setUp();
// Ugh. Need full bootstrap to enumerate classes.
$classList = CRM_Core_DAO_AllCoreTables::getClasses();
$return = array();
foreach ($classList as $class) {
$return[] = array($class);
}
return $return;
}
示例4: findReferences
/**
* Create a query to find references to a particular record
*
* @param CRM_Core_DAO $targetDao the instance for which we want references
* @return CRM_Core_DAO a query-handle (like the result of CRM_Core_DAO::executeQuery)
*/
public function findReferences($targetDao)
{
$refColumn = $this->getReferenceKey();
$targetColumn = $this->getTargetKey();
$params = array(1 => array($targetDao->{$targetColumn}, 'String'), 2 => array($targetDao::getTableName(), 'String'));
$sql = <<<EOS
SELECT id
FROM {$this->getReferenceTable()}
WHERE {$refColumn} = %1
AND {$this->getTypeColumn()} = %2
EOS;
$daoName = CRM_Core_DAO_AllCoreTables::getClassForTable($this->getReferenceTable());
$result = CRM_Core_DAO::executeQuery($sql, $params, TRUE, $daoName);
return $result;
}
示例5: getEntityName
/**
* Attempts to retrieve the API entity name from any calling class.
* FIXME: This is a bit hackish but the naming convention for forms is not very strict
*
* @param string|object $classNameOrObject
*
* @return string
* @throws CRM_Core_Exception
*/
public static function getEntityName($classNameOrObject)
{
require_once 'api/api.php';
$className = is_string($classNameOrObject) ? $classNameOrObject : get_class($classNameOrObject);
// First try the obvious replacements
$daoName = str_replace(array('_BAO_', '_Form_', '_Page_'), '_DAO_', $className);
$entityName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
// If that didn't work, try a different pattern
if (!$entityName) {
list(, $parent, , $child) = explode('_', $className);
$daoName = "CRM_{$parent}_DAO_{$child}";
$entityName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
}
// If that didn't work, try a different pattern
if (!$entityName) {
$daoName = "CRM_{$parent}_DAO_{$parent}";
$entityName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
}
// If that didn't work, try a different pattern
if (!$entityName) {
$daoName = "CRM_Core_DAO_{$child}";
$entityName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
}
// If that didn't work, try using just the trailing name
if (!$entityName) {
$entityName = CRM_Core_DAO_AllCoreTables::getFullName($child) ? $child : NULL;
}
// If that didn't work, try using just the leading name
if (!$entityName) {
$entityName = CRM_Core_DAO_AllCoreTables::getFullName($parent) ? $parent : NULL;
}
if (!$entityName) {
throw new CRM_Core_Exception('Could not find api name for supplied class');
}
return $entityName;
}
示例6: array
/**
* 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__, 'participant_payment', $prefix, array());
return $r;
}
示例7: _civicrm_api_get_entity_name_from_dao
/**
* Having a DAO object find the entity name
* @param object $bao DAO being passed in
* @return string
*/
function _civicrm_api_get_entity_name_from_dao($bao)
{
$daoName = str_replace("BAO", "DAO", get_class($bao));
return _civicrm_api_get_entity_name_from_camel(CRM_Core_DAO_AllCoreTables::getBriefName($daoName));
}
示例8: civicrm_api3_generic_getrefcount
/**
* API to determine if a record is in-use.
*
* @param array $apiRequest
* Api request as an array.
*
* @throws API_Exception
* @return array
* API result (int 0 or 1)
*/
function civicrm_api3_generic_getrefcount($apiRequest)
{
$entityToClassMap = CRM_Core_DAO_AllCoreTables::daoToClass();
if (!isset($entityToClassMap[$apiRequest['entity']])) {
throw new API_Exception("The entity '{$apiRequest['entity']}' is unknown or unsupported by 'getrefcount'. Consider implementing this API.", 'getrefcount_unsupported');
}
$daoClass = $entityToClassMap[$apiRequest['entity']];
/* @var $dao CRM_Core_DAO */
$dao = new $daoClass();
$dao->id = $apiRequest['params']['id'];
if ($dao->find(TRUE)) {
return civicrm_api3_create_success($dao->getReferenceCounts());
} else {
return civicrm_api3_create_success(array());
}
}
示例9: tearDown
protected function tearDown()
{
CRM_Utils_Hook::singleton()->reset();
CRM_Core_DAO_AllCoreTables::init(1);
parent::tearDown();
}
示例10: rebuildMenuAndCaches
static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE)
{
$config = CRM_Core_Config::singleton();
$config->clearModuleList();
// also cleanup all caches
$config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
CRM_Core_Menu::store();
// also reset navigation
CRM_Core_BAO_Navigation::resetNavigation();
// also cleanup module permissions
$config->cleanupPermissions();
// also rebuild word replacement cache
CRM_Core_BAO_WordReplacement::rebuild();
CRM_Core_BAO_Setting::updateSettingsFromMetaData();
CRM_Core_Resources::singleton()->resetCacheCode();
// also rebuild triggers if requested explicitly
if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) {
CRM_Core_DAO::triggerRebuild();
}
CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
}
示例11: getReferencesToTable
/**
* List all tables which have hard foreign keys to this table.
*
* For now, this returns a description of every entity_id/entity_table
* reference.
* TODO: filter dynamic entity references on the $tableName, based on
* schema metadata in dynamicForeignKey which enumerates a restricted
* set of possible entity_table's.
*
* @param string $tableName table referred to
*
* @return array structure of table and column, listing every table with a
* foreign key reference to $tableName, and the column where the key appears.
*/
static function getReferencesToTable($tableName)
{
$refsFound = array();
foreach (CRM_Core_DAO_AllCoreTables::getClasses() as $daoClassName) {
$links = $daoClassName::getReferenceColumns();
$daoTableName = $daoClassName::getTableName();
foreach ($links as $refSpec) {
if ($refSpec->getTargetTable() === $tableName or $refSpec->isGeneric()) {
$refsFound[] = $refSpec;
}
}
}
return $refsFound;
}
示例12: preProcess
/**
* @param $entityTable
*/
public static function preProcess($entityTable)
{
self::$_entityId = (int) CRM_Utils_Request::retrieve('id', 'Positive');
self::$_entityTable = $entityTable;
if (self::$_entityId && $entityTable) {
$checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor(self::$_entityId, $entityTable);
if ($checkParentExistsForThisId) {
self::$_hasParent = TRUE;
self::$_parentEntityId = $checkParentExistsForThisId;
self::$_scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $entityTable);
} else {
self::$_parentEntityId = self::$_entityId;
self::$_scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId(self::$_entityId, $entityTable);
}
if (property_exists(self::$_scheduleReminderDetails, 'id')) {
self::$_scheduleReminderID = self::$_scheduleReminderDetails->id;
}
}
CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue);
$excludeOptionValues = array();
if (!empty($optionValue)) {
foreach ($optionValue as $key => $val) {
$excludeOptionValues[$val['value']] = substr(CRM_Utils_Date::mysqlToIso($val['value']), 0, 10);
}
self::$_excludeDateInfo = $excludeOptionValues;
}
// Assign variables
$entityType = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($entityTable));
$tpl = CRM_Core_Smarty::singleton();
$tpl->assign('recurringEntityType', ts($entityType));
$tpl->assign('currentEntityId', self::$_entityId);
$tpl->assign('entityTable', self::$_entityTable);
$tpl->assign('scheduleReminderId', self::$_scheduleReminderID);
$tpl->assign('hasParent', self::$_hasParent);
}
示例13: getReferencesToTable
/**
* List all tables which have hard foreign keys to this table.
*
* For now, this returns a description of every entity_id/entity_table
* reference.
* TODO: filter dynamic entity references on the $tableName, based on
* schema metadata in dynamicForeignKey which enumerates a restricted
* set of possible entity_table's.
*
* @param string $tableName
* Table referred to.
*
* @return array
* structure of table and column, listing every table with a
* foreign key reference to $tableName, and the column where the key appears.
*/
public static function getReferencesToTable($tableName)
{
$refsFound = array();
foreach (CRM_Core_DAO_AllCoreTables::getClasses() as $daoClassName) {
$links = $daoClassName::getReferenceColumns();
$daoTableName = $daoClassName::getTableName();
foreach ($links as $refSpec) {
/** @var $refSpec CRM_Core_Reference_Interface */
if ($refSpec->matchesTargetTable($tableName)) {
$refsFound[] = $refSpec;
}
}
}
return $refsFound;
}
示例14: addFkField
/**
* Joins onto an fk field
*
* Adds one or more joins to the query to make this field available for use in a clause.
*
* Enforces permissions at the api level and by appending the acl clause for that entity to the join.
*
* @param $fkFieldName
* @return array|null
* Returns the table and field name for adding this field to a SELECT or WHERE clause
* @throws \API_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
private function addFkField($fkFieldName)
{
$stack = explode('.', $fkFieldName);
if (count($stack) < 2) {
return NULL;
}
$prev = 'a';
foreach ($stack as $depth => $fieldName) {
// Setup variables then skip the first level
if (!$depth) {
$fk = $fieldName;
// We only join on core fields
// @TODO: Custom contact ref fields could be supported too
if (!in_array($fk, $this->entityFieldNames)) {
return NULL;
}
$fkField =& $this->apiFieldSpec[$fk];
continue;
}
// More than 4 joins deep seems excessive - DOS attack?
if ($depth > self::MAX_JOINS) {
throw new UnauthorizedException("Maximum number of joins exceeded for api.{$this->entity}.get in parameter {$fkFieldName}");
}
if (!isset($fkField['FKApiName']) && !isset($fkField['FKClassName'])) {
// Join doesn't exist - might be another param with a dot in it for some reason, we'll just ignore it.
return NULL;
}
// Ensure we have permission to access the other api
if (!$this->checkPermissionToJoin($fkField['FKApiName'], array_slice($stack, 0, $depth))) {
throw new UnauthorizedException("Authorization failed to join onto {$fkField['FKApiName']} api in parameter {$fkFieldName}");
}
if (!isset($fkField['FKApiSpec'])) {
$fkField['FKApiSpec'] = \_civicrm_api_get_fields($fkField['FKApiName']);
}
$fieldInfo = \CRM_Utils_Array::value($fieldName, $fkField['FKApiSpec']);
// FIXME: What if the foreign key is not the "id" column?
if (!$fieldInfo || !isset($fkField['FKApiSpec']['id'])) {
// Join doesn't exist - might be another param with a dot in it for some reason, we'll just ignore it.
return NULL;
}
$fkTable = \CRM_Core_DAO_AllCoreTables::getTableForClass($fkField['FKClassName']);
$tableAlias = implode('_to_', array_slice($stack, 0, $depth)) . "_to_{$fkTable}";
$joinClause = "LEFT JOIN {$fkTable} {$tableAlias} ON {$prev}.{$fk} = {$tableAlias}.id";
// Add acl condition
$joinCondition = $this->getAclClause($tableAlias, $fkField['FKClassName']);
if ($joinCondition !== NULL) {
$joinClause .= " AND {$joinCondition}";
}
$this->query->join($tableAlias, $joinClause);
if (strpos($fieldName, 'custom_') === 0) {
list($tableAlias, $fieldName) = $this->addCustomField($fieldInfo, $tableAlias);
}
// Get ready to recurse to the next level
$fk = $fieldName;
$fkField =& $fkField['FKApiSpec'][$fieldName];
$prev = $tableAlias;
}
return array($tableAlias, $fieldName);
}
示例15: getOptionEditUrl
/**
* Lookup the admin page at which a field's option list can be edited
* @param $fieldSpec
* @return string|null
*/
static function getOptionEditUrl($fieldSpec)
{
// If it's an option group, that's easy
if (!empty($fieldSpec['pseudoconstant']['optionGroupName'])) {
return 'civicrm/admin/options/' . $fieldSpec['pseudoconstant']['optionGroupName'];
} elseif (!empty($fieldSpec['pseudoconstant']['table'])) {
$daoName = CRM_Core_DAO_AllCoreTables::getClassForTable($fieldSpec['pseudoconstant']['table']);
if (!$daoName) {
return NULL;
}
// We don't have good mapping so have to do a bit of guesswork from the menu
list(, $parent, , $child) = explode('_', $daoName);
$sql = "SELECT path FROM civicrm_menu\n WHERE page_callback LIKE '%CRM_Admin_Page_{$child}%' OR page_callback LIKE '%CRM_{$parent}_Page_{$child}%'\n ORDER BY page_callback\n LIMIT 1";
return CRM_Core_Dao::singleValueQuery($sql);
}
return NULL;
}