本文整理汇总了PHP中CRM_Core_DAO_AllCoreTables类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_AllCoreTables类的具体用法?PHP CRM_Core_DAO_AllCoreTables怎么用?PHP CRM_Core_DAO_AllCoreTables使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_DAO_AllCoreTables类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:36,代码来源:Api.php
示例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;
}
开发者ID:GuGuss,项目名称:civicrm-core,代码行数:12,代码来源:DAOConformanceTest.php
示例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;
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:14,代码来源:DAOConformanceTest.php
示例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;
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:21,代码来源:Dynamic.php
示例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;
}
开发者ID:kidaa30,项目名称:yes,代码行数:45,代码来源:Api.php
示例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;
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:12,代码来源:ParticipantPayment.php
示例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));
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:10,代码来源:api.php
示例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());
}
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:26,代码来源:Generic.php
示例9: tearDown
protected function tearDown()
{
CRM_Utils_Hook::singleton()->reset();
CRM_Core_DAO_AllCoreTables::init(1);
parent::tearDown();
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:6,代码来源:AllCoreTablesTest.php
示例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();
}
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:22,代码来源:Invoke.php
示例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;
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:28,代码来源:DAO.php
示例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);
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:38,代码来源:RecurringEntity.php
示例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;
}
开发者ID:konadave,项目名称:civicrm-core,代码行数:31,代码来源:DAO.php
示例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);
}
开发者ID:Prem-Patel,项目名称:civicrm-core,代码行数:72,代码来源:SelectQuery.php
示例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;
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:22,代码来源:PseudoConstant.php
示例16: handlePrimary
/**
* Handling for is_primary.
* $params is_primary could be
* # 1 - find other entries with is_primary = 1 & reset them to 0
* # 0 - make sure at least one entry is set to 1
* - if no other entry is 1 change to 1
* - if one other entry exists change that to 1
* - if more than one other entry exists change first one to 1
* @fixme - perhaps should choose by location_type
* # empty - same as 0 as once we have checked first step
* we know if it should be 1 or 0
*
* if $params['id'] is set $params['contact_id'] may need to be retrieved
*
* @param array $params
* @static
*/
public static function handlePrimary(&$params, $class)
{
$table = CRM_Core_DAO_AllCoreTables::getTableForClass($class);
if (!$table) {
throw new API_Exception("Failed to locate table for class [{$class}]");
}
// contact_id in params might be empty or the string 'null' so cast to integer
$contactId = (int) CRM_Utils_Array::value('contact_id', $params);
// If id is set & we haven't been passed a contact_id, retrieve it
if (!empty($params['id']) && !isset($params['contact_id'])) {
$entity = new $class();
$entity->id = $params['id'];
$entity->find(TRUE);
$contactId = $entity->contact_id;
}
// If entity is not associated with contact, concept of is_primary not relevant
if (!$contactId) {
return;
}
// if params is_primary then set all others to not be primary & exit out
if (!empty($params['is_primary'])) {
$sql = "UPDATE {$table} SET is_primary = 0 WHERE contact_id = %1";
$sqlParams = array(1 => array($contactId, 'Integer'));
// we don't want to create unecessary entries in the log_ tables so exclude the one we are working on
if (!empty($params['id'])) {
$sql .= " AND id <> %2";
$sqlParams[2] = array($params['id'], 'Integer');
}
CRM_Core_DAO::executeQuery($sql, $sqlParams);
return;
}
//Check what other emails exist for the contact
$existingEntities = new $class();
$existingEntities->contact_id = $contactId;
$existingEntities->orderBy('is_primary DESC');
if (!$existingEntities->find(TRUE) || !empty($params['id']) && $existingEntities->id == $params['id']) {
// ie. if no others is set to be primary then this has to be primary set to 1 so change
$params['is_primary'] = 1;
return;
} else {
/*
* If the only existing email is the one we are editing then we must set
* is_primary to 1
* CRM-10451
*/
if ($existingEntities->N == 1 && $existingEntities->id == CRM_Utils_Array::value('id', $params)) {
$params['is_primary'] = 1;
return;
}
if ($existingEntities->is_primary == 1) {
return;
}
// so at this point we are only dealing with ones explicity setting is_primary to 0
// since we have reverse sorted by email we can either set the first one to
// primary or return if is already is
$existingEntities->is_primary = 1;
$existingEntities->save();
}
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:76,代码来源:Block.php
示例17: setEntityRefDefaults
/**
* Apply common settings to entityRef fields.
*
* @param array $field
* @param string $table
*/
private function setEntityRefDefaults(&$field, $table)
{
$field['attributes'] = $field['attributes'] ? $field['attributes'] : array();
$field['attributes'] += array('entity' => CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($table)), 'multiple' => TRUE, 'placeholder' => ts('- select -'));
}
开发者ID:konadave,项目名称:civicrm-core,代码行数:11,代码来源:Form.php
示例18: create
/**
* Takes an associative array and creates a custom group object.
*
* This function is invoked from within the web form layer and also from the api layer
*
* @param array $params
* (reference) an assoc array of name/value pairs.
*
* @return CRM_Core_DAO_CustomGroup
*/
public static function create(&$params)
{
// create custom group dao, populate fields and then save.
$group = new CRM_Core_DAO_CustomGroup();
if (isset($params['title'])) {
$group->title = $params['title'];
}
if (in_array($params['extends'][0], array('ParticipantRole', 'ParticipantEventName', 'ParticipantEventType'))) {
$group->extends = 'Participant';
} else {
$group->extends = $params['extends'][0];
}
$group->extends_entity_column_id = 'null';
if ($params['extends'][0] == 'ParticipantRole' || $params['extends'][0] == 'ParticipantEventName' || $params['extends'][0] == 'ParticipantEventType') {
$group->extends_entity_column_id = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $params['extends'][0], 'value', 'name');
}
//this is format when form get submit.
$extendsChildType = CRM_Utils_Array::value(1, $params['extends']);
//lets allow user to pass direct child type value, CRM-6893
if (!empty($params['extends_entity_column_value'])) {
$extendsChildType = $params['extends_entity_column_value'];
}
if (!CRM_Utils_System::isNull($extendsChildType)) {
$extendsChildType = implode(CRM_Core_DAO::VALUE_SEPARATOR, $extendsChildType);
if (CRM_Utils_Array::value(0, $params['extends']) == 'Relationship') {
$extendsChildType = str_replace(array('_a_b', '_b_a'), array('', ''), $extendsChildType);
}
if (substr($extendsChildType, 0, 1) != CRM_Core_DAO::VALUE_SEPARATOR) {
$extendsChildType = CRM_Core_DAO::VALUE_SEPARATOR . $extendsChildType . CRM_Core_DAO::VALUE_SEPARATOR;
}
} else {
$extendsChildType = 'null';
}
$group->extends_entity_column_value = $extendsChildType;
if (isset($params['id'])) {
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'weight', 'id');
} else {
$oldWeight = 0;
}
$group->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomGroup', $oldWeight, CRM_Utils_Array::value('weight', $params, FALSE));
$fields = array('style', 'collapse_display', 'collapse_adv_display', 'help_pre', 'help_post', 'is_active', 'is_multiple');
foreach ($fields as $field) {
if (isset($params[$field]) || $field == 'is_multiple') {
$group->{$field} = CRM_Utils_Array::value($field, $params, FALSE);
}
}
$group->max_multiple = isset($params['is_multiple']) ? isset($params['max_multiple']) && $params['max_multiple'] >= '0' ? $params['max_multiple'] : 'null' : 'null';
$tableName = $oldTableName = NULL;
if (isset($params['id'])) {
$group->id = $params['id'];
//check whether custom group was changed from single-valued to multiple-valued
$isMultiple = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'is_multiple');
if ((!empty($params['is_multiple']) || $isMultiple) && $params['is_multiple'] != $isMultiple) {
$oldTableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $params['id'], 'table_name');
}
} else {
$group->created_id = CRM_Utils_Array::value('created_id', $params);
$group->created_date = CRM_Utils_Array::value('created_date', $params);
// we do this only once, so name never changes
if (isset($params['name'])) {
$group->name = CRM_Utils_String::munge($params['name'], '_', 64);
} else {
$group->name = CRM_Utils_String::munge($group->title, '_', 64);
}
if (isset($params['table_name'])) {
$tableName = $params['table_name'];
if (CRM_Core_DAO_AllCoreTables::isCoreTable($tableName)) {
// Bad idea. Prevent group creation because it might lead to a broken configuration.
CRM_Core_Error::fatal(ts("Cannot create custom table because %1 is already a core table.", array('1' => $tableName)));
}
}
}
if (array_key_exists('is_reserved', $params)) {
$group->is_reserved = $params['is_reserved'] ? 1 : 0;
}
$op = isset($params['id']) ? 'edit' : 'create';
CRM_Utils_Hook::pre($op, 'CustomGroup', CRM_Utils_Array::value('id', $params), $params);
// enclose the below in a transaction
$transaction = new CRM_Core_Transaction();
$group->save();
if (!isset($params['id'])) {
if (!isset($params['table_name'])) {
$munged_title = strtolower(CRM_Utils_String::munge($group->title, '_', 42));
$tableName = "civicrm_value_{$munged_title}_{$group->id}";
}
$group->table_name = $tableName;
CRM_Core_DAO::setFieldValue('CRM_Core_DAO_CustomGroup', $group->id, 'table_name', $tableName);
// now create the table associated with this group
self::createTable($group);
} elseif ($oldTableName) {
//.........这里部分代码省略.........
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:101,代码来源:CustomGroup.php
示例19: createDefaultCrudLink
/**
* Determine the standard URL for viewing or editing the specified link.
*
* This function delegates the decision-making to (a) the hook system and
* (b) the BAO system.
*
* @param array $crudLinkSpec
* With keys:.
* - action: int, CRM_Core_Action::UPDATE or CRM_Core_Action::VIEW [default: VIEW]
* - entity_table: string, eg "civicrm_contact"
* - entity_id: int
* @return array|NULL
* NULL if unavailable, or an array. array has keys:
* - path: string
* - query: array
* - title: string
* - url: string
*/
public static function createDefaultCrudLink($crudLinkSpec)
{
$crudLinkSpec['action'] = CRM_Utils_Array::value('action', $crudLinkSpec, CRM_Core_Action::VIEW);
$daoClass = CRM_Core_DAO_AllCoreTables::getClassForTable($crudLinkSpec['entity_table']);
if (!$daoClass) {
return NULL;
}
$baoClass = str_replace('_DAO_', '_BAO_', $daoClass);
if (!class_exists($baoClass)) {
return NULL;
}
$bao = new $baoClass();
$bao->id = $crudLinkSpec['entity_id'];
if (!$bao->find(TRUE)) {
return NULL;
}
$link = array();
CRM_Utils_Hook::crudLink($crudLinkSpec, $bao, $link);
if (empty($link) && is_callable(array($bao, 'createDefaultCrudLink'))) {
$link = $bao->createDefaultCrudLink($crudLinkSpec);
}
if (!empty($link)) {
if (!isset($link['url'])) {
$link['url'] = self::url($link['path'], $link['query'], TRUE, NULL, FALSE);
}
return $link;
}
return NULL;
}
开发者ID:rollox,项目名称:civicrm-core,代码行数:47,代码来源:System.php
示例20: rebuildMenuAndCaches
/**
* @param bool $triggerRebuild
* @param bool $sessionReset
*
* @throws Exception
*/
public 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();
// rebuild word replacement cache - pass false to prevent operations redundant with this fn
CRM_Core_BAO_WordReplacement::rebuild(FALSE);
Civi::service('settings_manager')->flush();
// Clear js caches
CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode();
CRM_Case_XMLRepository::singleton(TRUE);
// 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();
//CRM-16257 update Config.IDS.ini might be an old copy
CRM_Core_IDS::createConfigFile(TRUE);
}
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:32,代码来源:Invoke.php
注:本文中的CRM_Core_DAO_AllCoreTables类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论