Completed
Pull Request — master (#4)
by
unknown
02:20
created
src/Davispeixoto/ForceDotComToolkitForPhp/SforceBaseClient.php 1 patch
Indentation   +974 added lines, -974 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php namespace Davispeixoto\ForceDotComToolkitForPhp;
2 2
 
3
-    /*
3
+	/*
4 4
      * Copyright (c) 2007, salesforce.com, inc.
5 5
      * All rights reserved.
6 6
      *
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
      * POSSIBILITY OF SUCH DAMAGE.
27 27
      */
28 28
 
29
-    /**
30
-     * This file contains one class.
31
-     * @package SalesforceSoapClient
32
-     */
29
+	/**
30
+	 * This file contains one class.
31
+	 * @package SalesforceSoapClient
32
+	 */
33 33
 use SoapClient;
34 34
 use SoapHeader;
35 35
 use SoapVar;
@@ -42,1003 +42,1003 @@  discard block
 block discarded – undo
42 42
  */
43 43
 class SforceBaseClient
44 44
 {
45
-    protected $sforce;
46
-    protected $sessionId;
47
-    protected $location;
48
-    protected $version = '27.0';
49
-
50
-    protected $namespace;
51
-
52
-    // Header Options
53
-    protected $callOptions;
54
-    protected $assignmentRuleHeader;
55
-    protected $emailHeader;
56
-    protected $loginScopeHeader;
57
-    protected $mruHeader;
58
-    protected $queryHeader;
59
-    protected $userTerritoryDeleteHeader;
60
-    protected $sessionHeader;
61
-
62
-    // new headers
63
-    protected $allowFieldTruncationHeader;
64
-    protected $localeOptions;
65
-    protected $packageVersionHeader;
66
-
67
-    protected function getSoapClient($wsdl, $options)
68
-    {
69
-        return new SoapClient($wsdl, $options);
70
-    }
71
-
72
-    public function getNamespace()
73
-    {
74
-        return $this->namespace;
75
-    }
76
-
77
-
78
-    // clientId specifies which application or toolkit is accessing the
79
-    // salesforce.com API. For applications that are certified salesforce.com
80
-    // solutions, replace this with the value provided by salesforce.com.
81
-    // Otherwise, leave this value as 'phpClient/1.0'.
82
-    protected $client_id;
83
-
84
-    public function printDebugInfo()
85
-    {
86
-        echo 'PHP Toolkit Version: ' . $this->version . PHP_EOL;
87
-        echo 'Current PHP version: ' . phpversion();
88
-        echo PHP_EOL;
89
-        echo 'SOAP enabled: ';
90
-        if (extension_loaded('soap')) {
91
-            echo 'True';
92
-        } else {
93
-            echo 'False';
94
-        }
95
-        echo PHP_EOL;
96
-        echo 'OpenSSL enabled: ';
97
-        if (extension_loaded('openssl')) {
98
-            echo 'True';
99
-        } else {
100
-            echo 'False';
101
-        }
102
-    }
103
-
104
-    /**
105
-     * Connect method to www.salesforce.com
106
-     *
107
-     * @param string $wsdl Salesforce.com Partner WSDL
108
-     * @param object $proxy (optional) proxy settings with properties host, port,
109
-     *                       login and password
110
-     * @param array $soap_options (optional) Additional options to send to the
111
-     *                       SoapClient constructor. @see
112
-     *                       http://php.net/manual/en/soapclient.soapclient.php
113
-     */
114
-    public function createConnection($wsdl, $proxy = null, $soap_options = array())
115
-    {
116
-        // use correct version comparison
117
-        if (version_compare(phpversion(), '5.3', '<')) {
118
-            throw new Exception ('PHP versions older than 5.3 are no longer supported. Please upgrade!');
119
-        }
120
-
121
-        $soapClientArray = array_merge(array(
122
-            'user_agent' => 'salesforce-toolkit-php/' . $this->version,
123
-            'encoding' => 'utf-8',
124
-            'trace' => 1,
125
-            'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
126
-            'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP
127
-        ), $soap_options);
128
-
129
-
130
-        if ($proxy != null) {
131
-            $proxySettings = array();
132
-            $proxySettings['proxy_host'] = $proxy->host;
133
-            $proxySettings['proxy_port'] = $proxy->port; // Use an integer, not a string
134
-            $proxySettings['proxy_login'] = $proxy->login;
135
-            $proxySettings['proxy_password'] = $proxy->password;
136
-            $soapClientArray = array_merge($soapClientArray, $proxySettings);
137
-        }
138
-
139
-        $this->sforce = $this->getSoapClient($wsdl, $soapClientArray);
140
-
141
-        return $this->sforce;
142
-    }
143
-
144
-    public function setCallOptions($header)
145
-    {
146
-        if ($header != null) {
147
-            $this->callOptions = new SoapHeader($this->namespace, 'CallOptions', array(
148
-                'client' => $header->client,
149
-                'defaultNamespace' => $header->defaultNamespace
150
-            ));
151
-        } else {
152
-            $this->callOptions = null;
153
-        }
154
-    }
155
-
156
-    /**
157
-     * Login to Salesforce.com and starts a client session.
158
-     *
159
-     * @param string $username Username
160
-     * @param string $password Password
161
-     *
162
-     * @return LoginResult
163
-     */
164
-    public function login($username, $password)
165
-    {
166
-        $this->sforce->__setSoapHeaders(null);
167
-        if ($this->callOptions != null) {
168
-            $this->sforce->__setSoapHeaders(array($this->callOptions));
169
-        }
170
-        if ($this->loginScopeHeader != null) {
171
-            $this->sforce->__setSoapHeaders(array($this->loginScopeHeader));
172
-        }
173
-        $result = $this->sforce->login(array(
174
-            'username' => $username,
175
-            'password' => $password
176
-        ));
177
-        $result = $result->result;
178
-        $this->_setLoginHeader($result);
179
-
180
-        return $result;
181
-    }
182
-
183
-    /**
184
-     * log outs from the salseforce system`
185
-     *
186
-     * @return LogoutResult
187
-     */
188
-    public function logout()
189
-    {
190
-        $this->setHeaders("logout");
191
-        $arg = new stdClass();
45
+	protected $sforce;
46
+	protected $sessionId;
47
+	protected $location;
48
+	protected $version = '27.0';
49
+
50
+	protected $namespace;
51
+
52
+	// Header Options
53
+	protected $callOptions;
54
+	protected $assignmentRuleHeader;
55
+	protected $emailHeader;
56
+	protected $loginScopeHeader;
57
+	protected $mruHeader;
58
+	protected $queryHeader;
59
+	protected $userTerritoryDeleteHeader;
60
+	protected $sessionHeader;
61
+
62
+	// new headers
63
+	protected $allowFieldTruncationHeader;
64
+	protected $localeOptions;
65
+	protected $packageVersionHeader;
66
+
67
+	protected function getSoapClient($wsdl, $options)
68
+	{
69
+		return new SoapClient($wsdl, $options);
70
+	}
192 71
 
193
-        return $this->sforce->logout();
194
-    }
72
+	public function getNamespace()
73
+	{
74
+		return $this->namespace;
75
+	}
195 76
 
196
-    /**
197
-     *invalidate Sessions from the salseforce system`
198
-     *
199
-     * @return invalidateSessionsResult
200
-     */
201
-    public function invalidateSessions()
202
-    {
203
-        $this->setHeaders("invalidateSessions");
204
-        $arg = new stdClass();
205
-        $this->logout();
206
-
207
-        return $this->sforce->invalidateSessions();
208
-    }
209
-
210
-    /**
211
-     * Specifies the session ID returned from the login server after a successful
212
-     * login.
213
-     */
214
-    protected function _setLoginHeader($loginResult)
215
-    {
216
-        $this->sessionId = $loginResult->sessionId;
217
-        $this->setSessionHeader($this->sessionId);
218
-        $serverURL = $loginResult->serverUrl;
219
-        $this->setEndPoint($serverURL);
220
-    }
221
-
222
-    /**
223
-     * Set the endpoint.
224
-     *
225
-     * @param string $location Location
226
-     */
227
-    public function setEndpoint($location)
228
-    {
229
-        $this->location = $location;
230
-        $this->sforce->__setLocation($location);
231
-    }
232
-
233
-    private function setHeaders($call = null)
234
-    {
235
-        $this->sforce->__setSoapHeaders(null);
236
-
237
-        $header_array = array(
238
-            $this->sessionHeader
239
-        );
240
-
241
-        $header = $this->callOptions;
242
-        if ($header != null) {
243
-            array_push($header_array, $header);
244
-        }
245
-
246
-        if ($call == "create" ||
247
-            $call == "merge" ||
248
-            $call == "update" ||
249
-            $call == "upsert"
250
-        ) {
251
-            $header = $this->assignmentRuleHeader;
252
-            if ($header != null) {
253
-                array_push($header_array, $header);
254
-            }
255
-        }
256
-
257
-        if ($call == "login") {
258
-            $header = $this->loginScopeHeader;
259
-            if ($header != null) {
260
-                array_push($header_array, $header);
261
-            }
262
-        }
263
-
264
-        if ($call == "create" ||
265
-            $call == "resetPassword" ||
266
-            $call == "update" ||
267
-            $call == "upsert"
268
-        ) {
269
-            $header = $this->emailHeader;
270
-            if ($header != null) {
271
-                array_push($header_array, $header);
272
-            }
273
-        }
274
-
275
-        if ($call == "create" ||
276
-            $call == "merge" ||
277
-            $call == "query" ||
278
-            $call == "retrieve" ||
279
-            $call == "update" ||
280
-            $call == "upsert"
281
-        ) {
282
-            $header = $this->mruHeader;
283
-            if ($header != null) {
284
-                array_push($header_array, $header);
285
-            }
286
-        }
287
-
288
-        if ($call == "delete") {
289
-            $header = $this->userTerritoryDeleteHeader;
290
-            if ($header != null) {
291
-                array_push($header_array, $header);
292
-            }
293
-        }
294
-
295
-        if ($call == "query" ||
296
-            $call == "queryMore" ||
297
-            $call == "retrieve"
298
-        ) {
299
-            $header = $this->queryHeader;
300
-            if ($header != null) {
301
-                array_push($header_array, $header);
302
-            }
303
-        }
304
-
305
-        // try to add allowFieldTruncationHeader
306
-        $allowFieldTruncationHeaderCalls = array(
307
-            'convertLead',
308
-            'create',
309
-            'merge',
310
-            'process',
311
-            'undelete',
312
-            'update',
313
-            'upsert',
314
-        );
315
-        if (in_array($call, $allowFieldTruncationHeaderCalls)) {
316
-            $header = $this->allowFieldTruncationHeader;
317
-            if ($header != null) {
318
-                array_push($header_array, $header);
319
-            }
320
-        }
321
-
322
-        // try to add localeOptions
323
-        if ($call == 'describeSObject' || $call == 'describeSObjects') {
324
-            $header = $this->localeOptions;
325
-            if ($header != null) {
326
-                array_push($header_array, $header);
327
-            }
328
-        }
329
-
330
-        // try to add PackageVersionHeader
331
-        $packageVersionHeaderCalls = array(
332
-            'convertLead',
333
-            'create',
334
-            'delete',
335
-            'describeGlobal',
336
-            'describeLayout',
337
-            'describeSObject',
338
-            'describeSObjects',
339
-            'describeSoftphoneLayout',
340
-            'describeTabs',
341
-            'merge',
342
-            'process',
343
-            'query',
344
-            'retrieve',
345
-            'search',
346
-            'undelete',
347
-            'update',
348
-            'upsert',
349
-        );
350
-
351
-        if (in_array($call, $packageVersionHeaderCalls)) {
352
-            $header = $this->packageVersionHeader;
353
-            if ($header != null) {
354
-                array_push($header_array, $header);
355
-            }
356
-        }
357
-
358
-        $this->sforce->__setSoapHeaders($header_array);
359
-    }
360
-
361
-    public function setAssignmentRuleHeader($header)
362
-    {
363
-        if ($header != null) {
364
-            $this->assignmentRuleHeader = new SoapHeader($this->namespace, 'AssignmentRuleHeader', array(
365
-                'assignmentRuleId' => $header->assignmentRuleId,
366
-                'useDefaultRule' => $header->useDefaultRuleFlag
367
-            ));
368
-        } else {
369
-            $this->assignmentRuleHeader = null;
370
-        }
371
-    }
372
-
373
-    public function setEmailHeader($header)
374
-    {
375
-        if ($header != null) {
376
-            $this->emailHeader = new SoapHeader($this->namespace, 'EmailHeader', array(
377
-                'triggerAutoResponseEmail' => $header->triggerAutoResponseEmail,
378
-                'triggerOtherEmail' => $header->triggerOtherEmail,
379
-                'triggerUserEmail' => $header->triggerUserEmail
380
-            ));
381
-        } else {
382
-            $this->emailHeader = null;
383
-        }
384
-    }
385
-
386
-    public function setLoginScopeHeader($header)
387
-    {
388
-        if ($header != null) {
389
-            $this->loginScopeHeader = new SoapHeader($this->namespace, 'LoginScopeHeader', array(
390
-                'organizationId' => $header->organizationId,
391
-                'portalId' => $header->portalId
392
-            ));
393
-        } else {
394
-            $this->loginScopeHeader = null;
395
-        }
396
-    }
397
-
398
-    public function setMruHeader($header)
399
-    {
400
-        if ($header != null) {
401
-            $this->mruHeader = new SoapHeader($this->namespace, 'MruHeader', array(
402
-                'updateMru' => $header->updateMruFlag
403
-            ));
404
-        } else {
405
-            $this->mruHeader = null;
406
-        }
407
-    }
408
-
409
-    public function setSessionHeader($id)
410
-    {
411
-        if ($id != null) {
412
-            $this->sessionHeader = new SoapHeader($this->namespace, 'SessionHeader', array(
413
-                'sessionId' => $id
414
-            ));
415
-            $this->sessionId = $id;
416
-        } else {
417
-            $this->sessionHeader = null;
418
-            $this->sessionId = null;
419
-        }
420
-    }
421
-
422
-    public function setUserTerritoryDeleteHeader($header)
423
-    {
424
-        if ($header != null) {
425
-            $this->userTerritoryDeleteHeader = new SoapHeader($this->namespace, 'UserTerritoryDeleteHeader  ', array(
426
-                'transferToUserId' => $header->transferToUserId
427
-            ));
428
-        } else {
429
-            $this->userTerritoryDeleteHeader = null;
430
-        }
431
-    }
432
-
433
-    public function setQueryOptions($header)
434
-    {
435
-        if ($header != null) {
436
-            $this->queryHeader = new SoapHeader($this->namespace, 'QueryOptions', array(
437
-                'batchSize' => $header->batchSize
438
-            ));
439
-        } else {
440
-            $this->queryHeader = null;
441
-        }
442
-    }
443
-
444
-    public function setAllowFieldTruncationHeader($header)
445
-    {
446
-        if ($header != null) {
447
-            $this->allowFieldTruncationHeader = new SoapHeader($this->namespace, 'AllowFieldTruncationHeader', array(
448
-                    'allowFieldTruncation' => $header->allowFieldTruncation
449
-                )
450
-            );
451
-        } else {
452
-            $this->allowFieldTruncationHeader = null;
453
-        }
454
-    }
455
-
456
-    public function setLocaleOptions($header)
457
-    {
458
-        if ($header != null) {
459
-            $this->localeOptions = new SoapHeader($this->namespace, 'LocaleOptions',
460
-                array(
461
-                    'language' => $header->language
462
-                )
463
-            );
464
-        } else {
465
-            $this->localeOptions = null;
466
-        }
467
-    }
468
-
469
-    /**
470
-     * @param $header
471
-     */
472
-    public function setPackageVersionHeader($header)
473
-    {
474
-        if ($header != null) {
475
-            $headerData = array('packageVersions' => array());
476
-
477
-            foreach ($header->packageVersions as $key => $hdrElem) {
478
-                $headerData['packageVersions'][] = array(
479
-                    'majorNumber' => $hdrElem->majorNumber,
480
-                    'minorNumber' => $hdrElem->minorNumber,
481
-                    'namespace' => $hdrElem->namespace,
482
-                );
483
-            }
484
-
485
-            $this->packageVersionHeader = new SoapHeader($this->namespace,
486
-                'PackageVersionHeader',
487
-                $headerData
488
-            );
489
-        } else {
490
-            $this->packageVersionHeader = null;
491
-        }
492
-    }
493
-
494
-    public function getSessionId()
495
-    {
496
-        return $this->sessionId;
497
-    }
498
-
499
-    public function getLocation()
500
-    {
501
-        return $this->location;
502
-    }
503
-
504
-    public function getConnection()
505
-    {
506
-        return $this->sforce;
507
-    }
508
-
509
-    public function getFunctions()
510
-    {
511
-        return $this->sforce->__getFunctions();
512
-    }
513
-
514
-    public function getTypes()
515
-    {
516
-        return $this->sforce->__getTypes();
517
-    }
518
-
519
-    public function getLastRequest()
520
-    {
521
-        return $this->sforce->__getLastRequest();
522
-    }
523
-
524
-    public function getLastRequestHeaders()
525
-    {
526
-        return $this->sforce->__getLastRequestHeaders();
527
-    }
528
-
529
-    public function getLastResponse()
530
-    {
531
-        return $this->sforce->__getLastResponse();
532
-    }
533
-
534
-    public function getLastResponseHeaders()
535
-    {
536
-        return $this->sforce->__getLastResponseHeaders();
537
-    }
538
-
539
-    protected function _convertToAny($fields)
540
-    {
541
-        $anyString = '';
542
-        foreach ($fields as $key => $value) {
543
-            $anyString = $anyString . '<' . $key . '>' . $value . '</' . $key . '>';
544
-        }
545
-
546
-        return $anyString;
547
-    }
548
-
549
-    protected function _create($arg)
550
-    {
551
-        $this->setHeaders("create");
552
-
553
-        return $this->sforce->create($arg)->result;
554
-    }
555
-
556
-    protected function _merge($arg)
557
-    {
558
-        $this->setHeaders("merge");
559
-
560
-        return $this->sforce->merge($arg)->result;
561
-    }
562
-
563
-    protected function _process($arg)
564
-    {
565
-        $this->setHeaders();
566
-
567
-        return $this->sforce->process($arg)->result;
568
-    }
569
-
570
-    protected function _update($arg)
571
-    {
572
-        $this->setHeaders("update");
573
-
574
-        return $this->sforce->update($arg)->result;
575
-    }
576
-
577
-    protected function _upsert($arg)
578
-    {
579
-        $this->setHeaders("upsert");
580
-
581
-        return $this->sforce->upsert($arg)->result;
582
-    }
583
-
584
-    public function sendSingleEmail($request)
585
-    {
586
-        if (is_array($request)) {
587
-            $messages = array();
588
-            foreach ($request as $r) {
589
-                $email = new SoapVar($r, SOAP_ENC_OBJECT, 'SingleEmailMessage', $this->namespace);
590
-                array_push($messages, $email);
591
-            }
592
-            $arg = new stdClass();
593
-            $arg->messages = $messages;
594
-
595
-            return $this->_sendEmail($arg);
596
-        } else {
597
-            $backtrace = debug_backtrace();
598
-            error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
599
-            return false;
600
-        }
601
-    }
602
-
603
-    public function sendMassEmail($request)
604
-    {
605
-        if (is_array($request)) {
606
-            $messages = array();
607
-            foreach ($request as $r) {
608
-                $email = new SoapVar($r, SOAP_ENC_OBJECT, 'MassEmailMessage', $this->namespace);
609
-                array_push($messages, $email);
610
-            }
611
-            $arg = new stdClass();
612
-            $arg->messages = $messages;
613
-
614
-            return $this->_sendEmail($arg);
615
-        } else {
616
-            $backtrace = debug_backtrace();
617
-            error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
618
-            return false;
619
-        }
620
-    }
621
-
622
-    protected function _sendEmail($arg)
623
-    {
624
-        $this->setHeaders();
625
-
626
-        return $this->sforce->sendEmail($arg)->result;
627
-    }
628
-
629
-    /**
630
-     * Converts a Lead into an Account, Contact, or (optionally) an Opportunity.
631
-     *
632
-     * @param array $leadConverts Array of LeadConvert
633
-     *
634
-     * @return LeadConvertResult
635
-     */
636
-    public function convertLead($leadConverts)
637
-    {
77
+
78
+	// clientId specifies which application or toolkit is accessing the
79
+	// salesforce.com API. For applications that are certified salesforce.com
80
+	// solutions, replace this with the value provided by salesforce.com.
81
+	// Otherwise, leave this value as 'phpClient/1.0'.
82
+	protected $client_id;
83
+
84
+	public function printDebugInfo()
85
+	{
86
+		echo 'PHP Toolkit Version: ' . $this->version . PHP_EOL;
87
+		echo 'Current PHP version: ' . phpversion();
88
+		echo PHP_EOL;
89
+		echo 'SOAP enabled: ';
90
+		if (extension_loaded('soap')) {
91
+			echo 'True';
92
+		} else {
93
+			echo 'False';
94
+		}
95
+		echo PHP_EOL;
96
+		echo 'OpenSSL enabled: ';
97
+		if (extension_loaded('openssl')) {
98
+			echo 'True';
99
+		} else {
100
+			echo 'False';
101
+		}
102
+	}
103
+
104
+	/**
105
+	 * Connect method to www.salesforce.com
106
+	 *
107
+	 * @param string $wsdl Salesforce.com Partner WSDL
108
+	 * @param object $proxy (optional) proxy settings with properties host, port,
109
+	 *                       login and password
110
+	 * @param array $soap_options (optional) Additional options to send to the
111
+	 *                       SoapClient constructor. @see
112
+	 *                       http://php.net/manual/en/soapclient.soapclient.php
113
+	 */
114
+	public function createConnection($wsdl, $proxy = null, $soap_options = array())
115
+	{
116
+		// use correct version comparison
117
+		if (version_compare(phpversion(), '5.3', '<')) {
118
+			throw new Exception ('PHP versions older than 5.3 are no longer supported. Please upgrade!');
119
+		}
120
+
121
+		$soapClientArray = array_merge(array(
122
+			'user_agent' => 'salesforce-toolkit-php/' . $this->version,
123
+			'encoding' => 'utf-8',
124
+			'trace' => 1,
125
+			'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
126
+			'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP
127
+		), $soap_options);
128
+
129
+
130
+		if ($proxy != null) {
131
+			$proxySettings = array();
132
+			$proxySettings['proxy_host'] = $proxy->host;
133
+			$proxySettings['proxy_port'] = $proxy->port; // Use an integer, not a string
134
+			$proxySettings['proxy_login'] = $proxy->login;
135
+			$proxySettings['proxy_password'] = $proxy->password;
136
+			$soapClientArray = array_merge($soapClientArray, $proxySettings);
137
+		}
138
+
139
+		$this->sforce = $this->getSoapClient($wsdl, $soapClientArray);
140
+
141
+		return $this->sforce;
142
+	}
143
+
144
+	public function setCallOptions($header)
145
+	{
146
+		if ($header != null) {
147
+			$this->callOptions = new SoapHeader($this->namespace, 'CallOptions', array(
148
+				'client' => $header->client,
149
+				'defaultNamespace' => $header->defaultNamespace
150
+			));
151
+		} else {
152
+			$this->callOptions = null;
153
+		}
154
+	}
155
+
156
+	/**
157
+	 * Login to Salesforce.com and starts a client session.
158
+	 *
159
+	 * @param string $username Username
160
+	 * @param string $password Password
161
+	 *
162
+	 * @return LoginResult
163
+	 */
164
+	public function login($username, $password)
165
+	{
166
+		$this->sforce->__setSoapHeaders(null);
167
+		if ($this->callOptions != null) {
168
+			$this->sforce->__setSoapHeaders(array($this->callOptions));
169
+		}
170
+		if ($this->loginScopeHeader != null) {
171
+			$this->sforce->__setSoapHeaders(array($this->loginScopeHeader));
172
+		}
173
+		$result = $this->sforce->login(array(
174
+			'username' => $username,
175
+			'password' => $password
176
+		));
177
+		$result = $result->result;
178
+		$this->_setLoginHeader($result);
179
+
180
+		return $result;
181
+	}
182
+
183
+	/**
184
+	 * log outs from the salseforce system`
185
+	 *
186
+	 * @return LogoutResult
187
+	 */
188
+	public function logout()
189
+	{
190
+		$this->setHeaders("logout");
191
+		$arg = new stdClass();
192
+
193
+		return $this->sforce->logout();
194
+	}
195
+
196
+	/**
197
+	 *invalidate Sessions from the salseforce system`
198
+	 *
199
+	 * @return invalidateSessionsResult
200
+	 */
201
+	public function invalidateSessions()
202
+	{
203
+		$this->setHeaders("invalidateSessions");
204
+		$arg = new stdClass();
205
+		$this->logout();
206
+
207
+		return $this->sforce->invalidateSessions();
208
+	}
209
+
210
+	/**
211
+	 * Specifies the session ID returned from the login server after a successful
212
+	 * login.
213
+	 */
214
+	protected function _setLoginHeader($loginResult)
215
+	{
216
+		$this->sessionId = $loginResult->sessionId;
217
+		$this->setSessionHeader($this->sessionId);
218
+		$serverURL = $loginResult->serverUrl;
219
+		$this->setEndPoint($serverURL);
220
+	}
221
+
222
+	/**
223
+	 * Set the endpoint.
224
+	 *
225
+	 * @param string $location Location
226
+	 */
227
+	public function setEndpoint($location)
228
+	{
229
+		$this->location = $location;
230
+		$this->sforce->__setLocation($location);
231
+	}
232
+
233
+	private function setHeaders($call = null)
234
+	{
235
+		$this->sforce->__setSoapHeaders(null);
236
+
237
+		$header_array = array(
238
+			$this->sessionHeader
239
+		);
240
+
241
+		$header = $this->callOptions;
242
+		if ($header != null) {
243
+			array_push($header_array, $header);
244
+		}
245
+
246
+		if ($call == "create" ||
247
+			$call == "merge" ||
248
+			$call == "update" ||
249
+			$call == "upsert"
250
+		) {
251
+			$header = $this->assignmentRuleHeader;
252
+			if ($header != null) {
253
+				array_push($header_array, $header);
254
+			}
255
+		}
256
+
257
+		if ($call == "login") {
258
+			$header = $this->loginScopeHeader;
259
+			if ($header != null) {
260
+				array_push($header_array, $header);
261
+			}
262
+		}
263
+
264
+		if ($call == "create" ||
265
+			$call == "resetPassword" ||
266
+			$call == "update" ||
267
+			$call == "upsert"
268
+		) {
269
+			$header = $this->emailHeader;
270
+			if ($header != null) {
271
+				array_push($header_array, $header);
272
+			}
273
+		}
274
+
275
+		if ($call == "create" ||
276
+			$call == "merge" ||
277
+			$call == "query" ||
278
+			$call == "retrieve" ||
279
+			$call == "update" ||
280
+			$call == "upsert"
281
+		) {
282
+			$header = $this->mruHeader;
283
+			if ($header != null) {
284
+				array_push($header_array, $header);
285
+			}
286
+		}
287
+
288
+		if ($call == "delete") {
289
+			$header = $this->userTerritoryDeleteHeader;
290
+			if ($header != null) {
291
+				array_push($header_array, $header);
292
+			}
293
+		}
294
+
295
+		if ($call == "query" ||
296
+			$call == "queryMore" ||
297
+			$call == "retrieve"
298
+		) {
299
+			$header = $this->queryHeader;
300
+			if ($header != null) {
301
+				array_push($header_array, $header);
302
+			}
303
+		}
304
+
305
+		// try to add allowFieldTruncationHeader
306
+		$allowFieldTruncationHeaderCalls = array(
307
+			'convertLead',
308
+			'create',
309
+			'merge',
310
+			'process',
311
+			'undelete',
312
+			'update',
313
+			'upsert',
314
+		);
315
+		if (in_array($call, $allowFieldTruncationHeaderCalls)) {
316
+			$header = $this->allowFieldTruncationHeader;
317
+			if ($header != null) {
318
+				array_push($header_array, $header);
319
+			}
320
+		}
321
+
322
+		// try to add localeOptions
323
+		if ($call == 'describeSObject' || $call == 'describeSObjects') {
324
+			$header = $this->localeOptions;
325
+			if ($header != null) {
326
+				array_push($header_array, $header);
327
+			}
328
+		}
329
+
330
+		// try to add PackageVersionHeader
331
+		$packageVersionHeaderCalls = array(
332
+			'convertLead',
333
+			'create',
334
+			'delete',
335
+			'describeGlobal',
336
+			'describeLayout',
337
+			'describeSObject',
338
+			'describeSObjects',
339
+			'describeSoftphoneLayout',
340
+			'describeTabs',
341
+			'merge',
342
+			'process',
343
+			'query',
344
+			'retrieve',
345
+			'search',
346
+			'undelete',
347
+			'update',
348
+			'upsert',
349
+		);
350
+
351
+		if (in_array($call, $packageVersionHeaderCalls)) {
352
+			$header = $this->packageVersionHeader;
353
+			if ($header != null) {
354
+				array_push($header_array, $header);
355
+			}
356
+		}
357
+
358
+		$this->sforce->__setSoapHeaders($header_array);
359
+	}
360
+
361
+	public function setAssignmentRuleHeader($header)
362
+	{
363
+		if ($header != null) {
364
+			$this->assignmentRuleHeader = new SoapHeader($this->namespace, 'AssignmentRuleHeader', array(
365
+				'assignmentRuleId' => $header->assignmentRuleId,
366
+				'useDefaultRule' => $header->useDefaultRuleFlag
367
+			));
368
+		} else {
369
+			$this->assignmentRuleHeader = null;
370
+		}
371
+	}
372
+
373
+	public function setEmailHeader($header)
374
+	{
375
+		if ($header != null) {
376
+			$this->emailHeader = new SoapHeader($this->namespace, 'EmailHeader', array(
377
+				'triggerAutoResponseEmail' => $header->triggerAutoResponseEmail,
378
+				'triggerOtherEmail' => $header->triggerOtherEmail,
379
+				'triggerUserEmail' => $header->triggerUserEmail
380
+			));
381
+		} else {
382
+			$this->emailHeader = null;
383
+		}
384
+	}
385
+
386
+	public function setLoginScopeHeader($header)
387
+	{
388
+		if ($header != null) {
389
+			$this->loginScopeHeader = new SoapHeader($this->namespace, 'LoginScopeHeader', array(
390
+				'organizationId' => $header->organizationId,
391
+				'portalId' => $header->portalId
392
+			));
393
+		} else {
394
+			$this->loginScopeHeader = null;
395
+		}
396
+	}
397
+
398
+	public function setMruHeader($header)
399
+	{
400
+		if ($header != null) {
401
+			$this->mruHeader = new SoapHeader($this->namespace, 'MruHeader', array(
402
+				'updateMru' => $header->updateMruFlag
403
+			));
404
+		} else {
405
+			$this->mruHeader = null;
406
+		}
407
+	}
408
+
409
+	public function setSessionHeader($id)
410
+	{
411
+		if ($id != null) {
412
+			$this->sessionHeader = new SoapHeader($this->namespace, 'SessionHeader', array(
413
+				'sessionId' => $id
414
+			));
415
+			$this->sessionId = $id;
416
+		} else {
417
+			$this->sessionHeader = null;
418
+			$this->sessionId = null;
419
+		}
420
+	}
421
+
422
+	public function setUserTerritoryDeleteHeader($header)
423
+	{
424
+		if ($header != null) {
425
+			$this->userTerritoryDeleteHeader = new SoapHeader($this->namespace, 'UserTerritoryDeleteHeader  ', array(
426
+				'transferToUserId' => $header->transferToUserId
427
+			));
428
+		} else {
429
+			$this->userTerritoryDeleteHeader = null;
430
+		}
431
+	}
432
+
433
+	public function setQueryOptions($header)
434
+	{
435
+		if ($header != null) {
436
+			$this->queryHeader = new SoapHeader($this->namespace, 'QueryOptions', array(
437
+				'batchSize' => $header->batchSize
438
+			));
439
+		} else {
440
+			$this->queryHeader = null;
441
+		}
442
+	}
443
+
444
+	public function setAllowFieldTruncationHeader($header)
445
+	{
446
+		if ($header != null) {
447
+			$this->allowFieldTruncationHeader = new SoapHeader($this->namespace, 'AllowFieldTruncationHeader', array(
448
+					'allowFieldTruncation' => $header->allowFieldTruncation
449
+				)
450
+			);
451
+		} else {
452
+			$this->allowFieldTruncationHeader = null;
453
+		}
454
+	}
455
+
456
+	public function setLocaleOptions($header)
457
+	{
458
+		if ($header != null) {
459
+			$this->localeOptions = new SoapHeader($this->namespace, 'LocaleOptions',
460
+				array(
461
+					'language' => $header->language
462
+				)
463
+			);
464
+		} else {
465
+			$this->localeOptions = null;
466
+		}
467
+	}
468
+
469
+	/**
470
+	 * @param $header
471
+	 */
472
+	public function setPackageVersionHeader($header)
473
+	{
474
+		if ($header != null) {
475
+			$headerData = array('packageVersions' => array());
476
+
477
+			foreach ($header->packageVersions as $key => $hdrElem) {
478
+				$headerData['packageVersions'][] = array(
479
+					'majorNumber' => $hdrElem->majorNumber,
480
+					'minorNumber' => $hdrElem->minorNumber,
481
+					'namespace' => $hdrElem->namespace,
482
+				);
483
+			}
484
+
485
+			$this->packageVersionHeader = new SoapHeader($this->namespace,
486
+				'PackageVersionHeader',
487
+				$headerData
488
+			);
489
+		} else {
490
+			$this->packageVersionHeader = null;
491
+		}
492
+	}
493
+
494
+	public function getSessionId()
495
+	{
496
+		return $this->sessionId;
497
+	}
498
+
499
+	public function getLocation()
500
+	{
501
+		return $this->location;
502
+	}
503
+
504
+	public function getConnection()
505
+	{
506
+		return $this->sforce;
507
+	}
508
+
509
+	public function getFunctions()
510
+	{
511
+		return $this->sforce->__getFunctions();
512
+	}
513
+
514
+	public function getTypes()
515
+	{
516
+		return $this->sforce->__getTypes();
517
+	}
518
+
519
+	public function getLastRequest()
520
+	{
521
+		return $this->sforce->__getLastRequest();
522
+	}
523
+
524
+	public function getLastRequestHeaders()
525
+	{
526
+		return $this->sforce->__getLastRequestHeaders();
527
+	}
528
+
529
+	public function getLastResponse()
530
+	{
531
+		return $this->sforce->__getLastResponse();
532
+	}
533
+
534
+	public function getLastResponseHeaders()
535
+	{
536
+		return $this->sforce->__getLastResponseHeaders();
537
+	}
538
+
539
+	protected function _convertToAny($fields)
540
+	{
541
+		$anyString = '';
542
+		foreach ($fields as $key => $value) {
543
+			$anyString = $anyString . '<' . $key . '>' . $value . '</' . $key . '>';
544
+		}
545
+
546
+		return $anyString;
547
+	}
548
+
549
+	protected function _create($arg)
550
+	{
551
+		$this->setHeaders("create");
552
+
553
+		return $this->sforce->create($arg)->result;
554
+	}
555
+
556
+	protected function _merge($arg)
557
+	{
558
+		$this->setHeaders("merge");
559
+
560
+		return $this->sforce->merge($arg)->result;
561
+	}
562
+
563
+	protected function _process($arg)
564
+	{
565
+		$this->setHeaders();
566
+
567
+		return $this->sforce->process($arg)->result;
568
+	}
569
+
570
+	protected function _update($arg)
571
+	{
572
+		$this->setHeaders("update");
573
+
574
+		return $this->sforce->update($arg)->result;
575
+	}
576
+
577
+	protected function _upsert($arg)
578
+	{
579
+		$this->setHeaders("upsert");
580
+
581
+		return $this->sforce->upsert($arg)->result;
582
+	}
583
+
584
+	public function sendSingleEmail($request)
585
+	{
586
+		if (is_array($request)) {
587
+			$messages = array();
588
+			foreach ($request as $r) {
589
+				$email = new SoapVar($r, SOAP_ENC_OBJECT, 'SingleEmailMessage', $this->namespace);
590
+				array_push($messages, $email);
591
+			}
592
+			$arg = new stdClass();
593
+			$arg->messages = $messages;
594
+
595
+			return $this->_sendEmail($arg);
596
+		} else {
597
+			$backtrace = debug_backtrace();
598
+			error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
599
+			return false;
600
+		}
601
+	}
602
+
603
+	public function sendMassEmail($request)
604
+	{
605
+		if (is_array($request)) {
606
+			$messages = array();
607
+			foreach ($request as $r) {
608
+				$email = new SoapVar($r, SOAP_ENC_OBJECT, 'MassEmailMessage', $this->namespace);
609
+				array_push($messages, $email);
610
+			}
611
+			$arg = new stdClass();
612
+			$arg->messages = $messages;
613
+
614
+			return $this->_sendEmail($arg);
615
+		} else {
616
+			$backtrace = debug_backtrace();
617
+			error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
618
+			return false;
619
+		}
620
+	}
621
+
622
+	protected function _sendEmail($arg)
623
+	{
624
+		$this->setHeaders();
625
+
626
+		return $this->sforce->sendEmail($arg)->result;
627
+	}
628
+
629
+	/**
630
+	 * Converts a Lead into an Account, Contact, or (optionally) an Opportunity.
631
+	 *
632
+	 * @param array $leadConverts Array of LeadConvert
633
+	 *
634
+	 * @return LeadConvertResult
635
+	 */
636
+	public function convertLead($leadConverts)
637
+	{
638 638
 		$this->setHeaders("convertLead");
639
-        $arg = new stdClass();
639
+		$arg = new stdClass();
640 640
         
641
-        foreach ($leadConverts as $k => $lc) {
642
-            if (isset($lc->contactRecord) && !$lc->contactRecord instanceof SoapVar) {
643
-                $lc->contactRecord = new SoapVar($lc->contactRecord, SOAP_ENC_OBJECT, 'Contact', $this->namespace);
644
-            }
641
+		foreach ($leadConverts as $k => $lc) {
642
+			if (isset($lc->contactRecord) && !$lc->contactRecord instanceof SoapVar) {
643
+				$lc->contactRecord = new SoapVar($lc->contactRecord, SOAP_ENC_OBJECT, 'Contact', $this->namespace);
644
+			}
645 645
 
646
-            if (isset($lc->opportunityRecord) && !$lc->opportunityRecord instanceof SoapVar) {
647
-                $lc->opportunityRecord = new SoapVar($lc->opportunityRecord, SOAP_ENC_OBJECT, 'Opportunity', $this->namespace);
648
-            }
646
+			if (isset($lc->opportunityRecord) && !$lc->opportunityRecord instanceof SoapVar) {
647
+				$lc->opportunityRecord = new SoapVar($lc->opportunityRecord, SOAP_ENC_OBJECT, 'Opportunity', $this->namespace);
648
+			}
649 649
 
650
-            if (isset($lc->accountRecord) && !$lc->accountRecord instanceof SoapVar) {
651
-                $lc->accountRecord = new SoapVar($lc->accountRecord, SOAP_ENC_OBJECT, 'Account', $this->namespace);
652
-            }
650
+			if (isset($lc->accountRecord) && !$lc->accountRecord instanceof SoapVar) {
651
+				$lc->accountRecord = new SoapVar($lc->accountRecord, SOAP_ENC_OBJECT, 'Account', $this->namespace);
652
+			}
653 653
 
654
-            $leadConverts[$k] = $lc;
655
-        }
654
+			$leadConverts[$k] = $lc;
655
+		}
656 656
 		
657
-        $arg->leadConverts = $leadConverts;
657
+		$arg->leadConverts = $leadConverts;
658 658
         
659 659
 		return $this->sforce->convertLead($arg);
660 660
 	}
661 661
 
662
-    /**
663
-     * Deletes one or more new individual objects to your organization's data.
664
-     *
665
-     * @param array $ids Array of fields
666
-     * @return DeleteResult
667
-     */
668
-    public function delete($ids)
669
-    {
670
-        $this->setHeaders("delete");
671
-        $arg = new stdClass();
672
-        $arg->ids = $ids;
662
+	/**
663
+	 * Deletes one or more new individual objects to your organization's data.
664
+	 *
665
+	 * @param array $ids Array of fields
666
+	 * @return DeleteResult
667
+	 */
668
+	public function delete($ids)
669
+	{
670
+		$this->setHeaders("delete");
671
+		$arg = new stdClass();
672
+		$arg->ids = $ids;
673
+
674
+		return $this->sforce->delete($arg)->result;
675
+	}
673 676
 
674
-        return $this->sforce->delete($arg)->result;
675
-    }
677
+	/**
678
+	 * Deletes one or more new individual objects to your organization's data.
679
+	 *
680
+	 * @param array $ids Array of fields
681
+	 * @return DeleteResult
682
+	 */
683
+	public function undelete($ids)
684
+	{
685
+		$this->setHeaders("undelete");
686
+		$arg = new stdClass();
687
+		$arg->ids = $ids;
688
+
689
+		return $this->sforce->undelete($arg)->result;
690
+	}
676 691
 
677
-    /**
678
-     * Deletes one or more new individual objects to your organization's data.
679
-     *
680
-     * @param array $ids Array of fields
681
-     * @return DeleteResult
682
-     */
683
-    public function undelete($ids)
684
-    {
685
-        $this->setHeaders("undelete");
686
-        $arg = new stdClass();
687
-        $arg->ids = $ids;
692
+	/**
693
+	 * Deletes one or more new individual objects to your organization's data.
694
+	 *
695
+	 * @param array $ids Array of fields
696
+	 * @return DeleteResult
697
+	 */
698
+	public function emptyRecycleBin($ids)
699
+	{
700
+		$this->setHeaders();
701
+		$arg = new stdClass();
702
+		$arg->ids = $ids;
703
+
704
+		return $this->sforce->emptyRecycleBin($arg)->result;
705
+	}
688 706
 
689
-        return $this->sforce->undelete($arg)->result;
690
-    }
707
+	/**
708
+	 * Process Submit Request for Approval
709
+	 *
710
+	 * @param array $processRequestArray
711
+	 * @return ProcessResult
712
+	 */
713
+	public function processSubmitRequest($processRequestArray)
714
+	{
715
+		if (is_array($processRequestArray)) {
716
+			foreach ($processRequestArray as &$process) {
717
+				$process = new SoapVar($process, SOAP_ENC_OBJECT, 'ProcessSubmitRequest', $this->namespace);
718
+			}
719
+			$arg = new stdClass();
720
+			$arg->actions = $processRequestArray;
721
+
722
+			return $this->_process($arg);
723
+		} else {
724
+			$backtrace = debug_backtrace();
725
+			error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
726
+			return false;
727
+		}
728
+	}
691 729
 
692
-    /**
693
-     * Deletes one or more new individual objects to your organization's data.
694
-     *
695
-     * @param array $ids Array of fields
696
-     * @return DeleteResult
697
-     */
698
-    public function emptyRecycleBin($ids)
699
-    {
700
-        $this->setHeaders();
701
-        $arg = new stdClass();
702
-        $arg->ids = $ids;
730
+	/**
731
+	 * Process Work Item Request for Approval
732
+	 *
733
+	 * @param array $processRequestArray
734
+	 * @return ProcessResult
735
+	 */
736
+	public function processWorkitemRequest($processRequestArray)
737
+	{
738
+		if (is_array($processRequestArray)) {
739
+			foreach ($processRequestArray as &$process) {
740
+				$process = new SoapVar($process, SOAP_ENC_OBJECT, 'ProcessWorkitemRequest', $this->namespace);
741
+			}
742
+			$arg = new stdClass();
743
+			$arg->actions = $processRequestArray;
744
+
745
+			return $this->_process($arg);
746
+		} else {
747
+			$backtrace = debug_backtrace();
748
+			error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
749
+			return false;
750
+		}
751
+	}
703 752
 
704
-        return $this->sforce->emptyRecycleBin($arg)->result;
705
-    }
753
+	/**
754
+	 * Retrieves a list of available objects for your organization's data.
755
+	 *
756
+	 * @return DescribeGlobalResult
757
+	 */
758
+	public function describeGlobal()
759
+	{
760
+		$this->setHeaders("describeGlobal");
706 761
 
707
-    /**
708
-     * Process Submit Request for Approval
709
-     *
710
-     * @param array $processRequestArray
711
-     * @return ProcessResult
712
-     */
713
-    public function processSubmitRequest($processRequestArray)
714
-    {
715
-        if (is_array($processRequestArray)) {
716
-            foreach ($processRequestArray as &$process) {
717
-                $process = new SoapVar($process, SOAP_ENC_OBJECT, 'ProcessSubmitRequest', $this->namespace);
718
-            }
719
-            $arg = new stdClass();
720
-            $arg->actions = $processRequestArray;
721
-
722
-            return $this->_process($arg);
723
-        } else {
724
-            $backtrace = debug_backtrace();
725
-            error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
726
-            return false;
727
-        }
728
-    }
729
-
730
-    /**
731
-     * Process Work Item Request for Approval
732
-     *
733
-     * @param array $processRequestArray
734
-     * @return ProcessResult
735
-     */
736
-    public function processWorkitemRequest($processRequestArray)
737
-    {
738
-        if (is_array($processRequestArray)) {
739
-            foreach ($processRequestArray as &$process) {
740
-                $process = new SoapVar($process, SOAP_ENC_OBJECT, 'ProcessWorkitemRequest', $this->namespace);
741
-            }
742
-            $arg = new stdClass();
743
-            $arg->actions = $processRequestArray;
744
-
745
-            return $this->_process($arg);
746
-        } else {
747
-            $backtrace = debug_backtrace();
748
-            error_log('Please pass in array to this function:  ' . $backtrace[0]['function']);
749
-            return false;
750
-        }
751
-    }
752
-
753
-    /**
754
-     * Retrieves a list of available objects for your organization's data.
755
-     *
756
-     * @return DescribeGlobalResult
757
-     */
758
-    public function describeGlobal()
759
-    {
760
-        $this->setHeaders("describeGlobal");
761
-
762
-        return $this->sforce->describeGlobal()->result;
763
-    }
764
-
765
-    /**
766
-     * Use describeLayout to retrieve information about the layout (presentation
767
-     * of data to users) for a given object type. The describeLayout call returns
768
-     * metadata about a given page layout, including layouts for edit and
769
-     * display-only views and record type mappings. Note that field-level security
770
-     * and layout editability affects which fields appear in a layout.
771
-     *
772
-     * @param string Type   Object Type
773
-     * @return DescribeLayoutResult
774
-     */
775
-    public function describeLayout($type, array $recordTypeIds = null)
776
-    {
777
-        $this->setHeaders("describeLayout");
778
-        $arg = new stdClass();
779
-        $arg->sObjectType = new SoapVar($type, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
780
-        if (isset($recordTypeIds) && count($recordTypeIds)) {
781
-            $arg->recordTypeIds = $recordTypeIds;
782
-        }
783
-
784
-        return $this->sforce->describeLayout($arg)->result;
785
-    }
786
-
787
-    /**
788
-     * Describes metadata (field list and object properties) for the specified
789
-     * object.
790
-     *
791
-     * @param string $type Object type
792
-     * @return DescribsSObjectResult
793
-     */
794
-    public function describeSObject($type)
795
-    {
796
-        $this->setHeaders("describeSObject");
797
-        $arg = new stdClass();
798
-        $arg->sObjectType = new SoapVar($type, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
799
-
800
-        return $this->sforce->describeSObject($arg)->result;
801
-    }
802
-
803
-    /**
804
-     * An array-based version of describeSObject; describes metadata (field list
805
-     * and object properties) for the specified object or array of objects.
806
-     *
807
-     * @param array $arrayOfTypes Array of object types.
808
-     * @return DescribsSObjectResult
809
-     */
810
-    public function describeSObjects($arrayOfTypes)
811
-    {
812
-        $this->setHeaders("describeSObjects");
762
+		return $this->sforce->describeGlobal()->result;
763
+	}
813 764
 
814
-        return $this->sforce->describeSObjects($arrayOfTypes)->result;
815
-    }
765
+	/**
766
+	 * Use describeLayout to retrieve information about the layout (presentation
767
+	 * of data to users) for a given object type. The describeLayout call returns
768
+	 * metadata about a given page layout, including layouts for edit and
769
+	 * display-only views and record type mappings. Note that field-level security
770
+	 * and layout editability affects which fields appear in a layout.
771
+	 *
772
+	 * @param string Type   Object Type
773
+	 * @return DescribeLayoutResult
774
+	 */
775
+	public function describeLayout($type, array $recordTypeIds = null)
776
+	{
777
+		$this->setHeaders("describeLayout");
778
+		$arg = new stdClass();
779
+		$arg->sObjectType = new SoapVar($type, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
780
+		if (isset($recordTypeIds) && count($recordTypeIds)) {
781
+			$arg->recordTypeIds = $recordTypeIds;
782
+		}
783
+
784
+		return $this->sforce->describeLayout($arg)->result;
785
+	}
816 786
 
817
-    /**
818
-     * The describeTabs call returns information about the standard apps and
819
-     * custom apps, if any, available for the user who sends the call, including
820
-     * the list of tabs defined for each app.
821
-     *
822
-     * @return DescribeTabSetResult
823
-     */
824
-    public function describeTabs()
825
-    {
826
-        $this->setHeaders("describeTabs");
787
+	/**
788
+	 * Describes metadata (field list and object properties) for the specified
789
+	 * object.
790
+	 *
791
+	 * @param string $type Object type
792
+	 * @return DescribsSObjectResult
793
+	 */
794
+	public function describeSObject($type)
795
+	{
796
+		$this->setHeaders("describeSObject");
797
+		$arg = new stdClass();
798
+		$arg->sObjectType = new SoapVar($type, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
799
+
800
+		return $this->sforce->describeSObject($arg)->result;
801
+	}
827 802
 
828
-        return $this->sforce->describeTabs()->result;
829
-    }
803
+	/**
804
+	 * An array-based version of describeSObject; describes metadata (field list
805
+	 * and object properties) for the specified object or array of objects.
806
+	 *
807
+	 * @param array $arrayOfTypes Array of object types.
808
+	 * @return DescribsSObjectResult
809
+	 */
810
+	public function describeSObjects($arrayOfTypes)
811
+	{
812
+		$this->setHeaders("describeSObjects");
813
+
814
+		return $this->sforce->describeSObjects($arrayOfTypes)->result;
815
+	}
830 816
 
831
-    /**
832
-     * To enable data categories groups you must enable Answers or Knowledge Articles module in
833
-     * admin panel, after adding category group and assign it to Answers or Knowledge Articles
834
-     *
835
-     * @param string $sObjectType sObject Type
836
-     * @return DescribeDataCategoryGroupResult
837
-     */
838
-    public function describeDataCategoryGroups($sObjectType)
839
-    {
840
-        $this->setHeaders('describeDataCategoryGroups');
841
-        $arg = new stdClass();
842
-        $arg->sObjectType = new SoapVar($sObjectType, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
817
+	/**
818
+	 * The describeTabs call returns information about the standard apps and
819
+	 * custom apps, if any, available for the user who sends the call, including
820
+	 * the list of tabs defined for each app.
821
+	 *
822
+	 * @return DescribeTabSetResult
823
+	 */
824
+	public function describeTabs()
825
+	{
826
+		$this->setHeaders("describeTabs");
827
+
828
+		return $this->sforce->describeTabs()->result;
829
+	}
843 830
 
844
-        return $this->sforce->describeDataCategoryGroups($arg)->result;
845
-    }
831
+	/**
832
+	 * To enable data categories groups you must enable Answers or Knowledge Articles module in
833
+	 * admin panel, after adding category group and assign it to Answers or Knowledge Articles
834
+	 *
835
+	 * @param string $sObjectType sObject Type
836
+	 * @return DescribeDataCategoryGroupResult
837
+	 */
838
+	public function describeDataCategoryGroups($sObjectType)
839
+	{
840
+		$this->setHeaders('describeDataCategoryGroups');
841
+		$arg = new stdClass();
842
+		$arg->sObjectType = new SoapVar($sObjectType, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
843
+
844
+		return $this->sforce->describeDataCategoryGroups($arg)->result;
845
+	}
846 846
 
847
-    /**
848
-     * Retrieves available category groups along with their data category structure for objects specified in the request.
849
-     *
850
-     * @param DataCategoryGroupSobjectTypePair $pairs
851
-     * @param bool $topCategoriesOnly Object Type
852
-     * @return DescribeLayoutResult
853
-     */
854
-    public function describeDataCategoryGroupStructures(array $pairs, $topCategoriesOnly)
855
-    {
856
-        $this->setHeaders('describeDataCategoryGroupStructures');
857
-        $arg = new stdClass();
858
-        $arg->pairs = $pairs;
859
-        $arg->topCategoriesOnly = new SoapVar($topCategoriesOnly, XSD_BOOLEAN, 'boolean',
860
-            'http://www.w3.org/2001/XMLSchema');
861
-
862
-        return $this->sforce->describeDataCategoryGroupStructures($arg)->result;
863
-    }
864
-
865
-    /**
866
-     * Retrieves the list of individual objects that have been deleted within the
867
-     * given timespan for the specified object.
868
-     *
869
-     * @param string $type Ojbect type
870
-     * @param string $startDate Start date
871
-     * @param string $endDate End Date
872
-     * @return GetDeletedResult
873
-     */
874
-    public function getDeleted($type, $startDate, $endDate)
875
-    {
876
-        $this->setHeaders("getDeleted");
877
-        $arg = new stdClass();
878
-        $arg->sObjectType = new SoapVar($type, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
879
-        $arg->startDate = $startDate;
880
-        $arg->endDate = $endDate;
881
-
882
-        return $this->sforce->getDeleted($arg)->result;
883
-    }
884
-
885
-    /**
886
-     * Retrieves the list of individual objects that have been updated (added or
887
-     * changed) within the given timespan for the specified object.
888
-     *
889
-     * @param string $type Ojbect type
890
-     * @param string $startDate Start date
891
-     * @param string $endDate End Date
892
-     * @return GetUpdatedResult
893
-     */
894
-    public function getUpdated($type, $startDate, $endDate)
895
-    {
896
-        $this->setHeaders("getUpdated");
897
-        $arg = new stdClass();
898
-        $arg->sObjectType = new SoapVar($type, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
899
-        $arg->startDate = $startDate;
900
-        $arg->endDate = $endDate;
901
-
902
-        return $this->sforce->getUpdated($arg)->result;
903
-    }
904
-
905
-    /**
906
-     * Executes a query against the specified object and returns data that matches
907
-     * the specified criteria.
908
-     *
909
-     * @param string $query Query String
910
-     * @param QueryOptions $queryOptions Batch size limit.  OPTIONAL
911
-     * @return QueryResult
912
-     */
913
-    public function query($query)
914
-    {
915
-        $this->setHeaders("query");
916
-        $raw = $this->sforce->query(array(
917
-            'queryString' => $query
918
-        ))->result;
919
-        $QueryResult = new QueryResult($raw);
920
-        $QueryResult->setSf($this); // Dependency Injection
921
-        return $QueryResult;
922
-    }
923
-
924
-    /**
925
-     * Retrieves the next batch of objects from a query.
926
-     *
927
-     * @param string $queryLocator Represents the server-side cursor that tracks the current processing location in the query result set.
928
-     * @param QueryOptions $queryOptions Batch size limit.  OPTIONAL
929
-     * @return QueryResult
930
-     */
931
-    public function queryMore($queryLocator)
932
-    {
933
-        $this->setHeaders("queryMore");
934
-        $arg = new stdClass();
935
-        $arg->queryLocator = $queryLocator;
936
-        $raw = $this->sforce->queryMore($arg)->result;
937
-        $QueryResult = new QueryResult($raw);
938
-        $QueryResult->setSf($this); // Dependency Injection
939
-        return $QueryResult;
940
-    }
941
-
942
-    /**
943
-     * Retrieves data from specified objects, whether or not they have been deleted.
944
-     *
945
-     * @param String $query Query String
946
-     * @param QueryOptions $queryOptions Batch size limit.  OPTIONAL
947
-     * @return QueryResult
948
-     */
949
-    public function queryAll($query, $queryOptions = null)
950
-    {
951
-        $this->setHeaders("queryAll");
952
-        $raw = $this->sforce->queryAll(array(
953
-            'queryString' => $query
954
-        ))->result;
955
-        $QueryResult = new QueryResult($raw);
956
-        $QueryResult->setSf($this); // Dependency Injection
957
-        return $QueryResult;
958
-    }
959
-
960
-
961
-    /**
962
-     * Retrieves one or more objects based on the specified object IDs.
963
-     *
964
-     * @param string $fieldList One or more fields separated by commas.
965
-     * @param string $sObjectType Object from which to retrieve data.
966
-     * @param array $ids Array of one or more IDs of the objects to retrieve.
967
-     * @return sObject[]
968
-     */
969
-    public function retrieve($fieldList, $sObjectType, $ids)
970
-    {
971
-        $this->setHeaders("retrieve");
972
-        $arg = new stdClass();
973
-        $arg->fieldList = $fieldList;
974
-        $arg->sObjectType = new SoapVar($sObjectType, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
975
-        $arg->ids = $ids;
976
-
977
-        return $this->sforce->retrieve($arg)->result;
978
-    }
979
-
980
-    /**
981
-     * Executes a text search in your organization's data.
982
-     *
983
-     * @param string $searchString Search string that specifies the text expression to search for.
984
-     * @return SearchResult
985
-     */
986
-    public function search($searchString)
987
-    {
988
-        $this->setHeaders("search");
989
-        $arg = new stdClass();
990
-        $arg->searchString = new SoapVar($searchString, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
847
+	/**
848
+	 * Retrieves available category groups along with their data category structure for objects specified in the request.
849
+	 *
850
+	 * @param DataCategoryGroupSobjectTypePair $pairs
851
+	 * @param bool $topCategoriesOnly Object Type
852
+	 * @return DescribeLayoutResult
853
+	 */
854
+	public function describeDataCategoryGroupStructures(array $pairs, $topCategoriesOnly)
855
+	{
856
+		$this->setHeaders('describeDataCategoryGroupStructures');
857
+		$arg = new stdClass();
858
+		$arg->pairs = $pairs;
859
+		$arg->topCategoriesOnly = new SoapVar($topCategoriesOnly, XSD_BOOLEAN, 'boolean',
860
+			'http://www.w3.org/2001/XMLSchema');
861
+
862
+		return $this->sforce->describeDataCategoryGroupStructures($arg)->result;
863
+	}
991 864
 
992
-        return new SforceSearchResult($this->sforce->search($arg)->result);
993
-    }
865
+	/**
866
+	 * Retrieves the list of individual objects that have been deleted within the
867
+	 * given timespan for the specified object.
868
+	 *
869
+	 * @param string $type Ojbect type
870
+	 * @param string $startDate Start date
871
+	 * @param string $endDate End Date
872
+	 * @return GetDeletedResult
873
+	 */
874
+	public function getDeleted($type, $startDate, $endDate)
875
+	{
876
+		$this->setHeaders("getDeleted");
877
+		$arg = new stdClass();
878
+		$arg->sObjectType = new SoapVar($type, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
879
+		$arg->startDate = $startDate;
880
+		$arg->endDate = $endDate;
881
+
882
+		return $this->sforce->getDeleted($arg)->result;
883
+	}
994 884
 
995
-    /**
996
-     * Retrieves the current system timestamp (GMT) from the Web service.
997
-     *
998
-     * @return timestamp
999
-     */
1000
-    public function getServerTimestamp()
1001
-    {
1002
-        $this->setHeaders("getServerTimestamp");
885
+	/**
886
+	 * Retrieves the list of individual objects that have been updated (added or
887
+	 * changed) within the given timespan for the specified object.
888
+	 *
889
+	 * @param string $type Ojbect type
890
+	 * @param string $startDate Start date
891
+	 * @param string $endDate End Date
892
+	 * @return GetUpdatedResult
893
+	 */
894
+	public function getUpdated($type, $startDate, $endDate)
895
+	{
896
+		$this->setHeaders("getUpdated");
897
+		$arg = new stdClass();
898
+		$arg->sObjectType = new SoapVar($type, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
899
+		$arg->startDate = $startDate;
900
+		$arg->endDate = $endDate;
901
+
902
+		return $this->sforce->getUpdated($arg)->result;
903
+	}
1003 904
 
1004
-        return $this->sforce->getServerTimestamp()->result;
1005
-    }
905
+	/**
906
+	 * Executes a query against the specified object and returns data that matches
907
+	 * the specified criteria.
908
+	 *
909
+	 * @param string $query Query String
910
+	 * @param QueryOptions $queryOptions Batch size limit.  OPTIONAL
911
+	 * @return QueryResult
912
+	 */
913
+	public function query($query)
914
+	{
915
+		$this->setHeaders("query");
916
+		$raw = $this->sforce->query(array(
917
+			'queryString' => $query
918
+		))->result;
919
+		$QueryResult = new QueryResult($raw);
920
+		$QueryResult->setSf($this); // Dependency Injection
921
+		return $QueryResult;
922
+	}
1006 923
 
1007
-    public function getUserInfo()
1008
-    {
1009
-        $this->setHeaders("getUserInfo");
924
+	/**
925
+	 * Retrieves the next batch of objects from a query.
926
+	 *
927
+	 * @param string $queryLocator Represents the server-side cursor that tracks the current processing location in the query result set.
928
+	 * @param QueryOptions $queryOptions Batch size limit.  OPTIONAL
929
+	 * @return QueryResult
930
+	 */
931
+	public function queryMore($queryLocator)
932
+	{
933
+		$this->setHeaders("queryMore");
934
+		$arg = new stdClass();
935
+		$arg->queryLocator = $queryLocator;
936
+		$raw = $this->sforce->queryMore($arg)->result;
937
+		$QueryResult = new QueryResult($raw);
938
+		$QueryResult->setSf($this); // Dependency Injection
939
+		return $QueryResult;
940
+	}
1010 941
 
1011
-        return $this->sforce->getUserInfo()->result;
1012
-    }
942
+	/**
943
+	 * Retrieves data from specified objects, whether or not they have been deleted.
944
+	 *
945
+	 * @param String $query Query String
946
+	 * @param QueryOptions $queryOptions Batch size limit.  OPTIONAL
947
+	 * @return QueryResult
948
+	 */
949
+	public function queryAll($query, $queryOptions = null)
950
+	{
951
+		$this->setHeaders("queryAll");
952
+		$raw = $this->sforce->queryAll(array(
953
+			'queryString' => $query
954
+		))->result;
955
+		$QueryResult = new QueryResult($raw);
956
+		$QueryResult->setSf($this); // Dependency Injection
957
+		return $QueryResult;
958
+	}
1013 959
 
1014
-    /**
1015
-     * Sets the specified user's password to the specified value.
1016
-     *
1017
-     * @param string $userId ID of the User.
1018
-     * @param string $password New password
1019
-     */
1020
-    public function setPassword($userId, $password)
1021
-    {
1022
-        $this->setHeaders("setPassword");
1023
-        $arg = new stdClass();
1024
-        $arg->userId = new SoapVar($userId, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
1025
-        $arg->password = $password;
1026
-
1027
-        return $this->sforce->setPassword($arg);
1028
-    }
1029
-
1030
-    /**
1031
-     * Changes a user's password to a system-generated value.
1032
-     *
1033
-     * @param string $userId Id of the User
1034
-     * @return password
1035
-     */
1036
-    public function resetPassword($userId)
1037
-    {
1038
-        $this->setHeaders("resetPassword");
1039
-        $arg = new stdClass();
1040
-        $arg->userId = new SoapVar($userId, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
1041
-
1042
-        return $this->sforce->resetPassword($arg)->result;
1043
-    }
960
+
961
+	/**
962
+	 * Retrieves one or more objects based on the specified object IDs.
963
+	 *
964
+	 * @param string $fieldList One or more fields separated by commas.
965
+	 * @param string $sObjectType Object from which to retrieve data.
966
+	 * @param array $ids Array of one or more IDs of the objects to retrieve.
967
+	 * @return sObject[]
968
+	 */
969
+	public function retrieve($fieldList, $sObjectType, $ids)
970
+	{
971
+		$this->setHeaders("retrieve");
972
+		$arg = new stdClass();
973
+		$arg->fieldList = $fieldList;
974
+		$arg->sObjectType = new SoapVar($sObjectType, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
975
+		$arg->ids = $ids;
976
+
977
+		return $this->sforce->retrieve($arg)->result;
978
+	}
979
+
980
+	/**
981
+	 * Executes a text search in your organization's data.
982
+	 *
983
+	 * @param string $searchString Search string that specifies the text expression to search for.
984
+	 * @return SearchResult
985
+	 */
986
+	public function search($searchString)
987
+	{
988
+		$this->setHeaders("search");
989
+		$arg = new stdClass();
990
+		$arg->searchString = new SoapVar($searchString, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
991
+
992
+		return new SforceSearchResult($this->sforce->search($arg)->result);
993
+	}
994
+
995
+	/**
996
+	 * Retrieves the current system timestamp (GMT) from the Web service.
997
+	 *
998
+	 * @return timestamp
999
+	 */
1000
+	public function getServerTimestamp()
1001
+	{
1002
+		$this->setHeaders("getServerTimestamp");
1003
+
1004
+		return $this->sforce->getServerTimestamp()->result;
1005
+	}
1006
+
1007
+	public function getUserInfo()
1008
+	{
1009
+		$this->setHeaders("getUserInfo");
1010
+
1011
+		return $this->sforce->getUserInfo()->result;
1012
+	}
1013
+
1014
+	/**
1015
+	 * Sets the specified user's password to the specified value.
1016
+	 *
1017
+	 * @param string $userId ID of the User.
1018
+	 * @param string $password New password
1019
+	 */
1020
+	public function setPassword($userId, $password)
1021
+	{
1022
+		$this->setHeaders("setPassword");
1023
+		$arg = new stdClass();
1024
+		$arg->userId = new SoapVar($userId, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
1025
+		$arg->password = $password;
1026
+
1027
+		return $this->sforce->setPassword($arg);
1028
+	}
1029
+
1030
+	/**
1031
+	 * Changes a user's password to a system-generated value.
1032
+	 *
1033
+	 * @param string $userId Id of the User
1034
+	 * @return password
1035
+	 */
1036
+	public function resetPassword($userId)
1037
+	{
1038
+		$this->setHeaders("resetPassword");
1039
+		$arg = new stdClass();
1040
+		$arg->userId = new SoapVar($userId, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema');
1041
+
1042
+		return $this->sforce->resetPassword($arg)->result;
1043
+	}
1044 1044
 }
Please login to merge, or discard this patch.