forked from civicrm/civicrm-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBase.php
1181 lines (1067 loc) · 29 KB
/
Base.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Base class for UF system integrations
*/
abstract class CRM_Utils_System_Base {
/**
* Deprecated property to check if this is a drupal install.
*
* The correct method is to have functions on the UF classes for all UF specific
* functions and leave the codebase oblivious to the type of CMS
*
* @var bool
* @deprecated
* TRUE, if the CMS is Drupal.
*/
public $is_drupal = FALSE;
/**
* Deprecated property to check if this is a joomla install. The correct method is to have functions on the UF classes for all UF specific
* functions and leave the codebase oblivious to the type of CMS
*
* @var bool
* @deprecated
* TRUE, if the CMS is Joomla!.
*/
public $is_joomla = FALSE;
/**
* deprecated property to check if this is a wordpress install. The correct method is to have functions on the UF classes for all UF specific
* functions and leave the codebase oblivious to the type of CMS
*
* @var bool
* @deprecated
* TRUE, if the CMS is WordPress.
*/
public $is_wordpress = FALSE;
/**
* Does this CMS / UF support a CMS specific logging mechanism?
* @var bool
* @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions
*/
public $supports_UF_Logging = FALSE;
/**
* @var bool
* TRUE, if the CMS allows CMS forms to be extended by hooks.
*/
public $supports_form_extensions = FALSE;
public function initialize() {
if (\CRM_Utils_System::isSSL()) {
$this->mapConfigToSSL();
}
}
abstract public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL);
/**
* Append an additional breadcrumb tag to the existing breadcrumb.
*
* @param array $breadCrumbs
*/
public function appendBreadCrumb($breadCrumbs) {
}
/**
* Reset an additional breadcrumb tag to the existing breadcrumb.
*/
public function resetBreadCrumb() {
}
/**
* Append a string to the head of the html file.
*
* @param string $head
* The new string to be appended.
*/
public function addHTMLHead($head) {
}
/**
* Rewrite various system urls to https.
*/
public function mapConfigToSSL() {
// dont need to do anything, let CMS handle their own switch to SSL
}
/**
* Figure out the post url for QuickForm.
*
* @param string $action
* The default url if one is pre-specified.
*
* @return string
* The url to post the form.
*/
public function postURL($action) {
$config = CRM_Core_Config::singleton();
if (!empty($action)) {
return $action;
}
return $this->url(CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET),
NULL, TRUE, NULL, FALSE
);
}
/**
* Generate the url string to a CiviCRM path.
*
* @param string $path
* The path being linked to, such as "civicrm/add".
* @param string $query
* A query string to append to the link.
* @param bool $absolute
* Whether to force the output to be an absolute link (beginning with http).
* Useful for links that will be displayed outside the site, such as in an RSS feed.
* @param string $fragment
* A fragment identifier (named anchor) to append to the link.
* @param bool $frontend
* This link should be to the CMS front end (applies to WP & Joomla).
* @param bool $forceBackend
* This link should be to the CMS back end (applies to WP & Joomla).
*
* @return string
*/
abstract public function url(
$path = NULL,
$query = NULL,
$absolute = FALSE,
$fragment = NULL,
$frontend = FALSE,
$forceBackend = FALSE
);
/**
* Compose the URL for a page/route.
*
* @internal
* @see \Civi\Core\Url::__toString
* @param string $scheme
* Ex: 'frontend', 'backend', 'service'
* @param string $path
* Ex: 'civicrm/event/info'
* @param string|null $query
* Ex: 'id=100&msg=Hello+world'
* @return string|null
* Absolute URL, or NULL if scheme is unsupported.
* Ex: 'https://subdomain.example.com/index.php?q=civicrm/event/info&id=100&msg=Hello+world'
*/
public function getRouteUrl(string $scheme, string $path, ?string $query): ?string {
switch ($scheme) {
case 'frontend':
return $this->url($path, $query, TRUE, NULL, TRUE, FALSE, FALSE);
case 'service':
// The original `url()` didn't have an analog for "service://". But "frontend" is probably the closer bet?
// Or maybe getNotifyUrl() makes sense?
return $this->url($path, $query, TRUE, NULL, TRUE, FALSE, FALSE);
case 'backend':
return $this->url($path, $query, TRUE, NULL, FALSE, TRUE, FALSE);
// If the UF defines other major UI/URL conventions, then you might hypothetically handle
// additional schemes.
default:
return NULL;
}
}
/**
* Return the Notification URL for Payments.
*
* The default is to pass the params through to `url()`. However the WordPress
* CMS class overrides this method because Notification URLs must always target
* the Base Page to avoid IPN failures when Forms are embedded in pages that
* require authentication.
*
* @param string $path
* The path being linked to, such as "civicrm/add".
* @param string $query
* A query string to append to the link.
* @param bool $absolute
* Whether to force the output to be an absolute link (beginning with http).
* Useful for links that will be displayed outside the site, such as in an RSS feed.
* @param string $fragment
* A fragment identifier (named anchor) to append to the link.
* @param bool $frontend
* This link should be to the CMS front end (applies to WP & Joomla).
* @param bool $forceBackend
* This link should be to the CMS back end (applies to WP & Joomla).
*
* @return string
* The Notification URL.
*/
public function getNotifyUrl(
$path = NULL,
$query = NULL,
$absolute = FALSE,
$fragment = NULL,
$frontend = FALSE,
$forceBackend = FALSE
) {
return $this->url($path, $query, $absolute, $fragment, $frontend, $forceBackend);
}
/**
* Authenticate the user against the CMS db.
*
* @param string $name
* The user name.
* @param string $password
* The password for the above user.
* @param bool $loadCMSBootstrap
* Load cms bootstrap?.
* @param string $realPath
* Filename of script
*
* @return array|bool
* [contactID, ufID, unique string] else false if no auth
* @throws \CRM_Core_Exception.
*/
public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
return FALSE;
}
/**
* Set a message in the CMS to display to a user.
*
* @param string $message
* The message to set.
*/
public function setMessage($message) {
}
/**
* Load user into session.
*
* @param obj $user
*
* @return bool
*/
public function loadUser($user) {
return TRUE;
}
/**
* Immediately stop script execution and display a 401 "Access Denied" page.
* @throws \CRM_Core_Exception
*/
public function permissionDenied() {
throw new CRM_Core_Exception(ts('You do not have permission to access this page.'));
}
/**
* Immediately stop script execution, log out the user and redirect to the home page.
*
* @deprecated
* This function should be removed in favor of linking to the CMS's logout page
*/
public function logout() {
}
/**
* Clear CMS caches related to the user registration/profile forms.
* Used when updating/embedding profiles on CMS user forms.
* @see CRM-3600
*/
public function updateCategories() {
}
/**
* Get the locale set in the CMS.
*
* @return string|null
* Locale or null for none
*/
public function getUFLocale() {
return NULL;
}
/**
* If we are using a theming system, invoke theme, else just print the content.
*
* @param string $content
* The content that will be themed.
* @param bool $print
* Are we displaying to the screen or bypassing theming?.
* @param bool $maintenance
* For maintenance mode.
*
* @throws Exception
* @return string|null
* NULL, If $print is FALSE, and some other criteria match up.
* The themed string, otherwise.
*
* @todo The return value is inconsistent.
* @todo Better to always return, and never print.
*/
public function theme(&$content, $print = FALSE, $maintenance = FALSE) {
print $content;
return NULL;
}
/**
* @return string
*/
public function getDefaultBlockLocation() {
return 'left';
}
/**
* Get the absolute path to the site's base url.
*
* @return bool|mixed|string
*/
public function getAbsoluteBaseURL() {
if (!defined('CIVICRM_UF_BASEURL')) {
return FALSE;
}
$url = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/');
//format url for language negotiation, CRM-7803
$url = $this->languageNegotiationURL($url);
if (CRM_Utils_System::isSSL()) {
$url = str_replace('http://', 'https://', $url);
}
return $url;
}
/**
* Get the relative path to the sites base url.
*
* @return string|false
*/
public function getRelativeBaseURL() {
$absoluteBaseURL = $this->getAbsoluteBaseURL();
if ($absoluteBaseURL === FALSE) {
return FALSE;
}
$parts = parse_url($absoluteBaseURL);
return $parts['path'];
//$this->useFrameworkRelativeBase = empty($base['path']) ? '/' : $base['path'];
}
/**
* Get CMS Version.
*
* @return string
*/
public function getVersion() {
return 'Unknown';
}
/**
* Format the url as per language Negotiation.
*
* @param string $url
* @param bool $addLanguagePart
* @param bool $removeLanguagePart
*
* @return string
* Formatted url.
*/
public function languageNegotiationURL(
$url,
$addLanguagePart = TRUE,
$removeLanguagePart = FALSE
) {
return $url;
}
/**
* Determine the location of the CMS root.
*
* @return string|null
* Local file system path to CMS root, or NULL if it cannot be determined
*/
public function cmsRootPath() {
return NULL;
}
/**
* Create a user in the CMS.
*
* @param array $params
* @param string $mailParam
* Name of the $param which contains the email address.
* Because. Right. OK. That's what it is.
*
* @return int|bool
* uid if user exists, false otherwise
*/
public function createUser(&$params, $mailParam) {
return FALSE;
}
/**
* Update a user's email address in the CMS.
*
* @param int $ufID
* User ID in CMS.
* @param string $email
* Primary contact email address.
*/
public function updateCMSName($ufID, $email) {
}
/**
* Check if user is logged in to the CMS.
*
* @return bool
*/
public function isUserLoggedIn() {
return FALSE;
}
/**
* Check if user registration is permitted.
*
* @return bool
*/
public function isUserRegistrationPermitted() {
return FALSE;
}
/**
* Check if user can create passwords or is initially assigned a system-generated one.
*
* @return bool
*/
public function isPasswordUserGenerated() {
return FALSE;
}
/**
* Verify password
*
* @param array $params
* Array of name, mail and password values.
* @param array $errors
* Array of errors.
*/
public function verifyPassword($params, &$errors) {
}
/**
* Is a front end page being accessed.
*
* Generally this would be a contribution form or other public page as opposed to a backoffice page (like contact edit).
*
* @todo Drupal uses the is_public setting - clarify & rationalise. See https://github.com/civicrm/civicrm-drupal/pull/546/files
*
* @return bool
*/
public function isFrontEndPage() {
return CRM_Core_Config::singleton()->userFrameworkFrontend;
}
/**
* Get user login URL for hosting CMS (method declared in each CMS system class)
*
* @param string $destination
* If present, add destination to querystring (works for Drupal and WordPress only).
*
* @return string
* loginURL for the current CMS
*/
abstract public function getLoginURL($destination = '');
/**
* Get the login destination string.
*
* When this is passed in the URL the user will be directed to it after filling in the CMS form.
*
* @param CRM_Core_Form $form
* Form object representing the 'current' form - to which the user will be returned.
*
* @return string|NULL
* destination value for URL
*/
public function getLoginDestination(&$form) {
return NULL;
}
/**
* Determine the native ID of the CMS user.
*
* @param string $username
*
* @throws CRM_Core_Exception
*/
public function getUfId($username) {
$className = get_class($this);
throw new CRM_Core_Exception("Not implemented: {$className}->getUfId");
}
/**
* Set the localisation from the user framework.
*
* @param string $civicrm_language
*
* @return bool
*/
public function setUFLocale($civicrm_language) {
return TRUE;
}
/**
* Set a init session with user object.
*
* @param array $data
* Array with user specific data
*/
public function setUserSession($data) {
list($userID, $ufID) = $data;
$session = CRM_Core_Session::singleton();
$session->set('ufID', $ufID);
$session->set('userID', $userID);
}
/**
* Reset any system caches that may be required for proper CiviCRM integration.
*/
public function flush() {
// nullop by default
}
/**
* Flush css/js caches.
*/
public function clearResourceCache() {
// nullop by default
}
/**
* Add a script file.
*
* Note: This function is not to be called directly
* @see CRM_Core_Region::render()
*
* @param string $url absolute path to file
* @param string $region
* location within the document: 'html-header', 'page-header', 'page-footer'.
*
* @return bool
* TRUE if we support this operation in this CMS, FALSE otherwise
*/
public function addScriptUrl($url, $region) {
return FALSE;
}
/**
* Add an inline script.
*
* Note: This function is not to be called directly
* @see CRM_Core_Region::render()
*
* @param string $code javascript code
* @param string $region
* location within the document: 'html-header', 'page-header', 'page-footer'.
*
* @return bool
* TRUE if we support this operation in this CMS, FALSE otherwise
*/
public function addScript($code, $region) {
return FALSE;
}
/**
* Add a css file.
*
* Note: This function is not to be called directly
* @see CRM_Core_Region::render()
*
* @param string $url absolute path to file
* @param string $region
* location within the document: 'html-header', 'page-header', 'page-footer'.
*
* @return bool
* TRUE if we support this operation in this CMS, FALSE otherwise
*/
public function addStyleUrl($url, $region) {
return FALSE;
}
/**
* Add an inline style.
*
* Note: This function is not to be called directly
* @see CRM_Core_Region::render()
*
* @param string $code css code
* @param string $region
* location within the document: 'html-header', 'page-header', 'page-footer'.
*
* @return bool
* TRUE if we support this operation in this CMS, FALSE otherwise
*/
public function addStyle($code, $region) {
return FALSE;
}
/**
* Sets the title of the page.
*
* @param string $title
* Title to set in html header
* @param string|null $pageTitle
* Title to set in html body (if different)
*/
public function setTitle($title, $pageTitle = NULL) {
}
/**
* Return default Site Settings.
*
* @param string $dir
*
* @return array
* - $url, (Joomla - non admin url)
* - $siteName,
* - $siteRoot
*/
public function getDefaultSiteSettings($dir) {
$config = CRM_Core_Config::singleton();
$url = $config->userFrameworkBaseURL;
return [$url, NULL, NULL];
}
/**
* Determine the default location for file storage.
*
* FIXME:
* 1. This was pulled out from a bigger function. It should be split
* into even smaller pieces and marked abstract.
* 2. This would be easier to compute by a calling a CMS API, but
* for whatever reason Civi gets it from config data.
*
* @return array
* - url: string. ex: "http://example.com/sites/foo.com/files/civicrm"
* - path: string. ex: "/var/www/sites/foo.com/files/civicrm"
*/
public function getDefaultFileStorage() {
global $civicrm_root;
$config = CRM_Core_Config::singleton();
$baseURL = CRM_Utils_System::languageNegotiationURL($config->userFrameworkBaseURL, FALSE, TRUE);
$filesURL = NULL;
$filesPath = NULL;
if ($config->userFramework == 'Joomla') {
// gross hack
// we need to remove the administrator/ from the end
$tempURL = str_replace("/administrator/", "/", $baseURL);
$filesURL = $tempURL . "media/civicrm/";
}
elseif ($config->userFramework == 'UnitTests') {
$filesURL = $baseURL . "sites/default/files/civicrm/";
}
else {
throw new CRM_Core_Exception("Failed to locate default file storage ($config->userFramework)");
}
return [
'url' => $filesURL,
'path' => CRM_Utils_File::baseFilePath(),
];
}
/**
* Determine the location of the CiviCRM source tree.
*
* @return array
* - url: string. ex: "http://example.com/sites/all/modules/civicrm"
* - path: string. ex: "/var/www/sites/all/modules/civicrm"
*/
abstract public function getCiviSourceStorage():array;
/**
* Perform any post login activities required by the CMS.
*
* e.g. for drupal: records a watchdog message about the new session, saves the login timestamp,
* calls hook_user op 'login' and generates a new session.
*
* @param array $params
*
* FIXME: Document values accepted/required by $params
*/
public function userLoginFinalize($params = []) {
}
/**
* Set timezone in mysql so that timestamp fields show the correct time.
*/
public function setMySQLTimeZone() {
$timeZoneOffset = $this->getTimeZoneOffset();
if ($timeZoneOffset) {
$sql = "SET time_zone = '$timeZoneOffset'";
CRM_Core_DAO::executeQuery($sql);
}
}
/**
* Get timezone from CMS.
*
* @return string|false|null
*/
public function getTimeZoneOffset() {
$timezone = $this->getTimeZoneString();
if ($timezone) {
if ($timezone == 'UTC' || $timezone == 'Etc/UTC') {
// CRM-17072 Let's short-circuit all the zero handling & return it here!
return '+00:00';
}
$tzObj = new DateTimeZone($timezone);
$dateTime = new DateTime("now", $tzObj);
$tz = $tzObj->getOffset($dateTime);
if ($tz === 0) {
// CRM-21422
return '+00:00';
}
if (empty($tz)) {
return FALSE;
}
$timeZoneOffset = sprintf("%02d:%02d", $tz / 3600, abs(($tz / 60) % 60));
if ($timeZoneOffset > 0) {
$timeZoneOffset = '+' . $timeZoneOffset;
}
return $timeZoneOffset;
}
return NULL;
}
/**
* Get timezone as a string.
* @return string
* Timezone string e.g. 'America/Los_Angeles'
*/
public function getTimeZoneString() {
return date_default_timezone_get();
}
/**
* Get Unique Identifier from UserFramework system (CMS).
*
* @param object $user
* Object as described by the User Framework.
*
* @return mixed
* Unique identifier from the user Framework system
*/
public function getUniqueIdentifierFromUserObject($user) {
return NULL;
}
/**
* Get User ID from UserFramework system (CMS).
*
* @param object $user
*
* Object as described by the User Framework.
* @return null|int
*/
public function getUserIDFromUserObject($user) {
return NULL;
}
/**
* Get an array of user details for a contact, containing at minimum the user ID & name.
*
* @param int $contactID
*
* @return array
* CMS user details including
* - id
* - name (ie the system user name.
*/
public function getUser($contactID) {
$ufMatch = civicrm_api3('UFMatch', 'getsingle', [
'contact_id' => $contactID,
'domain_id' => CRM_Core_Config::domainID(),
]);
return [
'id' => $ufMatch['uf_id'],
'name' => $ufMatch['uf_name'],
];
}
/**
* Get currently logged in user uf id.
*
* @return int|null
* logged in user uf id.
*/
public function getLoggedInUfID() {
return NULL;
}
/**
* Get currently logged in user unique identifier - this tends to be the email address or user name.
*
* @return string|null
* logged in user unique identifier
*/
public function getLoggedInUniqueIdentifier() {
return NULL;
}
/**
* Return a UFID (user account ID from the UserFramework / CMS system.
*
* ID is based on the user object passed, defaulting to the logged in user if not passed.
*
* Note that ambiguous situation occurs in CRM_Core_BAO_UFMatch::synchronize - a cleaner approach would
* seem to be resolving the user id before calling the function.
*
* Note there is already a function getUFId which takes $username as a param - we could add $user
* as a second param to it but it seems messy - just overloading it because the name is taken.
*
* @param object $user
*
* @return int
* User ID of UF System
*/
public function getBestUFID($user = NULL) {
if ($user) {
return $this->getUserIDFromUserObject($user);
}
return $this->getLoggedInUfID();
}
/**
* Return a unique identifier (usually an email address or username) from the UserFramework / CMS system.
*
* This is based on the user object passed, defaulting to the logged in user if not passed.
*
* Note that ambiguous situation occurs in CRM_Core_BAO_UFMatch::synchronize - a cleaner approach would seem to be
* resolving the unique identifier before calling the function.
*
* @param object $user
*
* @return string
* unique identifier from the UF System
*/
public function getBestUFUniqueIdentifier($user = NULL) {
if ($user) {
return $this->getUniqueIdentifierFromUserObject($user);
}
return $this->getLoggedInUniqueIdentifier();
}
/**
* List modules installed in the CMS, including enabled and disabled ones.
*
* @return array
* [CRM_Core_Module]
*/
public function getModules() {
return [];
}
/**
* Get Url to view user record.
*
* @param int $contactID
* Contact ID.
*
* @return string|null
*/
public function getUserRecordUrl($contactID) {
return NULL;
}
/**
* Is the current user permitted to add a user.
*
* @return bool
*/
public function checkPermissionAddUser() {
return FALSE;
}
/**
* Output code from error function.
*
* @param string $content
*/
public function outputError($content) {
echo CRM_Utils_System::theme($content);
}
/**
* Log error to CMS.
*
* @param string $message
* @param string|NULL $priority
*/
public function logger($message, $priority = NULL) {
}
/**
* Append to coreResourcesList.
*
* @param \Civi\Core\Event\GenericHookEvent $e
*/
public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
}
/**
* Modify dynamic assets.
*
* @param \Civi\Core\Event\GenericHookEvent $e
*/
public function alterAssetUrl(\Civi\Core\Event\GenericHookEvent $e) {
}
/**
* @param string $name
* @param string $value
*/
public function setHttpHeader($name, $value) {
header("$name: $value");
}
/**
* Create CRM contacts for all existing CMS users
*
* @return array
* @throws \Exception
*/
public function synchronizeUsers() {
throw new Exception('CMS user creation not supported for this framework');
return [];
}
/**
* Send an HTTP Response base on PSR HTTP RespnseInterface response.
*
* @param \Psr\Http\Message\ResponseInterface $response
*/
public function sendResponse(\Psr\Http\Message\ResponseInterface $response) {
http_response_code($response->getStatusCode());
foreach ($response->getHeaders() as $name => $values) {
CRM_Utils_System::setHttpHeader($name, implode(', ', (array) $values));
}
echo $response->getBody();
CRM_Utils_System::civiExit();
}
/**
* Start a new session.
*/
public function sessionStart() {
session_start();
}
/**
* This exists because of https://www.drupal.org/node/3006306 where
* they changed so that they don't start sessions for anonymous, but we
* want that.
*/
public function getSessionId() {
return session_id();
}
/**
* Get role names
*
* @return array|null
*/
public function getRoleNames() {
return NULL;
}
/**
* Determine if the Views module exists.
*
* @return bool
*/
public function viewsExists() {
return FALSE;
}
/**
* Perform any necessary actions prior to redirecting via POST.
*/
public function prePostRedirect() {
}