diff --git a/CRM/Core/BAO/SchemaHandler.php b/CRM/Core/BAO/SchemaHandler.php index 99499b6be739..80a2255d98e4 100644 --- a/CRM/Core/BAO/SchemaHandler.php +++ b/CRM/Core/BAO/SchemaHandler.php @@ -39,6 +39,8 @@ */ class CRM_Core_BAO_SchemaHandler { + const DEFAULT_COLLATION = 'utf8mb4_unicode_ci'; + /** * Create a CiviCRM-table * @@ -899,7 +901,7 @@ public static function getInUseCollation(): string { if (!isset(\Civi::$statics[__CLASS__][__FUNCTION__])) { $dao = CRM_Core_DAO::executeQuery('SHOW TABLE STATUS LIKE \'civicrm_contact\''); $dao->fetch(); - \Civi::$statics[__CLASS__][__FUNCTION__] = $dao->Collation; + \Civi::$statics[__CLASS__][__FUNCTION__] = $dao->Collation ?? self::DEFAULT_COLLATION; } return \Civi::$statics[__CLASS__][__FUNCTION__]; } diff --git a/CRM/Core/CRM/Core/DAO/Base.php b/CRM/Core/CRM/Core/DAO/Base.php new file mode 100644 index 000000000000..13b13a4e2240 --- /dev/null +++ b/CRM/Core/CRM/Core/DAO/Base.php @@ -0,0 +1,263 @@ + $field) { + if (!empty($field['primary_key'])) { + $keys[] = $name; + } + } + return $keys; + } + + public static function getEntityTitle($plural = FALSE) { + $info = static::getEntityInfo(); + return ($plural && isset($info['title_plural'])) ? $info['title_plural'] : $info['title']; + } + + /** + * @inheritDoc + */ + public static function getEntityPaths(): array { + $definition = static::getEntityDefinition(); + if (isset($definition['getPaths'])) { + return $definition['getPaths'](); + } + return []; + } + + /** + * @inheritDoc + */ + public static function getEntityDescription(): ?string { + return static::getEntityInfo()['description'] ?? NULL; + } + + /** + * @inheritDoc + */ + public static function getTableName() { + return static::getEntityDefinition()['table']; + } + + /** + * @inheritDoc + */ + public function getLog(): bool { + return static::getEntityInfo()['log'] ?? FALSE; + } + + /** + * @inheritDoc + */ + public static function getEntityIcon(string $entityName, int $entityId = NULL): ?string { + return static::getEntityInfo()['icon'] ?? NULL; + } + + /** + * @inheritDoc + */ + protected static function getTableAddVersion(): string { + return static::getEntityInfo()['add'] ?? '1.0'; + } + + /** + * @inheritDoc + */ + public static function getExtensionName(): ?string { + return static::getEntityDefinition()['module']; + } + + /** + * @inheritDoc + */ + public static function &fields() { + $fields = []; + foreach (static::getSchemaFields() as $field) { + $key = $field['uniqueName'] ?? $field['name']; + unset($field['uniqueName']); + $fields[$key] = $field; + } + return $fields; + } + + private static function getSchemaFields(): array { + return (Civi::$statics[static::class]['fields'] ??= static::loadSchemaFields()); + } + + private static function loadSchemaFields(): array { + $fields = []; + $entityDef = static::getEntityDefinition(); + $baoName = CRM_Core_DAO_AllCoreTables::getBAOClassName(static::class); + + foreach ($entityDef['getFields']() as $fieldName => $fieldSpec) { + $field = [ + 'name' => $fieldName, + 'type' => !empty($fieldSpec['data_type']) ? \CRM_Utils_Type::getValidTypes()[$fieldSpec['data_type']] : constant(\CRM_Utils_Schema::getCrmTypeFromSqlType($fieldSpec['sql_type'])), + 'title' => $fieldSpec['title'], + 'description' => $fieldSpec['description'] ?? NULL, + ]; + if (!empty($fieldSpec['required'])) { + $field['required'] = TRUE; + } + if (str_starts_with($fieldSpec['sql_type'], 'decimal(')) { + $precision = self::getFieldLength($fieldSpec['sql_type']); + $field['precision'] = explode(',', $precision); + } + foreach (['maxlength', 'size', 'rows', 'cols'] as $attr) { + if (isset($fieldSpec['input_attrs'][$attr])) { + $field[$attr] = $fieldSpec['input_attrs'][$attr]; + unset($fieldSpec['input_attrs'][$attr]); + } + } + if (!isset($field['size']) && str_contains($fieldSpec['sql_type'], 'char')) { + $length = self::getFieldLength($fieldSpec['sql_type']); + $field['size'] = constant(CRM_Utils_Schema::getDefaultSize($length)); + } + $usage = $fieldSpec['usage'] ?? []; + $field['usage'] = [ + 'import' => in_array('import', $usage), + 'export' => in_array('export', $usage), + 'duplicate_matching' => in_array('duplicate_matching', $usage), + 'token' => in_array('token', $usage), + ]; + if ($field['usage']['import']) { + $field['import'] = TRUE; + } + $field['where'] = $entityDef['table'] . '.' . $field['name']; + if ($field['usage']['export'] || (!$field['usage']['export'] && $field['usage']['import'])) { + $field['export'] = $field['usage']['export']; + } + if (!empty($fieldSpec['contact_type'])) { + $field['contactType'] = $fieldSpec['contact_type']; + } + if (!empty($fieldSpec['permission'])) { + $field['permission'] = $fieldSpec['permission']; + } + if (array_key_exists('default', $fieldSpec)) { + $field['default'] = isset($fieldSpec['default']) ? (string) $fieldSpec['default'] : NULL; + if (is_bool($fieldSpec['default'])) { + $field['default'] = $fieldSpec['default'] ? '1' : '0'; + } + } + $field['table_name'] = $entityDef['table']; + $field['entity'] = $entityDef['name']; + $field['bao'] = $baoName; + $field['localizable'] = intval($fieldSpec['localizable'] ?? 0); + if (!empty($fieldSpec['localize_context'])) { + $field['localize_context'] = (string) $fieldSpec['localize_context']; + } + if (!empty($fieldSpec['entity_reference'])) { + if (!empty($fieldSpec['entity_reference']['entity'])) { + $field['FKClassName'] = CRM_Core_DAO_AllCoreTables::getDAONameForEntity($fieldSpec['entity_reference']['entity']); + } + if (!empty($fieldSpec['entity_reference']['dynamic_entity'])) { + $field['DFKEntityColumn'] = $fieldSpec['entity_reference']['dynamic_entity']; + } + $field['FKColumnName'] = $fieldSpec['entity_reference']['key'] ?? 'id'; + } + if (!empty($fieldSpec['component'])) { + $field['component'] = $fieldSpec['component']; + } + if (!empty($fieldSpec['serialize'])) { + $field['serialize'] = $fieldSpec['serialize']; + } + if (!empty($fieldSpec['unique_name'])) { + $field['uniqueName'] = $fieldSpec['unique_name']; + } + if (!empty($fieldSpec['unique_title'])) { + $field['uniqueTitle'] = $fieldSpec['unique_title']; + } + if (!empty($fieldSpec['deprecated'])) { + $field['deprecated'] = TRUE; + } + if (!empty($fieldSpec['input_attrs'])) { + $field['html'] = CRM_Utils_Array::rekey($fieldSpec['input_attrs'], fn($str) => CRM_Utils_String::convertStringToCamel($str, FALSE)); + } + if (!empty($fieldSpec['input_type'])) { + $field['html']['type'] = $fieldSpec['input_type']; + } + if (!empty($fieldSpec['pseudoconstant'])) { + $field['pseudoconstant'] = CRM_Utils_Array::rekey($fieldSpec['pseudoconstant'], fn($str) => CRM_Utils_String::convertStringToCamel($str, FALSE)); + if (!isset($field['pseudoconstant']['optionEditPath']) && !empty($field['pseudoconstant']['optionGroupName'])) { + $field['pseudoconstant']['optionEditPath'] = 'civicrm/admin/options/' . $field['pseudoconstant']['optionGroupName']; + } + } + if (!empty($fieldSpec['primary_key']) || !empty($field['readonly'])) { + $field['readonly'] = TRUE; + } + $field['add'] = $fieldSpec['add'] ?? NULL; + $fields[$fieldName] = $field; + } + CRM_Core_DAO_AllCoreTables::invoke(static::class, 'fields_callback', $fields); + return $fields; + } + + private static function getFieldLength($sqlType): ?string { + $open = strpos($sqlType, '('); + if ($open) { + return substr($sqlType, $open + 1, -1); + } + return NULL; + } + + /** + * @inheritDoc + */ + public static function indices(bool $localize = TRUE): array { + $definition = static::getEntityDefinition(); + $indices = []; + if (isset($definition['getIndices'])) { + $fields = $definition['getFields'](); + foreach ($definition['getIndices']() as $name => $info) { + $index = [ + 'name' => $name, + 'field' => [], + 'localizable' => FALSE, + ]; + foreach ($info['fields'] as $fieldName => $length) { + if (!empty($fields[$fieldName]['localizable'])) { + $index['localizable'] = TRUE; + } + if (is_int($length)) { + $fieldName .= "($length)"; + } + $index['field'][] = $fieldName; + } + if (!empty($info['unique'])) { + $index['unique'] = TRUE; + } + $index['sig'] = ($definition['table']) . '::' . intval($info['unique'] ?? 0) . '::' . implode('::', $index['field']); + $indices[$name] = $index; + } + } + return ($localize && $indices) ? CRM_Core_DAO_AllCoreTables::multilingualize(static::class, $indices) : $indices; + } + + private static function getEntityDefinition(): array { + $entityName = CRM_Core_DAO_AllCoreTables::getEntityNameForClass(static::class); + return \Civi\Schema\EntityRepository::getEntity($entityName); + } + + private static function getEntityInfo(): array { + return static::getEntityDefinition()['getInfo'](); + } + +} diff --git a/CRM/Core/ClassLoader.php b/CRM/Core/ClassLoader.php index b92512ad36ff..acfc35c6ad4f 100644 --- a/CRM/Core/ClassLoader.php +++ b/CRM/Core/ClassLoader.php @@ -138,6 +138,10 @@ public function register($prepend = FALSE) { set_include_path($include_paths . PATH_SEPARATOR . get_include_path()); // @todo Why do we need to load this again? $this->requireComposerAutoload(); + + $mixinLib = dirname(__DIR__, 2) . '/mixin/lib'; + ($GLOBALS['_PathLoad'][0] ?? require "$mixinLib/pathload-0.php"); + require_once "$mixinLib/pathload.index.php"; } /** diff --git a/CRM/Core/CodeGen/Main.php b/CRM/Core/CodeGen/Main.php index fe90d38f5039..b3df7e092281 100644 --- a/CRM/Core/CodeGen/Main.php +++ b/CRM/Core/CodeGen/Main.php @@ -145,7 +145,7 @@ public function getTasks() { $tasks = []; $tasks[] = new CRM_Core_CodeGen_Config($this); $tasks[] = new CRM_Core_CodeGen_Reflection($this); - $tasks[] = new CRM_Core_CodeGen_Schema($this); + $tasks[] = new CRM_Core_CodeGen_PhpSchema($this); foreach (array_keys($this->tables) as $name) { $tasks[] = new CRM_Core_CodeGen_DAO($this, $name); } diff --git a/CRM/Core/CodeGen/PhpSchema.php b/CRM/Core/CodeGen/PhpSchema.php new file mode 100644 index 000000000000..a36028bd3883 --- /dev/null +++ b/CRM/Core/CodeGen/PhpSchema.php @@ -0,0 +1,149 @@ +locales = $this->findLocales(); + } + + public function run() { + CRM_Core_CodeGen_Util_File::createDir($this->config->sqlCodePath); + + $put = function ($files) { + foreach ($files as $file => $content) { + if (substr($content, -1) !== "\n") { + $content .= "\n"; + } + file_put_contents($this->config->sqlCodePath . $file, $content); + } + }; + + echo "Generating sql file\n"; + $put($this->generateCreateSql()); + + echo "Generating sql drop tables file\n"; + $put($this->generateDropSql()); + + foreach ($this->locales as $locale) { + echo "Generating data files for $locale\n"; + $put($this->generateLocaleDataSql($locale)); + } + + // also create the archive tables + // $this->generateCreateSql('civicrm_archive.mysql' ); + // $this->generateDropSql('civicrm_archive_drop.mysql'); + + echo "Generating navigation file\n"; + $put($this->generateNavigation()); + + echo "Generating sample file\n"; + $put($this->generateSample()); + } + + public function generateCreateSql() { + return ['civicrm.mysql' => \Civi::schemaHelper()->generateUninstallSql() . \Civi::schemaHelper()->generateInstallSql()]; + } + + public function generateDropSql() { + return ['civicrm_drop.mysql' => \Civi::schemaHelper()->generateUninstallSql()]; + } + + public function generateNavigation() { + $template = new CRM_Core_CodeGen_Util_Template('sql'); + return ['civicrm_navigation.mysql' => $template->fetch('civicrm_navigation.tpl')]; + } + + /** + * @param string $locale + * Ex: en_US, fr_FR + * @return array + */ + public function generateLocaleDataSql($locale) { + $template = new CRM_Core_CodeGen_Util_Template('sql'); + CRM_Core_CodeGen_Util_MessageTemplates::assignSmartyVariables($template->getSmarty()); + global $tsLocale; + $oldTsLocale = $tsLocale; + + try { + + $tsLocale = $locale; + $template->assign('locale', $locale); + $template->assign('db_version', $this->config->db_version); + + $sections = [ + 'civicrm_country.tpl', + 'civicrm_state_province.tpl', + 'civicrm_currency.tpl', + 'civicrm_data.tpl', + 'civicrm_navigation.tpl', + 'civicrm_version_sql.tpl', + ]; + + $ext = ($locale !== 'en_US' ? ".$locale" : ''); + + return [ + "civicrm_data$ext.mysql" => $template->fetchConcat($sections), + "civicrm_acl$ext.mysql" => $template->fetch('civicrm_acl.tpl'), + ]; + } + finally { + $tsLocale = $oldTsLocale; + } + } + + /** + * @return array + * Array(string $fileName => string $fileContent). + * List of files + */ + public function generateSample() { + $template = new CRM_Core_CodeGen_Util_Template('sql'); + $sections = [ + 'civicrm_sample.tpl', + 'civicrm_acl.tpl', + ]; + return [ + 'civicrm_sample.mysql' => $template->fetchConcat($sections), + 'case_sample.mysql' => $template->fetch('case_sample.tpl'), + ]; + } + + /** + * @return array + */ + public function findLocales() { + require_once 'CRM/Core/Config.php'; + $config = CRM_Core_Config::singleton(FALSE); + $locales = []; + $localeDir = CRM_Core_I18n::getResourceDir(); + if (file_exists($localeDir)) { + $locales = preg_grep('/^[a-z][a-z]_[A-Z][A-Z]$/', scandir($localeDir)); + } + + $localesMask = getenv('CIVICRM_LOCALES'); + if (!empty($localesMask)) { + $mask = explode(',', $localesMask); + $locales = array_intersect($locales, $mask); + } + + if (!in_array('en_US', $locales)) { + array_unshift($locales, 'en_US'); + } + + return $locales; + } + +} diff --git a/CRM/Core/CodeGen/Schema.php b/CRM/Core/CodeGen/Schema.php index fe8af1f138ee..f91d5f962163 100644 --- a/CRM/Core/CodeGen/Schema.php +++ b/CRM/Core/CodeGen/Schema.php @@ -2,6 +2,11 @@ /** * Create SQL files to create and populate a new schema. + * + * @deprecated + * Replaced by CRM_Core_CodeGen_PhpSchema. + * Delete this after civicrm-core and civix drop their references. + * Maybe allow grace-period of a couple months. */ class CRM_Core_CodeGen_Schema extends CRM_Core_CodeGen_BaseTask { diff --git a/CRM/Core/DAO/AllCoreTables.php b/CRM/Core/DAO/AllCoreTables.php index c4acb7be1881..993a00de0d54 100644 --- a/CRM/Core/DAO/AllCoreTables.php +++ b/CRM/Core/DAO/AllCoreTables.php @@ -10,6 +10,8 @@ +--------------------------------------------------------------------+ */ +use Civi\Schema\EntityRepository; + /** * * @package CRM @@ -18,36 +20,14 @@ class CRM_Core_DAO_AllCoreTables { /** - * Initialise. + * @deprecated in 5.73 will be removed in 5.90 * * @param bool $fresh Deprecated parameter, use flush() to flush. */ public static function init(bool $fresh = FALSE): void { - if (isset(Civi::$statics[__CLASS__]) && !$fresh) { - return; - } + CRM_Core_Error::deprecatedFunctionWarning('CRM_Core_DAO_AllCoreTables::flush()'); if ($fresh) { - CRM_Core_Error::deprecatedWarning('Use CRM_Core_DAO_AllCoreTables::flush()'); - } - - Civi::$statics[__CLASS__] = [ - 'entities' => [], - 'tables' => [], - 'classes' => [], - ]; - - $file = preg_replace('/\.php$/', '.data.php', __FILE__); - $entityTypes = require $file; - CRM_Utils_Hook::entityTypes($entityTypes); - - foreach ($entityTypes as $entityType) { - self::registerEntityType( - $entityType['name'], - $entityType['class'], - $entityType['table'], - $entityType['fields_callback'] ?? NULL, - $entityType['links_callback'] ?? NULL - ); + EntityRepository::flush(); } } @@ -55,32 +35,7 @@ public static function init(bool $fresh = FALSE): void { * Flush class cache. */ public static function flush(): void { - Civi::$statics[__CLASS__] = NULL; - } - - /** - * Add entity type to cached array. - * - * @param string $briefName - * @param string $className - * @param string $tableName - * @param string $fields_callback - * @param string $links_callback - * @internal - */ - private static function registerEntityType($briefName, $className, $tableName, $fields_callback = NULL, $links_callback = NULL) { - Civi::$statics[__CLASS__]['tables'][$tableName] = $briefName; - Civi::$statics[__CLASS__]['classes'][$className] = $briefName; - Civi::$statics[__CLASS__]['entities'][$briefName] = [ - 'class' => $className, - 'table' => $tableName, - ]; - if ($fields_callback) { - Civi::$statics[__CLASS__]['entities'][$briefName]['fields_callback'] = $fields_callback; - } - if ($links_callback) { - Civi::$statics[__CLASS__]['entities'][$briefName]['links_callback'] = $links_callback; - } + EntityRepository::flush(); } /** @@ -88,8 +43,7 @@ private static function registerEntityType($briefName, $className, $tableName, $ * [EntityName => [table => table_name, class => CRM_DAO_ClassName]][] */ public static function getEntities(): array { - self::init(); - return Civi::$statics[__CLASS__]['entities']; + return EntityRepository::getEntities(); } /** @@ -97,8 +51,7 @@ public static function getEntities(): array { * [table_name => EntityName][] */ private static function getEntitiesByTable(): array { - self::init(); - return Civi::$statics[__CLASS__]['tables']; + return EntityRepository::getTableIndex(); } /** @@ -109,8 +62,7 @@ private static function getEntitiesByTable(): array { * [CRM_DAO_ClassName => EntityName] */ private static function getEntitiesByClass(): array { - self::init(); - return Civi::$statics[__CLASS__]['classes']; + return EntityRepository::getClassIndex(); } /** diff --git a/CRM/Utils/Schema.php b/CRM/Utils/Schema.php index 3e4b0800288b..19ef35d53663 100644 --- a/CRM/Utils/Schema.php +++ b/CRM/Utils/Schema.php @@ -115,6 +115,10 @@ public static function getSize(SimpleXMLElement $fieldXML): string { if (!empty($fieldXML->html) && !empty($fieldXML->html->size)) { return (string) $fieldXML->html->size; } + return self::getDefaultSize(self::toString('length', $fieldXML)); + } + + public static function getDefaultSize($length) { // Infer from tag if was not explicitly set or was invalid // This map is slightly different from CRM_Core_Form_Renderer::$_sizeMapper // Because we usually want fields to render as smaller than their maxlength @@ -127,14 +131,39 @@ public static function getSize(SimpleXMLElement $fieldXML): string { 32 => 'MEDIUM', 64 => 'BIG', ]; - foreach ($sizes as $length => $name) { - if ($fieldXML->length <= $length) { + foreach ($sizes as $size => $name) { + if ($length <= $size) { return "CRM_Utils_Type::$name"; } } return 'CRM_Utils_Type::HUGE'; } + public static function getCrmTypeFromSqlType(string $sqlType) { + [$type] = explode('(', $sqlType); + switch ($type) { + case 'varchar': + case 'char': + return 'CRM_Utils_Type::T_STRING'; + + case 'datetime': + return 'CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME'; + + case 'decimal': + return 'CRM_Utils_Type::T_MONEY'; + + case 'double': + return 'CRM_Utils_Type::T_FLOAT'; + + case 'int unsigned': + case 'tinyint': + return 'CRM_Utils_Type::T_INT'; + + default: + return 'CRM_Utils_Type::T_' . strtoupper($type); + } + } + /** * Fallback used when field in schema xml is missing a title. * diff --git a/Civi.php b/Civi.php index 7c8684554188..b635bd8b06fe 100644 --- a/Civi.php +++ b/Civi.php @@ -303,4 +303,29 @@ public static function url(?string $logicalUri = NULL, ?string $flags = NULL): \ return new \Civi\Core\Url($logicalUri, $flags); } + /** + * Get the canonical entityProvider for a given entity type. + * + * @param string $entityName + * @return \Civi\Schema\EntityProvider + */ + public static function entity(string $entityName): \Civi\Schema\EntityProvider { + return new \Civi\Schema\EntityProvider($entityName); + } + + /** + * Get the schema-helper for CiviCRM (core-core). + * + * @param string $key + * Ex: 'civicrm' or 'org.example.myextension' + * @return \CiviMix\Schema\SchemaHelperInterface + */ + public static function schemaHelper(string $key = 'civicrm'): \CiviMix\Schema\SchemaHelperInterface { + if (!isset(Civi::$statics['schemaHelper'])) { + pathload()->loadPackage('civimix-schema@5'); + Civi::$statics['schemaHelper'] = TRUE; + } + return $GLOBALS['CiviMixSchema']->getHelper($key); + } + } diff --git a/Civi/Schema/EntityMetadataBase.php b/Civi/Schema/EntityMetadataBase.php new file mode 100644 index 000000000000..6c248f92882a --- /dev/null +++ b/Civi/Schema/EntityMetadataBase.php @@ -0,0 +1,32 @@ +entityName = $entityName; + } + + /** + * @return array{name: string, table: string, class: string, module: string, getInfo: callable, getPaths: callable, getIndices: callable, getFields: callable, metaProvider: callable, storageProvider: callable} + */ + protected function getEntity(): array { + return EntityRepository::getEntity($this->entityName); + } + +} diff --git a/Civi/Schema/EntityMetadataInterface.php b/Civi/Schema/EntityMetadataInterface.php new file mode 100644 index 000000000000..16d96f994b05 --- /dev/null +++ b/Civi/Schema/EntityMetadataInterface.php @@ -0,0 +1,22 @@ +entityName = $entityName; + } + + public function getMeta(string $property) { + return $this->getMetaProvider()->getProperty($property); + } + + public function getFields(): array { + return $this->getMetaProvider()->getFields(); + } + + public function getField(string $fieldName): ?array { + return $this->getFields()[$fieldName] ?? NULL; + } + + public function getOptions(string $fieldName, array $values = NULL): ?array { + return $this->getMetaProvider()->getOptions($fieldName, $values); + } + + public function writeRecords(array $records): array { + return $this->getStorageProvider()->writeRecords($records); + } + + public function deleteRecords(array $records): array { + return $this->getStorageProvider()->deleteRecords($records); + } + + private function getMetaProvider(): EntityMetadataInterface { + if (!isset($this->meta)) { + $entity = EntityRepository::getEntity($this->entityName); + if (isset($entity['metaProvider'])) { + return new $entity['metaProvider']($this->entityName); + } + if (isset($entity['getFields'])) { + return new SqlEntityMetadata($this->entityName); + } + if (isset($entity['table'])) { + return new LegacySqlEntityMetadata($this->entityName); + } + throw new \CRM_Core_Exception("Unknown entity $this->entityName"); + } + return $this->meta; + } + + private function getStorageProvider(): EntityStorageInterface { + if (!isset($this->storage)) { + $entity = EntityRepository::getEntity($this->entityName); + if (isset($entity['storageProvider'])) { + return new $entity['storageProvider']($this->entityName); + } + if (isset($entity['table'])) { + return new SqlEntityStorage($this->entityName); + } + throw new \CRM_Core_Exception("Unknown entity $this->entityName"); + } + return $this->storage; + } + +} diff --git a/Civi/Schema/EntityRepository.php b/Civi/Schema/EntityRepository.php new file mode 100644 index 000000000000..1fb84900431c --- /dev/null +++ b/Civi/Schema/EntityRepository.php @@ -0,0 +1,79 @@ +getFileName()); + $entityTypes = require $dataFile; + \CRM_Utils_Hook::entityTypes($entityTypes); + self::$entities = array_column($entityTypes, NULL, 'name'); + self::$tableIndex = array_column($entityTypes, 'name', 'table'); + self::$classIndex = array_column($entityTypes, 'name', 'class'); + } + +} diff --git a/Civi/Schema/EntityStorageInterface.php b/Civi/Schema/EntityStorageInterface.php new file mode 100644 index 000000000000..b449a16dbec9 --- /dev/null +++ b/Civi/Schema/EntityStorageInterface.php @@ -0,0 +1,20 @@ +getEntity()['class']; + } + + public function getProperty(string $propertyName) { + switch ($propertyName) { + case 'title': + return $this->getClassName()::getEntityTitle(); + + case 'title_plural': + return $this->getClassName()::getEntityTitle(TRUE); + + case 'icon': + return $this->getClassName()::$_icon ?? NULL; + + case 'paths': + return $this->getClassName()::getEntityPaths(); + + case 'label_field': + return $this->getClassName()::$_labelField; + + case 'primary_keys': + return $this->getClassName()::$_primaryKey ?? ['id']; + + case 'description': + return $this->getClassName()::getEntityDescription(); + + default: + return $this->getEntity()[$propertyName] ?? NULL; + } + } + + public function getFields(): array { + $fields = []; + $primaryKeys = $this->getProperty('primary_keys'); + foreach ($this->getClassName()::fields() as $uniqueName => $legacyField) { + $fieldName = $legacyField['name']; + $field = [ + 'title' => $legacyField['title'], + 'sql_type' => $this->getSqlType($legacyField), + 'input_type' => $legacyField['html']['type'] ?? NULL, + 'description' => $legacyField['description'] ?? NULL, + 'required' => $legacyField['required'] ?? FALSE, + 'add' => $legacyField['add'] ?? NULL, + 'usage' => $this->getUsage($legacyField), + 'deprecated' => $legacyField['deprecated'] ?? FALSE, + 'readonly' => $legacyField['readonly'] ?? FALSE, + 'localizable' => !empty($legacyField['localizable']), + 'localize_context' => $legacyField['localize_context'] ?? NULL, + 'unique_title' => $legacyField['uniqueTitle'] ?? NULL, + 'contact_type' => $legacyField['contactType'] ?? NULL, + 'component' => $legacyField['component'] ?? NULL, + 'serialize' => $legacyField['serialize'] ?? NULL, + 'permission' => $legacyField['permission'] ?? NULL, + ]; + if ($uniqueName !== $fieldName) { + $field['unique_name'] = $uniqueName; + } + if (array_key_exists('default', $legacyField)) { + $field['default'] = $legacyField['default']; + if ($field['default'] === 'NULL') { + $field['default'] = NULL; + } + elseif (is_string($field['default'])) { + $field['default'] = trim($field['default'], '"\''); + if (str_contains($field['sql_type'], 'int')) { + $field['default'] = (int) $field['default']; + } + if ($field['sql_type'] === 'boolean') { + $field['default'] = (bool) $field['default']; + } + } + } + unset($legacyField['html']['type']); + if (!empty($legacyField['html'])) { + $field['input_attrs'] = \CRM_Utils_Array::rekey($legacyField['html'], ['CRM_Utils_String', 'convertStringToSnakeCase']); + } + foreach (['rows', 'cols', 'maxlength'] as $attr) { + if (!empty($legacyField[$attr])) { + $field['input_attrs'][$attr] = $legacyField[$attr]; + } + } + if (!empty($legacyField['pseudoconstant'])) { + $field['pseudoconstant'] = \CRM_Utils_Array::rekey($legacyField['pseudoconstant'], ['CRM_Utils_String', 'convertStringToSnakeCase']); + unset($field['pseudoconstant']['option_edit_path']); + } + if (!empty($legacyField['FKClassName'])) { + $field['entity_reference'] = [ + 'entity' => \CRM_Core_DAO_AllCoreTables::getEntityNameForClass($legacyField['FKClassName']), + // Making assumptions about key but this is a legacy filler & it doesn't really matter + 'key' => 'id', + ]; + } + // Making assumptions about the nature of an `entity_id` field but this is a legacy filler & it doesn't really matter + if ($fieldName === 'entity_id') { + $field['entity_reference'] = [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ]; + } + if (in_array($fieldName, $primaryKeys)) { + $field['primary_key'] = TRUE; + $field['auto_increment'] = TRUE; + } + $fields[$fieldName] = $field; + } + return $fields; + } + + private function getSqlType(array $legacyField): string { + switch ($legacyField['type']) { + case \CRM_Utils_Type::T_INT: + return 'int'; + + case \CRM_Utils_Type::T_STRING: + return 'varchar' . (empty($legacyField['maxlength']) ? '' : "({$legacyField['maxlength']})"); + + case \CRM_Utils_Type::T_TEXT: + return 'text'; + + case \CRM_Utils_Type::T_LONGTEXT: + return 'longtext'; + + case \CRM_Utils_Type::T_BOOLEAN: + return 'boolean'; + + case \CRM_Utils_Type::T_FLOAT: + return 'double'; + + case \CRM_Utils_Type::T_MEDIUMBLOB: + return 'mediumblob'; + + case \CRM_Utils_Type::T_BLOB: + return 'blob'; + + case \CRM_Utils_Type::T_TIMESTAMP: + return 'timestamp'; + + case \CRM_Utils_Type::T_MONEY: + return 'decimal' . (empty($legacyField['precision']) ? '' : '(' . implode(',', $legacyField['precision']) . ')'); + + case \CRM_Utils_Type::T_DATE: + return 'date'; + + case \CRM_Utils_Type::T_DATE + \CRM_Utils_Type::T_TIME: + return 'datetime'; + + default: + throw new \CRM_Core_Exception('Unknown field type for ' . $legacyField['name']); + } + } + + private function getUsage(array $legacyField): array { + if (isset($legacyField['usage'])) { + return array_keys(array_filter($legacyField['usage'])); + } + $usage = []; + if (!empty($legacyField['import'])) { + $usage = ['import', 'duplicate_matching']; + } + if (!empty($legacyField['export'])) { + $usage[] = 'export'; + } + return $usage; + } + + public function getOptions(string $fieldName, array $values = NULL): ?array { + // TODO: Implement getOptions() method. + } + +} diff --git a/Civi/Schema/SqlEntityMetadata.php b/Civi/Schema/SqlEntityMetadata.php new file mode 100644 index 000000000000..2add4837fa91 --- /dev/null +++ b/Civi/Schema/SqlEntityMetadata.php @@ -0,0 +1,47 @@ +getFields() as $name => $field) { + if (!empty($field['primary_key'])) { + $keys[] = $name; + } + } + return $keys; + + case 'paths': + if (isset($this->getEntity()['getPaths'])) { + return $this->getEntity()['getPaths'](); + } + return []; + + default: + return $this->getEntity()[$propertyName] ?? $this->getEntity()['getInfo']()[$propertyName] ?? NULL; + + } + } + + public function getFields(): array { + return $this->getEntity()['getFields'](); + } + + public function getOptions(string $fieldName, array $values = NULL): ?array { + // TODO: Implement getOptions() method. + } + +} diff --git a/Civi/Schema/SqlEntityStorage.php b/Civi/Schema/SqlEntityStorage.php new file mode 100644 index 000000000000..466d3fdb2aa2 --- /dev/null +++ b/Civi/Schema/SqlEntityStorage.php @@ -0,0 +1,33 @@ +entityName = $entityName; + } + + public function writeRecords(array $records): array { + // TODO: Implement writeRecords() method. + } + + public function deleteRecords(array $records): array { + // TODO: Implement deleteRecords() method. + } + +} diff --git a/Civi/Test/CiviEnvBuilder/CoreSchemaStep.php b/Civi/Test/CiviEnvBuilder/CoreSchemaStep.php index 5f8e56abf96b..f27c26be619e 100644 --- a/Civi/Test/CiviEnvBuilder/CoreSchemaStep.php +++ b/Civi/Test/CiviEnvBuilder/CoreSchemaStep.php @@ -19,11 +19,10 @@ class CoreSchemaStep implements StepInterface { */ public function getSql() { if (!isset(\Civi\Test::$statics['core_schema_sql'])) { - $schema = new \CRM_Core_CodeGen_Schema(\Civi\Test::codeGen()); - $files = $schema->generateCreateSql(); + $sql = \Civi::schemaHelper()->generateInstallSql(); \Civi\Test::$statics['core_schema_sql'] = [ - 'digest' => md5($files['civicrm.mysql']), - 'content' => $files['civicrm.mysql'], + 'digest' => md5($sql), + 'content' => $sql, ]; } return \Civi\Test::$statics['core_schema_sql']; diff --git a/Civi/Test/Data.php b/Civi/Test/Data.php index 87116adfeb67..bcb190a25eb9 100644 --- a/Civi/Test/Data.php +++ b/Civi/Test/Data.php @@ -22,7 +22,7 @@ public function populate() { $sqlDir = dirname(dirname(__DIR__)) . "/sql"; if (!isset(\Civi\Test::$statics['locale_data'])) { - $schema = new \CRM_Core_CodeGen_Schema(\Civi\Test::codeGen()); + $schema = new \CRM_Core_CodeGen_PhpSchema(\Civi\Test::codeGen()); \Civi\Test::$statics['locale_data'] = $schema->generateLocaleDataSql('en_US'); } diff --git a/mixin/lib/civimix-schema/pathload.main.php b/mixin/lib/civimix-schema/pathload.main.php new file mode 100644 index 000000000000..f0442e848bfa --- /dev/null +++ b/mixin/lib/civimix-schema/pathload.main.php @@ -0,0 +1,28 @@ +activatePackage('civimix-schema@5', __DIR__, [ + 'reloadable' => TRUE, + // The civimix-schema library specifically supports installation processes. From a + // bootstrap/service-availability POV, this is a rough environment which leads to + // the "Multi-Activation Issue" and "Multi-Download Issue". To adapt to them, + // civimix-schema follows "Reloadable Library" patterns. + // More information: https://github.com/totten/pathload-poc/blob/master/doc/issues.md +]); + +// When reloading, we make newer instance of the Facade object. +$GLOBALS['CiviMixSchema'] = require __DIR__ . '/src/CiviMixSchema.php'; + +if (!interface_exists(__NAMESPACE__ . '\SchemaHelperInterface')) { + require __DIR__ . '/src/SchemaHelperInterface.php'; +} + +// \CiviMix\Schema\loadClass() is a facade. The facade should remain identical across versions. +if (!function_exists(__NAMESPACE__ . '\loadClass')) { + + function loadClass(string $class) { + return $GLOBALS['CiviMixSchema']->loadClass($class); + } + + spl_autoload_register(__NAMESPACE__ . '\loadClass'); +} diff --git a/mixin/lib/civimix-schema/src/AutomaticUpgrader.php b/mixin/lib/civimix-schema/src/AutomaticUpgrader.php new file mode 100644 index 000000000000..cf26ce684a2d --- /dev/null +++ b/mixin/lib/civimix-schema/src/AutomaticUpgrader.php @@ -0,0 +1,135 @@ +initIdentity($params); + if ($info = $this->getInfo()) { + if ($class = $this->getDelegateUpgraderClass($info)) { + $this->customUpgrader = new $class(); + $this->customUpgrader->init($params); + if ($errors = $this->checkDelegateCompatibility($this->customUpgrader)) { + throw new \CRM_Core_Exception("AutomaticUpgrader is not compatible with $class:\n" . implode("\n", $errors)); + } + } + } + } + + public function notify(string $event, array $params = []) { + $info = $this->getInfo(); + if (!$info) { + return; + } + + if ($event === 'install') { + $GLOBALS['CiviMixSchema']->getHelper($this->getExtensionKey())->install(); + } + + if ($this->customUpgrader) { + $this->customUpgrader->notify($event, $params); + } + + if ($event === 'uninstall') { + $GLOBALS['CiviMixSchema']->getHelper($this->getExtensionKey())->uninstall(); + } + } + + /** + * Civix-based extensions have a conventional name for their upgrader class ("CRM_Myext_Upgrader" + * or "Civi\Myext\Upgrader"). Figure out if this class exists. + * + * @param \CRM_Extension_Info $info + * @return string|null + * Ex: 'CRM_Myext_Upgrader' or 'Civi\Myext\Upgrader' + */ + public function getDelegateUpgraderClass(\CRM_Extension_Info $info): ?string { + $candidates = []; + + if (!empty($info->civix['namespace'])) { + $namespace = $info->civix['namespace']; + $candidates[] = sprintf('%s_Upgrader', str_replace('/', '_', $namespace)); + $candidates[] = sprintf('%s\\Upgrader', str_replace('/', '\\', $namespace)); + } + + foreach ($candidates as $candidate) { + if (class_exists($candidate)) { + return $candidate; + } + } + + return NULL; + } + + public function getInfo(): ?\CRM_Extension_Info { + try { + return \CRM_Extension_System::singleton()->getMapper()->keyToInfo($this->extensionName); + } + catch (\CRM_Extension_Exception_ParseException $e) { + \Civi::log()->error("Parse error in extension " . $this->extensionName . ": " . $e->getMessage()); + return NULL; + } + } + + /** + * @param \CRM_Extension_Upgrader_Interface $upgrader + * @return array + * List of error messages. + */ + public function checkDelegateCompatibility($upgrader): array { + $class = get_class($upgrader); + + $errors = []; + + if (!($upgrader instanceof \CRM_Extension_Upgrader_Base)) { + $errors[] = "$class is not based on CRM_Extension_Upgrader_Base."; + return $errors; + } + + // In the future, we will probably modify AutomaticUpgrader to build its own + // sequence of revisions (based on other sources of data). AutomaticUpgrader + // is only regarded as compatible with classes that strictly follow the standard revision-model. + $methodNames = [ + 'appendTask', + 'onUpgrade', + 'getRevisions', + 'getCurrentRevision', + 'setCurrentRevision', + 'enqueuePendingRevisions', + 'hasPendingRevisions', + ]; + foreach ($methodNames as $methodName) { + $method = new \ReflectionMethod($upgrader, $methodName); + if ($method->getDeclaringClass()->getName() !== 'CRM_Extension_Upgrader_Base') { + $errors[] = "To ensure future interoperability, AutomaticUpgrader only supports {$class}::{$methodName}() if it's inherited from CRM_Extension_Upgrader_Base"; + } + } + + return $errors; + } + +}; diff --git a/mixin/lib/civimix-schema/src/CiviMixSchema.php b/mixin/lib/civimix-schema/src/CiviMixSchema.php new file mode 100644 index 000000000000..72223e701104 --- /dev/null +++ b/mixin/lib/civimix-schema/src/CiviMixSchema.php @@ -0,0 +1,46 @@ +regex, $class, $m)) { + $absPath = __DIR__ . DIRECTORY_SEPARATOR . $m[2] . '.php'; + class_alias(get_class(require $absPath), $class); + } + } + + /** + * @param string $extensionKey + * Ex: 'org.civicrm.flexmailer' + * @return \CiviMix\Schema\SchemaHelperInterface + */ + public function getHelper(string $extensionKey) { + $store = &\Civi::$statics['CiviMixSchema-helpers']; + if (!isset($store[$extensionKey])) { + $class = get_class(require __DIR__ . '/SchemaHelper.php'); + $store[$extensionKey] = new $class($extensionKey); + } + return $store[$extensionKey]; + } + +}; diff --git a/mixin/lib/civimix-schema/src/SchemaHelper.php b/mixin/lib/civimix-schema/src/SchemaHelper.php new file mode 100644 index 000000000000..41e68e48beb7 --- /dev/null +++ b/mixin/lib/civimix-schema/src/SchemaHelper.php @@ -0,0 +1,82 @@ +key = $key; + } + + public function install(): void { + $this->runSqls([$this->generateInstallSql()]); + } + + public function uninstall(): void { + $this->runSqls([$this->generateUninstallSql()]); + } + + public function generateInstallSql(): ?string { + return $this->getSqlGenerator()->getCreateTablesSql(); + } + + public function generateUninstallSql(): string { + return $this->getSqlGenerator()->getDropTablesSql(); + } + + public function hasSchema(): bool { + return file_exists($this->getExtensionDir() . '/schema'); + } + + // FIXME: You can add more utility methods here + + // public function addTables(array $names): void { + // throw new \RuntimeException("TODO: Install a single tables"); + // } + // + // public function addColumn(string $table, string $column): void { + // throw new \RuntimeException("TODO: Install a single tables"); + // } + + /** + * @param array $sqls + * List of SQL scripts. + */ + private function runSqls(array $sqls): void { + foreach ($sqls as $sql) { + \CRM_Utils_File::runSqlQuery(CIVICRM_DSN, $sql); + } + } + + protected function getExtensionDir(): string { + if ($this->key === 'civicrm') { + $r = new \ReflectionClass('CRM_Core_ClassLoader'); + return dirname($r->getFileName(), 3); + } + $system = \CRM_Extension_System::singleton(); + return $system->getMapper()->keyToBasePath($this->key); + } + + private function getSqlGenerator() { + if ($this->sqlGenerator === NULL) { + $gen = require __DIR__ . '/SqlGenerator.php'; + $this->sqlGenerator = $gen::createFromFolder($this->key, $this->getExtensionDir() . '/schema', $this->key === 'civicrm'); + } + return $this->sqlGenerator; + } + +}; diff --git a/mixin/lib/civimix-schema/src/SchemaHelperInterface.php b/mixin/lib/civimix-schema/src/SchemaHelperInterface.php new file mode 100644 index 000000000000..e915a8064e6b --- /dev/null +++ b/mixin/lib/civimix-schema/src/SchemaHelperInterface.php @@ -0,0 +1,30 @@ +NULL) { + + /** + * @var array + */ + private array $entities; + + private $findExternalTable; + + /** + * @param string $module + * Ex: 'civicrm' or 'org.example.mymodule' + * @param string $path + * Ex: '/var/www/sites/all/modules/civicrm/schema' + * @param bool $isolated + * TRUE if these entities should be a self-sufficient (i.e. no external references). + * FALSE if these entities may include references to other tables. + * TRUE would make sense in (eg) civicrm-core, before installation or bootstrap + * FALSE would make sense in (eg) an extension on an active system. + * + * @return static + */ + public static function createFromFolder(string $module, string $path, bool $isolated) { + $files = \CRM_Utils_File::findFiles($path, '*.entityType.php'); + $entities = []; + foreach ($files as $file) { + $entity = include $file; + $entity['module'] = $module; + $entities[$entity['name']] = $entity; + } + + $findExternalTable = $isolated ? (fn($entity) => NULL) : (['CRM_Core_DAO_AllCoreTables', 'getTableForEntityName']); + return new static($entities, $findExternalTable); + } + + public function __construct(array $entities, callable $findExternalTable) { + $this->entities = $entities; + $this->findExternalTable = $findExternalTable; + } + + public function getEntities(): array { + return $this->entities; + } + + public function getCreateTablesSql(): string { + $sql = ''; + foreach ($this->entities as $entity) { + $sql .= $this->generateCreateTableSql($entity); + } + foreach ($this->entities as $entity) { + $sql .= $this->generateConstraintsSql($entity); + } + return $sql; + } + + public function getCreateTableSql(string $entityName): string { + $sql = $this->generateCreateTableSql($this->entities[$entityName]); + $sql .= $this->generateConstraintsSql($this->entities[$entityName]); + return $sql; + } + + public function getDropTablesSql(): string { + $sql = "SET FOREIGN_KEY_CHECKS=0;\n"; + foreach ($this->entities as $entity) { + $sql .= "DROP TABLE IF EXISTS `{$entity['table']}`;\n"; + } + $sql .= "SET FOREIGN_KEY_CHECKS=1;\n"; + return $sql; + } + + private function generateCreateTableSql(array $entity): string { + $definition = []; + $primaryKeys = []; + foreach ($entity['getFields']() as $fieldName => $field) { + if (!empty($field['primary_key'])) { + $primaryKeys[] = "`$fieldName`"; + } + $fieldSql = "`$fieldName` {$field['sql_type']}"; + if (!empty($field['collate'])) { + $fieldSql .= " COLLATE {$field['collate']}"; + } + // Required fields and booleans cannot be null + // FIXME: For legacy support this doesn't force boolean fields to be NOT NULL... but it really should. + if (!empty($field['required'])) { + $fieldSql .= ' NOT NULL'; + } + // Mysql 5.7 requires timestamp to be explicitly declared NULL + if (empty($field['required']) && $field['sql_type'] === 'timestamp') { + $fieldSql .= ' NULL'; + } + if (!empty($field['auto_increment'])) { + $fieldSql .= " AUTO_INCREMENT"; + } + $fieldSql .= self::getDefaultSql($field); + if (!empty($field['description'])) { + $fieldSql .= " COMMENT '" . \CRM_Core_DAO::escapeString($field['description']) . "'"; + } + $definition[] = $fieldSql; + } + if ($primaryKeys) { + $definition[] = 'PRIMARY KEY (' . implode(', ', $primaryKeys) . ')'; + } + $indices = isset($entity['getIndices']) ? $entity['getIndices']() : []; + foreach ($indices as $indexName => $index) { + $indexFields = []; + foreach ($index['fields'] as $fieldName => $length) { + $indexFields[] = "`$fieldName`" . (is_int($length) ? "($length)" : ''); + } + $definition[] = (!empty($index['unique']) ? 'UNIQUE ' : '') . "INDEX `$indexName`(" . implode(', ', $indexFields) . ')'; + } + + $sql = "CREATE TABLE `{$entity['table']}` (\n " . + implode(",\n ", $definition) . + "\n)\n" . + $this->getTableOptions() . ";\n"; + return $sql; + } + + private function generateConstraintsSql(array $entity): string { + $constraints = []; + foreach ($entity['getFields']() as $fieldName => $field) { + if (!empty($field['entity_reference']['entity'])) { + $constraint = "ADD CONSTRAINT `FK_{$entity['table']}_$fieldName` FOREIGN KEY (`$fieldName`)" . + " REFERENCES `" . $this->getTableForEntity($field['entity_reference']['entity']) . "`(`{$field['entity_reference']['key']}`)"; + if (!empty($field['entity_reference']['on_delete'])) { + $constraint .= " ON DELETE {$field['entity_reference']['on_delete']}"; + } + $constraints[] = $constraint; + } + } + $sql = ''; + if ($constraints) { + $sql .= "ALTER TABLE `{$entity['table']}`\n "; + $sql .= implode(",\n ", $constraints) . ";\n"; + } + return $sql; + } + + private static function getDefaultSql(array $field): string { + // Booleans always have a default + if ($field['sql_type'] === 'boolean') { + $field += ['default' => FALSE]; + } + if (!array_key_exists('default', $field)) { + return ''; + } + if (is_null($field['default'])) { + $default = 'NULL'; + } + elseif (is_bool($field['default'])) { + $default = $field['default'] ? 'TRUE' : 'FALSE'; + } + elseif (!is_string($field['default']) || str_starts_with($field['default'], 'CURRENT_TIMESTAMP')) { + $default = $field['default']; + } + else { + $default = "'" . \CRM_Core_DAO::escapeString($field['default']) . "'"; + } + return ' DEFAULT ' . $default; + } + + private function getTableForEntity(string $entityName): string { + return $this->entities[$entityName]['table'] ?? call_user_func($this->findExternalTable, $entityName); + } + + /** + * Get general/default options for use in CREATE TABLE (eg character set, collation). + */ + private function getTableOptions(): string { + if (!Civi\Core\Container::isContainerBooted()) { + // Pre-installation environment ==> aka new install + $collation = CRM_Core_BAO_SchemaHandler::DEFAULT_COLLATION; + } + else { + // What character-set is used for CiviCRM core schema? What collation? + // This depends on when the DB was *initialized*: + // - civicrm-core >= 5.33 has used `CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci` + // - civicrm-core 4.3-5.32 has used `CHARACTER SET utf8 COLLATE utf8_unicode_ci` + // - civicrm-core <= 4.2 -- I haven't checked, but it's probably the same. + // Some systems have migrated (eg APIv3's `System.utf8conversion`), but (as of Feb 2024) + // we haven't made any effort to push to this change. + $collation = \CRM_Core_BAO_SchemaHandler::getInUseCollation(); + } + + $characterSet = (stripos($collation, 'utf8mb4') !== FALSE) ? 'utf8mb4' : 'utf8'; + return "ENGINE=InnoDB DEFAULT CHARACTER SET {$characterSet} COLLATE {$collation} ROW_FORMAT=DYNAMIC"; + } + +}; diff --git a/mixin/lib/pathload-0.php b/mixin/lib/pathload-0.php new file mode 100644 index 000000000000..76d642548beb --- /dev/null +++ b/mixin/lib/pathload-0.php @@ -0,0 +1,711 @@ +top = $top; + } + public function offsetExists($version): bool { + return ($version === 'top' || $version <= $this->top->version); + } + public function offsetGet($version): ?\PathLoadInterface { + if ($version === 'top' || $version <= $this->top->version) { + return $this->top; + } + return NULL; + } + public function offsetSet($offset, $value): void { + error_log("Cannot overwrite PathLoad[$offset]"); + } + public function offsetUnset($offset): void { + error_log("Cannot remove PathLoad[$offset]"); + } + } + class Package { + /** + * Split a package identifier into its parts. + * + * @param string $package + * Ex: 'foobar@1.2.3' + * @return array + * Tuple: [$majorName, $name, $version] + * Ex: 'foobar@1', 'foobar', '1.2.3' + */ + public static function parseExpr(string $package): array { + if (strpos($package, '@') === FALSE) { + throw new \RuntimeException("Malformed package name: $package"); + } + [$prefix, $suffix] = explode('@', $package, 2); + $prefix = str_replace('/', '~', $prefix); + [$major] = explode('.', $suffix, 2); + return ["$prefix@$major", $prefix, $suffix]; + } + public static function parseFileType(string $file): array { + if (substr($file, -4) === '.php') { + return ['php', substr(basename($file), 0, -4)]; + } + elseif (substr($file, '-5') === '.phar') { + return ['phar', substr(basename($file), 0, -5)]; + } + elseif (is_dir($file)) { + return ['dir', basename($file)]; + } + else { + return [NULL, NULL]; + } + } + /** + * @param string $file + * Ex: '/var/www/app-1/lib/foobar@.1.2.3.phar' + * @return \PathLoad\Vn\Package|null + */ + public static function create(string $file): ?Package { + [$type, $base] = self::parseFileType($file); + if ($type === NULL) { + return NULL; + } + $self = new Package(); + [$self->majorName, $self->name, $self->version] = static::parseExpr($base); + $self->file = $file; + $self->type = $type; + return $self; + } + /** + * @var string + * Ex: '/var/www/app-1/lib/cloud-file-io@1.2.3.phar' + */ + public $file; + /** + * @var string + * Ex: 'cloud-file-io' + */ + public $name; + /** + * @var string + * Ex: 'cloud-file-io@1' + */ + public $majorName; + /** + * @var string + * Ex: '1.2.3' + */ + public $version; + /** + * @var string + * Ex: 'php' or 'phar' or 'dir' + */ + public $type; + public $reloadable = FALSE; + } + class Scanner { + /** + * @var array + * Array(string $id => [package => string, glob => string]) + * @internal + */ + public $allRules = []; + /** + * @var array + * Array(string $id => [package => string, glob => string]) + * @internal + */ + public $newRules = []; + /** + * @param array $rule + * Ex: ['package' => '*', 'glob' => '/var/www/lib/*@*'] + * Ex: ['package' => 'cloud-file-io@1', 'glob' => '/var/www/lib/cloud-io@1*.phar']) + * @return void + */ + public function addRule(array $rule): void { + $id = static::id($rule); + $this->newRules[$id] = $this->allRules[$id] = $rule; + } + public function reset(): void { + $this->newRules = $this->allRules; + } + /** + * Evaluate any rules that have a chance of finding $packageHint. + * + * @param string $packageHint + * Give a hint about what package we're looking for. + * The scanner will try to target packages based on this hint. + * Ex: '*' or 'cloud-file-io' + * @return \Generator + * A list of packages. These may not be the exact package you're looking for. + * You should assimilate knowledge of all outputs because you may not get them again. + */ + public function scan(string $packageHint): \Generator { + yield from []; + foreach (array_keys($this->newRules) as $id) { + $searchRule = $this->newRules[$id]; + if ($searchRule['package'] === '*' || $searchRule['package'] === $packageHint) { + unset($this->newRules[$id]); + if (isset($searchRule['glob'])) { + foreach ((array) glob($searchRule['glob']) as $file) { + if (($package = Package::create($file)) !== NULL) { + yield $package; + } + } + } + if (isset($searchRule['file'])) { + $package = new Package(); + $package->file = $searchRule['file']; + $package->name = $searchRule['package']; + $package->majorName = $searchRule['package'] . '@' . explode('.', $searchRule['version'])[0]; + $package->version = $searchRule['version']; + $package->type = $searchRule['type'] ?: Package::parseFileType($searchRule['file'])[0]; + yield $package; + } + } + } + } + protected static function id(array $rule): string { + if (isset($rule['glob'])) { + return $rule['glob']; + } + elseif (isset($rule['file'])) { + return md5(implode(' ', [$rule['file'], $rule['package'], $rule['version']])); + } + else { + throw new \RuntimeException("Cannot identify rule: " . json_encode($rule)); + } + } + } + class Psr0Loader { + /** + * @var array + * Ex: $paths['F']['Foo_'][0] = '/var/www/app/lib/foo@1.0.0/src/'; + * @internal + */ + public $paths = []; + /** + * @param string $dir + * @param array $config + * Ex: ['Foo_' => ['src/']] or ['Foo_' => ['Foo_']] + */ + public function addAll(string $dir, array $config) { + $dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; + foreach ($config as $prefix => $relPaths) { + $bucket = $prefix[0]; + foreach ((array) $relPaths as $relPath) { + $this->paths[$bucket][$prefix][] = $dir . $relPath; + } + } + } + /** + * Loads the class file for a given class name. + * + * @param string $class The fully-qualified class name. + * @return mixed The mapped file name on success, or boolean false on failure. + */ + public function loadClass(string $class) { + $bucket = $class[0]; + if (!isset($this->paths[$bucket])) { + return FALSE; + } + $file = DIRECTORY_SEPARATOR . str_replace(['_', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $class) . '.php'; + foreach ($this->paths[$bucket] as $prefix => $paths) { + if ($prefix === substr($class, 0, strlen($prefix))) { + foreach ($paths as $path) { + $fullFile = $path . $file; + if (file_exists($fullFile)) { + doRequire($fullFile); + return $fullFile; + } + } + } + } + return FALSE; + } + } + class Psr4Loader { + /** + * @var array + * Ex: $prefixes['Foo\\'][0] = '/var/www/app/lib/foo@1.0.0/src/'] + * @internal + */ + public $prefixes = []; + public function addAll(string $dir, array $config) { + foreach ($config as $prefix => $relPaths) { + foreach ($relPaths as $relPath) { + $this->addNamespace($prefix, $dir . '/' . $relPath); + } + } + } + /** + * Adds a base directory for a namespace prefix. + * + * @param string $prefix + * The namespace prefix. + * @param string $baseDir + * A base directory for class files in the namespace. + * @return void + */ + private function addNamespace($prefix, $baseDir) { + $prefix = trim($prefix, '\\') . '\\'; + $baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR) . '/'; + if (isset($this->prefixes[$prefix]) === FALSE) { + $this->prefixes[$prefix] = []; + } + array_push($this->prefixes[$prefix], $baseDir); + } + /** + * Loads the class file for a given class name. + * + * @param string $class The fully-qualified class name. + * @return mixed The mapped file name on success, or boolean false on failure. + */ + public function loadClass(string $class) { + $prefix = $class; + while (FALSE !== $pos = strrpos($prefix, '\\')) { + $prefix = substr($class, 0, $pos + 1); + $relativeClass = substr($class, $pos + 1); + if ($mappedFile = $this->findRelativeClass($prefix, $relativeClass)) { + doRequire($mappedFile); + return $mappedFile; + } + $prefix = rtrim($prefix, '\\'); + } + return FALSE; + } + /** + * Load the mapped file for a namespace prefix and relative class. + * + * @param string $prefix + * The namespace prefix. + * @param string $relativeClass + * The relative class name. + * @return string|FALSE + * Matched file name, or FALSE if none found. + */ + private function findRelativeClass($prefix, $relativeClass) { + if (isset($this->prefixes[$prefix]) === FALSE) { + return FALSE; + } + $relFile = str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass) . '.php'; + foreach ($this->prefixes[$prefix] as $baseDir) { + $file = $baseDir . $relFile; + if (file_exists($file)) { + return $file; + } + } + return FALSE; + } + } + class PathLoad implements \PathLoadInterface { + /** + * @var null|int + */ + public $version; + /** + * @var Scanner + * @internal + */ + public $scanner; + /** + * List of best-known versions for each package. + * + * Packages are loaded lazily. Once loaded, the data is moved to $loadedPackages. + * + * @var Package[] + * Ex: ['cloud-file-io@1' => new Package('/usr/share/php-pathload/cloud-file-io@1.2.3.phar', + * ...)] + * @internal + */ + public $availablePackages = []; + /** + * List of packages that have already been resolved. + * + * @var Package[] + * Ex: ['cloud-file-io@1' => new Package('/usr/share/php-pathload/cloud-file-io@1.2.3.phar', + * ...)] Note: If PathLoad version is super-ceded, then the loadedPackages may be instances of + * an old `Package` class. Be mindful of duck-type compatibility. We don't strictly need to + * retain this data, but it feels it'd be handy for debugging. + * @internal + */ + public $loadedPackages = []; + /** + * Log of package activations. Used to re-initialize class-loader if we upgrade. + * + * @var array + * @internal + */ + public $activatedPackages = []; + /** + * List of hints for class-loading. If someone tries to use a matching class, then + * load the corresponding package. + * + * Namespace-rules are evaluated lazily. Once evaluated, the data is removed. + * + * @var array + * Array(string $prefix => [string $package => string $package]) + * Ex: ['Super\Cloud\IO\' => ['cloud-io@1' => 'cloud-io@1'] + * @internal + */ + public $availableNamespaces; + /** + * @var \PathLoad\Vn\Psr0Loader + * @internal + */ + public $psr0; + /** + * @var \PathLoad\Vn\Psr4Loader + * @internal + */ + public $psr4; + /** + * @param int $version + * Identify the version being instantiated. + * @param \PathLoadInterface|null $old + * If this instance is a replacement for an older instance, then it will be passed in. + * @return \ArrayAccess + * Versioned work-a-like array. + */ + public static function create(int $version, ?\PathLoadInterface $old = NULL) { + if ($old !== NULL) { + $old->unregister(); + } + $new = new static(); + $new->version = $version; + $new->scanner = new Scanner(); + $new->psr0 = new Psr0Loader(); + $new->psr4 = new Psr4Loader(); + $new->register(); + // The exact protocol for assimilating $old instances may need change. + // This seems like a fair guess as long as old properties are forward-compatible. + + if ($old === NULL) { + $baseDirs = getenv('PHP_PATHLOAD') ? explode(PATH_SEPARATOR, getenv('PHP_PATHLOAD')) : []; + foreach ($baseDirs as $baseDir) { + $new->addSearchDir($baseDir); + } + } + else { + // TIP: You might use $old->version to decide what to use. + foreach ($old->scanner->allRules as $rule) { + $new->scanner->addRule($rule); + } + $new->loadedPackages = $old->loadedPackages; + $new->availableNamespaces = $old->availableNamespaces; + foreach ($old->activatedPackages as $activatedPackage) { + $new->activatePackage($activatedPackage['name'], $activatedPackage['dir'], $activatedPackage['config']); + } + } + return new Versions($new); + } + public function register(): \PathLoadInterface { + spl_autoload_register([$this, 'loadClass']); + return $this; + } + public function unregister(): \PathLoadInterface { + spl_autoload_unregister([$this, 'loadClass']); + return $this; + } + public function reset(): \PathLoadInterface { + $this->scanner->reset(); + return $this; + } + /** + * Append a directory (with many packages) to the search-path. + * + * @param string $baseDir + * The path to a base directory (e.g. `/var/www/myapp/lib`) which contains many packages (e.g. + * `foo@1.2.3.phar` or `bar@4.5.6/autoload.php`). + */ + public function addSearchDir(string $baseDir): \PathLoadInterface { + $this->scanner->addRule(['package' => '*', 'glob' => "$baseDir/*@*"]); + return $this; + } + /** + * Append one specific item to the search list. + * + * @param string $name + * Ex: 'cloud-file-io' + * @param string $version + * Ex: '1.2.3' + * @param string $file + * Full path to the file or folder. + * @param string|null $type + * One of: 'php', 'phar', or 'dir'. NULL will auto-detect. + * + * @return \PathLoadInterface + */ + public function addSearchItem(string $name, string $version, string $file, ?string $type = NULL): \PathLoadInterface { + $this->scanner->addRule(['package' => $name, 'version' => $version, 'file' => $file, 'type' => $type]); + return $this; + } + /** + * Add auto-loading hints. If someone requests a class in $namespace, then we load $package. + * + * Consecutive/identical calls to addNamespace() are de-duplicated. + * + * @param string $package + * Ex: 'cloud-io@1' + * @param string|string[] $namespaces + * Ex: 'Super\Cloud\IO\' + */ + public function addNamespace(string $package, $namespaces): \PathLoadInterface { + foreach ((array) $namespaces as $namespace) { + $this->availableNamespaces[$namespace][$package] = $package; + } + return $this; + } + public function loadClass(string $class) { + if (strpos($class, '\\') !== FALSE) { + $this->loadPackagesByNamespace('\\', explode('\\', $class)); + } + elseif (strpos($class, '_') !== FALSE) { + $this->loadPackagesByNamespace('_', explode('_', $class)); + } + return $this->psr4->loadClass($class) || $this->psr0->loadClass($class); + } + /** + * If the application requests class "Foo\Bar\Whiz\Bang", then you should load + * any packages related to "Foo\*", "Foo\Bar\*", or "Foo\Bar\Whiz\*". + * + * @param string $delim + * Ex: '\\' or '_' + * @param string[] $classParts + * Ex: ['Symfony', 'Components', 'Filesystem', 'Filesystem'] + */ + private function loadPackagesByNamespace(string $delim, array $classParts): void { + array_pop($classParts); + do { + $foundPackages = FALSE; + $namespace = ''; + foreach ($classParts as $nsPart) { + $namespace .= $nsPart . $delim; + if (isset($this->availableNamespaces[$namespace])) { + $packages = $this->availableNamespaces[$namespace]; + foreach ($packages as $package) { + unset($this->availableNamespaces[$namespace][$package]); + if ($this->loadPackage($package)) { + $foundPackages = TRUE; + } + else { + trigger_error("PathLoad: Failed to locate package \"$package\" required for namespace \"$namespace\"", E_USER_WARNING); + $this->availableNamespaces[$namespace][$package] = $package; /* Maybe some other time */ + } + } + } + } + } while ($foundPackages); + // Loading a package could produce metadata about other packages. Assimilate those too. + } + /** + * Load the content of a package. + * + * @param string $majorName + * Ex: 'cloud-io@1' + * @param bool $reload + * @return string|NULL + * The version# of the loaded package. Otherwise, NULL + */ + public function loadPackage(string $majorName, bool $reload = FALSE): ?string { + if (isset($this->loadedPackages[$majorName])) { + if ($reload && $this->loadedPackages[$majorName]->reloadable) { + $this->scanner->reset(); + } + else { + if ($reload) { + trigger_error("PathLoad: Declined to reload \"$majorName\". Package is not reloadable.", E_USER_WARNING); + } + return $this->loadedPackages[$majorName]->version; + } + } + $this->scanAvailablePackages(explode('@', $majorName, 2)[0], $this->availablePackages); + if (!isset($this->availablePackages[$majorName])) { + return NULL; + } + $package = $this->loadedPackages[$majorName] = $this->availablePackages[$majorName]; + unset($this->availablePackages[$majorName]); + switch ($package->type ?? NULL) { + case 'php': + doRequire($package->file); + return $package->version; + case 'phar': + doRequire($package->file); + $this->useMetadataFiles($package, 'phar://' . $package->file); + return $package->version; + case 'dir': + $this->useMetadataFiles($package, $package->file); + return $package->version; + default: + \error_log("PathLoad: Package (\"$majorName\") appears malformed."); + return NULL; + } + } + private function scanAvailablePackages(string $hint, array &$avail): void { + foreach ($this->scanner->scan($hint) as $package) { + /** @var Package $package */ + if (!isset($avail[$package->majorName]) || \version_compare($package->version, $avail[$package->majorName]->version, '>')) { + $avail[$package->majorName] = $package; + } + } + } + /** + * When loading a package, execute metadata files like "pathload.main.php" or "pathload.json". + * + * @param Package $package + * @param string $dir + * Ex: '/var/www/lib/cloud-io@1.2.0' + * Ex: 'phar:///var/www/lib/cloud-io@1.2.0.phar' + */ + private function useMetadataFiles(Package $package, string $dir): void { + $phpFile = "$dir/pathload.main.php"; + $jsonFile = "$dir/pathload.json"; + if (file_exists($phpFile)) { + require $phpFile; + } + elseif (file_exists($jsonFile)) { + $jsonData = json_decode(file_get_contents($jsonFile), TRUE); + $id = $package->name . '@' . $package->version; + $this->activatePackage($id, $dir, $jsonData); + } + } + /** + * Given a configuration for the package, activate the correspond autoloader rules. + * + * @param string $majorName + * Ex: 'cloud-io@1' + * @param string|null $dir + * Used for applying the 'autoload' rules. + * Ex: '/var/www/lib/cloud-io@1.2.3' + * @param array $config + * Ex: ['autoload' => ['psr4' => ...], 'require-namespace' => [...], 'require-package' => [...]] + * @return \PathLoadInterface + */ + public function activatePackage(string $majorName, ?string $dir, array $config): \PathLoadInterface { + if (isset($config['reloadable'])) { + $this->loadedPackages[$majorName]->reloadable = $config['reloadable']; + } + if (!isset($config['autoload'])) { + return $this; + } + if ($dir === NULL) { + throw new \RuntimeException("Cannot activate package $majorName. The 'autoload' property requires a base-directory."); + } + $this->activatedPackages[] = ['name' => $majorName, 'dir' => $dir, 'config' => $config]; + if (!empty($config['autoload']['include'])) { + foreach ($config['autoload']['include'] as $file) { + doRequire($dir . DIRECTORY_SEPARATOR . $file); + } + } + if (isset($config['autoload']['psr-0'])) { + $this->psr0->addAll($dir, $config['autoload']['psr-0']); + } + if (isset($config['autoload']['psr-4'])) { + $this->psr4->addAll($dir, $config['autoload']['psr-4']); + } + foreach ($config['require-namespace'] ?? [] as $nsRule) { + foreach ((array) $nsRule['package'] as $package) { + foreach ((array) $nsRule['prefix'] as $prefix) { + $this->availableNamespaces[$prefix][$package] = $package; + } + } + } + foreach ($config['require-package'] ?? [] as $package) { + $this->loadPackage($package); + } + return $this; + } + } + } +} + +namespace { + // New or upgraded instance. + $GLOBALS['_PathLoad'] = \PathLoad\V0\PathLoad::create(0, $GLOBALS['_PathLoad']['top'] ?? NULL); + if (!function_exists('pathload')) { + /** + * Get a reference the PathLoad manager. + * + * @param int|string $version + * @return \PathLoadInterface + */ + function pathload($version = 'top') { + return $GLOBALS['_PathLoad'][$version]; + } + } + return pathload(); +} diff --git a/mixin/lib/pathload.index.php b/mixin/lib/pathload.index.php new file mode 100644 index 000000000000..26b81a76767d --- /dev/null +++ b/mixin/lib/pathload.index.php @@ -0,0 +1,15 @@ +addSearchDir(__DIR__ . '/lib'); +// +// However, that would detect version#'s from the filenames. In this folder, +// we want all subprojects to have the same version-number as the main +// project. It would be quite inconvenient to rename them every month. +// +// So instead, we use `addSearchItem()` and register with explicit versions. + +$version = \CRM_Utils_System::version() . '.1'; /* Higher priority than contrib copies of same version... */ +\pathload()->addSearchItem('civimix-schema', $version, __DIR__ . '/civimix-schema'); diff --git a/schema/ACL/ACL.entityType.php b/schema/ACL/ACL.entityType.php new file mode 100644 index 000000000000..dac170ef598e --- /dev/null +++ b/schema/ACL/ACL.entityType.php @@ -0,0 +1,163 @@ + 'ACL', + 'table' => 'civicrm_acl', + 'class' => 'CRM_ACL_DAO_ACL', + 'getInfo' => fn() => [ + 'title' => ts('Acl'), + 'title_plural' => ts('Acls'), + 'description' => ts('Access Control List'), + 'add' => '1.6', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/acl/edit?reset=1&action=add', + 'delete' => 'civicrm/acl/delete?reset=1&action=delete&id=[id]', + 'update' => 'civicrm/acl/edit?reset=1&action=edit&id=[id]', + 'browse' => 'civicrm/acl', + ], + 'getIndices' => fn() => [ + 'index_acl_id' => [ + 'fields' => [ + 'acl_id' => TRUE, + ], + 'add' => '1.6', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('ACL ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique table ID'), + 'add' => '1.6', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('ACL Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('ACL Name.'), + 'add' => '1.6', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'deny' => [ + 'title' => ts('Deny ACL?'), + 'sql_type' => 'boolean', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Is this ACL entry Allow (0) or Deny (1) ?'), + 'add' => '1.6', + 'default' => FALSE, + ], + 'entity_table' => [ + 'title' => ts('ACL Entity'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Table of the object possessing this ACL entry (Contact, Group, or ACL Group)'), + 'add' => '1.6', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('ID of the object possessing this ACL'), + 'add' => '1.6', + 'pseudoconstant' => [ + 'option_group_name' => 'acl_role', + ], + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'operation' => [ + 'title' => ts('ACL Operation'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('What operation does this ACL entry control?'), + 'add' => '1.6', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_ACL_BAO_ACL::operation', + ], + ], + 'object_table' => [ + 'title' => ts('ACL Object'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('The table of the object controlled by this ACL entry'), + 'add' => '1.6', + 'input_attrs' => [ + 'label' => ts('Type of Data'), + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_ACL_BAO_ACL::getObjectTableOptions', + ], + ], + 'object_id' => [ + 'title' => ts('ACL Object ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('The ID of the object controlled by this ACL entry'), + 'add' => '1.6', + 'input_attrs' => [ + 'label' => ts('Which Data'), + 'control_field' => 'object_table', + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_ACL_BAO_ACL::getObjectIdOptions', + 'prefetch' => 'disabled', + ], + ], + 'acl_table' => [ + 'title' => ts('ACL Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('If this is a grant/revoke entry, what table are we granting?'), + 'add' => '1.6', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'acl_id' => [ + 'title' => ts('ACL Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('ID of the ACL or ACL group being granted/revoked'), + 'add' => '1.6', + ], + 'is_active' => [ + 'title' => ts('ACL Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property active?'), + 'add' => '1.6', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'priority' => [ + 'title' => ts('Priority'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '5.64', + 'default' => 0, + ], + ], +]; diff --git a/schema/ACL/ACLCache.entityType.php b/schema/ACL/ACLCache.entityType.php new file mode 100644 index 000000000000..190921a93dd9 --- /dev/null +++ b/schema/ACL/ACLCache.entityType.php @@ -0,0 +1,83 @@ + 'ACLCache', + 'table' => 'civicrm_acl_cache', + 'class' => 'CRM_ACL_DAO_ACLCache', + 'getInfo' => fn() => [ + 'title' => ts('Aclcache'), + 'title_plural' => ts('Aclcaches'), + 'description' => ts('Cache for acls and contacts'), + 'add' => '1.6', + ], + 'getIndices' => fn() => [ + 'index_contact_id' => [ + 'fields' => [ + 'contact_id' => TRUE, + ], + 'add' => '5.31', + ], + 'index_acl_id' => [ + 'fields' => [ + 'acl_id' => TRUE, + ], + 'add' => '1.6', + ], + 'index_modified_date' => [ + 'fields' => [ + 'modified_date' => TRUE, + ], + 'add' => '5.22', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Cache ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique table ID'), + 'add' => '1.6', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Foreign Key to Contact'), + 'add' => '1.6', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + ], + 'acl_id' => [ + 'title' => ts('ACL ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign Key to ACL'), + 'add' => '1.6', + 'input_attrs' => [ + 'label' => ts('ACL'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_acl', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'ACL', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'modified_date' => [ + 'title' => ts('Cache Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('When was this cache entry last modified'), + 'add' => '1.6', + ], + ], +]; diff --git a/schema/ACL/ACLEntityRole.entityType.php b/schema/ACL/ACLEntityRole.entityType.php new file mode 100644 index 000000000000..e6c2ae815fe0 --- /dev/null +++ b/schema/ACL/ACLEntityRole.entityType.php @@ -0,0 +1,95 @@ + 'ACLEntityRole', + 'table' => 'civicrm_acl_entity_role', + 'class' => 'CRM_ACL_DAO_ACLEntityRole', + 'getInfo' => fn() => [ + 'title' => ts('ACL Role Assignment'), + 'title_plural' => ts('ACL Role Assignments'), + 'description' => ts('Join table for Contacts and Groups to ACL Roles'), + 'add' => '1.6', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/acl/entityrole/edit?reset=1&action=add', + 'delete' => 'civicrm/acl/entityrole/edit?reset=1&action=delete&id=[id]', + 'update' => 'civicrm/acl/entityrole/edit?reset=1&action=update&id=[id]', + 'browse' => 'civicrm/acl/entityrole', + ], + 'getIndices' => fn() => [ + 'index_role' => [ + 'fields' => [ + 'acl_role_id' => TRUE, + ], + 'add' => '1.6', + ], + 'index_entity' => [ + 'fields' => [ + 'entity_table' => TRUE, + 'entity_id' => TRUE, + ], + 'add' => '1.6', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Entity Role'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique table ID'), + 'add' => '1.6', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'acl_role_id' => [ + 'title' => ts('ACL Role ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Foreign Key to ACL Role (which is an option value pair and hence an implicit FK)'), + 'add' => '1.6', + 'pseudoconstant' => [ + 'option_group_name' => 'acl_role', + ], + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Table of the object joined to the ACL Role (Contact or Group)'), + 'add' => '1.6', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_ACL_BAO_ACLEntityRole::entityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('ACL Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('ID of the group/contact object being joined'), + 'add' => '1.6', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'is_active' => [ + 'title' => ts('ACL Entity Role is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property active?'), + 'add' => '1.6', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Activity/Activity.entityType.php b/schema/Activity/Activity.entityType.php new file mode 100644 index 000000000000..39e8c5ceb6be --- /dev/null +++ b/schema/Activity/Activity.entityType.php @@ -0,0 +1,456 @@ + 'Activity', + 'table' => 'civicrm_activity', + 'class' => 'CRM_Activity_DAO_Activity', + 'getInfo' => fn() => [ + 'title' => ts('Activity'), + 'title_plural' => ts('Activities'), + 'description' => ts('Past or future actions concerning one or more contacts.'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-tasks', + 'label_field' => 'subject', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/activity?reset=1&action=add&context=standalone', + 'view' => 'civicrm/activity?reset=1&action=view&id=[id]', + 'update' => 'civicrm/activity/add?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/activity?reset=1&action=delete&id=[id]', + ], + 'getIndices' => fn() => [ + 'UI_source_record_id' => [ + 'fields' => [ + 'source_record_id' => TRUE, + ], + 'add' => '3.2', + ], + 'UI_activity_type_id' => [ + 'fields' => [ + 'activity_type_id' => TRUE, + ], + 'add' => '1.6', + ], + 'index_activity_date_time' => [ + 'fields' => [ + 'activity_date_time' => TRUE, + ], + 'add' => '4.7', + ], + 'index_status_id' => [ + 'fields' => [ + 'status_id' => TRUE, + ], + 'add' => '4.7', + ], + 'index_is_current_revision' => [ + 'fields' => [ + 'is_current_revision' => TRUE, + ], + 'add' => '2.2', + ], + 'index_is_deleted' => [ + 'fields' => [ + 'is_deleted' => TRUE, + ], + 'add' => '2.2', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Activity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Other Activity ID'), + 'add' => '1.1', + 'unique_name' => 'activity_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'source_record_id' => [ + 'title' => ts('Source Record'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Entity table is discovered by filtering by the appropriate activity_type_id.'), + 'add' => '2.0', + ], + 'activity_type_id' => [ + 'title' => ts('Activity Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to civicrm_option_value.id, that has to be valid, registered activity type.'), + 'add' => '1.1', + 'default' => 1, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Activity Type'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'activity_type', + ], + ], + 'subject' => [ + 'title' => ts('Subject'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('The subject/purpose/short description of the activity.'), + 'add' => '1.1', + 'unique_name' => 'activity_subject', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'activity_date_time' => [ + 'title' => ts('Activity Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.'), + 'add' => '2.0', + 'default' => 'CURRENT_TIMESTAMP', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'duration' => [ + 'title' => ts('Duration'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.'), + 'add' => '2.0', + 'unique_name' => 'activity_duration', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'location' => [ + 'title' => ts('Location'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Location of the activity (optional, open text).'), + 'add' => '1.1', + 'unique_name' => 'activity_location', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'phone_id' => [ + 'title' => ts('Phone ID (called)'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'deprecated' => TRUE, + 'description' => ts('Phone ID of the number called (optional - used if an existing phone number is selected).'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Phone (called)'), + ], + 'entity_reference' => [ + 'entity' => 'Phone', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'phone_number' => [ + 'title' => ts('Phone (called) Number'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'deprecated' => TRUE, + 'description' => ts('Phone number in case the number does not exist in the civicrm_phone table.'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'details' => [ + 'title' => ts('Details'), + 'sql_type' => 'longtext', + 'input_type' => 'RichTextEditor', + 'description' => ts('Details about the activity (agenda, notes, etc).'), + 'add' => '1.1', + 'unique_name' => 'activity_details', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 60, + ], + ], + 'status_id' => [ + 'title' => ts('Activity Status'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('ID of the status this activity is currently in. Foreign key to civicrm_option_value.'), + 'add' => '2.0', + 'unique_name' => 'activity_status_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'activity_status', + ], + ], + 'priority_id' => [ + 'title' => ts('Priority'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('ID of the priority given to this activity. Foreign key to civicrm_option_value.'), + 'add' => '2.0', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'priority', + ], + ], + 'parent_id' => [ + 'title' => ts('Parent Activity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Parent meeting ID (if this is a follow-up item).'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Parent Activity'), + ], + 'entity_reference' => [ + 'entity' => 'Activity', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_test' => [ + 'title' => ts('Test'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '2.0', + 'unique_name' => 'activity_is_test', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'medium_id' => [ + 'title' => ts('Activity Medium'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.'), + 'add' => '2.2', + 'unique_name' => 'activity_medium_id', + 'default' => NULL, + 'pseudoconstant' => [ + 'option_group_name' => 'encounter_medium', + ], + ], + 'is_auto' => [ + 'title' => ts('Auto'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '2.2', + 'default' => FALSE, + ], + 'relationship_id' => [ + 'title' => ts('Relationship ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'deprecated' => TRUE, + 'description' => ts('FK to Relationship ID'), + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Relationship'), + ], + 'entity_reference' => [ + 'entity' => 'Relationship', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_current_revision' => [ + 'title' => ts('Is current (unused)'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'deprecated' => TRUE, + 'description' => ts('Unused deprecated column.'), + 'add' => '2.2', + 'default' => TRUE, + ], + 'original_id' => [ + 'title' => ts('Original ID (unused)'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'deprecated' => TRUE, + 'readonly' => TRUE, + 'description' => ts('Unused deprecated column.'), + 'add' => '2.2', + 'input_attrs' => [ + 'label' => ts('Original Activity'), + ], + 'entity_reference' => [ + 'entity' => 'Activity', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'result' => [ + 'title' => ts('Result'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Currently being used to store result id for survey activity, FK to option value.'), + 'add' => '3.3', + 'unique_name' => 'activity_result', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_deleted' => [ + 'title' => ts('Activity is in the Trash'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '2.2', + 'unique_name' => 'activity_is_deleted', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The campaign for which this activity has been triggered.'), + 'add' => '3.4', + 'unique_name' => 'activity_campaign_id', + 'component' => 'CiviCampaign', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'engagement_level' => [ + 'title' => ts('Engagement Index'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.'), + 'add' => '3.4', + 'unique_name' => 'activity_engagement_level', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'engagement_index', + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'add' => '4.1', + ], + 'is_star' => [ + 'title' => ts('Is Starred'), + 'sql_type' => 'boolean', + 'input_type' => 'Checkbox', + 'required' => TRUE, + 'description' => ts('Activity marked as favorite.'), + 'add' => '4.7', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('When was the activity was created.'), + 'add' => '4.7', + 'unique_name' => 'activity_created_date', + 'default' => 'CURRENT_TIMESTAMP', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Created Date'), + ], + ], + 'modified_date' => [ + 'title' => ts('Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('When was the activity (or closely related entity) was created or modified or deleted.'), + 'add' => '4.7', + 'unique_name' => 'activity_modified_date', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Modified Date'), + ], + ], + ], +]; diff --git a/schema/Activity/ActivityContact.entityType.php b/schema/Activity/ActivityContact.entityType.php new file mode 100644 index 000000000000..d258dddbe61f --- /dev/null +++ b/schema/Activity/ActivityContact.entityType.php @@ -0,0 +1,94 @@ + 'ActivityContact', + 'table' => 'civicrm_activity_contact', + 'class' => 'CRM_Activity_DAO_ActivityContact', + 'getInfo' => fn() => [ + 'title' => ts('Activitycontact'), + 'title_plural' => ts('Activitycontacts'), + 'description' => ts('Activity Contact'), + 'log' => TRUE, + 'add' => '4.4', + ], + 'getIndices' => fn() => [ + 'UI_activity_contact' => [ + 'fields' => [ + 'contact_id' => TRUE, + 'activity_id' => TRUE, + 'record_type_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.4', + ], + 'index_record_type' => [ + 'fields' => [ + 'activity_id' => TRUE, + 'record_type_id' => TRUE, + ], + 'add' => '4.4', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Activity Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Activity contact id'), + 'add' => '4.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'activity_id' => [ + 'title' => ts('Activity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to the activity for this record.'), + 'add' => '4.4', + 'input_attrs' => [ + 'label' => ts('Activity'), + ], + 'entity_reference' => [ + 'entity' => 'Activity', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to the contact for this record.'), + 'add' => '4.4', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'record_type_id' => [ + 'title' => ts('Activity Contact Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => 'Determines the contact\'s role in the activity (source, target, or assignee).', + 'add' => '4.4', + 'input_attrs' => [ + 'label' => ts('Contact Role'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'activity_contacts', + ], + ], + ], +]; diff --git a/schema/Batch/Batch.entityType.php b/schema/Batch/Batch.entityType.php new file mode 100644 index 000000000000..489b43a32e53 --- /dev/null +++ b/schema/Batch/Batch.entityType.php @@ -0,0 +1,198 @@ + 'Batch', + 'table' => 'civicrm_batch', + 'class' => 'CRM_Batch_DAO_Batch', + 'getInfo' => fn() => [ + 'title' => ts('Batch'), + 'title_plural' => ts('Batches'), + 'description' => ts('Stores the details of a batch operation Used primarily when doing batch operations with an external system.'), + 'add' => '3.3', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.2', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Batch ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Address ID'), + 'add' => '3.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Batch Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Variable name/programmatic handle for this batch.'), + 'add' => '3.3', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'title' => [ + 'title' => ts('Batch Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Friendly Name.'), + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Batch Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description of this batch set.'), + 'add' => '3.3', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 80, + ], + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('Batch Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('When was this item created'), + 'add' => '3.3', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'modified_id' => [ + 'title' => ts('Modified By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Modified By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'modified_date' => [ + 'title' => ts('Batch Modified Date'), + 'sql_type' => 'datetime', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('When was this item modified'), + 'add' => '3.3', + ], + 'saved_search_id' => [ + 'title' => ts('Smart Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Saved Search ID'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Smart Group'), + ], + 'entity_reference' => [ + 'entity' => 'SavedSearch', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'status_id' => [ + 'title' => ts('Batch Status'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('fk to Batch Status options in civicrm_option_values'), + 'add' => '4.2', + 'pseudoconstant' => [ + 'option_group_name' => 'batch_status', + ], + ], + 'type_id' => [ + 'title' => ts('Batch Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('fk to Batch Type options in civicrm_option_values'), + 'add' => '4.2', + 'pseudoconstant' => [ + 'option_group_name' => 'batch_type', + ], + ], + 'mode_id' => [ + 'title' => ts('Batch Mode'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('fk to Batch mode options in civicrm_option_values'), + 'add' => '4.2', + 'pseudoconstant' => [ + 'option_group_name' => 'batch_mode', + ], + ], + 'total' => [ + 'title' => ts('Batch Total'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'description' => ts('Total amount for this batch.'), + 'add' => '4.2', + ], + 'item_count' => [ + 'title' => ts('Batch Number of Items'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Number of items in a batch.'), + 'add' => '4.2', + ], + 'payment_instrument_id' => [ + 'title' => ts('Batch Payment Method'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('fk to Payment Instrument options in civicrm_option_values'), + 'add' => '4.3', + 'pseudoconstant' => [ + 'option_group_name' => 'payment_instrument', + ], + ], + 'exported_date' => [ + 'title' => ts('Batch Exported Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'add' => '4.3', + ], + 'data' => [ + 'title' => ts('Batch Data'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('cache entered data'), + 'add' => '4.4', + ], + ], +]; diff --git a/schema/Batch/EntityBatch.entityType.php b/schema/Batch/EntityBatch.entityType.php new file mode 100644 index 000000000000..9f14e086b052 --- /dev/null +++ b/schema/Batch/EntityBatch.entityType.php @@ -0,0 +1,89 @@ + 'EntityBatch', + 'table' => 'civicrm_entity_batch', + 'class' => 'CRM_Batch_DAO_EntityBatch', + 'getInfo' => fn() => [ + 'title' => ts('Entitybatch'), + 'title_plural' => ts('Entitybatches'), + 'description' => ts('Batch entities (Contributions, Participants, Contacts) to a batch.'), + 'add' => '3.3', + ], + 'getIndices' => fn() => [ + 'index_entity' => [ + 'fields' => [ + 'entity_table' => TRUE, + 'entity_id' => TRUE, + ], + 'add' => '3.3', + ], + 'UI_batch_entity' => [ + 'fields' => [ + 'batch_id' => TRUE, + 'entity_id' => TRUE, + 'entity_table' => TRUE, + ], + 'unique' => TRUE, + 'add' => '3.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('EntityBatch ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('primary key'), + 'add' => '3.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('EntityBatch Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('physical tablename for entity being joined to file, e.g. civicrm_contact'), + 'add' => '3.3', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'entity_batch_extends', + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to entity table specified in entity_table column.'), + 'add' => '3.3', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'batch_id' => [ + 'title' => ts('Batch ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to civicrm_batch'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Batch'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_batch', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'Batch', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Campaign/Campaign.entityType.php b/schema/Campaign/Campaign.entityType.php new file mode 100644 index 000000000000..7a3f8217858e --- /dev/null +++ b/schema/Campaign/Campaign.entityType.php @@ -0,0 +1,302 @@ + 'Campaign', + 'table' => 'civicrm_campaign', + 'class' => 'CRM_Campaign_DAO_Campaign', + 'getInfo' => fn() => [ + 'title' => ts('Campaign'), + 'title_plural' => ts('Campaigns'), + 'description' => ts('Campaigns link activities, contributions, mailings, etc. that share a programmatic goal.'), + 'add' => '3.3', + 'icon' => 'fa-bullhorn', + 'label_field' => 'title', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/campaign/add?reset=1', + 'update' => 'civicrm/campaign/add?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/campaign/add?reset=1&action=delete&id=[id]', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '5.63', + ], + 'index_campaign_type_id' => [ + 'fields' => [ + 'campaign_type_id' => TRUE, + ], + 'add' => '5.63', + ], + 'index_status_id' => [ + 'fields' => [ + 'status_id' => TRUE, + ], + 'add' => '5.63', + ], + 'UI_external_identifier' => [ + 'fields' => [ + 'external_identifier' => TRUE, + ], + 'unique' => TRUE, + 'add' => '3.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Campaign ID.'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Campaign Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name of the Campaign.'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Name'), + 'maxlength' => 255, + ], + ], + 'title' => [ + 'title' => ts('Campaign Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Title of the Campaign.'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Title'), + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Campaign Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Full description of Campaign.'), + 'add' => '3.3', + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 60, + 'label' => ts('Description'), + ], + ], + 'start_date' => [ + 'title' => ts('Campaign Start Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that Campaign starts.'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Start Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'end_date' => [ + 'title' => ts('Campaign End Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that Campaign ends.'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('End Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'campaign_type_id' => [ + 'title' => ts('Campaign Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'), + 'add' => '3.3', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Type'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'campaign_type', + ], + ], + 'status_id' => [ + 'title' => ts('Campaign Status'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'), + 'add' => '3.3', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Status'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'campaign_status', + ], + ], + 'external_identifier' => [ + 'title' => ts('Campaign External ID'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Text', + 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('External ID'), + 'maxlength' => 32, + ], + ], + 'parent_id' => [ + 'title' => ts('Parent Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Optional parent id for this Campaign.'), + 'add' => '3.3', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Parent Campaign'), + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_active' => [ + 'title' => ts('Is Campaign Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this Campaign enabled or disabled/cancelled?'), + 'add' => '3.3', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => [ + 'Enabled', + 'Enabled', + ], + ], + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who created this Campaign.'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('Campaign Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('Date and time that Campaign was created.'), + 'add' => '3.3', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + 'label' => ts('Created Date'), + ], + ], + 'last_modified_id' => [ + 'title' => ts('Modified By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Modified By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'last_modified_date' => [ + 'title' => ts('Campaign Modified Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that Campaign was edited last time.'), + 'add' => '3.3', + ], + 'goal_general' => [ + 'title' => ts('Campaign Goals'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'description' => ts('General goals for Campaign.'), + 'add' => '3.4', + ], + 'goal_revenue' => [ + 'title' => ts('Goal Revenue'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'description' => ts('The target revenue for this campaign.'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Goal Revenue'), + ], + ], + ], +]; diff --git a/schema/Campaign/CampaignGroup.entityType.php b/schema/Campaign/CampaignGroup.entityType.php new file mode 100644 index 000000000000..cae1e5739b5f --- /dev/null +++ b/schema/Campaign/CampaignGroup.entityType.php @@ -0,0 +1,83 @@ + 'CampaignGroup', + 'table' => 'civicrm_campaign_group', + 'class' => 'CRM_Campaign_DAO_CampaignGroup', + 'getInfo' => fn() => [ + 'title' => ts('Campaigngroup'), + 'title_plural' => ts('Campaigngroups'), + 'description' => ts('Campaign Group Details.'), + 'add' => '3.3', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Campaign Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Campaign Group id.'), + 'add' => '3.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to the activity Campaign.'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'group_type' => [ + 'title' => ts('Campaign Group Type'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Type of Group.'), + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getCampaignGroupTypes', + ], + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Name of table where item being referenced is stored.'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Entity id of referenced table.'), + 'add' => '3.3', + 'default' => NULL, + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + ], +]; diff --git a/schema/Campaign/Survey.entityType.php b/schema/Campaign/Survey.entityType.php new file mode 100644 index 000000000000..eec9d365cff2 --- /dev/null +++ b/schema/Campaign/Survey.entityType.php @@ -0,0 +1,255 @@ + 'Survey', + 'table' => 'civicrm_survey', + 'class' => 'CRM_Campaign_DAO_Survey', + 'getInfo' => fn() => [ + 'title' => ts('Survey'), + 'title_plural' => ts('Surveys'), + 'description' => ts('Campaign Survey Details.'), + 'add' => '3.2', + 'icon' => 'fa-clipboard', + 'label_field' => 'title', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/survey/add?reset=1', + 'update' => 'civicrm/survey/configure/main?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/survey/delete?reset=1&id=[id]', + ], + 'getIndices' => fn() => [ + 'UI_activity_type_id' => [ + 'fields' => [ + 'activity_type_id' => TRUE, + ], + 'add' => '3.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Survey ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Survey id.'), + 'add' => '3.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'title' => [ + 'title' => ts('Survey Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Title of the Survey.'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Foreign key to the Campaign.'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'activity_type_id' => [ + 'title' => ts('Activity Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Implicit FK to civicrm_option_value where option_group = activity_type'), + 'add' => '3.3', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'activity_type', + ], + ], + 'instructions' => [ + 'title' => ts('Instructions'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Script instructions for volunteers to use for the survey.'), + 'add' => '3.3', + 'input_attrs' => [ + 'rows' => 20, + 'cols' => 80, + ], + ], + 'release_frequency' => [ + 'title' => ts('Survey Hold Duration'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Number of days for recurrence of release.'), + 'add' => '3.3', + 'default' => NULL, + ], + 'max_number_of_contacts' => [ + 'title' => ts('Maximum number of contacts'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Maximum number of contacts to allow for survey.'), + 'add' => '3.3', + 'default' => NULL, + ], + 'default_number_of_contacts' => [ + 'title' => ts('Default number of contacts'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Default number of contacts to allow for survey.'), + 'add' => '3.3', + 'default' => NULL, + ], + 'is_active' => [ + 'title' => ts('Survey Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this survey enabled or disabled/cancelled?'), + 'add' => '3.3', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_default' => [ + 'title' => ts('Is Default Survey'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this default survey?'), + 'add' => '3.3', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who created this Survey.'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('Campaign Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that Survey was created.'), + 'add' => '3.3', + ], + 'last_modified_id' => [ + 'title' => ts('Modified By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who recently edited this Survey.'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Modified By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'last_modified_date' => [ + 'title' => ts('Survey Modified On'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that Survey was edited last time.'), + 'add' => '3.3', + ], + 'result_id' => [ + 'title' => ts('Survey Result'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Used to store option group id.'), + 'add' => '3.3', + 'default' => NULL, + 'pseudoconstant' => [ + 'table' => 'civicrm_option_group', + 'key_column' => 'id', + 'label_column' => 'title', + 'name_column' => 'name', + 'condition' => 'name LIKE "civicrm_survey_%"', + ], + ], + 'bypass_confirm' => [ + 'title' => ts('No Email Verification'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Bypass the email verification.'), + 'add' => '4.2', + 'default' => FALSE, + ], + 'thankyou_title' => [ + 'title' => ts('Thank-you Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Title for Thank-you page (header title tag, and display at the top of the page).'), + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'thankyou_text' => [ + 'title' => ts('Thank-you Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('text and html allowed. displayed above result on success page'), + 'add' => '4.2', + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 60, + ], + ], + 'is_share' => [ + 'title' => ts('Is shared through social media'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Can people share the petition through social media?'), + 'add' => '4.4', + 'default' => TRUE, + ], + ], +]; diff --git a/schema/Case/Case.entityType.php b/schema/Case/Case.entityType.php new file mode 100644 index 000000000000..c88fe8d7f1f4 --- /dev/null +++ b/schema/Case/Case.entityType.php @@ -0,0 +1,200 @@ + 'Case', + 'table' => 'civicrm_case', + 'class' => 'CRM_Case_DAO_Case', + 'getInfo' => fn() => [ + 'title' => ts('Case'), + 'title_plural' => ts('Cases'), + 'description' => ts('Collections of activities and relationships for a given purpose.'), + 'log' => TRUE, + 'add' => '1.8', + 'icon' => 'fa-folder-open', + 'label_field' => 'subject', + ], + 'getPaths' => fn() => [ + 'view' => 'civicrm/contact/view/case?action=view&reset=1&id=[id]', + ], + 'getIndices' => fn() => [ + 'index_case_type_id' => [ + 'fields' => [ + 'case_type_id' => TRUE, + ], + 'add' => '2.0', + ], + 'index_is_deleted' => [ + 'fields' => [ + 'is_deleted' => TRUE, + ], + 'add' => '2.2', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Case ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Case ID'), + 'add' => '1.8', + 'unique_name' => 'case_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'case_type_id' => [ + 'title' => ts('Case Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to civicrm_case_type.id'), + 'add' => '2.0', + 'usage' => [ + 'import', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Case Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_case_type', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'CaseType', + 'key' => 'id', + ], + ], + 'subject' => [ + 'title' => ts('Case Subject'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Short name of the case.'), + 'add' => '1.8', + 'unique_name' => 'case_subject', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'start_date' => [ + 'title' => ts('Case Start Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Date on which given case starts.'), + 'add' => '1.8', + 'unique_name' => 'case_start_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'end_date' => [ + 'title' => ts('Case End Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Date on which given case ends.'), + 'add' => '1.8', + 'unique_name' => 'case_end_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'details' => [ + 'title' => ts('Details'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Details populated from Open Case. Only used in the CiviCase extension.'), + 'add' => '1.8', + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 60, + 'label' => ts('Details'), + ], + ], + 'status_id' => [ + 'title' => ts('Case Status'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('ID of case status.'), + 'add' => '1.8', + 'unique_name' => 'case_status_id', + 'usage' => [ + 'import', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'control_field' => 'case_type_id', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'case_status', + ], + ], + 'is_deleted' => [ + 'title' => ts('Case is in the Trash'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '2.2', + 'unique_name' => 'case_deleted', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('When was the case was created.'), + 'add' => '4.7', + 'unique_name' => 'case_created_date', + 'default' => NULL, + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Created Date'), + ], + ], + 'modified_date' => [ + 'title' => ts('Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('When was the case (or closely related entity) was created or modified or deleted.'), + 'add' => '4.7', + 'unique_name' => 'case_modified_date', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Modified Date'), + ], + ], + ], +]; diff --git a/schema/Case/CaseActivity.entityType.php b/schema/Case/CaseActivity.entityType.php new file mode 100644 index 000000000000..614265521949 --- /dev/null +++ b/schema/Case/CaseActivity.entityType.php @@ -0,0 +1,67 @@ + 'CaseActivity', + 'table' => 'civicrm_case_activity', + 'class' => 'CRM_Case_DAO_CaseActivity', + 'getInfo' => fn() => [ + 'title' => ts('Caseactivity'), + 'title_plural' => ts('Caseactivities'), + 'description' => ts('Joining table for case-activity associations.'), + 'log' => TRUE, + 'add' => '1.8', + ], + 'getIndices' => fn() => [ + 'UI_case_activity_id' => [ + 'fields' => [ + 'case_id' => TRUE, + 'activity_id' => TRUE, + ], + 'add' => '2.0', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Case Activity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique case-activity association id'), + 'add' => '1.8', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'case_id' => [ + 'title' => ts('Case ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Case ID of case-activity association.'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Case'), + ], + 'entity_reference' => [ + 'entity' => 'Case', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'activity_id' => [ + 'title' => ts('Activity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Activity ID of case-activity association.'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Activity'), + ], + 'entity_reference' => [ + 'entity' => 'Activity', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Case/CaseContact.entityType.php b/schema/Case/CaseContact.entityType.php new file mode 100644 index 000000000000..a29ff513bcbd --- /dev/null +++ b/schema/Case/CaseContact.entityType.php @@ -0,0 +1,68 @@ + 'CaseContact', + 'table' => 'civicrm_case_contact', + 'class' => 'CRM_Case_DAO_CaseContact', + 'getInfo' => fn() => [ + 'title' => ts('Casecontact'), + 'title_plural' => ts('Casecontacts'), + 'description' => ts('Joining table for case-contact associations.'), + 'log' => TRUE, + 'add' => '2.1', + ], + 'getIndices' => fn() => [ + 'UI_case_contact_id' => [ + 'fields' => [ + 'case_id' => TRUE, + 'contact_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Case Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique case-contact association id'), + 'add' => '2.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'case_id' => [ + 'title' => ts('Case ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Case ID of case-contact association.'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Case'), + ], + 'entity_reference' => [ + 'entity' => 'Case', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Contact ID of contact record given case belongs to.'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Case/CaseType.entityType.php b/schema/Case/CaseType.entityType.php new file mode 100644 index 000000000000..7fa1be759b6b --- /dev/null +++ b/schema/Case/CaseType.entityType.php @@ -0,0 +1,106 @@ + 'CaseType', + 'table' => 'civicrm_case_type', + 'class' => 'CRM_Case_DAO_CaseType', + 'getInfo' => fn() => [ + 'title' => ts('Casetype'), + 'title_plural' => ts('Casetypes'), + 'description' => ts('Case type definition'), + 'log' => TRUE, + 'add' => '4.5', + ], + 'getIndices' => fn() => [ + 'case_type_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.5', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Case Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Autoincremented type id'), + 'add' => '4.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Case Type Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Machine name for Case Type'), + 'add' => '4.5', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'title' => [ + 'title' => ts('Case Type Title'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Natural language name for Case Type'), + 'add' => '4.5', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Case Type Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Description of the Case Type'), + 'add' => '4.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_active' => [ + 'title' => ts('Case Type Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this case type enabled?'), + 'add' => '4.5', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_reserved' => [ + 'title' => ts('Case Type Is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this case type a predefined system type?'), + 'add' => '4.5', + 'default' => FALSE, + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Ordering of the case types'), + 'add' => '4.5', + 'default' => 1, + ], + 'definition' => [ + 'title' => ts('Case Type Definition'), + 'sql_type' => 'blob', + 'input_type' => NULL, + 'description' => ts('xml definition of case type'), + 'add' => '4.5', + ], + ], +]; diff --git a/schema/Contact/ACLContactCache.entityType.php b/schema/Contact/ACLContactCache.entityType.php new file mode 100644 index 000000000000..499de1552c24 --- /dev/null +++ b/schema/Contact/ACLContactCache.entityType.php @@ -0,0 +1,68 @@ + 'ACLContactCache', + 'table' => 'civicrm_acl_contact_cache', + 'class' => 'CRM_Contact_DAO_ACLContactCache', + 'getInfo' => fn() => [ + 'title' => ts('Aclcontactcache'), + 'title_plural' => ts('Aclcontactcaches'), + 'description' => ts('Join table cache for contacts that a user has permission on.'), + 'add' => '3.1', + ], + 'getIndices' => fn() => [ + 'UI_user_contact_operation' => [ + 'fields' => [ + 'user_id' => TRUE, + 'contact_id' => TRUE, + 'operation' => TRUE, + ], + 'unique' => TRUE, + 'add' => '3.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('ACL Contact Cache ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('primary key'), + 'add' => '3.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'user_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('FK to civicrm_contact (could be null for anon user)'), + 'add' => '3.1', + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('FK to civicrm_contact'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + ], + 'operation' => [ + 'title' => ts('Operation'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('What operation does this user have permission on?'), + 'add' => '1.6', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_ACL_BAO_ACL::operation', + ], + ], + ], +]; diff --git a/schema/Contact/Contact.entityType.php b/schema/Contact/Contact.entityType.php new file mode 100644 index 000000000000..69f0f4eeabe5 --- /dev/null +++ b/schema/Contact/Contact.entityType.php @@ -0,0 +1,992 @@ + 'Contact', + 'table' => 'civicrm_contact', + 'class' => 'CRM_Contact_DAO_Contact', + 'getInfo' => fn() => [ + 'title' => ts('Contact'), + 'title_plural' => ts('Contacts'), + 'description' => ts('Individuals, organizations, households, etc.'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-address-book-o', + 'label_field' => 'display_name', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/contact/add?reset=1&ct=[contact_type]', + 'view' => 'civicrm/contact/view?reset=1&cid=[id]', + 'update' => 'civicrm/contact/add?reset=1&action=update&cid=[id]', + 'delete' => 'civicrm/contact/view/delete?reset=1&delete=1&cid=[id]', + ], + 'getIndices' => fn() => [ + 'index_contact_type' => [ + 'fields' => [ + 'contact_type' => TRUE, + ], + 'add' => '2.1', + ], + 'UI_external_identifier' => [ + 'fields' => [ + 'external_identifier' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.7', + ], + 'index_organization_name' => [ + 'fields' => [ + 'organization_name' => TRUE, + ], + 'add' => '1.8', + ], + 'index_contact_sub_type' => [ + 'fields' => [ + 'contact_sub_type' => TRUE, + ], + 'add' => '2.1', + ], + 'index_first_name' => [ + 'fields' => [ + 'first_name' => TRUE, + ], + 'add' => '1.8', + ], + 'index_last_name' => [ + 'fields' => [ + 'last_name' => TRUE, + ], + 'add' => '1.8', + ], + 'index_sort_name' => [ + 'fields' => [ + 'sort_name' => TRUE, + ], + 'add' => '2.1', + ], + 'index_preferred_communication_method' => [ + 'fields' => [ + 'preferred_communication_method' => TRUE, + ], + 'add' => '1.6', + ], + 'index_hash' => [ + 'fields' => [ + 'hash' => TRUE, + ], + 'add' => '2.1', + ], + 'index_api_key' => [ + 'fields' => [ + 'api_key' => TRUE, + ], + 'add' => '2.1', + ], + 'UI_prefix' => [ + 'fields' => [ + 'prefix_id' => TRUE, + ], + 'add' => '1.6', + ], + 'UI_suffix' => [ + 'fields' => [ + 'suffix_id' => TRUE, + ], + 'add' => '1.6', + ], + 'index_communication_style_id' => [ + 'fields' => [ + 'communication_style_id' => TRUE, + ], + 'add' => '4.4', + ], + 'UI_gender' => [ + 'fields' => [ + 'gender_id' => TRUE, + ], + 'add' => '1.6', + ], + 'index_is_deceased' => [ + 'fields' => [ + 'is_deceased' => TRUE, + ], + 'add' => '4.7', + ], + 'index_household_name' => [ + 'fields' => [ + 'household_name' => TRUE, + ], + 'add' => '1.8', + ], + 'index_is_deleted_sort_name' => [ + 'fields' => [ + 'is_deleted' => TRUE, + 'sort_name' => TRUE, + 'id' => TRUE, + ], + 'add' => '4.4', + ], + 'index_created_date' => [ + 'fields' => [ + 'created_date' => TRUE, + ], + 'add' => '5.18', + ], + 'index_modified_date' => [ + 'fields' => [ + 'modified_date' => TRUE, + ], + 'add' => '5.18', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Contact ID'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_type' => [ + 'title' => ts('Contact Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'readonly' => TRUE, + 'description' => ts('Type of Contact.'), + 'add' => '1.1', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_contact_type', + 'key_column' => 'name', + 'label_column' => 'label', + 'icon_column' => 'icon', + 'condition' => 'parent_id IS NULL', + ], + ], + 'external_identifier' => [ + 'title' => ts('External Identifier'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '8', + 'label' => ts('External Identifier'), + 'maxlength' => 64, + ], + ], + 'display_name' => [ + 'title' => ts('Display Name'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'readonly' => TRUE, + 'description' => ts('Formatted name representing preferred format for display/print/other output.'), + 'add' => '1.1', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'size' => '30', + 'maxlength' => 128, + ], + ], + 'organization_name' => [ + 'title' => ts('Organization Name'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Organization Name.'), + 'add' => '1.1', + 'contact_type' => 'Organization', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'label' => ts('Organization Name'), + 'maxlength' => 128, + ], + ], + 'contact_sub_type' => [ + 'title' => ts('Contact Subtype'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'description' => ts('May be used to over-ride contact view and edit templates.'), + 'add' => '1.5', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'multiple' => '1', + 'control_field' => 'contact_type', + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_contact_type', + 'key_column' => 'name', + 'label_column' => 'label', + 'icon_column' => 'icon', + 'condition' => 'parent_id IS NOT NULL', + ], + ], + 'first_name' => [ + 'title' => ts('First Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('First Name.'), + 'add' => '1.1', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'label' => ts('First Name'), + 'maxlength' => 64, + ], + ], + 'middle_name' => [ + 'title' => ts('Middle Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Middle Name.'), + 'add' => '1.1', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'label' => ts('Middle Name'), + 'maxlength' => 64, + ], + ], + 'last_name' => [ + 'title' => ts('Last Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Last Name.'), + 'add' => '1.1', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'label' => ts('Last Name'), + 'maxlength' => 64, + ], + ], + 'do_not_email' => [ + 'title' => ts('Do Not Email'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '1.1', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Do Not Email'), + ], + ], + 'do_not_phone' => [ + 'title' => ts('Do Not Phone'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '1.1', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Do Not Phone'), + ], + ], + 'do_not_mail' => [ + 'title' => ts('Do Not Mail'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '1.1', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Do Not Mail'), + ], + ], + 'do_not_sms' => [ + 'title' => ts('Do Not Sms'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '3.0', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Do Not Sms'), + ], + ], + 'do_not_trade' => [ + 'title' => ts('Do Not Trade'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '1.1', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Do Not Trade'), + ], + ], + 'is_opt_out' => [ + 'title' => ts('No Bulk Emails (User Opt Out)'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'), + 'add' => '1.1', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Is Opt Out'), + ], + ], + 'legal_identifier' => [ + 'title' => ts('Legal Identifier'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Text', + 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Legal Identifier'), + 'maxlength' => 32, + ], + ], + 'sort_name' => [ + 'title' => ts('Sort Name'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'readonly' => TRUE, + 'description' => ts('Name used for sorting different contact types'), + 'add' => '1.1', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'size' => '30', + 'maxlength' => 128, + ], + ], + 'nick_name' => [ + 'title' => ts('Nickname'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Nickname.'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'maxlength' => 128, + ], + ], + 'legal_name' => [ + 'title' => ts('Legal Name'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Legal Name.'), + 'add' => '1.1', + 'contact_type' => 'Organization', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'label' => ts('Legal Name'), + 'maxlength' => 128, + ], + ], + 'image_URL' => [ + 'title' => ts('Image Url'), + 'sql_type' => 'text', + 'input_type' => 'File', + 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'label' => ts('Image'), + ], + ], + 'preferred_communication_method' => [ + 'title' => ts('Preferred Communication Method'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'description' => ts('What is the preferred mode of communication.'), + 'add' => '1.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'multiple' => '1', + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'preferred_communication_method', + ], + ], + 'preferred_language' => [ + 'title' => ts('Preferred Language'), + 'sql_type' => 'varchar(5)', + 'input_type' => 'Select', + 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'), + 'add' => '3.2', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 5, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'languages', + 'key_column' => 'name', + ], + ], + 'hash' => [ + 'title' => ts('Contact Hash'), + 'sql_type' => 'varchar(32)', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Key for validating requests related to this contact.'), + 'add' => '1.1', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 32, + ], + ], + 'api_key' => [ + 'title' => ts('Api Key'), + 'sql_type' => 'varchar(32)', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('API Key for validating requests related to this contact.'), + 'add' => '2.2', + 'permission' => [ + [ + 'administer CiviCRM', + 'edit api keys', + ], + ], + 'input_attrs' => [ + 'label' => ts('API KEY'), + 'maxlength' => 32, + ], + ], + 'source' => [ + 'title' => ts('Contact Source'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('where contact come from, e.g. import, donate module insert...'), + 'add' => '1.1', + 'unique_name' => 'contact_source', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'maxlength' => 255, + ], + ], + 'prefix_id' => [ + 'title' => ts('Individual Prefix'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'), + 'add' => '1.2', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'individual_prefix', + ], + ], + 'suffix_id' => [ + 'title' => ts('Individual Suffix'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'), + 'add' => '1.2', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'individual_suffix', + ], + ], + 'formal_title' => [ + 'title' => ts('Formal Title'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'), + 'add' => '4.5', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Formal Title'), + 'maxlength' => 64, + ], + ], + 'communication_style_id' => [ + 'title' => ts('Communication Style'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'), + 'add' => '4.4', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'communication_style', + ], + ], + 'email_greeting_id' => [ + 'title' => ts('Email Greeting ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'), + 'add' => '3.0', + 'usage' => [ + 'export', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'email_greeting', + ], + ], + 'email_greeting_custom' => [ + 'title' => ts('Email Greeting Custom'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Custom Email Greeting.'), + 'add' => '3.0', + 'usage' => [ + 'import', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Email Greeting Custom'), + 'maxlength' => 128, + ], + ], + 'email_greeting_display' => [ + 'title' => ts('Email Greeting'), + 'sql_type' => 'varchar(255)', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Cache Email Greeting.'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'postal_greeting_id' => [ + 'title' => ts('Postal Greeting ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'), + 'add' => '3.0', + 'usage' => [ + 'export', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'postal_greeting', + ], + ], + 'postal_greeting_custom' => [ + 'title' => ts('Postal Greeting Custom'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Custom Postal greeting.'), + 'add' => '3.0', + 'usage' => [ + 'import', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Postal Greeting Custom'), + 'maxlength' => 128, + ], + ], + 'postal_greeting_display' => [ + 'title' => ts('Postal Greeting'), + 'sql_type' => 'varchar(255)', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Cache Postal greeting.'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'addressee_id' => [ + 'title' => ts('Addressee ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'), + 'add' => '3.0', + 'usage' => [ + 'export', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'addressee', + ], + ], + 'addressee_custom' => [ + 'title' => ts('Addressee Custom'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Custom Addressee.'), + 'add' => '3.0', + 'usage' => [ + 'import', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Addressee Custom'), + 'maxlength' => 128, + ], + ], + 'addressee_display' => [ + 'title' => ts('Addressee'), + 'sql_type' => 'varchar(255)', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Cache Addressee.'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'job_title' => [ + 'title' => ts('Job Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Job Title'), + 'add' => '1.1', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'label' => ts('Job Title'), + 'maxlength' => 255, + ], + ], + 'gender_id' => [ + 'title' => ts('Gender ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to gender ID'), + 'add' => '1.2', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Gender'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'gender', + ], + ], + 'birth_date' => [ + 'title' => ts('Birth Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Date of birth'), + 'add' => '1.1', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'birth', + 'label' => ts('Birth Date'), + ], + ], + 'is_deceased' => [ + 'title' => ts('Deceased'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '1.1', + 'contact_type' => 'Individual', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Is Deceased'), + ], + ], + 'deceased_date' => [ + 'title' => ts('Deceased Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Date of deceased'), + 'add' => '1.5', + 'contact_type' => 'Individual', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'birth', + 'label' => ts('Deceased Date'), + ], + ], + 'household_name' => [ + 'title' => ts('Household Name'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Household Name.'), + 'add' => '1.1', + 'contact_type' => 'Household', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'label' => ts('Household Name'), + 'maxlength' => 128, + ], + ], + 'primary_contact_id' => [ + 'title' => ts('Household Primary Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Optional FK to Primary Contact for this household.'), + 'add' => '1.1', + 'contact_type' => 'Household', + 'input_attrs' => [ + 'label' => ts('Household Primary Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'sic_code' => [ + 'title' => ts('Sic Code'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Text', + 'description' => ts('Standard Industry Classification Code.'), + 'add' => '1.1', + 'contact_type' => 'Organization', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('SIC Code'), + 'maxlength' => 8, + ], + ], + 'user_unique_id' => [ + 'title' => ts('Unique ID (OpenID)'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'deprecated' => TRUE, + 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'), + 'add' => '2.0', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'employer_id' => [ + 'title' => ts('Current Employer ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('OPTIONAL FK to civicrm_contact record.'), + 'add' => '2.1', + 'unique_name' => 'current_employer_id', + 'contact_type' => 'Individual', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Current Employer'), + 'filter' => 'contact_type=Organization', + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_deleted' => [ + 'title' => ts('Contact is in Trash'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '3.2', + 'unique_name' => 'contact_is_deleted', + 'default' => FALSE, + 'usage' => [ + 'export', + ], + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('When was the contact was created.'), + 'add' => '4.3', + 'default' => NULL, + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + 'label' => ts('Created Date'), + ], + ], + 'modified_date' => [ + 'title' => ts('Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'), + 'add' => '4.3', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + 'label' => ts('Modified Date'), + ], + ], + 'preferred_mail_format' => [ + 'title' => ts('Preferred Mail Format'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'deprecated' => TRUE, + 'description' => ts('Deprecated setting for text vs html mailings'), + 'add' => '1.1', + 'default' => 'Both', + 'input_attrs' => [ + 'label' => ts('Preferred Mail Format'), + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::pmf', + ], + ], + ], +]; diff --git a/schema/Contact/ContactType.entityType.php b/schema/Contact/ContactType.entityType.php new file mode 100644 index 000000000000..53bf05463001 --- /dev/null +++ b/schema/Contact/ContactType.entityType.php @@ -0,0 +1,139 @@ + 'ContactType', + 'table' => 'civicrm_contact_type', + 'class' => 'CRM_Contact_DAO_ContactType', + 'getInfo' => fn() => [ + 'title' => ts('Contacttype'), + 'title_plural' => ts('Contacttypes'), + 'description' => ts('Provide type information for contacts'), + 'add' => '3.1', + 'label_field' => 'label', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/options/subtype/edit?action=add&reset=1', + 'update' => 'civicrm/admin/options/subtype/edit?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/options/subtype/edit?action=delete&id=[id]&reset=1', + 'browse' => 'civicrm/admin/options/subtype', + ], + 'getIndices' => fn() => [ + 'contact_type' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '3.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Contact Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Contact Type ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Internal name of Contact Type (or Subtype).'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Name'), + 'maxlength' => 64, + ], + ], + 'label' => [ + 'title' => ts('Contact Type Label'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('localized Name of Contact Type.'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Label'), + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Contact Type Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('localized Optional verbose description of the type.'), + 'add' => '3.1', + 'input_attrs' => [ + 'rows' => 2, + 'cols' => 60, + ], + ], + 'image_URL' => [ + 'title' => ts('Contact Type Image URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('URL of image if any.'), + 'add' => '3.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'icon' => [ + 'title' => ts('Icon'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('crm-i icon class representing this contact type'), + 'add' => '5.49', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'parent_id' => [ + 'title' => ts('Parent ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Optional FK to parent contact type.'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Parent'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_contact_type', + 'key_column' => 'id', + 'label_column' => 'label', + 'condition' => 'parent_id IS NULL', + ], + 'entity_reference' => [ + 'entity' => 'ContactType', + 'key' => 'id', + ], + ], + 'is_active' => [ + 'title' => ts('Contact Type Enabled'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this entry active?'), + 'add' => '3.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_reserved' => [ + 'title' => ts('Contact Type is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this contact type a predefined system type'), + 'add' => '3.1', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Contact/DashboardContact.entityType.php b/schema/Contact/DashboardContact.entityType.php new file mode 100644 index 000000000000..c326193cc230 --- /dev/null +++ b/schema/Contact/DashboardContact.entityType.php @@ -0,0 +1,97 @@ + 'DashboardContact', + 'table' => 'civicrm_dashboard_contact', + 'class' => 'CRM_Contact_DAO_DashboardContact', + 'getInfo' => fn() => [ + 'title' => ts('Dashboardcontact'), + 'title_plural' => ts('Dashboardcontacts'), + 'description' => ts('Table to store dashboard for each contact.'), + 'add' => '3.1', + ], + 'getIndices' => fn() => [ + 'index_dashboard_id_contact_id' => [ + 'fields' => [ + 'dashboard_id' => TRUE, + 'contact_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.7', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Dashboard Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '3.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'dashboard_id' => [ + 'title' => ts('Dashboard ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Dashboard ID'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Dashboard'), + ], + 'entity_reference' => [ + 'entity' => 'Dashboard', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Contact ID'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'column_no' => [ + 'title' => ts('Column No'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('column no for this widget'), + 'add' => '3.1', + 'default' => 0, + 'input_attrs' => [ + 'label' => ts('Column Number'), + ], + ], + 'is_active' => [ + 'title' => ts('Dashlet is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this widget active?'), + 'add' => '3.1', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Ordering of the widgets.'), + 'add' => '3.1', + 'default' => 0, + ], + ], +]; diff --git a/schema/Contact/Group.entityType.php b/schema/Contact/Group.entityType.php new file mode 100644 index 000000000000..416828b34424 --- /dev/null +++ b/schema/Contact/Group.entityType.php @@ -0,0 +1,326 @@ + 'Group', + 'table' => 'civicrm_group', + 'class' => 'CRM_Contact_DAO_Group', + 'getInfo' => fn() => [ + 'title' => ts('Group'), + 'title_plural' => ts('Groups'), + 'description' => ts('Provide grouping of related contacts'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-users', + 'label_field' => 'title', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/group/add?reset=1', + 'view' => 'civicrm/group/search?force=1&context=smog&gid=[id]&component_mode=1', + 'update' => 'civicrm/group/edit?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/group/edit?reset=1&action=delete&id=[id]', + 'browse' => 'civicrm/group', + ], + 'getIndices' => fn() => [ + 'UI_cache_date' => [ + 'fields' => [ + 'cache_date' => TRUE, + ], + 'add' => '5.34', + ], + 'index_group_type' => [ + 'fields' => [ + 'group_type' => TRUE, + ], + 'add' => '1.9', + ], + 'UI_title' => [ + 'fields' => [ + 'title' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Group ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Group Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Internal name of Group.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'title' => [ + 'title' => ts('Group Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Name of Group.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Group Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Optional verbose description of the group.'), + 'add' => '1.1', + 'input_attrs' => [ + 'rows' => 2, + 'cols' => 60, + ], + ], + 'source' => [ + 'title' => ts('Group Source'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Module or process which created this group.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'saved_search_id' => [ + 'title' => ts('Saved Search ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to saved search table.'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Saved Search'), + ], + 'entity_reference' => [ + 'entity' => 'SavedSearch', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'is_active' => [ + 'title' => ts('Group Enabled'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this group active?'), + 'add' => '1.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'visibility' => [ + 'title' => ts('Group Visibility Setting'), + 'sql_type' => 'varchar(24)', + 'input_type' => 'Select', + 'description' => ts('In what context(s) is this field visible.'), + 'add' => '1.2', + 'default' => 'User and User Admin Only', + 'input_attrs' => [ + 'maxlength' => 24, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::groupVisibility', + ], + ], + 'where_clause' => [ + 'title' => ts('Group Where Clause'), + 'sql_type' => 'text', + 'input_type' => NULL, + 'deprecated' => TRUE, + 'readonly' => TRUE, + 'description' => ts('the sql where clause if a saved search acl'), + 'add' => '1.6', + ], + 'select_tables' => [ + 'title' => ts('Tables For Select Clause'), + 'sql_type' => 'text', + 'input_type' => NULL, + 'deprecated' => TRUE, + 'readonly' => TRUE, + 'description' => ts('the tables to be included in a select data'), + 'add' => '1.6', + 'serialize' => CRM_Core_DAO::SERIALIZE_PHP, + ], + 'where_tables' => [ + 'title' => ts('Tables For Where Clause'), + 'sql_type' => 'text', + 'input_type' => NULL, + 'deprecated' => TRUE, + 'readonly' => TRUE, + 'description' => ts('the tables to be included in the count statement'), + 'add' => '1.6', + 'serialize' => CRM_Core_DAO::SERIALIZE_PHP, + ], + 'group_type' => [ + 'title' => ts('Group Type'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('FK to group type'), + 'add' => '1.9', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, + 'input_attrs' => [ + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'group_type', + ], + ], + 'cache_date' => [ + 'title' => ts('Group Cache Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Date when we created the cache for a smart group'), + 'add' => '2.1', + ], + 'cache_fill_took' => [ + 'title' => ts('Seconds taken by last cache fill'), + 'sql_type' => 'double', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Seconds taken to fill smart group cache'), + 'add' => '5.67', + ], + 'refresh_date' => [ + 'title' => ts('Next Group Refresh Time'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'deprecated' => TRUE, + 'readonly' => TRUE, + 'description' => ts('Unused deprecated column.'), + 'add' => '4.3', + ], + 'parents' => [ + 'title' => ts('Group Parents'), + 'sql_type' => 'text', + 'input_type' => 'EntityRef', + 'description' => ts('List of parent groups'), + 'add' => '2.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'input_attrs' => [ + 'label' => ts('Parent Groups'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_group', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + ], + 'children' => [ + 'title' => ts('Group Children'), + 'sql_type' => 'text', + 'input_type' => 'EntityRef', + 'readonly' => TRUE, + 'description' => ts('List of child groups (calculated)'), + 'add' => '2.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'input_attrs' => [ + 'label' => ts('Child Groups'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_group', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + ], + 'is_hidden' => [ + 'title' => ts('Group is Hidden'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this group hidden?'), + 'add' => '2.2', + 'default' => FALSE, + ], + 'is_reserved' => [ + 'title' => ts('Group is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '4.2', + 'default' => FALSE, + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to contact table.'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'modified_id' => [ + 'title' => ts('Modified By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('FK to contact table.'), + 'add' => '4.5', + 'input_attrs' => [ + 'label' => ts('Modified By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'frontend_title' => [ + 'title' => ts('Public Group Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Alternative public title for this Group.'), + 'add' => '5.31', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'frontend_description' => [ + 'title' => ts('Public Group Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Alternative public description of the group.'), + 'add' => '5.31', + 'default' => NULL, + 'input_attrs' => [ + 'rows' => 2, + 'cols' => 60, + ], + ], + ], +]; diff --git a/schema/Contact/GroupContact.entityType.php b/schema/Contact/GroupContact.entityType.php new file mode 100644 index 000000000000..967aaf3b4507 --- /dev/null +++ b/schema/Contact/GroupContact.entityType.php @@ -0,0 +1,115 @@ + 'GroupContact', + 'table' => 'civicrm_group_contact', + 'class' => 'CRM_Contact_DAO_GroupContact', + 'getInfo' => fn() => [ + 'title' => ts('Groupcontact'), + 'title_plural' => ts('Groupcontacts'), + 'description' => 'Join table sets membership for \'static\' groups. Also used to store \'opt-out\' entries for \'query\' type groups (status = \'OUT\')', + 'log' => TRUE, + 'add' => '1.1', + ], + 'getIndices' => fn() => [ + 'UI_contact_group' => [ + 'fields' => [ + 'contact_id' => TRUE, + 'group_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.6', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Group Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('primary key'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'group_id' => [ + 'title' => ts('Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to civicrm_group'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Group'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_group', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to civicrm_contact'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'status' => [ + 'title' => ts('Group Contact Status'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('status of contact relative to membership in group'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::groupContactStatus', + ], + ], + 'location_id' => [ + 'title' => ts('Location ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Optional location to associate with this membership'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Location'), + ], + 'entity_reference' => [ + 'entity' => 'LocBlock', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'email_id' => [ + 'title' => ts('Email ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Optional email to associate with this membership'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Email'), + ], + 'entity_reference' => [ + 'entity' => 'Email', + 'key' => 'id', + ], + ], + ], +]; diff --git a/schema/Contact/GroupContactCache.entityType.php b/schema/Contact/GroupContactCache.entityType.php new file mode 100644 index 000000000000..c59c493f3f66 --- /dev/null +++ b/schema/Contact/GroupContactCache.entityType.php @@ -0,0 +1,72 @@ + 'GroupContactCache', + 'table' => 'civicrm_group_contact_cache', + 'class' => 'CRM_Contact_DAO_GroupContactCache', + 'getInfo' => fn() => [ + 'title' => ts('Groupcontactcache'), + 'title_plural' => ts('Groupcontactcaches'), + 'description' => 'Join table cache for \'static\' groups.', + 'add' => '2.1', + ], + 'getIndices' => fn() => [ + 'UI_contact_group' => [ + 'fields' => [ + 'contact_id' => TRUE, + 'group_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Group Contact Cache ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('primary key'), + 'add' => '2.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'group_id' => [ + 'title' => ts('Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to civicrm_group'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Group'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_group', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to civicrm_contact'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Contact/GroupNesting.entityType.php b/schema/Contact/GroupNesting.entityType.php new file mode 100644 index 000000000000..0202ea848260 --- /dev/null +++ b/schema/Contact/GroupNesting.entityType.php @@ -0,0 +1,58 @@ + 'GroupNesting', + 'table' => 'civicrm_group_nesting', + 'class' => 'CRM_Contact_DAO_GroupNesting', + 'getInfo' => fn() => [ + 'title' => ts('Groupnesting'), + 'title_plural' => ts('Groupnestings'), + 'description' => ts('Provide parent-child relationships for groups'), + 'log' => TRUE, + 'add' => '2.0', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Group Nesting ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Relationship ID'), + 'add' => '2.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'child_group_id' => [ + 'title' => ts('Child Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('ID of the child group'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Child Group'), + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'parent_group_id' => [ + 'title' => ts('Parent Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('ID of the parent group'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Parent Group'), + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Contact/GroupOrganization.entityType.php b/schema/Contact/GroupOrganization.entityType.php new file mode 100644 index 000000000000..f796d06d8f02 --- /dev/null +++ b/schema/Contact/GroupOrganization.entityType.php @@ -0,0 +1,73 @@ + 'GroupOrganization', + 'table' => 'civicrm_group_organization', + 'class' => 'CRM_Contact_DAO_GroupOrganization', + 'getInfo' => fn() => [ + 'title' => ts('Grouporganization'), + 'title_plural' => ts('Grouporganizations'), + 'description' => ts('Integrate Organization information into Groups'), + 'log' => TRUE, + 'add' => '2.0', + ], + 'getIndices' => fn() => [ + 'UI_group_organization' => [ + 'fields' => [ + 'group_id' => TRUE, + 'organization_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.0', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Group Organization ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Relationship ID'), + 'add' => '2.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'group_id' => [ + 'title' => ts('Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('ID of the group'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Group'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_group', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'organization_id' => [ + 'title' => ts('Organization ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('ID of the Organization Contact'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Organization'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Contact/Relationship.entityType.php b/schema/Contact/Relationship.entityType.php new file mode 100644 index 000000000000..9fdc9f3d1b37 --- /dev/null +++ b/schema/Contact/Relationship.entityType.php @@ -0,0 +1,199 @@ + 'Relationship', + 'table' => 'civicrm_relationship', + 'class' => 'CRM_Contact_DAO_Relationship', + 'getInfo' => fn() => [ + 'title' => ts('Relationship'), + 'title_plural' => ts('Relationships'), + 'description' => ts('Relationship between any 2 types of contacts.'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-handshake-o', + ], + 'getPaths' => fn() => [ + 'view' => 'civicrm/contact/view/rel?action=view&reset=1&cid=[contact_id_a]&id=[id]', + 'delete' => 'civicrm/contact/view/rel?action=delete&reset=1&cid=[contact_id_a]&id=[id]', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Relationship ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Relationship ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id_a' => [ + 'title' => ts('Contact A ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('id of the first contact'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Contact A'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id_b' => [ + 'title' => ts('Contact B ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('id of the second contact'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Contact B'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'relationship_type_id' => [ + 'title' => ts('Relationship Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Type of relationship'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Relationship Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_relationship_type', + 'key_column' => 'id', + 'name_column' => 'name_a_b', + 'label_column' => 'label_a_b', + ], + 'entity_reference' => [ + 'entity' => 'RelationshipType', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'start_date' => [ + 'title' => ts('Relationship Start Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('date when the relationship started'), + 'add' => '1.1', + 'unique_name' => 'relationship_start_date', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'end_date' => [ + 'title' => ts('Relationship End Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('date when the relationship ended'), + 'add' => '1.1', + 'unique_name' => 'relationship_end_date', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'is_active' => [ + 'title' => ts('Relationship Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('is the relationship active ?'), + 'add' => '1.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'description' => [ + 'title' => ts('Relationship Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Optional verbose description for the relationship.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_permission_a_b' => [ + 'title' => ts('Contact A has Permission Over Contact B'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Permission that Contact A has to view/update Contact B'), + 'add' => '2.1', + 'default' => 0, + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions', + 'suffixes' => [ + 'name', + 'label', + 'icon', + ], + ], + ], + 'is_permission_b_a' => [ + 'title' => ts('Contact B has Permission Over Contact A'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Permission that Contact B has to view/update Contact A'), + 'add' => '2.1', + 'default' => 0, + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions', + 'suffixes' => [ + 'name', + 'label', + 'icon', + ], + ], + ], + 'case_id' => [ + 'title' => ts('Case ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_case'), + 'add' => '2.2', + 'component' => 'CiviCase', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Case'), + ], + 'entity_reference' => [ + 'entity' => 'Case', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('Relationship created date.'), + 'add' => '5.47', + 'default' => 'CURRENT_TIMESTAMP', + ], + 'modified_date' => [ + 'title' => ts('Relationship Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('Relationship last modified.'), + 'add' => '5.47', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + ], + ], +]; diff --git a/schema/Contact/RelationshipCache.entityType.php b/schema/Contact/RelationshipCache.entityType.php new file mode 100644 index 000000000000..e0d5028c21aa --- /dev/null +++ b/schema/Contact/RelationshipCache.entityType.php @@ -0,0 +1,231 @@ + 'RelationshipCache', + 'table' => 'civicrm_relationship_cache', + 'class' => 'CRM_Contact_DAO_RelationshipCache', + 'getInfo' => fn() => [ + 'title' => ts('Related Contact'), + 'title_plural' => ts('Related Contacts'), + 'description' => ts('The cache permutes information from the relationship table to facilitate querying. Every relationship is mapped to multiple records in the cache. Joins should begin on the near side and extract info from the far side.'), + 'log' => FALSE, + 'add' => '5.29', + 'icon' => 'fa-handshake-o', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/contact/view/rel?cid=[near_contact_id]&action=add&reset=1', + 'view' => 'civicrm/contact/view/rel?action=view&reset=1&cid=[near_contact_id]&id=[relationship_id]', + 'update' => 'civicrm/contact/view/rel?action=update&reset=1&cid=[near_contact_id]&id=[relationship_id]&rtype=[orientation]', + 'delete' => 'civicrm/contact/view/rel?action=delete&reset=1&cid=[near_contact_id]&id=[relationship_id]', + ], + 'getIndices' => fn() => [ + 'UI_relationship' => [ + 'fields' => [ + 'relationship_id' => TRUE, + 'orientation' => TRUE, + ], + 'unique' => TRUE, + 'add' => '5.29', + ], + 'index_nearid_nearrelation' => [ + 'fields' => [ + 'near_contact_id' => TRUE, + 'near_relation' => TRUE, + ], + 'add' => '5.29', + ], + 'index_nearid_farrelation' => [ + 'fields' => [ + 'near_contact_id' => TRUE, + 'far_relation' => TRUE, + ], + 'add' => '5.29', + ], + 'index_near_relation' => [ + 'fields' => [ + 'near_relation' => TRUE, + ], + 'add' => '5.29', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Relationship Cache ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Relationship Cache ID'), + 'add' => '5.29', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'relationship_id' => [ + 'title' => ts('Relationship ID'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'), + 'add' => '5.29', + 'input_attrs' => [ + 'label' => ts('Relationship'), + ], + 'entity_reference' => [ + 'entity' => 'Relationship', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'relationship_type_id' => [ + 'title' => ts('Relationship Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('id of the relationship type'), + 'add' => '5.29', + 'input_attrs' => [ + 'label' => ts('Relationship Type'), + ], + 'entity_reference' => [ + 'entity' => 'RelationshipType', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'orientation' => [ + 'title' => ts('Orientation (a_b or b_a)'), + 'sql_type' => 'char(3)', + 'input_type' => NULL, + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.'), + 'add' => '5.29', + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::relationshipOrientation', + ], + ], + 'near_contact_id' => [ + 'title' => ts('Contact ID (Near side)'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('id of the first contact'), + 'add' => '5.29', + 'input_attrs' => [ + 'label' => ts('Contact (Near side)'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'near_relation' => [ + 'title' => ts('Relationship Name (to related contact)'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'readonly' => TRUE, + 'description' => ts('name for relationship of near_contact to far_contact.'), + 'add' => '5.29', + 'input_attrs' => [ + 'label' => ts('Relationship to contact'), + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions', + ], + ], + 'far_contact_id' => [ + 'title' => ts('Contact ID (Far side)'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('id of the second contact'), + 'add' => '5.29', + 'input_attrs' => [ + 'label' => ts('Contact (Far side)'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'far_relation' => [ + 'title' => ts('Relationship Name (from related contact)'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'readonly' => TRUE, + 'description' => ts('name for relationship of far_contact to near_contact.'), + 'add' => '5.29', + 'input_attrs' => [ + 'label' => ts('Relationship from contact'), + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions', + ], + ], + 'is_active' => [ + 'title' => ts('Relationship Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('is the relationship active ?'), + 'add' => '5.29', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'start_date' => [ + 'title' => ts('Relationship Start Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('date when the relationship started'), + 'add' => '5.29', + 'unique_name' => 'relationship_start_date', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'end_date' => [ + 'title' => ts('Relationship End Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('date when the relationship ended'), + 'add' => '5.29', + 'unique_name' => 'relationship_end_date', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'case_id' => [ + 'title' => ts('Case ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'readonly' => TRUE, + 'description' => ts('FK to civicrm_case'), + 'add' => '5.44', + 'component' => 'CiviCase', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Case'), + ], + 'entity_reference' => [ + 'entity' => 'Case', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Contact/RelationshipType.entityType.php b/schema/Contact/RelationshipType.entityType.php new file mode 100644 index 000000000000..95f1001bedf0 --- /dev/null +++ b/schema/Contact/RelationshipType.entityType.php @@ -0,0 +1,188 @@ + 'RelationshipType', + 'table' => 'civicrm_relationship_type', + 'class' => 'CRM_Contact_DAO_RelationshipType', + 'getInfo' => fn() => [ + 'title' => ts('Relationshiptype'), + 'title_plural' => ts('Relationshiptypes'), + 'description' => 'Relationship types s/b structured with contact_a as the \'subject/child\' contact and contact_b as the \'object/parent\' contact (e.g. Individual A is Employee of Org B).', + 'log' => TRUE, + 'add' => '1.1', + 'label_field' => 'label_a_b', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/reltype/edit?action=add&reset=1', + 'view' => 'civicrm/admin/reltype/edit?action=view&id=[id]&reset=1', + 'update' => 'civicrm/admin/reltype/edit?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/reltype/edit?action=delete&id=[id]&reset=1', + 'browse' => 'civicrm/admin/reltype', + ], + 'getIndices' => fn() => [ + 'UI_name_a_b' => [ + 'fields' => [ + 'name_a_b' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + 'UI_name_b_a' => [ + 'fields' => [ + 'name_b_a' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Relationship Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Primary key'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name_a_b' => [ + 'title' => ts('Relationship Type Name A to B'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('name for relationship of contact_a to contact_b.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'label_a_b' => [ + 'title' => ts('Relationship Type Label A to B'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('label for relationship of contact_a to contact_b.'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'name_b_a' => [ + 'title' => ts('Relationship Type Name B to A'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Optional name for relationship of contact_b to contact_a.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'label_b_a' => [ + 'title' => ts('Relationship Type Label B to A'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Optional label for relationship of contact_b to contact_a.'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Relationship Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Optional verbose description of the relationship type.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'contact_type_a' => [ + 'title' => ts('Contact Type for Contact A'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Select', + 'description' => ts('If defined, contact_a in a relationship of this type must be a specific contact_type.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 12, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_contact_type', + 'key_column' => 'name', + 'label_column' => 'label', + 'condition' => 'parent_id IS NULL', + ], + ], + 'contact_type_b' => [ + 'title' => ts('Contact Type for Contact B'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Select', + 'description' => ts('If defined, contact_b in a relationship of this type must be a specific contact_type.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 12, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_contact_type', + 'key_column' => 'name', + 'label_column' => 'label', + 'condition' => 'parent_id IS NULL', + ], + ], + 'contact_sub_type_a' => [ + 'title' => ts('Contact Subtype A'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.'), + 'add' => '3.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_contact_type', + 'key_column' => 'name', + 'label_column' => 'label', + 'condition' => 'parent_id IS NOT NULL', + ], + ], + 'contact_sub_type_b' => [ + 'title' => ts('Contact Subtype B'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.'), + 'add' => '3.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_contact_type', + 'key_column' => 'name', + 'label_column' => 'label', + 'condition' => 'parent_id IS NOT NULL', + ], + ], + 'is_reserved' => [ + 'title' => ts('Relationship Type is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'is_active' => [ + 'title' => ts('Relationship Type is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?'), + 'add' => '1.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Contact/SavedSearch.entityType.php b/schema/Contact/SavedSearch.entityType.php new file mode 100644 index 000000000000..b9804c6b4b12 --- /dev/null +++ b/schema/Contact/SavedSearch.entityType.php @@ -0,0 +1,190 @@ + 'SavedSearch', + 'table' => 'civicrm_saved_search', + 'class' => 'CRM_Contact_DAO_SavedSearch', + 'getInfo' => fn() => [ + 'title' => ts('Savedsearch'), + 'title_plural' => ts('Savedsearches'), + 'description' => ts('Users can save their complex SQL queries and use them later.'), + 'add' => '1.1', + 'icon' => 'fa-search-plus', + 'label_field' => 'label', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '5.32', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Saved Search ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Saved Search ID'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Saved Search Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Unique name of saved search'), + 'add' => '1.0', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Name'), + 'maxlength' => 255, + ], + ], + 'label' => [ + 'title' => ts('Saved Search Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Administrative label for search'), + 'add' => '5.32', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Label'), + 'maxlength' => 255, + ], + ], + 'form_values' => [ + 'title' => ts('Submitted Form Values'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Submitted form values for this search'), + 'add' => '1.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_PHP, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'mapping_id' => [ + 'title' => ts('Mapping ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Mapping'), + ], + 'entity_reference' => [ + 'entity' => 'Mapping', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'search_custom_id' => [ + 'title' => ts('Option Value ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'), + 'add' => '2.0', + ], + 'api_entity' => [ + 'title' => ts('Entity Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'description' => ts('Entity name for API based search'), + 'add' => '5.24', + 'input_attrs' => [ + 'label' => ts('For'), + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Contact_BAO_SavedSearch::getApiEntityOptions', + ], + ], + 'api_params' => [ + 'title' => ts('API Parameters'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Parameters for API based search'), + 'add' => '5.24', + 'serialize' => CRM_Core_DAO::SERIALIZE_JSON, + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('FK to contact table.'), + 'add' => '5.36', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'modified_id' => [ + 'title' => ts('Modified By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('FK to contact table.'), + 'add' => '5.36', + 'input_attrs' => [ + 'label' => ts('Modified By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'expires_date' => [ + 'title' => ts('Search Expiry Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('Optional date after which the search is not needed'), + 'add' => '5.36', + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('When the search was created.'), + 'add' => '5.36', + 'default' => 'CURRENT_TIMESTAMP', + ], + 'modified_date' => [ + 'title' => ts('Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('When the search was last modified.'), + 'add' => '5.36', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + ], + 'description' => [ + 'title' => ts('Saved Search Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'add' => '5.36', + 'input_attrs' => [ + 'label' => ts('Description'), + 'rows' => 2, + 'cols' => 60, + ], + ], + ], +]; diff --git a/schema/Contact/SubscriptionHistory.entityType.php b/schema/Contact/SubscriptionHistory.entityType.php new file mode 100644 index 000000000000..fdb2f3ee04cf --- /dev/null +++ b/schema/Contact/SubscriptionHistory.entityType.php @@ -0,0 +1,111 @@ + 'SubscriptionHistory', + 'table' => 'civicrm_subscription_history', + 'class' => 'CRM_Contact_DAO_SubscriptionHistory', + 'getInfo' => fn() => [ + 'title' => ts('Subscriptionhistory'), + 'title_plural' => ts('Subscriptionhistories'), + 'description' => ts('History information of subscribe/unsubscribe actions'), + 'log' => TRUE, + 'add' => '1.1', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Group Membership History ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Internal ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Contact ID'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'group_id' => [ + 'title' => ts('Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Group ID'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Group'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_group', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'date' => [ + 'title' => ts('Group Membership Action Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'description' => ts('Date of the (un)subscription'), + 'add' => '1.1', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'label' => ts('Group Membership Action Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'method' => [ + 'title' => ts('Group Membership Action'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('How the (un)subscription was triggered'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods', + ], + ], + 'status' => [ + 'title' => ts('Group Membership Status'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('The state of the contact within the group'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::groupContactStatus', + ], + ], + 'tracking' => [ + 'title' => ts('Group Membership Tracking'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('IP address or other tracking info'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + ], +]; diff --git a/schema/Contribute/Contribution.entityType.php b/schema/Contribute/Contribution.entityType.php new file mode 100644 index 000000000000..49712fc05f14 --- /dev/null +++ b/schema/Contribute/Contribution.entityType.php @@ -0,0 +1,606 @@ + 'Contribution', + 'table' => 'civicrm_contribution', + 'class' => 'CRM_Contribute_DAO_Contribution', + 'getInfo' => fn() => [ + 'title' => ts('Contribution'), + 'title_plural' => ts('Contributions'), + 'description' => ts('Financial records consisting of transactions, line-items, etc.'), + 'log' => TRUE, + 'add' => '1.3', + 'icon' => 'fa-credit-card', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/contribute/add?reset=1&action=add&context=standalone', + 'view' => 'civicrm/contact/view/contribution?reset=1&action=view&id=[id]', + 'update' => 'civicrm/contact/view/contribution?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/contact/view/contribution?reset=1&action=delete&id=[id]', + ], + 'getIndices' => fn() => [ + 'UI_contrib_payment_instrument_id' => [ + 'fields' => [ + 'payment_instrument_id' => TRUE, + ], + 'add' => '1.6', + ], + 'index_total_amount_receive_date' => [ + 'fields' => [ + 'total_amount' => TRUE, + 'receive_date' => TRUE, + ], + 'add' => '4.7', + ], + 'index_source' => [ + 'fields' => [ + 'source' => TRUE, + ], + 'add' => '4.7', + ], + 'UI_contrib_trxn_id' => [ + 'fields' => [ + 'trxn_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + 'UI_contrib_invoice_id' => [ + 'fields' => [ + 'invoice_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + 'index_contribution_status' => [ + 'fields' => [ + 'contribution_status_id' => TRUE, + ], + 'add' => '1.6', + ], + 'received_date' => [ + 'fields' => [ + 'receive_date' => TRUE, + ], + 'add' => '1.6', + ], + 'check_number' => [ + 'fields' => [ + 'check_number' => TRUE, + ], + 'add' => '2.2', + ], + 'index_creditnote_id' => [ + 'fields' => [ + 'creditnote_id' => TRUE, + ], + 'add' => '4.7', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Contribution ID'), + 'add' => '1.3', + 'unique_name' => 'contribution_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact ID'), + 'add' => '1.3', + 'unique_name' => 'contribution_contact_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to Financial Type for (total_amount - non_deductible_amount).'), + 'add' => '4.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + ], + ], + 'contribution_page_id' => [ + 'title' => ts('Contribution Page ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('The Contribution Page which triggered this contribution'), + 'add' => '1.5', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Contribution Page'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_contribution_page', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'ContributionPage', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'payment_instrument_id' => [ + 'title' => ts('Payment Method ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to Payment Instrument'), + 'add' => '1.3', + 'unique_name' => 'payment_instrument_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Payment Method'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'payment_instrument', + ], + ], + 'receive_date' => [ + 'title' => ts('Contribution Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'add' => '1.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'non_deductible_amount' => [ + 'title' => ts('Non-deductible Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'description' => ts('Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.'), + 'add' => '1.3', + 'default' => '0', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'total_amount' => [ + 'title' => ts('Total Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Total amount of this contribution. Use market value for non-monetary gifts.'), + 'add' => '1.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Total Amount'), + ], + ], + 'fee_amount' => [ + 'title' => ts('Fee Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'description' => ts('actual processor fee if known - may be 0.'), + 'add' => '1.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Fee Amount'), + ], + ], + 'net_amount' => [ + 'title' => ts('Net Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'description' => ts('actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.'), + 'add' => '1.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Net Amount'), + ], + ], + 'trxn_id' => [ + 'title' => ts('Transaction ID'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'readonly' => TRUE, + 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'), + 'add' => '1.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'invoice_id' => [ + 'title' => ts('Invoice Reference'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'readonly' => TRUE, + 'description' => ts('unique invoice id, system generated or passed in'), + 'add' => '1.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'invoice_number' => [ + 'title' => ts('Invoice Number'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Human readable invoice number'), + 'add' => '4.7', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'currency' => [ + 'title' => ts('Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '1.3', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Currency'), + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'cancel_date' => [ + 'title' => ts('Cancelled / Refunded Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('when was gift cancelled'), + 'add' => '1.3', + 'unique_name' => 'contribution_cancel_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'cancel_reason' => [ + 'title' => ts('Cancellation / Refund Reason'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'add' => '1.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '40', + ], + ], + 'receipt_date' => [ + 'title' => ts('Receipt Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('when (if) receipt was sent. populated automatically for online donations w/ automatic receipting'), + 'add' => '1.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + 'label' => ts('Receipt Date'), + ], + ], + 'thankyou_date' => [ + 'title' => ts('Thank-you Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('when (if) was donor thanked'), + 'add' => '1.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'source' => [ + 'title' => ts('Contribution Source'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Origin of this Contribution.'), + 'add' => '1.3', + 'unique_name' => 'contribution_source', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'amount_level' => [ + 'title' => ts('Amount Label'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'add' => '1.7', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'contribution_recur_id' => [ + 'title' => ts('Recurring Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'readonly' => TRUE, + 'description' => ts('Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.'), + 'add' => '1.4', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Recurring Contribution'), + ], + 'entity_reference' => [ + 'entity' => 'ContributionRecur', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_test' => [ + 'title' => ts('Test'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'is_pay_later' => [ + 'title' => ts('Is Pay Later'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '2.1', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'contribution_status_id' => [ + 'title' => ts('Contribution Status ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'add' => '1.6', + 'default' => 1, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Contribution Status'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'contribution_status', + ], + ], + 'address_id' => [ + 'title' => ts('Address ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.'), + 'add' => '2.2', + 'unique_name' => 'contribution_address_id', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Address'), + ], + 'entity_reference' => [ + 'entity' => 'Address', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'check_number' => [ + 'title' => ts('Check Number'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '2.2', + 'unique_name' => 'contribution_check_number', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '6', + 'maxlength' => 255, + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The campaign for which this contribution has been triggered.'), + 'add' => '3.4', + 'unique_name' => 'contribution_campaign_id', + 'component' => 'CiviCampaign', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'creditnote_id' => [ + 'title' => ts('Credit Note ID'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('unique credit note id, system generated or passed in'), + 'add' => '4.6', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'tax_amount' => [ + 'title' => ts('Tax Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Total tax amount of this contribution.'), + 'add' => '4.6', + 'default' => '0', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'revenue_recognition_date' => [ + 'title' => ts('Revenue Recognition Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Stores the date when revenue should be recognized.'), + 'add' => '4.7', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + 'label' => ts('Revenue Recognition Date'), + ], + ], + 'is_template' => [ + 'title' => ts('Is a Template Contribution'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('Shows this is a template for recurring contributions.'), + 'add' => '5.20', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + ], +]; diff --git a/schema/Contribute/ContributionPage.entityType.php b/schema/Contribute/ContributionPage.entityType.php new file mode 100644 index 000000000000..c164b24757f5 --- /dev/null +++ b/schema/Contribute/ContributionPage.entityType.php @@ -0,0 +1,538 @@ + 'ContributionPage', + 'table' => 'civicrm_contribution_page', + 'class' => 'CRM_Contribute_DAO_ContributionPage', + 'getInfo' => fn() => [ + 'title' => ts('Contributionpage'), + 'title_plural' => ts('Contributionpages'), + 'description' => ts('A Contribution object store meta information about a single customized contribution page'), + 'log' => TRUE, + 'add' => '1.3', + 'label_field' => 'title', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/contribute/add?reset=1&action=add', + 'update' => 'civicrm/admin/contribute/settings?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/admin/contribute/manage?reset=1&action=delete&id=[id]', + 'browse' => 'civicrm/admin/contribute', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Contribution Page ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Contribution ID'), + 'add' => '1.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'title' => [ + 'title' => ts('Page Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Contribution Page title. For top of page display'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'frontend_title' => [ + 'title' => ts('Public Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Contribution Page Public title'), + 'add' => '5.20', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'name' => [ + 'title' => ts('Unique Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Unique name for identifying contribution page'), + 'add' => '5.63', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'intro_text' => [ + 'title' => ts('Contribution Page Introduction Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Text and html allowed. Displayed below title.'), + 'add' => '1.3', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('default financial type assigned to contributions submitted via this page, e.g. Contribution, Campaign Contribution'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + ], + ], + 'payment_processor' => [ + 'title' => ts('Payment Processor'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('Payment Processors configured for this contribution Page'), + 'add' => '1.8', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'label' => ts('Payment Processors'), + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_payment_processor', + 'key_column' => 'id', + 'label_column' => 'name', + ], + ], + 'is_credit_card_only' => [ + 'title' => ts('Is Credit Card Only?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - processing logic must reject transaction at confirmation stage if pay method != credit card'), + 'add' => '1.3', + 'default' => FALSE, + ], + 'is_monetary' => [ + 'title' => ts('Is Monetary'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - allows real-time monetary transactions otherwise non-monetary transactions'), + 'add' => '1.6', + 'default' => TRUE, + ], + 'is_recur' => [ + 'title' => ts('Is Recurring'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - allows recurring contributions, valid only for PayPal_Standard'), + 'add' => '1.6', + 'default' => FALSE, + ], + 'is_confirm_enabled' => [ + 'title' => ts('Confirmation Page?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if FALSE, the confirm page in contribution pages gets skipped'), + 'add' => '4.2', + 'default' => TRUE, + ], + 'recur_frequency_unit' => [ + 'title' => ts('Recurring Frequency'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('Supported recurring frequency units.'), + 'add' => '2.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'multiple' => '1', + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'recur_frequency_units', + 'key_column' => 'name', + ], + ], + 'is_recur_interval' => [ + 'title' => ts('Support Recurring Intervals'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - supports recurring intervals'), + 'add' => '2.1', + 'default' => FALSE, + ], + 'is_recur_installments' => [ + 'title' => ts('Recurring Installments?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - asks user for recurring installments'), + 'add' => '4.3', + 'default' => FALSE, + ], + 'adjust_recur_start_date' => [ + 'title' => ts('Adjust Recurring Start Date'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - user is able to adjust payment start date'), + 'add' => '4.7', + 'default' => FALSE, + ], + 'is_pay_later' => [ + 'title' => ts('Pay Later'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - allows the user to send payment directly to the org later'), + 'add' => '2.0', + 'default' => FALSE, + ], + 'pay_later_text' => [ + 'title' => ts('Pay Later Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('The text displayed to the user in the main form'), + 'add' => '2.0', + ], + 'pay_later_receipt' => [ + 'title' => ts('Pay Later Receipt'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('The receipt sent to the user instead of the normal receipt text'), + 'add' => '2.0', + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 60, + ], + ], + 'is_partial_payment' => [ + 'title' => ts('Allow Partial Payment'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'description' => ts('is partial payment enabled for this online contribution page'), + 'add' => '4.3', + 'default' => FALSE, + ], + 'initial_amount_label' => [ + 'title' => ts('Initial Amount Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Initial amount label for partial payment'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Initial Amount Label'), + 'maxlength' => 255, + ], + ], + 'initial_amount_help_text' => [ + 'title' => ts('Initial Amount Help Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Initial amount help text for partial payment'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Initial Amount Help Text'), + ], + ], + 'min_initial_amount' => [ + 'title' => ts('Min Initial Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('Minimum initial amount for partial payment'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Min. Initial Amount'), + ], + ], + 'is_allow_other_amount' => [ + 'title' => ts('Allow Other Amounts'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if TRUE, page will include an input text field where user can enter their own amount'), + 'add' => '1.3', + 'default' => FALSE, + ], + 'default_amount_id' => [ + 'title' => ts('Default Amount'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('FK to civicrm_option_value.'), + 'add' => '1.7', + ], + 'min_amount' => [ + 'title' => ts('Minimum Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('if other amounts allowed, user can configure minimum allowed.'), + 'add' => '1.3', + ], + 'max_amount' => [ + 'title' => ts('Maximum Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('if other amounts allowed, user can configure maximum allowed.'), + 'add' => '1.3', + ], + 'goal_amount' => [ + 'title' => ts('Goal Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('The target goal for this page, allows people to build a goal meter'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Goal Amount'), + ], + ], + 'thankyou_title' => [ + 'title' => ts('Thank-you Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Title for Thank-you page (header title tag, and display at the top of the page).'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'thankyou_text' => [ + 'title' => ts('Thank-you Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('text and html allowed. displayed above result on success page'), + 'add' => '1.3', + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 60, + ], + ], + 'thankyou_footer' => [ + 'title' => ts('Thank-you Footer'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Text and html allowed. displayed at the bottom of the success page. Common usage is to include link(s) to other pages such as tell-a-friend, etc.'), + 'add' => '1.3', + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 60, + ], + ], + 'is_email_receipt' => [ + 'title' => ts('Send email Receipt'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if TRUE, receipt is automatically emailed to contact on success'), + 'add' => '1.3', + 'default' => FALSE, + ], + 'receipt_from_name' => [ + 'title' => ts('Receipt From'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('FROM email name used for receipts generated by contributions to this contribution page.'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'receipt_from_email' => [ + 'title' => ts('Receipt From email'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('FROM email address used for receipts generated by contributions to this contribution page.'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'cc_receipt' => [ + 'title' => ts('Receipt cc'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('comma-separated list of email addresses to cc each time a receipt is sent'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'bcc_receipt' => [ + 'title' => ts('Receipt bcc'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('comma-separated list of email addresses to bcc each time a receipt is sent'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'receipt_text' => [ + 'title' => ts('Receipt Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('text to include above standard receipt info on receipt email. emails are text-only, so do not allow html for now'), + 'add' => '1.3', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + ], + ], + 'is_active' => [ + 'title' => ts('Is Page Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this page active?'), + 'add' => '1.3', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'footer_text' => [ + 'title' => ts('Footer Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Text and html allowed. Displayed at the bottom of the first page of the contribution wizard.'), + 'add' => '1.4', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + ], + ], + 'amount_block_is_active' => [ + 'title' => ts('Is Amount Block Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property active?'), + 'add' => '1.5', + 'default' => TRUE, + ], + 'start_date' => [ + 'title' => ts('Contribution Page Start Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that this page starts.'), + 'add' => '1.8', + ], + 'end_date' => [ + 'title' => ts('Contribution Page End Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that this page ends. May be NULL if no defined end date/time'), + 'add' => '1.8', + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who created this contribution page'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('Contribution Page Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that contribution page was created.'), + 'add' => '3.0', + ], + 'currency' => [ + 'title' => ts('Contribution Page Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The campaign for which we are collecting contributions with this page.'), + 'add' => '3.4', + 'component' => 'CiviCampaign', + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_share' => [ + 'title' => ts('Is Contribution Page Shared?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Can people share the contribution page through social media?'), + 'add' => '4.1', + 'default' => TRUE, + ], + 'is_billing_required' => [ + 'title' => ts('Is billing block required'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - billing block is required for online contribution page'), + 'add' => '4.6', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Contribute/ContributionProduct.entityType.php b/schema/Contribute/ContributionProduct.entityType.php new file mode 100644 index 000000000000..4d6726f68d72 --- /dev/null +++ b/schema/Contribute/ContributionProduct.entityType.php @@ -0,0 +1,136 @@ + 'ContributionProduct', + 'table' => 'civicrm_contribution_product', + 'class' => 'CRM_Contribute_DAO_ContributionProduct', + 'getInfo' => fn() => [ + 'title' => ts('Contributionproduct'), + 'title_plural' => ts('Contributionproducts'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.4', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Contribution Product ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '1.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'product_id' => [ + 'title' => ts('Product ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'add' => '1.4', + 'entity_reference' => [ + 'entity' => 'Product', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contribution_id' => [ + 'title' => ts('Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'add' => '1.4', + 'input_attrs' => [ + 'label' => ts('Contribution'), + ], + 'entity_reference' => [ + 'entity' => 'Contribution', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'product_option' => [ + 'title' => ts('Product Option'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Option value selected if applicable - e.g. color, size etc.'), + 'add' => '1.4', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'quantity' => [ + 'title' => ts('Quantity'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'add' => '1.4', + 'usage' => [ + 'export', + ], + ], + 'fulfilled_date' => [ + 'title' => ts('Fulfilled Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Optional. Can be used to record the date this product was fulfilled or shipped.'), + 'add' => '1.4', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'start_date' => [ + 'title' => ts('Start date for premium'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Actual start date for a time-delimited premium (subscription, service or membership)'), + 'add' => '1.4', + 'unique_name' => 'contribution_start_date', + 'usage' => [ + 'export', + ], + ], + 'end_date' => [ + 'title' => ts('End date for premium'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Actual end date for a time-delimited premium (subscription, service or membership)'), + 'add' => '1.4', + 'unique_name' => 'contribution_end_date', + 'usage' => [ + 'export', + ], + ], + 'comment' => [ + 'title' => ts('Premium comment'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'add' => '1.4', + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Financial Type(for membership price sets only).'), + 'add' => '4.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Contribute/ContributionRecur.entityType.php b/schema/Contribute/ContributionRecur.entityType.php new file mode 100644 index 000000000000..676f4b45ca23 --- /dev/null +++ b/schema/Contribute/ContributionRecur.entityType.php @@ -0,0 +1,419 @@ + 'ContributionRecur', + 'table' => 'civicrm_contribution_recur', + 'class' => 'CRM_Contribute_DAO_ContributionRecur', + 'getInfo' => fn() => [ + 'title' => ts('Recurring Contribution'), + 'title_plural' => ts('Recurring Contributions'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.6', + ], + 'getIndices' => fn() => [ + 'UI_contrib_trxn_id' => [ + 'fields' => [ + 'trxn_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + 'UI_contrib_invoice_id' => [ + 'fields' => [ + 'invoice_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + 'index_contribution_status' => [ + 'fields' => [ + 'contribution_status_id' => TRUE, + ], + 'add' => '1.6', + ], + 'UI_contribution_recur_payment_instrument_id' => [ + 'fields' => [ + 'payment_instrument_id' => TRUE, + ], + 'add' => '4.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Recurring Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Contribution Recur ID'), + 'add' => '1.6', + 'unique_name' => 'contribution_recur_id', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to civicrm_contact.id.'), + 'add' => '1.6', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'amount' => [ + 'title' => ts('Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Amount to be collected (including any sales tax) by payment processor each recurrence.'), + 'add' => '1.6', + ], + 'currency' => [ + 'title' => ts('Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '3.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'frequency_unit' => [ + 'title' => ts('Frequency Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Time units for recurrence of payment.'), + 'add' => '1.6', + 'default' => 'month', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'recur_frequency_units', + 'key_column' => 'name', + ], + ], + 'frequency_interval' => [ + 'title' => ts('Interval (number of units)'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Number of time units for recurrence of payment.'), + 'add' => '1.6', + 'default' => 1, + ], + 'installments' => [ + 'title' => ts('Number of Installments'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.'), + 'add' => '1.6', + ], + 'start_date' => [ + 'title' => ts('Start Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'description' => ts('The date the first scheduled recurring contribution occurs.'), + 'add' => '1.6', + 'unique_name' => 'contribution_recur_start_date', + 'unique_title' => 'Recurring Contribution Start Date', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'create_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'description' => ts('When this recurring contribution record was created.'), + 'add' => '1.6', + 'unique_name' => 'contribution_recur_create_date', + 'unique_title' => 'Recurring Contribution Create Date', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'modified_date' => [ + 'title' => ts('Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('Last updated date for this record. mostly the last time a payment was received'), + 'add' => '1.6', + 'unique_name' => 'contribution_recur_modified_date', + 'unique_title' => 'Recurring Contribution Modified Date', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'cancel_date' => [ + 'title' => ts('Cancel Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'), + 'add' => '1.6', + 'unique_name' => 'contribution_recur_cancel_date', + 'unique_title' => 'Recurring Contribution Cancel Date', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'cancel_reason' => [ + 'title' => ts('Cancellation Reason'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'description' => ts('Free text field for a reason for cancelling'), + 'add' => '5.13', + 'unique_name' => 'contribution_recur_cancel_reason', + 'unique_title' => 'Recurring Contribution Cancel Reason', + 'input_attrs' => [ + 'size' => '40', + ], + ], + 'end_date' => [ + 'title' => ts('Recurring Contribution End Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date this recurring contribution finished successfully'), + 'add' => '1.6', + 'unique_name' => 'contribution_recur_end_date', + 'unique_title' => 'Recurring Contribution End Date', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'processor_id' => [ + 'title' => ts('Processor ID'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'), + 'add' => '1.6', + 'unique_name' => 'contribution_recur_processor_id', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'payment_token_id' => [ + 'title' => ts('Payment Token ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Payment Token'), + ], + 'entity_reference' => [ + 'entity' => 'PaymentToken', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'trxn_id' => [ + 'title' => ts('Transaction ID'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('unique transaction id (deprecated - use processor_id)'), + 'add' => '1.6', + 'unique_name' => 'contribution_recur_trxn_id', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'invoice_id' => [ + 'title' => ts('Invoice ID'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('unique invoice id, system generated or passed in'), + 'add' => '1.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'contribution_status_id' => [ + 'title' => ts('Status'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'add' => '1.6', + 'unique_name' => 'contribution_recur_contribution_status_id', + 'default' => 2, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'contribution_recur_status', + ], + ], + 'is_test' => [ + 'title' => ts('Test'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'cycle_day' => [ + 'title' => ts('Cycle Day'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'), + 'add' => '1.6', + 'default' => 1, + ], + 'next_sched_contribution_date' => [ + 'title' => ts('Next Scheduled Contribution Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Next scheduled date'), + 'add' => '4.4', + 'unique_name' => 'contribution_recur_next_sched_contribution_date', + 'unique_title' => 'Next Scheduled Recurring Contribution', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'failure_count' => [ + 'title' => ts('Number of Failures'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'), + 'add' => '1.6', + 'default' => 0, + ], + 'failure_retry_date' => [ + 'title' => ts('Retry Failed Attempt Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date to retry failed attempt'), + 'add' => '1.6', + 'unique_name' => 'contribution_recur_failure_retry_date', + 'unique_title' => 'Failed Recurring Contribution Retry Date', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'auto_renew' => [ + 'title' => ts('Auto Renew'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.'), + 'add' => '1.6', + 'default' => FALSE, + ], + 'payment_processor_id' => [ + 'title' => ts('Payment Processor ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Foreign key to civicrm_payment_processor.id'), + 'add' => '3.3', + 'unique_name' => 'contribution_recur_payment_processor_id', + 'input_attrs' => [ + 'label' => ts('Payment Processor'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_payment_processor', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'PaymentProcessor', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to Financial Type'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'payment_instrument_id' => [ + 'title' => ts('Payment Method'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to Payment Instrument'), + 'add' => '4.1', + 'pseudoconstant' => [ + 'option_group_name' => 'payment_instrument', + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The campaign for which this contribution has been triggered.'), + 'add' => '4.1', + 'unique_name' => 'contribution_campaign_id', + 'component' => 'CiviCampaign', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_email_receipt' => [ + 'title' => ts('Send email Receipt?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if TRUE, receipt is automatically emailed to contact on each successful payment'), + 'add' => '4.1', + 'default' => TRUE, + ], + ], +]; diff --git a/schema/Contribute/ContributionSoft.entityType.php b/schema/Contribute/ContributionSoft.entityType.php new file mode 100644 index 000000000000..a5de9241c997 --- /dev/null +++ b/schema/Contribute/ContributionSoft.entityType.php @@ -0,0 +1,169 @@ + 'ContributionSoft', + 'table' => 'civicrm_contribution_soft', + 'class' => 'CRM_Contribute_DAO_ContributionSoft', + 'getInfo' => fn() => [ + 'title' => ts('Contribution Soft Credit'), + 'title_plural' => ts('Contribution Soft Credits'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '2.2', + ], + 'getIndices' => fn() => [ + 'index_id' => [ + 'fields' => [ + 'pcp_id' => TRUE, + ], + 'add' => '2.2', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Soft Credit ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Soft Credit ID'), + 'add' => '2.2', + 'unique_name' => 'contribution_soft_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contribution_id' => [ + 'title' => ts('Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to contribution table.'), + 'add' => '2.2', + 'input_attrs' => [ + 'label' => ts('Contribution'), + ], + 'entity_reference' => [ + 'entity' => 'Contribution', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact ID'), + 'add' => '2.2', + 'unique_name' => 'contribution_soft_contact_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'amount' => [ + 'title' => ts('Soft Credit Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('Amount of this soft credit.'), + 'add' => '2.2', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'currency' => [ + 'title' => ts('Soft Contribution Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '3.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'pcp_id' => [ + 'title' => ts('PCP ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_pcp.id'), + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('PCP'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_pcp', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'PCP', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'pcp_display_in_roll' => [ + 'title' => ts('Soft Contribution Display on PCP'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '2.2', + 'default' => FALSE, + ], + 'pcp_roll_nickname' => [ + 'title' => ts('Soft Contribution PCP Nickname'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'pcp_personal_note' => [ + 'title' => ts('Soft Contribution PCP Note'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'TextArea', + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'soft_credit_type_id' => [ + 'title' => ts('Soft Credit Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Soft Credit Type ID.Implicit FK to civicrm_option_value where option_group = soft_credit_type.'), + 'add' => '2.2', + 'default' => NULL, + 'pseudoconstant' => [ + 'option_group_name' => 'soft_credit_type', + ], + ], + ], +]; diff --git a/schema/Contribute/Premium.entityType.php b/schema/Contribute/Premium.entityType.php new file mode 100644 index 000000000000..68eee76f4a0a --- /dev/null +++ b/schema/Contribute/Premium.entityType.php @@ -0,0 +1,125 @@ + 'Premium', + 'table' => 'civicrm_premiums', + 'class' => 'CRM_Contribute_DAO_Premium', + 'getInfo' => fn() => [ + 'title' => ts('Premium'), + 'title_plural' => ts('Premiums'), + 'description' => ts('table - settings for the Premiums features for a given contribution page'), + 'log' => TRUE, + 'add' => '1.4', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Premium ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '1.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Premium Entity'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Joins these premium settings to another object. Always civicrm_contribution_page for now.'), + 'add' => '1.4', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Contribute_BAO_Premium::entityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('Premium entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'add' => '1.4', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'premiums_active' => [ + 'title' => ts('Is Premium Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is the Premiums feature enabled for this page?'), + 'add' => '1.4', + 'default' => FALSE, + ], + 'premiums_intro_title' => [ + 'title' => ts('Title for Premiums section'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Title for Premiums section.'), + 'add' => '1.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'premiums_intro_text' => [ + 'title' => ts('Premium Introductory Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Displayed in
at top of Premiums section of page. Text and HTML allowed.'), + 'add' => '1.4', + ], + 'premiums_contact_email' => [ + 'title' => ts('Premium Contact Email'), + 'sql_type' => 'varchar(100)', + 'input_type' => 'Text', + 'description' => ts('This email address is included in receipts if it is populated and a premium has been selected.'), + 'add' => '1.4', + 'input_attrs' => [ + 'maxlength' => 100, + ], + ], + 'premiums_contact_phone' => [ + 'title' => ts('Premiums Contact Phone'), + 'sql_type' => 'varchar(50)', + 'input_type' => 'Text', + 'description' => ts('This phone number is included in receipts if it is populated and a premium has been selected.'), + 'add' => '1.4', + 'input_attrs' => [ + 'maxlength' => 50, + ], + ], + 'premiums_display_min_contribution' => [ + 'title' => ts('Display Minimum Contribution?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Boolean. Should we automatically display minimum contribution amount text after the premium descriptions.'), + 'add' => '1.4', + 'default' => FALSE, + ], + 'premiums_nothankyou_label' => [ + 'title' => ts('No Thank-you Text'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Label displayed for No Thank-you option in premiums block (e.g. No thank you)'), + 'add' => '4.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'premiums_nothankyou_position' => [ + 'title' => ts('No Thank-you Position'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'add' => '4.3', + 'default' => 1, + ], + ], +]; diff --git a/schema/Contribute/PremiumsProduct.entityType.php b/schema/Contribute/PremiumsProduct.entityType.php new file mode 100644 index 000000000000..bee0b0a67fdd --- /dev/null +++ b/schema/Contribute/PremiumsProduct.entityType.php @@ -0,0 +1,84 @@ + 'PremiumsProduct', + 'table' => 'civicrm_premiums_product', + 'class' => 'CRM_Contribute_DAO_PremiumsProduct', + 'getInfo' => fn() => [ + 'title' => ts('Product Premium'), + 'title_plural' => ts('Product Premiums'), + 'description' => ts('joins premiums (settings) to individual product/premium items - determines which products are available for a given contribution page'), + 'log' => TRUE, + 'add' => '1.4', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Premium Product ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Contribution ID'), + 'add' => '1.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'premiums_id' => [ + 'title' => ts('Premium ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to premiums settings record.'), + 'add' => '1.4', + 'input_attrs' => [ + 'label' => ts('Premium'), + ], + 'entity_reference' => [ + 'entity' => 'Premium', + 'key' => 'id', + ], + ], + 'product_id' => [ + 'title' => ts('Product ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to each product object.'), + 'add' => '1.4', + 'input_attrs' => [ + 'label' => ts('Product'), + ], + 'entity_reference' => [ + 'entity' => 'Product', + 'key' => 'id', + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '2.0', + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Financial Type.'), + 'add' => '4.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Contribute/Product.entityType.php b/schema/Contribute/Product.entityType.php new file mode 100644 index 000000000000..966fa3206b6b --- /dev/null +++ b/schema/Contribute/Product.entityType.php @@ -0,0 +1,235 @@ + 'Product', + 'table' => 'civicrm_product', + 'class' => 'CRM_Contribute_DAO_Product', + 'getInfo' => fn() => [ + 'title' => ts('Product'), + 'title_plural' => ts('Products'), + 'description' => ts('able - stores "product info" for premiums and can be used for non-incentive products'), + 'log' => TRUE, + 'add' => '1.4', + 'label_field' => 'name', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/contribute/managePremiums/edit?action=add&reset=1', + 'update' => 'civicrm/admin/contribute/managePremiums/edit?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/contribute/managePremiums/edit?action=delete&id=[id]&reset=1', + 'preview' => 'civicrm/admin/contribute/managePremiums/edit?action=preview&reset=1&id=[id]', + 'browse' => 'civicrm/admin/contribute/managePremiums/', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Product ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '1.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Product Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Required product/premium name'), + 'add' => '1.4', + 'unique_name' => 'product_name', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Optional description of the product/premium.'), + 'add' => '1.4', + ], + 'sku' => [ + 'title' => ts('SKU'), + 'sql_type' => 'varchar(50)', + 'input_type' => 'Text', + 'description' => ts('Optional product sku or code.'), + 'add' => '1.4', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 50, + ], + ], + 'options' => [ + 'title' => ts('Options'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'), + 'add' => '1.4', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + ], + 'image' => [ + 'title' => ts('Image'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Full or relative URL to uploaded image - fullsize.'), + 'add' => '1.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'thumbnail' => [ + 'title' => ts('Thumbnail'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Full or relative URL to image thumbnail.'), + 'add' => '1.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'price' => [ + 'title' => ts('Price'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('Sell price or market value for premiums. For tax-deductible contributions, this will be stored as non_deductible_amount in the contribution record.'), + 'add' => '1.4', + ], + 'currency' => [ + 'title' => ts('Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '3.2', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Currency'), + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Financial Type.'), + 'add' => '4.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'min_contribution' => [ + 'title' => ts('Minimum Contribution'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('Minimum contribution required to be eligible to select this premium.'), + 'add' => '1.4', + ], + 'cost' => [ + 'title' => ts('Cost'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('Actual cost of this product. Useful to determine net return from sale or using this as an incentive.'), + 'add' => '1.4', + ], + 'is_active' => [ + 'title' => ts('Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Disabling premium removes it from the premiums_premium join table below.'), + 'add' => '1.4', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'period_type' => [ + 'title' => ts('Period Type'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Rolling means we set start/end based on current day, fixed means we set start/end for current year or month (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006)'), + 'add' => '1.4', + 'default' => 'rolling', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::periodType', + ], + ], + 'fixed_period_start_day' => [ + 'title' => ts('Fixed Period Start Day'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'), + 'add' => '1.4', + 'default' => 101, + ], + 'duration_unit' => [ + 'title' => ts('Duration Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'add' => '1.4', + 'default' => 'year', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getPremiumUnits', + ], + ], + 'duration_interval' => [ + 'title' => ts('Duration Interval'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'), + 'add' => '1.4', + ], + 'frequency_unit' => [ + 'title' => ts('Frequency Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'), + 'add' => '1.4', + 'default' => 'month', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getPremiumUnits', + ], + ], + 'frequency_interval' => [ + 'title' => ts('Frequency Interval'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'), + 'add' => '1.4', + ], + ], +]; diff --git a/schema/Contribute/Widget.entityType.php b/schema/Contribute/Widget.entityType.php new file mode 100644 index 000000000000..e5aac081dd32 --- /dev/null +++ b/schema/Contribute/Widget.entityType.php @@ -0,0 +1,181 @@ + 'Widget', + 'table' => 'civicrm_contribution_widget', + 'class' => 'CRM_Contribute_DAO_Widget', + 'getInfo' => fn() => [ + 'title' => ts('Widget'), + 'title_plural' => ts('Widgets'), + 'description' => ts('A Widget object to store meta information about a single customized contribution widget'), + 'log' => TRUE, + 'add' => '2.0', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Widget ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Contribution ID'), + 'add' => '2.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contribution_page_id' => [ + 'title' => ts('Contribution Page ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The Contribution Page which triggered this contribution'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Contribution Page'), + ], + 'entity_reference' => [ + 'entity' => 'ContributionPage', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'is_active' => [ + 'title' => ts('Enabled?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property active?'), + 'add' => '2.0', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'title' => [ + 'title' => ts('Widget Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Widget title.'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_logo' => [ + 'title' => ts('Widget Image Url'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('URL to Widget logo'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'button_title' => [ + 'title' => ts('Button Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Button title.'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'about' => [ + 'title' => ts('Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('About description.'), + 'add' => '2.0', + ], + 'url_homepage' => [ + 'title' => ts('Homepage Url'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('URL to Homepage.'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'color_title' => [ + 'title' => ts('Title Color'), + 'sql_type' => 'varchar(10)', + 'input_type' => 'Text', + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'color_button' => [ + 'title' => ts('Button Color'), + 'sql_type' => 'varchar(10)', + 'input_type' => 'Text', + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'color_bar' => [ + 'title' => ts('Bar Color'), + 'sql_type' => 'varchar(10)', + 'input_type' => 'Text', + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'color_main_text' => [ + 'title' => ts('Main Text Color'), + 'sql_type' => 'varchar(10)', + 'input_type' => 'Text', + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'color_main' => [ + 'title' => ts('Main Color'), + 'sql_type' => 'varchar(10)', + 'input_type' => 'Text', + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'color_main_bg' => [ + 'title' => ts('Background Color'), + 'sql_type' => 'varchar(10)', + 'input_type' => 'Text', + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'color_bg' => [ + 'title' => ts('Other Background Color'), + 'sql_type' => 'varchar(10)', + 'input_type' => 'Text', + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'color_about_link' => [ + 'title' => ts('About Link Color'), + 'sql_type' => 'varchar(10)', + 'input_type' => 'Text', + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'color_homepage_link' => [ + 'title' => ts('Homepage Link Color'), + 'sql_type' => 'varchar(10)', + 'input_type' => 'Text', + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + ], +]; diff --git a/schema/Core/ActionLog.entityType.php b/schema/Core/ActionLog.entityType.php new file mode 100644 index 000000000000..f91ce8154899 --- /dev/null +++ b/schema/Core/ActionLog.entityType.php @@ -0,0 +1,115 @@ + 'ActionLog', + 'table' => 'civicrm_action_log', + 'class' => 'CRM_Core_DAO_ActionLog', + 'getInfo' => fn() => [ + 'title' => ts('Actionlog'), + 'title_plural' => ts('Actionlogs'), + 'description' => ts('Table to store log for the reminder.'), + 'add' => '3.4', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Action Schedule ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '3.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to id of the entity that the action was performed on. Pseudo - FK.'), + 'add' => '3.4', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('name of the entity table for the above id, e.g. civicrm_activity, civicrm_participant'), + 'add' => '3.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'action_schedule_id' => [ + 'title' => ts('Schedule ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to the action schedule that this action originated from.'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Schedule'), + ], + 'entity_reference' => [ + 'entity' => 'ActionSchedule', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'action_date_time' => [ + 'title' => ts('Action Date And Time'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('date time that the action was performed on.'), + 'add' => '3.4', + ], + 'is_error' => [ + 'title' => ts('Error?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Was there any error sending the reminder?'), + 'add' => '3.4', + 'default' => FALSE, + ], + 'message' => [ + 'title' => ts('Message'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Description / text in case there was an error encountered.'), + 'add' => '3.4', + ], + 'repetition_number' => [ + 'title' => ts('Repetition Number'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Keeps track of the sequence number of this repetition.'), + 'add' => '3.4', + ], + 'reference_date' => [ + 'title' => ts('Reference Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Stores the date from the entity which triggered this reminder action (e.g. membership.end_date for most membership renewal reminders)'), + 'add' => '4.6', + 'default' => NULL, + ], + ], +]; diff --git a/schema/Core/ActionSchedule.entityType.php b/schema/Core/ActionSchedule.entityType.php new file mode 100644 index 000000000000..7e2900a9d01a --- /dev/null +++ b/schema/Core/ActionSchedule.entityType.php @@ -0,0 +1,577 @@ + 'ActionSchedule', + 'table' => 'civicrm_action_schedule', + 'class' => 'CRM_Core_DAO_ActionSchedule', + 'getInfo' => fn() => [ + 'title' => ts('Scheduled Reminder'), + 'title_plural' => ts('Scheduled Reminders'), + 'description' => ts('Table to store the reminders.'), + 'add' => '3.4', + 'label_field' => 'title', + ], + 'getPaths' => fn() => [ + 'browse' => 'civicrm/admin/scheduleReminders', + 'add' => 'civicrm/admin/scheduleReminders/edit?reset=1&action=add', + 'update' => 'civicrm/admin/scheduleReminders/edit?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/admin/scheduleReminders/edit?reset=1&action=delete&id=[id]', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '5.65', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Action Schedule ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '3.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name of the scheduled action'), + 'add' => '3.4', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'title' => [ + 'title' => ts('Title'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Title of the action(reminder)'), + 'add' => '3.4', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'recipient' => [ + 'title' => ts('Recipient'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('Recipient'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Limit or Add Recipients'), + 'control_field' => 'mapping_id', + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getRecipientOptions', + ], + ], + 'limit_to' => [ + 'title' => ts('Limit To'), + 'sql_type' => 'int', + 'input_type' => 'Select', + 'description' => ts('Is this the recipient criteria limited to OR in addition to?'), + 'add' => '4.4', + 'input_attrs' => [ + 'label' => ts('Limit/Add'), + 'control_field' => 'mapping_id', + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getLimitToOptions', + ], + ], + 'entity_value' => [ + 'title' => ts('Entity Value'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'description' => ts('Entity value'), + 'add' => '3.4', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'label' => ts('Entity Value'), + 'multiple' => '1', + 'control_field' => 'mapping_id', + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getEntityValueOptions', + ], + ], + 'entity_status' => [ + 'title' => ts('Entity Status'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('Entity status'), + 'add' => '3.4', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'label' => ts('Entity Status'), + 'multiple' => '1', + 'control_field' => 'entity_value', + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getEntityStatusOptions', + ], + ], + 'start_action_offset' => [ + 'title' => ts('Start Action Offset'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Reminder Interval.'), + 'add' => '3.4', + 'default' => 0, + 'input_attrs' => [ + 'min' => '0', + 'label' => ts('Start Action Offset'), + ], + ], + 'start_action_unit' => [ + 'title' => ts('Start Action Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Time units for reminder.'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Start Action Unit'), + 'control_field' => 'start_action_offset', + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getDateUnits', + ], + ], + 'start_action_condition' => [ + 'title' => ts('Start Action Condition'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('Reminder Action'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Start Condition'), + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::beforeAfter', + ], + ], + 'start_action_date' => [ + 'title' => ts('Start Action Date'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('Entity date'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Start Date'), + 'control_field' => 'entity_value', + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getActionDateOptions', + ], + ], + 'is_repeat' => [ + 'title' => ts('Repeat'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '3.4', + 'default' => FALSE, + ], + 'repetition_frequency_unit' => [ + 'title' => ts('Repetition Frequency Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Time units for repetition of reminder.'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Repetition Frequency Unit'), + 'control_field' => 'repetition_frequency_interval', + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getDateUnits', + ], + ], + 'repetition_frequency_interval' => [ + 'title' => ts('Repetition Frequency Interval'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Time interval for repeating the reminder.'), + 'add' => '3.4', + 'default' => 0, + 'input_attrs' => [ + 'min' => '0', + 'label' => ts('Repetition Frequency Interval'), + ], + ], + 'end_frequency_unit' => [ + 'title' => ts('End Frequency Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Time units till repetition of reminder.'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('End Frequency Unit'), + 'control_field' => 'end_frequency_interval', + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getDateUnits', + ], + ], + 'end_frequency_interval' => [ + 'title' => ts('End Frequency Interval'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Time interval till repeating the reminder.'), + 'add' => '3.4', + 'default' => 0, + 'input_attrs' => [ + 'min' => '0', + 'label' => ts('End Frequency Interval'), + ], + ], + 'end_action' => [ + 'title' => ts('End Action'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Select', + 'description' => ts('Reminder Action till repeating the reminder.'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('End Condition'), + 'maxlength' => 32, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::beforeAfter', + ], + ], + 'end_date' => [ + 'title' => ts('End Date'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('Entity end date'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('End Date'), + 'control_field' => 'entity_value', + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getActionDateOptions', + ], + ], + 'is_active' => [ + 'title' => ts('Schedule is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this option active?'), + 'add' => '3.4', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'recipient_manual' => [ + 'title' => ts('Recipient Manual'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'EntityRef', + 'description' => ts('Contact IDs to which reminder should be sent.'), + 'add' => '3.4', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'input_attrs' => [ + 'label' => ts('Manual Recipients'), + 'multiple' => '1', + 'maxlength' => 128, + ], + ], + 'recipient_listing' => [ + 'title' => ts('Recipient Listing'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('listing based on recipient field.'), + 'add' => '4.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'label' => ts('Recipient Roles'), + 'multiple' => '1', + 'control_field' => 'recipient', + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getRecipientListingOptions', + ], + ], + 'body_text' => [ + 'title' => ts('Reminder Text'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Body of the mailing in text format.'), + 'add' => '3.4', + ], + 'body_html' => [ + 'title' => ts('Reminder HTML'), + 'sql_type' => 'longtext', + 'input_type' => 'RichTextEditor', + 'description' => ts('Body of the mailing in html format.'), + 'add' => '3.4', + ], + 'sms_body_text' => [ + 'title' => ts('SMS Reminder Text'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Content of the SMS text.'), + 'add' => '4.5', + ], + 'subject' => [ + 'title' => ts('Reminder Subject'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Subject of mailing'), + 'add' => '3.4', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'record_activity' => [ + 'title' => ts('Record Activity'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Record Activity for this reminder?'), + 'add' => '3.4', + 'default' => FALSE, + ], + 'mapping_id' => [ + 'title' => ts('Reminder For'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('Name/ID of the mapping to use on this table'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Used For'), + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getMappingOptions', + 'suffixes' => [ + 'name', + 'label', + 'icon', + ], + ], + ], + 'group_id' => [ + 'title' => ts('Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Group'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Group'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_group', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'msg_template_id' => [ + 'title' => ts('Message Template ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to the message template.'), + 'input_attrs' => [ + 'label' => ts('Message Template'), + ], + 'entity_reference' => [ + 'entity' => 'MessageTemplate', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'sms_template_id' => [ + 'title' => ts('SMS Template ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to the message template.'), + 'input_attrs' => [ + 'label' => ts('SMS Template'), + ], + 'entity_reference' => [ + 'entity' => 'MessageTemplate', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'absolute_date' => [ + 'title' => ts('Fixed Date for Reminder'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Date on which the reminder be sent.'), + 'add' => '4.1', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'from_name' => [ + 'title' => ts('Reminder from Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Name in "from" field'), + 'add' => '4.5', + 'input_attrs' => [ + 'label' => ts('From Name'), + 'maxlength' => 255, + ], + ], + 'from_email' => [ + 'title' => ts('Reminder From Email'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Email', + 'description' => ts('Email address in "from" field'), + 'add' => '4.5', + 'input_attrs' => [ + 'label' => ts('From Email'), + 'maxlength' => 255, + ], + ], + 'mode' => [ + 'title' => ts('Message Mode'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('Send the message as email or sms or both.'), + 'add' => '4.5', + 'default' => 'Email', + 'input_attrs' => [ + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'msg_mode', + ], + ], + 'sms_provider_id' => [ + 'title' => ts('SMS Provider ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'add' => '4.5', + 'input_attrs' => [ + 'label' => ts('SMS Provider'), + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::smsProvider', + ], + 'entity_reference' => [ + 'entity' => 'SmsProvider', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'used_for' => [ + 'title' => ts('Used For'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Used for repeating entity'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Used For'), + 'maxlength' => 64, + ], + ], + 'filter_contact_language' => [ + 'title' => ts('Filter Contact Language'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('Used for multilingual installation'), + 'add' => '4.7', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'multiple' => '1', + 'label' => ts('Recipients Language'), + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getFilterContactLanguageOptions', + ], + ], + 'communication_language' => [ + 'title' => ts('Communication Language'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Used for multilingual installation'), + 'add' => '4.7', + 'input_attrs' => [ + 'label' => ts('Communication Language'), + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_ActionSchedule::getCommunicationLanguageOptions', + ], + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('When was the scheduled reminder created.'), + 'add' => '5.34', + 'unique_name' => 'action_schedule_created_date', + 'default' => 'CURRENT_TIMESTAMP', + 'usage' => [ + 'export', + ], + ], + 'modified_date' => [ + 'title' => ts('Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('When the reminder was created or modified.'), + 'add' => '5.34', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'label' => ts('Modified Date'), + ], + ], + 'effective_start_date' => [ + 'title' => ts('Effective start date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('Earliest date to consider start events from.'), + 'add' => '5.34', + 'unique_name' => 'action_schedule_effective_start_date', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'effective_end_date' => [ + 'title' => ts('Effective end date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('Latest date to consider end events from.'), + 'add' => '5.34', + 'unique_name' => 'action_schedule_effective_end_date', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + ], +]; diff --git a/schema/Core/Address.entityType.php b/schema/Core/Address.entityType.php new file mode 100644 index 000000000000..df96ac4d2f05 --- /dev/null +++ b/schema/Core/Address.entityType.php @@ -0,0 +1,478 @@ + 'Address', + 'table' => 'civicrm_address', + 'class' => 'CRM_Core_DAO_Address', + 'getInfo' => fn() => [ + 'title' => ts('Address'), + 'title_plural' => ts('Addresses'), + 'description' => ts('Stores the physical street / mailing address. This format should be capable of storing ALL international addresses.'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-map-marker', + ], + 'getIndices' => fn() => [ + 'index_location_type' => [ + 'fields' => [ + 'location_type_id' => TRUE, + ], + 'add' => '2.0', + ], + 'index_is_primary' => [ + 'fields' => [ + 'is_primary' => TRUE, + ], + 'add' => '2.0', + ], + 'index_is_billing' => [ + 'fields' => [ + 'is_billing' => TRUE, + ], + 'add' => '2.0', + ], + 'index_street_name' => [ + 'fields' => [ + 'street_name' => TRUE, + ], + 'add' => '1.1', + ], + 'index_city' => [ + 'fields' => [ + 'city' => TRUE, + ], + 'add' => '1.1', + ], + 'index_geo_code_1_geo_code_2' => [ + 'fields' => [ + 'geo_code_1' => TRUE, + 'geo_code_2' => TRUE, + ], + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Address ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Address ID'), + 'add' => '1.1', + 'unique_name' => 'address_id', + 'usage' => [ + 'export', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'location_type_id' => [ + 'title' => ts('Address Location Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which Location does this address belong to.'), + 'add' => '2.0', + 'pseudoconstant' => [ + 'table' => 'civicrm_location_type', + 'key_column' => 'id', + 'label_column' => 'display_name', + ], + ], + 'is_primary' => [ + 'title' => ts('Is Primary'), + 'sql_type' => 'boolean', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Is this the primary address.'), + 'add' => '2.0', + 'default' => FALSE, + ], + 'is_billing' => [ + 'title' => ts('Is Billing Address'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this the billing address.'), + 'add' => '2.0', + 'default' => FALSE, + ], + 'street_address' => [ + 'title' => ts('Street Address'), + 'sql_type' => 'varchar(96)', + 'input_type' => 'Text', + 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail delivery, etc.).'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 96, + ], + ], + 'street_number' => [ + 'title' => ts('Street Number'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'), + 'add' => '1.1', + 'usage' => [ + 'export', + ], + ], + 'street_number_suffix' => [ + 'title' => ts('Street Number Suffix'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Text', + 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'), + 'add' => '1.1', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 8, + ], + ], + 'street_number_predirectional' => [ + 'title' => ts('Street Direction Prefix'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Text', + 'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 8, + ], + ], + 'street_name' => [ + 'title' => ts('Street Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'), + 'add' => '1.1', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'street_type' => [ + 'title' => ts('Street Type'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Text', + 'description' => ts('St, Rd, Dr, etc.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 8, + ], + ], + 'street_number_postdirectional' => [ + 'title' => ts('Street Direction Suffix'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Text', + 'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 8, + ], + ], + 'street_unit' => [ + 'title' => ts('Street Unit'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Text', + 'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'), + 'add' => '1.1', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 16, + ], + ], + 'supplemental_address_1' => [ + 'title' => ts('Supplemental Address 1'), + 'sql_type' => 'varchar(96)', + 'input_type' => 'Text', + 'description' => ts('Supplemental Address Information, Line 1'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 96, + ], + ], + 'supplemental_address_2' => [ + 'title' => ts('Supplemental Address 2'), + 'sql_type' => 'varchar(96)', + 'input_type' => 'Text', + 'description' => ts('Supplemental Address Information, Line 2'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 96, + ], + ], + 'supplemental_address_3' => [ + 'title' => ts('Supplemental Address 3'), + 'sql_type' => 'varchar(96)', + 'input_type' => 'Text', + 'description' => ts('Supplemental Address Information, Line 3'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 96, + ], + ], + 'city' => [ + 'title' => ts('City'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('City, Town or Village Name.'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'county_id' => [ + 'title' => ts('County ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'ChainSelect', + 'description' => ts('Which County does this address belong to.'), + 'add' => '1.1', + 'input_attrs' => [ + 'control_field' => 'state_province_id', + 'label' => ts('County'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_county', + 'key_column' => 'id', + 'label_column' => 'name', + 'abbr_column' => 'abbreviation', + 'suffixes' => [ + 'label', + 'abbr', + ], + ], + 'entity_reference' => [ + 'entity' => 'County', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'state_province_id' => [ + 'title' => ts('State/Province ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'ChainSelect', + 'description' => ts('Which State_Province does this address belong to.'), + 'add' => '1.1', + 'localize_context' => 'province', + 'input_attrs' => [ + 'control_field' => 'country_id', + 'label' => ts('State/Province'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_state_province', + 'key_column' => 'id', + 'label_column' => 'name', + 'abbr_column' => 'abbreviation', + 'suffixes' => [ + 'label', + 'abbr', + ], + ], + 'entity_reference' => [ + 'entity' => 'StateProvince', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'postal_code_suffix' => [ + 'title' => ts('Postal Code Suffix'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Text', + 'description' => ts('Store the suffix, like the +4 part in the USPS system.'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '3', + 'maxlength' => 12, + ], + ], + 'postal_code' => [ + 'title' => ts('Postal Code'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '6', + 'maxlength' => 64, + ], + ], + 'usps_adc' => [ + 'title' => ts('USPS Code'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Text', + 'deprecated' => TRUE, + 'description' => ts('USPS Bulk mailing code.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 32, + ], + ], + 'country_id' => [ + 'title' => ts('Country ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which Country does this address belong to.'), + 'add' => '1.1', + 'localize_context' => 'country', + 'input_attrs' => [ + 'label' => ts('Country'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_country', + 'key_column' => 'id', + 'label_column' => 'name', + 'name_column' => 'iso_code', + 'abbr_column' => 'iso_code', + 'suffixes' => [ + 'label', + 'abbr', + ], + ], + 'entity_reference' => [ + 'entity' => 'Country', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'geo_code_1' => [ + 'title' => ts('Latitude'), + 'sql_type' => 'double', + 'input_type' => 'Text', + 'description' => ts('Latitude'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '9', + ], + ], + 'geo_code_2' => [ + 'title' => ts('Longitude'), + 'sql_type' => 'double', + 'input_type' => 'Text', + 'description' => ts('Longitude'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '9', + ], + ], + 'manual_geo_code' => [ + 'title' => ts('Is Manually Geocoded'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a manually entered geo code'), + 'add' => '4.3', + 'default' => FALSE, + 'usage' => [ + 'export', + ], + ], + 'timezone' => [ + 'title' => ts('Timezone'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Text', + 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 8, + ], + ], + 'name' => [ + 'title' => ts('Address Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '2.1', + 'unique_name' => 'address_name', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'master_id' => [ + 'title' => ts('Master Address ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Address ID'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Master Address Belongs To'), + ], + 'entity_reference' => [ + 'entity' => 'Address', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Core/AddressFormat.entityType.php b/schema/Core/AddressFormat.entityType.php new file mode 100644 index 000000000000..999bc4d24ed4 --- /dev/null +++ b/schema/Core/AddressFormat.entityType.php @@ -0,0 +1,32 @@ + 'AddressFormat', + 'table' => 'civicrm_address_format', + 'class' => 'CRM_Core_DAO_AddressFormat', + 'getInfo' => fn() => [ + 'title' => ts('Addressformat'), + 'title_plural' => ts('Addressformats'), + 'description' => ts('FIXME'), + 'add' => '3.2', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Address Format ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Address Format ID'), + 'add' => '3.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'format' => [ + 'title' => ts('Address Format'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('The format of an address'), + 'add' => '3.2', + ], + ], +]; diff --git a/schema/Core/Cache.entityType.php b/schema/Core/Cache.entityType.php new file mode 100644 index 000000000000..dfaf57ebb3a1 --- /dev/null +++ b/schema/Core/Cache.entityType.php @@ -0,0 +1,104 @@ + 'Cache', + 'table' => 'civicrm_cache', + 'class' => 'CRM_Core_DAO_Cache', + 'getInfo' => fn() => [ + 'title' => ts('Cache'), + 'title_plural' => ts('Caches'), + 'description' => ts('Table to cache items for civicrm components.'), + 'add' => '2.1', + ], + 'getIndices' => fn() => [ + 'UI_group_name_path' => [ + 'fields' => [ + 'group_name' => TRUE, + 'path' => TRUE, + ], + 'unique' => TRUE, + 'add' => '5.61', + ], + 'index_expired_date' => [ + 'fields' => [ + 'expired_date' => TRUE, + ], + 'add' => '5.61', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Cache ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique table ID'), + 'add' => '2.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'group_name' => [ + 'title' => ts('Group Name'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('group name for cache element, useful in cleaning cache elements'), + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 32, + ], + ], + 'path' => [ + 'title' => ts('Path'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Unique path name for cache element'), + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'data' => [ + 'title' => ts('Data'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('data associated with this path'), + 'add' => '2.1', + ], + 'component_id' => [ + 'title' => ts('Component ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Component that this menu item belongs to'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Component'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_component', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Component', + 'key' => 'id', + ], + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('When was the cache item created'), + 'add' => '2.1', + 'default' => 'CURRENT_TIMESTAMP', + ], + 'expired_date' => [ + 'title' => ts('Expired Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('When should the cache item expire'), + 'add' => '2.1', + 'default' => NULL, + ], + ], +]; diff --git a/schema/Core/Component.entityType.php b/schema/Core/Component.entityType.php new file mode 100644 index 000000000000..35daea071b1e --- /dev/null +++ b/schema/Core/Component.entityType.php @@ -0,0 +1,46 @@ + 'Component', + 'table' => 'civicrm_component', + 'class' => 'CRM_Core_DAO_Component', + 'getInfo' => fn() => [ + 'title' => ts('Component'), + 'title_plural' => ts('Components'), + 'description' => ts('FIXME'), + 'add' => '2.0', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Component ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Component ID'), + 'add' => '2.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Component name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name of the component.'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'namespace' => [ + 'title' => ts('Namespace reserved for component.'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Path to components main directory in a form of a class namespace.'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + ], +]; diff --git a/schema/Core/Country.entityType.php b/schema/Core/Country.entityType.php new file mode 100644 index 000000000000..359509e3e4ad --- /dev/null +++ b/schema/Core/Country.entityType.php @@ -0,0 +1,148 @@ + 'Country', + 'table' => 'civicrm_country', + 'class' => 'CRM_Core_DAO_Country', + 'getInfo' => fn() => [ + 'title' => ts('Country'), + 'title_plural' => ts('Countries'), + 'description' => ts('Countries of the world'), + 'add' => '1.1', + 'icon' => 'fa-globe', + 'label_field' => 'name', + ], + 'getIndices' => fn() => [ + 'UI_name_iso_code' => [ + 'fields' => [ + 'name' => TRUE, + 'iso_code' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Country ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Country ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Country'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Country Name'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'iso_code' => [ + 'title' => ts('Country ISO Code'), + 'sql_type' => 'char(2)', + 'input_type' => 'Text', + 'description' => ts('ISO Code'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 2, + ], + ], + 'country_code' => [ + 'title' => ts('Country Phone Prefix'), + 'sql_type' => 'varchar(4)', + 'input_type' => 'Text', + 'description' => ts('National prefix to be used when dialing TO this country.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 4, + ], + ], + 'address_format_id' => [ + 'title' => ts('Address Format ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Foreign key to civicrm_address_format.id.'), + 'add' => '3.2', + 'input_attrs' => [ + 'label' => ts('Address Format'), + ], + 'entity_reference' => [ + 'entity' => 'AddressFormat', + 'key' => 'id', + ], + ], + 'idd_prefix' => [ + 'title' => ts('Outgoing Phone Prefix'), + 'sql_type' => 'varchar(4)', + 'input_type' => 'Text', + 'description' => ts('International direct dialing prefix from within the country TO another country'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 4, + ], + ], + 'ndd_prefix' => [ + 'title' => ts('Area Code'), + 'sql_type' => 'varchar(4)', + 'input_type' => 'Text', + 'description' => ts('Access prefix to call within a country to a different area'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 4, + ], + ], + 'region_id' => [ + 'title' => ts('World Region ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Foreign key to civicrm_worldregion.id.'), + 'add' => '1.8', + 'localize_context' => 'country', + 'input_attrs' => [ + 'label' => ts('World Region'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_worldregion', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'WorldRegion', + 'key' => 'id', + ], + ], + 'is_province_abbreviated' => [ + 'title' => ts('Abbreviate Province?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'), + 'add' => '3.1', + 'default' => FALSE, + ], + 'is_active' => [ + 'title' => ts('Country Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this Country active?'), + 'add' => '5.35', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Core/County.entityType.php b/schema/Core/County.entityType.php new file mode 100644 index 000000000000..167472e1e230 --- /dev/null +++ b/schema/Core/County.entityType.php @@ -0,0 +1,94 @@ + 'County', + 'table' => 'civicrm_county', + 'class' => 'CRM_Core_DAO_County', + 'getInfo' => fn() => [ + 'title' => ts('County'), + 'title_plural' => ts('Counties'), + 'description' => ts('FIXME'), + 'add' => '1.1', + 'label_field' => 'name', + ], + 'getIndices' => fn() => [ + 'UI_name_state_id' => [ + 'fields' => [ + 'name' => TRUE, + 'state_province_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('County ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('County ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('County'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Name of County'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'abbreviation' => [ + 'title' => ts('County Abbreviation'), + 'sql_type' => 'varchar(4)', + 'input_type' => 'Text', + 'description' => ts('2-4 Character Abbreviation of County'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 4, + ], + ], + 'state_province_id' => [ + 'title' => ts('State ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('ID of State/Province that County belongs'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('State'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_state_province', + 'key_column' => 'id', + 'label_column' => 'name', + 'abbr_column' => 'abbreviation', + ], + 'entity_reference' => [ + 'entity' => 'StateProvince', + 'key' => 'id', + ], + ], + 'is_active' => [ + 'title' => ts('County Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this County active?'), + 'add' => '5.35', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Core/CustomField.entityType.php b/schema/Core/CustomField.entityType.php new file mode 100644 index 000000000000..55b49f86428e --- /dev/null +++ b/schema/Core/CustomField.entityType.php @@ -0,0 +1,371 @@ + 'CustomField', + 'table' => 'civicrm_custom_field', + 'class' => 'CRM_Core_DAO_CustomField', + 'getInfo' => fn() => [ + 'title' => ts('Customfield'), + 'title_plural' => ts('Customfields'), + 'description' => ts('Stores info about an extended (custom) property (data and form field info).'), + 'log' => TRUE, + 'add' => '1.1', + 'label_field' => 'label', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/custom/group/field/add?reset=1&action=add&gid=[custom_group_id]', + 'update' => 'civicrm/admin/custom/group/field/update?action=update&reset=1&id=[id]&gid=[custom_group_id]', + 'preview' => 'civicrm/admin/custom/group/preview?reset=1&fid=[id]', + 'delete' => 'civicrm/admin/custom/group/field/delete?reset=1&id=[id]', + 'detach' => 'civicrm/admin/custom/group/field/move?reset=1&fid=[id]', + ], + 'getIndices' => fn() => [ + 'UI_label_custom_group_id' => [ + 'fields' => [ + 'label' => TRUE, + 'custom_group_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.1', + ], + 'UI_name_custom_group_id' => [ + 'fields' => [ + 'name' => TRUE, + 'custom_group_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Custom Field ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Custom Field ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'custom_group_id' => [ + 'title' => ts('Custom Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to civicrm_custom_group.'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Custom Group'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_custom_group', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'CustomGroup', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'name' => [ + 'title' => ts('Custom Field Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Variable name/programmatic handle for this field.'), + 'add' => '3.3', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'label' => [ + 'title' => ts('Custom Field Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Text for form field label (also friendly name for administering this custom property).'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'data_type' => [ + 'title' => ts('Data Type'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Controls location of data storage in extended_data table.'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Data Type'), + 'maxlength' => 16, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_CustomField::dataType', + ], + ], + 'html_type' => [ + 'title' => ts('HTML Type'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('HTML types plus several built-in extended types.'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Field Input Type'), + 'maxlength' => 32, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::customHtmlType', + ], + ], + 'default_value' => [ + 'title' => ts('Custom Field Default'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Use form_options.is_default for field_types which use options.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_required' => [ + 'title' => ts('Custom Field Is Required?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is a value required for this property.'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'is_searchable' => [ + 'title' => ts('Allow Searching on Field?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property searchable.'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'is_search_range' => [ + 'title' => ts('Search as a Range'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property range searchable.'), + 'add' => '1.4', + 'default' => FALSE, + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Controls field display order within an extended property group.'), + 'add' => '1.1', + 'default' => 1, + ], + 'help_pre' => [ + 'title' => ts('Custom Field Pre Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display before this field.'), + 'add' => '1.1', + ], + 'help_post' => [ + 'title' => ts('Custom Field Post Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display after this field.'), + 'add' => '1.1', + ], + 'attributes' => [ + 'title' => ts('Custom Field Attributes'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_active' => [ + 'title' => ts('Custom Field Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'description' => ts('Is this property active?'), + 'add' => '1.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_view' => [ + 'title' => ts('Field is Viewable'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'options_per_line' => [ + 'title' => ts('Field Options Per Line'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('number of options per line for checkbox and radio'), + ], + 'text_length' => [ + 'title' => ts('Field Length'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('field length if alphanumeric'), + 'add' => '2.2', + ], + 'start_date_years' => [ + 'title' => ts('Field Start Date'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Date may be up to start_date_years years prior to the current date.'), + 'add' => '1.4', + ], + 'end_date_years' => [ + 'title' => ts('Field End Date'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Date may be up to end_date_years years after the current date.'), + 'add' => '1.4', + ], + 'date_format' => [ + 'title' => ts('Field Data Format'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('date format for custom date'), + 'add' => '3.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats', + ], + ], + 'time_format' => [ + 'title' => ts('Field Time Format'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('time format for custom date'), + 'add' => '3.1', + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getTimeFormats', + ], + ], + 'note_columns' => [ + 'title' => ts('Field Note Columns'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Number of columns in Note Field'), + 'add' => '1.4', + ], + 'note_rows' => [ + 'title' => ts('Field Note Rows'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Number of rows in Note Field'), + 'add' => '1.4', + ], + 'column_name' => [ + 'title' => ts('Field Column Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Name of the column that holds the values for this field.'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'option_group_id' => [ + 'title' => ts('Field Option Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('For elements with options, the option group id that is used'), + 'add' => '1.4', + 'input_attrs' => [ + 'label' => ts('Field Option Group'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_option_group', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'OptionGroup', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'serialize' => [ + 'title' => ts('Serialize'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'), + 'add' => '5.27', + 'default' => 0, + 'input_attrs' => [ + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::fieldSerialization', + ], + ], + 'filter' => [ + 'title' => ts('Field Filter'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'in_selector' => [ + 'title' => ts('Field Display'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'), + 'add' => '4.5', + 'default' => FALSE, + ], + 'fk_entity' => [ + 'title' => ts('Entity'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Name of entity being referenced.'), + 'add' => '5.60', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'fk_entity_on_delete' => [ + 'title' => ts('On Referenced Entity Delete'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Behavior if referenced entity is deleted.'), + 'add' => '5.71', + 'default' => 'set_null', + 'input_attrs' => [ + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_CustomField::getFkEntityOnDeleteOptions', + ], + ], + ], +]; diff --git a/schema/Core/CustomGroup.entityType.php b/schema/Core/CustomGroup.entityType.php new file mode 100644 index 000000000000..206035b01dd7 --- /dev/null +++ b/schema/Core/CustomGroup.entityType.php @@ -0,0 +1,289 @@ + 'CustomGroup', + 'table' => 'civicrm_custom_group', + 'class' => 'CRM_Core_DAO_CustomGroup', + 'getInfo' => fn() => [ + 'title' => ts('Custom Field Group'), + 'title_plural' => ts('Custom Field Groups'), + 'description' => ts('All extended (custom) properties are associated with a group. These are logical sets of related data.'), + 'log' => TRUE, + 'add' => '1.1', + 'label_field' => 'title', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/custom/group/edit?action=add&reset=1', + 'update' => 'civicrm/admin/custom/group/edit?action=update&reset=1&id=[id]', + 'preview' => 'civicrm/admin/custom/group/preview?reset=1&gid=[id]', + 'delete' => 'civicrm/admin/custom/group/delete?reset=1&id=[id]', + 'browse' => 'civicrm/admin/custom/group', + ], + 'getIndices' => fn() => [ + 'UI_title_extends' => [ + 'fields' => [ + 'title' => TRUE, + 'extends' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '5.47', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Custom Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Custom Group ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Custom Group Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Variable name/programmatic handle for this group.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'title' => [ + 'title' => ts('Custom Group Title'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Friendly Name.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'extends' => [ + 'title' => ts('Custom Group Extends'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'description' => ts('Type of object this group extends (can add other options later e.g. contact_address, etc.).'), + 'add' => '1.1', + 'default' => 'Contact', + 'input_attrs' => [ + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_CustomGroup::getCustomGroupExtendsOptions', + 'suffixes' => [ + 'name', + 'label', + 'grouping', + 'icon', + ], + ], + ], + 'extends_entity_column_id' => [ + 'title' => ts('Custom Group Subtype List'), + 'sql_type' => 'int unsigned', + 'input_type' => 'ChainSelect', + 'description' => ts('FK to civicrm_option_value.value (for option group custom_data_type)'), + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'control_field' => 'extends', + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_CustomGroup::getExtendsEntityColumnIdOptions', + 'suffixes' => [ + 'name', + 'label', + 'grouping', + ], + ], + ], + 'extends_entity_column_value' => [ + 'title' => ts('Custom Group Subtype'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'ChainSelect', + 'description' => ts('linking custom group for dynamic object'), + 'add' => '1.6', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, + 'input_attrs' => [ + 'control_field' => 'extends_entity_column_id', + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_CustomGroup::getExtendsEntityColumnValueOptions', + ], + ], + 'style' => [ + 'title' => ts('Custom Group Style'), + 'sql_type' => 'varchar(15)', + 'input_type' => 'Select', + 'description' => ts('Visual relationship between this form and its parent.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 15, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::customGroupStyle', + ], + ], + 'collapse_display' => [ + 'title' => ts('Collapse Custom Group?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Will this group be in collapsed or expanded mode on initial display ?'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'help_pre' => [ + 'title' => ts('Custom Group Pre Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display before fields in form.'), + 'add' => '1.1', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 80, + ], + ], + 'help_post' => [ + 'title' => ts('Custom Group Post Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display after fields in form.'), + 'add' => '1.1', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 80, + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Controls display order when multiple extended property groups are setup for the same class.'), + 'add' => '1.1', + 'default' => 1, + ], + 'is_active' => [ + 'title' => ts('Custom Group Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property active?'), + 'add' => '1.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'table_name' => [ + 'title' => ts('Table Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Name of the table that holds the values for this group.'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Table Name'), + 'maxlength' => 255, + ], + ], + 'is_multiple' => [ + 'title' => ts('Supports Multiple Records'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Does this group hold multiple values?'), + 'add' => '2.0', + 'default' => FALSE, + ], + 'min_multiple' => [ + 'title' => ts('Minimum Multiple Records'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('minimum number of multiple records (typically 0?)'), + 'add' => '2.2', + ], + 'max_multiple' => [ + 'title' => ts('Maximum Multiple Records'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('maximum number of multiple records, if 0 - no max'), + 'add' => '2.2', + ], + 'collapse_adv_display' => [ + 'title' => ts('Collapse Group Display'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Will this group be in collapsed or expanded mode on advanced search display ?'), + 'add' => '3.0', + 'default' => FALSE, + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who created this custom group'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('Custom Group Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time this custom group was created.'), + 'add' => '3.0', + ], + 'is_reserved' => [ + 'title' => ts('Reserved Group?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a reserved Custom Group?'), + 'add' => '4.4', + 'default' => FALSE, + ], + 'is_public' => [ + 'title' => ts('Custom Group Is Public?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property public?'), + 'add' => '4.7', + 'default' => TRUE, + ], + 'icon' => [ + 'title' => ts('Icon'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('crm-i icon class'), + 'add' => '5.28', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + ], +]; diff --git a/schema/Core/Dashboard.entityType.php b/schema/Core/Dashboard.entityType.php new file mode 100644 index 000000000000..9a82535cab9d --- /dev/null +++ b/schema/Core/Dashboard.entityType.php @@ -0,0 +1,150 @@ + 'Dashboard', + 'table' => 'civicrm_dashboard', + 'class' => 'CRM_Core_DAO_Dashboard', + 'getInfo' => fn() => [ + 'title' => ts('Dashboard'), + 'title_plural' => ts('Dashboards'), + 'description' => ts('Table to store dashboard.'), + 'add' => '3.1', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('DashletID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '3.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Domain for dashboard'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'name' => [ + 'title' => ts('Dashlet Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Internal name of dashlet.'), + 'add' => '4.4', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'label' => [ + 'title' => ts('Dashlet Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('dashlet title'), + 'add' => '3.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url' => [ + 'title' => ts('Dashlet URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('url in case of external dashlet'), + 'add' => '3.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'permission' => [ + 'title' => ts('Dashlet Permission'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Permission for the dashlet'), + 'add' => '3.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'permission_operator' => [ + 'title' => ts('Dashlet Permission Operator'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('Permission Operator'), + 'add' => '3.1', + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::andOr', + ], + ], + 'fullscreen_url' => [ + 'title' => ts('Fullscreen URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('fullscreen url for dashlet'), + 'add' => '3.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_active' => [ + 'title' => ts('Is Dashlet Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this dashlet active?'), + 'add' => '3.1', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_reserved' => [ + 'title' => ts('Is Dashlet Reserved?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this dashlet reserved?'), + 'add' => '3.1', + 'default' => FALSE, + ], + 'cache_minutes' => [ + 'title' => ts('Cache Minutes'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Number of minutes to cache dashlet content in browser localStorage.'), + 'add' => '4.7', + 'default' => 60, + ], + 'directive' => [ + 'title' => ts('Angular directive'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Element name of angular directive to invoke (lowercase hyphenated format)'), + 'add' => '5.33', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + ], +]; diff --git a/schema/Core/Discount.entityType.php b/schema/Core/Discount.entityType.php new file mode 100644 index 000000000000..fbc74b757877 --- /dev/null +++ b/schema/Core/Discount.entityType.php @@ -0,0 +1,109 @@ + 'Discount', + 'table' => 'civicrm_discount', + 'class' => 'CRM_Core_DAO_Discount', + 'getInfo' => fn() => [ + 'title' => ts('Discount'), + 'title_plural' => ts('Discounts'), + 'description' => ts('Stores discounts for events on the basis of date'), + 'log' => TRUE, + 'add' => '2.1', + ], + 'getIndices' => fn() => [ + 'index_entity' => [ + 'fields' => [ + 'entity_table' => TRUE, + 'entity_id' => TRUE, + ], + 'add' => '2.1', + ], + 'index_entity_option_id' => [ + 'fields' => [ + 'entity_table' => TRUE, + 'entity_id' => TRUE, + 'price_set_id' => TRUE, + ], + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Discount ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('primary key'), + 'add' => '2.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'), + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_Discount::entityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to entity table specified in entity_table column.'), + 'add' => '2.1', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'price_set_id' => [ + 'title' => ts('Price Set ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to civicrm_price_set'), + 'add' => '4.3', + 'unique_name' => 'participant_discount_name', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Price Set'), + 'control_field' => 'entity_id', + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_price_set', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'PriceSet', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'start_date' => [ + 'title' => ts('Discount Start Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Date when discount starts.'), + 'add' => '2.1', + ], + 'end_date' => [ + 'title' => ts('Discount End Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Date when discount ends.'), + 'add' => '2.1', + ], + ], +]; diff --git a/schema/Core/Domain.entityType.php b/schema/Core/Domain.entityType.php new file mode 100644 index 000000000000..689462b3870e --- /dev/null +++ b/schema/Core/Domain.entityType.php @@ -0,0 +1,94 @@ + 'Domain', + 'table' => 'civicrm_domain', + 'class' => 'CRM_Core_DAO_Domain', + 'getInfo' => fn() => [ + 'title' => ts('Domain'), + 'title_plural' => ts('Domains'), + 'description' => ts('Top-level hierarchy to support multi-org/domain installations. Define domains for multi-org installs, else all contacts belong to one domain.'), + 'add' => '1.1', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Domain ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Domain Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Name of Domain / Organization'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Domain Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Description of Domain.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'version' => [ + 'title' => ts('CiviCRM Version'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Text', + 'description' => ts('The civicrm version this instance is running'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 32, + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID. This is specifically not an FK to avoid circular constraints'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + ], + ], + 'locales' => [ + 'title' => ts('Supported Languages'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('list of locales supported by the current db state (NULL for single-lang install)'), + 'add' => '2.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + ], + 'locale_custom_strings' => [ + 'title' => ts('Language Customizations'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Locale specific string overrides'), + 'add' => '3.2', + 'serialize' => CRM_Core_DAO::SERIALIZE_PHP, + ], + ], +]; diff --git a/schema/Core/Email.entityType.php b/schema/Core/Email.entityType.php new file mode 100644 index 000000000000..f651c6e9ea3a --- /dev/null +++ b/schema/Core/Email.entityType.php @@ -0,0 +1,197 @@ + 'Email', + 'table' => 'civicrm_email', + 'class' => 'CRM_Core_DAO_Email', + 'getInfo' => fn() => [ + 'title' => ts('Email'), + 'title_plural' => ts('Emails'), + 'description' => ts('Email information for a specific location.'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-envelope-o', + 'label_field' => 'email', + ], + 'getIndices' => fn() => [ + 'index_location_type' => [ + 'fields' => [ + 'location_type_id' => TRUE, + ], + 'add' => '2.0', + ], + 'UI_email' => [ + 'fields' => [ + 'email' => TRUE, + ], + 'add' => '1.5', + ], + 'index_is_primary' => [ + 'fields' => [ + 'is_primary' => TRUE, + ], + 'add' => '2.0', + ], + 'index_is_billing' => [ + 'fields' => [ + 'is_billing' => TRUE, + ], + 'add' => '2.0', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Email ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Email ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'location_type_id' => [ + 'title' => ts('Email Location Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which Location does this email belong to.'), + 'add' => '2.0', + 'pseudoconstant' => [ + 'table' => 'civicrm_location_type', + 'key_column' => 'id', + 'label_column' => 'display_name', + ], + ], + 'email' => [ + 'title' => ts('Email'), + 'sql_type' => 'varchar(254)', + 'input_type' => 'Email', + 'description' => ts('Email address'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '30', + 'maxlength' => 254, + ], + ], + 'is_primary' => [ + 'title' => ts('Is Primary'), + 'sql_type' => 'boolean', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Is this the primary email address'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'is_billing' => [ + 'title' => ts('Is Billing Email?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this the billing?'), + 'add' => '2.0', + 'default' => FALSE, + ], + 'on_hold' => [ + 'title' => ts('On Hold'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'), + 'add' => '1.1', + 'default' => 0, + 'usage' => [ + 'export', + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions', + ], + ], + 'is_bulkmail' => [ + 'title' => ts('Use for Bulk Mail'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this address for bulk mail ?'), + 'add' => '1.9', + 'default' => FALSE, + 'usage' => [ + 'export', + ], + ], + 'hold_date' => [ + 'title' => ts('Hold Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('When the address went on bounce hold'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Hold Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'reset_date' => [ + 'title' => ts('Reset Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('When the address bounce status was last reset'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Reset Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'signature_text' => [ + 'title' => ts('Signature Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Text formatted signature for the email.'), + 'add' => '3.2', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Signature Text'), + ], + ], + 'signature_html' => [ + 'title' => ts('Signature Html'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('HTML formatted signature for the email.'), + 'add' => '3.2', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Signature HTML'), + ], + ], + ], +]; diff --git a/schema/Core/EntityFile.entityType.php b/schema/Core/EntityFile.entityType.php new file mode 100644 index 000000000000..665644fc901c --- /dev/null +++ b/schema/Core/EntityFile.entityType.php @@ -0,0 +1,78 @@ + 'EntityFile', + 'table' => 'civicrm_entity_file', + 'class' => 'CRM_Core_DAO_EntityFile', + 'getInfo' => fn() => [ + 'title' => ts('Entityfile'), + 'title_plural' => ts('Entityfiles'), + 'description' => ts('Attaches (joins) uploaded files (images, documents, etc.) to entities (Contacts, Groups, Actions).'), + 'log' => TRUE, + 'add' => '1.5', + ], + 'getIndices' => fn() => [ + 'UI_entity_id_entity_table_file_id' => [ + 'fields' => [ + 'entity_id' => TRUE, + 'entity_table' => TRUE, + 'file_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Entity File ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('primary key'), + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('physical tablename for entity being joined to file, e.g. civicrm_contact'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_File::getEntityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to entity table specified in entity_table column.'), + 'add' => '1.5', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'file_id' => [ + 'title' => ts('File ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to civicrm_file'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('File'), + ], + 'entity_reference' => [ + 'entity' => 'File', + 'key' => 'id', + ], + ], + ], +]; diff --git a/schema/Core/EntityTag.entityType.php b/schema/Core/EntityTag.entityType.php new file mode 100644 index 000000000000..c99853ad2890 --- /dev/null +++ b/schema/Core/EntityTag.entityType.php @@ -0,0 +1,86 @@ + 'EntityTag', + 'table' => 'civicrm_entity_tag', + 'class' => 'CRM_Core_DAO_EntityTag', + 'getInfo' => fn() => [ + 'title' => ts('Entitytag'), + 'title_plural' => ts('Entitytags'), + 'description' => ts('Tag entities (Contacts, Groups, Actions) to categories.'), + 'log' => TRUE, + 'add' => '1.1', + ], + 'getIndices' => fn() => [ + 'UI_entity_id_entity_table_tag_id' => [ + 'fields' => [ + 'entity_id' => TRUE, + 'entity_table' => TRUE, + 'tag_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '3.4', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Entity Tag ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('primary key'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('physical tablename for entity being joined to file, e.g. civicrm_contact'), + 'add' => '3.2', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'tag_used_for', + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to entity table specified in entity_table column.'), + 'add' => '3.2', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'tag_id' => [ + 'title' => ts('Tag ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to civicrm_tag'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Tag'), + 'control_field' => 'entity_table', + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_tag', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'label', + 'condition' => 'is_tagset != 1', + ], + 'entity_reference' => [ + 'entity' => 'Tag', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Core/Extension.entityType.php b/schema/Core/Extension.entityType.php new file mode 100644 index 000000000000..e99e6b2e528b --- /dev/null +++ b/schema/Core/Extension.entityType.php @@ -0,0 +1,136 @@ + 'Extension', + 'table' => 'civicrm_extension', + 'class' => 'CRM_Core_DAO_Extension', + 'getInfo' => fn() => [ + 'title' => ts('Extension'), + 'title_plural' => ts('Extensions'), + 'description' => ts('FIXME'), + 'log' => FALSE, + 'add' => '4.2', + ], + 'getIndices' => fn() => [ + 'UI_extension_full_name' => [ + 'fields' => [ + 'full_name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.2', + ], + 'UI_extension_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'add' => '4.2', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Extension ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Local Extension ID'), + 'add' => '4.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'type' => [ + 'title' => ts('Type'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'required' => TRUE, + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getExtensionTypes', + ], + ], + 'full_name' => [ + 'title' => ts('Key'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Fully qualified extension name'), + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Short name'), + 'add' => '4.2', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'label' => [ + 'title' => ts('Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Short, printable name'), + 'add' => '4.2', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'file' => [ + 'title' => ts('File'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Primary PHP file'), + 'add' => '4.2', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'schema_version' => [ + 'title' => ts('Schema Version'), + 'sql_type' => 'varchar(63)', + 'input_type' => 'Text', + 'description' => ts('Revision code of the database schema; the format is module-defined'), + 'add' => '4.2', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 63, + ], + ], + 'is_active' => [ + 'title' => ts('Extension is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'description' => ts('Is this extension active?'), + 'add' => '4.2', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Core/File.entityType.php b/schema/Core/File.entityType.php new file mode 100644 index 000000000000..f40ba2f7e9bb --- /dev/null +++ b/schema/Core/File.entityType.php @@ -0,0 +1,95 @@ + 'File', + 'table' => 'civicrm_file', + 'class' => 'CRM_Core_DAO_File', + 'getInfo' => fn() => [ + 'title' => ts('File'), + 'title_plural' => ts('Files'), + 'description' => ts('Data store for uploaded (attached) files (pointer to file on disk OR blob). Maybe be joined to entities via custom_value.file_id or entity_file table.'), + 'log' => TRUE, + 'add' => '1.5', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('File ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique ID'), + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'file_type_id' => [ + 'title' => ts('File Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.'), + 'add' => '1.5', + 'pseudoconstant' => [ + 'option_group_name' => 'file_type', + ], + ], + 'mime_type' => [ + 'title' => ts('Mime Type'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('mime type of the document'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'uri' => [ + 'title' => ts('Path'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('uri of the file on disk'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'document' => [ + 'title' => ts('File Contents'), + 'sql_type' => 'mediumblob', + 'input_type' => NULL, + 'description' => ts('contents of the document'), + 'add' => '1.5', + ], + 'description' => [ + 'title' => ts('File Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Additional descriptive text regarding this attachment (optional).'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'upload_date' => [ + 'title' => ts('File Upload Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that this attachment was uploaded or written to server.'), + 'add' => '1.5', + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who uploaded this file'), + 'add' => '5.3', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Core/IM.entityType.php b/schema/Core/IM.entityType.php new file mode 100644 index 000000000000..5e43f24c8276 --- /dev/null +++ b/schema/Core/IM.entityType.php @@ -0,0 +1,124 @@ + 'IM', + 'table' => 'civicrm_im', + 'class' => 'CRM_Core_DAO_IM', + 'getInfo' => fn() => [ + 'title' => ts('Instant Messaging'), + 'title_plural' => ts('Instant Messaging'), + 'description' => ts('IM information for a specific location.'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-comments-o', + 'label_field' => 'name', + ], + 'getIndices' => fn() => [ + 'index_location_type' => [ + 'fields' => [ + 'location_type_id' => TRUE, + ], + 'add' => '2.0', + ], + 'UI_provider_id' => [ + 'fields' => [ + 'provider_id' => TRUE, + ], + 'add' => '1.6', + ], + 'index_is_primary' => [ + 'fields' => [ + 'is_primary' => TRUE, + ], + 'add' => '2.0', + ], + 'index_is_billing' => [ + 'fields' => [ + 'is_billing' => TRUE, + ], + 'add' => '2.0', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Instant Messenger ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique IM ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'location_type_id' => [ + 'title' => ts('IM Location Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which Location does this email belong to.'), + 'add' => '2.0', + 'pseudoconstant' => [ + 'table' => 'civicrm_location_type', + 'key_column' => 'id', + 'label_column' => 'display_name', + ], + ], + 'name' => [ + 'title' => ts('IM Screen Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('IM screen name'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'provider_id' => [ + 'title' => ts('IM Provider'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which IM Provider does this screen name belong to.'), + 'add' => '1.1', + 'pseudoconstant' => [ + 'option_group_name' => 'instant_messenger_service', + ], + ], + 'is_primary' => [ + 'title' => ts('Is Primary'), + 'sql_type' => 'boolean', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Is this the primary IM for this contact and location.'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'is_billing' => [ + 'title' => ts('Is IM Billing?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this the billing?'), + 'add' => '2.0', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Core/Job.entityType.php b/schema/Core/Job.entityType.php new file mode 100644 index 000000000000..a63e646a1a17 --- /dev/null +++ b/schema/Core/Job.entityType.php @@ -0,0 +1,164 @@ + 'Job', + 'table' => 'civicrm_job', + 'class' => 'CRM_Core_DAO_Job', + 'getInfo' => fn() => [ + 'title' => ts('Job'), + 'title_plural' => ts('Jobs'), + 'description' => ts('Scheduled job.'), + 'log' => FALSE, + 'add' => '4.1', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/job/add?reset=1&action=add', + 'delete' => 'civicrm/admin/job/edit?reset=1&action=delete&id=[id]', + 'update' => 'civicrm/admin/job/edit?reset=1&action=update&id=[id]', + 'browse' => 'civicrm/admin/job', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Job ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Job ID'), + 'add' => '4.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Which Domain is this scheduled job for'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'run_frequency' => [ + 'title' => ts('Job Frequency'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Scheduled job run frequency.'), + 'add' => '4.1', + 'default' => 'Daily', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getJobFrequency', + ], + ], + 'last_run' => [ + 'title' => ts('Last Run'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('When was this cron entry last run'), + 'add' => '4.1', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Last Run'), + ], + ], + 'last_run_end' => [ + 'title' => ts('Last Run End'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('When did this cron entry last finish running'), + 'add' => '5.72', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Last Run End'), + ], + ], + 'scheduled_run_date' => [ + 'title' => ts('Scheduled Run Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('When is this cron entry scheduled to run'), + 'add' => '4.7', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Scheduled Run Date'), + ], + ], + 'name' => [ + 'title' => ts('Job Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Title of the job'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Job Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'TextArea', + 'description' => ts('Description of the job'), + 'add' => '4.1', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 60, + 'maxlength' => 255, + ], + ], + 'api_entity' => [ + 'title' => ts('API Entity'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Entity of the job api call'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'api_action' => [ + 'title' => ts('API Action'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Action of the job api call'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'parameters' => [ + 'title' => ts('API Parameters'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('List of parameters to the command.'), + 'add' => '4.1', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 60, + ], + ], + 'is_active' => [ + 'title' => ts('Job Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this job active?'), + 'add' => '4.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Core/JobLog.entityType.php b/schema/Core/JobLog.entityType.php new file mode 100644 index 000000000000..211dab636d33 --- /dev/null +++ b/schema/Core/JobLog.entityType.php @@ -0,0 +1,102 @@ + 'JobLog', + 'table' => 'civicrm_job_log', + 'class' => 'CRM_Core_DAO_JobLog', + 'getInfo' => fn() => [ + 'title' => ts('Joblog'), + 'title_plural' => ts('Joblogs'), + 'description' => ts('Scheduled jobs log.'), + 'log' => FALSE, + 'add' => '4.1', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Job Log ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Job log entry ID'), + 'add' => '4.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Which Domain is this scheduled job for'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'run_time' => [ + 'title' => ts('Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('Log entry date'), + 'add' => '4.1', + ], + 'job_id' => [ + 'title' => ts('Job ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Pointer to job id'), + 'add' => '4.1', + 'entity_reference' => [ + 'entity' => 'Job', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'name' => [ + 'title' => ts('Job Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Title of the job'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'command' => [ + 'title' => ts('Command'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Full path to file containing job script'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Title line of log entry'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'data' => [ + 'title' => ts('Extended Data'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Potential extended data for specific job run (e.g. tracebacks).'), + 'add' => '4.1', + ], + ], +]; diff --git a/schema/Core/LocBlock.entityType.php b/schema/Core/LocBlock.entityType.php new file mode 100644 index 000000000000..3b8d346245af --- /dev/null +++ b/schema/Core/LocBlock.entityType.php @@ -0,0 +1,139 @@ + 'LocBlock', + 'table' => 'civicrm_loc_block', + 'class' => 'CRM_Core_DAO_LocBlock', + 'getInfo' => fn() => [ + 'title' => ts('Location'), + 'title_plural' => ts('Locations'), + 'description' => ts('Define location specific properties'), + 'log' => TRUE, + 'add' => '2.0', + 'icon' => 'fa-map-o', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Location Block ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique ID'), + 'add' => '2.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'address_id' => [ + 'title' => ts('Address ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Address'), + ], + 'entity_reference' => [ + 'entity' => 'Address', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'email_id' => [ + 'title' => ts('Email ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Email'), + ], + 'entity_reference' => [ + 'entity' => 'Email', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'phone_id' => [ + 'title' => ts('Phone ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Phone'), + ], + 'entity_reference' => [ + 'entity' => 'Phone', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'im_id' => [ + 'title' => ts('IM ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Instant Messenger'), + ], + 'entity_reference' => [ + 'entity' => 'IM', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'address_2_id' => [ + 'title' => ts('Address 2 ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Address 2'), + ], + 'entity_reference' => [ + 'entity' => 'Address', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'email_2_id' => [ + 'title' => ts('Email 2 ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Email 2'), + ], + 'entity_reference' => [ + 'entity' => 'Email', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'phone_2_id' => [ + 'title' => ts('Phone 2 ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Phone 2'), + ], + 'entity_reference' => [ + 'entity' => 'Phone', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'im_2_id' => [ + 'title' => ts('IM 2 ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Instant Messenger 2'), + ], + 'entity_reference' => [ + 'entity' => 'IM', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Core/LocationType.entityType.php b/schema/Core/LocationType.entityType.php new file mode 100644 index 000000000000..d7d76b40c695 --- /dev/null +++ b/schema/Core/LocationType.entityType.php @@ -0,0 +1,121 @@ + 'LocationType', + 'table' => 'civicrm_location_type', + 'class' => 'CRM_Core_DAO_LocationType', + 'getInfo' => fn() => [ + 'title' => ts('Locationtype'), + 'title_plural' => ts('Locationtypes'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.1', + 'label_field' => 'display_name', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/locationType/edit?action=add&reset=1', + 'update' => 'civicrm/admin/locationType/edit?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/locationType/edit?action=delete&id=[id]&reset=1', + 'browse' => 'civicrm/admin/locationType', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Location Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Location Type ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Location Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Location Type Name.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'display_name' => [ + 'title' => ts('Display Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Location Type Display Name.'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'vcard_name' => [ + 'title' => ts('vCard Location Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('vCard Location Type Name.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Location Type Description.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_reserved' => [ + 'title' => ts('Location Type is Reserved?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this location type a predefined system location?'), + 'add' => '1.1', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Reserved'), + ], + ], + 'is_active' => [ + 'title' => ts('Location Type is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property active?'), + 'add' => '1.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_default' => [ + 'title' => ts('Default Location Type?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this location type the default?'), + 'add' => '1.1', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + ], +]; diff --git a/schema/Core/Log.entityType.php b/schema/Core/Log.entityType.php new file mode 100644 index 000000000000..7fafa0ee133a --- /dev/null +++ b/schema/Core/Log.entityType.php @@ -0,0 +1,86 @@ + 'Log', + 'table' => 'civicrm_log', + 'class' => 'CRM_Core_DAO_Log', + 'getInfo' => fn() => [ + 'title' => ts('Log'), + 'title_plural' => ts('Logs'), + 'description' => ts('Log can be linked to any object in the application.'), + 'add' => '1.5', + ], + 'getIndices' => fn() => [ + 'index_entity' => [ + 'fields' => [ + 'entity_table' => TRUE, + 'entity_id' => TRUE, + ], + 'add' => '1.5', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Log ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Log ID'), + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name of table where item being referenced is stored.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to the referenced item.'), + 'add' => '1.5', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'data' => [ + 'title' => ts('Data'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Updates does to this object if any.'), + 'add' => '1.5', + ], + 'modified_id' => [ + 'title' => ts('Modified By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID of person under whose credentials this data modification was made.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Modified By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'modified_date' => [ + 'title' => ts('Modified Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('When was the referenced entity created or modified or deleted.'), + 'add' => '1.5', + ], + ], +]; diff --git a/schema/Core/MailSettings.entityType.php b/schema/Core/MailSettings.entityType.php new file mode 100644 index 000000000000..1a2cafeb9fc4 --- /dev/null +++ b/schema/Core/MailSettings.entityType.php @@ -0,0 +1,278 @@ + 'MailSettings', + 'table' => 'civicrm_mail_settings', + 'class' => 'CRM_Core_DAO_MailSettings', + 'getInfo' => fn() => [ + 'title' => ts('Mail Account'), + 'title_plural' => ts('Mail Accounts'), + 'description' => ts('Various email accounts for use by CiviMail (and its processor)'), + 'add' => '2.2', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/mailSettings/edit?action=add&reset=1', + 'update' => 'civicrm/admin/mailSettings/edit?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/mailSettings/edit?action=delete&id=[id]&reset=1', + 'browse' => 'civicrm/admin/mailSettings', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mail Settings ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('primary key'), + 'add' => '2.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Which Domain is this match entry for'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'name' => [ + 'title' => ts('Mail Settings Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('name of this group of settings'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_default' => [ + 'title' => ts('Is Default Mail Settings?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('whether this is the default set of settings for this domain'), + 'add' => '2.2', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'domain' => [ + 'title' => ts('email Domain'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('email address domain (the part after @)'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'localpart' => [ + 'title' => ts('email Local Part'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('optional local part (like civimail+ for addresses like civimail+s.1.2@example.com)'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'return_path' => [ + 'title' => ts('Return Path'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('contents of the Return-Path header'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'protocol' => [ + 'title' => ts('Protocol'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'description' => ts('name of the protocol to use for polling (like IMAP, POP3 or Maildir)'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'mail_protocol', + ], + ], + 'server' => [ + 'title' => ts('Mail Server'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('server to use when polling'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'port' => [ + 'title' => ts('Mail Port'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('port to use when polling'), + 'add' => '2.2', + ], + 'username' => [ + 'title' => ts('Mail Account Username'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('username to use when polling'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'password' => [ + 'title' => ts('Mail Account Password'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('password to use when polling'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_ssl' => [ + 'title' => ts('Mail Account Uses SSL'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('whether to use SSL or not'), + 'add' => '2.2', + 'default' => FALSE, + ], + 'source' => [ + 'title' => ts('Mail Folder'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('folder to poll from when using IMAP, path to poll from when using Maildir, etc.'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'activity_status' => [ + 'title' => ts('Activity Status'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'description' => ts('Name of status to use when creating email to activity.'), + 'add' => '4.7', + 'input_attrs' => [ + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'activity_status', + 'key_column' => 'name', + ], + ], + 'is_non_case_email_skipped' => [ + 'title' => ts('Skip emails which do not have a Case ID or Case hash'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Enabling this option will have CiviCRM skip any emails that do not have the Case ID or Case Hash so that the system will only process emails that can be placed on case records. Any emails that are not processed will be moved to the ignored folder.'), + 'add' => '5.31', + 'default' => FALSE, + ], + 'is_contact_creation_disabled_if_no_match' => [ + 'title' => ts('Do not create new contacts when filing emails'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('If this option is enabled, CiviCRM will not create new contacts when filing emails.'), + 'add' => '5.31', + 'default' => FALSE, + ], + 'is_active' => [ + 'title' => ts('Enabled?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Ignored for bounce processing, only for email-to-activity'), + 'add' => '5.66', + 'default' => TRUE, + ], + 'activity_type_id' => [ + 'title' => ts('Activity Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Implicit FK to civicrm_option_value where option_group = activity_type'), + 'add' => '5.66', + 'pseudoconstant' => [ + 'option_group_name' => 'activity_type', + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Foreign key to the Campaign.'), + 'add' => '5.66', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'activity_source' => [ + 'title' => ts('Activity Source'), + 'sql_type' => 'varchar(4)', + 'input_type' => 'Select', + 'description' => ts('Which email recipient to add as the activity source (from, to, cc, bcc).'), + 'add' => '5.66', + 'input_attrs' => [ + 'maxlength' => 4, + ], + ], + 'activity_targets' => [ + 'title' => ts('Activity Targets'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Select', + 'description' => ts('Which email recipients to add as the activity targets (from, to, cc, bcc).'), + 'add' => '5.66', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'input_attrs' => [ + 'maxlength' => 16, + ], + ], + 'activity_assignees' => [ + 'title' => ts('Activity Assignees'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Select', + 'description' => ts('Which email recipients to add as the activity assignees (from, to, cc, bcc).'), + 'add' => '5.66', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'input_attrs' => [ + 'maxlength' => 16, + ], + ], + ], +]; diff --git a/schema/Core/Managed.entityType.php b/schema/Core/Managed.entityType.php new file mode 100644 index 000000000000..ef99e90109a0 --- /dev/null +++ b/schema/Core/Managed.entityType.php @@ -0,0 +1,108 @@ + 'Managed', + 'table' => 'civicrm_managed', + 'class' => 'CRM_Core_DAO_Managed', + 'getInfo' => fn() => [ + 'title' => ts('Managed Record'), + 'title_plural' => ts('Managed Records'), + 'description' => ts('List of declaratively managed objects'), + 'log' => FALSE, + 'add' => '4.2', + ], + 'getIndices' => fn() => [ + 'UI_managed_module_name' => [ + 'fields' => [ + 'module' => TRUE, + 'name' => TRUE, + ], + 'add' => '4.2', + ], + 'UI_managed_entity' => [ + 'fields' => [ + 'entity_type' => TRUE, + 'entity_id' => TRUE, + ], + 'add' => '4.2', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Managed ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Surrogate Key'), + 'add' => '4.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'module' => [ + 'title' => ts('Module'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Name of the module which declared this object (soft FK to civicrm_extension.full_name)'), + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_Managed::getBaseModules', + ], + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Symbolic name used by the module to identify the object'), + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'entity_type' => [ + 'title' => ts('Entity Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('API entity type'), + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Soft foreign key to the referenced item.'), + 'add' => '4.2', + ], + 'cleanup' => [ + 'title' => ts('Cleanup Setting'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Policy on when to cleanup entity (always, never, unused)'), + 'add' => '4.5', + 'default' => 'always', + 'input_attrs' => [ + 'maxlength' => 16, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_ManagedEntities::getCleanupOptions', + ], + ], + 'entity_modified_date' => [ + 'title' => ts('Entity Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('When the managed entity was changed from its original settings.'), + 'add' => '5.45', + 'default' => NULL, + ], + ], +]; diff --git a/schema/Core/Mapping.entityType.php b/schema/Core/Mapping.entityType.php new file mode 100644 index 000000000000..448d83fd27ca --- /dev/null +++ b/schema/Core/Mapping.entityType.php @@ -0,0 +1,71 @@ + 'Mapping', + 'table' => 'civicrm_mapping', + 'class' => 'CRM_Core_DAO_Mapping', + 'getInfo' => fn() => [ + 'title' => ts('Field Mapping'), + 'title_plural' => ts('Field Mappings'), + 'description' => ts('Store field mappings in import or export for reuse'), + 'add' => '1.2', + 'label_field' => 'name', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/mapping/edit?reset=1&action=add', + 'browse' => 'civicrm/admin/mapping?reset=1', + 'update' => 'civicrm/admin/mapping/edit?reset=1&action=update&id=[id]', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.2', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mapping ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Mapping ID'), + 'add' => '1.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Mapping Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Unique name of Mapping'), + 'add' => '1.2', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Description of Mapping.'), + 'add' => '1.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'mapping_type_id' => [ + 'title' => ts('Mapping Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Mapping Type'), + 'add' => '2.1', + 'pseudoconstant' => [ + 'option_group_name' => 'mapping_type', + ], + ], + ], +]; diff --git a/schema/Core/MappingField.entityType.php b/schema/Core/MappingField.entityType.php new file mode 100644 index 000000000000..7cec1870d8cd --- /dev/null +++ b/schema/Core/MappingField.entityType.php @@ -0,0 +1,169 @@ + 'MappingField', + 'table' => 'civicrm_mapping_field', + 'class' => 'CRM_Core_DAO_MappingField', + 'getInfo' => fn() => [ + 'title' => ts('Mappingfield'), + 'title_plural' => ts('Mappingfields'), + 'description' => ts('Individual field mappings for Mapping'), + 'add' => '1.2', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mapping Field ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Mapping Field ID'), + 'add' => '1.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'mapping_id' => [ + 'title' => ts('Mapping ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Mapping to which this field belongs'), + 'add' => '1.2', + 'input_attrs' => [ + 'label' => ts('Mapping'), + ], + 'entity_reference' => [ + 'entity' => 'Mapping', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'name' => [ + 'title' => ts('Field Name (or unique reference)'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Mapping field key'), + 'add' => '1.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'contact_type' => [ + 'title' => ts('Contact Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('Contact Type in mapping'), + 'add' => '1.2', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'column_number' => [ + 'title' => ts('Column Number to map to'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Column number for mapping set'), + 'add' => '1.2', + ], + 'location_type_id' => [ + 'title' => ts('Location type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Location type of this mapping, if required'), + 'add' => '1.2', + 'input_attrs' => [ + 'label' => ts('Location type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_location_type', + 'key_column' => 'id', + 'label_column' => 'display_name', + ], + 'entity_reference' => [ + 'entity' => 'LocationType', + 'key' => 'id', + ], + ], + 'phone_type_id' => [ + 'title' => ts('Phone type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Which type of phone does this number belongs.'), + 'add' => '2.2', + ], + 'im_provider_id' => [ + 'title' => ts('IM provider ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which type of IM Provider does this name belong.'), + 'add' => '3.0', + 'pseudoconstant' => [ + 'option_group_name' => 'instant_messenger_service', + ], + ], + 'website_type_id' => [ + 'title' => ts('Website type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which type of website does this site belong'), + 'add' => '3.2', + 'pseudoconstant' => [ + 'option_group_name' => 'website_type', + ], + ], + 'relationship_type_id' => [ + 'title' => ts('Relationship type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Relationship type, if required'), + 'add' => '1.2', + 'input_attrs' => [ + 'label' => ts('Relationship type'), + ], + 'entity_reference' => [ + 'entity' => 'RelationshipType', + 'key' => 'id', + ], + ], + 'relationship_direction' => [ + 'title' => ts('Relationship Direction'), + 'sql_type' => 'varchar(6)', + 'input_type' => 'Text', + 'add' => '1.7', + 'input_attrs' => [ + 'maxlength' => 6, + ], + ], + 'grouping' => [ + 'title' => ts('Field Grouping'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Used to group mapping_field records into related sets (e.g. for criteria sets in search builder mappings).'), + 'add' => '1.5', + 'default' => 1, + ], + 'operator' => [ + 'title' => ts('Operator'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Select', + 'description' => ts('SQL WHERE operator for search-builder mapping fields (search criteria).'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 16, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getSearchBuilderOperators', + ], + ], + 'value' => [ + 'title' => ts('Search builder where clause'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('SQL WHERE value for search-builder mapping fields.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + ], +]; diff --git a/schema/Core/Menu.entityType.php b/schema/Core/Menu.entityType.php new file mode 100644 index 000000000000..049e238cfb5d --- /dev/null +++ b/schema/Core/Menu.entityType.php @@ -0,0 +1,244 @@ + 'Menu', + 'table' => 'civicrm_menu', + 'class' => 'CRM_Core_DAO_Menu', + 'getInfo' => fn() => [ + 'title' => ts('Menu'), + 'title_plural' => ts('Menus'), + 'description' => ts('Table to store menu items for all civicrm components.'), + 'add' => '1.1', + ], + 'getIndices' => fn() => [ + 'UI_path_domain_id' => [ + 'fields' => [ + 'path' => TRUE, + 'domain_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Menu ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '2.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Which Domain is this menu item for'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'path' => [ + 'title' => ts('Path'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Path Name'), + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'path_arguments' => [ + 'title' => ts('Arguments'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Arguments to pass to the url'), + 'add' => '2.1', + ], + 'title' => [ + 'title' => ts('Menu Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'access_callback' => [ + 'title' => ts('Access Callback'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Function to call to check access permissions'), + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'access_arguments' => [ + 'title' => ts('Access Arguments'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Arguments to pass to access callback'), + 'add' => '2.1', + ], + 'page_callback' => [ + 'title' => ts('Page Callback'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('function to call for this url'), + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'page_arguments' => [ + 'title' => ts('Page Arguments'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Arguments to pass to page callback'), + 'add' => '2.1', + ], + 'breadcrumb' => [ + 'title' => ts('Breadcrumb'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Breadcrumb for the path.'), + 'add' => '2.1', + ], + 'return_url' => [ + 'title' => ts('Return Url'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Url where a page should redirected to, if next url not known.'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Return URL'), + 'maxlength' => 255, + ], + ], + 'return_url_args' => [ + 'title' => ts('Return Url Args'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Arguments to pass to return_url'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Return URL Arguments'), + 'maxlength' => 255, + ], + ], + 'component_id' => [ + 'title' => ts('Component ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Component that this menu item belongs to'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Component'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_component', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Component', + 'key' => 'id', + ], + ], + 'is_active' => [ + 'title' => ts('Enabled?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this menu item active?'), + 'add' => '2.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_public' => [ + 'title' => ts('Public?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this menu accessible to the public?'), + 'add' => '2.1', + 'default' => FALSE, + ], + 'is_exposed' => [ + 'title' => ts('Exposed?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this menu exposed to the navigation system?'), + 'add' => '2.1', + 'default' => TRUE, + ], + 'is_ssl' => [ + 'title' => ts('Use SSL?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should this menu be exposed via SSL if enabled?'), + 'add' => '2.1', + 'default' => TRUE, + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Ordering of the menu items in various blocks.'), + 'add' => '2.1', + 'default' => 1, + ], + 'type' => [ + 'title' => ts('Type'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Drupal menu type.'), + 'add' => '2.1', + 'default' => 1, + ], + 'page_type' => [ + 'title' => ts('Page Type'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('CiviCRM menu type.'), + 'add' => '2.1', + 'default' => 1, + ], + 'skipBreadcrumb' => [ + 'title' => ts('Hide Breadcrumb?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('skip this url being exposed to breadcrumb'), + 'add' => '2.2', + 'default' => FALSE, + ], + 'module_data' => [ + 'title' => ts('Other menu data'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('All other menu metadata not stored in other fields'), + 'add' => '4.7', + ], + ], +]; diff --git a/schema/Core/MessageTemplate.entityType.php b/schema/Core/MessageTemplate.entityType.php new file mode 100644 index 000000000000..46dd327cbf2b --- /dev/null +++ b/schema/Core/MessageTemplate.entityType.php @@ -0,0 +1,140 @@ + 'MessageTemplate', + 'table' => 'civicrm_msg_template', + 'class' => 'CRM_Core_DAO_MessageTemplate', + 'getInfo' => fn() => [ + 'title' => ts('Message Template'), + 'title_plural' => ts('Message Templates'), + 'description' => ts('Users will need a way to save and retrieve templates with tokens for use in recurring email communication tasks'), + 'add' => '1.6', + 'icon' => 'fa-newspaper-o', + 'label_field' => 'msg_title', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/messageTemplates/add?action=add&reset=1', + 'view' => 'civicrm/admin/messageTemplates/add?action=view&id=[id]&reset=1', + 'update' => 'civicrm/admin/messageTemplates/add?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/messageTemplates?action=delete&id=[id]&reset=1', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Message Template ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Message Template ID'), + 'add' => '1.6', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'msg_title' => [ + 'title' => ts('Message Template Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Descriptive title of message'), + 'add' => '1.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'msg_subject' => [ + 'title' => ts('Message Template Subject'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'description' => ts('Subject for email message.'), + 'add' => '1.6', + ], + 'msg_text' => [ + 'title' => ts('Message Template Text'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Text formatted message'), + 'add' => '1.6', + 'input_attrs' => [ + 'rows' => 10, + 'cols' => 75, + ], + ], + 'msg_html' => [ + 'title' => ts('Message Template HTML'), + 'sql_type' => 'longtext', + 'input_type' => 'RichTextEditor', + 'description' => ts('HTML formatted message'), + 'add' => '1.6', + 'input_attrs' => [ + 'rows' => 10, + 'cols' => 75, + ], + ], + 'is_active' => [ + 'title' => ts('Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '1.6', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'workflow_id' => [ + 'title' => ts('Deprecated field for Message Template Workflow.'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('a pseudo-FK to civicrm_option_value'), + 'add' => '3.1', + ], + 'workflow_name' => [ + 'title' => ts('Message Template Workflow Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '5.26', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_default' => [ + 'title' => ts('Message Template Is Default?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('is this the default message template for the workflow referenced by workflow_id?'), + 'add' => '3.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'is_reserved' => [ + 'title' => ts('Message Template Is Reserved?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('is this the reserved message template which we ship for the workflow referenced by workflow_id?'), + 'add' => '3.1', + 'default' => FALSE, + ], + 'is_sms' => [ + 'title' => ts('Message Template is used for SMS?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this message template used for sms?'), + 'add' => '4.5', + 'default' => FALSE, + ], + 'pdf_format_id' => [ + 'title' => ts('Message Template Format'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('a pseudo-FK to civicrm_option_value containing PDF Page Format.'), + 'add' => '3.4', + 'pseudoconstant' => [ + 'option_group_name' => 'pdf_format', + 'key_column' => 'id', + ], + ], + ], +]; diff --git a/schema/Core/Navigation.entityType.php b/schema/Core/Navigation.entityType.php new file mode 100644 index 000000000000..03fcc0fb3daa --- /dev/null +++ b/schema/Core/Navigation.entityType.php @@ -0,0 +1,163 @@ + 'Navigation', + 'table' => 'civicrm_navigation', + 'class' => 'CRM_Core_DAO_Navigation', + 'getInfo' => fn() => [ + 'title' => ts('Menu Item'), + 'title_plural' => ts('Menu Items'), + 'description' => ts('Table to store navigation.'), + 'add' => '3.0', + 'label_field' => 'label', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Navigation ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '3.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Which Domain is this navigation item for'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'label' => [ + 'title' => ts('Navigation Item Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Navigation Title'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'name' => [ + 'title' => ts('Navigation Item Machine Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Internal Name'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url' => [ + 'title' => ts('Url'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('url in case of custom navigation link'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'icon' => [ + 'title' => ts('Icon'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('CSS class name for an icon'), + 'add' => '4.7', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'permission' => [ + 'title' => ts('Required Permission'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Permission(s) needed to access menu item'), + 'add' => '3.0', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'permission_operator' => [ + 'title' => ts('Permission Operator'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('Operator to use if item has more than one permission'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::andOr', + ], + ], + 'parent_id' => [ + 'title' => ts('parent ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Parent navigation item, used for grouping'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('parent'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_navigation', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'label', + ], + 'entity_reference' => [ + 'entity' => 'Navigation', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'is_active' => [ + 'title' => ts('Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this navigation item active?'), + 'add' => '3.0', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'has_separator' => [ + 'title' => ts('Separator'), + 'sql_type' => 'tinyint', + 'input_type' => 'Select', + 'description' => ts('Place a separator either before or after this menu item.'), + 'add' => '3.0', + 'default' => 0, + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::navigationMenuSeparator', + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Ordering of the navigation items in various blocks.'), + 'add' => '3.0', + 'default' => 0, + ], + ], +]; diff --git a/schema/Core/Note.entityType.php b/schema/Core/Note.entityType.php new file mode 100644 index 000000000000..19114314c797 --- /dev/null +++ b/schema/Core/Note.entityType.php @@ -0,0 +1,166 @@ + 'Note', + 'table' => 'civicrm_note', + 'class' => 'CRM_Core_DAO_Note', + 'getInfo' => fn() => [ + 'title' => ts('Note'), + 'title_plural' => ts('Notes'), + 'description' => ts('Notes can be linked to any object in the application.'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-sticky-note', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/note?reset=1&action=add&entity_table=[entity_table]&entity_id=[entity_id]', + 'view' => 'civicrm/note?reset=1&action=view&id=[id]', + 'update' => 'civicrm/note?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/note?reset=1&action=delete&id=[id]', + ], + 'getIndices' => fn() => [ + 'index_entity' => [ + 'fields' => [ + 'entity_table' => TRUE, + 'entity_id' => TRUE, + ], + 'add' => '1.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Note ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Note ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Note Entity'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Name of table where item being referenced is stored.'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Reference Type'), + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'note_used_for', + ], + ], + 'entity_id' => [ + 'title' => ts('Note Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to the referenced item.'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Reference Item'), + ], + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'note' => [ + 'title' => ts('Note'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Note and/or Comment.'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 60, + ], + ], + 'contact_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID creator'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'note_date' => [ + 'title' => ts('Note Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('Date attached to the note'), + 'add' => '5.36', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('When the note was created.'), + 'add' => '5.36', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'modified_date' => [ + 'title' => ts('Note Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('When was this note last modified/edited'), + 'add' => '1.1', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'label' => ts('Modified Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'subject' => [ + 'title' => ts('Subject'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('subject of note description'), + 'add' => '1.5', + 'input_attrs' => [ + 'size' => '60', + 'maxlength' => 255, + ], + ], + 'privacy' => [ + 'title' => ts('Privacy'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'), + 'add' => '3.3', + 'default' => '0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'note_privacy', + ], + ], + ], +]; diff --git a/schema/Core/OpenID.entityType.php b/schema/Core/OpenID.entityType.php new file mode 100644 index 000000000000..1dd6df0b3256 --- /dev/null +++ b/schema/Core/OpenID.entityType.php @@ -0,0 +1,103 @@ + 'OpenID', + 'table' => 'civicrm_openid', + 'class' => 'CRM_Core_DAO_OpenID', + 'getInfo' => fn() => [ + 'title' => ts('Openid'), + 'title_plural' => ts('Openids'), + 'description' => ts('OpenID information for a specific location.'), + 'add' => '2.0', + ], + 'getIndices' => fn() => [ + 'index_location_type' => [ + 'fields' => [ + 'location_type_id' => TRUE, + ], + 'add' => '2.0', + ], + 'UI_openid' => [ + 'fields' => [ + 'openid' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.0', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Open ID identifier'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique OpenID ID'), + 'add' => '2.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'location_type_id' => [ + 'title' => ts('OpenID Location Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which Location does this email belong to.'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Location Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_location_type', + 'key_column' => 'id', + 'label_column' => 'display_name', + ], + ], + 'openid' => [ + 'title' => ts('OpenID'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Url', + 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'), + 'add' => '2.0', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'allowed_to_login' => [ + 'title' => ts('Allowed to login?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Whether or not this user is allowed to login'), + 'add' => '2.0', + 'default' => FALSE, + ], + 'is_primary' => [ + 'title' => ts('Is Primary'), + 'sql_type' => 'boolean', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Is this the primary email for this contact and location.'), + 'add' => '2.0', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Core/OptionGroup.entityType.php b/schema/Core/OptionGroup.entityType.php new file mode 100644 index 000000000000..5def82838773 --- /dev/null +++ b/schema/Core/OptionGroup.entityType.php @@ -0,0 +1,133 @@ + 'OptionGroup', + 'table' => 'civicrm_option_group', + 'class' => 'CRM_Core_DAO_OptionGroup', + 'getInfo' => fn() => [ + 'title' => ts('Optiongroup'), + 'title_plural' => ts('Optiongroups'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.5', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/options?action=add&reset=1', + 'update' => 'civicrm/admin/options?action=update&reset=1&id=[id]', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Option Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Option Group ID'), + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Option Group Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Option group name. Used as selection key by class properties which lookup options in civicrm_option_value.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'title' => [ + 'title' => ts('Option Group Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Option Group title.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Option Group Description'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Option group description.'), + 'add' => '1.5', + ], + 'data_type' => [ + 'title' => ts('Data Type'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('Type of data stored by this option group.'), + 'add' => '4.7', + 'input_attrs' => [ + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Utils_Type::dataTypes', + ], + ], + 'is_reserved' => [ + 'title' => ts('Option Group Is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a predefined system option group (i.e. it can not be deleted)?'), + 'add' => '1.5', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Reserved'), + ], + ], + 'is_active' => [ + 'title' => ts('Enabled'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this option group active?'), + 'add' => '1.5', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_locked' => [ + 'title' => ts('Option Group Is Locked'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('A lock to remove the ability to add new options via the UI.'), + 'add' => '4.5', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Locked'), + ], + ], + 'option_value_fields' => [ + 'title' => ts('Option Value Fields'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('Which optional columns from the option_value table are in use by this group.'), + 'add' => '5.49', + 'default' => 'name,label,description', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'input_attrs' => [ + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::optionValueFields', + ], + ], + ], +]; diff --git a/schema/Core/OptionValue.entityType.php b/schema/Core/OptionValue.entityType.php new file mode 100644 index 000000000000..7730f50458c1 --- /dev/null +++ b/schema/Core/OptionValue.entityType.php @@ -0,0 +1,255 @@ + 'OptionValue', + 'table' => 'civicrm_option_value', + 'class' => 'CRM_Core_DAO_OptionValue', + 'getInfo' => fn() => [ + 'title' => ts('Optionvalue'), + 'title_plural' => ts('Optionvalues'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.5', + ], + 'getPaths' => fn() => [ + 'update' => 'civicrm/admin/options/[option_group_id:name]?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/admin/options/[option_group_id:name]?reset=1&action=delete&id=[id]', + ], + 'getIndices' => fn() => [ + 'index_option_group_id_value' => [ + 'fields' => [ + 'value' => 128, + 'option_group_id' => TRUE, + ], + 'add' => '1.5', + ], + 'index_option_group_id_name' => [ + 'fields' => [ + 'name' => 128, + 'option_group_id' => TRUE, + ], + 'add' => '2.2', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Option Value ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Option ID'), + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'option_group_id' => [ + 'title' => ts('Option Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Group which this option belongs to.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Option Group'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_option_group', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'OptionGroup', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'label' => [ + 'title' => ts('Option Label'), + 'sql_type' => 'varchar(512)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Option string as displayed to users - e.g. the label in an HTML OPTION tag.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 512, + ], + ], + 'value' => [ + 'title' => ts('Option Value'), + 'sql_type' => 'varchar(512)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('The actual value stored (as a foreign key) in the data record. Functions which need lookup option_value.title should use civicrm_option_value.option_group_id plus civicrm_option_value.value as the key.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 512, + ], + ], + 'name' => [ + 'title' => ts('Option Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.'), + 'add' => '1.5', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'grouping' => [ + 'title' => ts('Option Grouping Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Use to sort and/or set display properties for sub-set(s) of options within an option group. EXAMPLE: Use for college_interest field, to differentiate partners from non-partners.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'filter' => [ + 'title' => ts('Filter'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'), + 'add' => '1.5', + 'default' => 0, + 'input_attrs' => [ + 'label' => ts('Filter'), + ], + ], + 'is_default' => [ + 'title' => ts('Option is Default?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'description' => ts('Is this the default option for the group?'), + 'add' => '1.5', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Controls display sort order.'), + 'add' => '1.5', + ], + 'description' => [ + 'title' => ts('Option Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Optional description.'), + 'add' => '1.5', + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 60, + ], + ], + 'is_optgroup' => [ + 'title' => ts('Option is Header?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'description' => ts('Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?'), + 'add' => '1.5', + 'default' => FALSE, + ], + 'is_reserved' => [ + 'title' => ts('Option Is Reserved?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'description' => ts('Is this a predefined system object?'), + 'add' => '1.5', + 'default' => FALSE, + ], + 'is_active' => [ + 'title' => ts('Option Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'description' => ts('Is this option active?'), + 'add' => '1.5', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'component_id' => [ + 'title' => ts('Component ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Component that this option value belongs/caters to.'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Component'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_component', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Component', + 'key' => 'id', + ], + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Which Domain is this option value for'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'visibility_id' => [ + 'title' => ts('Option Visibility'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'add' => '2.2', + 'default' => NULL, + 'pseudoconstant' => [ + 'option_group_name' => 'visibility', + ], + ], + 'icon' => [ + 'title' => ts('Icon'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('crm-i icon class'), + 'add' => '4.7', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'color' => [ + 'title' => ts('Color'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Hex color value e.g. #ffffff'), + 'add' => '4.7', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + ], +]; diff --git a/schema/Core/Phone.entityType.php b/schema/Core/Phone.entityType.php new file mode 100644 index 000000000000..ed03415cd359 --- /dev/null +++ b/schema/Core/Phone.entityType.php @@ -0,0 +1,176 @@ + 'Phone', + 'table' => 'civicrm_phone', + 'class' => 'CRM_Core_DAO_Phone', + 'getInfo' => fn() => [ + 'title' => ts('Phone'), + 'title_plural' => ts('Phones'), + 'description' => ts('Phone information for a specific location.'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-phone', + 'label_field' => 'phone', + ], + 'getIndices' => fn() => [ + 'index_location_type' => [ + 'fields' => [ + 'location_type_id' => TRUE, + ], + 'add' => '2.0', + ], + 'index_is_primary' => [ + 'fields' => [ + 'is_primary' => TRUE, + ], + 'add' => '2.0', + ], + 'index_is_billing' => [ + 'fields' => [ + 'is_billing' => TRUE, + ], + 'add' => '2.0', + ], + 'UI_mobile_provider_id' => [ + 'fields' => [ + 'mobile_provider_id' => TRUE, + ], + 'add' => '1.6', + ], + 'index_phone_numeric' => [ + 'fields' => [ + 'phone_numeric' => TRUE, + ], + 'add' => '4.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Phone ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Phone ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'location_type_id' => [ + 'title' => ts('Location Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which Location does this phone belong to.'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Location Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_location_type', + 'key_column' => 'id', + 'label_column' => 'display_name', + ], + ], + 'is_primary' => [ + 'title' => ts('Is Primary'), + 'sql_type' => 'boolean', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Is this the primary phone for this contact and location.'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'is_billing' => [ + 'title' => ts('Is Billing Phone'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this the billing?'), + 'add' => '2.0', + 'default' => FALSE, + ], + 'mobile_provider_id' => [ + 'title' => ts('Mobile Provider'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'deprecated' => TRUE, + 'description' => ts('Which Mobile Provider does this phone belong to.'), + 'add' => '1.1', + ], + 'phone' => [ + 'title' => ts('Phone'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Text', + 'description' => ts('Complete phone number.'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Phone'), + 'maxlength' => 32, + ], + ], + 'phone_ext' => [ + 'title' => ts('Phone Extension'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Text', + 'description' => ts('Optional extension for a phone number.'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '4', + 'maxlength' => 16, + ], + ], + 'phone_numeric' => [ + 'title' => ts('Phone Numeric'), + 'sql_type' => 'varchar(32)', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Numeric'), + 'maxlength' => 32, + ], + ], + 'phone_type_id' => [ + 'title' => ts('Phone Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which type of phone does this number belongs.'), + 'add' => '2.2', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Phone Type'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'phone_type', + ], + ], + ], +]; diff --git a/schema/Core/PreferencesDate.entityType.php b/schema/Core/PreferencesDate.entityType.php new file mode 100644 index 000000000000..aecf75b7bea0 --- /dev/null +++ b/schema/Core/PreferencesDate.entityType.php @@ -0,0 +1,101 @@ + 'PreferencesDate', + 'table' => 'civicrm_preferences_date', + 'class' => 'CRM_Core_DAO_PreferencesDate', + 'getInfo' => fn() => [ + 'title' => ts('Date Preference'), + 'title_plural' => ts('Date Preferences'), + 'description' => ts('Define date preferences for the site'), + 'log' => TRUE, + 'add' => '2.0', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/setting/preferences/date/edit?reset=1&action=add', + 'browse' => 'civicrm/admin/setting/preferences/date?reset=1', + 'update' => 'civicrm/admin/setting/preferences/date/edit?reset=1&action=update&id=[id]', + ], + 'getIndices' => fn() => [ + 'index_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'add' => '2.0', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Date Preference ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '2.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Date Preference Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('The meta name for this date (fixed in code)'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Description of this date type.'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Description'), + 'maxlength' => 255, + ], + ], + 'start' => [ + 'title' => ts('Start'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('The start offset relative to current year'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Start'), + ], + ], + 'end' => [ + 'title' => ts('End Offset'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('The end offset relative to current year, can be negative'), + 'add' => '2.0', + ], + 'date_format' => [ + 'title' => ts('Date Format'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('The date type'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Date Format'), + 'maxlength' => 64, + ], + ], + 'time_format' => [ + 'title' => ts('Time Format'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('time format'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Time Format'), + 'maxlength' => 64, + ], + ], + ], +]; diff --git a/schema/Core/PrevNextCache.entityType.php b/schema/Core/PrevNextCache.entityType.php new file mode 100644 index 000000000000..87b4fa489db5 --- /dev/null +++ b/schema/Core/PrevNextCache.entityType.php @@ -0,0 +1,86 @@ + 'PrevNextCache', + 'table' => 'civicrm_prevnext_cache', + 'class' => 'CRM_Core_DAO_PrevNextCache', + 'getInfo' => fn() => [ + 'title' => ts('Prevnextcache'), + 'title_plural' => ts('Prevnextcaches'), + 'description' => ts('Table to cache items for navigation on civicrm searched results.'), + 'add' => '3.4', + ], + 'getIndices' => fn() => [ + 'index_all' => [ + 'fields' => [ + 'cachekey' => TRUE, + 'entity_id1' => TRUE, + 'entity_id2' => TRUE, + 'entity_table' => TRUE, + 'is_selected' => TRUE, + ], + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Prev Next Cache ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '3.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Prev Next Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'), + 'add' => '3.4', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id1' => [ + 'title' => ts('Prev Next Entity ID 1'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('FK to entity table specified in entity_table column.'), + 'add' => '3.4', + ], + 'entity_id2' => [ + 'title' => ts('Prev Next Entity ID 2'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('FK to entity table specified in entity_table column.'), + 'add' => '3.4', + ], + 'cachekey' => [ + 'title' => ts('Cache Key'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Unique path name for cache element of the searched item'), + 'add' => '3.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'data' => [ + 'title' => ts('Prev Next Data'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('cached snapshot of the serialized data'), + 'add' => '3.4', + 'serialize' => CRM_Core_DAO::SERIALIZE_PHP, + ], + 'is_selected' => [ + 'title' => ts('Is Selected'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '4.2', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Core/PrintLabel.entityType.php b/schema/Core/PrintLabel.entityType.php new file mode 100644 index 000000000000..6a5b2fec0825 --- /dev/null +++ b/schema/Core/PrintLabel.entityType.php @@ -0,0 +1,136 @@ + 'PrintLabel', + 'table' => 'civicrm_print_label', + 'class' => 'CRM_Core_DAO_PrintLabel', + 'getInfo' => fn() => [ + 'title' => ts('Printlabel'), + 'title_plural' => ts('Printlabels'), + 'description' => ts('Table to store the labels created by user.'), + 'add' => '4.4', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Print Label ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '4.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'title' => [ + 'title' => ts('Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('User title for this label layout'), + 'add' => '4.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('variable name/programmatic handle for this field.'), + 'add' => '4.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Description of this label layout'), + 'add' => '4.4', + 'input_attrs' => [ + 'label' => ts('Description'), + ], + ], + 'label_format_name' => [ + 'title' => ts('Label Format'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'description' => ts('This refers to name column of civicrm_option_value row in name_badge option group'), + 'add' => '4.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'name_badge', + ], + ], + 'label_type_id' => [ + 'title' => ts('Label Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Implicit FK to civicrm_option_value row in NEW label_type option group'), + 'add' => '4.4', + 'pseudoconstant' => [ + 'option_group_name' => 'label_type', + ], + ], + 'data' => [ + 'title' => ts('Data'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('contains json encode configurations options'), + 'add' => '4.4', + 'serialize' => CRM_Core_DAO::SERIALIZE_JSON, + 'input_attrs' => [ + 'label' => ts('Data'), + ], + ], + 'is_default' => [ + 'title' => ts('Label is Default?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this default?'), + 'add' => '4.4', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'is_active' => [ + 'title' => ts('Label Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this option active?'), + 'add' => '4.4', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_reserved' => [ + 'title' => ts('Is Label Reserved?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this reserved label?'), + 'add' => '4.4', + 'default' => TRUE, + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who created this label layout'), + 'add' => '4.4', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Core/RecurringEntity.entityType.php b/schema/Core/RecurringEntity.entityType.php new file mode 100644 index 000000000000..d792e0525bba --- /dev/null +++ b/schema/Core/RecurringEntity.entityType.php @@ -0,0 +1,69 @@ + 'RecurringEntity', + 'table' => 'civicrm_recurring_entity', + 'class' => 'CRM_Core_DAO_RecurringEntity', + 'getInfo' => fn() => [ + 'title' => ts('Recurringentity'), + 'title_plural' => ts('Recurringentities'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '4.6', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 10, + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'parent_id' => [ + 'title' => ts('Parent ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Recurring Entity Parent ID'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Recurring Entity Child ID'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Physical tablename for entity, e.g. civicrm_event'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'mode' => [ + 'title' => ts('Cascade Type'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('1-this entity, 2-this and the following entities, 3-all the entities'), + 'add' => '4.6', + 'default' => TRUE, + ], + ], +]; diff --git a/schema/Core/Setting.entityType.php b/schema/Core/Setting.entityType.php new file mode 100644 index 000000000000..881fe22621f9 --- /dev/null +++ b/schema/Core/Setting.entityType.php @@ -0,0 +1,142 @@ + 'Setting', + 'table' => 'civicrm_setting', + 'class' => 'CRM_Core_DAO_Setting', + 'getInfo' => fn() => [ + 'title' => ts('Setting'), + 'title_plural' => ts('Settings'), + 'description' => ts('Table to store civicrm settings for civicrm core and components.'), + 'add' => '4.1', + ], + 'getIndices' => fn() => [ + 'index_domain_contact_name' => [ + 'fields' => [ + 'domain_id' => TRUE, + 'contact_id' => TRUE, + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.7', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Setting ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '4.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Setting Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Unique name for setting'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'value' => [ + 'title' => ts('Value'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('data associated with this group / name combo'), + 'add' => '4.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_PHP, + 'input_attrs' => [ + 'label' => ts('Value'), + ], + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Which Domain does this setting belong to'), + 'add' => '4.1', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID if the setting is localized to a contact'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'is_domain' => [ + 'title' => ts('Is Domain Setting?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this setting per-domain or global?'), + 'add' => '4.1', + 'default' => FALSE, + ], + 'component_id' => [ + 'title' => ts('Component ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Component that this menu item belongs to'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Component'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_component', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Component', + 'key' => 'id', + ], + ], + 'created_date' => [ + 'title' => ts('Setting Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('When was the setting created'), + 'add' => '4.1', + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who created this setting'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Core/StateProvince.entityType.php b/schema/Core/StateProvince.entityType.php new file mode 100644 index 000000000000..2db29878c750 --- /dev/null +++ b/schema/Core/StateProvince.entityType.php @@ -0,0 +1,88 @@ + 'StateProvince', + 'table' => 'civicrm_state_province', + 'class' => 'CRM_Core_DAO_StateProvince', + 'getInfo' => fn() => [ + 'title' => ts('State/Province'), + 'title_plural' => ts('States/Provinces'), + 'description' => ts('FIXME'), + 'add' => '1.1', + 'label_field' => 'name', + ], + 'getIndices' => fn() => [ + 'UI_name_country_id' => [ + 'fields' => [ + 'name' => TRUE, + 'country_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('State ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('State/Province ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('State'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Name of State/Province'), + 'add' => '1.1', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'abbreviation' => [ + 'title' => ts('State Abbreviation'), + 'sql_type' => 'varchar(4)', + 'input_type' => 'Text', + 'description' => ts('2-4 Character Abbreviation of State/Province'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 4, + ], + ], + 'country_id' => [ + 'title' => ts('Country ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('ID of Country that State/Province belong'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Country'), + ], + 'entity_reference' => [ + 'entity' => 'Country', + 'key' => 'id', + ], + ], + 'is_active' => [ + 'title' => ts('StateProvince Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this StateProvince active?'), + 'add' => '5.35', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Core/StatusPreference.entityType.php b/schema/Core/StatusPreference.entityType.php new file mode 100644 index 000000000000..e0dead356f8b --- /dev/null +++ b/schema/Core/StatusPreference.entityType.php @@ -0,0 +1,130 @@ + 'StatusPreference', + 'table' => 'civicrm_status_pref', + 'class' => 'CRM_Core_DAO_StatusPreference', + 'getInfo' => fn() => [ + 'title' => ts('Statuspreference'), + 'title_plural' => ts('Statuspreferences'), + 'description' => ts('Preferences controlling status checks called in system.check.'), + 'add' => '4.7', + ], + 'getIndices' => fn() => [ + 'UI_status_pref_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'add' => '4.7', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Status Preference ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Status Preference ID'), + 'add' => '4.7', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Which Domain is this Status Preference for'), + 'add' => '4.7', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'name' => [ + 'title' => ts('Status Check Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name of the status check this preference references.'), + 'add' => '4.7', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'hush_until' => [ + 'title' => ts('Snooze Status Notifications Until'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('expires ignore_severity. NULL never hushes.'), + 'add' => '4.7', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'ignore_severity' => [ + 'title' => ts('Ignore Severity'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Hush messages up to and including this severity.'), + 'add' => '4.7', + 'default' => 1, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Utils_Check::getSeverityOptions', + ], + ], + 'prefs' => [ + 'title' => ts('Status Preferences'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => 'These settings are per-check, and can\'t be compared across checks.', + 'add' => '4.7', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'check_info' => [ + 'title' => ts('Check Info'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => 'These values are per-check, and can\'t be compared across checks.', + 'add' => '4.7', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_active' => [ + 'title' => ts('Check Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this status check active?'), + 'add' => '5.19', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Core/SystemLog.entityType.php b/schema/Core/SystemLog.entityType.php new file mode 100644 index 000000000000..f52db0c1b7f2 --- /dev/null +++ b/schema/Core/SystemLog.entityType.php @@ -0,0 +1,82 @@ + 'SystemLog', + 'table' => 'civicrm_system_log', + 'class' => 'CRM_Core_DAO_SystemLog', + 'getInfo' => fn() => [ + 'title' => ts('Systemlog'), + 'title_plural' => ts('Systemlogs'), + 'description' => ts('FIXME'), + 'add' => '4.5', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('System Log ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Primary key ID'), + 'add' => '4.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'message' => [ + 'title' => ts('System Log Message'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Standardized message'), + 'add' => '4.5', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'context' => [ + 'title' => ts('Detailed Log Data'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('JSON encoded data'), + 'add' => '4.5', + ], + 'level' => [ + 'title' => ts('Detailed Log Data'), + 'sql_type' => 'varchar(9)', + 'input_type' => 'Text', + 'description' => ts('error level per PSR3'), + 'add' => '4.5', + 'default' => 'info', + 'input_attrs' => [ + 'maxlength' => 9, + ], + ], + 'timestamp' => [ + 'title' => ts('Log Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('Timestamp of when event occurred.'), + 'add' => '4.5', + 'default' => 'CURRENT_TIMESTAMP', + ], + 'contact_id' => [ + 'title' => ts('Log Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Optional Contact ID that created the log. Not an FK as we keep this regardless'), + 'add' => '4.5', + 'input_attrs' => [ + 'maxlength' => 11, + ], + ], + 'hostname' => [ + 'title' => ts('Log Host'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Optional Name of logging host'), + 'add' => '4.5', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + ], +]; diff --git a/schema/Core/Tag.entityType.php b/schema/Core/Tag.entityType.php new file mode 100644 index 000000000000..c3507eadfb0b --- /dev/null +++ b/schema/Core/Tag.entityType.php @@ -0,0 +1,168 @@ + 'Tag', + 'table' => 'civicrm_tag', + 'class' => 'CRM_Core_DAO_Tag', + 'getInfo' => fn() => [ + 'title' => ts('Tag'), + 'title_plural' => ts('Tags'), + 'description' => ts('Provides support for flat or hierarchical classification of various types of entities (contacts, groups, actions...).'), + 'log' => TRUE, + 'add' => '1.1', + 'icon' => 'fa-tag', + 'label_field' => 'label', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Tag ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Tag ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Tag Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Unique machine name'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'label' => [ + 'title' => ts('Tag Label'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('User-facing tag name'), + 'add' => '5.68', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Optional verbose description of the tag.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'parent_id' => [ + 'title' => ts('Parent Tag ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Optional parent id for this tag.'), + 'add' => '1.1', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Parent Tag'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_tag', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'label', + ], + 'entity_reference' => [ + 'entity' => 'Tag', + 'key' => 'id', + ], + ], + 'is_selectable' => [ + 'title' => ts('Display Tag?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this tag selectable / displayed'), + 'add' => '2.1', + 'default' => TRUE, + ], + 'is_reserved' => [ + 'title' => ts('Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '3.2', + 'default' => FALSE, + ], + 'is_tagset' => [ + 'title' => ts('Tagset'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '3.2', + 'default' => FALSE, + ], + 'used_for' => [ + 'title' => ts('Used For'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'add' => '3.2', + 'default' => NULL, + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'tag_used_for', + ], + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who created this tag'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'color' => [ + 'title' => ts('Color'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Hex color value e.g. #ffffff'), + 'add' => '4.7', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'created_date' => [ + 'title' => ts('Tag Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('Date and time that tag was created.'), + 'add' => '3.4', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + 'label' => ts('Created Date'), + ], + ], + ], +]; diff --git a/schema/Core/Timezone.entityType.php b/schema/Core/Timezone.entityType.php new file mode 100644 index 000000000000..11190f4e6d20 --- /dev/null +++ b/schema/Core/Timezone.entityType.php @@ -0,0 +1,76 @@ + 'Timezone', + 'table' => 'civicrm_timezone', + 'class' => 'CRM_Core_DAO_Timezone', + 'getInfo' => fn() => [ + 'title' => ts('Timezone'), + 'title_plural' => ts('Timezones'), + 'description' => ts('FIXME'), + 'add' => '1.8', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Timezone ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Timezone ID'), + 'add' => '1.8', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Timezone Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Timezone full name'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'abbreviation' => [ + 'title' => ts('Timezone Abbreviation'), + 'sql_type' => 'char(3)', + 'input_type' => 'Text', + 'description' => ts('ISO Code for timezone abbreviation'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 3, + ], + ], + 'gmt' => [ + 'title' => ts('GMT Name of Timezone'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('GMT name of the timezone'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'offset' => [ + 'title' => ts('GMT Offset'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'add' => '1.8', + ], + 'country_id' => [ + 'title' => ts('Country ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Country ID'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Country'), + ], + 'entity_reference' => [ + 'entity' => 'Country', + 'key' => 'id', + ], + ], + ], +]; diff --git a/schema/Core/Translation.entityType.php b/schema/Core/Translation.entityType.php new file mode 100644 index 000000000000..1faeb726fcc9 --- /dev/null +++ b/schema/Core/Translation.entityType.php @@ -0,0 +1,118 @@ + 'Translation', + 'table' => 'civicrm_translation', + 'class' => 'CRM_Core_DAO_Translation', + 'getInfo' => fn() => [ + 'title' => ts('Translated String'), + 'title_plural' => ts('Translated Strings'), + 'description' => ts('Each string record is an alternate translation of some displayable string in the database.'), + 'log' => TRUE, + 'add' => '5.39', + ], + 'getIndices' => fn() => [ + 'index_entity_lang' => [ + 'fields' => [ + 'entity_id' => TRUE, + 'entity_table' => TRUE, + 'language' => TRUE, + ], + 'add' => '5.39', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Translated String ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique String ID'), + 'add' => '5.39', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Translated Entity'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Table where referenced item is stored'), + 'add' => '5.39', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_Translation::getEntityTables', + ], + ], + 'entity_field' => [ + 'title' => ts('Translated Field'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Field where referenced item is stored'), + 'add' => '5.39', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_Translation::getEntityFields', + ], + ], + 'entity_id' => [ + 'title' => ts('Translated Entity ID'), + 'sql_type' => 'int', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('ID of the relevant entity.'), + 'add' => '5.39', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'language' => [ + 'title' => ts('Language'), + 'sql_type' => 'varchar(5)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Relevant language'), + 'add' => '5.39', + 'input_attrs' => [ + 'maxlength' => 5, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'languages', + 'key_column' => 'name', + 'option_edit_path' => 'civicrm/admin/options/languages', + ], + ], + 'status_id' => [ + 'title' => ts('Status'), + 'sql_type' => 'tinyint', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Specify whether the string is active, draft, etc'), + 'add' => '5.39', + 'default' => 1, + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_Translation::getStatuses', + ], + ], + 'string' => [ + 'title' => ts('Translated String'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'required' => TRUE, + 'description' => ts('Translated string'), + 'add' => '5.39', + ], + ], +]; diff --git a/schema/Core/UFField.entityType.php b/schema/Core/UFField.entityType.php new file mode 100644 index 000000000000..cf93cbe4c77c --- /dev/null +++ b/schema/Core/UFField.entityType.php @@ -0,0 +1,238 @@ + 'UFField', + 'table' => 'civicrm_uf_field', + 'class' => 'CRM_Core_DAO_UFField', + 'getInfo' => fn() => [ + 'title' => ts('Profile Field'), + 'title_plural' => ts('Profile Fields'), + 'description' => ts('User Framework fields and their properties.'), + 'log' => TRUE, + 'add' => '1.1', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/uf/group/field/add?reset=1&action=add&gid=[uf_group_id]', + 'preview' => 'civicrm/admin/uf/group/preview?reset=1&gid=[uf_group_id]&fieldId=[id]', + 'update' => 'civicrm/admin/uf/group/field/update?reset=1&action=update&id=[id]', + 'delete' => 'civicrm/admin/uf/group/field/update?reset=1&action=delete&id=[id]', + 'browse' => 'civicrm/admin/uf/group/field', + ], + 'getIndices' => fn() => [ + 'IX_website_type_id' => [ + 'fields' => [ + 'website_type_id' => TRUE, + ], + 'add' => '4.5', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Profile Field ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique table ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'uf_group_id' => [ + 'title' => ts('Profile ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Which form does this field belong to.'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Profile'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_uf_group', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'UFGroup', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'field_name' => [ + 'title' => ts('Profile Field Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Name for CiviCRM field which is being exposed for sharing.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_UFField::getAvailableFieldOptions', + ], + ], + 'is_active' => [ + 'title' => ts('Profile Field Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this field currently shareable? If FALSE, hide the field for all sharing contexts.'), + 'add' => '1.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_view' => [ + 'title' => ts('Profile Is View Only'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('the field is view only and not editable in user forms.'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'is_required' => [ + 'title' => ts('Profile Field Is Required'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this field required when included in a user or registration form?'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Controls field display order when user framework fields are displayed in registration and account editing forms.'), + 'add' => '1.1', + 'default' => 1, + ], + 'help_post' => [ + 'title' => ts('Profile Field Post Help'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display after this field.'), + 'add' => '1.1', + ], + 'help_pre' => [ + 'title' => ts('Profile Field Pre Help'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display before this field.'), + 'add' => '3.2', + ], + 'visibility' => [ + 'title' => ts('Profile Field Visibility'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Select', + 'description' => ts('In what context(s) is this field visible.'), + 'add' => '1.1', + 'default' => 'User and User Admin Only', + 'input_attrs' => [ + 'maxlength' => 32, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::ufVisibility', + ], + ], + 'in_selector' => [ + 'title' => ts('Profile Field Is a Filter'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this field included as a column in the selector table?'), + 'add' => '1.2', + 'default' => FALSE, + ], + 'is_searchable' => [ + 'title' => ts('Profile Field Is Searchable'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this field included search form of profile?'), + 'add' => '1.4', + 'default' => FALSE, + ], + 'location_type_id' => [ + 'title' => ts('Location Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Location type of this mapping, if required'), + 'add' => '1.3', + 'input_attrs' => [ + 'label' => ts('Location Type'), + ], + 'entity_reference' => [ + 'entity' => 'LocationType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'phone_type_id' => [ + 'title' => ts('Profile Field Phone Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Phone Type ID, if required'), + 'add' => '2.2', + 'pseudoconstant' => [ + 'option_group_name' => 'phone_type', + ], + ], + 'website_type_id' => [ + 'title' => ts('Profile Field Website Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Website Type ID, if required'), + 'add' => '4.5', + 'pseudoconstant' => [ + 'option_group_name' => 'website_type', + ], + ], + 'label' => [ + 'title' => ts('Profile Field Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('To save label for fields.'), + 'add' => '1.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'field_type' => [ + 'title' => ts('Profile Field Type'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('This field saves field type (ie individual,household.. field etc).'), + 'add' => '1.4', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_reserved' => [ + 'title' => ts('Profile Field Is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this field reserved for use by some other CiviCRM functionality?'), + 'add' => '3.0', + 'default' => FALSE, + ], + 'is_multi_summary' => [ + 'title' => ts('Profile Field Supports Multiple'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Include in multi-record listing?'), + 'add' => '4.3', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Core/UFGroup.entityType.php b/schema/Core/UFGroup.entityType.php new file mode 100644 index 000000000000..b925fe9f4e4c --- /dev/null +++ b/schema/Core/UFGroup.entityType.php @@ -0,0 +1,326 @@ + 'UFGroup', + 'table' => 'civicrm_uf_group', + 'class' => 'CRM_Core_DAO_UFGroup', + 'getInfo' => fn() => [ + 'title' => ts('Profile'), + 'title_plural' => ts('Profiles'), + 'description' => ts('User framework groups. Each group represents a form which encompasses a set of fields defined in civicrm_uf_fields table. Initially will be used for CiviCRM Profile form(s). Subsequently we anticipate using this to define other public facing forms (e.g. online donation solicitation forms, mailing list preferences, etc.).'), + 'log' => TRUE, + 'add' => '1.1', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/uf/group/add?action=add&reset=1', + 'preview' => 'civicrm/admin/uf/group/preview?reset=1&gid=[id]', + 'update' => 'civicrm/admin/uf/group/update?action=update&reset=1&id=[id]', + 'delete' => 'civicrm/admin/uf/group/update?action=delete&reset=1&id=[id]', + 'browse' => 'civicrm/admin/uf/group', + 'copy' => 'civicrm/admin/uf/group/copy?action=copy&reset=1&gid=[id]', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.7', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Profile ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique table ID'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Profile Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name of the UF group for directly addressing it in the codebase'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'is_active' => [ + 'title' => ts('Profile Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this profile currently active? If FALSE, hide all related fields for all sharing contexts.'), + 'add' => '1.1', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'group_type' => [ + 'title' => ts('Profile Group Type'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Comma separated list of the type(s) of profile fields.'), + 'add' => '2.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_COMMA, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'title' => [ + 'title' => ts('Profile Title'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Form title.'), + 'add' => '1.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'frontend_title' => [ + 'title' => ts('Public Title'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Profile Form Public title'), + 'add' => '4.7', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Profile Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Optional verbose description of the profile.'), + 'add' => '4.4', + 'input_attrs' => [ + 'rows' => 2, + 'cols' => 60, + ], + ], + 'help_pre' => [ + 'title' => ts('Help Pre'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display before fields in form.'), + 'add' => '1.2', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 80, + 'label' => ts('Pre Help'), + ], + ], + 'help_post' => [ + 'title' => ts('Profile Post Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display after fields in form.'), + 'add' => '1.2', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 80, + ], + ], + 'limit_listings_group_id' => [ + 'title' => ts('Search Limit Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Group id, foreign key from civicrm_group'), + 'add' => '1.4', + 'input_attrs' => [ + 'label' => ts('Search Limit Group'), + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'post_url' => [ + 'title' => ts('Post Url'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Redirect to URL on submit.'), + 'add' => '1.4', + 'input_attrs' => [ + 'label' => ts('Post URL'), + 'maxlength' => 255, + ], + ], + 'add_to_group_id' => [ + 'title' => ts('Add Contact To Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('foreign key to civicrm_group_id'), + 'input_attrs' => [ + 'label' => ts('Add Contact To Group'), + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'add_captcha' => [ + 'title' => ts('Show Captcha On Profile'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should a CAPTCHA widget be included this Profile form.'), + 'add' => '1.1', + 'default' => FALSE, + ], + 'is_map' => [ + 'title' => ts('Map Profile'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Do we want to map results from this profile.'), + 'add' => '1.5', + 'default' => FALSE, + ], + 'is_edit_link' => [ + 'title' => ts('Show Edit Link?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should edit link display in profile selector'), + 'add' => '1.6', + 'default' => FALSE, + ], + 'is_uf_link' => [ + 'title' => ts('Show Link to CMS User'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should we display a link to the website profile in profile selector'), + 'add' => '1.7', + 'default' => FALSE, + ], + 'is_update_dupe' => [ + 'title' => ts('Update on Duplicate'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should we update the contact record if we find a duplicate'), + 'add' => '1.7', + 'default' => FALSE, + ], + 'cancel_url' => [ + 'title' => ts('Profile Cancel URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Redirect to URL when Cancel button clicked.'), + 'add' => '1.4', + 'input_attrs' => [ + 'label' => ts('Cancel URL'), + 'maxlength' => 255, + ], + ], + 'is_cms_user' => [ + 'title' => ts('Create CMS User?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should we create a cms user for this profile'), + 'add' => '1.8', + 'default' => FALSE, + ], + 'notify' => [ + 'title' => ts('Notify on Profile Submit'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'add' => '1.8', + ], + 'is_reserved' => [ + 'title' => ts('Profile Is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Is this group reserved for use by some other CiviCRM functionality?'), + 'add' => '3.0', + 'default' => FALSE, + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who created this UF group'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('UF Group Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time this UF group was created.'), + 'add' => '3.0', + ], + 'is_proximity_search' => [ + 'title' => ts('Include Proximity Search?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should we include proximity search feature in this profile search form?'), + 'add' => '3.2', + 'default' => FALSE, + ], + 'cancel_button_text' => [ + 'title' => ts('Cancel Button Text'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Custom Text to display on the Cancel button when used in create or edit mode'), + 'add' => '4.7', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'submit_button_text' => [ + 'title' => ts('Submit Button Text'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Custom Text to display on the submit button on profile edit/create screens'), + 'add' => '4.7', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'add_cancel_button' => [ + 'title' => ts('Include Cancel Button'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should a Cancel button be included in this Profile form.'), + 'add' => '5.0', + 'default' => TRUE, + ], + ], +]; diff --git a/schema/Core/UFJoin.entityType.php b/schema/Core/UFJoin.entityType.php new file mode 100644 index 000000000000..d0e22305580e --- /dev/null +++ b/schema/Core/UFJoin.entityType.php @@ -0,0 +1,119 @@ + 'UFJoin', + 'table' => 'civicrm_uf_join', + 'class' => 'CRM_Core_DAO_UFJoin', + 'getInfo' => fn() => [ + 'title' => ts('Profile Use'), + 'title_plural' => ts('Profile Uses'), + 'description' => ts('User framework join table. This links various internal civicrm object with a profile. Initial use cases are the donation object and the user module'), + 'log' => TRUE, + 'add' => '1.3', + ], + 'getIndices' => fn() => [ + 'index_entity' => [ + 'fields' => [ + 'entity_table' => TRUE, + 'entity_id' => TRUE, + ], + 'add' => '1.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('UF Join ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique table ID'), + 'add' => '1.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'is_active' => [ + 'title' => ts('Profile Use is active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this join currently active?'), + 'add' => '1.3', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'module' => [ + 'title' => ts('Profile Module'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Module which owns this uf_join instance, e.g. User Registration, CiviDonate, etc.'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_table' => [ + 'title' => ts('Profile Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('Name of table where item being referenced is stored. Modules which only need a single collection of uf_join instances may choose not to populate entity_table and entity_id.'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_UFJoin::entityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('Profile Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Foreign key to the referenced item.'), + 'add' => '1.3', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Controls display order when multiple user framework groups are setup for concurrent display.'), + 'add' => '1.3', + 'default' => 1, + ], + 'uf_group_id' => [ + 'title' => ts('Profile ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Which form does this field belong to.'), + 'add' => '1.3', + 'input_attrs' => [ + 'label' => ts('Profile'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_uf_group', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'UFGroup', + 'key' => 'id', + ], + ], + 'module_data' => [ + 'title' => ts('Profile Use Data'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Json serialized array of data used by the ufjoin.module'), + 'add' => '4.5', + 'serialize' => CRM_Core_DAO::SERIALIZE_JSON, + ], + ], +]; diff --git a/schema/Core/UFMatch.entityType.php b/schema/Core/UFMatch.entityType.php new file mode 100644 index 000000000000..6d83324288d4 --- /dev/null +++ b/schema/Core/UFMatch.entityType.php @@ -0,0 +1,120 @@ + 'UFMatch', + 'table' => 'civicrm_uf_match', + 'class' => 'CRM_Core_DAO_UFMatch', + 'getInfo' => fn() => [ + 'title' => ts('User Account'), + 'title_plural' => ts('User Accounts'), + 'description' => ts('The mapping from an user framework (UF) object to a CRM object.'), + 'log' => TRUE, + 'add' => '1.1', + ], + 'getIndices' => fn() => [ + 'I_civicrm_uf_match_uf_id' => [ + 'fields' => [ + 'uf_id' => TRUE, + ], + 'add' => '3.3', + ], + 'UI_uf_match_uf_id_domain_id' => [ + 'fields' => [ + 'uf_id' => TRUE, + 'domain_id' => TRUE, + ], + 'add' => '5.69', + ], + 'UI_uf_name_domain_id' => [ + 'fields' => [ + 'uf_name' => TRUE, + 'domain_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + 'UI_contact_domain_id' => [ + 'fields' => [ + 'contact_id' => TRUE, + 'domain_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.6', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('UF Match ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('System generated ID.'), + 'add' => '1.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Which Domain is this match entry for'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'uf_id' => [ + 'title' => ts('CMS ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('UF ID'), + 'add' => '1.1', + ], + 'uf_name' => [ + 'title' => ts('CMS Unique Identifier'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('UF Name'), + 'add' => '1.9', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'language' => [ + 'title' => ts('Preferred Language'), + 'sql_type' => 'varchar(5)', + 'input_type' => 'Text', + 'description' => ts('UI language preferred by the given user/contact'), + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 5, + ], + ], + ], +]; diff --git a/schema/Core/UserJob.entityType.php b/schema/Core/UserJob.entityType.php new file mode 100644 index 000000000000..08dfd0c50115 --- /dev/null +++ b/schema/Core/UserJob.entityType.php @@ -0,0 +1,174 @@ + 'UserJob', + 'table' => 'civicrm_user_job', + 'class' => 'CRM_Core_DAO_UserJob', + 'getInfo' => fn() => [ + 'title' => ts('Userjob'), + 'title_plural' => ts('Userjobs'), + 'description' => ts('Tracking for user jobs (eg. imports).'), + 'log' => FALSE, + 'add' => '5.50', + ], + 'getPaths' => fn() => [ + 'view' => 'civicrm/import/contact/summary?reset=1&user_job_id=[id]', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '5.50', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('User Job ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Job ID'), + 'add' => '5.50', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('User job name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Unique name for job.'), + 'add' => '5.50', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to contact table.'), + 'add' => '5.50', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('Import Job Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'readonly' => TRUE, + 'description' => ts('Date and time this job was created.'), + 'add' => '5.50', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'start_date' => [ + 'title' => ts('Import Job Started Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('Date and time this import job started.'), + 'add' => '5.50', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'end_date' => [ + 'title' => ts('Job Ended Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('Date and time this import job ended.'), + 'add' => '5.50', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'expires_date' => [ + 'title' => ts('Import Job Expires Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('Date and time to clean up after this import job (temp table deletion date).'), + 'add' => '5.50', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'status_id' => [ + 'title' => ts('User Job Status ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'add' => '5.50', + 'input_attrs' => [ + 'label' => ts('Job Status'), + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_UserJob::getStatuses', + ], + ], + 'job_type' => [ + 'title' => ts('User Job Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Name of the job type, which will allow finding the correct class'), + 'add' => '5.50', + 'input_attrs' => [ + 'label' => ts('Job Type'), + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_BAO_UserJob::getTypes', + 'suffixes' => [ + 'name', + 'label', + 'url', + ], + ], + ], + 'queue_id' => [ + 'title' => ts('Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Queue'), + 'input_attrs' => [ + 'label' => ts('Queue'), + ], + 'entity_reference' => [ + 'entity' => 'Queue', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'metadata' => [ + 'title' => ts('Job metadata'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Data pertaining to job configuration'), + 'add' => '5.50', + 'serialize' => CRM_Core_DAO::SERIALIZE_JSON, + ], + 'is_template' => [ + 'title' => ts('Is Template'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a template configuration (for use by other/future jobs)?'), + 'add' => '5.51', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Is Template'), + ], + ], + ], +]; diff --git a/schema/Core/Website.entityType.php b/schema/Core/Website.entityType.php new file mode 100644 index 000000000000..e6171f12f7c3 --- /dev/null +++ b/schema/Core/Website.entityType.php @@ -0,0 +1,76 @@ + 'Website', + 'table' => 'civicrm_website', + 'class' => 'CRM_Core_DAO_Website', + 'getInfo' => fn() => [ + 'title' => ts('Website'), + 'title_plural' => ts('Websites'), + 'description' => ts('Website information for a specific location.'), + 'add' => '3.2', + 'icon' => 'fa-desktop', + 'label_field' => 'url', + ], + 'getIndices' => fn() => [ + 'UI_website_type_id' => [ + 'fields' => [ + 'website_type_id' => TRUE, + ], + 'add' => '3.2', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Website ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique Website ID'), + 'add' => '3.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '3.2', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'url' => [ + 'title' => ts('Website'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Website'), + 'add' => '3.2', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'size' => '45', + 'maxlength' => 255, + ], + ], + 'website_type_id' => [ + 'title' => ts('Website Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Which Website type does this website belong to.'), + 'add' => '3.2', + 'pseudoconstant' => [ + 'option_group_name' => 'website_type', + ], + ], + ], +]; diff --git a/schema/Core/WordReplacement.entityType.php b/schema/Core/WordReplacement.entityType.php new file mode 100644 index 000000000000..bdf46d6707c2 --- /dev/null +++ b/schema/Core/WordReplacement.entityType.php @@ -0,0 +1,101 @@ + 'WordReplacement', + 'table' => 'civicrm_word_replacement', + 'class' => 'CRM_Core_DAO_WordReplacement', + 'getInfo' => fn() => [ + 'title' => ts('Wordreplacement'), + 'title_plural' => ts('Wordreplacements'), + 'description' => ts('Top-level hierarchy to support word replacement.'), + 'add' => '4.4', + ], + 'getIndices' => fn() => [ + 'UI_domain_find' => [ + 'fields' => [ + 'domain_id' => TRUE, + 'find_word' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.4', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Word Replacement ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Word replacement ID'), + 'add' => '4.4', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'find_word' => [ + 'title' => ts('Replaced Word'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Word which need to be replaced'), + 'add' => '4.4', + 'collate' => 'utf8_bin', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'replace_word' => [ + 'title' => ts('Replacement Word'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Word which will replace the word in find'), + 'add' => '4.4', + 'collate' => 'utf8_bin', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_active' => [ + 'title' => ts('Word Replacement is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this entry active?'), + 'add' => '4.4', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'match_type' => [ + 'title' => ts('Word Replacement Match Type'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Select', + 'add' => '4.4', + 'default' => 'wildcardMatch', + 'input_attrs' => [ + 'maxlength' => 16, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getWordReplacementMatchType', + ], + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Domain ID. This is for Domain specific word replacement'), + 'add' => '1.1', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + ], +]; diff --git a/schema/Core/Worldregion.entityType.php b/schema/Core/Worldregion.entityType.php new file mode 100644 index 000000000000..372c77776056 --- /dev/null +++ b/schema/Core/Worldregion.entityType.php @@ -0,0 +1,39 @@ + 'WorldRegion', + 'table' => 'civicrm_worldregion', + 'class' => 'CRM_Core_DAO_Worldregion', + 'getInfo' => fn() => [ + 'title' => ts('Worldregion'), + 'title_plural' => ts('Worldregions'), + 'description' => ts('FIXME'), + 'add' => '1.8', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('World Region ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Country ID'), + 'add' => '1.8', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('World Region'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Region name to be associated with countries'), + 'add' => '1.8', + 'unique_name' => 'world_region', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + ], +]; diff --git a/schema/Cxn/Cxn.entityType.php b/schema/Cxn/Cxn.entityType.php new file mode 100644 index 000000000000..1fc90cc50473 --- /dev/null +++ b/schema/Cxn/Cxn.entityType.php @@ -0,0 +1,145 @@ + 'Cxn', + 'table' => 'civicrm_cxn', + 'class' => 'CRM_Cxn_DAO_Cxn', + 'getInfo' => fn() => [ + 'title' => ts('Cxn'), + 'title_plural' => ts('Cxns'), + 'description' => ts('FIXME'), + 'add' => '4.6', + ], + 'getIndices' => fn() => [ + 'UI_appid' => [ + 'fields' => [ + 'app_guid' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.6', + ], + 'UI_keypair_cxnid' => [ + 'fields' => [ + 'cxn_guid' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.6', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Connection ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Connection ID'), + 'add' => '4.6', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'app_guid' => [ + 'title' => ts('Application GUID'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Application GUID'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'app_meta' => [ + 'title' => ts('Application Metadata (JSON)'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Application Metadata (JSON)'), + 'add' => '4.6', + ], + 'cxn_guid' => [ + 'title' => ts('Connection GUID'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Connection GUID'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'secret' => [ + 'title' => ts('Secret'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Shared secret'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Secret'), + ], + ], + 'perm' => [ + 'title' => ts('Perm'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Permissions approved for the service (JSON)'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Permissions'), + ], + ], + 'options' => [ + 'title' => ts('Options'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Options for the service (JSON)'), + 'add' => '4.6', + 'serialize' => CRM_Core_DAO::SERIALIZE_JSON, + 'input_attrs' => [ + 'label' => ts('Options'), + ], + ], + 'is_active' => [ + 'title' => ts('Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is connection currently enabled?'), + 'add' => '4.6', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('When was the connection was created.'), + 'add' => '4.6', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Created Date'), + ], + ], + 'modified_date' => [ + 'title' => ts('Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('When the connection was created or modified.'), + 'add' => '4.6', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'label' => ts('Modified Date'), + ], + ], + 'fetched_date' => [ + 'title' => ts('Fetched Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('The last time the application metadata was fetched.'), + 'add' => '4.6', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Fetched Date'), + ], + ], + ], +]; diff --git a/schema/Dedupe/DedupeException.entityType.php b/schema/Dedupe/DedupeException.entityType.php new file mode 100644 index 000000000000..069053f98740 --- /dev/null +++ b/schema/Dedupe/DedupeException.entityType.php @@ -0,0 +1,67 @@ + 'DedupeException', + 'table' => 'civicrm_dedupe_exception', + 'class' => 'CRM_Dedupe_DAO_DedupeException', + 'getInfo' => fn() => [ + 'title' => ts('Dedupeexception'), + 'title_plural' => ts('Dedupeexceptions'), + 'description' => ts('Dedupe exceptions'), + 'add' => '3.3', + ], + 'getIndices' => fn() => [ + 'UI_contact_id1_contact_id2' => [ + 'fields' => [ + 'contact_id1' => TRUE, + 'contact_id2' => TRUE, + ], + 'unique' => TRUE, + 'add' => '3.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Dedupe Exception ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique dedupe exception id'), + 'add' => '3.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id1' => [ + 'title' => ts('First Dupe Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact ID'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('First Dupe Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id2' => [ + 'title' => ts('Second Dupe Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact ID'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Second Dupe Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Dedupe/DedupeRule.entityType.php b/schema/Dedupe/DedupeRule.entityType.php new file mode 100644 index 000000000000..501d39a7bd5a --- /dev/null +++ b/schema/Dedupe/DedupeRule.entityType.php @@ -0,0 +1,77 @@ + 'DedupeRule', + 'table' => 'civicrm_dedupe_rule', + 'class' => 'CRM_Dedupe_DAO_DedupeRule', + 'getInfo' => fn() => [ + 'title' => ts('Deduperule'), + 'title_plural' => ts('Deduperules'), + 'description' => ts('Dedupe rules for use by rule groups'), + 'add' => '1.8', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Dedupe Rule ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique dedupe rule id'), + 'add' => '1.8', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'dedupe_rule_group_id' => [ + 'title' => ts('Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('The id of the rule group this rule belongs to'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Group'), + ], + 'entity_reference' => [ + 'entity' => 'DedupeRuleGroup', + 'key' => 'id', + ], + ], + 'rule_table' => [ + 'title' => ts('Rule Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('The name of the table this rule is about'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'rule_field' => [ + 'title' => ts('Rule Field'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('The name of the field of the table referenced in rule_table'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'rule_length' => [ + 'title' => ts('Rule Length'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('The length of the matching substring'), + 'add' => '1.8', + ], + 'rule_weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('The weight of the rule'), + 'add' => '1.8', + ], + ], +]; diff --git a/schema/Dedupe/DedupeRuleGroup.entityType.php b/schema/Dedupe/DedupeRuleGroup.entityType.php new file mode 100644 index 000000000000..bec94a695788 --- /dev/null +++ b/schema/Dedupe/DedupeRuleGroup.entityType.php @@ -0,0 +1,101 @@ + 'DedupeRuleGroup', + 'table' => 'civicrm_dedupe_rule_group', + 'class' => 'CRM_Dedupe_DAO_DedupeRuleGroup', + 'getInfo' => fn() => [ + 'title' => ts('Deduperulegroup'), + 'title_plural' => ts('Deduperulegroups'), + 'description' => ts('Dedupe rule groups'), + 'add' => '1.8', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '5.54', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Rule Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Unique dedupe rule group id'), + 'add' => '1.8', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_type' => [ + 'title' => ts('Contact Type'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Select', + 'description' => ts('The type of contacts this group applies to'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 12, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_contact_type', + 'key_column' => 'name', + 'label_column' => 'label', + 'condition' => 'parent_id IS NULL', + ], + ], + 'threshold' => [ + 'title' => ts('Threshold'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('The weight threshold the sum of the rule weights has to cross to consider two contacts the same'), + 'add' => '1.8', + ], + 'used' => [ + 'title' => ts('Length'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Radio', + 'required' => TRUE, + 'description' => ts('Whether the rule should be used for cases where usage is Unsupervised, Supervised OR General(programatically)'), + 'add' => '4.3', + 'input_attrs' => [ + 'maxlength' => 12, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getDedupeRuleTypes', + ], + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Unique name of rule group'), + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'title' => [ + 'title' => ts('Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Label of the rule group'), + 'add' => '4.1', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_reserved' => [ + 'title' => ts('Reserved?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a reserved rule - a rule group that has been optimized and cannot be changed by the admin'), + 'add' => '4.1', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Event/Cart/Cart.entityType.php b/schema/Event/Cart/Cart.entityType.php new file mode 100644 index 000000000000..b2967ec9cce5 --- /dev/null +++ b/schema/Event/Cart/Cart.entityType.php @@ -0,0 +1,48 @@ + 'Cart', + 'table' => 'civicrm_event_carts', + 'class' => 'CRM_Event_Cart_DAO_Cart', + 'getInfo' => fn() => [ + 'title' => ts('Cart'), + 'title_plural' => ts('Carts'), + 'description' => ts('FIXME'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Cart ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Cart ID'), + 'add' => '4.1', + 'unique_name' => 'cart_id', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'user_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact who created this cart'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'completed' => [ + 'title' => ts('Complete?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '4.1', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Event/Cart/EventInCart.entityType.php b/schema/Event/Cart/EventInCart.entityType.php new file mode 100644 index 000000000000..82c8b8a5a344 --- /dev/null +++ b/schema/Event/Cart/EventInCart.entityType.php @@ -0,0 +1,55 @@ + 'EventInCart', + 'table' => 'civicrm_events_in_carts', + 'class' => 'CRM_Event_Cart_DAO_EventInCart', + 'getInfo' => fn() => [ + 'title' => ts('Eventincart'), + 'title_plural' => ts('Eventincarts'), + 'description' => ts('FIXME'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Event In Cart'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Event In Cart ID'), + 'add' => '4.1', + 'unique_name' => 'event_in_cart_id', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'event_id' => [ + 'title' => ts('Event ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Event ID'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Event'), + ], + 'entity_reference' => [ + 'entity' => 'Event', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'event_cart_id' => [ + 'title' => ts('Event Cart ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Event Cart ID'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Event In Cart'), + ], + 'entity_reference' => [ + 'entity' => 'Cart', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Event/Event.entityType.php b/schema/Event/Event.entityType.php new file mode 100644 index 000000000000..75b58be15aeb --- /dev/null +++ b/schema/Event/Event.entityType.php @@ -0,0 +1,863 @@ + 'Event', + 'table' => 'civicrm_event', + 'class' => 'CRM_Event_DAO_Event', + 'getInfo' => fn() => [ + 'title' => ts('Event'), + 'title_plural' => ts('Events'), + 'description' => ts('Scheduled in-person or online events which contacts can register for and attend.'), + 'log' => TRUE, + 'add' => '1.7', + 'icon' => 'fa-calendar', + 'label_field' => 'title', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/event/add?reset=1', + 'view' => 'civicrm/event/info?reset=1&id=[id]', + ], + 'getIndices' => fn() => [ + 'index_event_type_id' => [ + 'fields' => [ + 'event_type_id' => TRUE, + ], + 'add' => '1.8', + ], + 'index_participant_listing_id' => [ + 'fields' => [ + 'participant_listing_id' => TRUE, + ], + 'add' => '2.0', + ], + 'index_parent_event_id' => [ + 'fields' => [ + 'parent_event_id' => TRUE, + ], + 'add' => '4.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Event ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Event'), + 'add' => '1.7', + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'title' => [ + 'title' => ts('Event Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Event Title (e.g. Fall Fundraiser Dinner)'), + 'add' => '1.7', + 'unique_name' => 'event_title', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Title'), + 'maxlength' => 255, + ], + ], + 'summary' => [ + 'title' => ts('Event Summary'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Brief summary of event. Text and html allowed. Displayed on Event Registration form and can be used on other CMS pages which need an event summary.'), + 'add' => '1.7', + 'input_attrs' => [ + 'label' => ts('Summary'), + 'rows' => 4, + 'cols' => 60, + ], + ], + 'description' => [ + 'title' => ts('Event Description'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Full description of event. Text and html allowed. Displayed on built-in Event Information screens.'), + 'add' => '1.7', + 'unique_name' => 'event_description', + 'input_attrs' => [ + 'label' => ts('Description'), + 'rows' => 8, + 'cols' => 60, + ], + ], + 'event_type_id' => [ + 'title' => ts('Event Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Event Type ID.Implicit FK to civicrm_option_value where option_group = event_type.'), + 'add' => '1.7', + 'unique_name' => 'event_type_id', + 'default' => 0, + 'input_attrs' => [ + 'label' => ts('Type'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'event_type', + ], + ], + 'participant_listing_id' => [ + 'title' => ts('Participant Listing'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Should we expose the participant list? Implicit FK to civicrm_option_value where option_group = participant_listing.'), + 'add' => '2.0', + 'unique_name' => 'participant_listing_id', + 'default' => NULL, + 'pseudoconstant' => [ + 'option_group_name' => 'participant_listing', + ], + ], + 'is_public' => [ + 'title' => ts('Is Event Public'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Public events will be included in the iCal feeds. Access to private event information may be limited using ACLs.'), + 'add' => '1.7', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Public'), + ], + ], + 'start_date' => [ + 'title' => ts('Event Start Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that event starts.'), + 'add' => '1.7', + 'unique_name' => 'event_start_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Start Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'end_date' => [ + 'title' => ts('Event End Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that event ends. May be NULL if no defined end date/time'), + 'add' => '1.7', + 'unique_name' => 'event_end_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('End Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'is_online_registration' => [ + 'title' => ts('Is Online Registration'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('If TRUE, include registration link on Event Info page.'), + 'add' => '1.7', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Online Registration'), + ], + ], + 'registration_link_text' => [ + 'title' => ts('Event Registration Link Text'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Text for link to Event Registration form which is displayed on Event Information screen when is_online_registration is true.'), + 'add' => '1.7', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'registration_start_date' => [ + 'title' => ts('Registration Start Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that online registration starts.'), + 'add' => '1.8', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + 'label' => ts('Registration Start Date'), + ], + ], + 'registration_end_date' => [ + 'title' => ts('Registration End Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that online registration ends.'), + 'add' => '1.8', + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + 'label' => ts('Registration End Date'), + ], + ], + 'max_participants' => [ + 'title' => ts('Max Participants'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Maximum number of registered participants to allow. After max is reached, a custom Event Full message is displayed. If NULL, allow unlimited number of participants.'), + 'add' => '1.7', + 'default' => NULL, + ], + 'event_full_text' => [ + 'title' => ts('Event Information'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Message to display on Event Information page and INSTEAD OF Event Registration form if maximum participants are signed up. Can include email address/info about getting on a waiting list, etc. Text and html allowed.'), + 'add' => '1.7', + 'input_attrs' => [ + 'label' => ts('Event Full Message'), + 'rows' => 4, + 'cols' => 60, + ], + ], + 'is_monetary' => [ + 'title' => ts('Is this a PAID event?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('If TRUE, one or more fee amounts must be set and a Payment Processor must be configured for Online Event Registration.'), + 'add' => '1.7', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Paid Event'), + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Financial type assigned to paid event registrations for this event. Required if is_monetary is true.'), + 'add' => '4.3', + 'default' => NULL, + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + ], + 'payment_processor' => [ + 'title' => ts('Payment Processor'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('Payment Processors configured for this Event (if is_monetary is true)'), + 'add' => '1.8', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'label' => ts('Payment Processors'), + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_payment_processor', + 'key_column' => 'id', + 'label_column' => 'name', + ], + ], + 'is_map' => [ + 'title' => ts('Map Enabled'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Include a map block on the Event Information page when geocode info is available and a mapping provider has been specified?'), + 'add' => '1.7', + 'default' => FALSE, + ], + 'is_active' => [ + 'title' => ts('Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this Event enabled or disabled/cancelled?'), + 'add' => '1.7', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => [ + 'Enabled', + 'Enabled', + ], + ], + ], + 'fee_label' => [ + 'title' => ts('Fee Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'add' => '1.8', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_show_location' => [ + 'title' => ts('Show Location'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('If TRUE, show event location.'), + 'add' => '1.7', + 'default' => TRUE, + ], + 'loc_block_id' => [ + 'title' => ts('Location Block ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Location Block ID'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Location Block'), + ], + 'entity_reference' => [ + 'entity' => 'LocBlock', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'default_role_id' => [ + 'title' => ts('Default Role'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Participant role ID. Implicit FK to civicrm_option_value where option_group = participant_role.'), + 'add' => '2.0', + 'unique_name' => 'default_role_id', + 'default' => 1, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'participant_role', + ], + ], + 'intro_text' => [ + 'title' => ts('Introductory Message'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Introductory message for Event Registration page. Text and html allowed. Displayed at the top of Event Registration form.'), + 'add' => '1.7', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + ], + ], + 'footer_text' => [ + 'title' => ts('Footer Message'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Footer message for Event Registration page. Text and html allowed. Displayed at the bottom of Event Registration form.'), + 'add' => '1.7', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + ], + ], + 'confirm_title' => [ + 'title' => ts('Confirmation Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Title for Confirmation page.'), + 'add' => '1.7', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'confirm_text' => [ + 'title' => ts('Confirm Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Introductory message for Event Registration page. Text and html allowed. Displayed at the top of Event Registration form.'), + 'add' => '1.7', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + ], + ], + 'confirm_footer_text' => [ + 'title' => ts('Footer Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Footer message for Event Registration page. Text and html allowed. Displayed at the bottom of Event Registration form.'), + 'add' => '1.7', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + ], + ], + 'is_email_confirm' => [ + 'title' => ts('Is confirm email'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('If TRUE, confirmation is automatically emailed to contact on successful registration.'), + 'add' => '1.7', + 'default' => FALSE, + ], + 'confirm_email_text' => [ + 'title' => ts('Confirmation Email Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('text to include above standard event info on confirmation email. emails are text-only, so do not allow html for now'), + 'add' => '1.7', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 50, + ], + ], + 'confirm_from_name' => [ + 'title' => ts('Confirm From Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('FROM email name used for confirmation emails.'), + 'add' => '1.7', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'confirm_from_email' => [ + 'title' => ts('Confirm From Email'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('FROM email address used for confirmation emails.'), + 'add' => '1.7', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'cc_confirm' => [ + 'title' => ts('Cc Confirm'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('comma-separated list of email addresses to cc each time a confirmation is sent'), + 'add' => '1.7', + 'input_attrs' => [ + 'label' => ts('CC Confirm'), + 'maxlength' => 255, + ], + ], + 'bcc_confirm' => [ + 'title' => ts('Bcc Confirm'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('comma-separated list of email addresses to bcc each time a confirmation is sent'), + 'add' => '1.7', + 'input_attrs' => [ + 'label' => ts('BCC Confirm'), + 'maxlength' => 255, + ], + ], + 'default_fee_id' => [ + 'title' => ts('Default Fee ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('FK to civicrm_option_value.'), + 'add' => '1.7', + ], + 'default_discount_fee_id' => [ + 'title' => ts('Default Discount Fee ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('FK to civicrm_option_value.'), + 'add' => '1.7', + ], + 'thankyou_title' => [ + 'title' => ts('ThankYou Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Title for ThankYou page.'), + 'add' => '1.7', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'thankyou_text' => [ + 'title' => ts('ThankYou Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('ThankYou Text.'), + 'add' => '1.7', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + ], + ], + 'thankyou_footer_text' => [ + 'title' => ts('Footer Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('Footer message.'), + 'add' => '1.7', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + ], + ], + 'is_pay_later' => [ + 'title' => ts('Pay Later Allowed'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - allows the user to send payment directly to the org later'), + 'add' => '2.0', + 'default' => FALSE, + ], + 'pay_later_text' => [ + 'title' => ts('Pay Later Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('The text displayed to the user in the main form'), + 'add' => '2.0', + ], + 'pay_later_receipt' => [ + 'title' => ts('Pay Later Receipt Text'), + 'sql_type' => 'text', + 'input_type' => 'RichTextEditor', + 'localizable' => TRUE, + 'description' => ts('The receipt sent to the user instead of the normal receipt text'), + 'add' => '2.0', + ], + 'is_partial_payment' => [ + 'title' => ts('Partial Payments Enabled'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('is partial payment enabled for this event'), + 'add' => '4.3', + 'default' => FALSE, + ], + 'initial_amount_label' => [ + 'title' => ts('Initial Amount Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Initial amount label for partial payment'), + 'add' => '4.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'initial_amount_help_text' => [ + 'title' => ts('Initial Amount Help Text'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Initial amount help text for partial payment'), + 'add' => '4.3', + ], + 'min_initial_amount' => [ + 'title' => ts('Minimum Initial Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'description' => ts('Minimum initial amount for partial payment'), + 'add' => '4.3', + ], + 'is_multiple_registrations' => [ + 'title' => ts('Allow Multiple Registrations'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - allows the user to register multiple participants for event'), + 'add' => '2.1', + 'default' => FALSE, + ], + 'max_additional_participants' => [ + 'title' => ts('Maximum number of additional participants per registration'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Maximum number of additional participants that can be registered on a single booking'), + 'add' => '4.7', + 'default' => 0, + ], + 'allow_same_participant_emails' => [ + 'title' => ts('Does Event allow multiple registrations from same email address?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true - allows the user to register multiple registrations from same email address.'), + 'add' => '2.2', + 'default' => FALSE, + ], + 'has_waitlist' => [ + 'title' => ts('Waitlist Enabled'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Whether the event has waitlist support.'), + 'add' => '3.0', + 'default' => FALSE, + ], + 'requires_approval' => [ + 'title' => ts('Requires Approval'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Whether participants require approval before they can finish registering.'), + 'add' => '3.0', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Requires Approval'), + ], + ], + 'expiration_time' => [ + 'title' => ts('Expiration Time'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Expire pending but unconfirmed registrations after this many hours.'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Expiration Time'), + ], + ], + 'allow_selfcancelxfer' => [ + 'title' => ts('Allow Self-service Cancellation or Transfer'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Allow self service cancellation or transfer for event?'), + 'add' => '4.7', + 'default' => FALSE, + ], + 'selfcancelxfer_time' => [ + 'title' => ts('Self-service Cancellation or Transfer Time'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Number of hours prior to event start date to allow self-service cancellation or transfer.'), + 'add' => '4.7', + 'default' => 0, + ], + 'waitlist_text' => [ + 'title' => ts('Waitlist Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Text to display when the event is full, but participants can signup for a waitlist.'), + 'add' => '3.0', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 60, + 'label' => ts('Waitlist Text'), + ], + ], + 'approval_req_text' => [ + 'title' => ts('Approval Req Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Text to display when the approval is required to complete registration for an event.'), + 'add' => '3.0', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 60, + 'label' => ts('Approval Required Text'), + ], + ], + 'is_template' => [ + 'title' => ts('Is an Event Template'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('whether the event has template'), + 'add' => '3.0', + 'default' => FALSE, + ], + 'template_title' => [ + 'title' => ts('Event Template Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Event Template Title'), + 'add' => '3.0', + 'unique_name' => 'template_title', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contact, who created this event'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('Event Created Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date and time that event was created.'), + 'add' => '3.0', + ], + 'currency' => [ + 'title' => ts('Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '3.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Currency'), + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The campaign for which this event has been created.'), + 'add' => '3.4', + 'component' => 'CiviCampaign', + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_share' => [ + 'title' => ts('Is shared through social media'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Can people share the event through social media?'), + 'add' => '4.1', + 'default' => TRUE, + ], + 'is_confirm_enabled' => [ + 'title' => ts('Is the booking confirmation screen enabled?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('If FALSE, the event booking confirmation screen gets skipped'), + 'add' => '4.5', + 'default' => TRUE, + ], + 'parent_event_id' => [ + 'title' => ts('Parent Event ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Implicit FK to civicrm_event: parent event'), + 'add' => '4.1', + 'default' => NULL, + ], + 'slot_label_id' => [ + 'title' => ts('Subevent Slot Label ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'deprecated' => TRUE, + 'description' => ts('Needs to be moved to Event cart extension. Subevent slot label. Implicit FK to civicrm_option_value where option_group = conference_slot.'), + 'add' => '4.1', + 'default' => NULL, + ], + 'dedupe_rule_group_id' => [ + 'title' => ts('Dedupe Rule ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Rule to use when matching registrations for this event'), + 'add' => '4.5', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Dedupe Rule'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_dedupe_rule_group', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'DedupeRuleGroup', + 'key' => 'id', + ], + ], + 'is_billing_required' => [ + 'title' => ts('Is billing block required'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('if true than billing block is required this event'), + 'add' => '4.6', + 'default' => FALSE, + ], + 'is_show_calendar_links' => [ + 'title' => ts('Are calendar links shown?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('If true then calendar links are shown for this event.'), + 'add' => '5.68', + 'default' => TRUE, + ], + ], +]; diff --git a/schema/Event/Participant.entityType.php b/schema/Event/Participant.entityType.php new file mode 100644 index 000000000000..b9c7f93691e7 --- /dev/null +++ b/schema/Event/Participant.entityType.php @@ -0,0 +1,391 @@ + 'Participant', + 'table' => 'civicrm_participant', + 'class' => 'CRM_Event_DAO_Participant', + 'getInfo' => fn() => [ + 'title' => ts('Participant'), + 'title_plural' => ts('Participants'), + 'description' => 'Records of contacts\' attendance and roles in events.', + 'log' => TRUE, + 'add' => '1.7', + 'icon' => 'fa-ticket', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/participant/add?action=add&context=standalone&reset=1', + 'view' => 'civicrm/contact/view/participant?id=[id]&cid=[contact_id]&action=view&reset=1', + 'update' => 'civicrm/contact/view/participant?id=[id]&cid=[contact_id]&action=update&reset=1', + 'detach' => 'civicrm/event/selfsvcupdate?reset=1&pid=[id]&is_backoffice=1', + 'delete' => 'civicrm/participant/delete?id=[id]&reset=1', + ], + 'getIndices' => fn() => [ + 'index_status_id' => [ + 'fields' => [ + 'status_id' => TRUE, + ], + 'add' => '1.8', + ], + 'index_role_id' => [ + 'fields' => [ + 'role_id' => TRUE, + ], + 'add' => '1.8', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Participant ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Participant ID'), + 'add' => '1.7', + 'unique_name' => 'participant_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact ID'), + 'add' => '1.7', + 'unique_name' => 'participant_contact_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'event_id' => [ + 'title' => ts('Event ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Event ID'), + 'add' => '1.7', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Event'), + ], + 'entity_reference' => [ + 'entity' => 'Event', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'status_id' => [ + 'title' => ts('Status ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Participant status ID. FK to civicrm_participant_status_type. Default of 1 should map to status = Registered.'), + 'add' => '1.7', + 'unique_name' => 'participant_status_id', + 'default' => 1, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Status'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_participant_status_type', + 'key_column' => 'id', + 'label_column' => 'label', + ], + 'entity_reference' => [ + 'entity' => 'ParticipantStatusType', + 'key' => 'id', + ], + ], + 'role_id' => [ + 'title' => ts('Participant Role ID'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Select', + 'description' => ts('Participant role ID. Implicit FK to civicrm_option_value where option_group = participant_role.'), + 'add' => '1.7', + 'unique_name' => 'participant_role_id', + 'default' => NULL, + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'multiple' => '1', + 'label' => ts('Participant Role'), + 'maxlength' => 128, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'participant_role', + ], + ], + 'register_date' => [ + 'title' => ts('Register date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('When did contact register for event?'), + 'add' => '1.7', + 'unique_name' => 'participant_register_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'source' => [ + 'title' => ts('Participant Source'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Source of this event registration.'), + 'add' => '1.7', + 'unique_name' => 'participant_source', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'fee_level' => [ + 'title' => ts('Fee level'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Populate with the label (text) associated with a fee level for paid events with multiple levels. Note that we store the label value and not the key'), + 'add' => '1.7', + 'unique_name' => 'participant_fee_level', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'is_test' => [ + 'title' => ts('Test'), + 'sql_type' => 'boolean', + 'input_type' => 'Radio', + 'required' => TRUE, + 'add' => '1.7', + 'unique_name' => 'participant_is_test', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'is_pay_later' => [ + 'title' => ts('Is Pay Later'), + 'sql_type' => 'boolean', + 'input_type' => 'Radio', + 'required' => TRUE, + 'add' => '2.1', + 'unique_name' => 'participant_is_pay_later', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'fee_amount' => [ + 'title' => ts('Fee Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'description' => ts('actual processor fee if known - may be 0.'), + 'add' => '2.1', + 'unique_name' => 'participant_fee_amount', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'registered_by_id' => [ + 'title' => ts('Registered By Participant ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Participant ID'), + 'add' => '2.1', + 'unique_name' => 'participant_registered_by_id', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Registered By Participant'), + ], + 'entity_reference' => [ + 'entity' => 'Participant', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'discount_id' => [ + 'title' => ts('Discount ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Discount ID'), + 'add' => '2.1', + 'unique_name' => 'participant_discount_id', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Discount'), + ], + 'entity_reference' => [ + 'entity' => 'Discount', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'fee_currency' => [ + 'title' => ts('Fee Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value derived from config setting.'), + 'add' => '3.0', + 'unique_name' => 'participant_fee_currency', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The campaign for which this participant has been registered.'), + 'add' => '3.4', + 'unique_name' => 'participant_campaign_id', + 'component' => 'CiviCampaign', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'discount_amount' => [ + 'title' => ts('Discount Amount'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Discount Amount'), + 'add' => '4.1', + ], + 'cart_id' => [ + 'title' => ts('Event Cart ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_event_carts'), + 'add' => '4.1', + 'input_attrs' => [ + 'label' => ts('Event Cart'), + ], + 'entity_reference' => [ + 'entity' => 'Cart', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'must_wait' => [ + 'title' => ts('Must Wait on List'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('On Waiting List'), + 'add' => '4.1', + ], + 'transferred_to_contact_id' => [ + 'title' => ts('Transferred to Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '4.7', + 'unique_name' => 'transferred_to_contact_id', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Transferred to'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_id' => [ + 'title' => ts('Created by Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Contact responsible for registering this participant'), + 'add' => '5.54', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Event/ParticipantPayment.entityType.php b/schema/Event/ParticipantPayment.entityType.php new file mode 100644 index 000000000000..4170b84d7ab3 --- /dev/null +++ b/schema/Event/ParticipantPayment.entityType.php @@ -0,0 +1,68 @@ + 'ParticipantPayment', + 'table' => 'civicrm_participant_payment', + 'class' => 'CRM_Event_DAO_ParticipantPayment', + 'getInfo' => fn() => [ + 'title' => ts('Participantpayment'), + 'title_plural' => ts('Participantpayments'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.7', + ], + 'getIndices' => fn() => [ + 'UI_contribution_participant' => [ + 'fields' => [ + 'contribution_id' => TRUE, + 'participant_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.0', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Payment ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Participant Payment ID'), + 'add' => '1.7', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'participant_id' => [ + 'title' => ts('Participant ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Participant ID (FK)'), + 'add' => '1.7', + 'input_attrs' => [ + 'label' => ts('Participant'), + ], + 'entity_reference' => [ + 'entity' => 'Participant', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contribution_id' => [ + 'title' => ts('Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to contribution table.'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Contribution'), + ], + 'entity_reference' => [ + 'entity' => 'Contribution', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Event/ParticipantStatusType.entityType.php b/schema/Event/ParticipantStatusType.entityType.php new file mode 100644 index 000000000000..dfa88b34a8b3 --- /dev/null +++ b/schema/Event/ParticipantStatusType.entityType.php @@ -0,0 +1,119 @@ + 'ParticipantStatusType', + 'table' => 'civicrm_participant_status_type', + 'class' => 'CRM_Event_DAO_ParticipantStatusType', + 'getInfo' => fn() => [ + 'title' => ts('Participantstatustype'), + 'title_plural' => ts('Participantstatustypes'), + 'description' => ts('various types of CiviEvent participant statuses'), + 'log' => TRUE, + 'add' => '3.0', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/participant_status?action=add&reset=1', + 'update' => 'civicrm/admin/participant_status?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/participant_status?action=delete&id=[id]&reset=1', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Participant Status Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('unique participant status type id'), + 'add' => '3.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Participant Status'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('non-localized name of the status type'), + 'add' => '3.0', + 'unique_name' => 'participant_status', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'label' => [ + 'title' => ts('Participant Status Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('localized label for display of this status type'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'class' => [ + 'title' => ts('Participant Status Class'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('the general group of status type this one belongs to'), + 'add' => '3.0', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Event_PseudoConstant::participantStatusClassOptions', + ], + ], + 'is_reserved' => [ + 'title' => ts('Participant Status Is Reserved?>'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('whether this is a status type required by the system'), + 'add' => '3.0', + 'default' => FALSE, + ], + 'is_active' => [ + 'title' => ts('Participant Status is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('whether this status type is active'), + 'add' => '3.0', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_counted' => [ + 'title' => ts('Participant Status Counts?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('whether this status type is counted against event size limit'), + 'add' => '3.0', + 'default' => FALSE, + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('controls sort order'), + 'add' => '3.0', + ], + 'visibility_id' => [ + 'title' => ts('Participant Status Visibility'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('whether the status type is visible to the public, an implicit foreign key to option_value.value related to the `visibility` option_group'), + 'add' => '3.0', + 'pseudoconstant' => [ + 'option_group_name' => 'visibility', + ], + ], + ], +]; diff --git a/schema/Financial/Currency.entityType.php b/schema/Financial/Currency.entityType.php new file mode 100644 index 000000000000..76a766b646bd --- /dev/null +++ b/schema/Financial/Currency.entityType.php @@ -0,0 +1,76 @@ + 'Currency', + 'table' => 'civicrm_currency', + 'class' => 'CRM_Financial_DAO_Currency', + 'getInfo' => fn() => [ + 'title' => ts('Currency'), + 'title_plural' => ts('Currencies'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.7', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Currency ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Currency ID'), + 'add' => '1.7', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Currency'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Currency Name'), + 'add' => '1.7', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'symbol' => [ + 'title' => ts('Currency Symbol'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Text', + 'description' => ts('Currency Symbol'), + 'add' => '1.7', + 'input_attrs' => [ + 'maxlength' => 8, + ], + ], + 'numeric_code' => [ + 'title' => ts('Currency Numeric Code'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Text', + 'description' => ts('Numeric currency code'), + 'add' => '1.9', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 3, + ], + ], + 'full_name' => [ + 'title' => ts('Full Currency Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Full currency name'), + 'add' => '1.9', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + ], +]; diff --git a/schema/Financial/EntityFinancialAccount.entityType.php b/schema/Financial/EntityFinancialAccount.entityType.php new file mode 100644 index 000000000000..aa27fa147a8e --- /dev/null +++ b/schema/Financial/EntityFinancialAccount.entityType.php @@ -0,0 +1,109 @@ + 'EntityFinancialAccount', + 'table' => 'civicrm_entity_financial_account', + 'class' => 'CRM_Financial_DAO_EntityFinancialAccount', + 'getInfo' => fn() => [ + 'title' => ts('Entityfinancialaccount'), + 'title_plural' => ts('Entityfinancialaccounts'), + 'description' => ts('Map between an entity and a financial account, where there is a specific relationship between the financial account and the entity, e.g. Income Account for or AR Account for'), + 'log' => TRUE, + 'add' => '4.3', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/financial/financialType/accounts?action=add&reset=1&aid=[entity_id]', + 'update' => 'civicrm/admin/financial/financialType/accounts?action=update&id=[id]&aid=[entity_id]&reset=1', + 'delete' => 'civicrm/admin/financial/financialType/accounts?action=delete&id=[id]&aid=[entity_id]&reset=1', + ], + 'getIndices' => fn() => [ + 'index_entity_id_entity_table_account_relationship' => [ + 'fields' => [ + 'entity_id' => TRUE, + 'entity_table' => TRUE, + 'account_relationship' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.7', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Entity Financial Account ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('ID'), + 'add' => '4.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Links to an entity_table like civicrm_financial_type'), + 'add' => '4.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Entity Type'), + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Financial_BAO_EntityFinancialAccount::entityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Links to an id in the entity_table, such as vid in civicrm_financial_type'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Entity'), + ], + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'account_relationship' => [ + 'title' => ts('Account Relationship'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to a new civicrm_option_value (account_relationship)'), + 'add' => '4.3', + 'pseudoconstant' => [ + 'option_group_name' => 'account_relationship', + ], + ], + 'financial_account_id' => [ + 'title' => ts('Financial Account ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to the financial_account_id'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Financial Account'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_account', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialAccount', + 'key' => 'id', + 'on_delete' => 'RESTRICT', + ], + ], + ], +]; diff --git a/schema/Financial/EntityFinancialTrxn.entityType.php b/schema/Financial/EntityFinancialTrxn.entityType.php new file mode 100644 index 000000000000..58c01501e9dd --- /dev/null +++ b/schema/Financial/EntityFinancialTrxn.entityType.php @@ -0,0 +1,96 @@ + 'EntityFinancialTrxn', + 'table' => 'civicrm_entity_financial_trxn', + 'class' => 'CRM_Financial_DAO_EntityFinancialTrxn', + 'getInfo' => fn() => [ + 'title' => ts('Entityfinancialtrxn'), + 'title_plural' => ts('Entityfinancialtrxns'), + 'description' => ts('FIXME'), + 'add' => '3.2', + ], + 'getIndices' => fn() => [ + 'UI_entity_financial_trxn_entity_table' => [ + 'fields' => [ + 'entity_table' => TRUE, + ], + 'add' => '4.3', + ], + 'UI_entity_financial_trxn_entity_id' => [ + 'fields' => [ + 'entity_id' => TRUE, + ], + 'add' => '4.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Entity Financial Transaction ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('ID'), + 'add' => '3.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'), + 'add' => '3.2', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Financial_BAO_EntityFinancialTrxn::entityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'add' => '3.2', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'financial_trxn_id' => [ + 'title' => ts('Financial Transaction ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'add' => '3.2', + 'input_attrs' => [ + 'label' => ts('Financial Transaction'), + ], + 'entity_reference' => [ + 'entity' => 'FinancialTrxn', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'amount' => [ + 'title' => ts('Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('allocated amount of transaction to this entity'), + 'add' => '3.2', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + ], +]; diff --git a/schema/Financial/FinancialAccount.entityType.php b/schema/Financial/FinancialAccount.entityType.php new file mode 100644 index 000000000000..d2e290c7fdfb --- /dev/null +++ b/schema/Financial/FinancialAccount.entityType.php @@ -0,0 +1,200 @@ + 'FinancialAccount', + 'table' => 'civicrm_financial_account', + 'class' => 'CRM_Financial_DAO_FinancialAccount', + 'getInfo' => fn() => [ + 'title' => ts('Financialaccount'), + 'title_plural' => ts('Financialaccounts'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '3.2', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/financial/financialAccount/edit?action=add&reset=1', + 'update' => 'civicrm/admin/financial/financialAccount/edit?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/financial/financialAccount/edit?action=delete&id=[id]&reset=1', + 'browse' => 'civicrm/admin/financial/financialAccount', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '4.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Financial Account ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('ID'), + 'add' => '3.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Financial Account Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Financial Account Name.'), + 'add' => '3.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID that is responsible for the funds in this account'), + 'add' => '4.3', + 'unique_name' => 'financial_account_contact_id', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'financial_account_type_id' => [ + 'title' => ts('Financial Account Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('pseudo FK into civicrm_option_value.'), + 'add' => '4.3', + 'default' => 3, + 'pseudoconstant' => [ + 'option_group_name' => 'financial_account_type', + ], + ], + 'accounting_code' => [ + 'title' => ts('Accounting Code'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Optional value for mapping monies owed and received to accounting system codes.'), + 'add' => '4.3', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'account_type_code' => [ + 'title' => ts('Account Type Code'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).'), + 'add' => '4.3', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Financial Account Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Financial Type Description.'), + 'add' => '4.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'parent_id' => [ + 'title' => ts('Parent ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Parent ID in account hierarchy'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Parent'), + ], + 'entity_reference' => [ + 'entity' => 'FinancialAccount', + 'key' => 'id', + ], + ], + 'is_header_account' => [ + 'title' => ts('Header Financial Account?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?'), + 'add' => '4.3', + 'default' => FALSE, + ], + 'is_deductible' => [ + 'title' => ts('Deductible Financial Account?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this account tax-deductible?'), + 'add' => '4.3', + 'default' => FALSE, + ], + 'is_tax' => [ + 'title' => ts('Tax Financial Account?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this account for taxes?'), + 'add' => '4.3', + 'default' => FALSE, + ], + 'tax_rate' => [ + 'title' => ts('Financial Account Tax Rate'), + 'sql_type' => 'decimal(10,8)', + 'input_type' => NULL, + 'description' => ts('The percentage of the total_amount that is due for this tax.'), + 'add' => '4.3', + 'input_attrs' => [ + 'maxlength' => 10, + ], + ], + 'is_reserved' => [ + 'title' => ts('Reserved Financial Account?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a predefined system object?'), + 'add' => '4.3', + 'default' => FALSE, + ], + 'is_active' => [ + 'title' => ts('Financial Account is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property active?'), + 'add' => '4.3', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_default' => [ + 'title' => ts('Default Financial Account'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this account the default one (or default tax one) for its financial_account_type?'), + 'add' => '4.3', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + ], +]; diff --git a/schema/Financial/FinancialItem.entityType.php b/schema/Financial/FinancialItem.entityType.php new file mode 100644 index 000000000000..bcb73ad6c241 --- /dev/null +++ b/schema/Financial/FinancialItem.entityType.php @@ -0,0 +1,180 @@ + 'FinancialItem', + 'table' => 'civicrm_financial_item', + 'class' => 'CRM_Financial_DAO_FinancialItem', + 'getInfo' => fn() => [ + 'title' => ts('Financialitem'), + 'title_plural' => ts('Financialitems'), + 'description' => ts('Financial data for civicrm_line_item, etc.'), + 'log' => TRUE, + 'add' => '4.3', + ], + 'getIndices' => fn() => [ + 'IX_created_date' => [ + 'fields' => [ + 'created_date' => TRUE, + ], + 'add' => '4.3', + ], + 'IX_transaction_date' => [ + 'fields' => [ + 'transaction_date' => TRUE, + ], + 'add' => '4.3', + ], + 'index_entity_id_entity_table' => [ + 'fields' => [ + 'entity_id' => TRUE, + 'entity_table' => TRUE, + ], + 'add' => '4.7', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Financial Item ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '4.3', + 'input_attrs' => [ + 'maxlength' => 10, + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'created_date' => [ + 'title' => ts('Financial Item Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('Date and time the item was created'), + 'add' => '4.3', + 'default' => 'CURRENT_TIMESTAMP', + ], + 'transaction_date' => [ + 'title' => ts('Financial Item Transaction Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'description' => ts('Date and time of the source transaction'), + 'add' => '4.3', + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact ID of contact the item is from'), + 'add' => '4.3', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'description' => [ + 'title' => ts('Financial Item Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Human readable description of this item, to ease display without lookup of source item.'), + 'add' => '4.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'amount' => [ + 'title' => ts('Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('Total amount of this item'), + 'add' => '4.3', + 'default' => '0', + ], + 'currency' => [ + 'title' => ts('Financial Item Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('Currency for the amount'), + 'add' => '4.3', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'financial_account_id' => [ + 'title' => ts('Financial Account ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to civicrm_financial_account'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Financial Account'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_account', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialAccount', + 'key' => 'id', + ], + ], + 'status_id' => [ + 'title' => ts('Financial Item Status ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'), + 'add' => '4.3', + 'usage' => [ + 'export', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'financial_item_status', + ], + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('May contain civicrm_line_item, civicrm_financial_trxn etc'), + 'add' => '4.3', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Financial_BAO_FinancialItem::entityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The specific source item that is responsible for the creation of this financial_item'), + 'add' => '4.3', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + ], +]; diff --git a/schema/Financial/FinancialTrxn.entityType.php b/schema/Financial/FinancialTrxn.entityType.php new file mode 100644 index 000000000000..acfe6d8f175f --- /dev/null +++ b/schema/Financial/FinancialTrxn.entityType.php @@ -0,0 +1,267 @@ + 'FinancialTrxn', + 'table' => 'civicrm_financial_trxn', + 'class' => 'CRM_Financial_DAO_FinancialTrxn', + 'getInfo' => fn() => [ + 'title' => ts('Financialtrxn'), + 'title_plural' => ts('Financialtrxns'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.3', + ], + 'getIndices' => fn() => [ + 'UI_ftrxn_trxn_id' => [ + 'fields' => [ + 'trxn_id' => TRUE, + ], + 'add' => '4.7', + ], + 'UI_ftrxn_payment_instrument_id' => [ + 'fields' => [ + 'payment_instrument_id' => TRUE, + ], + 'add' => '4.3', + ], + 'UI_ftrxn_check_number' => [ + 'fields' => [ + 'check_number' => TRUE, + ], + 'add' => '4.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Financial Transaction ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '1.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'from_financial_account_id' => [ + 'title' => ts('From Account ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to financial_account table.'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('From Account'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_account', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialAccount', + 'key' => 'id', + ], + ], + 'to_financial_account_id' => [ + 'title' => ts('To Account ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to financial_financial_account table.'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('To Account'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_account', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialAccount', + 'key' => 'id', + ], + ], + 'trxn_date' => [ + 'title' => ts('Financial Transaction Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('date transaction occurred'), + 'add' => '1.3', + 'default' => NULL, + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'total_amount' => [ + 'title' => ts('Financial Total Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('amount of transaction'), + 'add' => '1.3', + ], + 'fee_amount' => [ + 'title' => ts('Financial Fee Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('actual processor fee if known - may be 0.'), + 'add' => '1.3', + ], + 'net_amount' => [ + 'title' => ts('Financial Net Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.'), + 'add' => '1.3', + ], + 'currency' => [ + 'title' => ts('Financial Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '1.3', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'is_payment' => [ + 'title' => ts('Is Payment?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this entry either a payment or a reversal of a payment?'), + 'add' => '4.7', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'trxn_id' => [ + 'title' => ts('Transaction ID'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Transaction id supplied by external processor. This may not be unique.'), + 'add' => '1.3', + 'input_attrs' => [ + 'size' => '10', + 'maxlength' => 255, + ], + ], + 'trxn_result_code' => [ + 'title' => ts('Transaction Result Code'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('processor result code'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'status_id' => [ + 'title' => ts('Financial Transaction Status ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('pseudo FK to civicrm_option_value of contribution_status_id option_group'), + 'add' => '4.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'contribution_status', + ], + ], + 'payment_processor_id' => [ + 'title' => ts('Payment Processor ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Payment Processor for this financial transaction'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Payment Processor'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_payment_processor', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'PaymentProcessor', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'payment_instrument_id' => [ + 'title' => ts('Payment Method'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to payment_instrument option group values'), + 'add' => '4.3', + 'unique_name' => 'financial_trxn_payment_instrument_id', + 'pseudoconstant' => [ + 'option_group_name' => 'payment_instrument', + ], + ], + 'card_type_id' => [ + 'title' => ts('Card Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to accept_creditcard option group values'), + 'add' => '4.7', + 'unique_name' => 'financial_trxn_card_type_id', + 'pseudoconstant' => [ + 'option_group_name' => 'accept_creditcard', + ], + ], + 'check_number' => [ + 'title' => ts('Check Number'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Check number'), + 'add' => '4.3', + 'unique_name' => 'financial_trxn_check_number', + 'input_attrs' => [ + 'size' => '6', + 'maxlength' => 255, + ], + ], + 'pan_truncation' => [ + 'title' => ts('PAN Truncation'), + 'sql_type' => 'varchar(4)', + 'input_type' => 'Text', + 'description' => ts('Last 4 digits of credit card'), + 'add' => '4.7', + 'unique_name' => 'financial_trxn_pan_truncation', + 'input_attrs' => [ + 'size' => '4', + 'maxlength' => 4, + ], + ], + 'order_reference' => [ + 'title' => ts('Order Reference'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Payment Processor external order reference'), + 'add' => '5.20', + 'unique_name' => 'financial_trxn_order_reference', + 'input_attrs' => [ + 'size' => '25', + 'maxlength' => 255, + ], + ], + ], +]; diff --git a/schema/Financial/FinancialType.entityType.php b/schema/Financial/FinancialType.entityType.php new file mode 100644 index 000000000000..67d3ada76eac --- /dev/null +++ b/schema/Financial/FinancialType.entityType.php @@ -0,0 +1,106 @@ + 'FinancialType', + 'table' => 'civicrm_financial_type', + 'class' => 'CRM_Financial_DAO_FinancialType', + 'getInfo' => fn() => [ + 'title' => ts('Financialtype'), + 'title_plural' => ts('Financialtypes'), + 'description' => ts('Formerly civicrm_contribution_type merged into this table in 4.3'), + 'log' => TRUE, + 'add' => '1.3', + 'label_field' => 'name', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/financial/financialType/edit?action=add&reset=1', + 'update' => 'civicrm/admin/financial/financialType/edit?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/financial/financialType/edit?action=delete&id=[id]&reset=1', + 'browse' => 'civicrm/admin/financial/financialType', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('ID of original financial_type so you can search this table by the financial_type.id and then select the relevant version based on the timestamp'), + 'add' => '1.3', + 'input_attrs' => [ + 'maxlength' => 10, + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Financial Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Financial Type Name.'), + 'add' => '1.3', + 'unique_name' => 'financial_type', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Name'), + 'maxlength' => 64, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'TextArea', + 'description' => ts('Financial Type Description.'), + 'add' => '1.3', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + 'label' => ts('Description'), + 'maxlength' => 255, + ], + ], + 'is_deductible' => [ + 'title' => ts('Is Tax Deductible?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this financial type tax-deductible? If TRUE, contributions of this type may be fully OR partially deductible - non-deductible amount is stored in the Contribution record.'), + 'add' => '1.3', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Tax-Deductible?'), + 'maxlength' => 4, + ], + ], + 'is_reserved' => [ + 'title' => ts('Financial Type is Reserved?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a predefined system object?'), + 'add' => '1.3', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Reserved?'), + 'maxlength' => 4, + ], + ], + 'is_active' => [ + 'title' => ts('Financial Type Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property active?'), + 'add' => '1.3', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + 'maxlength' => 4, + ], + ], + ], +]; diff --git a/schema/Financial/PaymentProcessor.entityType.php b/schema/Financial/PaymentProcessor.entityType.php new file mode 100644 index 000000000000..83305e83e02a --- /dev/null +++ b/schema/Financial/PaymentProcessor.entityType.php @@ -0,0 +1,291 @@ + 'PaymentProcessor', + 'table' => 'civicrm_payment_processor', + 'class' => 'CRM_Financial_DAO_PaymentProcessor', + 'getInfo' => fn() => [ + 'title' => ts('Paymentprocessor'), + 'title_plural' => ts('Paymentprocessors'), + 'description' => ts('FIXME'), + 'add' => '1.8', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/paymentProcessor/edit?action=add&reset=1', + 'update' => 'civicrm/admin/paymentProcessor/edit?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/paymentProcessor/edit?action=delete&id=[id]&reset=1', + 'browse' => 'civicrm/admin/paymentProcessor', + ], + 'getIndices' => fn() => [ + 'UI_name_test_domain_id' => [ + 'fields' => [ + 'name' => TRUE, + 'is_test' => TRUE, + 'domain_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.8', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Payment Processor ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Payment Processor ID'), + 'add' => '1.8', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Which Domain is this match entry for'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'name' => [ + 'title' => ts('Payment Processor Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Payment Processor Name.'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Machine Name'), + 'maxlength' => 64, + ], + ], + 'title' => [ + 'title' => ts('Payment Processor Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Name of processor when shown to CiviCRM administrators.'), + 'add' => '5.13', + 'input_attrs' => [ + 'label' => ts('Backend Title'), + 'maxlength' => 255, + ], + ], + 'frontend_title' => [ + 'title' => ts('Payment Processor Frontend Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Name of processor when shown to users making a payment.'), + 'add' => '5.61', + 'input_attrs' => [ + 'label' => ts('Frontend Title'), + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Processor Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Additional processor information shown to administrators.'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Description'), + 'maxlength' => 255, + ], + ], + 'payment_processor_type_id' => [ + 'title' => ts('Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Type'), + 'maxlength' => 10, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_payment_processor_type', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'PaymentProcessorType', + 'key' => 'id', + ], + ], + 'is_active' => [ + 'title' => ts('Processor is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this processor active?'), + 'add' => '1.8', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_default' => [ + 'title' => ts('Processor Is Default?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this processor the default?'), + 'add' => '1.8', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'is_test' => [ + 'title' => ts('Is Test Processor?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this processor for a test site?'), + 'add' => '1.8', + 'default' => FALSE, + ], + 'user_name' => [ + 'title' => ts('User Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'password' => [ + 'title' => ts('Password'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Password', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'signature' => [ + 'title' => ts('Signature'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'add' => '1.8', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 40, + ], + ], + 'url_site' => [ + 'title' => ts('Site URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_api' => [ + 'title' => ts('API URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_recur' => [ + 'title' => ts('Recurring Payments URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_button' => [ + 'title' => ts('Button URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'subject' => [ + 'title' => ts('Subject'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'class_name' => [ + 'title' => ts('Suffix for PHP class name implementation'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'billing_mode' => [ + 'title' => ts('Processor Billing Mode'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Billing Mode (deprecated)'), + 'add' => '1.8', + ], + 'is_recur' => [ + 'title' => ts('Processor Supports Recurring?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Can process recurring contributions'), + 'add' => '1.8', + 'default' => FALSE, + ], + 'payment_type' => [ + 'title' => ts('Payment Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Payment Type: Credit or Debit (deprecated)'), + 'add' => '3.0', + 'default' => 1, + ], + 'payment_instrument_id' => [ + 'title' => ts('Payment Method'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Payment Instrument ID'), + 'add' => '4.7', + 'default' => 1, + 'pseudoconstant' => [ + 'option_group_name' => 'payment_instrument', + ], + ], + 'accepted_credit_cards' => [ + 'title' => ts('Accepted Credit Cards'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('array of accepted credit card types'), + 'add' => '4.7', + 'default' => NULL, + 'serialize' => CRM_Core_DAO::SERIALIZE_JSON, + ], + ], +]; diff --git a/schema/Financial/PaymentProcessorType.entityType.php b/schema/Financial/PaymentProcessorType.entityType.php new file mode 100644 index 000000000000..b3589aedb067 --- /dev/null +++ b/schema/Financial/PaymentProcessorType.entityType.php @@ -0,0 +1,255 @@ + 'PaymentProcessorType', + 'table' => 'civicrm_payment_processor_type', + 'class' => 'CRM_Financial_DAO_PaymentProcessorType', + 'getInfo' => fn() => [ + 'title' => ts('Paymentprocessortype'), + 'title_plural' => ts('Paymentprocessortypes'), + 'description' => ts('FIXME'), + 'add' => '1.8', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/paymentProcessorType?reset=1&action=add', + 'delete' => 'civicrm/admin/paymentProcessorType?reset=1&action=delete&id=[id]', + 'update' => 'civicrm/admin/paymentProcessorType?reset=1&action=update&id=[id]', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Payment Processor Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Payment Processor Type ID'), + 'add' => '1.8', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Payment Processor Type variable name to be used in code'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Payment Processor Type Name.'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'title' => [ + 'title' => ts('Payment Processor Type Title'), + 'sql_type' => 'varchar(127)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Payment Processor Type Title.'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 127, + ], + ], + 'description' => [ + 'title' => ts('Processor Type Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Payment Processor Description.'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_active' => [ + 'title' => ts('Processor Type Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this processor active?'), + 'add' => '1.8', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_default' => [ + 'title' => ts('Processor Type is Default?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this processor the default?'), + 'add' => '1.8', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'user_name_label' => [ + 'title' => ts('Label for User Name if used'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'password_label' => [ + 'title' => ts('Label for password'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'signature_label' => [ + 'title' => ts('Label for Signature'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'subject_label' => [ + 'title' => ts('Label for Subject'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'class_name' => [ + 'title' => ts('Suffix for PHP class name implementation'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_site_default' => [ + 'title' => ts('Default Live Site URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_api_default' => [ + 'title' => ts('Default API Site URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_recur_default' => [ + 'title' => ts('Default Live Recurring Payments URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_button_default' => [ + 'title' => ts('Default Live Button URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_site_test_default' => [ + 'title' => ts('Default Test Site URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_api_test_default' => [ + 'title' => ts('Default Test API URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_recur_test_default' => [ + 'title' => ts('Default Test Recurring Payment URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'url_button_test_default' => [ + 'title' => ts('Default Test Button URL'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'billing_mode' => [ + 'title' => ts('Billing Mode'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Billing Mode (deprecated)'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Billing Mode'), + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::billingMode', + ], + ], + 'is_recur' => [ + 'title' => ts('Processor Type Supports Recurring?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Can process recurring contributions'), + 'add' => '1.8', + 'default' => FALSE, + ], + 'payment_type' => [ + 'title' => ts('Processor Type Payment Type'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Payment Type: Credit or Debit (deprecated)'), + 'add' => '3.0', + 'default' => 1, + ], + 'payment_instrument_id' => [ + 'title' => ts('Payment Method'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Payment Instrument ID'), + 'add' => '4.7', + 'default' => 1, + 'pseudoconstant' => [ + 'option_group_name' => 'payment_instrument', + ], + ], + ], +]; diff --git a/schema/Financial/PaymentToken.entityType.php b/schema/Financial/PaymentToken.entityType.php new file mode 100644 index 000000000000..c3c73b1bfd01 --- /dev/null +++ b/schema/Financial/PaymentToken.entityType.php @@ -0,0 +1,158 @@ + 'PaymentToken', + 'table' => 'civicrm_payment_token', + 'class' => 'CRM_Financial_DAO_PaymentToken', + 'getInfo' => fn() => [ + 'title' => ts('Paymenttoken'), + 'title_plural' => ts('Paymenttokens'), + 'description' => ts('Payment Token'), + 'add' => '4.6', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Payment Token ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Payment Token ID'), + 'add' => '4.6', + 'unique_name' => 'payment_token_id', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact ID for the owner of the token'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'payment_processor_id' => [ + 'title' => ts('Payment Processor ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Payment Processor'), + ], + 'entity_reference' => [ + 'entity' => 'PaymentProcessor', + 'key' => 'id', + 'on_delete' => 'RESTRICT', + ], + ], + 'token' => [ + 'title' => ts('Token'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Externally provided token string'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'created_date' => [ + 'title' => ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('Date created'), + 'add' => '4.6', + 'default' => 'CURRENT_TIMESTAMP', + ], + 'created_id' => [ + 'title' => ts('Created ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Contact ID of token creator'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Created'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'expiry_date' => [ + 'title' => ts('Expiry Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date this token expires'), + 'add' => '4.6', + ], + 'email' => [ + 'title' => ts('Email'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Email at the time of token creation. Useful for fraud forensics'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'billing_first_name' => [ + 'title' => ts('Billing First Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Billing first name at the time of token creation. Useful for fraud forensics'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'billing_middle_name' => [ + 'title' => ts('Billing Middle Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Billing middle name at the time of token creation. Useful for fraud forensics'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'billing_last_name' => [ + 'title' => ts('Billing Last Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Billing last name at the time of token creation. Useful for fraud forensics'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'masked_account_number' => [ + 'title' => ts('Masked Account Number'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Holds the part of the card number or account details that may be retained or displayed'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'ip_address' => [ + 'title' => ts('IP Address'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('IP used when creating the token. Useful for fraud forensics'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + ], +]; diff --git a/schema/Friend/Friend.entityType.php b/schema/Friend/Friend.entityType.php new file mode 100644 index 000000000000..08380e530346 --- /dev/null +++ b/schema/Friend/Friend.entityType.php @@ -0,0 +1,119 @@ + 'Friend', + 'table' => 'civicrm_tell_friend', + 'class' => 'CRM_Friend_DAO_Friend', + 'getInfo' => fn() => [ + 'title' => ts('Friend'), + 'title_plural' => ts('Friends'), + 'description' => ts('FIXME'), + 'add' => '2.0', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Friend ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Friend ID'), + 'add' => '2.0', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name of table where item being referenced is stored.'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to the referenced item.'), + 'add' => '2.0', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'title' => [ + 'title' => ts('Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'intro' => [ + 'title' => ts('Intro'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Introductory message to contributor or participant displayed on the Tell a Friend form.'), + 'add' => '2.0', + ], + 'suggested_message' => [ + 'title' => ts('Suggested Message'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Suggested message to friends, provided as default on the Tell A Friend form.'), + 'add' => '2.0', + ], + 'general_link' => [ + 'title' => ts('General Link'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('URL for general info about the organization - included in the email sent to friends.'), + 'add' => '2.0', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'thankyou_title' => [ + 'title' => ts('Thank You Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Text for Tell a Friend thank you page header and HTML title.'), + 'add' => '2.0', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'thankyou_text' => [ + 'title' => ts('Thank You Text'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Thank you message displayed on success page.'), + 'add' => '2.0', + ], + 'is_active' => [ + 'title' => ts('Enabled?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '2.0', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Mailing/BouncePattern.entityType.php b/schema/Mailing/BouncePattern.entityType.php new file mode 100644 index 000000000000..5b8daafa9c4b --- /dev/null +++ b/schema/Mailing/BouncePattern.entityType.php @@ -0,0 +1,51 @@ + 'BouncePattern', + 'table' => 'civicrm_mailing_bounce_pattern', + 'class' => 'CRM_Mailing_DAO_BouncePattern', + 'getInfo' => fn() => [ + 'title' => ts('Bouncepattern'), + 'title_plural' => ts('Bouncepatterns'), + 'description' => ts('Pseudo-constant table of patterns for bounce classification'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Bounce Pattern ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'bounce_type_id' => [ + 'title' => ts('Bounce Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Type of bounce'), + 'input_attrs' => [ + 'label' => ts('Bounce Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_mailing_bounce_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'BounceType', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'pattern' => [ + 'title' => ts('Pattern'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('A regexp to match a message to a bounce type'), + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + ], +]; diff --git a/schema/Mailing/BounceType.entityType.php b/schema/Mailing/BounceType.entityType.php new file mode 100644 index 000000000000..187390c302b1 --- /dev/null +++ b/schema/Mailing/BounceType.entityType.php @@ -0,0 +1,48 @@ + 'BounceType', + 'table' => 'civicrm_mailing_bounce_type', + 'class' => 'CRM_Mailing_DAO_BounceType', + 'getInfo' => fn() => [ + 'title' => ts('Bouncetype'), + 'title_plural' => ts('Bouncetypes'), + 'description' => ts('Table to index the various bounce types and their properties'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Bounce Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Bounce Type Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Type of bounce'), + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Bounce Type Description'), + 'sql_type' => 'varchar(2048)', + 'input_type' => 'Text', + 'description' => ts('A description of this bounce type'), + 'input_attrs' => [ + 'maxlength' => 2048, + ], + ], + 'hold_threshold' => [ + 'title' => ts('Hold Threshold'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Number of bounces of this type required before the email address is put on bounce hold'), + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventBounce.entityType.php b/schema/Mailing/Event/MailingEventBounce.entityType.php new file mode 100644 index 000000000000..b0a7812333a3 --- /dev/null +++ b/schema/Mailing/Event/MailingEventBounce.entityType.php @@ -0,0 +1,71 @@ + 'MailingEventBounce', + 'table' => 'civicrm_mailing_event_bounce', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventBounce', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Bounce'), + 'title_plural' => ts('Mailing Bounces'), + 'description' => ts('Mailings that failed to reach the inbox of the recipient.'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Bounce ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'event_queue_id' => [ + 'title' => ts('Event Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to EventQueue'), + 'input_attrs' => [ + 'label' => ts('Recipient'), + ], + 'entity_reference' => [ + 'entity' => 'MailingEventQueue', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'bounce_type_id' => [ + 'title' => ts('Bounce Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('What type of bounce was it?'), + 'input_attrs' => [ + 'label' => ts('Bounce Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_mailing_bounce_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + ], + 'bounce_reason' => [ + 'title' => ts('Bounce Reason'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('The reason the email bounced.'), + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'time_stamp' => [ + 'title' => ts('Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('When this bounce event occurred.'), + 'default' => 'CURRENT_TIMESTAMP', + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventConfirm.entityType.php b/schema/Mailing/Event/MailingEventConfirm.entityType.php new file mode 100644 index 000000000000..7cbf7e495b6f --- /dev/null +++ b/schema/Mailing/Event/MailingEventConfirm.entityType.php @@ -0,0 +1,48 @@ + 'MailingEventConfirm', + 'table' => 'civicrm_mailing_event_confirm', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventConfirm', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Opt-In Confirmation'), + 'title_plural' => ts('Mailing Opt-In Confirmations'), + 'description' => ts('Tracks when a subscription event is confirmed by email'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mailing Confirmation ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'event_subscribe_id' => [ + 'title' => ts('Mailing Subscribe ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to civicrm_mailing_event_subscribe'), + 'input_attrs' => [ + 'label' => ts('Mailing Subscribe'), + ], + 'entity_reference' => [ + 'entity' => 'MailingEventSubscribe', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'time_stamp' => [ + 'title' => ts('Confirm Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('When this confirmation event occurred.'), + 'default' => 'CURRENT_TIMESTAMP', + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventDelivered.entityType.php b/schema/Mailing/Event/MailingEventDelivered.entityType.php new file mode 100644 index 000000000000..0efa7fbc95db --- /dev/null +++ b/schema/Mailing/Event/MailingEventDelivered.entityType.php @@ -0,0 +1,48 @@ + 'MailingEventDelivered', + 'table' => 'civicrm_mailing_event_delivered', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventDelivered', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Delivery'), + 'title_plural' => ts('Mailing Deliveries'), + 'description' => ts('Tracks when a queued email is actually delivered to the MTA'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Delivered ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'event_queue_id' => [ + 'title' => ts('Event Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to EventQueue'), + 'input_attrs' => [ + 'label' => ts('Recipient'), + ], + 'entity_reference' => [ + 'entity' => 'MailingEventQueue', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'time_stamp' => [ + 'title' => ts('Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('When this delivery event occurred.'), + 'default' => 'CURRENT_TIMESTAMP', + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventForward.entityType.php b/schema/Mailing/Event/MailingEventForward.entityType.php new file mode 100644 index 000000000000..4835dfd0ed08 --- /dev/null +++ b/schema/Mailing/Event/MailingEventForward.entityType.php @@ -0,0 +1,62 @@ + 'MailingEventForward', + 'table' => 'civicrm_mailing_event_forward', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventForward', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Forward'), + 'title_plural' => ts('Mailing Forwards'), + 'description' => ts('Tracks when a contact forwards a mailing to a (new) contact'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Forward ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'event_queue_id' => [ + 'title' => ts('Event Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to EventQueue'), + 'input_attrs' => [ + 'label' => ts('Recipient'), + ], + 'entity_reference' => [ + 'entity' => 'MailingEventQueue', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'dest_queue_id' => [ + 'title' => ts('Destination Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to EventQueue for destination'), + 'input_attrs' => [ + 'label' => ts('Destination Queue'), + ], + 'entity_reference' => [ + 'entity' => 'MailingEventQueue', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'time_stamp' => [ + 'title' => ts('Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('When this forward event occurred.'), + 'default' => 'CURRENT_TIMESTAMP', + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventOpened.entityType.php b/schema/Mailing/Event/MailingEventOpened.entityType.php new file mode 100644 index 000000000000..00dc3a7778e1 --- /dev/null +++ b/schema/Mailing/Event/MailingEventOpened.entityType.php @@ -0,0 +1,48 @@ + 'MailingEventOpened', + 'table' => 'civicrm_mailing_event_opened', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventOpened', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Opened'), + 'title_plural' => ts('Mailings Opened'), + 'description' => ts('Tracks when a delivered email is opened by the recipient'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mailing Opened ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'event_queue_id' => [ + 'title' => ts('Event Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to EventQueue'), + 'input_attrs' => [ + 'label' => ts('Recipient'), + ], + 'entity_reference' => [ + 'entity' => 'MailingEventQueue', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'time_stamp' => [ + 'title' => ts('Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('When this open event occurred.'), + 'default' => 'CURRENT_TIMESTAMP', + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventQueue.entityType.php b/schema/Mailing/Event/MailingEventQueue.entityType.php new file mode 100644 index 000000000000..fcd4edfc2741 --- /dev/null +++ b/schema/Mailing/Event/MailingEventQueue.entityType.php @@ -0,0 +1,126 @@ + 'MailingEventQueue', + 'table' => 'civicrm_mailing_event_queue', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventQueue', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Recipient'), + 'title_plural' => ts('Mailing Recipients'), + 'description' => ts('Intended recipients of a mailing.'), + ], + 'getIndices' => fn() => [ + 'index_hash' => [ + 'fields' => [ + 'hash' => TRUE, + ], + 'add' => '4.7', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mailing Event Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'job_id' => [ + 'title' => ts('Job ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Mailing Job'), + 'input_attrs' => [ + 'label' => ts('Outbound Mailing'), + ], + 'entity_reference' => [ + 'entity' => 'MailingJob', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'mailing_id' => [ + 'title' => ts('Mailing ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Related mailing. Used for reporting on mailing success, if present.'), + 'add' => '5.67', + 'input_attrs' => [ + 'label' => ts('Mailing'), + ], + 'entity_reference' => [ + 'entity' => 'Mailing', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_test' => [ + 'title' => ts('Test'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'readonly' => TRUE, + 'add' => '5.67', + 'default' => FALSE, + ], + 'email_id' => [ + 'title' => ts('Email ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Email'), + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Email'), + ], + 'entity_reference' => [ + 'entity' => 'Email', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact'), + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'hash' => [ + 'title' => ts('Security Hash'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Security hash'), + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'phone_id' => [ + 'title' => ts('Phone ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Phone'), + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Phone'), + ], + 'entity_reference' => [ + 'entity' => 'Phone', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventReply.entityType.php b/schema/Mailing/Event/MailingEventReply.entityType.php new file mode 100644 index 000000000000..52605cc069ab --- /dev/null +++ b/schema/Mailing/Event/MailingEventReply.entityType.php @@ -0,0 +1,48 @@ + 'MailingEventReply', + 'table' => 'civicrm_mailing_event_reply', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventReply', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Reply'), + 'title_plural' => ts('Mailing Replies'), + 'description' => ts('Tracks when a contact replies to a mailing'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Reply ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'event_queue_id' => [ + 'title' => ts('Event Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to EventQueue'), + 'input_attrs' => [ + 'label' => ts('Recipient'), + ], + 'entity_reference' => [ + 'entity' => 'MailingEventQueue', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'time_stamp' => [ + 'title' => ts('Reply Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('When this reply event occurred.'), + 'default' => 'CURRENT_TIMESTAMP', + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventSubscribe.entityType.php b/schema/Mailing/Event/MailingEventSubscribe.entityType.php new file mode 100644 index 000000000000..407a87cfd52c --- /dev/null +++ b/schema/Mailing/Event/MailingEventSubscribe.entityType.php @@ -0,0 +1,78 @@ + 'MailingEventSubscribe', + 'table' => 'civicrm_mailing_event_subscribe', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventSubscribe', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Opt-In'), + 'title_plural' => ts('Mailing Opt-Ins'), + 'description' => ts('Tracks when a (new) contact subscribes to a group by email'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mailing Subscribe ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'group_id' => [ + 'title' => ts('Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to Group'), + 'input_attrs' => [ + 'label' => ts('Group'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_group', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'Group', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact'), + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'hash' => [ + 'title' => ts('Mailing Subscribe Hash'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Security hash'), + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'time_stamp' => [ + 'title' => ts('Mailing Subscribe Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('When this subscription event occurred.'), + 'default' => 'CURRENT_TIMESTAMP', + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventTrackableURLOpen.entityType.php b/schema/Mailing/Event/MailingEventTrackableURLOpen.entityType.php new file mode 100644 index 000000000000..c8b28022e86b --- /dev/null +++ b/schema/Mailing/Event/MailingEventTrackableURLOpen.entityType.php @@ -0,0 +1,66 @@ + 'MailingEventTrackableURLOpen', + 'table' => 'civicrm_mailing_event_trackable_url_open', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventTrackableURLOpen', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Link Clickthrough'), + 'title_plural' => ts('Mailing Link Clickthroughs'), + 'description' => ts('Tracks when a TrackableURL is clicked by a recipient.'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Trackable URL Open ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'event_queue_id' => [ + 'title' => ts('Event Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to EventQueue'), + 'input_attrs' => [ + 'label' => ts('Recipient'), + ], + 'entity_reference' => [ + 'entity' => 'MailingEventQueue', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'trackable_url_id' => [ + 'title' => ts('Trackable Url ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to TrackableURL'), + 'input_attrs' => [ + 'label' => ts('Mailing Link'), + ], + 'entity_reference' => [ + 'entity' => 'MailingTrackableURL', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'time_stamp' => [ + 'title' => ts('Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => 'Date', + 'required' => TRUE, + 'description' => ts('When this trackable URL open occurred.'), + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'label' => ts('Opened Date'), + ], + ], + ], +]; diff --git a/schema/Mailing/Event/MailingEventUnsubscribe.entityType.php b/schema/Mailing/Event/MailingEventUnsubscribe.entityType.php new file mode 100644 index 000000000000..b43a4018bf84 --- /dev/null +++ b/schema/Mailing/Event/MailingEventUnsubscribe.entityType.php @@ -0,0 +1,55 @@ + 'MailingEventUnsubscribe', + 'table' => 'civicrm_mailing_event_unsubscribe', + 'class' => 'CRM_Mailing_Event_DAO_MailingEventUnsubscribe', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Unsubscribe'), + 'title_plural' => ts('Mailing Unsubscribes'), + 'description' => ts('Tracks when a recipient unsubscribes from a group/domain'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Unsubscribe ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'event_queue_id' => [ + 'title' => ts('Event Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to EventQueue'), + 'input_attrs' => [ + 'label' => ts('Recipient'), + ], + 'entity_reference' => [ + 'entity' => 'MailingEventQueue', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'org_unsubscribe' => [ + 'title' => ts('Unsubscribe is for Organization?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Unsubscribe at org- or group-level'), + ], + 'time_stamp' => [ + 'title' => ts('Unsubscribe Timestamp'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('When this delivery event occurred.'), + 'default' => 'CURRENT_TIMESTAMP', + ], + ], +]; diff --git a/schema/Mailing/Mailing.entityType.php b/schema/Mailing/Mailing.entityType.php new file mode 100644 index 000000000000..9129ca662fe0 --- /dev/null +++ b/schema/Mailing/Mailing.entityType.php @@ -0,0 +1,566 @@ + 'Mailing', + 'table' => 'civicrm_mailing', + 'class' => 'CRM_Mailing_DAO_Mailing', + 'getInfo' => fn() => [ + 'title' => ts('Mailing'), + 'title_plural' => ts('Mailings'), + 'description' => ts('Mass emails sent from CiviMail.'), + 'icon' => 'fa-envelope-o', + 'label_field' => 'name', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/mailing/send', + 'update' => 'civicrm/mailing/send?mid=[id]&continue=true', + 'copy' => 'civicrm/mailing/send?mid=[id]', + 'view' => 'civicrm/mailing/report?mid=[id]&reset=1', + 'preview' => 'civicrm/mailing/view?id=[id]&reset=1', + 'delete' => 'civicrm/mailing/browse?action=delete&mid=[id]&reset=1', + ], + 'getIndices' => fn() => [ + 'index_hash' => [ + 'fields' => [ + 'hash' => TRUE, + ], + 'add' => '4.5', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mailing ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Which site is this mailing for'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'header_id' => [ + 'title' => ts('Header ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to the header component.'), + 'input_attrs' => [ + 'label' => ts('Header'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_mailing_component', + 'key_column' => 'id', + 'label_column' => 'name', + 'condition' => 'component_type = "Header"', + ], + 'entity_reference' => [ + 'entity' => 'MailingComponent', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'footer_id' => [ + 'title' => ts('Footer ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to the footer component.'), + 'input_attrs' => [ + 'label' => ts('Footer'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_mailing_component', + 'key_column' => 'id', + 'label_column' => 'name', + 'condition' => 'component_type = "Footer"', + ], + 'entity_reference' => [ + 'entity' => 'MailingComponent', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'reply_id' => [ + 'title' => ts('Reply ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to the auto-responder component.'), + 'input_attrs' => [ + 'label' => ts('Reply'), + ], + 'entity_reference' => [ + 'entity' => 'MailingComponent', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'unsubscribe_id' => [ + 'title' => ts('Unsubscribe ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to the unsubscribe component.'), + 'input_attrs' => [ + 'label' => ts('Unsubscribe'), + ], + 'entity_reference' => [ + 'entity' => 'MailingComponent', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'resubscribe_id' => [ + 'title' => ts('Mailing Resubscribe'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + ], + 'optout_id' => [ + 'title' => ts('Opt Out ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to the opt-out component.'), + 'input_attrs' => [ + 'label' => ts('Opt Out'), + ], + 'entity_reference' => [ + 'entity' => 'MailingComponent', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'name' => [ + 'title' => ts('Mailing Name'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Mailing Name.'), + 'unique_name' => 'mailing_name', + 'input_attrs' => [ + 'label' => ts('Name'), + 'maxlength' => 128, + ], + ], + 'mailing_type' => [ + 'title' => ts('Mailing Type'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Select', + 'description' => ts('differentiate between standalone mailings, A/B tests, and A/B final-winner'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 32, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Mailing_PseudoConstant::mailingTypes', + ], + ], + 'from_name' => [ + 'title' => ts('Mailing From Name'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('From Header of mailing'), + 'input_attrs' => [ + 'label' => ts('From Name'), + 'maxlength' => 128, + ], + ], + 'from_email' => [ + 'title' => ts('Mailing From Email'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('From Email of mailing'), + 'input_attrs' => [ + 'label' => ts('From Email'), + 'maxlength' => 128, + ], + ], + 'replyto_email' => [ + 'title' => ts('Replyto Email'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Reply-To Email of mailing'), + 'input_attrs' => [ + 'label' => ts('Reply-To Email'), + 'maxlength' => 128, + ], + ], + 'template_type' => [ + 'title' => ts('Template Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('The language/processing system used for email templates.'), + 'add' => '4.7', + 'default' => 'traditional', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Mailing_BAO_Mailing::getTemplateTypeNames', + ], + ], + 'template_options' => [ + 'title' => ts('Template Options (JSON)'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Advanced options used by the email templating system. (JSON encoded)'), + 'add' => '4.7', + 'serialize' => CRM_Core_DAO::SERIALIZE_JSON, + ], + 'subject' => [ + 'title' => ts('Subject'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Subject of mailing'), + 'input_attrs' => [ + 'label' => ts('Subject'), + 'maxlength' => 128, + ], + ], + 'body_text' => [ + 'title' => ts('Body Text'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Body of the mailing in text format.'), + 'input_attrs' => [ + 'label' => ts('Body Text'), + ], + ], + 'body_html' => [ + 'title' => ts('Body Html'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Body of the mailing in html format.'), + 'input_attrs' => [ + 'label' => ts('Body HTML'), + ], + ], + 'url_tracking' => [ + 'title' => ts('Url Tracking'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should we track URL click-throughs for this mailing?'), + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Url Tracking'), + ], + ], + 'forward_replies' => [ + 'title' => ts('Forward Replies'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should we forward replies back to the author?'), + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Forward Replies'), + ], + ], + 'auto_responder' => [ + 'title' => ts('Auto Responder'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should we enable the auto-responder?'), + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Auto Responder'), + ], + ], + 'open_tracking' => [ + 'title' => ts('Track Mailing?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should we track when recipients open/read this mailing?'), + 'default' => FALSE, + ], + 'is_completed' => [ + 'title' => ts('Mailing Completed'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Has at least one job associated with this mailing finished?'), + 'default' => FALSE, + ], + 'msg_template_id' => [ + 'title' => ts('Message Template ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to the message template.'), + 'input_attrs' => [ + 'label' => ts('Message Template'), + ], + 'entity_reference' => [ + 'entity' => 'MessageTemplate', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'override_verp' => [ + 'title' => ts('Override Verp'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Overwrite the VERP address in Reply-To'), + 'add' => '2.2', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Overwrite VERP'), + ], + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID who first created this mailing'), + 'input_attrs' => [ + 'label' => ts('Creator'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('Mailing Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('Date and time this mailing was created.'), + 'add' => '3.0', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'label' => ts('Created Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'modified_date' => [ + 'title' => ts('Modified Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'readonly' => TRUE, + 'description' => ts('When the mailing (or closely related entity) was created or modified or deleted.'), + 'add' => '4.7', + 'unique_name' => 'mailing_modified_date', + 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Modified Date'), + ], + ], + 'scheduled_id' => [ + 'title' => ts('Scheduled By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID who scheduled this mailing'), + 'input_attrs' => [ + 'label' => ts('Scheduled By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'scheduled_date' => [ + 'title' => ts('Mailing Scheduled Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('Date and time this mailing was scheduled.'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Scheduled Date'), + 'format_type' => 'activityDateTime', + ], + ], + 'approver_id' => [ + 'title' => ts('Approved By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID who approved this mailing'), + 'input_attrs' => [ + 'label' => ts('Approved By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'approval_date' => [ + 'title' => ts('Mailing Approved Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('Date and time this mailing was approved.'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'approval_status_id' => [ + 'title' => ts('Approval Status'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('The status of this mailing. Values: none, approved, rejected'), + 'add' => '3.3', + 'pseudoconstant' => [ + 'option_group_name' => 'mail_approval_status', + ], + ], + 'approval_note' => [ + 'title' => ts('Approval Note'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Note behind the decision.'), + 'add' => '3.3', + ], + 'is_archived' => [ + 'title' => ts('Is Mailing Archived?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this mailing archived?'), + 'add' => '2.2', + 'default' => FALSE, + ], + 'visibility' => [ + 'title' => ts('Mailing Visibility'), + 'sql_type' => 'varchar(40)', + 'input_type' => 'Select', + 'description' => ts('In what context(s) is the mailing contents visible (online viewing)'), + 'add' => '3.3', + 'default' => 'Public Pages', + 'input_attrs' => [ + 'label' => ts('Visibility'), + 'maxlength' => 40, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::groupVisibility', + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The campaign for which this mailing has been initiated.'), + 'add' => '3.4', + 'component' => 'CiviCampaign', + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'dedupe_email' => [ + 'title' => ts('No Duplicate emails?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Remove duplicate emails?'), + 'add' => '4.1', + 'default' => FALSE, + ], + 'sms_provider_id' => [ + 'title' => ts('SMS Provider ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'add' => '4.2', + 'input_attrs' => [ + 'label' => ts('SMS Provider'), + ], + 'entity_reference' => [ + 'entity' => 'SmsProvider', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'hash' => [ + 'title' => ts('Mailing Hash'), + 'sql_type' => 'varchar(16)', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Key for validating requests related to this mailing.'), + 'add' => '4.5', + 'input_attrs' => [ + 'maxlength' => 16, + ], + ], + 'location_type_id' => [ + 'title' => ts('Location Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('With email_selection_method, determines which email address to use'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Location Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_location_type', + 'key_column' => 'id', + 'label_column' => 'display_name', + ], + 'entity_reference' => [ + 'entity' => 'LocationType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'email_selection_method' => [ + 'title' => ts('Email Selection Method'), + 'sql_type' => 'varchar(20)', + 'input_type' => 'Select', + 'description' => ts('With location_type_id, determine how to choose the email address to use.'), + 'add' => '4.6', + 'default' => 'automatic', + 'input_attrs' => [ + 'label' => ts('Email Selection Method'), + 'maxlength' => 20, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::emailSelectMethods', + ], + ], + 'language' => [ + 'title' => ts('Mailing Language'), + 'sql_type' => 'varchar(5)', + 'input_type' => 'Select', + 'description' => ts('Language of the content of the mailing. Useful for tokens.'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 5, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'languages', + 'key_column' => 'name', + ], + ], + ], +]; diff --git a/schema/Mailing/MailingAB.entityType.php b/schema/Mailing/MailingAB.entityType.php new file mode 100644 index 000000000000..29e942a575af --- /dev/null +++ b/schema/Mailing/MailingAB.entityType.php @@ -0,0 +1,147 @@ + 'MailingAB', + 'table' => 'civicrm_mailing_abtest', + 'class' => 'CRM_Mailing_DAO_MailingAB', + 'getInfo' => fn() => [ + 'title' => ts('Mailingab'), + 'title_plural' => ts('Mailingabs'), + 'description' => ts('Stores information about abtesting'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('MailingAB ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Name of the A/B test'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'status' => [ + 'title' => ts('Status'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Select', + 'description' => ts('Status'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 32, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Mailing_PseudoConstant::abStatus', + ], + ], + 'mailing_id_a' => [ + 'title' => ts('Mailing ID (A)'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('The first experimental mailing ("A" condition)'), + 'add' => '4.6', + ], + 'mailing_id_b' => [ + 'title' => ts('Mailing ID (B)'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('The second experimental mailing ("B" condition)'), + 'add' => '4.6', + ], + 'mailing_id_c' => [ + 'title' => ts('Mailing ID (C)'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('The final, general mailing (derived from A or B)'), + 'add' => '4.6', + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Which site is this mailing for'), + 'add' => '4.6', + ], + 'testing_criteria' => [ + 'title' => ts('Testing Criteria'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Select', + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 32, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Mailing_PseudoConstant::abTestCriteria', + ], + ], + 'winner_criteria' => [ + 'title' => ts('Winner Criteria'), + 'sql_type' => 'varchar(32)', + 'input_type' => 'Select', + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 32, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Mailing_PseudoConstant::abWinnerCriteria', + ], + ], + 'specific_url' => [ + 'title' => ts('URL for Winner Criteria'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('What specific url to track'), + 'add' => '4.6', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'declare_winning_time' => [ + 'title' => ts('Declaration Time'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('In how much time to declare winner'), + 'add' => '4.6', + ], + 'group_percentage' => [ + 'title' => ts('Group Percentage'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'add' => '4.6', + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Contact ID'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'created_date' => [ + 'title' => ts('AB Test Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('When was this item created'), + 'add' => '4.6', + 'default' => 'CURRENT_TIMESTAMP', + 'input_attrs' => [ + 'format_type' => 'mailing', + ], + ], + ], +]; diff --git a/schema/Mailing/MailingComponent.entityType.php b/schema/Mailing/MailingComponent.entityType.php new file mode 100644 index 000000000000..05bc11aad9a1 --- /dev/null +++ b/schema/Mailing/MailingComponent.entityType.php @@ -0,0 +1,100 @@ + 'MailingComponent', + 'table' => 'civicrm_mailing_component', + 'class' => 'CRM_Mailing_DAO_MailingComponent', + 'getInfo' => fn() => [ + 'title' => ts('Mailingcomponent'), + 'title_plural' => ts('Mailingcomponents'), + 'description' => ts('Stores information about the mailing components (header/footer).'), + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/component/edit?action=add&reset=1', + 'update' => 'civicrm/admin/component/edit?action=update&id=[id]&reset=1', + 'browse' => 'civicrm/admin/component?action=browse&id=[id]&reset=1', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mailing Component ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Component Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('The name of this component'), + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'component_type' => [ + 'title' => ts('Mailing Component Type'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Select', + 'description' => ts('Type of Component.'), + 'input_attrs' => [ + 'maxlength' => 12, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::mailingComponents', + ], + ], + 'subject' => [ + 'title' => ts('Subject'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'input_attrs' => [ + 'label' => ts('Subject'), + 'maxlength' => 255, + ], + ], + 'body_html' => [ + 'title' => ts('Mailing Component Body HTML'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Body of the component in html format.'), + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 80, + ], + ], + 'body_text' => [ + 'title' => ts('Body Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('Body of the component in text format.'), + 'input_attrs' => [ + 'rows' => 8, + 'cols' => 80, + 'label' => ts('Body in Text Format'), + ], + ], + 'is_default' => [ + 'title' => ts('Mailing Component is Default?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this the default component for this component_type?'), + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'is_active' => [ + 'title' => ts('Mailing Component Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this property active?'), + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Mailing/MailingGroup.entityType.php b/schema/Mailing/MailingGroup.entityType.php new file mode 100644 index 000000000000..3cb6482fce65 --- /dev/null +++ b/schema/Mailing/MailingGroup.entityType.php @@ -0,0 +1,85 @@ + 'MailingGroup', + 'table' => 'civicrm_mailing_group', + 'class' => 'CRM_Mailing_DAO_MailingGroup', + 'getInfo' => fn() => [ + 'title' => ts('Mailinggroup'), + 'title_plural' => ts('Mailinggroups'), + 'description' => ts('Stores information about the groups that participate in this mailing..'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mailing Group ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'mailing_id' => [ + 'title' => ts('Mailing ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('The ID of a previous mailing to include/exclude recipients.'), + 'input_attrs' => [ + 'label' => ts('Mailing'), + ], + 'entity_reference' => [ + 'entity' => 'Mailing', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'group_type' => [ + 'title' => ts('Mailing Group Type'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Are the members of the group included or excluded?.'), + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getMailingGroupTypes', + ], + ], + 'entity_table' => [ + 'title' => ts('Mailing Group Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Name of table where item being referenced is stored.'), + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Mailing_BAO_Mailing::mailingGroupEntityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('Mailing Group Entity'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to the referenced item.'), + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'search_id' => [ + 'title' => ts('Mailing Group Search'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('The filtering search. custom search id or -1 for civicrm api search'), + ], + 'search_args' => [ + 'title' => ts('Mailing Group Search Arguments'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('The arguments to be sent to the search function'), + ], + ], +]; diff --git a/schema/Mailing/MailingJob.entityType.php b/schema/Mailing/MailingJob.entityType.php new file mode 100644 index 000000000000..2d2cf0bb4f57 --- /dev/null +++ b/schema/Mailing/MailingJob.entityType.php @@ -0,0 +1,143 @@ + 'MailingJob', + 'table' => 'civicrm_mailing_job', + 'class' => 'CRM_Mailing_DAO_MailingJob', + 'getInfo' => fn() => [ + 'title' => ts('Outbound Mailing'), + 'title_plural' => ts('Outbound Mailings'), + 'description' => ts('Attempted delivery of a mailing.'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mailing Job ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'mailing_id' => [ + 'title' => ts('Mailing ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('The ID of the mailing this Job will send.'), + 'input_attrs' => [ + 'label' => ts('Mailing'), + ], + 'entity_reference' => [ + 'entity' => 'Mailing', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'scheduled_date' => [ + 'title' => ts('Mailing Scheduled Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('date on which this job was scheduled.'), + 'default' => NULL, + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'start_date' => [ + 'title' => ts('Mailing Job Start Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('date on which this job was started.'), + 'unique_name' => 'mailing_job_start_date', + 'unique_title' => 'Mailing Start Date', + 'default' => NULL, + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'end_date' => [ + 'title' => ts('Mailing Job End Date'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('date on which this job ended.'), + 'default' => NULL, + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'status' => [ + 'title' => ts('Mailing Job Status'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Select', + 'description' => ts('The state of this job'), + 'unique_name' => 'mailing_job_status', + 'input_attrs' => [ + 'label' => ts('Status'), + 'maxlength' => 12, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::getMailingJobStatus', + ], + ], + 'is_test' => [ + 'title' => ts('Mailing Job Is Test?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this job for a test mail?'), + 'add' => '1.9', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Test Mailing'), + ], + ], + 'job_type' => [ + 'title' => ts('Mailing Job Type'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Type of mailling job: null | child'), + 'add' => '3.3', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'parent_id' => [ + 'title' => ts('Parent ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Parent job id'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Parent'), + ], + 'entity_reference' => [ + 'entity' => 'MailingJob', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'job_offset' => [ + 'title' => ts('Mailing Job Offset'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Offset of the child job'), + 'add' => '3.3', + 'default' => 0, + ], + 'job_limit' => [ + 'title' => ts('Mailing Job Limit'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Queue size limit for each child job'), + 'add' => '3.3', + 'default' => 0, + 'input_attrs' => [ + 'label' => ts('Batch Limit'), + ], + ], + ], +]; diff --git a/schema/Mailing/MailingRecipients.entityType.php b/schema/Mailing/MailingRecipients.entityType.php new file mode 100644 index 000000000000..5f9cd4c65099 --- /dev/null +++ b/schema/Mailing/MailingRecipients.entityType.php @@ -0,0 +1,82 @@ + 'MailingRecipients', + 'table' => 'civicrm_mailing_recipients', + 'class' => 'CRM_Mailing_DAO_MailingRecipients', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Recipient'), + 'title_plural' => ts('Mailing Recipients'), + 'description' => ts('Stores information about the recipients of a mailing.'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Mailing Recipients ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'mailing_id' => [ + 'title' => ts('Mailing ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('The ID of the mailing this Job will send.'), + 'input_attrs' => [ + 'label' => ts('Mailing'), + ], + 'entity_reference' => [ + 'entity' => 'Mailing', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contact_id' => [ + 'title' => ts('Recipient ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact'), + 'input_attrs' => [ + 'label' => ts('Recipient'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'email_id' => [ + 'title' => ts('Email ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Email'), + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Email'), + ], + 'entity_reference' => [ + 'entity' => 'Email', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'phone_id' => [ + 'title' => ts('Phone ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Phone'), + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Phone'), + ], + 'entity_reference' => [ + 'entity' => 'Phone', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Mailing/MailingTrackableURL.entityType.php b/schema/Mailing/MailingTrackableURL.entityType.php new file mode 100644 index 000000000000..71cf7b15db00 --- /dev/null +++ b/schema/Mailing/MailingTrackableURL.entityType.php @@ -0,0 +1,44 @@ + 'MailingTrackableURL', + 'table' => 'civicrm_mailing_trackable_url', + 'class' => 'CRM_Mailing_DAO_MailingTrackableURL', + 'getInfo' => fn() => [ + 'title' => ts('Mailing Link'), + 'title_plural' => ts('Mailing Links'), + 'description' => ts('Stores URLs for which we should track click-throughs from mailings'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Trackable URL ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'url' => [ + 'title' => ts('Url'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('The URL to be tracked.'), + ], + 'mailing_id' => [ + 'title' => ts('Mailing ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to the mailing'), + 'input_attrs' => [ + 'label' => ts('Mailing'), + ], + 'entity_reference' => [ + 'entity' => 'Mailing', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Mailing/Spool.entityType.php b/schema/Mailing/Spool.entityType.php new file mode 100644 index 000000000000..51dcda757bba --- /dev/null +++ b/schema/Mailing/Spool.entityType.php @@ -0,0 +1,69 @@ + 'Spool', + 'table' => 'civicrm_mailing_spool', + 'class' => 'CRM_Mailing_DAO_Spool', + 'getInfo' => fn() => [ + 'title' => ts('Spool'), + 'title_plural' => ts('Spools'), + 'description' => ts('Stores the outbond mails'), + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Spool ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'job_id' => [ + 'title' => ts('Job ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('The ID of the Job .'), + 'input_attrs' => [ + 'label' => ts('Job'), + ], + 'entity_reference' => [ + 'entity' => 'MailingJob', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'recipient_email' => [ + 'title' => ts('Recipient Email'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('The email of the recipients this mail is to be sent.'), + ], + 'headers' => [ + 'title' => ts('Headers'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('The header information of this mailing .'), + ], + 'body' => [ + 'title' => ts('Body'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('The body of this mailing.'), + ], + 'added_at' => [ + 'title' => ts('Added'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('date on which this job was added.'), + 'default' => NULL, + ], + 'removed_at' => [ + 'title' => ts('Removed'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => ts('date on which this job was removed.'), + 'default' => NULL, + ], + ], +]; diff --git a/schema/Member/Membership.entityType.php b/schema/Member/Membership.entityType.php new file mode 100644 index 000000000000..26661652e686 --- /dev/null +++ b/schema/Member/Membership.entityType.php @@ -0,0 +1,318 @@ + 'Membership', + 'table' => 'civicrm_membership', + 'class' => 'CRM_Member_DAO_Membership', + 'getInfo' => fn() => [ + 'title' => ts('Membership'), + 'title_plural' => ts('Memberships'), + 'description' => 'Records of contacts belonging to an organization\'s membership program.', + 'log' => TRUE, + 'add' => '1.5', + 'icon' => 'fa-id-badge', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/member/add?reset=1&action=add&context=standalone', + 'view' => 'civicrm/contact/view/membership?reset=1&action=view&id=[id]&cid=[contact_id]', + 'update' => 'civicrm/contact/view/membership?reset=1&action=update&id=[id]&cid=[contact_id]', + 'delete' => 'civicrm/contact/view/membership?reset=1&action=delete&id=[id]&cid=[contact_id]', + ], + 'getIndices' => fn() => [ + 'index_owner_membership_id' => [ + 'fields' => [ + 'owner_membership_id' => TRUE, + ], + 'add' => '1.7', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Membership ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Membership ID'), + 'add' => '1.5', + 'unique_name' => 'membership_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact ID'), + 'add' => '1.5', + 'unique_name' => 'membership_contact_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'membership_type_id' => [ + 'title' => ts('Membership Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to Membership Type'), + 'add' => '1.5', + 'usage' => [ + 'import', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Membership Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_membership_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'MembershipType', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'join_date' => [ + 'title' => ts('Member Since'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Beginning of initial membership period (member since...).'), + 'add' => '1.5', + 'unique_name' => 'membership_join_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'start_date' => [ + 'title' => ts('Membership Start Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Beginning of current uninterrupted membership period.'), + 'add' => '1.5', + 'unique_name' => 'membership_start_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'end_date' => [ + 'title' => ts('Membership Expiration Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Current membership period expire date.'), + 'add' => '1.5', + 'unique_name' => 'membership_end_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'source' => [ + 'title' => ts('Membership Source'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'add' => '1.5', + 'unique_name' => 'membership_source', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'status_id' => [ + 'title' => ts('Status ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to Membership Status'), + 'add' => '1.5', + 'usage' => [ + 'import', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Status'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_membership_status', + 'key_column' => 'id', + 'label_column' => 'label', + ], + 'entity_reference' => [ + 'entity' => 'MembershipStatus', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'is_override' => [ + 'title' => ts('Status Override'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Admin users may set a manual status which overrides the calculated status. When this flag is TRUE, automated status update scripts should NOT modify status for the record.'), + 'add' => '1.5', + 'unique_name' => 'member_is_override', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'status_override_end_date' => [ + 'title' => ts('Status Override End Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => 'Then end date of membership status override if \'Override until selected date\' override type is selected.', + 'add' => '4.7', + 'default' => NULL, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'owner_membership_id' => [ + 'title' => ts('Primary Member ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Optional FK to Parent Membership.'), + 'add' => '1.7', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Primary Member'), + ], + 'entity_reference' => [ + 'entity' => 'Membership', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'max_related' => [ + 'title' => ts('Max Related'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'description' => ts('Maximum number of related memberships (membership_type override).'), + 'add' => '4.3', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Maximum number of related memberships'), + ], + ], + 'is_test' => [ + 'title' => ts('Test'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'unique_name' => 'member_is_test', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'is_pay_later' => [ + 'title' => ts('Is Pay Later'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '2.1', + 'unique_name' => 'member_is_pay_later', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'contribution_recur_id' => [ + 'title' => ts('Recurring Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.'), + 'add' => '3.3', + 'unique_name' => 'membership_recur_id', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'label' => ts('Recurring Contribution'), + ], + 'entity_reference' => [ + 'entity' => 'ContributionRecur', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The campaign for which this membership is attached.'), + 'add' => '3.4', + 'unique_name' => 'member_campaign_id', + 'component' => 'CiviCampaign', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Member/MembershipBlock.entityType.php b/schema/Member/MembershipBlock.entityType.php new file mode 100644 index 000000000000..ef09c166fc83 --- /dev/null +++ b/schema/Member/MembershipBlock.entityType.php @@ -0,0 +1,153 @@ + 'MembershipBlock', + 'table' => 'civicrm_membership_block', + 'class' => 'CRM_Member_DAO_MembershipBlock', + 'getInfo' => fn() => [ + 'title' => ts('Membershipblock'), + 'title_plural' => ts('Membershipblocks'), + 'description' => ts('A Membership Block stores admin configurable status options and rules'), + 'log' => TRUE, + 'add' => '1.5', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Membership Block ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Membership ID'), + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Membership Block Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Name for Membership Status'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to civicrm_contribution_page.id'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Entity'), + ], + 'entity_reference' => [ + 'entity' => 'ContributionPage', + 'key' => 'id', + ], + ], + 'membership_types' => [ + 'title' => ts('Membership Block Membership Types'), + 'sql_type' => 'varchar(1024)', + 'input_type' => 'Text', + 'description' => ts('Membership types to be exposed by this block'), + 'add' => '1.5', + 'serialize' => CRM_Core_DAO::SERIALIZE_PHP, + 'input_attrs' => [ + 'maxlength' => 1024, + ], + ], + 'membership_type_default' => [ + 'title' => ts('Default Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Optional foreign key to membership_type'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Default Type'), + ], + 'entity_reference' => [ + 'entity' => 'MembershipType', + 'key' => 'id', + ], + ], + 'display_min_fee' => [ + 'title' => ts('Membership Block Display Minimum Fee'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Display minimum membership fee'), + 'add' => '1.5', + 'default' => TRUE, + ], + 'is_separate_payment' => [ + 'title' => ts('Membership Block Is Separate Payment'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should membership transactions be processed separately'), + 'add' => '1.5', + 'default' => TRUE, + ], + 'new_title' => [ + 'title' => ts('Membership Block New Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Title to display at top of block'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'new_text' => [ + 'title' => ts('Membership Block New Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Text to display below title'), + 'add' => '1.5', + ], + 'renewal_title' => [ + 'title' => ts('Membership Block Renewal Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Title for renewal'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'renewal_text' => [ + 'title' => ts('Membership Block Renewal Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Text to display for member renewal'), + 'add' => '1.5', + ], + 'is_required' => [ + 'title' => ts('Is Required'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is membership sign up optional'), + 'add' => '1.5', + 'default' => FALSE, + ], + 'is_active' => [ + 'title' => ts('Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this membership_block enabled'), + 'add' => '1.5', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/Member/MembershipLog.entityType.php b/schema/Member/MembershipLog.entityType.php new file mode 100644 index 000000000000..3a921e68e474 --- /dev/null +++ b/schema/Member/MembershipLog.entityType.php @@ -0,0 +1,116 @@ + 'MembershipLog', + 'table' => 'civicrm_membership_log', + 'class' => 'CRM_Member_DAO_MembershipLog', + 'getInfo' => fn() => [ + 'title' => ts('Membershiplog'), + 'title_plural' => ts('Membershiplogs'), + 'description' => ts('Logs actions which affect a Membership record (signup, status override, renewal, etc.)'), + 'log' => TRUE, + 'add' => '1.5', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Membership Log ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'membership_id' => [ + 'title' => ts('Membership ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Membership table'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Membership'), + ], + 'entity_reference' => [ + 'entity' => 'Membership', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'status_id' => [ + 'title' => ts('Membership Status ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('New status assigned to membership by this action. FK to Membership Status'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Membership Status'), + ], + 'entity_reference' => [ + 'entity' => 'MembershipStatus', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'start_date' => [ + 'title' => ts('Membership Log Start Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('New membership period start date'), + 'add' => '1.5', + ], + 'end_date' => [ + 'title' => ts('Membership Log End Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('New membership period expiration date.'), + 'add' => '1.5', + ], + 'modified_id' => [ + 'title' => ts('Modified By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('FK to Contact ID of person under whose credentials this data modification was made.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Modified By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'modified_date' => [ + 'title' => ts('Membership Change Date'), + 'sql_type' => 'date', + 'input_type' => 'Select Date', + 'description' => ts('Date this membership modification action was logged.'), + 'add' => '1.5', + ], + 'membership_type_id' => [ + 'title' => ts('Membership Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Membership Type.'), + 'add' => '3.4', + 'input_attrs' => [ + 'label' => ts('Membership Type'), + ], + 'entity_reference' => [ + 'entity' => 'MembershipType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'max_related' => [ + 'title' => ts('Maximum Related Memberships'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Maximum number of related memberships.'), + 'add' => '4.3', + ], + ], +]; diff --git a/schema/Member/MembershipPayment.entityType.php b/schema/Member/MembershipPayment.entityType.php new file mode 100644 index 000000000000..bc7259f12a79 --- /dev/null +++ b/schema/Member/MembershipPayment.entityType.php @@ -0,0 +1,66 @@ + 'MembershipPayment', + 'table' => 'civicrm_membership_payment', + 'class' => 'CRM_Member_DAO_MembershipPayment', + 'getInfo' => fn() => [ + 'title' => ts('Membershippayment'), + 'title_plural' => ts('Membershippayments'), + 'description' => ts('Membership Payment'), + 'log' => TRUE, + 'add' => '1.5', + ], + 'getIndices' => fn() => [ + 'UI_contribution_membership' => [ + 'fields' => [ + 'contribution_id' => TRUE, + 'membership_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '2.0', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Membership Payment ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'membership_id' => [ + 'title' => ts('Membership ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Membership table'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Membership'), + ], + 'entity_reference' => [ + 'entity' => 'Membership', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contribution_id' => [ + 'title' => ts('Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to contribution table.'), + 'add' => '2.0', + 'input_attrs' => [ + 'label' => ts('Contribution'), + ], + 'entity_reference' => [ + 'entity' => 'Contribution', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + ], +]; diff --git a/schema/Member/MembershipStatus.entityType.php b/schema/Member/MembershipStatus.entityType.php new file mode 100644 index 000000000000..3325e315c37a --- /dev/null +++ b/schema/Member/MembershipStatus.entityType.php @@ -0,0 +1,193 @@ + 'MembershipStatus', + 'table' => 'civicrm_membership_status', + 'class' => 'CRM_Member_DAO_MembershipStatus', + 'getInfo' => fn() => [ + 'title' => ts('Membershipstatus'), + 'title_plural' => ts('Membershipstatuses'), + 'description' => ts('Membership Status stores admin configurable rules for assigning status to memberships.'), + 'log' => TRUE, + 'add' => '1.5', + 'label_field' => 'label', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/member/membershipStatus?action=add&reset=1', + 'update' => 'civicrm/admin/member/membershipStatus?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/member/membershipStatus?action=delete&id=[id]&reset=1', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Membership Status ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Membership ID'), + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Membership Status'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name for Membership Status'), + 'add' => '1.5', + 'unique_name' => 'membership_status', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'label' => [ + 'title' => ts('Label'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Label for Membership Status'), + 'add' => '3.2', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'start_event' => [ + 'title' => ts('Start Event'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Select', + 'description' => ts('Event when this status starts.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Start Event'), + 'maxlength' => 12, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::eventDate', + ], + ], + 'start_event_adjust_unit' => [ + 'title' => ts('Start Event Adjust Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Unit used for adjusting from start_event.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Start Event Adjust Unit'), + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::unitList', + ], + ], + 'start_event_adjust_interval' => [ + 'title' => ts('Start Event Adjust Interval'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Status range begins this many units from start_event.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Start Event Adjust Interval'), + ], + ], + 'end_event' => [ + 'title' => ts('End Event'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Select', + 'description' => ts('Event after which this status ends.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('End Event'), + 'maxlength' => 12, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::eventDate', + ], + ], + 'end_event_adjust_unit' => [ + 'title' => ts('End Event Adjust Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'description' => ts('Unit used for adjusting from the ending event.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('End Event Adjust Unit'), + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::unitList', + ], + ], + 'end_event_adjust_interval' => [ + 'title' => ts('End Event Adjust Interval'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('Status range ends this many units from end_event.'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('End Event Adjust Interval'), + ], + ], + 'is_current_member' => [ + 'title' => ts('Current Membership?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).'), + 'add' => '1.5', + 'default' => FALSE, + ], + 'is_admin' => [ + 'title' => ts('Administrator Only?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this status for admin/manual assignment only.'), + 'add' => '1.5', + 'default' => FALSE, + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'add' => '1.5', + ], + 'is_default' => [ + 'title' => ts('Default Status?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Assign this status to a membership record if no other status match is found.'), + 'add' => '1.5', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'is_active' => [ + 'title' => ts('Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this membership_status enabled.'), + 'add' => '1.5', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_reserved' => [ + 'title' => ts('Is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this membership_status reserved.'), + 'add' => '2.1', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Member/MembershipType.entityType.php b/schema/Member/MembershipType.entityType.php new file mode 100644 index 000000000000..a33053724a97 --- /dev/null +++ b/schema/Member/MembershipType.entityType.php @@ -0,0 +1,289 @@ + 'MembershipType', + 'table' => 'civicrm_membership_type', + 'class' => 'CRM_Member_DAO_MembershipType', + 'getInfo' => fn() => [ + 'title' => ts('Membershiptype'), + 'title_plural' => ts('Membershiptypes'), + 'description' => ts('Sites can configure multiple types of memberships. They encode the owner organization, fee, and the rules needed to set start and end (expire) dates when a member signs up for that type.'), + 'log' => TRUE, + 'add' => '1.5', + 'label_field' => 'name', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/member/membershipType/add?action=add&reset=1', + 'update' => 'civicrm/admin/member/membershipType/add?action=update&id=[id]&reset=1', + 'delete' => 'civicrm/admin/member/membershipType/add?action=delete&id=[id]&reset=1', + ], + 'getIndices' => fn() => [ + 'index_relationship_type_id' => [ + 'fields' => [ + 'relationship_type_id' => TRUE, + ], + 'add' => '3.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Membership Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Membership ID'), + 'add' => '1.5', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Which Domain is this match entry for'), + 'add' => '3.0', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'name' => [ + 'title' => ts('Membership Type'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Name of Membership Type'), + 'add' => '1.5', + 'unique_name' => 'membership_type', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Name'), + 'maxlength' => 128, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description of Membership Type'), + 'add' => '1.5', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + 'label' => ts('Description'), + 'maxlength' => 255, + ], + ], + 'member_of_contact_id' => [ + 'title' => ts('Organization ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Owner organization for this membership type. FK to Contact ID'), + 'add' => '1.5', + 'input_attrs' => [ + 'label' => ts('Organization'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'RESTRICT', + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + ], + ], + 'minimum_fee' => [ + 'title' => ts('Minimum Fee'), + 'sql_type' => 'decimal(18,9)', + 'input_type' => 'Text', + 'description' => ts('Minimum fee for this membership (0 for free/complimentary memberships).'), + 'add' => '1.5', + 'default' => '0', + 'input_attrs' => [ + 'label' => ts('Minimum Fee'), + 'maxlength' => 18, + ], + ], + 'duration_unit' => [ + 'title' => ts('Membership Type Duration Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Unit in which membership period is expressed.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::membershipTypeUnitList', + ], + ], + 'duration_interval' => [ + 'title' => ts('Membership Type Duration Interval'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'description' => ts('Number of duration units in membership period (e.g. 1 year, 12 months).'), + 'add' => '1.5', + ], + 'period_type' => [ + 'title' => ts('Membership Type Plan'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.'), + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::periodType', + ], + ], + 'fixed_period_start_day' => [ + 'title' => ts('Fixed Period Start Day'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('For fixed period memberships, month and day (mmdd) on which subscription/membership will start. Period start is back-dated unless after rollover day.'), + 'add' => '1.5', + ], + 'fixed_period_rollover_day' => [ + 'title' => ts('Fixed Period Rollover Day'), + 'sql_type' => 'int', + 'input_type' => 'Number', + 'description' => ts('For fixed period memberships, signups after this day (mmdd) rollover to next period.'), + 'add' => '1.5', + ], + 'relationship_type_id' => [ + 'title' => ts('Membership Type Relationship'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('FK to Relationship Type ID'), + 'add' => '1.5', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'relationship_direction' => [ + 'title' => ts('Relationship Direction'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'add' => '1.7', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'label' => ts('Relationship Direction'), + 'maxlength' => 128, + ], + ], + 'max_related' => [ + 'title' => ts('Max Related Members for Type'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'description' => ts('Maximum number of related memberships.'), + 'add' => '4.3', + 'input_attrs' => [ + 'label' => ts('Max Related'), + ], + ], + 'visibility' => [ + 'title' => ts('Visible'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'add' => '1.5', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::memberVisibility', + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'add' => '1.5', + ], + 'receipt_text_signup' => [ + 'title' => ts('Membership Type Receipt Text'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'TextArea', + 'description' => ts('Receipt Text for membership signup'), + 'add' => '2.0', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + 'maxlength' => 255, + ], + ], + 'receipt_text_renewal' => [ + 'title' => ts('Membership Type Renewal Text'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'TextArea', + 'description' => ts('Receipt Text for membership renewal'), + 'add' => '2.0', + 'input_attrs' => [ + 'rows' => 6, + 'cols' => 50, + 'maxlength' => 255, + ], + ], + 'auto_renew' => [ + 'title' => ts('Auto Renew'), + 'sql_type' => 'tinyint', + 'input_type' => 'Radio', + 'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'), + 'add' => '3.3', + 'default' => 0, + 'input_attrs' => [ + 'label' => ts('Auto-Renew'), + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Core_SelectValues::memberAutoRenew', + ], + ], + 'is_active' => [ + 'title' => ts('Is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'description' => ts('Is this membership_type enabled'), + 'add' => '1.5', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + ], +]; diff --git a/schema/PCP/PCP.entityType.php b/schema/PCP/PCP.entityType.php new file mode 100644 index 000000000000..49f7e5b3d5b4 --- /dev/null +++ b/schema/PCP/PCP.entityType.php @@ -0,0 +1,189 @@ + 'PCP', + 'table' => 'civicrm_pcp', + 'class' => 'CRM_PCP_DAO_PCP', + 'getInfo' => fn() => [ + 'title' => ts('Personal Campaign Page'), + 'title_plural' => ts('Personal Campaign Pages'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '2.2', + 'label_field' => 'title', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Personal Campaign Page ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Personal Campaign Page ID'), + 'add' => '2.2', + 'unique_name' => 'pcp_id', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Contact ID'), + 'add' => '2.2', + 'unique_name' => 'pcp_contact_id', + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'status_id' => [ + 'title' => ts('Personal Campaign Page Status'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'add' => '2.2', + 'pseudoconstant' => [ + 'option_group_name' => 'pcp_status', + ], + ], + 'title' => [ + 'title' => ts('Personal Campaign Page Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'intro_text' => [ + 'title' => ts('Intro Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Intro Text'), + ], + ], + 'page_text' => [ + 'title' => ts('Page Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Page Text'), + ], + ], + 'donate_link_text' => [ + 'title' => ts('Donate Link Text'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'page_id' => [ + 'title' => ts('Contribution Page'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('The Contribution or Event Page which triggered this pcp'), + 'add' => '4.1', + 'entity_reference' => [ + 'dynamic_entity' => 'page_type', + 'key' => 'id', + ], + ], + 'page_type' => [ + 'title' => ts('PCP Page Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'description' => ts('The type of PCP this is: contribute or event'), + 'add' => '2.2', + 'default' => 'contribute', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_PCP_BAO_PCP::pageTypeOptions', + ], + ], + 'pcp_block_id' => [ + 'title' => ts('PCP Block'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('The pcp block that this pcp page was created from'), + 'add' => '4.1', + ], + 'is_thermometer' => [ + 'title' => ts('Use Thermometer?'), + 'sql_type' => 'int unsigned', + 'input_type' => 'CheckBox', + 'add' => '2.2', + 'default' => 0, + ], + 'is_honor_roll' => [ + 'title' => ts('Show Honor Roll?'), + 'sql_type' => 'int unsigned', + 'input_type' => 'CheckBox', + 'add' => '2.2', + 'default' => 0, + ], + 'goal_amount' => [ + 'title' => ts('Goal Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'description' => ts('Goal amount of this Personal Campaign Page.'), + 'add' => '2.2', + ], + 'currency' => [ + 'title' => ts('Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '3.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'is_active' => [ + 'title' => ts('Enabled?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is Personal Campaign Page enabled/active?'), + 'add' => '2.2', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_notify' => [ + 'title' => ts('Notify Owner?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Notify owner via email when someone donates to page?'), + 'add' => '4.6', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/PCP/PCPBlock.entityType.php b/schema/PCP/PCPBlock.entityType.php new file mode 100644 index 000000000000..94ad42641afc --- /dev/null +++ b/schema/PCP/PCPBlock.entityType.php @@ -0,0 +1,159 @@ + 'PCPBlock', + 'table' => 'civicrm_pcp_block', + 'class' => 'CRM_PCP_DAO_PCPBlock', + 'getInfo' => fn() => [ + 'title' => ts('Personal Campaign Block'), + 'title_plural' => ts('Personal Campaign Blocks'), + 'description' => ts('A Personal Campaign Page Block stores admin configurable status options and rules'), + 'log' => TRUE, + 'add' => '2.2', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('PCP Block ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('PCP block ID'), + 'add' => '2.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to civicrm_contribution_page.id OR civicrm_event.id'), + 'add' => '2.2', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'target_entity_type' => [ + 'title' => ts('Target Entity'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('The type of entity that this pcp targets'), + 'add' => '4.1', + 'default' => 'contribute', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'target_entity_id' => [ + 'title' => ts('Target Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('The entity that this pcp targets'), + 'add' => '4.1', + 'entity_reference' => [ + 'dynamic_entity' => 'target_entity_type', + 'key' => 'id', + ], + ], + 'supporter_profile_id' => [ + 'title' => ts('Supporter Profile ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_uf_group.id. Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?'), + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Supporter Profile'), + ], + 'entity_reference' => [ + 'entity' => 'UFGroup', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'owner_notify_id' => [ + 'title' => ts('Owner Notification'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Radio', + 'description' => ts('FK to civicrm_option_group with name = PCP owner notifications'), + 'add' => '4.6', + 'default' => 0, + 'pseudoconstant' => [ + 'option_group_name' => 'pcp_owner_notify', + ], + ], + 'is_approval_needed' => [ + 'title' => ts('Approval Required?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?'), + 'add' => '2.2', + 'default' => FALSE, + ], + 'is_tellfriend_enabled' => [ + 'title' => ts('Tell a Friend Enabled?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Does Personal Campaign Page allow using tell a friend?'), + 'add' => '2.2', + 'default' => FALSE, + ], + 'tellfriend_limit' => [ + 'title' => ts('Tell A Friend Limit'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Maximum recipient fields allowed in tell a friend'), + 'add' => '2.2', + 'default' => NULL, + ], + 'link_text' => [ + 'title' => ts('Link Text'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Link text for PCP.'), + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_active' => [ + 'title' => ts('Enabled?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is Personal Campaign Page Block enabled/active?'), + 'add' => '2.2', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'notify_email' => [ + 'title' => ts('Notification Email'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('If set, notification is automatically emailed to this email-address on create/update Personal Campaign Page'), + 'add' => '2.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + ], +]; diff --git a/schema/Pledge/Pledge.entityType.php b/schema/Pledge/Pledge.entityType.php new file mode 100644 index 000000000000..e4efd8e5fd46 --- /dev/null +++ b/schema/Pledge/Pledge.entityType.php @@ -0,0 +1,357 @@ + 'Pledge', + 'table' => 'civicrm_pledge', + 'class' => 'CRM_Pledge_DAO_Pledge', + 'getInfo' => fn() => [ + 'title' => ts('Pledge'), + 'title_plural' => ts('Pledges'), + 'description' => ts('Promises to contribute at a future time, either in full, or at regular intervals until a total goal is reached.'), + 'log' => TRUE, + 'add' => '2.1', + 'icon' => 'fa-paper-plane', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/pledge/add?action=add&context=standalone&reset=1', + 'view' => 'civicrm/contact/view/pledge?id=[id]&cid=[contact_id]&action=view&reset=1', + 'update' => 'civicrm/contact/view/pledge?id=[id]&cid=[contact_id]&action=update&reset=1', + 'delete' => 'civicrm/contact/view/pledge?id=[id]&cid=[contact_id]&action=delete&reset=1', + ], + 'getIndices' => fn() => [ + 'index_status' => [ + 'fields' => [ + 'status_id' => TRUE, + ], + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Pledge ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Pledge ID'), + 'add' => '2.1', + 'unique_name' => 'pledge_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'contact_id' => [ + 'title' => ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Foreign key to civicrm_contact.id .'), + 'add' => '2.1', + 'unique_name' => 'pledge_contact_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Contact'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to Financial Type'), + 'add' => '4.3', + 'unique_name' => 'pledge_financial_type_id', + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + ], + ], + 'contribution_page_id' => [ + 'title' => ts('Contribution Page ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The Contribution Page which triggered this contribution'), + 'add' => '2.1', + 'unique_name' => 'pledge_contribution_page_id', + 'input_attrs' => [ + 'label' => ts('Contribution Page'), + ], + 'entity_reference' => [ + 'entity' => 'ContributionPage', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'amount' => [ + 'title' => ts('Total Pledged'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Total pledged amount.'), + 'add' => '2.1', + 'unique_name' => 'pledge_amount', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'original_installment_amount' => [ + 'title' => ts('Original Installment Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Original amount for each of the installments.'), + 'add' => '3.2', + 'unique_name' => 'pledge_original_installment_amount', + 'usage' => [ + 'export', + ], + ], + 'currency' => [ + 'title' => ts('Pledge Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '3.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'frequency_unit' => [ + 'title' => ts('Pledge Frequency Unit'), + 'sql_type' => 'varchar(8)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Time units for recurrence of pledge payments.'), + 'add' => '2.1', + 'unique_name' => 'pledge_frequency_unit', + 'default' => 'month', + 'input_attrs' => [ + 'maxlength' => 8, + ], + 'pseudoconstant' => [ + 'option_group_name' => 'recur_frequency_units', + 'key_column' => 'name', + ], + ], + 'frequency_interval' => [ + 'title' => ts('Pledge Frequency Interval'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Number of time units for recurrence of pledge payments.'), + 'add' => '2.1', + 'unique_name' => 'pledge_frequency_interval', + 'default' => 1, + ], + 'frequency_day' => [ + 'title' => ts('Pledge day'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Day in the period when the pledge payment is due e.g. 1st of month, 15th etc. Use this to set the scheduled dates for pledge payments.'), + 'add' => '2.1', + 'default' => 3, + ], + 'installments' => [ + 'title' => ts('Pledge Number of Installments'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Total number of payments to be made.'), + 'add' => '2.1', + 'default' => 1, + 'usage' => [ + 'export', + ], + ], + 'start_date' => [ + 'title' => ts('Pledge Start Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'description' => ts('The date the first scheduled pledge occurs.'), + 'add' => '2.1', + 'unique_name' => 'pledge_start_date', + 'unique_title' => 'Payments Start Date', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'create_date' => [ + 'title' => ts('Pledge Made'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'description' => ts('When this pledge record was created.'), + 'add' => '2.1', + 'unique_name' => 'pledge_create_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'acknowledge_date' => [ + 'title' => ts('Pledge Acknowledged'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'), + 'add' => '2.1', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'modified_date' => [ + 'title' => ts('Pledge Modified Date'), + 'sql_type' => 'datetime', + 'input_type' => NULL, + 'readonly' => TRUE, + 'description' => ts('Last updated date for this pledge record.'), + 'add' => '2.1', + ], + 'cancel_date' => [ + 'title' => ts('Pledge Cancelled Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date this pledge was cancelled by contributor.'), + 'add' => '2.1', + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'end_date' => [ + 'title' => ts('Pledge End Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'), + 'add' => '2.1', + 'unique_name' => 'pledge_end_date', + 'unique_title' => 'Payments Ended Date', + 'usage' => [ + 'export', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'max_reminders' => [ + 'title' => ts('Maximum Number of Reminders'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('The maximum number of payment reminders to send for any given payment.'), + 'add' => '2.1', + 'default' => 1, + ], + 'initial_reminder_day' => [ + 'title' => ts('Initial Reminder Day'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('Send initial reminder this many days prior to the payment due date.'), + 'add' => '2.1', + 'default' => 5, + ], + 'additional_reminder_day' => [ + 'title' => ts('Additional Reminder Days'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'), + 'add' => '2.1', + 'default' => 5, + ], + 'status_id' => [ + 'title' => ts('Pledge Status ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'), + 'add' => '2.1', + 'unique_name' => 'pledge_status_id', + 'usage' => [ + 'import', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Status'), + ], + 'pseudoconstant' => [ + 'option_group_name' => 'pledge_status', + ], + ], + 'is_test' => [ + 'title' => ts('Test'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'unique_name' => 'pledge_is_test', + 'default' => FALSE, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'campaign_id' => [ + 'title' => ts('Campaign ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('The campaign for which this pledge has been initiated.'), + 'add' => '3.4', + 'unique_name' => 'pledge_campaign_id', + 'component' => 'CiviCampaign', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Campaign'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_campaign', + 'key_column' => 'id', + 'label_column' => 'title', + 'prefetch' => 'disabled', + ], + 'entity_reference' => [ + 'entity' => 'Campaign', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/schema/Pledge/PledgeBlock.entityType.php b/schema/Pledge/PledgeBlock.entityType.php new file mode 100644 index 000000000000..bce9d7b83021 --- /dev/null +++ b/schema/Pledge/PledgeBlock.entityType.php @@ -0,0 +1,129 @@ + 'PledgeBlock', + 'table' => 'civicrm_pledge_block', + 'class' => 'CRM_Pledge_DAO_PledgeBlock', + 'getInfo' => fn() => [ + 'title' => ts('Pledgeblock'), + 'title_plural' => ts('Pledgeblocks'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '2.1', + ], + 'getIndices' => fn() => [ + 'index_entity' => [ + 'fields' => [ + 'entity_table' => TRUE, + 'entity_id' => TRUE, + ], + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Pledge Block ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Pledge ID'), + 'add' => '2.1', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('physical tablename for entity being joined to pledge, e.g. civicrm_contact'), + 'add' => '2.1', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to entity table specified in entity_table column.'), + 'add' => '2.1', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'pledge_frequency_unit' => [ + 'title' => ts('Pledge Frequency Unit'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'description' => ts('Delimited list of supported frequency units'), + 'add' => '2.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'is_pledge_interval' => [ + 'title' => ts('Expose Frequency Interval?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is frequency interval exposed on the contribution form.'), + 'add' => '2.1', + 'default' => FALSE, + ], + 'max_reminders' => [ + 'title' => ts('Maximum Number of Reminders'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('The maximum number of payment reminders to send for any given payment.'), + 'add' => '2.1', + 'default' => 1, + ], + 'initial_reminder_day' => [ + 'title' => ts('Initial Reminder Day'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Send initial reminder this many days prior to the payment due date.'), + 'add' => '2.1', + 'default' => 5, + ], + 'additional_reminder_day' => [ + 'title' => ts('Additional Reminder Days'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'), + 'add' => '2.1', + 'default' => 5, + ], + 'pledge_start_date' => [ + 'title' => ts('Pledge Start Date'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('The date the first scheduled pledge occurs.'), + 'add' => '4.7', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'is_pledge_start_date_visible' => [ + 'title' => ts('Show Recurring Donation Start Date?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('If true - recurring start date is shown.'), + 'add' => '4.7', + 'default' => FALSE, + ], + 'is_pledge_start_date_editable' => [ + 'title' => ts('Allow Edits to Recurring Donation Start Date?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('If true - recurring start date is editable.'), + 'add' => '4.7', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/Pledge/PledgePayment.entityType.php b/schema/Pledge/PledgePayment.entityType.php new file mode 100644 index 000000000000..091c5b166003 --- /dev/null +++ b/schema/Pledge/PledgePayment.entityType.php @@ -0,0 +1,181 @@ + 'PledgePayment', + 'table' => 'civicrm_pledge_payment', + 'class' => 'CRM_Pledge_DAO_PledgePayment', + 'getInfo' => fn() => [ + 'title' => ts('Pledgepayment'), + 'title_plural' => ts('Pledgepayments'), + 'description' => ts('Pledge Payment'), + 'log' => TRUE, + 'add' => '2.1', + ], + 'getIndices' => fn() => [ + 'index_contribution_pledge' => [ + 'fields' => [ + 'contribution_id' => TRUE, + 'pledge_id' => TRUE, + ], + 'add' => '2.1', + ], + 'index_status' => [ + 'fields' => [ + 'status_id' => TRUE, + ], + 'add' => '2.1', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Payment ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '2.1', + 'unique_name' => 'pledge_payment_id', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'pledge_id' => [ + 'title' => ts('Pledge ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to Pledge table'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Pledge'), + ], + 'entity_reference' => [ + 'entity' => 'Pledge', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'contribution_id' => [ + 'title' => ts('Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to contribution table.'), + 'add' => '2.1', + 'input_attrs' => [ + 'label' => ts('Contribution'), + ], + 'entity_reference' => [ + 'entity' => 'Contribution', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'scheduled_amount' => [ + 'title' => ts('Scheduled Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('Pledged amount for this payment (the actual contribution amount might be different).'), + 'add' => '2.1', + 'unique_name' => 'pledge_payment_scheduled_amount', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'actual_amount' => [ + 'title' => ts('Actual Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'description' => ts('Actual amount that is paid as the Pledged installment amount.'), + 'add' => '3.2', + 'unique_name' => 'pledge_payment_actual_amount', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'currency' => [ + 'title' => ts('Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Select', + 'description' => ts('3 character string, value from config setting or input via user.'), + 'add' => '3.2', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 3, + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_currency', + 'key_column' => 'name', + 'label_column' => 'full_name', + 'name_column' => 'name', + 'abbr_column' => 'symbol', + ], + ], + 'scheduled_date' => [ + 'title' => ts('Scheduled Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'description' => ts('The date the pledge payment is supposed to happen.'), + 'add' => '2.1', + 'unique_name' => 'pledge_payment_scheduled_date', + 'unique_title' => 'Payment Scheduled', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'format_type' => 'activityDate', + ], + ], + 'reminder_date' => [ + 'title' => ts('Last Reminder'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('The date that the most recent payment reminder was sent.'), + 'add' => '2.1', + 'unique_name' => 'pledge_payment_reminder_date', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'reminder_count' => [ + 'title' => ts('Reminders Sent'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('The number of payment reminders sent.'), + 'add' => '2.1', + 'unique_name' => 'pledge_payment_reminder_count', + 'default' => 0, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'status_id' => [ + 'title' => ts('Payment Status'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'add' => '2.1', + 'unique_name' => 'pledge_payment_status_id', + 'usage' => [ + 'import', + 'duplicate_matching', + ], + 'pseudoconstant' => [ + 'option_group_name' => 'contribution_status', + ], + ], + ], +]; diff --git a/schema/Price/LineItem.entityType.php b/schema/Price/LineItem.entityType.php new file mode 100644 index 000000000000..e0e84117977c --- /dev/null +++ b/schema/Price/LineItem.entityType.php @@ -0,0 +1,222 @@ + 'LineItem', + 'table' => 'civicrm_line_item', + 'class' => 'CRM_Price_DAO_LineItem', + 'getInfo' => fn() => [ + 'title' => ts('Lineitem'), + 'title_plural' => ts('Lineitems'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.7', + ], + 'getIndices' => fn() => [ + 'UI_line_item_value' => [ + 'fields' => [ + 'entity_id' => TRUE, + 'entity_table' => TRUE, + 'contribution_id' => TRUE, + 'price_field_value_id' => TRUE, + 'price_field_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '3.3', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Line Item ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Line Item'), + 'add' => '1.7', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Line Item Entity Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('May contain civicrm_contribution, civicrm_participant or civicrm_membership'), + 'add' => '1.7', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Price_BAO_LineItem::entityTables', + ], + ], + 'entity_id' => [ + 'title' => ts('Line Item Entity'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('entry in table'), + 'add' => '1.7', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'contribution_id' => [ + 'title' => ts('Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_contribution'), + 'add' => '4.5', + 'input_attrs' => [ + 'label' => ts('Contribution'), + ], + 'entity_reference' => [ + 'entity' => 'Contribution', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'price_field_id' => [ + 'title' => ts('Price Field ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to civicrm_price_field'), + 'add' => '1.7', + 'input_attrs' => [ + 'label' => ts('Price Field'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_price_field', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'label', + ], + 'entity_reference' => [ + 'entity' => 'PriceField', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'label' => [ + 'title' => ts('Line Item Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('descriptive label for item - from price_field_value.label'), + 'add' => '1.7', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'qty' => [ + 'title' => ts('Line Item Quantity'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'data_type' => 'Float', + 'required' => TRUE, + 'description' => ts('How many items ordered'), + 'add' => '1.7', + ], + 'unit_price' => [ + 'title' => ts('Unit Price'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('price of each item'), + 'add' => '1.7', + 'input_attrs' => [ + 'label' => ts('Unit Price'), + ], + ], + 'line_total' => [ + 'title' => ts('Line Item Total'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => NULL, + 'required' => TRUE, + 'description' => ts('qty * unit_price'), + 'add' => '1.7', + ], + 'participant_count' => [ + 'title' => ts('Line Item Participant Count'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Participant count for field'), + 'add' => '3.2', + 'default' => NULL, + ], + 'price_field_value_id' => [ + 'title' => ts('Option ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to civicrm_price_field_value'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Option'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_price_field_value', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'label', + ], + 'entity_reference' => [ + 'entity' => 'PriceFieldValue', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to Financial Type.'), + 'add' => '4.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'non_deductible_amount' => [ + 'title' => ts('Non-deductible Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Portion of total amount which is NOT tax deductible.'), + 'add' => '4.7', + 'default' => '0.0', + ], + 'tax_amount' => [ + 'title' => ts('Tax Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('tax of each item'), + 'add' => '4.6', + 'default' => '0', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'membership_num_terms' => [ + 'title' => ts('Number of membership terms purchased'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => ts('Number of terms for this membership (only supported in Order->Payment flow). If the field is NULL it means unknown and it will be assumed to be 1 during payment.create if entity_table is civicrm_membership'), + 'add' => '5.40', + 'default' => NULL, + ], + ], +]; diff --git a/schema/Price/PriceField.entityType.php b/schema/Price/PriceField.entityType.php new file mode 100644 index 000000000000..e8e077b2cf61 --- /dev/null +++ b/schema/Price/PriceField.entityType.php @@ -0,0 +1,220 @@ + 'PriceField', + 'table' => 'civicrm_price_field', + 'class' => 'CRM_Price_DAO_PriceField', + 'getInfo' => fn() => [ + 'title' => ts('Pricefield'), + 'title_plural' => ts('Pricefields'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.8', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/price/field/edit?reset=1&action=add&sid=[price_set_id]', + 'update' => 'civicrm/admin/price/field/edit?reset=1&action=update&sid=[price_set_id]&fid=[id]', + 'delete' => 'civicrm/admin/price/field/edit?reset=1&action=delete&sid=[price_set_id]&fid=[id]', + 'preview' => 'civicrm/admin/price/field/edit?reset=1&action=preview&sid=[price_set_id]&fid=[id]', + 'browse' => 'civicrm/admin/price/field', + ], + 'getIndices' => fn() => [ + 'index_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'add' => '1.8', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Price Field ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Price Field'), + 'add' => '1.8', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'price_set_id' => [ + 'title' => ts('Price Set ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to civicrm_price_set'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Price Set'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_price_set', + 'key_column' => 'id', + 'name_column' => 'name', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'PriceSet', + 'key' => 'id', + ], + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Variable name/programmatic handle for this field.'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'label' => [ + 'title' => ts('Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Text for form field label (also friendly name for administering this field).'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'html_type' => [ + 'title' => ts('Html Type'), + 'sql_type' => 'varchar(12)', + 'input_type' => 'Select', + 'required' => TRUE, + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Html Type'), + 'maxlength' => 12, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Price_BAO_PriceField::htmlTypes', + ], + ], + 'is_enter_qty' => [ + 'title' => ts('Price Field Quantity Required?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Enter a quantity for this field?'), + 'add' => '1.8', + 'default' => FALSE, + ], + 'help_pre' => [ + 'title' => ts('Price Field Pre Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display before this field.'), + 'add' => '1.8', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 80, + ], + ], + 'help_post' => [ + 'title' => ts('Price Field Post Text'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display after this field.'), + 'add' => '1.8', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 80, + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Select', + 'description' => ts('Order in which the fields should appear'), + 'add' => '1.8', + 'default' => 1, + ], + 'is_display_amounts' => [ + 'title' => ts('Price Field Show Amounts?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Should the price be displayed next to the label for each option?'), + 'default' => TRUE, + ], + 'options_per_line' => [ + 'title' => ts('Price Field Options per Row'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('number of options per line for checkbox and radio'), + 'add' => '1.8', + 'default' => 1, + ], + 'is_active' => [ + 'title' => ts('Price Field Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this price field active'), + 'add' => '1.8', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'is_required' => [ + 'title' => ts('Price Field is Required?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this price field required (value must be > 1)'), + 'add' => '1.8', + 'default' => TRUE, + ], + 'active_on' => [ + 'title' => ts('Price Field Start Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('If non-zero, do not show this field before the date specified'), + 'add' => '1.8', + 'default' => NULL, + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'expire_on' => [ + 'title' => ts('Price Field End Date'), + 'sql_type' => 'datetime', + 'input_type' => 'Select Date', + 'description' => ts('If non-zero, do not show this field after the date specified'), + 'add' => '1.8', + 'default' => NULL, + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'javascript' => [ + 'title' => ts('Price Field Javascript'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Optional scripting attributes for field'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'visibility_id' => [ + 'title' => ts('Price Field Visibility'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => 'Implicit FK to civicrm_option_group with name = \'visibility\'', + 'add' => '3.2', + 'default' => 1, + 'pseudoconstant' => [ + 'option_group_name' => 'visibility', + ], + ], + ], +]; diff --git a/schema/Price/PriceFieldValue.entityType.php b/schema/Price/PriceFieldValue.entityType.php new file mode 100644 index 000000000000..d594f57cbf40 --- /dev/null +++ b/schema/Price/PriceFieldValue.entityType.php @@ -0,0 +1,246 @@ + 'PriceFieldValue', + 'table' => 'civicrm_price_field_value', + 'class' => 'CRM_Price_DAO_PriceFieldValue', + 'getInfo' => fn() => [ + 'title' => ts('Pricefieldvalue'), + 'title_plural' => ts('Pricefieldvalues'), + 'description' => ts('FIXME'), + 'add' => '3.3', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/price/field/option/edit?reset=1&action=add&fid=[price_field_id]&sid=[price_field_id.price_set_id]', + 'view' => 'civicrm/admin/price/field/option/edit?reset=1&action=view&oid=[id]&fid=[price_field_id]&sid=[price_field_id.price_set_id]', + 'update' => 'civicrm/admin/price/field/option/edit?reset=1&action=update&oid=[id]&fid=[price_field_id]&sid=[price_field_id.price_set_id]', + 'delete' => 'civicrm/admin/price/field/option/edit?reset=1&action=delete&oid=[id]&fid=[price_field_id]&sid=[price_field_id.price_set_id]', + 'browse' => 'civicrm/admin/price/field/option', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Price Field Value ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Price Field Value'), + 'add' => '3.3', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'price_field_id' => [ + 'title' => ts('Price Field ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('FK to civicrm_price_field'), + 'add' => '3.3', + 'input_attrs' => [ + 'label' => ts('Price Field'), + ], + 'entity_reference' => [ + 'entity' => 'PriceField', + 'key' => 'id', + ], + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Price field option name'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'label' => [ + 'title' => ts('Label'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'localizable' => TRUE, + 'description' => ts('Price field option label'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Description'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Price field option description.'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'rows' => 2, + 'cols' => 60, + 'label' => ts('Description'), + ], + ], + 'help_pre' => [ + 'title' => ts('Help Pre'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Price field option pre help text.'), + 'add' => '4.7', + 'default' => NULL, + 'input_attrs' => [ + 'rows' => 2, + 'cols' => 60, + 'label' => ts('Pre Help'), + ], + ], + 'help_post' => [ + 'title' => ts('Help Post'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Price field option post field help.'), + 'add' => '4.7', + 'default' => NULL, + 'input_attrs' => [ + 'rows' => 2, + 'cols' => 60, + 'label' => ts('Post Help'), + ], + ], + 'amount' => [ + 'title' => ts('Amount'), + 'sql_type' => 'decimal(18,9)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Price field option amount'), + 'add' => '3.3', + 'input_attrs' => [ + 'size' => '8', + 'maxlength' => 18, + ], + ], + 'count' => [ + 'title' => ts('Count'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Number of participants per field option'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Count'), + ], + ], + 'max_value' => [ + 'title' => ts('Max Value'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Max number of participants per field options'), + 'add' => '3.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Max Value'), + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'description' => ts('Order in which the field options should appear'), + 'add' => '3.3', + 'default' => 1, + ], + 'membership_type_id' => [ + 'title' => ts('Membership Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to Membership Type'), + 'add' => '3.4', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Membership Type'), + ], + 'entity_reference' => [ + 'entity' => 'MembershipType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'membership_num_terms' => [ + 'title' => ts('Membership Num Terms'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Number of terms for this membership'), + 'add' => '4.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Number of terms'), + ], + ], + 'is_default' => [ + 'title' => ts('Is Default Price Field Option?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this default price field option'), + 'add' => '3.3', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'is_active' => [ + 'title' => ts('Price Field Value is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this price field value active'), + 'add' => '3.3', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to Financial Type.'), + 'add' => '4.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'non_deductible_amount' => [ + 'title' => ts('Non-deductible Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Portion of total amount which is NOT tax deductible.'), + 'add' => '4.7', + 'default' => '0.0', + ], + 'visibility_id' => [ + 'title' => ts('Price Field Option Visibility'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => 'Implicit FK to civicrm_option_group with name = \'visibility\'', + 'add' => '4.7', + 'default' => 1, + 'pseudoconstant' => [ + 'option_group_name' => 'visibility', + ], + ], + ], +]; diff --git a/schema/Price/PriceSet.entityType.php b/schema/Price/PriceSet.entityType.php new file mode 100644 index 000000000000..5e2b257800fe --- /dev/null +++ b/schema/Price/PriceSet.entityType.php @@ -0,0 +1,196 @@ + 'PriceSet', + 'table' => 'civicrm_price_set', + 'class' => 'CRM_Price_DAO_PriceSet', + 'getInfo' => fn() => [ + 'title' => ts('Priceset'), + 'title_plural' => ts('Pricesets'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.8', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/price/add?reset=1&action=add', + 'update' => 'civicrm/admin/price/edit?reset=1&action=update&sid=[id]', + 'delete' => 'civicrm/admin/price/edit?reset=1&action=delete&sid=[id]', + 'preview' => 'civicrm/admin/price/edit?reset=1&action=preview&sid=[id]', + 'browse' => 'civicrm/admin/price', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.8', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Price Set'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Price Set'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('ID'), + ], + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'description' => ts('Which Domain is this price-set for'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Variable name/programmatic handle for this set of price fields.'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Name'), + 'maxlength' => 255, + ], + ], + 'title' => [ + 'title' => ts('Price Set Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'localizable' => TRUE, + 'description' => ts('Displayed title for the Price Set.'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'is_active' => [ + 'title' => ts('Price Set Is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this price set active'), + 'add' => '1.8', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'help_pre' => [ + 'title' => ts('Price Set Pre Help'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display before fields in form.'), + 'add' => '1.8', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 80, + ], + ], + 'help_post' => [ + 'title' => ts('Price Set Post Help'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'localizable' => TRUE, + 'description' => ts('Description and/or help text to display after fields in form.'), + 'add' => '1.8', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 80, + ], + ], + 'javascript' => [ + 'title' => ts('Price Set Javascript'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Optional Javascript script function(s) included on the form with this price_set. Can be used for conditional'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'extends' => [ + 'title' => ts('Price Set Extends'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('What components are using this price set?'), + 'add' => '3.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, + 'input_attrs' => [ + 'maxlength' => 255, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Price_BAO_PriceSet::getExtendsOptions', + ], + ], + 'financial_type_id' => [ + 'title' => ts('Financial Type ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'description' => ts('FK to Financial Type(for membership price sets only).'), + 'add' => '4.3', + 'default' => NULL, + 'input_attrs' => [ + 'label' => ts('Financial Type'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_financial_type', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'FinancialType', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_quick_config' => [ + 'title' => ts('Is Price Set Quick Config?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is set if edited on Contribution or Event Page rather than through Manage Price Sets'), + 'add' => '4.1', + 'default' => FALSE, + ], + 'is_reserved' => [ + 'title' => ts('Price Set Is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a predefined system price set (i.e. it can not be deleted, edited)?'), + 'add' => '4.2', + 'default' => FALSE, + ], + 'min_amount' => [ + 'title' => ts('Minimum Amount'), + 'sql_type' => 'decimal(20,2)', + 'input_type' => 'Text', + 'description' => ts('Minimum Amount required for this set.'), + 'add' => '4.7', + 'default' => '0.0', + ], + ], +]; diff --git a/schema/Price/PriceSetEntity.entityType.php b/schema/Price/PriceSetEntity.entityType.php new file mode 100644 index 000000000000..1be20ad16c97 --- /dev/null +++ b/schema/Price/PriceSetEntity.entityType.php @@ -0,0 +1,79 @@ + 'PriceSetEntity', + 'table' => 'civicrm_price_set_entity', + 'class' => 'CRM_Price_DAO_PriceSetEntity', + 'getInfo' => fn() => [ + 'title' => ts('Pricesetentity'), + 'title_plural' => ts('Pricesetentities'), + 'description' => ts('FIXME'), + 'log' => TRUE, + 'add' => '1.8', + ], + 'getIndices' => fn() => [ + 'UI_entity' => [ + 'fields' => [ + 'entity_table' => TRUE, + 'entity_id' => TRUE, + ], + 'unique' => TRUE, + 'add' => '1.8', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Price Set Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Price Set Entity'), + 'add' => '1.8', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'entity_table' => [ + 'title' => ts('Entity Table'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Table which uses this price set'), + 'add' => '1.8', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'entity_id' => [ + 'title' => ts('Entity ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Item in table'), + 'add' => '1.8', + 'entity_reference' => [ + 'dynamic_entity' => 'entity_table', + 'key' => 'id', + ], + ], + 'price_set_id' => [ + 'title' => ts('Price Set ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('price set being used'), + 'add' => '1.8', + 'input_attrs' => [ + 'label' => ts('Price Set'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_price_set', + 'key_column' => 'id', + 'label_column' => 'title', + ], + 'entity_reference' => [ + 'entity' => 'PriceSet', + 'key' => 'id', + ], + ], + ], +]; diff --git a/schema/Queue/Queue.entityType.php b/schema/Queue/Queue.entityType.php new file mode 100644 index 000000000000..255a8f889133 --- /dev/null +++ b/schema/Queue/Queue.entityType.php @@ -0,0 +1,141 @@ + 'Queue', + 'table' => 'civicrm_queue', + 'class' => 'CRM_Queue_DAO_Queue', + 'getInfo' => fn() => [ + 'title' => ts('Queue'), + 'title_plural' => ts('Queues'), + 'description' => ts('Stores a list of persistent queues'), + 'add' => '5.47', + ], + 'getIndices' => fn() => [ + 'UI_name' => [ + 'fields' => [ + 'name' => TRUE, + ], + 'unique' => TRUE, + 'add' => '5.47', + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('System Queue ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'add' => '5.47', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name of the queue'), + 'add' => '5.47', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'type' => [ + 'title' => ts('Type'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Type of the queue'), + 'add' => '5.47', + 'input_attrs' => [ + 'maxlength' => 64, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Queue_BAO_Queue::getTypes', + ], + ], + 'runner' => [ + 'title' => ts('Runner'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Name of the task runner'), + 'add' => '5.48', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'batch_limit' => [ + 'title' => ts('Batch Limit'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Maximum number of items in a batch.'), + 'add' => '5.48', + 'default' => 1, + ], + 'lease_time' => [ + 'title' => ts('Lease Time'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('When claiming an item (or batch of items) for work, how long should the item(s) be reserved. (Seconds)'), + 'add' => '5.48', + 'default' => 3600, + ], + 'retry_limit' => [ + 'title' => ts('Retry Limit'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Number of permitted retries. Set to zero (0) to disable.'), + 'add' => '5.48', + 'default' => 0, + ], + 'retry_interval' => [ + 'title' => ts('Retry Interval'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'description' => ts('Number of seconds to wait before retrying a failed execution.'), + 'add' => '5.48', + ], + 'status' => [ + 'title' => ts('Status'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Text', + 'description' => ts('Execution status'), + 'add' => '5.51', + 'default' => 'active', + 'input_attrs' => [ + 'maxlength' => 16, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Queue_BAO_Queue::getStatuses', + ], + ], + 'error' => [ + 'title' => ts('Error Mode'), + 'sql_type' => 'varchar(16)', + 'input_type' => 'Text', + 'description' => ts('Fallback behavior for unhandled errors'), + 'add' => '5.51', + 'input_attrs' => [ + 'maxlength' => 16, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Queue_BAO_Queue::getErrorModes', + ], + ], + 'is_template' => [ + 'title' => ts('Is Template'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this a template configuration (for use by other/future queues)?'), + 'add' => '5.51', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Is Template'), + ], + ], + ], +]; diff --git a/schema/Queue/QueueItem.entityType.php b/schema/Queue/QueueItem.entityType.php new file mode 100644 index 000000000000..d88b4bbf44ed --- /dev/null +++ b/schema/Queue/QueueItem.entityType.php @@ -0,0 +1,84 @@ + 'QueueItem', + 'table' => 'civicrm_queue_item', + 'class' => 'CRM_Queue_DAO_QueueItem', + 'getInfo' => fn() => [ + 'title' => ts('Queueitem'), + 'title_plural' => ts('Queueitems'), + 'description' => ts('Stores a list of queue items'), + 'add' => '4.2', + ], + 'getIndices' => fn() => [ + 'index_queueids' => [ + 'fields' => [ + 'queue_name' => TRUE, + 'weight' => TRUE, + 'id' => TRUE, + ], + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Queue Item ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'queue_name' => [ + 'title' => ts('Queue Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Name of the queue which includes this item'), + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'weight' => [ + 'title' => ts('Order'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'required' => TRUE, + ], + 'submit_time' => [ + 'title' => ts('Submit Time'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'required' => TRUE, + 'description' => ts('date on which this item was submitted to the queue'), + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'release_time' => [ + 'title' => ts('Release Time'), + 'sql_type' => 'timestamp', + 'input_type' => 'Select Date', + 'description' => ts('date on which this job becomes available; null if ASAP'), + 'default' => NULL, + 'input_attrs' => [ + 'format_type' => 'activityDateTime', + ], + ], + 'run_count' => [ + 'title' => ts('Run Count'), + 'sql_type' => 'int', + 'input_type' => 'Text', + 'required' => TRUE, + 'description' => ts('Number of times execution has been attempted.'), + 'add' => '5.48', + 'default' => 0, + ], + 'data' => [ + 'title' => ts('Queue item data'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Serialized queue data'), + 'serialize' => CRM_Core_DAO::SERIALIZE_PHP, + ], + ], +]; diff --git a/schema/Report/ReportInstance.entityType.php b/schema/Report/ReportInstance.entityType.php new file mode 100644 index 000000000000..abc05d18d256 --- /dev/null +++ b/schema/Report/ReportInstance.entityType.php @@ -0,0 +1,272 @@ + 'ReportInstance', + 'table' => 'civicrm_report_instance', + 'class' => 'CRM_Report_DAO_ReportInstance', + 'getInfo' => fn() => [ + 'title' => ts('Report'), + 'title_plural' => ts('Reports'), + 'description' => ts('Users can save their report instance and put in a cron tab etc.'), + 'add' => '2.2', + 'icon' => 'fa-bar-chart', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('Report Instance ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('Report Instance ID'), + 'add' => '2.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'required' => TRUE, + 'description' => ts('Which Domain is this instance for'), + 'add' => '3.1', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + ], + ], + 'title' => [ + 'title' => ts('Report Instance Title'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Report Instance Title.'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'report_id' => [ + 'title' => ts('Report template ID'), + 'sql_type' => 'varchar(512)', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('FK to civicrm_option_value for the report template'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 512, + ], + ], + 'name' => [ + 'title' => ts('Report instance Name'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('when combined with report_id/template uniquely identifies the instance'), + 'add' => '3.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'args' => [ + 'title' => ts('Report Instance Arguments'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('arguments that are passed in the url when invoking the instance'), + 'add' => '3.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'description' => [ + 'title' => ts('Report Instance description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Report Instance description.'), + 'add' => '2.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'permission' => [ + 'title' => ts('Report Instance Permissions'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Select', + 'description' => ts('permission required to be able to run this instance'), + 'add' => '2.2', + 'input_attrs' => [ + 'label' => ts('Permission'), + 'maxlength' => 255, + ], + ], + 'grouprole' => [ + 'title' => ts('Report Instance Assigned to Roles'), + 'sql_type' => 'varchar(1024)', + 'input_type' => 'Select', + 'description' => ts('role required to be able to run this instance'), + 'add' => '4.1', + 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_TRIMMED, + 'input_attrs' => [ + 'title' => ts('ACL Group/Role'), + 'multiple' => '1', + 'maxlength' => 1024, + ], + 'pseudoconstant' => [ + 'callback' => 'CRM_Report_BAO_ReportInstance::getGrouproleOptions', + ], + ], + 'form_values' => [ + 'title' => ts('Submitted Form Values'), + 'sql_type' => 'longtext', + 'input_type' => 'TextArea', + 'description' => ts('Submitted form values for this report'), + 'add' => '2.2', + 'serialize' => CRM_Core_DAO::SERIALIZE_PHP, + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + ], + 'is_active' => [ + 'title' => ts('Report Instance is Active'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'description' => ts('Is this entry active?'), + 'add' => '2.2', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'created_id' => [ + 'title' => ts('Created By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to contact table.'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Created By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'owner_id' => [ + 'title' => ts('Owned By Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to contact table.'), + 'add' => '4.6', + 'input_attrs' => [ + 'label' => ts('Owned By'), + ], + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'email_subject' => [ + 'title' => ts('Report Instance email Subject'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => ts('Subject of email'), + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'email_to' => [ + 'title' => ts('Email Report Instance To'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'description' => ts('comma-separated list of email addresses to send the report to'), + 'add' => '2.2', + ], + 'email_cc' => [ + 'title' => ts('cc Email Report Instance To'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'description' => ts('comma-separated list of email addresses to send the report to'), + 'add' => '2.2', + ], + 'header' => [ + 'title' => ts('Report Instance Header'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('comma-separated list of email addresses to send the report to'), + 'add' => '2.2', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 60, + ], + ], + 'footer' => [ + 'title' => ts('Report Instance Footer'), + 'sql_type' => 'text', + 'input_type' => 'TextArea', + 'description' => ts('comma-separated list of email addresses to send the report to'), + 'add' => '2.2', + 'input_attrs' => [ + 'rows' => 4, + 'cols' => 60, + ], + ], + 'navigation_id' => [ + 'title' => ts('Navigation ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to navigation ID'), + 'add' => '3.0', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Navigation'), + ], + 'entity_reference' => [ + 'entity' => 'Navigation', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'drilldown_id' => [ + 'title' => ts('Drilldown Report ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('FK to instance ID drilldown to'), + 'add' => '4.3', + 'usage' => [ + 'import', + 'export', + 'duplicate_matching', + ], + 'input_attrs' => [ + 'label' => ts('Drilldown Report'), + ], + 'entity_reference' => [ + 'entity' => 'ReportInstance', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'is_reserved' => [ + 'title' => ts('Instance is Reserved'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '4.2', + 'default' => FALSE, + ], + ], +]; diff --git a/schema/SMS/SmsProvider.entityType.php b/schema/SMS/SmsProvider.entityType.php new file mode 100644 index 000000000000..16fc45f80628 --- /dev/null +++ b/schema/SMS/SmsProvider.entityType.php @@ -0,0 +1,138 @@ + 'SmsProvider', + 'table' => 'civicrm_sms_provider', + 'class' => 'CRM_SMS_DAO_SmsProvider', + 'getInfo' => fn() => [ + 'title' => ts('SMS Provider'), + 'title_plural' => ts('SMS Providers'), + 'description' => ts('Table to add different sms providers'), + 'add' => '4.2', + ], + 'getPaths' => fn() => [ + 'add' => 'civicrm/admin/sms/provider/edit?reset=1&action=add', + 'delete' => 'civicrm/admin/sms/provider/edit?reset=1&action=delete&id=[id]', + 'update' => 'civicrm/admin/sms/provider/edit?reset=1&action=update&id=[id]', + 'browse' => 'civicrm/admin/sms/provider?reset=1', + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => ts('SMS Provider ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => ts('SMS Provider ID'), + 'add' => '4.2', + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'name' => [ + 'title' => ts('SMS Provider Name'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Provider internal name points to option_value of option_group sms_provider_name'), + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'title' => [ + 'title' => ts('SMS Provider Title'), + 'sql_type' => 'varchar(64)', + 'input_type' => 'Text', + 'description' => ts('Provider name visible to user'), + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 64, + ], + ], + 'username' => [ + 'title' => ts('SMS Provider Username'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'password' => [ + 'title' => ts('SMS Provider Password'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 255, + ], + ], + 'api_type' => [ + 'title' => ts('SMS Provider API'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Select', + 'required' => TRUE, + 'description' => ts('points to value in civicrm_option_value for group sms_api_type'), + 'add' => '4.2', + 'pseudoconstant' => [ + 'option_group_name' => 'sms_api_type', + ], + ], + 'api_url' => [ + 'title' => ts('SMS Provider API URL'), + 'sql_type' => 'varchar(128)', + 'input_type' => 'Text', + 'add' => '4.2', + 'input_attrs' => [ + 'maxlength' => 128, + ], + ], + 'api_params' => [ + 'title' => ts('SMS Provider API Params'), + 'sql_type' => 'text', + 'input_type' => 'Text', + 'description' => ts('the api params in xml, http or smtp format'), + 'add' => '4.2', + ], + 'is_default' => [ + 'title' => ts('SMS Provider is Default?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '4.2', + 'default' => FALSE, + 'input_attrs' => [ + 'label' => ts('Default'), + ], + ], + 'is_active' => [ + 'title' => ts('SMS Provider is Active?'), + 'sql_type' => 'boolean', + 'input_type' => 'CheckBox', + 'required' => TRUE, + 'add' => '4.2', + 'default' => TRUE, + 'input_attrs' => [ + 'label' => ts('Enabled'), + ], + ], + 'domain_id' => [ + 'title' => ts('Domain ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => ts('Which Domain is this sms provider for'), + 'add' => '4.7', + 'input_attrs' => [ + 'label' => ts('Domain'), + ], + 'pseudoconstant' => [ + 'table' => 'civicrm_domain', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'Domain', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + ], +]; diff --git a/setup/plugins/installDatabase/InstallSchema.civi-setup.php b/setup/plugins/installDatabase/InstallSchema.civi-setup.php index 1455edab09e7..0be8ffdbe829 100644 --- a/setup/plugins/installDatabase/InstallSchema.civi-setup.php +++ b/setup/plugins/installDatabase/InstallSchema.civi-setup.php @@ -66,10 +66,9 @@ public function installDatabase(\Civi\Setup\Event\InstallDatabaseEvent $e) { $model = $e->getModel(); $sqlPath = $model->srcPath . DIRECTORY_SEPARATOR . 'sql'; - $spec = $this->loadSpecification($model->srcPath); \Civi\Setup::log()->info(sprintf('[%s] Load basic tables', basename(__FILE__))); - \Civi\Setup\DbUtil::sourceSQL($model->db, \Civi\Setup\SchemaGenerator::generateCreateSql($model->srcPath, $spec->database, $spec->tables)); + \Civi\Setup\DbUtil::sourceSQL($model->db, Civi::schemaHelper()->generateInstallSql()); $seedLanguage = $model->lang; if (!empty($model->loadGenerated)) { @@ -86,20 +85,6 @@ public function installDatabase(\Civi\Setup\Event\InstallDatabaseEvent $e) { } } - /** - * @param string $srcPath - * @return \CRM_Core_CodeGen_Specification - */ - protected function loadSpecification($srcPath) { - $schemaFile = implode(DIRECTORY_SEPARATOR, [$srcPath, 'xml', 'schema', 'Schema.xml']); - $versionFile = implode(DIRECTORY_SEPARATOR, [$srcPath, 'xml', 'version.xml']); - $xmlBuilt = \CRM_Core_CodeGen_Util_Xml::parse($versionFile); - $buildVersion = preg_replace('/^(\d{1,2}\.\d{1,2})\.(\d{1,2}|\w{4,7})$/i', '$1', $xmlBuilt->version_no); - $specification = new \CRM_Core_CodeGen_Specification(); - $specification->parse($schemaFile, $buildVersion, FALSE); - return $specification; - } - } \Civi\Setup::dispatcher()->addSubscriber(new InstallSchemaPlugin()); diff --git a/setup/src/Setup/SchemaGenerator.php b/setup/src/Setup/SchemaGenerator.php index c27f5fadab52..14bb06ee4857 100644 --- a/setup/src/Setup/SchemaGenerator.php +++ b/setup/src/Setup/SchemaGenerator.php @@ -3,26 +3,6 @@ class SchemaGenerator { - /** - * Return translated SQL content using tpl, mainly contain SQL codes on table CREATE/DROP - * - * @param string $srcPath - * @param array $database - * @param array $tables - * @return string - */ - public static function generateCreateSql($srcPath, $database, $tables) { - $template = new Template($srcPath, 'sql'); - - $template->assign('database', $database); - $template->assign('tables', $tables); - $dropOrder = array_reverse(array_keys($tables)); - $template->assign('dropOrder', $dropOrder); - $template->assign('mysql', 'modern'); - - return $template->getContent('schema.tpl'); - } - /** * Generate an example set of data, including the basic data as well * as some example records/entities (e.g. case-types, membership types). diff --git a/tests/phpunit/Civi/Schema/EntityTest.php b/tests/phpunit/Civi/Schema/EntityTest.php new file mode 100644 index 000000000000..8681733c7440 --- /dev/null +++ b/tests/phpunit/Civi/Schema/EntityTest.php @@ -0,0 +1,45 @@ +assertEquals('civicrm_activity', $entity->getMeta('table')); + $this->assertEquals('CRM_Activity_DAO_Activity', $entity->getMeta('class')); + $this->assertEquals('Activity', $entity->getMeta('title')); + $this->assertEquals('Activities', $entity->getMeta('title_plural')); + $this->assertEquals('Past or future actions concerning one or more contacts.', $entity->getMeta('description')); + $this->assertEquals('fa-tasks', $entity->getMeta('icon')); + $this->assertEquals('subject', $entity->getMeta('label_field')); + $this->assertEquals(['id'], $entity->getMeta('primary_keys')); + $this->assertNotEmpty($entity->getMeta('paths')); + foreach ($entity->getMeta('paths') as $path) { + $this->assertStringStartsWith('civicrm/', $path); + } + } + + public function testGetFields(): void { + $entity = \Civi::entity('Activity'); + + $fields = $entity->getFields(); + $this->assertTrue($fields['id']['primary_key']); + $this->assertTrue($fields['id']['auto_increment']); + $this->assertTrue($fields['id']['required']); + $this->assertFalse($fields['created_date']['required']); + $this->assertEquals('Relationship', $fields['relationship_id']['entity_reference']['entity']); + $this->assertEquals('engagement_index', $fields['engagement_level']['pseudoconstant']['option_group_name']); + $this->assertEquals([], $fields['weight']['usage']); + $this->assertEquals('timestamp', $fields['modified_date']['sql_type']); + $this->assertEquals('CiviCampaign', $fields['campaign_id']['component']); + $this->assertEquals('EntityRef', $fields['campaign_id']['input_type']); + $this->assertEquals('activity_modified_date', $fields['modified_date']['unique_name']); + $this->assertEquals('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', $fields['modified_date']['default']); + $this->assertTrue($fields['modified_date']['readonly']); + $this->assertFalse($fields['is_deleted']['default']); + $this->assertFalse($fields['is_deleted']['localizable']); + } + +} diff --git a/tests/phpunit/E2E/Core/LocalizedDataTest.php b/tests/phpunit/E2E/Core/LocalizedDataTest.php index 2f9faac12191..5bd5630e8ff4 100644 --- a/tests/phpunit/E2E/Core/LocalizedDataTest.php +++ b/tests/phpunit/E2E/Core/LocalizedDataTest.php @@ -43,7 +43,7 @@ public function testLocalizedData(): void { } private function getRenderedSql($locale) { - $schema = new \CRM_Core_CodeGen_Schema(\Civi\Test::codeGen()); + $schema = new \CRM_Core_CodeGen_PhpSchema(\Civi\Test::codeGen()); $files = $schema->generateLocaleDataSql($locale); foreach ($files as $file => $content) { if (preg_match(';^civicrm_data\.;', $file)) { diff --git a/tools/mixin/bin/build-lib b/tools/mixin/bin/build-lib new file mode 100755 index 000000000000..b97d6ea30ce8 --- /dev/null +++ b/tools/mixin/bin/build-lib @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + + + +############################################################################### +## Bootstrap + +## Determine the absolute path of the directory with the file +## usage: absdirname +function absdirname() { + pushd $(dirname $0) >> /dev/null + pwd + popd >> /dev/null +} + +BINDIR=$(absdirname "$0") +set -e + +############################################################################### + +function getCiviVer() { + pushd "$1" >> /dev/null + if [ -f xml/version.xml ]; then + ## Works in any git-based build, even if gencode hasn't run yet. + php -r 'echo simplexml_load_file("xml/version.xml")->version_no;' + else + ## works in any tar-based build. + php -r 'require "civicrm-version.php"; $a = civicrmVersion(); echo $a["version"];' + fi + popd >> /dev/null +} + + +function PHAR() { + php -d phar.readonly=0 `which phar` "$@" +} + +############################################################################### + +TOOLMIX=$(dirname "$BINDIR") +CIVI_CORE=$(dirname $(dirname "$TOOLMIX")) +OUTPUT="$1" +VERSION=$(getCiviVer "$CIVI_CORE") + +if [ -z "$OUTPUT" ]; then + echo 2>&1 "usage: $0 " + echo 2>&1 "example: $0 /tmp/civimix" + exit 1 +fi + +if [ ! -d "$OUTPUT" ]; then + mkdir "$OUTPUT" +fi + +for PACKAGE in civimix-schema ; do + + SRC="${CIVI_CORE}/mixin/lib/${PACKAGE}" + OUTPUT_PHAR="${OUTPUT}/${PACKAGE}@${VERSION}.phar" + #OUTPUT_PHP="${OUTPUT}/${PACKAGE}@${VERSION}.php" + + echo "Read $SRC" + echo "Create $OUTPUT_PHAR" + + [ -f "$OUTPUT_PHAR" ] && rm -f "$OUTPUT_PHAR" || true + #[ -f "$OUTPUT_PHP" ] && rm -f "$OUTPUT_PHP" || true + + (cd "$SRC" ; PHAR pack -f "$OUTPUT_PHAR" -s "$TOOLMIX/src/empty-stub.php" -i '\.php$' . ) + #php "$CIVI_CORE/scripts/concat-php.php" pathload.main.php $( find src -name '*.php' ) >"$OUTPUT_PHP" + +done diff --git a/tools/mixin/src/empty-stub.php b/tools/mixin/src/empty-stub.php new file mode 100644 index 000000000000..8fe23f16d293 --- /dev/null +++ b/tools/mixin/src/empty-stub.php @@ -0,0 +1,2 @@ +