15b528b246579aad073046a4484b9647670df9b5
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 +--------------------------------------------------------------------+
29 * This class handles all SOAP client requests.
32 * @copyright CiviCRM LLC (c) 2004-2015
34 class CRM_Utils_SoapServer
{
37 * Number of seconds we should let a soap process idle
39 static $soap_timeout = 0;
42 * Cache the actual UF Class
47 * Class constructor. This caches the real user framework class locally,
48 * so we can use it for authentication and validation.
50 * @internal param string $uf The userframework class
52 public function __construct() {
53 // any external program which call SoapServer is responsible for
54 // creating and attaching the session
55 $args = func_get_args();
56 $this->ufClass
= array_shift($args);
60 * Simple ping function to test for liveness.
63 * The string to be echoed.
67 public function ping($var) {
68 $session = CRM_Core_Session
::singleton();
69 $key = $session->get('key');
70 $session->set('key', $var);
71 return "PONG: $var ($key)";
78 * The soap key generated by authenticate().
82 public function verify($key) {
83 $session = CRM_Core_Session
::singleton();
85 $soap_key = $session->get('soap_key');
88 if ($key !== sha1($soap_key)) {
89 throw new SoapFault('Client', 'Invalid key');
92 if (self
::$soap_timeout &&
93 $t > ($session->get('soap_time') + self
::$soap_timeout)
95 throw new SoapFault('Client', 'Expired key');
98 // otherwise, we're ok. update the timestamp
100 $session->set('soap_time', $t);
104 * Authentication wrapper to the UF Class.
106 * @param string $name
108 * @param string $pass
111 * @param bool $loadCMSBootstrap
115 * The SOAP Client key
117 public function authenticate($name, $pass, $loadCMSBootstrap = FALSE) {
118 require_once str_replace('_', DIRECTORY_SEPARATOR
, $this->ufClass
) . '.php';
120 if ($this->ufClass
== 'CRM_Utils_System_Joomla') {
121 $loadCMSBootstrap = TRUE;
124 $className = $this->ufClass
;
125 $result =& $className::authenticate($name, $pass, $loadCMSBootstrap);
127 if (empty($result)) {
128 throw new SoapFault('Client', 'Invalid login');
131 $session = CRM_Core_Session
::singleton();
132 $session->set('soap_key', $result[2]);
133 $session->set('soap_time', time());
135 return sha1($result[2]);
141 public function mailer_event_bounce($key, $job, $queue, $hash, $body) {
145 'time_stamp' => date('YmdHis'),
146 'event_queue_id' => $queue,
151 return civicrm_api('Mailing', 'event_bounce', $params);
163 public function mailer_event_unsubscribe($key, $job, $queue, $hash) {
167 'time_stamp' => date('YmdHis'),
168 'org_unsubscribe' => 0,
169 'event_queue_id' => $queue,
173 return civicrm_api('MailingGroup', 'event_unsubscribe', $params);
185 public function mailer_event_domain_unsubscribe($key, $job, $queue, $hash) {
189 'time_stamp' => date('YmdHis'),
190 'org_unsubscribe' => 1,
191 'event_queue_id' => $queue,
195 return civicrm_api('MailingGroup', 'event_domain_unsubscribe', $params);
207 public function mailer_event_resubscribe($key, $job, $queue, $hash) {
211 'time_stamp' => date('YmdHis'),
212 'org_unsubscribe' => 0,
213 'event_queue_id' => $queue,
217 return civicrm_api('MailingGroup', 'event_resubscribe', $params);
229 public function mailer_event_subscribe($key, $email, $domain, $group) {
233 'group_id' => $group,
236 return civicrm_api('MailingGroup', 'event_subscribe', $params);
248 public function mailer_event_confirm($key, $contact, $subscribe, $hash) {
251 'contact_id' => $contact,
252 'subscribe_id' => $subscribe,
253 'time_stamp' => date('YmdHis'),
254 'event_subscribe_id' => $subscribe,
258 return civicrm_api('Mailing', 'event_confirm', $params);
268 * @param null $bodyHTML
269 * @param null $fullEmail
274 public function mailer_event_reply($key, $job, $queue, $hash, $bodyTxt, $rt, $bodyHTML = NULL, $fullEmail = NULL) {
278 'event_queue_id' => $queue,
280 'bodyTxt' => $bodyTxt,
282 'bodyHTML' => $bodyHTML,
283 'fullEmail' => $fullEmail,
284 'time_stamp' => date('YmdHis'),
287 return civicrm_api('Mailing', 'event_reply', $params);
300 public function mailer_event_forward($key, $job, $queue, $hash, $email) {
304 'event_queue_id' => $queue,
309 return civicrm_api('Mailing', 'event_forward', $params);
314 * @param array $params
319 public function get_contact($key, $params) {
321 $params['version'] = 3;
322 return civicrm_api('contact', 'get', $params);