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