3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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
49 static $soap_timeout = 0;
52 * Cache the actual UF Class
57 * Class constructor. This caches the real user framework class locally,
58 * so we can use it for authentication and validation.
60 * @internal param string $uf The userframework class
62 public function __construct() {
63 // any external program which call SoapServer is responsible for
64 // creating and attaching the session
65 $args = func_get_args();
66 $this->ufClass
= array_shift($args);
70 * Simple ping function to test for liveness.
73 * The string to be echoed.
77 public function ping($var) {
78 $session = CRM_Core_Session
::singleton();
79 $key = $session->get('key');
80 $session->set('key', $var);
81 return "PONG: $var ($key)";
88 * The soap key generated by authenticate().
93 public function verify($key) {
94 $session = CRM_Core_Session
::singleton();
96 $soap_key = $session->get('soap_key');
99 if ($key !== sha1($soap_key)) {
100 throw new SoapFault('Client', 'Invalid key');
103 if (self
::$soap_timeout &&
104 $t > ($session->get('soap_time') + self
::$soap_timeout)
106 throw new SoapFault('Client', 'Expired key');
109 /* otherwise, we're ok. update the timestamp */
111 $session->set('soap_time', $t);
115 * Authentication wrapper to the UF Class.
117 * @param string $name
119 * @param string $pass
122 * @param bool $loadCMSBootstrap
126 * The SOAP Client key
128 public function authenticate($name, $pass, $loadCMSBootstrap = FALSE) {
129 require_once str_replace('_', DIRECTORY_SEPARATOR
, $this->ufClass
) . '.php';
131 if ($this->ufClass
== 'CRM_Utils_System_Joomla') {
132 $loadCMSBootstrap = TRUE;
135 $className = $this->ufClass
;
136 $result =& $className::authenticate($name, $pass, $loadCMSBootstrap);
138 if (empty($result)) {
139 throw new SoapFault('Client', 'Invalid login');
142 $session = CRM_Core_Session
::singleton();
143 $session->set('soap_key', $result[2]);
144 $session->set('soap_time', time());
146 return sha1($result[2]);
152 public function mailer_event_bounce($key, $job, $queue, $hash, $body) {
156 'time_stamp' => date('YmdHis'),
157 'event_queue_id' => $queue,
162 return civicrm_api('Mailing', 'event_bounce', $params);
174 public function mailer_event_unsubscribe($key, $job, $queue, $hash) {
178 'time_stamp' => date('YmdHis'),
179 'org_unsubscribe' => 0,
180 'event_queue_id' => $queue,
184 return civicrm_api('MailingGroup', 'event_unsubscribe', $params);
196 public function mailer_event_domain_unsubscribe($key, $job, $queue, $hash) {
200 'time_stamp' => date('YmdHis'),
201 'org_unsubscribe' => 1,
202 'event_queue_id' => $queue,
206 return civicrm_api('MailingGroup', 'event_domain_unsubscribe', $params);
218 public function mailer_event_resubscribe($key, $job, $queue, $hash) {
222 'time_stamp' => date('YmdHis'),
223 'org_unsubscribe' => 0,
224 'event_queue_id' => $queue,
228 return civicrm_api('MailingGroup', 'event_resubscribe', $params);
240 public function mailer_event_subscribe($key, $email, $domain, $group) {
244 'group_id' => $group,
247 return civicrm_api('MailingGroup', 'event_subscribe', $params);
259 public function mailer_event_confirm($key, $contact, $subscribe, $hash) {
262 'contact_id' => $contact,
263 'subscribe_id' => $subscribe,
264 'time_stamp' => date('YmdHis'),
265 'event_subscribe_id' => $subscribe,
269 return civicrm_api('Mailing', 'event_confirm', $params);
279 * @param null $bodyHTML
280 * @param null $fullEmail
285 public function mailer_event_reply($key, $job, $queue, $hash, $bodyTxt, $rt, $bodyHTML = NULL, $fullEmail = NULL) {
289 'event_queue_id' => $queue,
291 'bodyTxt' => $bodyTxt,
293 'bodyHTML' => $bodyHTML,
294 'fullEmail' => $fullEmail,
295 'time_stamp' => date('YmdHis'),
298 return civicrm_api('Mailing', 'event_reply', $params);
311 public function mailer_event_forward($key, $job, $queue, $hash, $email) {
315 'event_queue_id' => $queue,
320 return civicrm_api('Mailing', 'event_forward', $params);
325 * @param array $params
330 public function get_contact($key, $params) {
332 $params['version'] = 3;
333 return civicrm_api('contact', 'get', $params);