3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * This class handles all SOAP client requests.
40 * @copyright CiviCRM LLC (c) 2004-2014
44 class CRM_Utils_SoapServer
{
47 * Number of seconds we should let a soap process idle
50 static $soap_timeout = 0;
53 * Cache the actual UF Class
58 * Class constructor. This caches the real user framework class locally,
59 * so we can use it for authentication and validation.
61 * @internal param string $uf The userframework class
63 public function __construct() {
64 // any external program which call SoapServer is responsible for
65 // creating and attaching the session
66 $args = func_get_args();
67 $this->ufClass
= array_shift($args);
71 * Simple ping function to test for liveness.
73 * @param string $var The string to be echoed
78 public function ping($var) {
79 $session = CRM_Core_Session
::singleton();
80 $key = $session->get('key');
81 $session->set('key', $var);
82 return "PONG: $var ($key)";
88 * @param string $key The soap key generated by authenticate()
94 public function verify($key) {
95 $session = CRM_Core_Session
::singleton();
97 $soap_key = $session->get('soap_key');
100 if ($key !== sha1($soap_key)) {
101 throw new SoapFault('Client', 'Invalid key');
105 if (self
::$soap_timeout &&
106 $t > ($session->get('soap_time') + self
::$soap_timeout)
108 throw new SoapFault('Client', 'Expired key');
111 /* otherwise, we're ok. update the timestamp */
113 $session->set('soap_time', $t);
117 * Authentication wrapper to the UF Class
119 * @param string $name Login name
120 * @param string $pass Password
122 * @param bool $loadCMSBootstrap
125 * @return string The SOAP Client key
129 public function authenticate($name, $pass, $loadCMSBootstrap = FALSE) {
130 require_once (str_replace('_', DIRECTORY_SEPARATOR
, $this->ufClass
) . '.php');
132 if ($this->ufClass
== 'CRM_Utils_System_Joomla'){
133 $loadCMSBootstrap = true;
136 $className = $this->ufClass
;
137 $result =& $className::authenticate($name, $pass, $loadCMSBootstrap );
139 if (empty($result)) {
140 throw new SoapFault('Client', 'Invalid login');
143 $session = CRM_Core_Session
::singleton();
144 $session->set('soap_key', $result[2]);
145 $session->set('soap_time', time());
147 return sha1($result[2]);
151 public function mailer_event_bounce($key, $job, $queue, $hash, $body) {
155 'time_stamp' => date('YmdHis'),
156 'event_queue_id' => $queue,
161 return civicrm_api('Mailing', 'event_bounce', $params);
173 public function mailer_event_unsubscribe($key, $job, $queue, $hash) {
177 'time_stamp' => date('YmdHis'),
178 'org_unsubscribe' => 0,
179 'event_queue_id' => $queue,
183 return civicrm_api('MailingGroup', 'event_unsubscribe', $params);
195 public function mailer_event_domain_unsubscribe($key, $job, $queue, $hash) {
199 'time_stamp' => date('YmdHis'),
200 'org_unsubscribe' => 1,
201 'event_queue_id' => $queue,
205 return civicrm_api('MailingGroup', 'event_domain_unsubscribe', $params);
217 public function mailer_event_resubscribe($key, $job, $queue, $hash) {
221 'time_stamp' => date('YmdHis'),
222 'org_unsubscribe' => 0,
223 'event_queue_id' => $queue,
227 return civicrm_api('MailingGroup', 'event_resubscribe', $params);
239 public function mailer_event_subscribe($key, $email, $domain, $group) {
243 'group_id' => $group,
246 return civicrm_api('MailingGroup', 'event_subscribe', $params);
258 public function mailer_event_confirm($key, $contact, $subscribe, $hash) {
261 'contact_id' => $contact,
262 'subscribe_id' => $subscribe,
263 'time_stamp' => date('YmdHis'),
264 'event_subscribe_id' => $subscribe,
268 return civicrm_api('Mailing', 'event_confirm', $params);
278 * @param null $bodyHTML
279 * @param null $fullEmail
284 public function mailer_event_reply($key, $job, $queue, $hash, $bodyTxt, $rt, $bodyHTML = NULL, $fullEmail = NULL) {
288 'event_queue_id' => $queue,
290 'bodyTxt' => $bodyTxt,
292 'bodyHTML' => $bodyHTML,
293 'fullEmail' => $fullEmail,
294 'time_stamp' => date('YmdHis'),
297 return civicrm_api('Mailing', 'event_reply', $params);
310 public function mailer_event_forward($key, $job, $queue, $hash, $email) {
314 'event_queue_id' => $queue,
319 return civicrm_api('Mailing', 'event_forward', $params);
329 public function get_contact($key, $params) {
331 $params['version'] = 3;
332 return civicrm_api('contact', 'get', $params);