Passed
Pull Request — develop (#200)
by Felipe
06:52 queued 01:49
created

HasTrait::hasRoles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * PHPPgAdmin v6.0.0-beta.43
5
 */
6
7
namespace PHPPgAdmin\Traits;
8
9
/**
10
 * Common trait for flags telling if the driver supports certain attributes/operations
11
 */
12
trait HasTrait
13
{
14
    public $conn;
15
16
    // The backend platform.  Set to UNKNOWN by default.
17
    public $platform = 'UNKNOWN';
18
19
    public $major_version = 9.6;
20
    // Max object name length
21
    public $_maxNameLen = 63;
22
    // Store the current schema
23
    public $_schema;
24
    // Map of database encoding names to HTTP encoding names.  If a
25
    // database encoding does not appear in this list, then its HTTP
26
    // encoding name is the same as its database encoding name.
27
    public $codemap = [
28
        'BIG5'       => 'BIG5',
29
        'EUC_CN'     => 'GB2312',
30
        'EUC_JP'     => 'EUC-JP',
31
        'EUC_KR'     => 'EUC-KR',
32
        'EUC_TW'     => 'EUC-TW',
33
        'GB18030'    => 'GB18030',
34
        'GBK'        => 'GB2312',
35
        'ISO_8859_5' => 'ISO-8859-5',
36
        'ISO_8859_6' => 'ISO-8859-6',
37
        'ISO_8859_7' => 'ISO-8859-7',
38
        'ISO_8859_8' => 'ISO-8859-8',
39
        'JOHAB'      => 'CP1361',
40
        'KOI8'       => 'KOI8-R',
41
        'LATIN1'     => 'ISO-8859-1',
42
        'LATIN2'     => 'ISO-8859-2',
43
        'LATIN3'     => 'ISO-8859-3',
44
        'LATIN4'     => 'ISO-8859-4',
45
        'LATIN5'     => 'ISO-8859-9',
46
        'LATIN6'     => 'ISO-8859-10',
47
        'LATIN7'     => 'ISO-8859-13',
48
        'LATIN8'     => 'ISO-8859-14',
49
        'LATIN9'     => 'ISO-8859-15',
50
        'LATIN10'    => 'ISO-8859-16',
51
        'SJIS'       => 'SHIFT_JIS',
52
        'SQL_ASCII'  => 'US-ASCII',
53
        'UHC'        => 'WIN949',
54
        'UTF8'       => 'UTF-8',
55
        'WIN866'     => 'CP866',
56
        'WIN874'     => 'CP874',
57
        'WIN1250'    => 'CP1250',
58
        'WIN1251'    => 'CP1251',
59
        'WIN1252'    => 'CP1252',
60
        'WIN1256'    => 'CP1256',
61
        'WIN1258'    => 'CP1258',
62
    ];
63
    public $defaultprops = ['', '', ''];
64
    // Extra "magic" types.  BIGSERIAL was added in PostgreSQL 7.2.
65
    public $extraTypes = ['SERIAL', 'BIGSERIAL'];
66
    // Foreign key stuff.  First element MUST be the default.
67
    public $fkactions    = ['NO ACTION', 'RESTRICT', 'CASCADE', 'SET NULL', 'SET DEFAULT'];
68
    public $fkdeferrable = ['NOT DEFERRABLE', 'DEFERRABLE'];
69
    public $fkinitial    = ['INITIALLY IMMEDIATE', 'INITIALLY DEFERRED'];
70
    public $fkmatches    = ['MATCH SIMPLE', 'MATCH FULL'];
71
    // Function properties
72
    public $funcprops = [
73
        ['', 'VOLATILE', 'IMMUTABLE', 'STABLE'],
74
        ['', 'CALLED ON NULL INPUT', 'RETURNS NULL ON NULL INPUT'],
75
        ['', 'SECURITY INVOKER', 'SECURITY DEFINER'],
76
    ];
77
78
    // Default help URL
79
    public $help_base;
80
    // Help sub pages
81
    public $help_page;
82
    // Name of id column
83
    public $id = 'oid';
84
85
    // Supported join operations for use with view wizard
86
    public $joinOps = ['INNER JOIN' => 'INNER JOIN', 'LEFT JOIN' => 'LEFT JOIN', 'RIGHT JOIN' => 'RIGHT JOIN', 'FULL JOIN' => 'FULL JOIN'];
87
    // Map of internal language name to syntax highlighting name
88
    public $langmap = [
89
        'sql'       => 'SQL',
90
        'plpgsql'   => 'SQL',
91
        'php'       => 'PHP',
92
        'phpu'      => 'PHP',
93
        'plphp'     => 'PHP',
94
        'plphpu'    => 'PHP',
95
        'perl'      => 'Perl',
96
        'perlu'     => 'Perl',
97
        'plperl'    => 'Perl',
98
        'plperlu'   => 'Perl',
99
        'java'      => 'Java',
100
        'javau'     => 'Java',
101
        'pljava'    => 'Java',
102
        'pljavau'   => 'Java',
103
        'plj'       => 'Java',
104
        'plju'      => 'Java',
105
        'python'    => 'Python',
106
        'pythonu'   => 'Python',
107
        'plpython'  => 'Python',
108
        'plpythonu' => 'Python',
109
        'ruby'      => 'Ruby',
110
        'rubyu'     => 'Ruby',
111
        'plruby'    => 'Ruby',
112
        'plrubyu'   => 'Ruby',
113
    ];
114
    // Predefined size types
115
    public $predefined_size_types = [
116
        'abstime',
117
        'aclitem',
118
        'bigserial',
119
        'boolean',
120
        'bytea',
121
        'cid',
122
        'cidr',
123
        'circle',
124
        'date',
125
        'float4',
126
        'float8',
127
        'gtsvector',
128
        'inet',
129
        'int2',
130
        'int4',
131
        'int8',
132
        'macaddr',
133
        'money',
134
        'oid',
135
        'path',
136
        'polygon',
137
        'refcursor',
138
        'regclass',
139
        'regoper',
140
        'regoperator',
141
        'regproc',
142
        'regprocedure',
143
        'regtype',
144
        'reltime',
145
        'serial',
146
        'smgr',
147
        'text',
148
        'tid',
149
        'tinterval',
150
        'tsquery',
151
        'tsvector',
152
        'varbit',
153
        'void',
154
        'xid',
155
    ];
156
    // List of all legal privileges that can be applied to different types
157
    // of objects.
158
    public $privlist = [
159
        'table'      => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
160
        'view'       => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
161
        'sequence'   => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'],
162
        'database'   => ['CREATE', 'TEMPORARY', 'CONNECT', 'ALL PRIVILEGES'],
163
        'function'   => ['EXECUTE', 'ALL PRIVILEGES'],
164
        'language'   => ['USAGE', 'ALL PRIVILEGES'],
165
        'schema'     => ['CREATE', 'USAGE', 'ALL PRIVILEGES'],
166
        'tablespace' => ['CREATE', 'ALL PRIVILEGES'],
167
        'column'     => ['SELECT', 'INSERT', 'UPDATE', 'REFERENCES', 'ALL PRIVILEGES'],
168
    ];
169
    // List of characters in acl lists and the privileges they
170
    // refer to.
171
    public $privmap = [
172
        'r' => 'SELECT',
173
        'w' => 'UPDATE',
174
        'a' => 'INSERT',
175
        'd' => 'DELETE',
176
        'D' => 'TRUNCATE',
177
        'R' => 'RULE',
178
        'x' => 'REFERENCES',
179
        't' => 'TRIGGER',
180
        'X' => 'EXECUTE',
181
        'U' => 'USAGE',
182
        'C' => 'CREATE',
183
        'T' => 'TEMPORARY',
184
        'c' => 'CONNECT',
185
    ];
186
    // Rule action types
187
    public $rule_events = ['SELECT', 'INSERT', 'UPDATE', 'DELETE'];
188
    // Select operators
189
    public $selectOps = [
190
        '='                   => 'i',
191
        '!='                  => 'i',
192
        '<'                   => 'i',
193
        '>'                   => 'i',
194
        '<='                  => 'i',
195
        '>='                  => 'i',
196
        '<<'                  => 'i',
197
        '>>'                  => 'i',
198
        '<<='                 => 'i',
199
        '>>='                 => 'i',
200
        'LIKE'                => 'i',
201
        'NOT LIKE'            => 'i',
202
        'ILIKE'               => 'i',
203
        'NOT ILIKE'           => 'i',
204
        'SIMILAR TO'          => 'i',
205
        'NOT SIMILAR TO'      => 'i',
206
        '~'                   => 'i',
207
        '!~'                  => 'i',
208
        '~*'                  => 'i',
209
        '!~*'                 => 'i',
210
        'IS NULL'             => 'p',
211
        'IS NOT NULL'         => 'p',
212
        'IN'                  => 'x',
213
        'NOT IN'              => 'x',
214
        '@@'                  => 'i',
215
        '@@@'                 => 'i',
216
        '@>'                  => 'i',
217
        '<@'                  => 'i',
218
        '@@ to_tsquery'       => 't',
219
        '@@@ to_tsquery'      => 't',
220
        '@> to_tsquery'       => 't',
221
        '<@ to_tsquery'       => 't',
222
        '@@ plainto_tsquery'  => 't',
223
        '@@@ plainto_tsquery' => 't',
224
        '@> plainto_tsquery'  => 't',
225
        '<@ plainto_tsquery'  => 't',
226
    ];
227
    // Array of allowed trigger events
228
    public $triggerEvents = [
229
        'INSERT',
230
        'UPDATE',
231
        'DELETE',
232
        'INSERT OR UPDATE',
233
        'INSERT OR DELETE',
234
        'DELETE OR UPDATE',
235
        'INSERT OR DELETE OR UPDATE',
236
    ];
237
    // When to execute the trigger
238
    public $triggerExecTimes = ['BEFORE', 'AFTER'];
239
    // How often to execute the trigger
240
    public $triggerFrequency = ['ROW', 'STATEMENT'];
241
    // Array of allowed type alignments
242
    public $typAligns = ['char', 'int2', 'int4', 'double'];
243
    // The default type alignment
244
    public $typAlignDef = 'int4';
245
    // Default index type
246
    public $typIndexDef = 'BTREE';
247
    // Array of allowed index types
248
    public $typIndexes = ['BTREE', 'RTREE', 'GIST', 'GIN', 'HASH'];
249
    // Array of allowed type storage attributes
250
    public $typStorages = ['plain', 'external', 'extended', 'main'];
251
    // The default type storage
252
    public $typStorageDef = 'plain';
253
    /**
254
     * Determines if it has tablespaces.
255
     *
256
     * @return bool true if has tablespaces, False otherwise
257
     */
258
    public function hasTablespaces()
259
    {
260
        return true;
261
    }
262
263
    /**
264
     * Determines if it has shared comments.
265
     *
266
     * @return bool true if has shared comments, False otherwise
267
     */
268
    public function hasSharedComments()
269
    {
270
        return true;
271
    }
272
273
    /**
274
     * Determines if it has roles.
275
     *
276
     * @return bool true if has roles, False otherwise
277
     */
278
    public function hasRoles()
279
    {
280
        return true;
281
    }
282
283
    /**
284
     * Determines if it has grant option.
285
     *
286
     * @return bool true if has grant option, False otherwise
287
     */
288
    public function hasGrantOption()
289
    {
290
        return true;
291
    }
292
293
    /**
294
     * Determines if it has create table like with constraints.
295
     *
296
     * @return bool true if has create table like with constraints, False otherwise
297
     */
298
    public function hasCreateTableLikeWithConstraints()
299
    {
300
        return true;
301
    }
302
303
    /**
304
     * Determines if it has create table like with indexes.
305
     *
306
     * @return bool true if has create table like with indexes, False otherwise
307
     */
308
    public function hasCreateTableLikeWithIndexes()
309
    {
310
        return true;
311
    }
312
313
    /**
314
     * Determines if it has create field with constraints.
315
     *
316
     * @return bool true if has create field with constraints, False otherwise
317
     */
318
    public function hasCreateFieldWithConstraints()
319
    {
320
        return true;
321
    }
322
323
    /**
324
     * Determines if it has domain constraints.
325
     *
326
     * @return bool true if has domain constraints, False otherwise
327
     */
328
    public function hasDomainConstraints()
329
    {
330
        return true;
331
    }
332
333
    /**
334
     * Determines if it has function alter owner.
335
     *
336
     * @return bool true if has function alter owner, False otherwise
337
     */
338
    public function hasFunctionAlterOwner()
339
    {
340
        return true;
341
    }
342
343
    /**
344
     * Determines if it has function alter schema.
345
     *
346
     * @return bool true if has function alter schema, False otherwise
347
     */
348
    public function hasFunctionAlterSchema()
349
    {
350
        return true;
351
    }
352
353
    /**
354
     * Determines if it has read only queries.
355
     *
356
     * @return bool true if has read only queries, False otherwise
357
     */
358
    public function hasReadOnlyQueries()
359
    {
360
        return true;
361
    }
362
363
    /**
364
     * Determines if it has aggregate sort operation.
365
     *
366
     * @return bool true if has aggregate sort operation, False otherwise
367
     */
368
    public function hasAggregateSortOp()
369
    {
370
        return true;
371
    }
372
373
    /**
374
     * Determines if it has alter aggregate.
375
     *
376
     * @return bool true if has alter aggregate, False otherwise
377
     */
378
    public function hasAlterAggregate()
379
    {
380
        return true;
381
    }
382
383
    /**
384
     * Determines if it has alter column type.
385
     *
386
     * @return bool true if has alter column type, False otherwise
387
     */
388
    public function hasAlterColumnType()
389
    {
390
        return true;
391
    }
392
393
    /**
394
     * Determines if it has alter database owner.
395
     *
396
     * @return bool true if has alter database owner, False otherwise
397
     */
398
    public function hasAlterDatabaseOwner()
399
    {
400
        return true;
401
    }
402
403
    /**
404
     * Determines if it has alter schema.
405
     *
406
     * @return bool true if has alter schema, False otherwise
407
     */
408
    public function hasAlterSchema()
409
    {
410
        return true;
411
    }
412
413
    /**
414
     * Determines if it has alter schema owner.
415
     *
416
     * @return bool true if has alter schema owner, False otherwise
417
     */
418
    public function hasAlterSchemaOwner()
419
    {
420
        return true;
421
    }
422
423
    /**
424
     * Determines if it has alter sequence schema.
425
     *
426
     * @return bool true if has alter sequence schema, False otherwise
427
     */
428
    public function hasAlterSequenceSchema()
429
    {
430
        return true;
431
    }
432
433
    /**
434
     * Determines if it has alter sequence start.
435
     *
436
     * @return bool true if has alter sequence start, False otherwise
437
     */
438
    public function hasAlterSequenceStart()
439
    {
440
        return true;
441
    }
442
443
    /**
444
     * Determines if it has alter table schema.
445
     *
446
     * @return bool true if has alter table schema, False otherwise
447
     */
448
    public function hasAlterTableSchema()
449
    {
450
        return true;
451
    }
452
453
    /**
454
     * Determines if it has autovacuum.
455
     *
456
     * @return bool true if has autovacuum, False otherwise
457
     */
458
    public function hasAutovacuum()
459
    {
460
        return true;
461
    }
462
463
    /**
464
     * Determines if it has create table like.
465
     *
466
     * @return bool true if has create table like, False otherwise
467
     */
468
    public function hasCreateTableLike()
469
    {
470
        return true;
471
    }
472
473
    /**
474
     * Determines if it has disable triggers.
475
     *
476
     * @return bool true if has disable triggers, False otherwise
477
     */
478
    public function hasDisableTriggers()
479
    {
480
        return true;
481
    }
482
483
    /**
484
     * Determines if it has alter domains.
485
     *
486
     * @return bool true if has alter domains, False otherwise
487
     */
488
    public function hasAlterDomains()
489
    {
490
        return true;
491
    }
492
493
    /**
494
     * Determines if it has enum types.
495
     *
496
     * @return bool true if has enum types, False otherwise
497
     */
498
    public function hasEnumTypes()
499
    {
500
        return true;
501
    }
502
503
    /**
504
     * Determines if it has fts.
505
     *
506
     * @return bool true if has fts, False otherwise
507
     */
508
    public function hasFTS()
509
    {
510
        return true;
511
    }
512
513
    /**
514
     * Determines if it has function costing.
515
     *
516
     * @return bool true if has function costing, False otherwise
517
     */
518
    public function hasFunctionCosting()
519
    {
520
        return true;
521
    }
522
523
    /**
524
     * Determines if it has function guc.
525
     *
526
     * @return bool true if has function guc, False otherwise
527
     */
528
    public function hasFunctionGUC()
529
    {
530
        return true;
531
    }
532
533
    /**
534
     * Determines if it has named parameters.
535
     *
536
     * @return bool true if has named parameters, False otherwise
537
     */
538
    public function hasNamedParams()
539
    {
540
        return true;
541
    }
542
543
    /**
544
     * Determines if it has prepare.
545
     *
546
     * @return bool true if has prepare, False otherwise
547
     */
548
    public function hasPrepare()
549
    {
550
        return true;
551
    }
552
553
    /**
554
     * Determines if it has prepared xacts.
555
     *
556
     * @return bool true if has prepared xacts, False otherwise
557
     */
558
    public function hasPreparedXacts()
559
    {
560
        return true;
561
    }
562
563
    /**
564
     * Determines if it has recluster.
565
     *
566
     * @return bool true if has recluster, False otherwise
567
     */
568
    public function hasRecluster()
569
    {
570
        return true;
571
    }
572
573
    /**
574
     * Determines if it has server admin funcs.
575
     *
576
     * @return bool true if has server admin funcs, False otherwise
577
     */
578
    public function hasServerAdminFuncs()
579
    {
580
        return true;
581
    }
582
583
    /**
584
     * Determines if it has query cancel.
585
     *
586
     * @return bool true if has query cancel, False otherwise
587
     */
588
    public function hasQueryCancel()
589
    {
590
        return true;
591
    }
592
593
    /**
594
     * Determines if it has user rename.
595
     *
596
     * @return bool true if has user rename, False otherwise
597
     */
598
    public function hasUserRename()
599
    {
600
        return true;
601
    }
602
603
    /**
604
     * Determines if it has user signals.
605
     *
606
     * @return bool true if has user signals, False otherwise
607
     */
608
    public function hasUserSignals()
609
    {
610
        return true;
611
    }
612
613
    /**
614
     * Determines if it has virtual transaction identifier.
615
     *
616
     * @return bool true if has virtual transaction identifier, False otherwise
617
     */
618
    public function hasVirtualTransactionId()
619
    {
620
        return true;
621
    }
622
623
    /**
624
     * Determines if it has alter database.
625
     *
626
     * @return bool true if has alter database, False otherwise
627
     */
628
    public function hasAlterDatabase()
629
    {
630
        return $this->hasAlterDatabaseRename();
631
    }
632
633
    /**
634
     * Determines if it has alter database rename.
635
     *
636
     * @return bool true if has alter database rename, False otherwise
637
     */
638
    public function hasAlterDatabaseRename()
639
    {
640
        return true;
641
    }
642
643
    /**
644
     * Determines if it has database collation.
645
     *
646
     * @return bool true if has database collation, False otherwise
647
     */
648
    public function hasDatabaseCollation()
649
    {
650
        return true;
651
    }
652
653
    /**
654
     * Determines if it has magic types.
655
     *
656
     * @return bool true if has magic types, False otherwise
657
     */
658
    public function hasMagicTypes()
659
    {
660
        return true;
661
    }
662
663
    /**
664
     * Determines if it has query kill.
665
     *
666
     * @return bool true if has query kill, False otherwise
667
     */
668
    public function hasQueryKill()
669
    {
670
        return true;
671
    }
672
673
    /**
674
     * Determines if it has concurrent index build.
675
     *
676
     * @return bool true if has concurrent index build, False otherwise
677
     */
678
    public function hasConcurrentIndexBuild()
679
    {
680
        return true;
681
    }
682
683
    /**
684
     * Determines if it has force reindex.
685
     *
686
     * @return bool true if has force reindex, False otherwise
687
     */
688
    public function hasForceReindex()
689
    {
690
        return false;
691
    }
692
693
    /**
694
     * Determines if it has bytea hexadecimal default.
695
     *
696
     * @return bool true if has bytea hexadecimal default, False otherwise
697
     */
698
    public function hasByteaHexDefault()
699
    {
700
        return true;
701
    }
702
}
703