PluginProbe ʕ •ᴥ•ʔ
Post Affiliate Pro / trunk
Post Affiliate Pro vtrunk
1.29.5 1.29.4 1.29.3 1.29.0 1.29.1 1.29.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.5.0 1.5.1 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.1 1.6.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 trunk 1.0.1 1.0.10 1.0.11 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.10.1 1.10.2 1.10.3 1.10.4 1.11.1 1.11.2 1.12.1 1.12.2 1.12.3 1.12.4 1.12.5 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.13.5 1.13.6 1.14.0 1.14.1 1.14.2 1.15.0 1.15.1 1.15.2 1.15.3 1.15.4 1.15.5 1.16.0 1.16.1 1.16.2 1.16.3 1.16.4 1.16.5 1.17.0 1.18.0 1.18.1 1.18.2 1.18.3 1.18.4 1.19.0 1.19.1 1.19.10 1.19.11 1.19.12 1.19.13 1.19.14 1.19.15 1.19.16 1.19.17 1.19.2 1.19.3 1.19.4 1.19.5 1.19.6 1.19.7 1.19.8 1.19.9 1.2.0 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.28 1.2.3 1.2.31 1.2.32 1.2.33 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.20.0 1.20.1 1.21.0 1.21.1 1.21.2 1.21.3 1.21.4 1.21.5 1.21.6 1.21.7 1.22.0 1.22.1 1.22.2 1.23.0 1.23.1 1.23.2 1.23.3 1.23.4 1.23.5 1.23.6 1.23.7 1.23.8 1.24.1 1.24.2 1.24.3 1.24.4 1.24.5 1.24.6 1.24.7 1.24.8 1.24.9 1.25.0 1.26.0 1.26.1 1.26.10 1.26.11 1.26.2 1.26.3 1.26.4 1.26.5 1.26.6 1.26.7 1.26.8 1.26.9 1.27.0 1.27.1 1.27.10 1.27.11 1.27.12 1.27.13 1.27.14 1.27.15 1.27.2 1.27.3 1.27.5 1.27.6 1.27.7 1.27.8 1.27.9 1.28.0 1.28.1 1.28.2 1.28.3
postaffiliatepro / Util / CampaignHelper.class.php
postaffiliatepro / Util Last commit date
CampaignHelper.class.php 2 months ago ContactForm7Helper.class.php 2 months ago TopAffiliatesHelper.class.php 2 months ago UpdateDB.class.php 2 months ago
CampaignHelper.class.php
98 lines
1 <?php
2 if (!defined('ABSPATH')) exit;
3
4 class postaffiliatepro_Util_CampaignHelper extends postaffiliatepro_Base {
5
6 const CAMPAIGN_NAME = 'name';
7 //const CAMPAIGN_STATUS = 'rstatus';
8 const CAMPAIGN_TYPE = 'rtype';
9 const CAMPAIGN_ID = 'id';
10
11 const CAMPAIGN_TYPE_PRIVATE = 'I';
12 const CAMPAIGN_TYPE_PUBLIC = 'P';
13 const CAMPAIGN_TYPE_PUBLIC_MANUAL = 'M';
14
15 /**
16 *
17 * @var Gpf_Data_RecordSet
18 */
19 private static $campaignList = null;
20
21 public function getTypeAsText($type) {
22 switch ($type) {
23 case self::CAMPAIGN_TYPE_PUBLIC:
24 return __('Public', 'postaffiliatepro');
25 case self::CAMPAIGN_TYPE_PUBLIC_MANUAL:
26 return __('Public with manual approval', 'postaffiliatepro');
27 case self::CAMPAIGN_TYPE_PRIVATE:
28 return __('Private', 'postaffiliatepro');
29 }
30 }
31
32 public function getCampaignsCount($type = null) {
33 $campaignList = $this->getCampaignsList();
34 if (empty($campaignList)) {
35 return 0;
36 }
37 if ($type === null) {
38 return $campaignList->getSize();
39 }
40 $count = 0;
41 foreach ($campaignList as $campaign) {
42 if ($campaign->get(self::CAMPAIGN_TYPE) === $type) {
43 $count ++;
44 }
45 }
46 return $count;
47 }
48
49 public function getCampaignType($campaignId) {
50 $campaignList = $this->getCampaignsList();
51 foreach ($campaignList as $campaign) {
52 if ($campaign->get(self::CAMPAIGN_ID) === $campaignId) {
53 return $campaign->get(self::CAMPAIGN_TYPE);
54 }
55 }
56 }
57
58 public function getCampaignName($campaignId) {
59 $campaignList = $this->getCampaignsList();
60 foreach ($campaignList as $campaign) {
61 if ($campaign->get(self::CAMPAIGN_ID) === $campaignId) {
62 return htmlspecialchars($campaign->get(self::CAMPAIGN_NAME));
63 }
64 }
65 }
66
67 /**
68 * @return Gpf_Data_RecordSet;
69 */
70 public function getCampaignsList() {
71 if (self::$campaignList !== null) {
72 return self::$campaignList;
73 }
74 $session = $this->getApiSession();
75 if ($session === null || $session === '0') {
76 return array();
77 }
78 $request = new Gpf_Rpc_GridRequest('Pap_Merchants_Campaign_CampaignsGrid', 'getRows', $session);
79 $request->setLimit(0, 9999);
80 $request->addParam('columns', new Gpf_Rpc_Array(array(array('id'), array('id'))));
81
82 $filters = new Gpf_Rpc_Array();
83 $filters->add(new Gpf_Data_Filter('rstatus', 'NE', 'D'));
84 $filters->add(new Gpf_Data_Filter('rstatus', 'NE', 'S'));
85 $filters->add(new Gpf_Data_Filter('rstatus', 'NE', 'W'));
86
87 $request->addParam('filters', $filters);
88 try {
89 $request->sendNow();
90 } catch(Exception $e) {
91 $this->_log('Can not obtain campaign list: '. $e->getMessage());
92 return array();
93 }
94 $grid = $request->getGrid();
95 self::$campaignList = $grid->getRecordset();
96 return self::$campaignList;
97 }
98 }