ActiveCampaign_Subscriptions - Version 1.5.2

Version Notes

Applied update for SUPEE-6788 security issue.

Also updated the ActiveCampaign PHP API wrapper files to the latest version.

Download this release

Release Info

Developer ActiveCampaign, Inc.
Extension ActiveCampaign_Subscriptions
Version 1.5.2
Comparing to
See all releases


Code changes from version 1.5.1 to 1.5.2

Files changed (21) hide show
  1. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Account.class.php +5 -1
  2. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/ActiveCampaign.class.php +49 -11
  3. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Auth.class.php +24 -20
  4. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Automation.class.php +51 -0
  5. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Campaign.class.php +132 -128
  6. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Connector.class.php +225 -145
  7. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Contact.class.php +121 -0
  8. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Deal.class.php +139 -0
  9. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Design.class.php +30 -26
  10. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Form.class.php +290 -252
  11. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Group.class.php +54 -50
  12. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/List.class.php +90 -80
  13. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Message.class.php +102 -98
  14. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Settings.class.php +25 -0
  15. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Subscriber.class.php +1 -74
  16. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Tracking.class.php +118 -0
  17. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/User.class.php +70 -66
  18. app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Webhook.class.php +83 -50
  19. app/code/community/ActiveCampaign/Subscriptions/etc/config.xml +11 -11
  20. app/design/adminhtml/default/default/layout/subscriptions.xml +3 -3
  21. package.xml +8 -8
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Account.class.php CHANGED
@@ -2,10 +2,14 @@
2
 
3
  class AC_Account extends ActiveCampaign {
4
 
 
 
5
  public $url;
6
  public $api_key;
7
 
8
- function __construct($url, $api_key) {
 
 
9
  $this->url = $url;
10
  $this->api_key = $api_key;
11
  }
2
 
3
  class AC_Account extends ActiveCampaign {
4
 
5
+ public $version;
6
+ public $url_base;
7
  public $url;
8
  public $api_key;
9
 
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
  $this->url = $url;
14
  $this->api_key = $api_key;
15
  }
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/ActiveCampaign.class.php CHANGED
@@ -1,37 +1,59 @@
1
  <?php
2
 
3
  if ( !defined("ACTIVECAMPAIGN_URL") || (!defined("ACTIVECAMPAIGN_API_KEY") && !defined("ACTIVECAMPAIGN_API_USER") && !defined("ACTIVECAMPAIGN_API_PASS")) ) {
4
- include "config.php";
5
  }
6
 
7
  require_once("Connector.class.php");
8
 
9
  class ActiveCampaign extends AC_Connector {
10
 
 
11
  public $url;
12
  public $api_key;
 
 
 
 
 
13
 
14
  function __construct($url, $api_key, $api_user = "", $api_pass = "") {
15
- $this->url = $url;
16
  $this->api_key = $api_key;
17
- AC_Connector::__construct($url, $api_key, $api_user, $api_pass);
 
 
 
 
 
 
 
18
  }
19
 
20
  function api($path, $post_data = array()) {
21
- // IE: "subscriber/view"
22
  $components = explode("/", $path);
23
  $component = $components[0];
24
 
 
 
 
 
 
 
 
 
 
25
  if (preg_match("/\?/", $components[1])) {
26
  // query params appended to method
27
- // IE: subscriber/edit?overwrite=0
28
  $method_arr = explode("?", $components[1]);
29
  $method = $method_arr[0];
30
  $params = $method_arr[1];
31
  }
32
  else {
33
  // just a method provided
34
- // IE: "subscriber/view
35
  if ( isset($components[1]) ) {
36
  $method = $components[1];
37
  $params = "";
@@ -50,25 +72,36 @@ class ActiveCampaign extends AC_Connector {
50
  $component = "design";
51
  }
52
  elseif ($component == "sync") {
53
- $component = "subscriber";
54
  $method = "sync";
55
  }
56
  elseif ($component == "singlesignon") {
57
  $component = "auth";
58
  }
59
 
60
- $class = ucwords($component); // IE: "subscriber" becomes "Subscriber"
61
  $class = "AC_" . $class;
62
- // IE: new Subscriber();
63
 
64
- $class = new $class($this->url, $this->api_key);
65
- // IE: $subscriber->view();
 
 
 
 
 
 
 
 
 
66
 
67
  if ($method == "list") {
68
  // reserved word
69
  $method = "list_";
70
  }
71
 
 
 
72
  $response = $class->$method($params, $post_data);
73
  return $response;
74
  }
@@ -77,13 +110,18 @@ class ActiveCampaign extends AC_Connector {
77
 
78
  require_once("Account.class.php");
79
  require_once("Auth.class.php");
 
80
  require_once("Campaign.class.php");
 
 
81
  require_once("Design.class.php");
82
  require_once("Form.class.php");
83
  require_once("Group.class.php");
84
  require_once("List.class.php");
85
  require_once("Message.class.php");
 
86
  require_once("Subscriber.class.php");
 
87
  require_once("User.class.php");
88
  require_once("Webhook.class.php");
89
 
1
  <?php
2
 
3
  if ( !defined("ACTIVECAMPAIGN_URL") || (!defined("ACTIVECAMPAIGN_API_KEY") && !defined("ACTIVECAMPAIGN_API_USER") && !defined("ACTIVECAMPAIGN_API_PASS")) ) {
4
+ require_once(dirname(__FILE__) . "/config.php");
5
  }
6
 
7
  require_once("Connector.class.php");
8
 
9
  class ActiveCampaign extends AC_Connector {
10
 
11
+ public $url_base;
12
  public $url;
13
  public $api_key;
14
+ public $track_email;
15
+ public $track_actid;
16
+ public $track_key;
17
+ public $version = 1;
18
+ public $debug = false;
19
 
20
  function __construct($url, $api_key, $api_user = "", $api_pass = "") {
21
+ $this->url_base = $this->url = $url;
22
  $this->api_key = $api_key;
23
+ parent::__construct($url, $api_key, $api_user, $api_pass);
24
+ }
25
+
26
+ function version($version) {
27
+ $this->version = (int)$version;
28
+ if ($version == 2) {
29
+ $this->url_base = $this->url_base . "/2";
30
+ }
31
  }
32
 
33
  function api($path, $post_data = array()) {
34
+ // IE: "contact/view"
35
  $components = explode("/", $path);
36
  $component = $components[0];
37
 
38
+ if (count($components) > 2) {
39
+ // IE: "contact/tag/add?whatever"
40
+ // shift off the first item (the component, IE: "contact").
41
+ array_shift($components);
42
+ // IE: convert to "tag_add?whatever"
43
+ $method_str = implode("_", $components);
44
+ $components = array($component, $method_str);
45
+ }
46
+
47
  if (preg_match("/\?/", $components[1])) {
48
  // query params appended to method
49
+ // IE: contact/edit?overwrite=0
50
  $method_arr = explode("?", $components[1]);
51
  $method = $method_arr[0];
52
  $params = $method_arr[1];
53
  }
54
  else {
55
  // just a method provided
56
+ // IE: "contact/view
57
  if ( isset($components[1]) ) {
58
  $method = $components[1];
59
  $params = "";
72
  $component = "design";
73
  }
74
  elseif ($component == "sync") {
75
+ $component = "contact";
76
  $method = "sync";
77
  }
78
  elseif ($component == "singlesignon") {
79
  $component = "auth";
80
  }
81
 
82
+ $class = ucwords($component); // IE: "contact" becomes "Contact"
83
  $class = "AC_" . $class;
84
+ // IE: new Contact();
85
 
86
+ $add_tracking = false;
87
+ if ($class == "AC_Tracking") $add_tracking = true;
88
+
89
+ $class = new $class($this->version, $this->url_base, $this->url, $this->api_key);
90
+ // IE: $contact->view()
91
+
92
+ if ($add_tracking) {
93
+ $class->track_email = $this->track_email;
94
+ $class->track_actid = $this->track_actid;
95
+ $class->track_key = $this->track_key;
96
+ }
97
 
98
  if ($method == "list") {
99
  // reserved word
100
  $method = "list_";
101
  }
102
 
103
+ $class->debug = $this->debug;
104
+
105
  $response = $class->$method($params, $post_data);
106
  return $response;
107
  }
110
 
111
  require_once("Account.class.php");
112
  require_once("Auth.class.php");
113
+ require_once("Automation.class.php");
114
  require_once("Campaign.class.php");
115
+ require_once("Contact.class.php");
116
+ require_once("Deal.class.php");
117
  require_once("Design.class.php");
118
  require_once("Form.class.php");
119
  require_once("Group.class.php");
120
  require_once("List.class.php");
121
  require_once("Message.class.php");
122
+ require_once("Settings.class.php");
123
  require_once("Subscriber.class.php");
124
+ require_once("Tracking.class.php");
125
  require_once("User.class.php");
126
  require_once("Webhook.class.php");
127
 
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Auth.class.php CHANGED
@@ -1,21 +1,25 @@
1
- <?php
2
-
3
- class AC_Auth extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function singlesignon($params) {
14
- $request_url = "{$this->url}&api_action=singlesignon&api_output={$this->output}&{$params}";
15
- $response = $this->curl($request_url);
16
- return $response;
17
- }
18
-
19
- }
20
-
 
 
 
 
21
  ?>
1
+ <?php
2
+
3
+ class AC_Auth extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function singlesignon($params) {
18
+ $request_url = "{$this->url}&api_action=singlesignon&api_output={$this->output}&{$params}";
19
+ $response = $this->curl($request_url);
20
+ return $response;
21
+ }
22
+
23
+ }
24
+
25
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Automation.class.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AC_Automation extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function list_($params) {
18
+ $request_url = "{$this->url}&api_action=automation_list&api_output={$this->output}&{$params}";
19
+ $response = $this->curl($request_url);
20
+ return $response;
21
+ }
22
+
23
+ function contact_add($params, $post_data) {
24
+ $request_url = "{$this->url}&api_action=automation_contact_add&api_output={$this->output}";
25
+ if ($params) $request_url .= "&{$params}";
26
+ $response = $this->curl($request_url, $post_data);
27
+ return $response;
28
+ }
29
+
30
+ function contact_remove($params, $post_data) {
31
+ $request_url = "{$this->url}&api_action=automation_contact_remove&api_output={$this->output}";
32
+ if ($params) $request_url .= "&{$params}";
33
+ $response = $this->curl($request_url, $post_data);
34
+ return $response;
35
+ }
36
+
37
+ function contact_list($params) {
38
+ $request_url = "{$this->url}&api_action=automation_contact_list&api_output={$this->output}&{$params}";
39
+ $response = $this->curl($request_url);
40
+ return $response;
41
+ }
42
+
43
+ function contact_view($params) {
44
+ $request_url = "{$this->url}&api_action=automation_contact_view&api_output={$this->output}&{$params}";
45
+ $response = $this->curl($request_url);
46
+ return $response;
47
+ }
48
+
49
+ }
50
+
51
+ ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Campaign.class.php CHANGED
@@ -1,129 +1,133 @@
1
- <?php
2
-
3
- class AC_Campaign extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function create($params, $post_data) {
14
- $request_url = "{$this->url}&api_action=campaign_create&api_output={$this->output}";
15
- $response = $this->curl($request_url, $post_data);
16
- return $response;
17
- }
18
-
19
- function delete_list($params) {
20
- $request_url = "{$this->url}&api_action=campaign_delete_list&api_output={$this->output}&{$params}";
21
- $response = $this->curl($request_url);
22
- return $response;
23
- }
24
-
25
- function delete($params) {
26
- $request_url = "{$this->url}&api_action=campaign_delete&api_output={$this->output}&{$params}";
27
- $response = $this->curl($request_url);
28
- return $response;
29
- }
30
-
31
- function list_($params) {
32
- $request_url = "{$this->url}&api_action=campaign_list&api_output={$this->output}&{$params}";
33
- $response = $this->curl($request_url);
34
- return $response;
35
- }
36
-
37
- function paginator($params) {
38
- $request_url = "{$this->url}&api_action=campaign_paginator&api_output={$this->output}&{$params}";
39
- $response = $this->curl($request_url);
40
- return $response;
41
- }
42
-
43
- function report_bounce_list($params) {
44
- $request_url = "{$this->url}&api_action=campaign_report_bounce_list&api_output={$this->output}&{$params}";
45
- $response = $this->curl($request_url);
46
- return $response;
47
- }
48
-
49
- function report_bounce_totals($params) {
50
- $request_url = "{$this->url}&api_action=campaign_report_bounce_totals&api_output={$this->output}&{$params}";
51
- $response = $this->curl($request_url);
52
- return $response;
53
- }
54
-
55
- function report_forward_list($params) {
56
- $request_url = "{$this->url}&api_action=campaign_report_forward_list&api_output={$this->output}&{$params}";
57
- $response = $this->curl($request_url);
58
- return $response;
59
- }
60
-
61
- function report_forward_totals($params) {
62
- $request_url = "{$this->url}&api_action=campaign_report_forward_totals&api_output={$this->output}&{$params}";
63
- $response = $this->curl($request_url);
64
- return $response;
65
- }
66
-
67
- function report_link_list($params) {
68
- $request_url = "{$this->url}&api_action=campaign_report_link_list&api_output={$this->output}&{$params}";
69
- $response = $this->curl($request_url);
70
- return $response;
71
- }
72
-
73
- function report_link_totals($params) {
74
- $request_url = "{$this->url}&api_action=campaign_report_link_totals&api_output={$this->output}&{$params}";
75
- $response = $this->curl($request_url);
76
- return $response;
77
- }
78
-
79
- function report_open_list($params) {
80
- $request_url = "{$this->url}&api_action=campaign_report_open_list&api_output={$this->output}&{$params}";
81
- $response = $this->curl($request_url);
82
- return $response;
83
- }
84
-
85
- function report_open_totals($params) {
86
- $request_url = "{$this->url}&api_action=campaign_report_open_totals&api_output={$this->output}&{$params}";
87
- $response = $this->curl($request_url);
88
- return $response;
89
- }
90
-
91
- function report_totals($params) {
92
- $request_url = "{$this->url}&api_action=campaign_report_totals&api_output={$this->output}&{$params}";
93
- $response = $this->curl($request_url);
94
- return $response;
95
- }
96
-
97
- function report_unopen_list($params) {
98
- $request_url = "{$this->url}&api_action=campaign_report_unopen_list&api_output={$this->output}&{$params}";
99
- $response = $this->curl($request_url);
100
- return $response;
101
- }
102
-
103
- function report_unsubscription_list($params) {
104
- $request_url = "{$this->url}&api_action=campaign_report_unsubscription_list&api_output={$this->output}&{$params}";
105
- $response = $this->curl($request_url);
106
- return $response;
107
- }
108
-
109
- function report_unsubscription_totals($params) {
110
- $request_url = "{$this->url}&api_action=campaign_report_unsubscription_totals&api_output={$this->output}&{$params}";
111
- $response = $this->curl($request_url);
112
- return $response;
113
- }
114
-
115
- function send($params) {
116
- $request_url = "{$this->url}&api_action=campaign_send&api_output={$this->output}&{$params}";
117
- $response = $this->curl($request_url);
118
- return $response;
119
- }
120
-
121
- function status($params) {
122
- $request_url = "{$this->url}&api_action=campaign_status&api_output={$this->output}&{$params}";
123
- $response = $this->curl($request_url);
124
- return $response;
125
- }
126
-
127
- }
128
-
 
 
 
 
129
  ?>
1
+ <?php
2
+
3
+ class AC_Campaign extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function create($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=campaign_create&api_output={$this->output}";
19
+ $response = $this->curl($request_url, $post_data);
20
+ return $response;
21
+ }
22
+
23
+ function delete_list($params) {
24
+ $request_url = "{$this->url}&api_action=campaign_delete_list&api_output={$this->output}&{$params}";
25
+ $response = $this->curl($request_url);
26
+ return $response;
27
+ }
28
+
29
+ function delete($params) {
30
+ $request_url = "{$this->url}&api_action=campaign_delete&api_output={$this->output}&{$params}";
31
+ $response = $this->curl($request_url);
32
+ return $response;
33
+ }
34
+
35
+ function list_($params) {
36
+ $request_url = "{$this->url}&api_action=campaign_list&api_output={$this->output}&{$params}";
37
+ $response = $this->curl($request_url);
38
+ return $response;
39
+ }
40
+
41
+ function paginator($params) {
42
+ $request_url = "{$this->url}&api_action=campaign_paginator&api_output={$this->output}&{$params}";
43
+ $response = $this->curl($request_url);
44
+ return $response;
45
+ }
46
+
47
+ function report_bounce_list($params) {
48
+ $request_url = "{$this->url}&api_action=campaign_report_bounce_list&api_output={$this->output}&{$params}";
49
+ $response = $this->curl($request_url);
50
+ return $response;
51
+ }
52
+
53
+ function report_bounce_totals($params) {
54
+ $request_url = "{$this->url}&api_action=campaign_report_bounce_totals&api_output={$this->output}&{$params}";
55
+ $response = $this->curl($request_url);
56
+ return $response;
57
+ }
58
+
59
+ function report_forward_list($params) {
60
+ $request_url = "{$this->url}&api_action=campaign_report_forward_list&api_output={$this->output}&{$params}";
61
+ $response = $this->curl($request_url);
62
+ return $response;
63
+ }
64
+
65
+ function report_forward_totals($params) {
66
+ $request_url = "{$this->url}&api_action=campaign_report_forward_totals&api_output={$this->output}&{$params}";
67
+ $response = $this->curl($request_url);
68
+ return $response;
69
+ }
70
+
71
+ function report_link_list($params) {
72
+ $request_url = "{$this->url}&api_action=campaign_report_link_list&api_output={$this->output}&{$params}";
73
+ $response = $this->curl($request_url);
74
+ return $response;
75
+ }
76
+
77
+ function report_link_totals($params) {
78
+ $request_url = "{$this->url}&api_action=campaign_report_link_totals&api_output={$this->output}&{$params}";
79
+ $response = $this->curl($request_url);
80
+ return $response;
81
+ }
82
+
83
+ function report_open_list($params) {
84
+ $request_url = "{$this->url}&api_action=campaign_report_open_list&api_output={$this->output}&{$params}";
85
+ $response = $this->curl($request_url);
86
+ return $response;
87
+ }
88
+
89
+ function report_open_totals($params) {
90
+ $request_url = "{$this->url}&api_action=campaign_report_open_totals&api_output={$this->output}&{$params}";
91
+ $response = $this->curl($request_url);
92
+ return $response;
93
+ }
94
+
95
+ function report_totals($params) {
96
+ $request_url = "{$this->url}&api_action=campaign_report_totals&api_output={$this->output}&{$params}";
97
+ $response = $this->curl($request_url);
98
+ return $response;
99
+ }
100
+
101
+ function report_unopen_list($params) {
102
+ $request_url = "{$this->url}&api_action=campaign_report_unopen_list&api_output={$this->output}&{$params}";
103
+ $response = $this->curl($request_url);
104
+ return $response;
105
+ }
106
+
107
+ function report_unsubscription_list($params) {
108
+ $request_url = "{$this->url}&api_action=campaign_report_unsubscription_list&api_output={$this->output}&{$params}";
109
+ $response = $this->curl($request_url);
110
+ return $response;
111
+ }
112
+
113
+ function report_unsubscription_totals($params) {
114
+ $request_url = "{$this->url}&api_action=campaign_report_unsubscription_totals&api_output={$this->output}&{$params}";
115
+ $response = $this->curl($request_url);
116
+ return $response;
117
+ }
118
+
119
+ function send($params) {
120
+ $request_url = "{$this->url}&api_action=campaign_send&api_output={$this->output}&{$params}";
121
+ $response = $this->curl($request_url);
122
+ return $response;
123
+ }
124
+
125
+ function status($params) {
126
+ $request_url = "{$this->url}&api_action=campaign_status&api_output={$this->output}&{$params}";
127
+ $response = $this->curl($request_url);
128
+ return $response;
129
+ }
130
+
131
+ }
132
+
133
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Connector.class.php CHANGED
@@ -1,146 +1,226 @@
1
- <?php
2
-
3
- class AC_Connector {
4
-
5
- public $url;
6
- public $api_key;
7
- public $output = "json";
8
-
9
- function __construct($url, $api_key, $api_user = "", $api_pass = "") {
10
- // $api_pass should be md5() already
11
- $base = "";
12
- if (!preg_match("/https:\/\/www.activecampaign.com/", $url)) {
13
- // not a reseller
14
- $base = "/admin";
15
- }
16
- if (preg_match("/\/$/", $url)) {
17
- // remove trailing slash
18
- $url = substr($url, 0, strlen($url) - 1);
19
- }
20
- if ($api_key) {
21
- $this->url = "{$url}{$base}/api.php?api_key={$api_key}";
22
- }
23
- elseif ($api_user && $api_pass) {
24
- $this->url = "{$url}{$base}/api.php?api_user={$api_user}&api_pass={$api_pass}";
25
- }
26
- $this->api_key = $api_key;
27
- }
28
-
29
- public function credentials_test() {
30
- $test_url = "{$this->url}&api_action=group_view&api_output={$this->output}&id=3";
31
- $r = $this->curl($test_url);
32
- if (is_object($r) && (int)$r->result_code) {
33
- // successful
34
- $r = true;
35
- }
36
- else {
37
- // failed
38
- $r = false;
39
- }
40
- return $r;
41
- }
42
-
43
- // debug function (nicely outputs variables)
44
- public function dbg($var, $continue = 0, $element = "pre") {
45
- echo "<" . $element . ">";
46
- echo "Vartype: " . gettype($var) . "\n";
47
- if ( is_array($var) ) echo "Elements: " . count($var) . "\n\n";
48
- elseif ( is_string($var) ) echo "Length: " . strlen($var) . "\n\n";
49
- print_r($var);
50
- echo "</" . $element . ">";
51
- if (!$continue) exit();
52
- }
53
-
54
- public function curl($url, $post_data = array()) {
55
- // find the method from the URL
56
- $method = preg_match("/api_action=[^&]*/i", $url, $matches);
57
- $method = preg_match("/[^=]*$/i", $matches[0], $matches2);
58
- $method = $matches2[0];
59
- $request = curl_init();
60
- curl_setopt($request, CURLOPT_URL, $url);
61
- curl_setopt($request, CURLOPT_HEADER, 0);
62
- curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
63
- if ($post_data) {
64
- curl_setopt($request, CURLOPT_POST, 1);
65
- $data = "";
66
-
67
- if (is_array($post_data)) {
68
- foreach($post_data as $key => $value) {
69
- if (is_array($value)) {
70
-
71
- if (is_int($key)) {
72
- // array two levels deep
73
- foreach ($value as $key_ => $value_) {
74
- if (is_array($value_)) {
75
- foreach ($value_ as $k => $v) {
76
- $k = urlencode($k);
77
- $data .= "{$key_}[{$key}][{$k}]=" . urlencode($v) . "&";
78
- }
79
- }
80
- else {
81
- $data .= "{$key_}[{$key}]=" . urlencode($value_) . "&";
82
- }
83
- }
84
- }
85
- else {
86
- // IE: [group] => array(2 => 2, 3 => 3)
87
- // normally we just want the key to be a string, IE: ["group[2]"] => 2
88
- // but we want to allow passing both formats
89
- foreach ($value as $k => $v) {
90
- $k = urlencode($k);
91
- $data .= "{$key}[{$k}]=" . urlencode($v) . "&";
92
- }
93
- }
94
-
95
- }
96
- else {
97
- $data .= "{$key}=" . urlencode($value) . "&";
98
- }
99
- }
100
- }
101
- else {
102
- // not an array - perhaps serialized or JSON string?
103
- // just pass it as data
104
- $data = "data={$post_data}";
105
- }
106
-
107
- $data = rtrim($data, "& ");
108
- curl_setopt($request, CURLOPT_HTTPHEADER, array("Expect:"));
109
- curl_setopt($request, CURLOPT_POSTFIELDS, $data);
110
- }
111
- curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
112
- curl_setopt($request, CURLOPT_SSL_VERIFYHOST, 0);
113
- curl_setopt($request, CURLOPT_FOLLOWLOCATION, true);
114
- $response = curl_exec($request);
115
- //$this->dbg($response);
116
- $http_code = curl_getinfo($request, CURLINFO_HTTP_CODE);
117
- curl_close($request);
118
- $object = json_decode($response);
119
- if ( !is_object($object) || (!isset($object->result_code) && !isset($object->succeeded)) ) {
120
- // add methods that only return a string
121
- $string_responses = array("form_html");
122
- if (in_array($method, $string_responses)) {
123
- return $response;
124
- }
125
- // something went wrong
126
- return "An unexpected problem occurred with the API request. Some causes include: invalid JSON or XML returned. Here is the actual response from the server: ---- " . $response;
127
- }
128
- if (isset($object->result_code)) {
129
- $object->success = $object->result_code;
130
- if (!(int)$object->result_code) {
131
- $object->error = $object->result_message;
132
- }
133
- }
134
- elseif (isset($object->succeeded)) {
135
- // some calls return "succeeded" only
136
- $object->success = $object->succeeded;
137
- if (!(int)$object->succeeded) {
138
- $object->error = $object->message;
139
- }
140
- }
141
- return $object;
142
- }
143
-
144
- }
145
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  ?>
1
+ <?php
2
+
3
+ class AC_Connector {
4
+
5
+ public $url;
6
+ public $api_key;
7
+ public $output = "json";
8
+
9
+ function __construct($url, $api_key, $api_user = "", $api_pass = "") {
10
+ // $api_pass should be md5() already
11
+ $base = "";
12
+ if (!preg_match("/https:\/\/www.activecampaign.com/", $url)) {
13
+ // not a reseller
14
+ $base = "/admin";
15
+ }
16
+ if (preg_match("/\/$/", $url)) {
17
+ // remove trailing slash
18
+ $url = substr($url, 0, strlen($url) - 1);
19
+ }
20
+ if ($api_key) {
21
+ $this->url = "{$url}{$base}/api.php?api_key={$api_key}";
22
+ }
23
+ elseif ($api_user && $api_pass) {
24
+ $this->url = "{$url}{$base}/api.php?api_user={$api_user}&api_pass={$api_pass}";
25
+ }
26
+ $this->api_key = $api_key;
27
+ }
28
+
29
+ public function credentials_test() {
30
+ $test_url = "{$this->url}&api_action=user_me&api_output={$this->output}";
31
+ $r = $this->curl($test_url);
32
+ if (is_object($r) && (int)$r->result_code) {
33
+ // successful
34
+ $r = true;
35
+ }
36
+ else {
37
+ // failed
38
+ $r = false;
39
+ }
40
+ return $r;
41
+ }
42
+
43
+ // debug function (nicely outputs variables)
44
+ public function dbg($var, $continue = 0, $element = "pre", $extra = "") {
45
+ echo "<" . $element . ">";
46
+ echo "Vartype: " . gettype($var) . "\n";
47
+ if ( is_array($var) ) echo "Elements: " . count($var) . "\n";
48
+ elseif ( is_string($var) ) echo "Length: " . strlen($var) . "\n";
49
+ if ($extra) {
50
+ echo $extra . "\n";
51
+ }
52
+ echo "\n";
53
+ print_r($var);
54
+ echo "</" . $element . ">";
55
+ if (!$continue) exit();
56
+ }
57
+
58
+ public function curl($url, $params_data = array(), $verb = "", $custom_method = "") {
59
+ if ($this->version == 1) {
60
+ // find the method from the URL.
61
+ $method = preg_match("/api_action=[^&]*/i", $url, $matches);
62
+ if ($matches) {
63
+ $method = preg_match("/[^=]*$/i", $matches[0], $matches2);
64
+ $method = $matches2[0];
65
+ } elseif ($custom_method) {
66
+ $method = $custom_method;
67
+ }
68
+ } elseif ($this->version == 2) {
69
+ $method = $custom_method;
70
+ $url .= "?api_key=" . $this->api_key;
71
+ }
72
+ $debug_str1 = "";
73
+ $request = curl_init();
74
+ $debug_str1 .= "\$ch = curl_init();\n";
75
+ curl_setopt($request, CURLOPT_HEADER, 0);
76
+ curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
77
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_HEADER, 0);\n";
78
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_RETURNTRANSFER, true);\n";
79
+ if ($params_data && $verb == "GET") {
80
+ if ($this->version == 2) {
81
+ $url .= "&" . $params_data;
82
+ curl_setopt($request, CURLOPT_URL, $url);
83
+ }
84
+ }
85
+ else {
86
+ curl_setopt($request, CURLOPT_URL, $url);
87
+ if ($params_data && !$verb) {
88
+ // if no verb passed but there IS params data, it's likely POST.
89
+ $verb = "POST";
90
+ } elseif ($params_data && $verb) {
91
+ // $verb is likely "POST" or "PUT".
92
+ } else {
93
+ $verb = "GET";
94
+ }
95
+ }
96
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_URL, \"" . $url . "\");\n";
97
+ if ($this->debug) {
98
+ $this->dbg($url, 1, "pre", "Description: Request URL");
99
+ }
100
+ if ($verb == "POST" || $verb == "PUT" || $verb == "DELETE") {
101
+ if ($verb == "PUT") {
102
+ curl_setopt($request, CURLOPT_CUSTOMREQUEST, "PUT");
103
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_CUSTOMREQUEST, \"PUT\");\n";
104
+ } elseif ($verb == "DELETE") {
105
+ curl_setopt($request, CURLOPT_CUSTOMREQUEST, "DELETE");
106
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_CUSTOMREQUEST, \"DELETE\");\n";
107
+ } else {
108
+ $verb = "POST";
109
+ curl_setopt($request, CURLOPT_POST, 1);
110
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_POST, 1);\n";
111
+ }
112
+ $data = "";
113
+ if (is_array($params_data)) {
114
+ foreach($params_data as $key => $value) {
115
+ if (is_array($value)) {
116
+
117
+ if (is_int($key)) {
118
+ // array two levels deep
119
+ foreach ($value as $key_ => $value_) {
120
+ if (is_array($value_)) {
121
+ foreach ($value_ as $k => $v) {
122
+ $k = urlencode($k);
123
+ $data .= "{$key_}[{$key}][{$k}]=" . urlencode($v) . "&";
124
+ }
125
+ }
126
+ else {
127
+ $data .= "{$key_}[{$key}]=" . urlencode($value_) . "&";
128
+ }
129
+ }
130
+ }
131
+ else {
132
+ // IE: [group] => array(2 => 2, 3 => 3)
133
+ // normally we just want the key to be a string, IE: ["group[2]"] => 2
134
+ // but we want to allow passing both formats
135
+ foreach ($value as $k => $v) {
136
+ if (!is_array($v)) {
137
+ $k = urlencode($k);
138
+ $data .= "{$key}[{$k}]=" . urlencode($v) . "&";
139
+ }
140
+ }
141
+ }
142
+
143
+ }
144
+ else {
145
+ $data .= "{$key}=" . urlencode($value) . "&";
146
+ }
147
+ }
148
+ }
149
+ else {
150
+ // not an array - perhaps serialized or JSON string?
151
+ // just pass it as data
152
+ $data = "data={$params_data}";
153
+ }
154
+
155
+ $data = rtrim($data, "& ");
156
+ curl_setopt($request, CURLOPT_HTTPHEADER, array("Expect:"));
157
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_HTTPHEADER, array(\"Expect:\"));\n";
158
+ if ($this->debug) {
159
+ curl_setopt($request, CURLINFO_HEADER_OUT, 1);
160
+ $debug_str1 .= "curl_setopt(\$ch, CURLINFO_HEADER_OUT, 1);\n";
161
+ $this->dbg($data, 1, "pre", "Description: POST data");
162
+ }
163
+ curl_setopt($request, CURLOPT_POSTFIELDS, $data);
164
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_POSTFIELDS, \"" . $data . "\");\n";
165
+ }
166
+ curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
167
+ curl_setopt($request, CURLOPT_SSL_VERIFYHOST, 0);
168
+ curl_setopt($request, CURLOPT_FOLLOWLOCATION, true);
169
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_SSL_VERIFYPEER, false);\n";
170
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_SSL_VERIFYHOST, 0);\n";
171
+ $debug_str1 .= "curl_setopt(\$ch, CURLOPT_FOLLOWLOCATION, true);\n";
172
+ $response = curl_exec($request);
173
+ $debug_str1 .= "curl_exec(\$ch);\n";
174
+ if ($this->debug) {
175
+ $this->dbg($response, 1, "pre", "Description: Raw response");
176
+ }
177
+ $http_code = curl_getinfo($request, CURLINFO_HTTP_CODE);
178
+ $debug_str1 .= "\$http_code = curl_getinfo(\$ch, CURLINFO_HTTP_CODE);\n";
179
+ if ($this->debug) {
180
+ $this->dbg($http_code, 1, "pre", "Description: Response HTTP code");
181
+ $request_headers = curl_getinfo($request, CURLINFO_HEADER_OUT);
182
+ $debug_str1 .= "\$request_headers = curl_getinfo(\$ch, CURLINFO_HEADER_OUT);\n";
183
+ $this->dbg($request_headers, 1, "pre", "Description: Request headers");
184
+ }
185
+ curl_close($request);
186
+ $debug_str1 .= "curl_close(\$ch);\n";
187
+ $object = json_decode($response);
188
+ if ($this->debug) {
189
+ $this->dbg($object, 1, "pre", "Description: Response object (json_decode)");
190
+ }
191
+ if ( !is_object($object) || (!isset($object->result_code) && !isset($object->succeeded) && !isset($object->success)) ) {
192
+ // add methods that only return a string
193
+ $string_responses = array("tracking_event_remove", "contact_list", "form_html", "tracking_site_status", "tracking_event_status", "tracking_whitelist", "tracking_log", "tracking_site_list", "tracking_event_list");
194
+ if (in_array($method, $string_responses)) {
195
+ return $response;
196
+ }
197
+ // something went wrong
198
+ return "An unexpected problem occurred with the API request. Some causes include: invalid JSON or XML returned. Here is the actual response from the server: ---- " . $response;
199
+ }
200
+
201
+ if ($this->debug) {
202
+ echo "<textarea style='height: 300px; width: 600px;'>" . $debug_str1 . "</textarea>";
203
+ }
204
+
205
+ header("HTTP/1.1 " . $http_code);
206
+ $object->http_code = $http_code;
207
+
208
+ if (isset($object->result_code)) {
209
+ $object->success = $object->result_code;
210
+ if (!(int)$object->result_code) {
211
+ $object->error = $object->result_message;
212
+ }
213
+ }
214
+ elseif (isset($object->succeeded)) {
215
+ // some calls return "succeeded" only
216
+ $object->success = $object->succeeded;
217
+ if (!(int)$object->succeeded) {
218
+ $object->error = $object->message;
219
+ }
220
+ }
221
+ return $object;
222
+ }
223
+
224
+ }
225
+
226
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Contact.class.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AC_Contact extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function add($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=contact_add&api_output={$this->output}";
19
+ if ($params) $request_url .= "&{$params}";
20
+ $response = $this->curl($request_url, $post_data);
21
+ return $response;
22
+ }
23
+
24
+ function delete_list($params) {
25
+ $request_url = "{$this->url}&api_action=contact_delete_list&api_output={$this->output}&{$params}";
26
+ $response = $this->curl($request_url);
27
+ return $response;
28
+ }
29
+
30
+ function delete($params) {
31
+ $request_url = "{$this->url}&api_action=contact_delete&api_output={$this->output}&{$params}";
32
+ $response = $this->curl($request_url);
33
+ return $response;
34
+ }
35
+
36
+ function edit($params, $post_data) {
37
+ $request_url = "{$this->url}&api_action=contact_edit&api_output={$this->output}&{$params}";
38
+ $response = $this->curl($request_url, $post_data);
39
+ return $response;
40
+ }
41
+
42
+ function list_($params) {
43
+ if ($this->version == 1) {
44
+ $request_url = "{$this->url}&api_action=contact_list&api_output={$this->output}&{$params}";
45
+ $response = $this->curl($request_url);
46
+ } elseif ($this->version == 2) {
47
+ $request_url = "{$this->url_base}/contact/emails";
48
+ // $params example: offset=0&limit=1000&listid=4
49
+ $response = $this->curl($request_url, $params, "GET", "contact_list");
50
+ }
51
+ return $response;
52
+ }
53
+
54
+ function note_add($params, $post_data) {
55
+ $request_url = "{$this->url}&api_action=contact_note_add&api_output={$this->output}&{$params}";
56
+ $response = $this->curl($request_url, $post_data);
57
+ return $response;
58
+ }
59
+
60
+ function note_edit($params, $post_data) {
61
+ $request_url = "{$this->url}&api_action=contact_note_edit&api_output={$this->output}&{$params}";
62
+ $response = $this->curl($request_url, $post_data);
63
+ return $response;
64
+ }
65
+
66
+ function note_delete($params) {
67
+ $request_url = "{$this->url}&api_action=contact_note_delete&api_output={$this->output}&{$params}";
68
+ $response = $this->curl($request_url);
69
+ return $response;
70
+ }
71
+
72
+ function paginator($params) {
73
+ $request_url = "{$this->url}&api_action=contact_paginator&api_output={$this->output}&{$params}";
74
+ $response = $this->curl($request_url);
75
+ return $response;
76
+ }
77
+
78
+ function sync($params, $post_data) {
79
+ $request_url = "{$this->url}&api_action=contact_sync&api_output={$this->output}";
80
+ if ($params) $request_url .= "&{$params}";
81
+ $response = $this->curl($request_url, $post_data);
82
+ return $response;
83
+ }
84
+
85
+ function tag_add($params, $post_data) {
86
+ $request_url = "{$this->url}&api_action=contact_tag_add&api_output={$this->output}";
87
+ if ($params) $request_url .= "&{$params}";
88
+ $response = $this->curl($request_url, $post_data);
89
+ return $response;
90
+ }
91
+
92
+ function tag_remove($params, $post_data) {
93
+ $request_url = "{$this->url}&api_action=contact_tag_remove&api_output={$this->output}";
94
+ if ($params) $request_url .= "&{$params}";
95
+ $response = $this->curl($request_url, $post_data);
96
+ return $response;
97
+ }
98
+
99
+ function view($params) {
100
+ // can be a contact ID, email, or hash
101
+ if (preg_match("/^email=/", $params)) {
102
+ $action = "contact_view_email";
103
+ }
104
+ elseif (preg_match("/^hash=/", $params)) {
105
+ $action = "contact_view_hash";
106
+ }
107
+ elseif (preg_match("/^id=/", $params)) {
108
+ $action = "contact_view";
109
+ }
110
+ else {
111
+ // default
112
+ $action = "contact_view";
113
+ }
114
+ $request_url = "{$this->url}&api_action={$action}&api_output={$this->output}&{$params}";
115
+ $response = $this->curl($request_url);
116
+ return $response;
117
+ }
118
+
119
+ }
120
+
121
+ ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Deal.class.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AC_Deal extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function add($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=deal_add&api_output={$this->output}";
19
+ $response = $this->curl($request_url, $post_data);
20
+ return $response;
21
+ }
22
+
23
+ function edit($params, $post_data) {
24
+ $request_url = "{$this->url}&api_action=deal_edit&api_output={$this->output}";
25
+ $response = $this->curl($request_url, $post_data);
26
+ return $response;
27
+ }
28
+
29
+ function delete($params, $post_data) {
30
+ $request_url = "{$this->url}&api_action=deal_delete&api_output={$this->output}";
31
+ $response = $this->curl($request_url, $post_data);
32
+ return $response;
33
+ }
34
+
35
+ function get($params) {
36
+ $request_url = "{$this->url}&api_action=deal_get&api_output={$this->output}&{$params}";
37
+ $response = $this->curl($request_url);
38
+ return $response;
39
+ }
40
+
41
+ function list_($params) {
42
+ $request_url = "{$this->url}&api_action=deal_list&api_output={$this->output}&{$params}";
43
+ $response = $this->curl($request_url);
44
+ return $response;
45
+ }
46
+
47
+ function note_add($params, $post_data) {
48
+ $request_url = "{$this->url}&api_action=deal_note_add&api_output={$this->output}";
49
+ $response = $this->curl($request_url, $post_data);
50
+ return $response;
51
+ }
52
+
53
+ function note_edit($params, $post_data) {
54
+ $request_url = "{$this->url}&api_action=deal_note_edit&api_output={$this->output}";
55
+ $response = $this->curl($request_url, $post_data);
56
+ return $response;
57
+ }
58
+
59
+ function pipeline_add($params, $post_data) {
60
+ $request_url = "{$this->url}&api_action=deal_pipeline_add&api_output={$this->output}";
61
+ $response = $this->curl($request_url, $post_data);
62
+ return $response;
63
+ }
64
+
65
+ function pipeline_edit($params, $post_data) {
66
+ $request_url = "{$this->url}&api_action=deal_pipeline_edit&api_output={$this->output}";
67
+ $response = $this->curl($request_url, $post_data);
68
+ return $response;
69
+ }
70
+
71
+ function pipeline_delete($params, $post_data) {
72
+ $request_url = "{$this->url}&api_action=deal_pipeline_delete&api_output={$this->output}";
73
+ $response = $this->curl($request_url, $post_data);
74
+ return $response;
75
+ }
76
+
77
+ function pipeline_list($params) {
78
+ $request_url = "{$this->url}&api_action=deal_pipeline_list&api_output={$this->output}&{$params}";
79
+ $response = $this->curl($request_url);
80
+ return $response;
81
+ }
82
+
83
+ function stage_add($params, $post_data) {
84
+ $request_url = "{$this->url}&api_action=deal_stage_add&api_output={$this->output}";
85
+ $response = $this->curl($request_url, $post_data);
86
+ return $response;
87
+ }
88
+
89
+ function stage_edit($params, $post_data) {
90
+ $request_url = "{$this->url}&api_action=deal_stage_edit&api_output={$this->output}";
91
+ $response = $this->curl($request_url, $post_data);
92
+ return $response;
93
+ }
94
+
95
+ function stage_delete($params, $post_data) {
96
+ $request_url = "{$this->url}&api_action=deal_stage_delete&api_output={$this->output}";
97
+ $response = $this->curl($request_url, $post_data);
98
+ return $response;
99
+ }
100
+
101
+ function stage_list($params) {
102
+ $request_url = "{$this->url}&api_action=deal_stage_list&api_output={$this->output}&{$params}";
103
+ $response = $this->curl($request_url);
104
+ return $response;
105
+ }
106
+
107
+ function task_add($params, $post_data) {
108
+ $request_url = "{$this->url}&api_action=deal_task_add&api_output={$this->output}";
109
+ $response = $this->curl($request_url, $post_data);
110
+ return $response;
111
+ }
112
+
113
+ function task_edit($params, $post_data) {
114
+ $request_url = "{$this->url}&api_action=deal_task_edit&api_output={$this->output}";
115
+ $response = $this->curl($request_url, $post_data);
116
+ return $response;
117
+ }
118
+
119
+ function tasktype_add($params, $post_data) {
120
+ $request_url = "{$this->url}&api_action=deal_tasktype_add&api_output={$this->output}";
121
+ $response = $this->curl($request_url, $post_data);
122
+ return $response;
123
+ }
124
+
125
+ function tasktype_edit($params, $post_data) {
126
+ $request_url = "{$this->url}&api_action=deal_tasktype_edit&api_output={$this->output}";
127
+ $response = $this->curl($request_url, $post_data);
128
+ return $response;
129
+ }
130
+
131
+ function tasktype_delete($params, $post_data) {
132
+ $request_url = "{$this->url}&api_action=deal_tasktype_delete&api_output={$this->output}";
133
+ $response = $this->curl($request_url, $post_data);
134
+ return $response;
135
+ }
136
+
137
+ }
138
+
139
+ ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Design.class.php CHANGED
@@ -1,27 +1,31 @@
1
- <?php
2
-
3
- class AC_Design extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function edit($params, $post_data) {
14
- $request_url = "{$this->url}&api_action=branding_edit&api_output={$this->output}";
15
- $response = $this->curl($request_url, $post_data);
16
- return $response;
17
- }
18
-
19
- function view($params, $post_data) {
20
- $request_url = "{$this->url}&api_action=branding_view&api_output={$this->output}";
21
- $response = $this->curl($request_url, $post_data);
22
- return $response;
23
- }
24
-
25
- }
26
-
 
 
 
 
27
  ?>
1
+ <?php
2
+
3
+ class AC_Design extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function edit($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=branding_edit&api_output={$this->output}";
19
+ $response = $this->curl($request_url, $post_data);
20
+ return $response;
21
+ }
22
+
23
+ function view($params, $post_data) {
24
+ $request_url = "{$this->url}&api_action=branding_view&api_output={$this->output}";
25
+ $response = $this->curl($request_url, $post_data);
26
+ return $response;
27
+ }
28
+
29
+ }
30
+
31
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Form.class.php CHANGED
@@ -1,253 +1,291 @@
1
- <?php
2
-
3
- class AC_Form extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function getforms($params) {
14
- $request_url = "{$this->url}&api_action=form_getforms&api_output={$this->output}";
15
- $response = $this->curl($request_url);
16
- return $response;
17
- }
18
-
19
- function html($params) {
20
- $request_url = "{$this->url}&api_action=form_html&api_output={$this->output}&{$params}";
21
- $response = $this->curl($request_url);
22
- return $response;
23
- }
24
-
25
- function embed($params) {
26
-
27
- $params_array = explode("&", $params);
28
- $params_ = array();
29
- foreach ($params_array as $expression) {
30
- // IE: css=1
31
- list($var, $val) = explode("=", $expression);
32
- $params_[$var] = $val;
33
- }
34
-
35
- $id = (isset($params_["id"])) ? (int)$params_["id"] : 0;
36
- $css = (isset($params_["css"])) ? (int)$params_["css"] : 1;
37
- $ajax = (isset($params_["ajax"])) ? (int)$params_["ajax"] : 0;
38
- // to set the current page as the action, pass "action=", or "action=[THIS URL]"
39
- $action = (isset($params_["action"])) ? ($params_["action"] ? $params_["action"] : "this") : "";
40
-
41
- $html = $this->html("id={$id}");
42
-
43
- if (is_object($html) && !(int)$html->success) {
44
- return $html->error;
45
- }
46
-
47
- if ($html) {
48
-
49
- if ($action) {
50
- if ($action != "this") {
51
- // replace the action attribute with the one provided
52
- $action_val = urldecode($action);
53
- $html = preg_replace("/action=['\"][^'\"]+['\"]/", "action='{$action_val}'", $html);
54
- }
55
- else {
56
- $action_val = "";
57
- }
58
- }
59
- else {
60
- // find the action attribute value (URL)
61
- // should be the proc.php URL (at this point in the script)
62
- $action_val = preg_match("/action=['\"][^'\"]+['\"]/", $html, $m);
63
- $action_val = $m[0];
64
- $action_val = substr($action_val, 8, strlen($action_val) - 9);
65
- }
66
-
67
- if (!$css) {
68
- // remove all CSS
69
- $html = preg_replace("/<style[^>]*>(.*)<\/style>/s", "", $html);
70
- }
71
-
72
- if (!$ajax) {
73
- // replace the Submit button to be an actual submit type
74
- $html = preg_replace("/input type='button'/", "input type='submit'", $html);
75
-
76
- // if action = "this", remove the action attribute completely
77
- if (!$action_val) {
78
- $html = preg_replace("/action=['\"][^'\"]+['\"]/", "", $html);
79
- }
80
- }
81
- else {
82
-
83
- // if using Ajax, remove the <form> action attribute completely
84
- $html = preg_replace("/action=['\"][^'\"]+['\"]/", "", $html);
85
-
86
- $action_val = urldecode($action_val);
87
-
88
- // add jQuery stuff
89
- $extra = "<script type='text/javascript'>
90
-
91
- $(document).ready(function() {
92
-
93
- $('input[type*=\"button\"]').click(function() {
94
-
95
- var form_data = {};
96
- $('form').each(function() {
97
- form_data = $(this).serialize();
98
- });
99
-
100
- var geturl;
101
- geturl = $.ajax({
102
- url: '{$action_val}',
103
- type: 'POST',
104
- dataType: 'json',
105
- data: form_data,
106
- error: function(jqXHR, textStatus, errorThrown) {
107
- alert('Error: ' + textStatus);
108
- },
109
- success: function(data) {
110
- $('#form_result_message').html(data.message);
111
- }
112
- });
113
-
114
- });
115
-
116
- });
117
-
118
- </script>";
119
-
120
- $html = $html . $extra;
121
- }
122
-
123
- }
124
-
125
- return $html;
126
- }
127
-
128
- function process($params) {
129
-
130
- $r = array();
131
- if ($_SERVER["REQUEST_METHOD"] != "POST") return $r;
132
-
133
- $sync = 0;
134
- if ($params) {
135
- $params_array = explode("&", $params);
136
- $params_ = array();
137
- foreach ($params_array as $expression) {
138
- // IE: css=1
139
- list($var, $val) = explode("=", $expression);
140
- $params_[$var] = $val;
141
- }
142
-
143
- $sync = (isset($params_["sync"])) ? (int)$params_["sync"] : 0;
144
- }
145
-
146
- $formid = $_POST["f"];
147
- $email = $_POST["email"];
148
-
149
- if (isset($_POST["fullname"])) {
150
- $fullname = explode(" ", $_POST["fullname"]);
151
- $firstname = array_shift($fullname);
152
- $lastname = implode(" ", $fullname);
153
- }
154
- else {
155
- $firstname = trim($_POST["firstname"]);
156
- $lastname = trim($_POST["lastname"]);
157
- if ($firstname == "") $firstname = trim($_POST["first_name"]);
158
- if ($lastname == "") $lastname = trim($_POST["last_name"]);
159
- }
160
-
161
- $fields = (isset($_POST["field"])) ? $_POST["field"] : array();
162
-
163
- $subscriber = array(
164
- "form" => $formid,
165
- "email" => $email,
166
- "first_name" => $firstname,
167
- "last_name" => $lastname,
168
- );
169
-
170
- foreach ($fields as $ac_field_id => $field_value) {
171
- $subscriber["field"][$ac_field_id . ",0"] = $field_value;
172
- }
173
-
174
- // add lists
175
- foreach ($_POST["nlbox"] as $listid) {
176
- $subscriber["p[{$listid}]"] = $listid;
177
- $subscriber["status[{$listid}]"] = 1;
178
- }
179
-
180
- if (!$sync) {
181
-
182
- // do add/edit
183
-
184
- $subscriber_exists = $this->api("subscriber/view?email={$email}", $subscriber);
185
-
186
- if ( !isset($subscriber_exists->id) ) {
187
-
188
- // subscriber does not exist - add them
189
-
190
- $subscriber_request = $this->api("subscriber/add", $subscriber);
191
-
192
- if ((int)$subscriber_request->success) {
193
- // successful request
194
- $subscriber_id = (int)$subscriber_request->subscriber_id;
195
- $r = array(
196
- "success" => 1,
197
- "message" => $subscriber_request->result_message,
198
- "subscriber_id" => $subscriber_id,
199
- );
200
- }
201
- else {
202
- // request failed
203
- $r = array(
204
- "success" => 0,
205
- "message" => $subscriber_request->error,
206
- );
207
- }
208
-
209
- }
210
- else {
211
-
212
- // subscriber already exists - edit them
213
-
214
- $subscriber_id = $subscriber_exists->id;
215
-
216
- $subscriber["id"] = $subscriber_id;
217
-
218
- $subscriber_request = $this->api("subscriber/edit?overwrite=0", $subscriber);
219
-
220
- }
221
-
222
- }
223
- else {
224
-
225
- // perform sync (add or edit)
226
-
227
- $subscriber_request = $this->api("subscriber/sync", $subscriber);
228
-
229
- }
230
-
231
- if ((int)$subscriber_request->success) {
232
- // successful request
233
- //$subscriber_id = (int)$subscriber_request->subscriber_id;
234
- $r = array(
235
- "success" => 1,
236
- "message" => $subscriber_request->result_message,
237
- //"subscriber_id" => $subscriber_id,
238
- );
239
- }
240
- else {
241
- // request failed
242
- $r = array(
243
- "success" => 0,
244
- "message" => $subscriber_request->error,
245
- );
246
- }
247
-
248
- return json_encode($r);
249
- }
250
-
251
- }
252
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  ?>
1
+ <?php
2
+
3
+ class AC_Form extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function getforms($params) {
18
+ $request_url = "{$this->url}&api_action=form_getforms&api_output={$this->output}";
19
+ $response = $this->curl($request_url);
20
+ return $response;
21
+ }
22
+
23
+ function html($params) {
24
+ $request_url = "{$this->url}&api_action=form_html&api_output={$this->output}&{$params}";
25
+ $response = $this->curl($request_url);
26
+ return $response;
27
+ }
28
+
29
+ function embed($params) {
30
+
31
+ $params_array = explode("&", $params);
32
+ $params_ = array();
33
+ foreach ($params_array as $expression) {
34
+ // IE: css=1
35
+ list($var, $val) = explode("=", $expression);
36
+ $params_[$var] = $val;
37
+ }
38
+
39
+ $id = (isset($params_["id"])) ? (int)$params_["id"] : 0;
40
+ $css = (isset($params_["css"])) ? (int)$params_["css"] : 1;
41
+ $ajax = (isset($params_["ajax"])) ? (int)$params_["ajax"] : 0;
42
+ // to set the current page as the action, pass "action=", or "action=[THIS URL]"
43
+ $action = (isset($params_["action"])) ? ($params_["action"] ? $params_["action"] : "this") : "";
44
+
45
+ $html = $this->html("id={$id}");
46
+
47
+ if (is_object($html) && !(int)$html->success) {
48
+ return $html->error;
49
+ }
50
+
51
+ if ($html) {
52
+
53
+ if ($action) {
54
+ if ($action != "this") {
55
+ // replace the action attribute with the one provided
56
+ $action_val = urldecode($action);
57
+ $html = preg_replace("/action=['\"][^'\"]+['\"]/", "action='{$action_val}'", $html);
58
+ }
59
+ else {
60
+ $action_val = "";
61
+ }
62
+ }
63
+ else {
64
+ // find the action attribute value (URL)
65
+ // should be the proc.php URL (at this point in the script)
66
+ $action_val = preg_match("/action=['\"][^'\"]+['\"]/", $html, $m);
67
+ $action_val = $m[0];
68
+ $action_val = substr($action_val, 8, strlen($action_val) - 9);
69
+ }
70
+
71
+ if (!$css) {
72
+ // remove all CSS
73
+ $html = preg_replace("/<style[^>]*>(.*)<\/style>/s", "", $html);
74
+ }
75
+
76
+ if (!$ajax) {
77
+ // replace the Submit button to be an actual submit type
78
+ $html = preg_replace("/input type='button'/", "input type='submit'", $html);
79
+
80
+ // if action = "this", remove the action attribute completely
81
+ if (!$action_val) {
82
+ $html = preg_replace("/action=['\"][^'\"]+['\"]/", "", $html);
83
+ }
84
+ }
85
+ else {
86
+
87
+ // if using Ajax, remove the <form> action attribute completely
88
+ $html = preg_replace("/action=['\"][^'\"]+['\"]/", "", $html);
89
+
90
+ // replace the Submit button to be a button type (for ajax).
91
+ // forms come out of AC now with a "submit" button (it used to be "button").
92
+ $html = preg_replace("/input type='submit'/", "input type='button'", $html);
93
+
94
+ $action_val = urldecode($action_val);
95
+
96
+ // add jQuery stuff
97
+ $extra = "<script type='text/javascript'>
98
+
99
+ var \$j = jQuery.noConflict();
100
+
101
+ \$j(document).ready(function() {
102
+
103
+ \$j('#_form_{$id} input[type*=\"button\"]').click(function() {
104
+
105
+ // rename the radio options for Subscribe/Unsubscribe, since they conflict with the hidden field.
106
+ \$j('input[type=radio][name=act]').attr('name','act_radio');
107
+
108
+ var form_data = {};
109
+ \$j('#_form_{$id}').each(function() {
110
+ form_data = \$j(this).serialize();
111
+ });
112
+
113
+ var geturl;
114
+ geturl = \$j.ajax({
115
+ url: '{$action_val}',
116
+ type: 'POST',
117
+ dataType: 'json',
118
+ data: form_data,
119
+ error: function(jqXHR, textStatus, errorThrown) {
120
+ console.log(errorThrown);
121
+ },
122
+ success: function(data) {
123
+ \$j('#form_result_message').html(data.message);
124
+ var result_class = (data.success) ? 'form_result_success' : 'form_result_error';
125
+ \$j('#form_result_message').removeClass('form_result_success form_result_error').addClass(result_class);
126
+ }
127
+ });
128
+
129
+ });
130
+
131
+ });
132
+
133
+ </script>";
134
+
135
+ $html = $html . $extra;
136
+ }
137
+
138
+ }
139
+
140
+ return $html;
141
+ }
142
+
143
+ function process($params) {
144
+
145
+ $r = array();
146
+ if ($_SERVER["REQUEST_METHOD"] != "POST") return $r;
147
+
148
+ $sync = 0;
149
+ $captcha_in_form = 0;
150
+ if ($params) {
151
+ $params_array = explode("&", $params);
152
+ $params_ = array();
153
+ foreach ($params_array as $expression) {
154
+ // IE: css=1
155
+ list($var, $val) = explode("=", $expression);
156
+ $params_[$var] = $val;
157
+ }
158
+
159
+ $sync = (isset($params_["sync"])) ? (int)$params_["sync"] : 0;
160
+ $captcha_in_form = (isset($params_["captcha"])) ? (int)$params_["captcha"] : 0;
161
+ }
162
+
163
+ $formid = $_POST["f"];
164
+ // sub or unsub
165
+ $act = isset($_POST["act"]) ? $_POST["act"] : "sub";
166
+ if (isset($_POST["act_radio"])) {
167
+ // the radio options for Subscribe/Unsubscribe.
168
+ $act = $_POST["act_radio"];
169
+ }
170
+ $email = $_POST["email"];
171
+ $phone = isset($_POST["phone"]) ? $_POST["phone"] : "";
172
+ $lists = (isset($_POST["nlbox"]) && $_POST["nlbox"]) ? $_POST["nlbox"] : array();
173
+ if ($captcha_in_form) {
174
+ // Captcha is part of the form.
175
+ // Get the captcha value the user entered.
176
+ $captcha = "";
177
+ if (isset($_POST["captcha"])) {
178
+ $captcha = md5(strtoupper((string)$_POST["captcha"]));
179
+ }
180
+ if (!isset($_SESSION["image_random_value"]) || !isset($_SESSION["image_random_value"][$captcha])) {
181
+ return json_encode(array("success" => 0, "message" => "Invalid captcha"));
182
+ }
183
+ }
184
+
185
+ if (isset($_POST["fullname"])) {
186
+ $fullname = explode(" ", $_POST["fullname"]);
187
+ $firstname = array_shift($fullname);
188
+ $lastname = implode(" ", $fullname);
189
+ }
190
+ else {
191
+ $firstname = trim($_POST["firstname"]);
192
+ $lastname = trim($_POST["lastname"]);
193
+ if ($firstname == "" && isset($_POST["first_name"])) $firstname = trim($_POST["first_name"]);
194
+ if ($lastname == "" && isset($_POST["last_name"])) $lastname = trim($_POST["last_name"]);
195
+ }
196
+
197
+ $fields = (isset($_POST["field"])) ? $_POST["field"] : array();
198
+
199
+ $contact = array(
200
+ "form" => $formid,
201
+ "email" => $email,
202
+ "first_name" => $firstname,
203
+ "last_name" => $lastname,
204
+ "phone" => $phone,
205
+ );
206
+
207
+ foreach ($fields as $ac_field_id => $field_value) {
208
+ $contact["field"][$ac_field_id . ",0"] = $field_value;
209
+ }
210
+
211
+ // add lists
212
+ $status = ($act == "unsub") ? 2 : 1;
213
+ foreach ($lists as $listid) {
214
+ $contact["p[{$listid}]"] = $listid;
215
+ $contact["status[{$listid}]"] = $status;
216
+ }
217
+
218
+ if (!$sync) {
219
+
220
+ // do add/edit
221
+
222
+ $contact_exists = $this->api("contact/view?email={$email}", $contact);
223
+
224
+ if ( !isset($contact_exists->id) ) {
225
+
226
+ // contact does not exist - add them
227
+
228
+ $contact_request = $this->api("contact/add", $contact);
229
+
230
+ if ((int)$contact_request->success) {
231
+ // successful request
232
+ $contact_id = (int)$contact_request->subscriber_id;
233
+ $r = array(
234
+ "success" => 1,
235
+ "message" => $contact_request->result_message,
236
+ "contact_id" => $contact_id,
237
+ );
238
+ }
239
+ else {
240
+ // request failed
241
+ $r = array(
242
+ "success" => 0,
243
+ "message" => $contact_request->error,
244
+ );
245
+ }
246
+
247
+ }
248
+ else {
249
+
250
+ // contact already exists - edit them
251
+
252
+ $contact_id = $contact_exists->id;
253
+
254
+ $contact["id"] = $contact_id;
255
+
256
+ $contact_request = $this->api("contact/edit?overwrite=0", $contact);
257
+
258
+ }
259
+
260
+ }
261
+ else {
262
+
263
+ // perform sync (add or edit)
264
+
265
+ $contact_request = $this->api("contact/sync", $contact);
266
+
267
+ }
268
+
269
+ if ((int)$contact_request->success) {
270
+ // successful request
271
+ //$contact_id = (int)$contact_request->contact_id;
272
+ $r = array(
273
+ "success" => 1,
274
+ "message" => $contact_request->result_message,
275
+ //"contact_id" => $contact_id,
276
+ );
277
+ }
278
+ else {
279
+ // request failed
280
+ $r = array(
281
+ "success" => 0,
282
+ "message" => $contact_request->error,
283
+ );
284
+ }
285
+
286
+ return json_encode($r);
287
+ }
288
+
289
+ }
290
+
291
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Group.class.php CHANGED
@@ -1,51 +1,55 @@
1
- <?php
2
-
3
- class AC_Group extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function add($params, $post_data) {
14
- $request_url = "{$this->url}&api_action=group_add&api_output={$this->output}";
15
- $response = $this->curl($request_url, $post_data);
16
- return $response;
17
- }
18
-
19
- function delete_list($params) {
20
- $request_url = "{$this->url}&api_action=group_delete_list&api_output={$this->output}&{$params}";
21
- $response = $this->curl($request_url);
22
- return $response;
23
- }
24
-
25
- function delete($params) {
26
- $request_url = "{$this->url}&api_action=group_delete&api_output={$this->output}&{$params}";
27
- $response = $this->curl($request_url);
28
- return $response;
29
- }
30
-
31
- function edit($params, $post_data) {
32
- $request_url = "{$this->url}&api_action=group_edit&api_output={$this->output}";
33
- $response = $this->curl($request_url, $post_data);
34
- return $response;
35
- }
36
-
37
- function list_($params) {
38
- $request_url = "{$this->url}&api_action=group_list&api_output={$this->output}&{$params}";
39
- $response = $this->curl($request_url);
40
- return $response;
41
- }
42
-
43
- function view($params) {
44
- $request_url = "{$this->url}&api_action=group_view&api_output={$this->output}&{$params}";
45
- $response = $this->curl($request_url);
46
- return $response;
47
- }
48
-
49
- }
50
-
 
 
 
 
51
  ?>
1
+ <?php
2
+
3
+ class AC_Group extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function add($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=group_add&api_output={$this->output}";
19
+ $response = $this->curl($request_url, $post_data);
20
+ return $response;
21
+ }
22
+
23
+ function delete_list($params) {
24
+ $request_url = "{$this->url}&api_action=group_delete_list&api_output={$this->output}&{$params}";
25
+ $response = $this->curl($request_url);
26
+ return $response;
27
+ }
28
+
29
+ function delete($params) {
30
+ $request_url = "{$this->url}&api_action=group_delete&api_output={$this->output}&{$params}";
31
+ $response = $this->curl($request_url);
32
+ return $response;
33
+ }
34
+
35
+ function edit($params, $post_data) {
36
+ $request_url = "{$this->url}&api_action=group_edit&api_output={$this->output}";
37
+ $response = $this->curl($request_url, $post_data);
38
+ return $response;
39
+ }
40
+
41
+ function list_($params) {
42
+ $request_url = "{$this->url}&api_action=group_list&api_output={$this->output}&{$params}";
43
+ $response = $this->curl($request_url);
44
+ return $response;
45
+ }
46
+
47
+ function view($params) {
48
+ $request_url = "{$this->url}&api_action=group_view&api_output={$this->output}&{$params}";
49
+ $response = $this->curl($request_url);
50
+ return $response;
51
+ }
52
+
53
+ }
54
+
55
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/List.class.php CHANGED
@@ -1,81 +1,91 @@
1
- <?php
2
-
3
- class AC_List_ extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function add($params, $post_data) {
14
- $request_url = "{$this->url}&api_action=list_add&api_output={$this->output}";
15
- $response = $this->curl($request_url, $post_data);
16
- return $response;
17
- }
18
-
19
- function delete_list($params) {
20
- $request_url = "{$this->url}&api_action=list_delete_list&api_output={$this->output}&{$params}";
21
- $response = $this->curl($request_url);
22
- return $response;
23
- }
24
-
25
- function delete($params) {
26
- $request_url = "{$this->url}&api_action=list_delete&api_output={$this->output}&{$params}";
27
- $response = $this->curl($request_url);
28
- return $response;
29
- }
30
-
31
- function edit($params, $post_data) {
32
- $request_url = "{$this->url}&api_action=list_edit&api_output={$this->output}";
33
- $response = $this->curl($request_url, $post_data);
34
- return $response;
35
- }
36
-
37
- function field_add($params, $post_data) {
38
- $request_url = "{$this->url}&api_action=list_field_add&api_output={$this->output}";
39
- $response = $this->curl($request_url, $post_data);
40
- return $response;
41
- }
42
-
43
- function field_delete($params) {
44
- $request_url = "{$this->url}&api_action=list_field_delete&api_output={$this->output}&{$params}";
45
- $response = $this->curl($request_url);
46
- return $response;
47
- }
48
-
49
- function field_edit($params, $post_data) {
50
- $request_url = "{$this->url}&api_action=list_field_edit&api_output={$this->output}";
51
- $response = $this->curl($request_url, $post_data);
52
- return $response;
53
- }
54
-
55
- function field_view($params) {
56
- $request_url = "{$this->url}&api_action=list_field_view&api_output={$this->output}&{$params}";
57
- $response = $this->curl($request_url);
58
- return $response;
59
- }
60
-
61
- function list_($params) {
62
- $request_url = "{$this->url}&api_action=list_list&api_output={$this->output}&{$params}";
63
- $response = $this->curl($request_url);
64
- return $response;
65
- }
66
-
67
- function paginator($params) {
68
- $request_url = "{$this->url}&api_action=list_paginator&api_output={$this->output}&{$params}";
69
- $response = $this->curl($request_url);
70
- return $response;
71
- }
72
-
73
- function view($params) {
74
- $request_url = "{$this->url}&api_action=list_view&api_output={$this->output}&{$params}";
75
- $response = $this->curl($request_url);
76
- return $response;
77
- }
78
-
79
- }
80
-
 
 
 
 
 
 
 
 
 
 
81
  ?>
1
+ <?php
2
+
3
+ class AC_List_ extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function add($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=list_add&api_output={$this->output}";
19
+ $response = $this->curl($request_url, $post_data);
20
+ return $response;
21
+ }
22
+
23
+ function delete_list($params) {
24
+ $request_url = "{$this->url}&api_action=list_delete_list&api_output={$this->output}&{$params}";
25
+ $response = $this->curl($request_url);
26
+ return $response;
27
+ }
28
+
29
+ function delete($params) {
30
+ $request_url = "{$this->url}&api_action=list_delete&api_output={$this->output}&{$params}";
31
+ $response = $this->curl($request_url);
32
+ return $response;
33
+ }
34
+
35
+ function edit($params, $post_data) {
36
+ $request_url = "{$this->url}&api_action=list_edit&api_output={$this->output}";
37
+ $response = $this->curl($request_url, $post_data);
38
+ return $response;
39
+ }
40
+
41
+ function field_add($params, $post_data) {
42
+ $request_url = "{$this->url}&api_action=list_field_add&api_output={$this->output}";
43
+ $response = $this->curl($request_url, $post_data);
44
+ return $response;
45
+ }
46
+
47
+ function field_delete($params) {
48
+ $request_url = "{$this->url}&api_action=list_field_delete&api_output={$this->output}&{$params}";
49
+ $response = $this->curl($request_url);
50
+ return $response;
51
+ }
52
+
53
+ function field_edit($params, $post_data) {
54
+ $request_url = "{$this->url}&api_action=list_field_edit&api_output={$this->output}";
55
+ $response = $this->curl($request_url, $post_data);
56
+ return $response;
57
+ }
58
+
59
+ function field_view($params) {
60
+ $request_url = "{$this->url}&api_action=list_field_view&api_output={$this->output}&{$params}";
61
+ $response = $this->curl($request_url);
62
+ return $response;
63
+ }
64
+
65
+ function list_($params, $post_data) {
66
+ if ($post_data) {
67
+ if (isset($post_data["ids"]) && is_array($post_data["ids"])) {
68
+ // make them comma-separated.
69
+ $post_data["ids"] = implode(",", $post_data["ids"]);
70
+ }
71
+ }
72
+ $request_url = "{$this->url}&api_action=list_list&api_output={$this->output}&{$params}";
73
+ $response = $this->curl($request_url, $post_data);
74
+ return $response;
75
+ }
76
+
77
+ function paginator($params) {
78
+ $request_url = "{$this->url}&api_action=list_paginator&api_output={$this->output}&{$params}";
79
+ $response = $this->curl($request_url);
80
+ return $response;
81
+ }
82
+
83
+ function view($params) {
84
+ $request_url = "{$this->url}&api_action=list_view&api_output={$this->output}&{$params}";
85
+ $response = $this->curl($request_url);
86
+ return $response;
87
+ }
88
+
89
+ }
90
+
91
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Message.class.php CHANGED
@@ -1,99 +1,103 @@
1
- <?php
2
-
3
- class AC_Message extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function add($params, $post_data) {
14
- $request_url = "{$this->url}&api_action=message_add&api_output={$this->output}";
15
- $response = $this->curl($request_url, $post_data);
16
- return $response;
17
- }
18
-
19
- function delete_list($params) {
20
- $request_url = "{$this->url}&api_action=message_delete_list&api_output={$this->output}&{$params}";
21
- $response = $this->curl($request_url);
22
- return $response;
23
- }
24
-
25
- function delete($params) {
26
- $request_url = "{$this->url}&api_action=message_delete&api_output={$this->output}&{$params}";
27
- $response = $this->curl($request_url);
28
- return $response;
29
- }
30
-
31
- function edit($params, $post_data) {
32
- $request_url = "{$this->url}&api_action=message_edit&api_output={$this->output}";
33
- $response = $this->curl($request_url, $post_data);
34
- return $response;
35
- }
36
-
37
- function list_($params) {
38
- $request_url = "{$this->url}&api_action=message_list&api_output={$this->output}&{$params}";
39
- $response = $this->curl($request_url);
40
- return $response;
41
- }
42
-
43
- function template_add($params, $post_data) {
44
- $request_url = "{$this->url}&api_action=message_template_add&api_output={$this->output}";
45
- $response = $this->curl($request_url, $post_data);
46
- return $response;
47
- }
48
-
49
- function template_delete_list($params) {
50
- $request_url = "{$this->url}&api_action=message_template_delete_list&api_output={$this->output}&{$params}";
51
- $response = $this->curl($request_url);
52
- return $response;
53
- }
54
-
55
- function template_delete($params) {
56
- $request_url = "{$this->url}&api_action=message_template_delete&api_output={$this->output}&{$params}";
57
- $response = $this->curl($request_url);
58
- return $response;
59
- }
60
-
61
- function template_edit($params, $post_data) {
62
- $request_url = "{$this->url}&api_action=message_template_edit&api_output={$this->output}";
63
- $response = $this->curl($request_url, $post_data);
64
- return $response;
65
- }
66
-
67
- function template_export($params) {
68
- $request_url = "{$this->url}&api_action=message_template_export&api_output={$this->output}&{$params}";
69
- $response = $this->curl($request_url);
70
- return $response;
71
- }
72
-
73
- function template_import($params, $post_data) {
74
- $request_url = "{$this->url}&api_action=message_template_import&api_output={$this->output}";
75
- $response = $this->curl($request_url, $post_data);
76
- return $response;
77
- }
78
-
79
- function template_list($params) {
80
- $request_url = "{$this->url}&api_action=message_template_list&api_output={$this->output}&{$params}";
81
- $response = $this->curl($request_url);
82
- return $response;
83
- }
84
-
85
- function template_view($params) {
86
- $request_url = "{$this->url}&api_action=message_template_view&api_output={$this->output}&{$params}";
87
- $response = $this->curl($request_url);
88
- return $response;
89
- }
90
-
91
- function view($params) {
92
- $request_url = "{$this->url}&api_action=message_view&api_output={$this->output}&{$params}";
93
- $response = $this->curl($request_url);
94
- return $response;
95
- }
96
-
97
- }
98
-
 
 
 
 
99
  ?>
1
+ <?php
2
+
3
+ class AC_Message extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function add($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=message_add&api_output={$this->output}";
19
+ $response = $this->curl($request_url, $post_data);
20
+ return $response;
21
+ }
22
+
23
+ function delete_list($params) {
24
+ $request_url = "{$this->url}&api_action=message_delete_list&api_output={$this->output}&{$params}";
25
+ $response = $this->curl($request_url);
26
+ return $response;
27
+ }
28
+
29
+ function delete($params) {
30
+ $request_url = "{$this->url}&api_action=message_delete&api_output={$this->output}&{$params}";
31
+ $response = $this->curl($request_url);
32
+ return $response;
33
+ }
34
+
35
+ function edit($params, $post_data) {
36
+ $request_url = "{$this->url}&api_action=message_edit&api_output={$this->output}";
37
+ $response = $this->curl($request_url, $post_data);
38
+ return $response;
39
+ }
40
+
41
+ function list_($params) {
42
+ $request_url = "{$this->url}&api_action=message_list&api_output={$this->output}&{$params}";
43
+ $response = $this->curl($request_url);
44
+ return $response;
45
+ }
46
+
47
+ function template_add($params, $post_data) {
48
+ $request_url = "{$this->url}&api_action=message_template_add&api_output={$this->output}";
49
+ $response = $this->curl($request_url, $post_data);
50
+ return $response;
51
+ }
52
+
53
+ function template_delete_list($params) {
54
+ $request_url = "{$this->url}&api_action=message_template_delete_list&api_output={$this->output}&{$params}";
55
+ $response = $this->curl($request_url);
56
+ return $response;
57
+ }
58
+
59
+ function template_delete($params) {
60
+ $request_url = "{$this->url}&api_action=message_template_delete&api_output={$this->output}&{$params}";
61
+ $response = $this->curl($request_url);
62
+ return $response;
63
+ }
64
+
65
+ function template_edit($params, $post_data) {
66
+ $request_url = "{$this->url}&api_action=message_template_edit&api_output={$this->output}";
67
+ $response = $this->curl($request_url, $post_data);
68
+ return $response;
69
+ }
70
+
71
+ function template_export($params) {
72
+ $request_url = "{$this->url}&api_action=message_template_export&api_output={$this->output}&{$params}";
73
+ $response = $this->curl($request_url);
74
+ return $response;
75
+ }
76
+
77
+ function template_import($params, $post_data) {
78
+ $request_url = "{$this->url}&api_action=message_template_import&api_output={$this->output}";
79
+ $response = $this->curl($request_url, $post_data);
80
+ return $response;
81
+ }
82
+
83
+ function template_list($params) {
84
+ $request_url = "{$this->url}&api_action=message_template_list&api_output={$this->output}&{$params}";
85
+ $response = $this->curl($request_url);
86
+ return $response;
87
+ }
88
+
89
+ function template_view($params) {
90
+ $request_url = "{$this->url}&api_action=message_template_view&api_output={$this->output}&{$params}";
91
+ $response = $this->curl($request_url);
92
+ return $response;
93
+ }
94
+
95
+ function view($params) {
96
+ $request_url = "{$this->url}&api_action=message_view&api_output={$this->output}&{$params}";
97
+ $response = $this->curl($request_url);
98
+ return $response;
99
+ }
100
+
101
+ }
102
+
103
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Settings.class.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AC_Settings extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function edit($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=settings_edit&api_output={$this->output}";
19
+ $response = $this->curl($request_url, $post_data);
20
+ return $response;
21
+ }
22
+
23
+ }
24
+
25
+ ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Subscriber.class.php CHANGED
@@ -1,79 +1,6 @@
1
  <?php
2
 
3
- class AC_Subscriber extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function add($params, $post_data) {
14
- $request_url = "{$this->url}&api_action=subscriber_add&api_output={$this->output}";
15
- if ($params) $request_url .= "&{$params}";
16
- $response = $this->curl($request_url, $post_data);
17
- return $response;
18
- }
19
-
20
- function delete_list($params) {
21
- $request_url = "{$this->url}&api_action=subscriber_delete_list&api_output={$this->output}&{$params}";
22
- $response = $this->curl($request_url);
23
- return $response;
24
- }
25
-
26
- function delete($params) {
27
- $request_url = "{$this->url}&api_action=subscriber_delete&api_output={$this->output}&{$params}";
28
- $response = $this->curl($request_url);
29
- return $response;
30
- }
31
-
32
- function edit($params, $post_data) {
33
- $request_url = "{$this->url}&api_action=subscriber_edit&api_output={$this->output}&{$params}";
34
- $response = $this->curl($request_url, $post_data);
35
- return $response;
36
- }
37
-
38
- function list_($params) {
39
- $request_url = "{$this->url}&api_action=subscriber_list&api_output={$this->output}&{$params}";
40
- $response = $this->curl($request_url);
41
- return $response;
42
- }
43
-
44
- function paginator($params) {
45
- $request_url = "{$this->url}&api_action=subscriber_paginator&api_output={$this->output}&{$params}";
46
- $response = $this->curl($request_url);
47
- return $response;
48
- }
49
-
50
- function sync($params, $post_data) {
51
- $request_url = "{$this->url}&api_action=subscriber_sync&api_output={$this->output}";
52
- if ($params) $request_url .= "&{$params}";
53
- $response = $this->curl($request_url, $post_data);
54
- return $response;
55
- }
56
-
57
- function view($params) {
58
- // can be a subscriber ID, email, or hash
59
- if (preg_match("/^email=/", $params)) {
60
- $action = "subscriber_view_email";
61
- }
62
- elseif (preg_match("/^hash=/", $params)) {
63
- $action = "subscriber_view_hash";
64
- }
65
- elseif (preg_match("/^id=/", $params)) {
66
- $action = "subscriber_view";
67
- }
68
- else {
69
- // default
70
- $action = "subscriber_view";
71
- }
72
- $request_url = "{$this->url}&api_action={$action}&api_output={$this->output}&{$params}";
73
- $response = $this->curl($request_url);
74
- return $response;
75
- }
76
-
77
  }
78
 
79
  ?>
1
  <?php
2
 
3
+ class AC_Subscriber extends AC_Contact {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
 
6
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Tracking.class.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AC_Tracking extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ /*
18
+ * Update the status (enabled or disabled) for site tracking.
19
+ */
20
+ function site_status($params, $post_data) {
21
+ // version 2 only.
22
+ $request_url = "{$this->url_base}/track/site";
23
+ $response = $this->curl($request_url, $post_data, "POST", "tracking_site_status");
24
+ return $response;
25
+ }
26
+
27
+ /*
28
+ * Update the status (enabled or disabled) for event tracking.
29
+ */
30
+ function event_status($params, $post_data) {
31
+ // version 2 only.
32
+ $request_url = "{$this->url_base}/track/event";
33
+ $response = $this->curl($request_url, $post_data, "POST", "tracking_event_status");
34
+ return $response;
35
+ }
36
+
37
+ /*
38
+ * Returns existing whitelisted domains.
39
+ */
40
+ function site_list($params) {
41
+ if ($this->version == 1) {
42
+ // not supported currently.
43
+ //$request_url = "{$this->url}&api_action=contact_delete_list&api_output={$this->output}&{$params}";
44
+ } elseif ($this->version == 2) {
45
+ $request_url = "{$this->url_base}/track/site";
46
+ }
47
+ $response = $this->curl($request_url, array(), "GET", "tracking_site_list");
48
+ return $response;
49
+ }
50
+
51
+ /*
52
+ * Returns existing tracked events.
53
+ */
54
+ function event_list($params) {
55
+ if ($this->version == 1) {
56
+ // not supported currently.
57
+ //$request_url = "{$this->url}&api_action=contact_delete_list&api_output={$this->output}&{$params}";
58
+ } elseif ($this->version == 2) {
59
+ $request_url = "{$this->url_base}/track/event";
60
+ }
61
+ $response = $this->curl($request_url, array(), "GET", "tracking_event_list");
62
+ return $response;
63
+ }
64
+
65
+ /*
66
+ * Adds a domain to the site tracking whitelist.
67
+ */
68
+ function whitelist($params, $post_data) {
69
+ // version 2 only.
70
+ $request_url = "{$this->url_base}/track/site";
71
+ $response = $this->curl($request_url, $post_data, "PUT", "tracking_whitelist");
72
+ return $response;
73
+ }
74
+
75
+ /*
76
+ * Removes a domain from the site tracking whitelist.
77
+ */
78
+ function whitelist_remove($params, $post_data) {
79
+ // version 2 only.
80
+ $request_url = "{$this->url_base}/track/site";
81
+ $response = $this->curl($request_url, $post_data, "DELETE", "tracking_whitelist");
82
+ return $response;
83
+ }
84
+
85
+ /*
86
+ * Removes an event.
87
+ */
88
+ function event_remove($params, $post_data) {
89
+ // version 2 only.
90
+ $request_url = "{$this->url_base}/track/event";
91
+ $response = $this->curl($request_url, $post_data, "DELETE", "tracking_event_remove");
92
+ return $response;
93
+ }
94
+
95
+ /*
96
+ * Adds a new event.
97
+ */
98
+ function log($params, $post_data) {
99
+ $request_url = "https://trackcmp.net/event";
100
+ $post_data["actid"] = $this->track_actid;
101
+ $post_data["key"] = $this->track_key;
102
+ $visit_data = array();
103
+ if ($this->track_email) {
104
+ $visit_data["email"] = $this->track_email;
105
+ }
106
+ if (isset($post_data["visit"])) {
107
+ $visit_data = array_merge($visit_data, $post_data["visit"]);
108
+ }
109
+ if ($visit_data) {
110
+ $post_data["visit"] = json_encode($visit_data);
111
+ }
112
+ $response = $this->curl($request_url, $post_data, "POST", "tracking_log");
113
+ return $response;
114
+ }
115
+
116
+ }
117
+
118
+ ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/User.class.php CHANGED
@@ -1,67 +1,71 @@
1
- <?php
2
-
3
- class AC_User extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function add($params, $post_data) {
14
- $request_url = "{$this->url}&api_action=user_add&api_output={$this->output}";
15
- $response = $this->curl($request_url, $post_data);
16
- return $response;
17
- }
18
-
19
- function delete_list($params) {
20
- $request_url = "{$this->url}&api_action=user_delete_list&api_output={$this->output}&{$params}";
21
- $response = $this->curl($request_url);
22
- return $response;
23
- }
24
-
25
- function delete($params) {
26
- $request_url = "{$this->url}&api_action=user_delete&api_output={$this->output}&{$params}";
27
- $response = $this->curl($request_url);
28
- return $response;
29
- }
30
-
31
- function edit($params, $post_data) {
32
- $request_url = "{$this->url}&api_action=user_edit&api_output={$this->output}";
33
- $response = $this->curl($request_url, $post_data);
34
- return $response;
35
- }
36
-
37
- function list_($params) {
38
- $request_url = "{$this->url}&api_action=user_list&api_output={$this->output}&{$params}";
39
- $response = $this->curl($request_url);
40
- return $response;
41
- }
42
-
43
- function me() {
44
- $request_url = "{$this->url}&api_action=user_me&api_output={$this->output}";
45
- $response = $this->curl($request_url);
46
- return $response;
47
- }
48
-
49
- function view($params) {
50
- // can be a user ID, email, or username
51
- if (preg_match("/^email=/", $params)) {
52
- $action = "user_view_email";
53
- }
54
- elseif (preg_match("/^username=/", $params)) {
55
- $action = "user_view_username";
56
- }
57
- elseif (preg_match("/^id=/", $params)) {
58
- $action = "user_view";
59
- }
60
- $request_url = "{$this->url}&api_action={$action}&api_output={$this->output}&{$params}";
61
- $response = $this->curl($request_url);
62
- return $response;
63
- }
64
-
65
- }
66
-
 
 
 
 
67
  ?>
1
+ <?php
2
+
3
+ class AC_User extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function add($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=user_add&api_output={$this->output}";
19
+ $response = $this->curl($request_url, $post_data);
20
+ return $response;
21
+ }
22
+
23
+ function delete_list($params) {
24
+ $request_url = "{$this->url}&api_action=user_delete_list&api_output={$this->output}&{$params}";
25
+ $response = $this->curl($request_url);
26
+ return $response;
27
+ }
28
+
29
+ function delete($params) {
30
+ $request_url = "{$this->url}&api_action=user_delete&api_output={$this->output}&{$params}";
31
+ $response = $this->curl($request_url);
32
+ return $response;
33
+ }
34
+
35
+ function edit($params, $post_data) {
36
+ $request_url = "{$this->url}&api_action=user_edit&api_output={$this->output}";
37
+ $response = $this->curl($request_url, $post_data);
38
+ return $response;
39
+ }
40
+
41
+ function list_($params) {
42
+ $request_url = "{$this->url}&api_action=user_list&api_output={$this->output}&{$params}";
43
+ $response = $this->curl($request_url);
44
+ return $response;
45
+ }
46
+
47
+ function me() {
48
+ $request_url = "{$this->url}&api_action=user_me&api_output={$this->output}";
49
+ $response = $this->curl($request_url);
50
+ return $response;
51
+ }
52
+
53
+ function view($params) {
54
+ // can be a user ID, email, or username
55
+ if (preg_match("/^email=/", $params)) {
56
+ $action = "user_view_email";
57
+ }
58
+ elseif (preg_match("/^username=/", $params)) {
59
+ $action = "user_view_username";
60
+ }
61
+ elseif (preg_match("/^id=/", $params)) {
62
+ $action = "user_view";
63
+ }
64
+ $request_url = "{$this->url}&api_action={$action}&api_output={$this->output}&{$params}";
65
+ $response = $this->curl($request_url);
66
+ return $response;
67
+ }
68
+
69
+ }
70
+
71
  ?>
app/code/community/ActiveCampaign/Subscriptions/activecampaign-api-php/Webhook.class.php CHANGED
@@ -1,51 +1,84 @@
1
- <?php
2
-
3
- class AC_Webhook extends ActiveCampaign {
4
-
5
- public $url;
6
- public $api_key;
7
-
8
- function __construct($url, $api_key) {
9
- $this->url = $url;
10
- $this->api_key = $api_key;
11
- }
12
-
13
- function add($params, $post_data) {
14
- $request_url = "{$this->url}&api_action=webhook_add&api_output={$this->output}";
15
- $response = $this->curl($request_url, $post_data);
16
- return $response;
17
- }
18
-
19
- function delete($params) {
20
- $request_url = "{$this->url}&api_action=webhook_delete&api_output={$this->output}&{$params}";
21
- $response = $this->curl($request_url);
22
- return $response;
23
- }
24
-
25
- function delete_list($params) {
26
- $request_url = "{$this->url}&api_action=webhook_delete_list&api_output={$this->output}&{$params}";
27
- $response = $this->curl($request_url);
28
- return $response;
29
- }
30
-
31
- function edit($params, $post_data) {
32
- $request_url = "{$this->url}&api_action=webhook_edit&api_output={$this->output}";
33
- $response = $this->curl($request_url, $post_data);
34
- return $response;
35
- }
36
-
37
- function list_($params) {
38
- $request_url = "{$this->url}&api_action=webhook_list&api_output={$this->output}&{$params}";
39
- $response = $this->curl($request_url);
40
- return $response;
41
- }
42
-
43
- function view($params) {
44
- $request_url = "{$this->url}&api_action=webhook_view&api_output={$this->output}&{$params}";
45
- $response = $this->curl($request_url);
46
- return $response;
47
- }
48
-
49
- }
50
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  ?>
1
+ <?php
2
+
3
+ class AC_Webhook extends ActiveCampaign {
4
+
5
+ public $version;
6
+ public $url_base;
7
+ public $url;
8
+ public $api_key;
9
+
10
+ function __construct($version, $url_base, $url, $api_key) {
11
+ $this->version = $version;
12
+ $this->url_base = $url_base;
13
+ $this->url = $url;
14
+ $this->api_key = $api_key;
15
+ }
16
+
17
+ function add($params, $post_data) {
18
+ $request_url = "{$this->url}&api_action=webhook_add&api_output={$this->output}";
19
+ $response = $this->curl($request_url, $post_data);
20
+ return $response;
21
+ }
22
+
23
+ function delete($params) {
24
+ $request_url = "{$this->url}&api_action=webhook_delete&api_output={$this->output}&{$params}";
25
+ $response = $this->curl($request_url);
26
+ return $response;
27
+ }
28
+
29
+ function delete_list($params) {
30
+ $request_url = "{$this->url}&api_action=webhook_delete_list&api_output={$this->output}&{$params}";
31
+ $response = $this->curl($request_url);
32
+ return $response;
33
+ }
34
+
35
+ function edit($params, $post_data) {
36
+ $request_url = "{$this->url}&api_action=webhook_edit&api_output={$this->output}";
37
+ $response = $this->curl($request_url, $post_data);
38
+ return $response;
39
+ }
40
+
41
+ function list_($params) {
42
+ $request_url = "{$this->url}&api_action=webhook_list&api_output={$this->output}&{$params}";
43
+ $response = $this->curl($request_url);
44
+ return $response;
45
+ }
46
+
47
+ function view($params) {
48
+ $request_url = "{$this->url}&api_action=webhook_view&api_output={$this->output}&{$params}";
49
+ $response = $this->curl($request_url);
50
+ return $response;
51
+ }
52
+
53
+ function events($params) {
54
+ $request_url = "{$this->url}&api_action=webhook_events&api_output={$this->output}&{$params}";
55
+ $response = $this->curl($request_url);
56
+ return $response;
57
+ }
58
+
59
+ function process($params) {
60
+ // process an incoming webhook payload (from ActiveCampaign), and format it (or do something with it)
61
+
62
+ $r = array();
63
+ if ($_SERVER["REQUEST_METHOD"] != "POST") return $r;
64
+
65
+ $params_array = explode("&", $params);
66
+ $params_ = array();
67
+ foreach ($params_array as $expression) {
68
+ // IE: css=1
69
+ list($var, $val) = explode("=", $expression);
70
+ $params_[$var] = $val;
71
+ }
72
+
73
+ $event = $params_["event"];
74
+ $format = $params_["output"];
75
+
76
+ if ($format == "json") {
77
+ return json_encode($_POST);
78
+ }
79
+
80
+ }
81
+
82
+ }
83
+
84
  ?>
app/code/community/ActiveCampaign/Subscriptions/etc/config.xml CHANGED
@@ -32,15 +32,15 @@
32
  </layout>
33
  </frontend>
34
  <admin>
35
- <routers>
36
- <subscriptions>
37
- <use>admin</use>
38
- <args>
39
- <module>ActiveCampaign_Subscriptions</module>
40
- <frontName>subscriptions</frontName>
41
- </args>
42
- </subscriptions>
43
- </routers>
44
  </admin>
45
  <adminhtml>
46
  <menu>
@@ -51,7 +51,7 @@
51
  <items module="subscriptions">
52
  <title>Settings</title>
53
  <sort_order>0</sort_order>
54
- <action>subscriptions/adminhtml_subscriptions</action>
55
  </items>
56
  </children>
57
  </subscriptions>
@@ -59,7 +59,7 @@
59
  <children>
60
  <subscriptions_adminform translate="title" module="subscriptions">
61
  <title>ActiveCampaign Settings</title>
62
- <action>subscriptions/adminhtml_subscriptions</action>
63
  </subscriptions_adminform>
64
  </children>
65
  </newsletter>
32
  </layout>
33
  </frontend>
34
  <admin>
35
+ <routers>
36
+ <adminhtml>
37
+ <args>
38
+ <modules>
39
+ <subscriptions after="Mage_Adminhtml">ActiveCampaign_Subscriptions_Adminhtml</subscriptions>
40
+ </modules>
41
+ </args>
42
+ </adminhtml>
43
+ </routers>
44
  </admin>
45
  <adminhtml>
46
  <menu>
51
  <items module="subscriptions">
52
  <title>Settings</title>
53
  <sort_order>0</sort_order>
54
+ <action>adminhtml/subscriptions</action>
55
  </items>
56
  </children>
57
  </subscriptions>
59
  <children>
60
  <subscriptions_adminform translate="title" module="subscriptions">
61
  <title>ActiveCampaign Settings</title>
62
+ <action>adminhtml/subscriptions</action>
63
  </subscriptions_adminform>
64
  </children>
65
  </newsletter>
app/design/adminhtml/default/default/layout/subscriptions.xml CHANGED
@@ -1,10 +1,10 @@
1
  <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
- <subscriptions_adminhtml_subscriptions_index>
4
  <reference name="content">
5
  <block type="subscriptions/adminhtml_subscriptions" name="subscriptions" template="subscriptions/list.phtml">
6
  <block type="subscriptions/adminhtml_subscriptions" name="grid" template="subscriptions/grid.phtml" />
7
  </block>
8
  </reference>
9
- </subscriptions_adminhtml_subscriptions_index>
10
  </layout>
1
  <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_subscriptions_index>
4
  <reference name="content">
5
  <block type="subscriptions/adminhtml_subscriptions" name="subscriptions" template="subscriptions/list.phtml">
6
  <block type="subscriptions/adminhtml_subscriptions" name="grid" template="subscriptions/grid.phtml" />
7
  </block>
8
  </reference>
9
+ </adminhtml_subscriptions_index>
10
  </layout>
package.xml CHANGED
@@ -1,26 +1,26 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ActiveCampaign_Subscriptions</name>
4
- <version>1.5.1</version>
5
  <stability>stable</stability>
6
  <license uri="https://www.activecampaign.com/hosted/terms.php">Commercial/Free</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Add Magento customers as ActiveCampaign subscribers with various sync options.</summary>
10
  <description>1. Connect any ActiveCampaign hosted account (using your API URL and Key).&#xD;
11
  &#xD;
12
  2. Have new customer account registrations added to ActiveCampaign (if they opt-in to the Newsletter).&#xD;
13
  &#xD;
14
  3. Have existing customer account newsletter modifications updated in ActiveCampaign.&#xD;
15
  &#xD;
16
- 4. Bulk export/sync all current newsletter subscribers to ActiveCampaign in just two clicks!</description>
17
- <notes>Added Forms selector, so you can control how subscribers receive Opt-in messages.&#xD;
18
  &#xD;
19
- Also removed the "Reset" and "Delete Connection" buttons, as they are not necessary (you can use "Enabled" or "Disabled" instead).</notes>
20
  <authors><author><name>ActiveCampaign, Inc.</name><user>activecampaign</user><email>help@activecampaign.com</email></author></authors>
21
- <date>2013-05-11</date>
22
- <time>15:33:54</time>
23
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="subscriptions.xml" hash="18bfe6676477fc84b488277025d42568"/></dir><dir name="template"><dir name="subscriptions"><file name="grid.phtml" hash="5d13aea3c7e678f80aa7e72d5337ae9d"/><file name="list.phtml" hash="70c40a80ee43596da6ae899f14191e91"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="subscriptions.xml" hash="d0a96f68db976ce1919a664228184e9c"/></dir><dir name="template"><dir name="subscriptions"><file name="subscriptions.phtml" hash="2025758bce03d7b9cfe99029050c7be4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ActiveCampaign_Subscriptions.xml" hash="14eb3a0c9c06bc847b4e8c6ff691c07d"/></dir></target><target name="magecommunity"><dir name="ActiveCampaign"><dir name="Subscriptions"><dir name="activecampaign-api-php"><file name="Account.class.php" hash="eb5d6e647e0c5d6db2e4291bd2e4c24a"/><file name="ActiveCampaign.class.php" hash="a088e4fb59ae3c5353d43a3d39a2d62f"/><file name="Auth.class.php" hash="6cf45573aaa8aa4b158f88d80bb9ac7d"/><file name="Campaign.class.php" hash="3db78bd78995f6d4c42d80d26300ebe3"/><file name="Connector.class.php" hash="73d01f8f2c29248c79913083b6d58963"/><file name="Design.class.php" hash="113a72a83d979fbe80b5ef3acd085a86"/><file name="Form.class.php" hash="c62e2fc1399d0dfac4532c7e450ff31d"/><file name="Group.class.php" hash="ce0792f8032ec09b8ca6636ffd14cdc3"/><file name="List.class.php" hash="ad045005e67f7724421b98d44b3464bd"/><file name="Message.class.php" hash="da8e027327b10dcbbd18a94a1a9730b0"/><file name="Subscriber.class.php" hash="132a8edd2d571f5064855e467e916d48"/><file name="User.class.php" hash="4732c709aedb1cc0448acafd4c956c29"/><file name="Webhook.class.php" hash="1b9fc3e1524c146f42c81f6d2521a7f9"/></dir><dir name="Block"><file name="Subscriptions.php" hash="79b032b024a0593188258d4fef3fa733"/><dir name="Adminhtml"><file name="Subscriptions.php" hash="7f9fdec5858ef7a30c1fcd129f13fe67"/><dir name="Subscriptions"><file name="Edit.php" hash="3c464d71d1ad78ae035f810a1248f918"/><file name="Grid.php" hash="b51fc9698c21224488c41826489a8177"/><dir name="Edit"><file name="Form.php" hash="b1eda088b2adf03d69bc1aa3cfb2a00a"/><file name="Tabs.php" hash="4c94ebd27bb6bb0a572131d441afa945"/><dir name="Tab"><file name="Connection.php" hash="230d5a8f70b5de930864b25821290efb"/><file name="Export.php" hash="f65aa906629d6a1b4a17f16014488017"/><file name="List.php" hash="4f2cd4ca088cca5bb2ad1b598c9bc486"/><file name="Form.php" hash="8bf394482cf60f311b8610521888b0d8"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="f6e27a764745bdb55f17fdca49a7fa81"/><dir name="Adminhtml"><file name="SubscriptionsController.php" hash="edd787979ac83ea735f8c4cd61340c89"/></dir></dir><dir name="etc"><file name="config.xml" hash="a3bacb007c725735eee61c9a2bae5475"/></dir><dir name="Helper"><file name="Data.php" hash="4b35d91431328ee595132df575a60a2a"/></dir><dir name="Model"><file name="Observer.php" hash="0333eb2cbbcdedaaf5607f80e3cdcfe9"/><file name="Status.php" hash="c35feda8164009341d289074be5612c0"/><file name="Subscriptions.php" hash="76818326ecfd635e574f704003184300"/><dir name="Mysql4"><file name="Subscriptions.php" hash="d112b3f1194a8bb7f329dacb34161941"/><dir name="Subscriptions"><file name="Collection.php" hash="457890390bd29e72dda81d3088ef5a50"/></dir></dir></dir><dir name="sql"><dir name="subscriptions_setup"><file name="mysql4-install-0.1.0.php" hash="9f756eb38486cc878134f07f22f661c0"/></dir></dir></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><extension><name>curl</name><min>7.19.7</min><max>7.28.0</max></extension></required></dependencies>
26
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ActiveCampaign_Subscriptions</name>
4
+ <version>1.5.2</version>
5
  <stability>stable</stability>
6
  <license uri="https://www.activecampaign.com/hosted/terms.php">Commercial/Free</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Add Magento customers as ActiveCampaign contacts with various sync options.</summary>
10
  <description>1. Connect any ActiveCampaign hosted account (using your API URL and Key).&#xD;
11
  &#xD;
12
  2. Have new customer account registrations added to ActiveCampaign (if they opt-in to the Newsletter).&#xD;
13
  &#xD;
14
  3. Have existing customer account newsletter modifications updated in ActiveCampaign.&#xD;
15
  &#xD;
16
+ 4. Bulk export/sync all current newsletter contacts to ActiveCampaign in just two clicks!</description>
17
+ <notes>Applied update for SUPEE-6788 security issue.&#xD;
18
  &#xD;
19
+ Also updated the ActiveCampaign PHP API wrapper files to the latest version.</notes>
20
  <authors><author><name>ActiveCampaign, Inc.</name><user>activecampaign</user><email>help@activecampaign.com</email></author></authors>
21
+ <date>2015-11-08</date>
22
+ <time>22:16:29</time>
23
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="subscriptions.xml" hash="825b33cd139c693c88047584959f49ed"/></dir><dir name="template"><dir name="subscriptions"><file name="grid.phtml" hash="5d13aea3c7e678f80aa7e72d5337ae9d"/><file name="list.phtml" hash="70c40a80ee43596da6ae899f14191e91"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="subscriptions.xml" hash="d0a96f68db976ce1919a664228184e9c"/></dir><dir name="template"><dir name="subscriptions"><file name="subscriptions.phtml" hash="2025758bce03d7b9cfe99029050c7be4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ActiveCampaign_Subscriptions.xml" hash="14eb3a0c9c06bc847b4e8c6ff691c07d"/></dir></target><target name="magecommunity"><dir name="ActiveCampaign"><dir name="Subscriptions"><dir name="activecampaign-api-php"><file name="Account.class.php" hash="b6426c518978bbfb4ae032cb6ddcc29c"/><file name="ActiveCampaign.class.php" hash="900f5ef0acd4af4105471feda2917aae"/><file name="Auth.class.php" hash="affc478ccf1622400409d8b623230183"/><file name="Campaign.class.php" hash="229ec1cb98add26450f38aa283f40e5f"/><file name="Connector.class.php" hash="6c6ae2daf963e4b8e1f941e73f94b8f0"/><file name="Design.class.php" hash="53104c2ee4f4d54577f385188ba8c9af"/><file name="Form.class.php" hash="2fe24b9e11057e55bb79221fa59a38a7"/><file name="Group.class.php" hash="4712367081b6099bc88440c7ac4c35d0"/><file name="List.class.php" hash="c451709386aaebabeef2d85422e3cf3f"/><file name="Message.class.php" hash="8c072e28994283d0ff7b950df55a6655"/><file name="Contact.class.php" hash="d19e57f06044b5dc98b929b449521a19"/><file name="User.class.php" hash="5a213c94cc6d2a9545856982a38ad26b"/><file name="Webhook.class.php" hash="2933f75823679abd5d178774c8d61682"/><file name="Deal.class.php" hash="39b1cacc347584517d4fb145d060082f"/><file name="Settings.class.php" hash="85a2ffea84086486f5fb9f4325fe701d"/><file name="Subscriber.class.php" hash="94c6b4289e50ea4cf33e98b72e450528"/><file name="Tracking.class.php" hash="f84aa5361c44203f90ef14bb08d90a9e"/><file name="Automation.class.php" hash="f58d2c9ed16fce6c838c50160484363e"/></dir><dir name="Block"><file name="Subscriptions.php" hash="79b032b024a0593188258d4fef3fa733"/><dir name="Adminhtml"><file name="Subscriptions.php" hash="7f9fdec5858ef7a30c1fcd129f13fe67"/><dir name="Subscriptions"><file name="Edit.php" hash="3c464d71d1ad78ae035f810a1248f918"/><file name="Grid.php" hash="b51fc9698c21224488c41826489a8177"/><dir name="Edit"><file name="Form.php" hash="b1eda088b2adf03d69bc1aa3cfb2a00a"/><file name="Tabs.php" hash="4c94ebd27bb6bb0a572131d441afa945"/><dir name="Tab"><file name="Connection.php" hash="230d5a8f70b5de930864b25821290efb"/><file name="Export.php" hash="f65aa906629d6a1b4a17f16014488017"/><file name="List.php" hash="4f2cd4ca088cca5bb2ad1b598c9bc486"/><file name="Form.php" hash="8bf394482cf60f311b8610521888b0d8"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="f6e27a764745bdb55f17fdca49a7fa81"/><dir name="Adminhtml"><file name="SubscriptionsController.php" hash="edd787979ac83ea735f8c4cd61340c89"/></dir></dir><dir name="etc"><file name="config.xml" hash="40947886dd3611ebeb717de55ef8c240"/></dir><dir name="Helper"><file name="Data.php" hash="4b35d91431328ee595132df575a60a2a"/></dir><dir name="Model"><file name="Observer.php" hash="0333eb2cbbcdedaaf5607f80e3cdcfe9"/><file name="Status.php" hash="c35feda8164009341d289074be5612c0"/><file name="Subscriptions.php" hash="76818326ecfd635e574f704003184300"/><dir name="Mysql4"><file name="Subscriptions.php" hash="d112b3f1194a8bb7f329dacb34161941"/><dir name="Subscriptions"><file name="Collection.php" hash="457890390bd29e72dda81d3088ef5a50"/></dir></dir></dir><dir name="sql"><dir name="subscriptions_setup"><file name="mysql4-install-0.1.0.php" hash="9f756eb38486cc878134f07f22f661c0"/></dir></dir></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><extension><name>curl</name><min>7.19.7</min><max>7.28.0</max></extension></required></dependencies>
26
  </package>