-
Notifications
You must be signed in to change notification settings - Fork 347
Expand file tree
/
Copy pathUtilities.php
More file actions
executable file
·1483 lines (1258 loc) · 37.7 KB
/
Copy pathUtilities.php
File metadata and controls
executable file
·1483 lines (1258 loc) · 37.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Various QuickBooks related utility methods
*
* Copyright (c) 2010-04-16 Keith Palmer / ConsoliBYTE, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.opensource.org/licenses/eclipse-1.0.php
*
* @author Keith Palmer <keith@consolibyte.com>
* @license LICENSE.txt
*
* @package QuickBooks
*/
/**
* QuickBooks driver factory, used to fetch driver instances
*/
QuickBooks_Loader::load('/QuickBooks/Driver/Factory.php');
/**
* Various QuickBooks related utilities
*
* All methods are static
*/
class QuickBooks_Utilities
{
/**
* Parse a DSN style connection string
*
* @param string $dsn The DSN connection string
* @param string $part If you want just a specific part of the string, choose which part here: scheme, host, port, user, pass, query, fragment
* @return mixed An array or a string, depending on if you wanted the whole thing parsed or just a piece of it
*/
static public function parseDSN($dsn, $defaults = array(), $part = null)
{
// Some DSN strings look like this: filesystem:///path/to/file
// parse_url() will not parse this *unless* we provide some sort of hostname (in this case, null)
$dsn = str_replace(':///', '://null/', $dsn);
$defaults = array_merge(array(
'scheme' => '',
'host' => '',
'port' => 0,
'user' => '',
'pass' => '',
'path' => '',
'query' => '',
'fragment' => '',
), $defaults);
$parse = array_merge($defaults, parse_url($dsn));
$parse['user'] = urldecode($parse['user']);
$parse['pass'] = urldecode($parse['pass']);
if (is_null($part))
{
return $parse;
}
else if (isset($parse[$part]))
{
return $parse[$part];
}
return null;
}
/**
* Mask certain sensitive data from occuring in output/logs
*
* @param string $message
* @returns string
*/
static public function mask($message)
{
$masks = array(
'<SessionTicket>',
'<ConnectionTicket>',
'<CreditCardNumber>',
'<CardSecurityCode>',
'<AppID>',
'<strPassword>',
);
foreach ($masks as $key)
{
if (substr($key, 0, 1) == '<')
{
// It's an XML tag
$contents = QuickBooks_Utilities::_extractTagContents(trim($key, '<> '), $message);
$masked = str_repeat('x', min(strlen($contents ?? ''), 12)) . substr($contents ?? '', 12);
$message = str_replace($key . $contents . '</' . trim($key, '<> ') . '>', $key . $masked . '</' . trim($key, '<> ') . '>', $message);
}
}
return $message;
}
/**
* @deprecated Use QuickBooks_XML::extractTagContents() instead
*/
static protected function _extractTagContents($tag, $data)
{
$tmp = QuickBooks_XML::extractTagContents($tag, $data);
return $tmp;
}
/**
* Write a message to the log (via the back-end driver)
*
* @param string $dsn The DSN connection string to the logger
* @param string $msg The message to log
* @param integer $lvl The message log level
* @return boolean Whether or not the message was logged
*/
static public function log($dsn, $msg, $lvl = QUICKBOOKS_LOG_NORMAL)
{
$Driver = QuickBooks_Utilities::driverFactory($dsn);
// Mask important data
$msg = QuickBooks_Utilities::mask($msg);
return $Driver->log($msg, null, $lvl);
}
/**
*
* 1 2 3
* -3 -2 -1
* domainParts('tools.consolibyte.com');
* 0 1 2
*
*/
/*static public function domainParts($domain, $part = null)
{
$tmp = explode('.', $domain);
$part = (int) $part;
if ($part > 0 and
isset($tmp[$part - 1]))
{
return $tmp[$part - 1];
}
else if ($part < 0 and
isset($tmp[count($tmp) + $part]))
{
return $tmp[count($tmp) + $part];
}
return $tmp;
}*/
/**
* Extract the requestID attribute from an XML stream
*
* @param string $xml The XML stream to look for a requestID attribute in
* @return mixed The request ID
*/
static public function extractRequestID($xml)
{
$look = array(
);
if (false !== ($start = strpos($xml, ' requestID="')) and
false !== ($end = strpos($xml, '"', $start + 12)))
{
return substr($xml, $start + 12, $end - $start - 12);
}
return false;
}
/**
* Create a requestID string from action and ident parts
*
* @param string $action
* @param mixed $ident
* @return string
*/
static public function constructRequestID($action, $ident)
{
return base64_encode($action . '|' . $ident);
}
/**
* Parse a requestID string into it's action and ident parts
*
* @param string $requestID
* @param string $action
* @param mixed $ident
* @return boolean
*/
static public function parseRequestID($requestID, &$action, &$ident)
{
$tmp = explode('|', base64_decode($requestID));
if (count($tmp) == 2)
{
$action = $tmp[0];
$ident = $tmp[1];
return true;
}
$action = null;
$ident = null;
return false;
}
/**
* Create an instance of a driver class from a DSN connection string *or* a connection resource
*
* You can actually pass in *either* a DSN-style connection string OR an already connected database resource
* - mysql://user:pass@localhost:port/database
* - $var (Resource ID #XYZ, valid MySQL connection resource)
*
* @param mixed $dsn_or_conn A DSN-style connection string or a PHP resource
* @param array $config An array of configuration options for the driver
* @param array $hooks An array mapping hooks to user-defined hook functions to call
* @param integer $log_level
* @return object A class instance, a child class of QuickBooks_Driver
*/
static public function driverFactory($dsn_or_conn, $config = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL)
{
return QuickBooks_Driver_Factory::create($dsn_or_conn, $config, $hooks, $log_level);
}
/**
*
*
* @param string $module
* @param string $key
* @param mixed $value
* @param string $type
* @param array $opts
* @return boolean
*/
static public function configWrite($dsn, $user, $module, $key, $value, $type = null, $opts = null)
{
if ($Driver = QuickBooks_Utilities::driverFactory($dsn))
{
return $Driver->configWrite($user, $module, $key, $value, $type, $opts);
}
return false;
}
/**
*
*
* @param string $module
* @param string $key
* @param string $type
* @param array $opts
* @return mixed
*/
static public function configRead($dsn, $user, $module, $key, &$type, &$opts)
{
if ($Driver = QuickBooks_Utilities::driverFactory($dsn))
{
return $Driver->configRead($user, $module, $key, $type, $opts);
}
return false;
}
/**
* Convert a time interval to a number of seconds (i.e.: "1 hour" => 600, "3 hours" => 1800, "2 minutes" => 120, etc.)
*
* @param mixed $interval
* @return integer
*/
static public function intervalToSeconds($interval)
{
if ( (string) (int) $interval === (string) $interval)
{
// It's already an integer...
}
else
{
$intervals = array(
'second' => 1,
'minute' => 60,
'hour' => 60 * 60,
'day' => 60 * 60 * 24,
'week' => 60 * 60 * 24 * 7,
'month' => 60 * 60 * 24 * 30,
'year' => 60 * 60 * 24 * 365,
);
$interval = strtolower(trim($interval));
$justletters = true;
$count = strlen($interval);
for ($i = 0; $i < $count; $i++)
{
if (ord($interval[$i]) < 97 or ord($interval[$i]) > 122)
{
$justletters = false;
}
}
if ($justletters)
{
$interval = '1 ' . $interval;
}
foreach ($intervals as $str => $multiplier)
{
if (false !== strpos($interval, ' ' . $str))
{
$interval = ((int) $interval) * $multiplier;
}
}
}
// If it's not an integer yet, cast it!
return (int) $interval;
}
/**
* Check if a given IP address lies within a CIDR range
*
* @param string $remoteaddr The remote machine's IP address (example: 192.168.1.4)
* @param string $CIDR A CIDR network address (example: 192.168.0.0/24)
* @return boolean
*/
static protected function _checkCIDR($remoteaddr, $CIDR)
{
$remoteaddr_long = ip2long($remoteaddr);
list ($net, $mask) = split('/', $CIDR);
$ip_net = ip2long($net);
$ip_mask = ~((1 << (32 - $mask)) - 1);
$remoteaddr_net = $remoteaddr_long & $ip_mask;
return $remoteaddr_net == $ip_net;
}
/**
* Check if a given remote address (IP address) is allowed based on allow and deny arrays
*
* @param string $remoteaddr
* @param array $allow
* @param array $deny
* @return boolean
*/
static public function checkRemoteAddress($remoteaddr, $arr_allow, $arr_deny)
{
$allowed = true;
if (count($arr_allow))
{
// only allow these addresses
$allowed = false;
foreach ($arr_allow as $allow)
{
if (false !== strpos($allow, '/'))
{
// CIDR notation
if (QuickBooks_Utilities::_checkCIDR($remoteaddr, $allow))
{
$allowed = true;
break;
}
}
else if (ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $allow))
{
// IPv4 address
if ($remoteaddr == $allow)
{
$allowed = true;
break;
}
}
}
if (!$allowed)
{
return false;
}
}
if (count($arr_deny))
{
// do *not* allow these addresses
foreach ($arr_deny as $deny)
{
if (false !== strpos($deny, '/'))
{
// CIDR notation
if (QuickBooks_Utilities::_checkCIDR($remoteaddr, $deny))
{
return false;
}
}
else if (ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $deny))
{
// IPv4 address
if ($remoteaddr == $deny)
{
return false;
}
}
}
}
return $allowed;
}
/**
* Create a user for the QuickBooks Web Connector SOAP server
*
* @param string $dsn A DSN-style connection string for the back-end driver
* @param string $username The username for the new user
* @param string $password The password for the new user
* @param string $company_file
* @param string $wait_before_next_update
* @param string $min_run_every_n_seconds
* @return boolean
*/
static public function createUser($dsn, $username, $password, $company_file = null, $wait_before_next_update = null, $min_run_every_n_seconds = null)
{
$driver = QuickBooks_Utilities::driverFactory($dsn);
return $driver->authCreate($username, $password, $company_file, $wait_before_next_update, $min_run_every_n_seconds);
}
/**
* Disable a user for the QuickBooks Web Connector SOAP server
*
* @param string $dsn A DSN-style connection string
* @param string $username The username for the user to disable
* @return boolean
*/
static public function disableUser($dsn, $username)
{
$driver = QuickBooks_Utilities::driverFactory($dsn);
return $driver->authDisable($username);
}
/**
* Generate a unique hash from a bunch of variables
*
* @param mixed $mixed1
* @param mixed $mixed2
* @param mixed $mixed3
* @param mixed $mixed4
* @param mixed $mixed5
* @return string
*/
static public function generateUniqueHash($mixed1, $mixed2 = null, $mixed3 = null, $mixed4 = null, $mixed5 = null)
{
return md5(serialize($mixed1) . serialize($mixed2) . serialize($mixed3) . serialize($mixed4) . serialize($mixed5));
}
/**
* Create a mapping between a QuickBooks object and an object in your own database/application
*
* @param string $dsn
* @param string $user
* @param string $object_type
* @param string $TxnID_or_ListID
* @param string $app_ID
* @return boolean
*/
public static function createMapping($dsn, $user, $object_type, $TxnID_or_ListID, $app_ID, $editsequence = '')
{
$Driver = QuickBooks_Utilities::driverFactory($dsn);
return $Driver->identMap($user, $object_type, $app_ID, $TxnID_or_ListID, $editsequence);
}
/**
*
*
* @param string $dsn
* @param string $user
* @param string $object_type
* @param string $TxnID_or_ListID
* @return mixed
*/
public static function fetchApplicationID($dsn, $user, $object_type, $TxnID_or_ListID)
{
$Driver = QuickBooks_Utilities::driverFactory($dsn);
$extra = null;
return $Driver->identToApplication($user, $object_type, $TxnID_or_ListID, $extra);
}
/**
*
*/
public static function hasApplicationID($dsn, $user, $object_type, $TxnID_or_ListID)
{
if (QuickBooks_Utilities::fetchApplicationID($dsn, $user, $object_type, $TxnID_or_ListID))
{
return true;
}
return false;
}
/**
*
* @param string $object_type A QuickBooks object-type constant, i.e.: QUICKBOOKS_OBJECT_CUSTOMER, QUICKBOOKS_OBJECT_INVOICE, etc.
* @param mixed $webapp_ID The unique ID or PRIMARY KEY of the object within your application
* @return string A QuickBooks TxnID or ListID
*/
public static function fetchQuickbooksID($dsn, $user, $object_type, $webapp_ID)
{
$Driver = QuickBooks_Utilities::driverFactory($dsn);
$editseq = null;
$extra = null;
return $Driver->identToQuickBooks($user, $object_type, $webapp_ID, $editseq, $extra);
}
/**
*
*
*
*/
public static function fetchQuickBooksEditSequence($dsn, $user, $object_type, $webapp_ID)
{
$Driver = QuickBooks_Utilities::driverFactory($dsn);
$editseq = null;
$extra = null;
$Driver->identToQuickBooks($user, $object_type, $webapp_ID, $editseq, $extra);
return $editseq;
}
/**
* Fetches extra data stored along with the mapping of a QuickBooks ListID or TxnID to application primary key
*
* @param string $dsn The driver connection string
* @param string $user The QuickBooks username
* @param string $object_type The object type (e.g. QUICKBOOKS_OBJECT_CUSTOMER, or QUICKBOOKS_OBJECT_INVOICE, etc.)
* @param mixed $webapp_ID The primary key for the record
* @return mixed Any extra data stored
*/
public static function fetchQuickBooksExtra($dsn, $user, $object_type, $webapp_ID)
{
$Driver = QuickBooks_Utilities::driverFactory($dsn);
$editseq = null;
$extra = null;
$Driver->identToQuickBooks($user, $object_type, $webapp_ID, $editseq, $extra);
return $extra;
}
/**
* Alias of {@link QuickBooks_Utilities::fetchQuickBooksEditSequence()}
*/
public static function fetchEditSequence($dsn, $user, $object_type, $webapp_ID)
{
return QuickBooks_Utilities::fetchQuickBooksEditSequence($dsn, $user, $object_type, $webapp_ID);
}
/**
* Tell whether or not a given object has a ListID or TxnID associated with it
*
* * Note *
* This function *does not* query QuickBooks, it only queries the internal
* mapping of QuickBooks IDs to PRIMARY KEYS. The mappings can be created
* with the {@link QuickBooks_Utilities::createMapping()} method and the API
* tries to automatically create the mapping when you add or update an
* object and provide a PRIMARY KEY when calling the ->add* or ->update*
* method.
*
* @param string $object_type
* @param mixed $app_ID
* @return boolean
*/
public static function hasQuickBooksID($dsn, $user, $object_type, $app_ID)
{
if (QuickBooks_Utilities::fetchQuickBooksID($dsn, $user, $object_type, $app_ID))
{
return true;
}
return false;
}
/**
* Initialize the backend driver
*
* Initialization should only be done once, and is used to take care of
* things like creating the database schema, etc.
*
* @param string $dsn A DSN-style connection string
* @param array $driver_options
* @return boolean
*/
static public function initialize($dsn, $driver_options = array(), $init_options = array())
{
$Driver = QuickBooks_Utilities::driverFactory($dsn, $driver_options);
return $Driver->initialize($init_options);
}
/**
* Tell whether or not a driver has been initialized
*
* @param string $dsn
* @param array $driver_options
* @return boolean
*/
static public function initialized($dsn, $driver_options = array())
{
$Driver = QuickBooks_Utilities::driverFactory($dsn, $driver_options);
return $Driver->initialized();
}
/**
*
*
*/
static public function date($date = null)
{
if ($date)
{
if (is_numeric($date) and
strlen($date) > 6)
{
return date('Y-m-d', $date);
}
return date('Y-m-d', strtotime($date));
}
return date('Y-m-d');
}
/**
*
*
* @return string
*/
static public function datetime($datetime = null)
{
if ($datetime)
{
if (is_numeric($datetime) and
strlen($datetime) > 6)
{
return date('Y-m-d', $datetime) . 'T' . date('H:i:s', $datetime);
}
return date('Y-m-d', strtotime($datetime)) . 'T' . date('H:i:s', strtotime($datetime));
}
return date('Y-m-d') . 'T' . date('H:i:s');
}
/**
* Tell if a pattern matches a string or not (Windows-compatible version of www.php.net/fnmatch)
*
* @param string $pattern
* @param string $str
* @return boolean
*/
static public function fnmatch($pattern, $str)
{
if (function_exists('fnmatch'))
{
return fnmatch($pattern, $str, FNM_CASEFOLD);
}
$arr = array(
'\*' => '.*',
'\?' => '.'
);
return preg_match('#^' . strtr(preg_quote($pattern, '#'), $arr) . '$#i', $str);
}
/**
* List all of the QuickBooks object types supported by the framework
*
* @param string $filter
* @param boolean $return_keys
* @param boolean $order_for_mapping
* @return array
*/
static public function listObjects($filter = null, $return_keys = false, $order_for_mapping = false)
{
static $cache = array();
$crunch = $filter . '[' . $return_keys . '[' . $order_for_mapping;
if (isset($cache[$crunch]))
{
return $cache[$crunch];
}
$constants = array();
foreach (get_defined_constants() as $constant => $value)
{
if (substr($constant, 0, strlen('QUICKBOOKS_OBJECT_')) == 'QUICKBOOKS_OBJECT_' and
substr_count($constant, '_') == 2)
{
if (!$return_keys)
{
$constant = $value;
}
if ($filter)
{
if (QuickBooks_Utilities::fnmatch($filter, $constant))
{
$constants[] = $constant;
}
}
else
{
$constants[] = $constant;
}
}
}
if ($order_for_mapping)
{
// Sort with the very longest values first, to the shortest values last
usort($constants, function($a, $b){ return strlen($a) > strlen($b) ? -1 : 1; });
}
else
{
sort($constants);
}
$cache[$crunch] = $constants;
return $constants;
}
/**
* Convert a QuickBooks action to a QuickBooks object type (i.e.: QUICKBOOKS_ADD_CUSTOMER gets converted to QUICKBOOKS_OBJECT_CUSTOMER)
*
* @param string $action
* @return string
*/
static public function actionToObject($action)
{
static $cache = array();
if (isset($cache[$action]))
{
//print('returning cached [' . $action . ']' . "\n");
return $cache[$action];
}
$types = QuickBooks_Utilities::listObjects(null, false, true);
foreach ($types as $type)
{
if (QuickBooks_Utilities::fnmatch('*' . $type . '*', $action))
{
$cache[$action] = $type;
//print('returning [' . $action . '] => ' . $type . "\n");
return $type;
}
}
return null;
}
/**
* Generate a GUID
*
* Note: This is used for tickets too, so it *must* be a RANDOM GUID!
*
* @param boolean $surround
* @return string
*/
static public function GUID()
{
$guid = sprintf('%04x%04x-%04x-%03x4-%04x-%04x%04x%04x',
mt_rand(0, 65535), mt_rand(0, 65535),
mt_rand(0, 65535),
mt_rand(0, 4095),
bindec(substr_replace(sprintf('%016b', mt_rand(0, 65535)), '01', 6, 2)),
mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)
);
return $guid;
}
/**
* Try to guess the queueing priority for this action
*
* @param string $action The action you're trying to guess for
* @param string $dependency If the action depends on another action (i.e. a DataExtAdd for a CustomerAdd) you can pass the dependency here
* @return integer A best guess at the proper priority
*/
static public function priorityForAction($action, $dependency = null)
{
// low priorities up here (*lots* of dependencies)
static $priorities = array(
QUICKBOOKS_DELETE_TRANSACTION,
QUICKBOOKS_VOID_TRANSACTION,
QUICKBOOKS_DEL_DATAEXT,
QUICKBOOKS_MOD_DATAEXT,
QUICKBOOKS_ADD_DATAEXT,
QUICKBOOKS_MOD_JOURNALENTRY,
QUICKBOOKS_ADD_JOURNALENTRY,
QUICKBOOKS_MOD_RECEIVEPAYMENT,
QUICKBOOKS_ADD_RECEIVEPAYMENT,
QUICKBOOKS_MOD_BILLPAYMENTCHECK,
QUICKBOOKS_ADD_BILLPAYMENTCHECK,
//QUICKBOOKS_MOD_BILLPAYMENTCREDITCARD,
QUICKBOOKS_ADD_BILLPAYMENTCREDITCARD,
QUICKBOOKS_MOD_BILL,
QUICKBOOKS_ADD_BILL,
QUICKBOOKS_MOD_PURCHASEORDER,
QUICKBOOKS_ADD_PURCHASEORDER,
QUICKBOOKS_MOD_INVOICE,
QUICKBOOKS_ADD_INVOICE,
QUICKBOOKS_MOD_SALESORDER,
QUICKBOOKS_ADD_SALESORDER,
QUICKBOOKS_MOD_ESTIMATE,
QUICKBOOKS_ADD_ESTIMATE,
QUICKBOOKS_ADD_INVENTORYADJUSTMENT,
QUICKBOOKS_ADD_CREDITMEMO,
QUICKBOOKS_MOD_CREDITMEMO,
QUICKBOOKS_ADD_ITEMRECEIPT,
QUICKBOOKS_MOD_ITEMRECEIPT,
QUICKBOOKS_MOD_SALESRECEIPT,
QUICKBOOKS_ADD_SALESRECEIPT,
QUICKBOOKS_ADD_SALESTAXITEM,
QUICKBOOKS_MOD_SALESTAXITEM,
QUICKBOOKS_ADD_DISCOUNTITEM,
QUICKBOOKS_MOD_DISCOUNTITEM,
QUICKBOOKS_ADD_OTHERCHARGEITEM,
QUICKBOOKS_MOD_OTHERCHARGEITEM,
QUICKBOOKS_MOD_NONINVENTORYITEM,
QUICKBOOKS_ADD_NONINVENTORYITEM,
QUICKBOOKS_MOD_INVENTORYITEM,
QUICKBOOKS_ADD_INVENTORYITEM,
QUICKBOOKS_MOD_INVENTORYASSEMBLYITEM,
QUICKBOOKS_ADD_INVENTORYASSEMBLYITEM,
QUICKBOOKS_MOD_SERVICEITEM,
QUICKBOOKS_ADD_SERVICEITEM,
QUICKBOOKS_MOD_PAYMENTITEM,
QUICKBOOKS_ADD_PAYMENTITEM,
QUICKBOOKS_MOD_SALESREP,
QUICKBOOKS_ADD_SALESREP,
QUICKBOOKS_MOD_EMPLOYEE,
QUICKBOOKS_ADD_EMPLOYEE,
//QUICKBOOKS_MOD_SALESTAXCODE, // The SDK doesn't support this
QUICKBOOKS_ADD_SALESTAXCODE,
QUICKBOOKS_MOD_VENDOR,
QUICKBOOKS_ADD_VENDOR,
QUICKBOOKS_MOD_JOB,
QUICKBOOKS_ADD_JOB,
QUICKBOOKS_MOD_CUSTOMER,
QUICKBOOKS_ADD_CUSTOMER,
QUICKBOOKS_MOD_ACCOUNT,
QUICKBOOKS_ADD_ACCOUNT,
//QUICKBOOKS_MOD_CLASS, (does not exist in qbXML API)
QUICKBOOKS_ADD_CLASS,
QUICKBOOKS_ADD_PAYMENTMETHOD,
QUICKBOOKS_ADD_SHIPMETHOD,
// Queries
QUICKBOOKS_QUERY_PURCHASEORDER,
QUICKBOOKS_QUERY_ITEMRECEIPT,
QUICKBOOKS_QUERY_SALESORDER,
QUICKBOOKS_QUERY_SALESRECEIPT,
QUICKBOOKS_QUERY_INVOICE,
QUICKBOOKS_QUERY_ESTIMATE,
QUICKBOOKS_QUERY_RECEIVEPAYMENT,
QUICKBOOKS_QUERY_CREDITMEMO,
QUICKBOOKS_QUERY_BILLPAYMENTCHECK,
QUICKBOOKS_QUERY_BILLPAYMENTCREDITCARD,
QUICKBOOKS_QUERY_BILLTOPAY,
QUICKBOOKS_QUERY_BILL,
QUICKBOOKS_QUERY_CREDITCARDCHARGE,
QUICKBOOKS_QUERY_CREDITCARDCREDIT,
QUICKBOOKS_QUERY_CHECK,
QUICKBOOKS_QUERY_CHARGE,
QUICKBOOKS_QUERY_DELETEDLISTS, // This gets all items deleted in the last 90 days
QUICKBOOKS_QUERY_DELETEDTXNS, // This gets all transactions deleted in the last 90 days
QUICKBOOKS_QUERY_TIMETRACKING,
QUICKBOOKS_QUERY_VENDORCREDIT,
QUICKBOOKS_QUERY_INVENTORYADJUSTMENT,
QUICKBOOKS_QUERY_ITEM,
QUICKBOOKS_QUERY_DISCOUNTITEM,
QUICKBOOKS_QUERY_SALESTAXITEM,
QUICKBOOKS_QUERY_SERVICEITEM,
QUICKBOOKS_QUERY_NONINVENTORYITEM,
QUICKBOOKS_QUERY_INVENTORYITEM,
QUICKBOOKS_QUERY_SALESREP,
QUICKBOOKS_QUERY_VEHICLEMILEAGE,
QUICKBOOKS_QUERY_VEHICLE,
QUICKBOOKS_QUERY_CUSTOMER,
QUICKBOOKS_QUERY_VENDOR,
QUICKBOOKS_QUERY_EMPLOYEE,
QUICKBOOKS_QUERY_JOB,
QUICKBOOKS_QUERY_WORKERSCOMPCODE,
QUICKBOOKS_QUERY_UNITOFMEASURESET,
QUICKBOOKS_QUERY_JOURNALENTRY,
QUICKBOOKS_QUERY_DEPOSIT,
QUICKBOOKS_QUERY_SHIPMETHOD,
QUICKBOOKS_QUERY_PAYMENTMETHOD,
QUICKBOOKS_QUERY_PRICELEVEL,
QUICKBOOKS_QUERY_DATEDRIVENTERMS,
QUICKBOOKS_QUERY_BILLINGRATE,
QUICKBOOKS_QUERY_CUSTOMERTYPE,
QUICKBOOKS_QUERY_CUSTOMERMSG,
QUICKBOOKS_QUERY_TERMS,
QUICKBOOKS_QUERY_SALESTAXCODE,
QUICKBOOKS_QUERY_ACCOUNT,
QUICKBOOKS_QUERY_CLASS,
QUICKBOOKS_QUERY_JOBTYPE,
QUICKBOOKS_QUERY_VENDORTYPE,
QUICKBOOKS_QUERY_COMPANY,
QUICKBOOKS_IMPORT_RECEIVEPAYMENT,
QUICKBOOKS_IMPORT_PURCHASEORDER,
QUICKBOOKS_IMPORT_ITEMRECEIPT,
QUICKBOOKS_IMPORT_SALESRECEIPT,
// The ESTIMATE, then INVOICE, then SALES ORDER order is important,
// because we might have events which depend on the estimate being present
// when the invoice is imported, or the sales order being present when
// then invoice is imported, etc.
QUICKBOOKS_IMPORT_INVOICE,
QUICKBOOKS_IMPORT_SALESORDER,
QUICKBOOKS_IMPORT_ESTIMATE,
QUICKBOOKS_IMPORT_BILLPAYMENTCHECK,
QUICKBOOKS_IMPORT_BILLPAYMENTCREDITCARD,