Added xml file for schema

This commit is contained in:
civiwaresolution 2019-09-19 22:54:14 +01:00 committed by Pradeep Nayak
parent 5596e9b90b
commit ae5edc1f48
6 changed files with 266 additions and 91 deletions

View File

@ -4,9 +4,9 @@
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2019
*
* Generated from xml/schema/CRM/Contact/RelateEntities.xml
* Generated from /Users/pradeep/Sites/drupal7/sites/all/extensions/com.megaphonetech.relateentities/xml/schema/CRM/RelateEntities/RelateEntities.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:ebfcea88ae4bd09a0821a942ecdfa4db)
* (GenCodeChecksum:0aed23f92f04bbba15d37ebab3346963)
*/
/**
@ -29,20 +29,68 @@ class CRM_RelateEntities_DAO_RelateEntities extends CRM_Core_DAO {
public static $_log = TRUE;
/**
* RelateEntities ID
* Unique Related Entity ID
*
* @var int
*/
public $id;
/**
* May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc
*
* @var string
*/
public $entity_table_a;
public $entity_table_b;
/**
* entry in table
*
* @var int
*/
public $entity_id_a;
/**
* May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc
*
* @var string
*/
public $entity_table_b;
/**
* entry in table
*
* @var int
*/
public $entity_id_b;
/**
* id of the relationship
*
* @var int
*/
public $relationship_type_id;
public $created_date;
public $modified_date;
/**
* is the relationship active ?
*
* @var bool
*/
public $is_active;
/**
* When was the entry was created.
*
* @var timestamp
*/
public $created_date;
/**
* When was the entry was modified.
*
* @var timestamp
*/
public $modified_date;
/**
* Class constructor.
*/
@ -61,6 +109,8 @@ class CRM_RelateEntities_DAO_RelateEntities extends CRM_Core_DAO {
if (!isset(Civi::$statics[__CLASS__]['links'])) {
Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id_a', NULL, 'id', 'entity_table_a');
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id_b', NULL, 'id', 'entity_table_b');
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
}
return Civi::$statics[__CLASS__]['links'];
@ -77,40 +127,23 @@ class CRM_RelateEntities_DAO_RelateEntities extends CRM_Core_DAO {
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('RelateEntities ID'),
'description' => ts('RelateEntities ID'),
'description' => CRM_RelateEntities_ExtensionUtil::ts('Unique Related Entity ID'),
'required' => TRUE,
'where' => 'civicrm_relate_entities.id',
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_BAO_RelateEntities',
'localizable' => 0,
],
'entity_table_a' => [
'name' => 'entity_table_a',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Entity Table A'),
'description' => ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'),
'required' => TRUE,
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'import' => TRUE,
'export' => TRUE,
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_DAO_RelateEntities',
'localizable' => 0,
],
'entity_table_b' => [
'name' => 'entity_table_b',
'entity_table_a' => [
'name' => 'entity_table_a',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Entity Table B'),
'description' => ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'),
'title' => CRM_RelateEntities_ExtensionUtil::ts('Entity Table A'),
'description' => CRM_RelateEntities_ExtensionUtil::ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'),
'required' => TRUE,
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'import' => TRUE,
'export' => TRUE,
'where' => 'civicrm_relate_entities.entity_table_a',
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_DAO_RelateEntities',
@ -119,86 +152,99 @@ class CRM_RelateEntities_DAO_RelateEntities extends CRM_Core_DAO {
'entity_id_a' => [
'name' => 'entity_id_a',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Entity Id A'),
'description' => '',
'title' => CRM_RelateEntities_ExtensionUtil::ts('Entity Id A'),
'description' => CRM_RelateEntities_ExtensionUtil::ts('entry in table'),
'required' => TRUE,
'where' => 'civicrm_relate_entities.entity_id_a',
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_BAO_RelateEntities',
'bao' => 'CRM_RelateEntities_DAO_RelateEntities',
'localizable' => 0,
],
'entity_table_b' => [
'name' => 'entity_table_b',
'type' => CRM_Utils_Type::T_STRING,
'title' => CRM_RelateEntities_ExtensionUtil::ts('Entity Table b'),
'description' => CRM_RelateEntities_ExtensionUtil::ts('May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc'),
'required' => TRUE,
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'where' => 'civicrm_relate_entities.entity_table_b',
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_DAO_RelateEntities',
'localizable' => 0,
],
'entity_id_b' => [
'name' => 'entity_id_b',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Entity Id B'),
'description' => '',
'title' => CRM_RelateEntities_ExtensionUtil::ts('Entity Id B'),
'description' => CRM_RelateEntities_ExtensionUtil::ts('entry in table'),
'required' => TRUE,
'where' => 'civicrm_relate_entities.entity_id_b',
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_BAO_RelateEntities',
'bao' => 'CRM_RelateEntities_DAO_RelateEntities',
'localizable' => 0,
],
'relationship_type_id' => [
'name' => 'relationship_type_id',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Relationship Type'),
'description' => ts('id of the relationship'),
'title' => CRM_RelateEntities_ExtensionUtil::ts('Relationship Type'),
'description' => CRM_RelateEntities_ExtensionUtil::ts('id of the relationship'),
'required' => TRUE,
'where' => 'civicrm_relate_entities.relationship_type_id',
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_BAO_RelateEntities',
'bao' => 'CRM_RelateEntities_DAO_RelateEntities',
'localizable' => 0,
'FKClassName' => 'CRM_Relationship_DAO_RelationshipType',
'html' => [
'type' => 'Select',
],
],
'created_date' => [
'name' => 'created_date',
'type' => CRM_Utils_Type::T_DATE,
'title' => ts('RelateEntities Created Date'),
'description' => ts('date when the relationship created'),
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_BAO_RelateEntities',
'localizable' => 0,
'html' => [
'type' => 'Select Date',
'formatType' => 'activityDate',
],
],
'modified_date' => [
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_DATE,
'title' => ts('RelateEntities Modified Date'),
'description' => ts('date when the relationship modified'),
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_BAO_RelateEntities',
'localizable' => 0,
'html' => [
'type' => 'Select Date',
'formatType' => 'activityDate',
],
],
'is_active' => [
'name' => 'is_active',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => ts('Is Active?'),
'description' => ts('is active ?'),
'title' => CRM_RelateEntities_ExtensionUtil::ts('Relationship Is Active'),
'description' => CRM_RelateEntities_ExtensionUtil::ts('is the relationship active ?'),
'where' => 'civicrm_relate_entities.is_active',
'default' => '1',
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_BAO_RelateEntities',
'bao' => 'CRM_RelateEntities_DAO_RelateEntities',
'localizable' => 0,
'html' => [
'type' => 'Radio',
],
'options' => [
'1' => ts('Yes'),
'0' => ts('No'),
'type' => 'CheckBox',
],
],
'created_date' => [
'name' => 'created_date',
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => CRM_RelateEntities_ExtensionUtil::ts('RelateEntities Created Date'),
'description' => CRM_RelateEntities_ExtensionUtil::ts('When was the entry was created.'),
'required' => FALSE,
'where' => 'civicrm_relate_entities.created_date',
'export' => TRUE,
'default' => 'CURRENT_TIMESTAMP',
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_DAO_RelateEntities',
'localizable' => 0,
],
'modified_date' => [
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => CRM_RelateEntities_ExtensionUtil::ts('RelateEntities Modified Date'),
'description' => CRM_RelateEntities_ExtensionUtil::ts('When was the entry was modified.'),
'required' => FALSE,
'where' => 'civicrm_relate_entities.modified_date',
'export' => TRUE,
'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
'table_name' => 'civicrm_relate_entities',
'entity' => 'RelateEntities',
'bao' => 'CRM_RelateEntities_DAO_RelateEntities',
'localizable' => 0,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}

View File

@ -214,7 +214,7 @@ use CRM_Core_Form_EntityFormTrait;
if (!empty($result['is_error'])) {
CRM_Core_Error::statusBounce($result['error_message'], CRM_Utils_System::url('civicrm/', "reset=1&action=browse"), ts('Cannot Delete'));
}
CRM_Core_Session::setStatus(ts('Selected Bank Account has been deleted.'), ts('Record Deleted'), 'success');
CRM_Core_Session::setStatus(ts('Selected Related entity has been deleted.'), ts('Record Deleted'), 'success');
}
else {
// store the submitted values in an array
@ -240,7 +240,7 @@ use CRM_Core_Form_EntityFormTrait;
);
}
if ($buttonName == $this->getButtonName('next', 'new')) {
CRM_Core_Session::setStatus(ts(' You can add another Bank Account.'));
CRM_Core_Session::setStatus(ts(' You can add another Related entity.'));
$session->replaceUserContext(CRM_Utils_System::url('civicrm/relatedentities/add',
"action=add&reset=1&entityTable={$this->entity_table}&entityId={$apiParams['entity_id_a']}")
);

View File

@ -6,10 +6,10 @@
* The ExtensionUtil class provides small stubs for accessing resources of this
* extension.
*/
class CRM_Relateentities_ExtensionUtil {
class CRM_RelateEntities_ExtensionUtil {
const SHORT_NAME = "relateentities";
const LONG_NAME = "com.megaphonetech.relateentities";
const CLASS_PREFIX = "CRM_Relateentities";
const CLASS_PREFIX = "CRM_RelateEntities";
/**
* Translate a string using the extension's domain.
@ -77,7 +77,7 @@ class CRM_Relateentities_ExtensionUtil {
}
use CRM_Relateentities_ExtensionUtil as E;
use CRM_RelateEntities_ExtensionUtil as E;
/**
* (Delegated) Implements hook_civicrm_config().
@ -193,7 +193,8 @@ function _relateentities_civix_civicrm_disable() {
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
*
* @return mixed
* @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
* for 'enqueue', returns void
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
*/
@ -204,14 +205,14 @@ function _relateentities_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NUL
}
/**
* @return CRM_Relateentities_Upgrader
* @return CRM_RelateEntities_Upgrader
*/
function _relateentities_civix_upgrader() {
if (!file_exists(__DIR__ . '/CRM/Relateentities/Upgrader.php')) {
if (!file_exists(__DIR__ . '/CRM/RelateEntities/Upgrader.php')) {
return NULL;
}
else {
return CRM_Relateentities_Upgrader_Base::instance();
return CRM_RelateEntities_Upgrader_Base::instance();
}
}
@ -253,7 +254,6 @@ function _relateentities_civix_find_files($dir, $pattern) {
}
return $result;
}
/**
* (Delegated) Implements hook_civicrm_managed().
*
@ -467,6 +467,14 @@ function _relateentities_civix_civicrm_alterSettingsFolders(&$metaDataFolders =
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
*/
function _relateentities_civix_civicrm_entityTypes(&$entityTypes) {
$entityTypes = array_merge($entityTypes, []);
$entityTypes = array_merge($entityTypes, array (
'CRM_RelateEntities_DAO_RelateEntities' =>
array (
'name' => 'RelateEntities',
'class' => 'CRM_RelateEntities_DAO_RelateEntities',
'table' => 'civicrm_relate_entities',
),
));
}

View File

@ -133,11 +133,6 @@ function relateentities_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
*/
function relateentities_civicrm_entityTypes(&$entityTypes) {
_relateentities_civix_civicrm_entityTypes($entityTypes);
$entityTypes[] = [
'name' => 'RelateEntities',
'class' => 'CRM_RelateEntities_DAO_RelateEntities',
'table' => 'civicrm_relate_entities',
];
}
/**

View File

@ -0,0 +1,11 @@
<?php
// This file declares a new entity type. For more details, see "hook_civicrm_entityTypes" at:
// http://wiki.civicrm.org/confluence/display/CRMDOC/Hook+Reference
return array (
0 =>
array (
'name' => 'RelateEntities',
'class' => 'CRM_RelateEntities_DAO_RelateEntities',
'table' => 'civicrm_relate_entities',
),
);

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<table>
<base>CRM/RelateEntities</base>
<class>RelateEntities</class>
<name>civicrm_relate_entities</name>
<comment>Related entity</comment>
<add>1.0</add>
<log>true</log>
<field>
<name>id</name>
<type>int unsigned</type>
<required>true</required>
<comment>Unique Related Entity ID</comment>
<add>1.0</add>
</field>
<primaryKey>
<name>id</name>
<autoincrement>true</autoincrement>
</primaryKey>
<field>
<name>entity_table_a</name>
<title>Entity Table A</title>
<type>varchar</type>
<length>64</length>
<required>true</required>
<comment>May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc</comment>
<add>1.0</add>
</field>
<field>
<name>entity_id_a</name>
<title>Entity Id A</title>
<type>int unsigned</type>
<required>true</required>
<comment>entry in table</comment>
<add>1.0</add>
</field>
<dynamicForeignKey>
<idColumn>entity_id_a</idColumn>
<typeColumn>entity_table_a</typeColumn>
<add>1.0</add>
</dynamicForeignKey>
<field>
<name>entity_table_b</name>
<title>Entity Table b</title>
<type>varchar</type>
<length>64</length>
<required>true</required>
<comment>May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc</comment>
<add>1.0</add>
</field>
<field>
<name>entity_id_b</name>
<title>Entity Id B</title>
<type>int unsigned</type>
<required>true</required>
<comment>entry in table</comment>
<add>1.0</add>
</field>
<dynamicForeignKey>
<idColumn>entity_id_b</idColumn>
<typeColumn>entity_table_b</typeColumn>
<add>1.0</add>
</dynamicForeignKey>
<field>
<name>relationship_type_id</name>
<type>int unsigned</type>
<title>Relationship Type</title>
<required>true</required>
<comment>id of the relationship</comment>
<add>1.0</add>
<html>
<type>Select</type>
</html>
</field>
<foreignKey>
<name>relationship_type_id</name>
<table>civicrm_relationship_type</table>
<key>id</key>
<add>1.0</add>
<onDelete>CASCADE</onDelete>
</foreignKey>
<field>
<name>is_active</name>
<type>boolean</type>
<title>Relationship Is Active</title>
<default>1</default>
<comment>is the relationship active ?</comment>
<add>1.1</add>
<html>
<type>CheckBox</type>
</html>
</field>
<field>
<name>created_date</name>
<title>RelateEntities Created Date</title>
<type>timestamp</type>
<comment>When was the entry was created.</comment>
<required>false</required>
<export>true</export>
<default>CURRENT_TIMESTAMP</default>
<add>1.0</add>
</field>
<field>
<name>modified_date</name>
<title>RelateEntities Modified Date</title>
<type>timestamp</type>
<comment>When was the entry was modified.</comment>
<required>false</required>
<export>true</export>
<default>CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP</default>
<add>1.0</add>
</field>
</table>