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