diff --git a/CRM/RelateEntities/DAO/RelateEntities.php b/CRM/RelateEntities/DAO/RelateEntities.php index a1526f1..451b60d 100644 --- a/CRM/RelateEntities/DAO/RelateEntities.php +++ b/CRM/RelateEntities/DAO/RelateEntities.php @@ -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']); } diff --git a/CRM/RelateEntities/Form/RelatedEntity.php b/CRM/RelateEntities/Form/RelatedEntity.php index 78376dd..dee7c11 100644 --- a/CRM/RelateEntities/Form/RelatedEntity.php +++ b/CRM/RelateEntities/Form/RelatedEntity.php @@ -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']}") ); diff --git a/relateentities.civix.php b/relateentities.civix.php index 6a1a13d..26f2a33 100644 --- a/relateentities.civix.php +++ b/relateentities.civix.php @@ -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', + ), + )); } diff --git a/relateentities.php b/relateentities.php index ef564ea..b43eed9 100644 --- a/relateentities.php +++ b/relateentities.php @@ -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', - ]; } /** diff --git a/xml/schema/CRM/RelateEntities/RelateEntities.entityType.php b/xml/schema/CRM/RelateEntities/RelateEntities.entityType.php new file mode 100644 index 0000000..b48fb48 --- /dev/null +++ b/xml/schema/CRM/RelateEntities/RelateEntities.entityType.php @@ -0,0 +1,11 @@ + + array ( + 'name' => 'RelateEntities', + 'class' => 'CRM_RelateEntities_DAO_RelateEntities', + 'table' => 'civicrm_relate_entities', + ), +); diff --git a/xml/schema/CRM/RelateEntities/RelateEntities.xml b/xml/schema/CRM/RelateEntities/RelateEntities.xml new file mode 100644 index 0000000..5a02a44 --- /dev/null +++ b/xml/schema/CRM/RelateEntities/RelateEntities.xml @@ -0,0 +1,115 @@ + + + + CRM/RelateEntities + RelateEntities + civicrm_relate_entities + Related entity + 1.0 + true + + + id + int unsigned + true + Unique Related Entity ID + 1.0 + + + id + true + + + entity_table_a + Entity Table A + varchar + 64 + true + May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc + 1.0 + + + entity_id_a + Entity Id A + int unsigned + true + entry in table + 1.0 + + + entity_id_a + entity_table_a + 1.0 + + + entity_table_b + Entity Table b + varchar + 64 + true + May contain civicrm_financial_item, civicrm_contribution, civicrm_financial_trxn, civicrm_grant, etc + 1.0 + + + entity_id_b + Entity Id B + int unsigned + true + entry in table + 1.0 + + + entity_id_b + entity_table_b + 1.0 + + + relationship_type_id + int unsigned + Relationship Type + true + id of the relationship + 1.0 + + Select + + + + relationship_type_id +
civicrm_relationship_type
+ id + 1.0 + CASCADE + + + is_active + boolean + Relationship Is Active + 1 + is the relationship active ? + 1.1 + + CheckBox + + + + created_date + RelateEntities Created Date + timestamp + When was the entry was created. + false + true + CURRENT_TIMESTAMP + 1.0 + + + modified_date + RelateEntities Modified Date + timestamp + When was the entry was modified. + false + true + CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP + 1.0 + +