1 <?php namespace rpf\api\module;
2
3 use rpf\api\apiModule;
4
5 require_once __DIR__.'/../apiModule.php';
6
7 8 9 10 11
12 class email extends apiModule
13 {
14 15 16 17 18 19 20
21 public function loadByOeid($oeids)
22 {
23 if (is_int($oeids))
24 {
25 $oeids[] = $oeids;
26 }
27
28 if (!is_array($oeids))
29 {
30 throw new \Exception(__CLASS__.'::'.__METHOD__.' expects an array, '.gettype($oeids).' given.');
31 }
32
33 foreach($oeids as $oeid)
34 {
35 if (!is_int($oeid))
36 {
37 throw new \Exception(__CLASS__.'::'.__METHOD__.' expects an int-array, '.gettype($oeid).' in array given.');
38 }
39 $this->orders[$oeid] = $this->system->call('bbEmail::readAccount', ['oeid' => $oeid, 'return_array' => 1]);
40 }
41 return $this;
42 }
43
44 public function loadAll($param = false, $runOnce = true)
45 {
46 if ($runOnce && !$this->runOnce(__METHOD__)) return $this;
47
48 if ($oeid == false && $param == false)
49 {
50 $this->data = $this->system->call('bbEmail::readAccount', ['return_array' => 1]);
51 }
52 else
53 {
54 throw new \Exception(__METHOD__."($oeid, $param, $runOnce) is not implemented yet", 501);
55 }
56
57 return $this;
58 }
59
60 61 62 63 64 65 66 67
68 public function loadOrderMailCount($oeid = false, $runOnce = true)
69 {
70 if ($runOnce && !$this->runOnce(__METHOD__)) return $this;
71
72 if ($oeid !== false)
73 {
74
75 throw new \Exception("Not implemented yet", 501);
76 }
77
78 $result = $this->system->call('bbEmail::readAccount', ['return_array' => 1]);
79
80 foreach ($result as &$row)
81 {
82 if (!isset($this->orders[$row['oeid']]['mail_addresses']))
83 {
84 $this->orders[$row['oeid']]['mail_addresses'] = 1;
85 }
86 else
87 {
88 $this->orders[$row['oeid']]['mail_addresses']++;
89 }
90 }
91 return $this;
92 }
93
94 95 96 97 98
99 public function getIndexedByOrderId()
100 {
101 if (!is_array($this->data) || empty($this->data))
102 {
103 return array();
104 }
105 else
106 {
107 foreach ($this->data as &$row) {
108 $return[$row['oeid']] = &$row;
109 }
110 return $return;
111 }
112 }
113
114 115 116 117 118
119 public function getIndexedByEmail()
120 {
121 if (!is_array($this->data) || empty($this->data))
122 {
123 return array();
124 }
125 else
126 {
127 foreach ($this->data as &$row) {
128
129 $return[$row['xxxx']] = &$row;
130 }
131 return $return;
132 }
133 }
134
135
136
137
138 }