Merge pull request #18305 from civicrm/5.29
[civicrm-core.git] / CRM / Contact / DAO / GroupOrganization.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Contact/GroupOrganization.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
929a1c14 9 * (GenCodeChecksum:dfe8edf8f786790af95f09f456d1cbe7)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the GroupOrganization entity.
f41f0342 14 */
e501603b 15class CRM_Contact_DAO_GroupOrganization extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '2.0';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_group_organization';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = TRUE;
c3fc2621 32
e501603b
TO
33 /**
34 * Relationship ID
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * ID of the group
42 *
e6ca0a57 43 * @var int
e501603b
TO
44 */
45 public $group_id;
c3fc2621 46
e501603b
TO
47 /**
48 * ID of the Organization Contact
49 *
e6ca0a57 50 * @var int
e501603b
TO
51 */
52 public $organization_id;
c3fc2621 53
e501603b 54 /**
f41f0342 55 * Class constructor.
e501603b 56 */
c3fc2621 57 public function __construct() {
e501603b
TO
58 $this->__table = 'civicrm_group_organization';
59 parent::__construct();
60 }
c3fc2621 61
449c4e6b
CW
62 /**
63 * Returns localized title of this entity.
64 */
65 public static function getEntityTitle() {
66 return ts('Group Organizations');
67 }
68
e501603b 69 /**
f41f0342 70 * Returns foreign keys and entity references.
e501603b
TO
71 *
72 * @return array
73 * [CRM_Core_Reference_Interface]
74 */
c3fc2621 75 public static function getReferenceColumns() {
346aaaba 76 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 77 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
78 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
79 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'organization_id', 'civicrm_contact', 'id');
346aaaba 80 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 81 }
346aaaba 82 return Civi::$statics[__CLASS__]['links'];
e501603b 83 }
c3fc2621 84
e501603b
TO
85 /**
86 * Returns all the column names of this table
87 *
88 * @return array
89 */
c3fc2621 90 public static function &fields() {
346aaaba 91 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
92 Civi::$statics[__CLASS__]['fields'] = [
93 'id' => [
e501603b
TO
94 'name' => 'id',
95 'type' => CRM_Utils_Type::T_INT,
c3fc2621 96 'title' => ts('Group Organization ID'),
215b423e 97 'description' => ts('Relationship ID'),
c3fc2621 98 'required' => TRUE,
a36434b9 99 'where' => 'civicrm_group_organization.id',
522a26c9 100 'table_name' => 'civicrm_group_organization',
101 'entity' => 'GroupOrganization',
102 'bao' => 'CRM_Contact_BAO_GroupOrganization',
6a7e5e5d 103 'localizable' => 0,
a9d0587b 104 'add' => '2.0',
c3fc2621
CW
105 ],
106 'group_id' => [
e501603b
TO
107 'name' => 'group_id',
108 'type' => CRM_Utils_Type::T_INT,
c3fc2621 109 'title' => ts('Group'),
215b423e 110 'description' => ts('ID of the group'),
c3fc2621 111 'required' => TRUE,
a36434b9 112 'where' => 'civicrm_group_organization.group_id',
522a26c9 113 'table_name' => 'civicrm_group_organization',
114 'entity' => 'GroupOrganization',
115 'bao' => 'CRM_Contact_BAO_GroupOrganization',
6a7e5e5d 116 'localizable' => 0,
e501603b 117 'FKClassName' => 'CRM_Contact_DAO_Group',
c3fc2621 118 'html' => [
e501603b 119 'type' => 'Select',
c3fc2621
CW
120 ],
121 'pseudoconstant' => [
e501603b
TO
122 'table' => 'civicrm_group',
123 'keyColumn' => 'id',
124 'labelColumn' => 'title',
e6ca0a57 125 ],
a9d0587b 126 'add' => '2.0',
c3fc2621
CW
127 ],
128 'organization_id' => [
e501603b
TO
129 'name' => 'organization_id',
130 'type' => CRM_Utils_Type::T_INT,
c3fc2621 131 'title' => ts('Organization'),
215b423e 132 'description' => ts('ID of the Organization Contact'),
c3fc2621 133 'required' => TRUE,
a36434b9 134 'where' => 'civicrm_group_organization.organization_id',
522a26c9 135 'table_name' => 'civicrm_group_organization',
136 'entity' => 'GroupOrganization',
137 'bao' => 'CRM_Contact_BAO_GroupOrganization',
6a7e5e5d 138 'localizable' => 0,
e501603b 139 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 140 'add' => '2.0',
c3fc2621
CW
141 ],
142 ];
346aaaba 143 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 144 }
346aaaba 145 return Civi::$statics[__CLASS__]['fields'];
e501603b 146 }
c3fc2621 147
e501603b 148 /**
bd8e0b14 149 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
150 *
151 * @return array
bd8e0b14 152 * Array(string $name => string $uniqueName).
e501603b 153 */
c3fc2621 154 public static function &fieldKeys() {
bd8e0b14
TO
155 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
156 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 157 }
bd8e0b14 158 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 159 }
c3fc2621 160
e501603b
TO
161 /**
162 * Returns the names of this table
163 *
164 * @return string
165 */
c3fc2621 166 public static function getTableName() {
e501603b
TO
167 return self::$_tableName;
168 }
c3fc2621 169
e501603b
TO
170 /**
171 * Returns if this table needs to be logged
172 *
c3fc2621 173 * @return bool
e501603b 174 */
c3fc2621 175 public function getLog() {
e501603b
TO
176 return self::$_log;
177 }
c3fc2621 178
e501603b
TO
179 /**
180 * Returns the list of fields that can be imported
181 *
182 * @param bool $prefix
183 *
184 * @return array
185 */
c3fc2621
CW
186 public static function &import($prefix = FALSE) {
187 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group_organization', $prefix, []);
60808919 188 return $r;
e501603b 189 }
c3fc2621 190
e501603b
TO
191 /**
192 * Returns the list of fields that can be exported
193 *
194 * @param bool $prefix
195 *
196 * @return array
197 */
c3fc2621
CW
198 public static function &export($prefix = FALSE) {
199 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group_organization', $prefix, []);
60808919 200 return $r;
e501603b 201 }
c3fc2621 202
e7a6b91a
AS
203 /**
204 * Returns the list of indices
c3fc2621
CW
205 *
206 * @param bool $localize
207 *
208 * @return array
e7a6b91a
AS
209 */
210 public static function indices($localize = TRUE) {
c3fc2621
CW
211 $indices = [
212 'UI_group_organization' => [
e7a6b91a 213 'name' => 'UI_group_organization',
c3fc2621 214 'field' => [
e7a6b91a
AS
215 0 => 'group_id',
216 1 => 'organization_id',
c3fc2621
CW
217 ],
218 'localizable' => FALSE,
219 'unique' => TRUE,
e7a6b91a 220 'sig' => 'civicrm_group_organization::1::group_id::organization_id',
c3fc2621
CW
221 ],
222 ];
e7a6b91a
AS
223 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
224 }
c3fc2621 225
e501603b 226}