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