Merge pull request #15989 from seamuslee001/dev_core_523
[civicrm-core.git] / CRM / Utils / System / Soap.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Soap specific stuff goes here.
20 */
21 class CRM_Utils_System_Soap extends CRM_Utils_System_Base {
22
23 /**
24 * UF container variables.
25 * @var string
26 */
27 public static $uf = NULL;
28 public static $ufClass = NULL;
29
30 /**
31 * Given a permission string, check for access requirements
32 *
33 * @param string $str
34 * The permission to check.
35 *
36 * @return bool
37 * true if yes, else false
38 */
39 public function checkPermission($str) {
40 return TRUE;
41 }
42
43 /**
44 * @inheritDoc
45 */
46 public function url($path = NULL, $query = NULL, $absolute = TRUE, $fragment = NULL) {
47 if (isset(self::$ufClass)) {
48 $className = self::$ufClass;
49 $url = $className::url($path, $query, $absolute, $fragment);
50 return $url;
51 }
52 else {
53 return NULL;
54 }
55 }
56
57 /**
58 * FIXME: Can this override be removed in favor of the parent?
59 * @inheritDoc
60 */
61 public function postURL($action) {
62 return NULL;
63 }
64
65 /**
66 * Set the email address of the user.
67 *
68 * @param object $user
69 * Handle to the user object.
70 */
71 public function setEmail(&$user) {
72 }
73
74 /**
75 * @inheritDoc
76 */
77 public function authenticate($name, $pass) {
78 if (isset(self::$ufClass)) {
79 $className = self::$ufClass;
80 $result =& $className::authenticate($name, $pass);
81 return $result;
82 }
83 else {
84 return NULL;
85 }
86 }
87
88 /**
89 * Swap the current UF for soap.
90 */
91 public function swapUF() {
92 $config = CRM_Core_Config::singleton();
93
94 self::$uf = $config->userFramework;
95 $config->userFramework = 'Soap';
96
97 self::$ufClass = $config->userFrameworkClass;
98 $config->userFrameworkClass = 'CRM_Utils_System_Soap';
99 }
100
101 /**
102 * Get user login URL for hosting CMS (method declared in each CMS system class)
103 *
104 * @param string $destination
105 *
106 * @throws Exception
107 */
108 public function getLoginURL($destination = '') {
109 throw new Exception("Method not implemented: getLoginURL");
110 }
111
112 public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
113 // It makes zero sense for this class to extend CRM_Utils_System_Base.
114 throw new \RuntimeException("Not implemented");
115 }
116
117 }