Merge pull request #17256 from demeritcowboy/test-for-16559
[civicrm-core.git] / CRM / Core / DAO / OpenID.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/OpenID.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ed6e574083475c9caf6e8f5028510263)
10 */
11
12 /**
13 * Database access object for the OpenID entity.
14 */
15 class CRM_Core_DAO_OpenID extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_openid';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = FALSE;
30
31 /**
32 * Unique OpenID ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int
42 */
43 public $contact_id;
44
45 /**
46 * Which Location does this email belong to.
47 *
48 * @var int
49 */
50 public $location_type_id;
51
52 /**
53 * the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM
54 *
55 * @var string
56 */
57 public $openid;
58
59 /**
60 * Whether or not this user is allowed to login
61 *
62 * @var bool
63 */
64 public $allowed_to_login;
65
66 /**
67 * Is this the primary email for this contact and location.
68 *
69 * @var bool
70 */
71 public $is_primary;
72
73 /**
74 * Class constructor.
75 */
76 public function __construct() {
77 $this->__table = 'civicrm_openid';
78 parent::__construct();
79 }
80
81 /**
82 * Returns localized title of this entity.
83 */
84 public static function getEntityTitle() {
85 return ts('Open IDs');
86 }
87
88 /**
89 * Returns foreign keys and entity references.
90 *
91 * @return array
92 * [CRM_Core_Reference_Interface]
93 */
94 public static function getReferenceColumns() {
95 if (!isset(Civi::$statics[__CLASS__]['links'])) {
96 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
98 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
99 }
100 return Civi::$statics[__CLASS__]['links'];
101 }
102
103 /**
104 * Returns all the column names of this table
105 *
106 * @return array
107 */
108 public static function &fields() {
109 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
110 Civi::$statics[__CLASS__]['fields'] = [
111 'id' => [
112 'name' => 'id',
113 'type' => CRM_Utils_Type::T_INT,
114 'title' => ts('Open ID identifier'),
115 'description' => ts('Unique OpenID ID'),
116 'required' => TRUE,
117 'where' => 'civicrm_openid.id',
118 'table_name' => 'civicrm_openid',
119 'entity' => 'OpenID',
120 'bao' => 'CRM_Core_BAO_OpenID',
121 'localizable' => 0,
122 'add' => '2.0',
123 ],
124 'contact_id' => [
125 'name' => 'contact_id',
126 'type' => CRM_Utils_Type::T_INT,
127 'title' => ts('OpenID Contact'),
128 'description' => ts('FK to Contact ID'),
129 'where' => 'civicrm_openid.contact_id',
130 'table_name' => 'civicrm_openid',
131 'entity' => 'OpenID',
132 'bao' => 'CRM_Core_BAO_OpenID',
133 'localizable' => 0,
134 'FKClassName' => 'CRM_Contact_DAO_Contact',
135 'add' => '2.0',
136 ],
137 'location_type_id' => [
138 'name' => 'location_type_id',
139 'type' => CRM_Utils_Type::T_INT,
140 'title' => ts('OpenID Location Type'),
141 'description' => ts('Which Location does this email belong to.'),
142 'where' => 'civicrm_openid.location_type_id',
143 'table_name' => 'civicrm_openid',
144 'entity' => 'OpenID',
145 'bao' => 'CRM_Core_BAO_OpenID',
146 'localizable' => 0,
147 'pseudoconstant' => [
148 'table' => 'civicrm_location_type',
149 'keyColumn' => 'id',
150 'labelColumn' => 'display_name',
151 ],
152 'add' => '2.0',
153 ],
154 'openid' => [
155 'name' => 'openid',
156 'type' => CRM_Utils_Type::T_STRING,
157 'title' => ts('OpenID'),
158 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
159 'maxlength' => 255,
160 'size' => CRM_Utils_Type::HUGE,
161 'import' => TRUE,
162 'where' => 'civicrm_openid.openid',
163 'headerPattern' => '/^Open.?ID|u(niq\w*)?.?ID/i',
164 'dataPattern' => '/^[\w\/\:\.]+$/',
165 'export' => TRUE,
166 'rule' => 'url',
167 'table_name' => 'civicrm_openid',
168 'entity' => 'OpenID',
169 'bao' => 'CRM_Core_BAO_OpenID',
170 'localizable' => 0,
171 'add' => '2.0',
172 ],
173 'allowed_to_login' => [
174 'name' => 'allowed_to_login',
175 'type' => CRM_Utils_Type::T_BOOLEAN,
176 'title' => ts('Allowed to login?'),
177 'description' => ts('Whether or not this user is allowed to login'),
178 'required' => TRUE,
179 'where' => 'civicrm_openid.allowed_to_login',
180 'default' => '0',
181 'table_name' => 'civicrm_openid',
182 'entity' => 'OpenID',
183 'bao' => 'CRM_Core_BAO_OpenID',
184 'localizable' => 0,
185 'add' => '2.0',
186 ],
187 'is_primary' => [
188 'name' => 'is_primary',
189 'type' => CRM_Utils_Type::T_BOOLEAN,
190 'title' => ts('Primary ID'),
191 'description' => ts('Is this the primary email for this contact and location.'),
192 'where' => 'civicrm_openid.is_primary',
193 'default' => '0',
194 'table_name' => 'civicrm_openid',
195 'entity' => 'OpenID',
196 'bao' => 'CRM_Core_BAO_OpenID',
197 'localizable' => 0,
198 'html' => [
199 'type' => 'Radio',
200 ],
201 'add' => '2.0',
202 ],
203 ];
204 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
205 }
206 return Civi::$statics[__CLASS__]['fields'];
207 }
208
209 /**
210 * Return a mapping from field-name to the corresponding key (as used in fields()).
211 *
212 * @return array
213 * Array(string $name => string $uniqueName).
214 */
215 public static function &fieldKeys() {
216 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
217 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
218 }
219 return Civi::$statics[__CLASS__]['fieldKeys'];
220 }
221
222 /**
223 * Returns the names of this table
224 *
225 * @return string
226 */
227 public static function getTableName() {
228 return self::$_tableName;
229 }
230
231 /**
232 * Returns if this table needs to be logged
233 *
234 * @return bool
235 */
236 public function getLog() {
237 return self::$_log;
238 }
239
240 /**
241 * Returns the list of fields that can be imported
242 *
243 * @param bool $prefix
244 *
245 * @return array
246 */
247 public static function &import($prefix = FALSE) {
248 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'openid', $prefix, []);
249 return $r;
250 }
251
252 /**
253 * Returns the list of fields that can be exported
254 *
255 * @param bool $prefix
256 *
257 * @return array
258 */
259 public static function &export($prefix = FALSE) {
260 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'openid', $prefix, []);
261 return $r;
262 }
263
264 /**
265 * Returns the list of indices
266 *
267 * @param bool $localize
268 *
269 * @return array
270 */
271 public static function indices($localize = TRUE) {
272 $indices = [
273 'index_location_type' => [
274 'name' => 'index_location_type',
275 'field' => [
276 0 => 'location_type_id',
277 ],
278 'localizable' => FALSE,
279 'sig' => 'civicrm_openid::0::location_type_id',
280 ],
281 'UI_openid' => [
282 'name' => 'UI_openid',
283 'field' => [
284 0 => 'openid',
285 ],
286 'localizable' => FALSE,
287 'unique' => TRUE,
288 'sig' => 'civicrm_openid::1::openid',
289 ],
290 ];
291 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
292 }
293
294 }