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