Skip to content

Commit 959c7d1

Browse files
committed
Add popo classes
1 parent f08efe2 commit 959c7d1

File tree

3 files changed

+426
-15
lines changed

3 files changed

+426
-15
lines changed

src/Ubiquity/controllers/DisplayMailController.php

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
<?php
2+
namespace Ubiquity\controllers\admin\popo;
3+
4+
use Ubiquity\mailer\MailerManager;
5+
use Ubiquity\cache\ClassUtils;
6+
7+
class MailerClass {
8+
9+
protected $name;
10+
11+
protected $shortname;
12+
13+
protected $to;
14+
15+
protected $cc;
16+
17+
protected $bcc;
18+
19+
protected $from;
20+
21+
protected $subject;
22+
23+
protected $body;
24+
25+
protected $bodyText;
26+
27+
protected $attachments;
28+
29+
protected $rawAttachments;
30+
31+
protected $hasRecipients;
32+
33+
protected $sentAt;
34+
35+
protected $attachmentsDir;
36+
37+
/**
38+
*
39+
* @return mixed
40+
*/
41+
public function getAttachmentsDir() {
42+
return $this->attachmentsDir;
43+
}
44+
45+
/**
46+
*
47+
* @param mixed $attachmentsDir
48+
*/
49+
public function setAttachmentsDir($attachmentsDir) {
50+
$this->attachmentsDir = $attachmentsDir;
51+
}
52+
53+
/**
54+
*
55+
* @return mixed
56+
*/
57+
public function getSentAt() {
58+
return $this->sentAt;
59+
}
60+
61+
/**
62+
*
63+
* @param mixed $sentAt
64+
*/
65+
public function setSentAt($sentAt) {
66+
$this->sentAt = $sentAt;
67+
}
68+
69+
/**
70+
*
71+
* @return mixed
72+
*/
73+
public function getBodyText() {
74+
return $this->bodyText;
75+
}
76+
77+
/**
78+
*
79+
* @return mixed
80+
*/
81+
public function getAttachments() {
82+
return $this->attachments;
83+
}
84+
85+
/**
86+
*
87+
* @return mixed
88+
*/
89+
public function getRawAttachments() {
90+
return $this->rawAttachments;
91+
}
92+
93+
/**
94+
*
95+
* @param mixed $bodyText
96+
*/
97+
public function setBodyText($bodyText) {
98+
$this->bodyText = $bodyText;
99+
}
100+
101+
/**
102+
*
103+
* @param mixed $attachments
104+
*/
105+
public function setAttachments($attachments) {
106+
$this->attachments = $attachments;
107+
}
108+
109+
/**
110+
*
111+
* @param mixed $rawAttachments
112+
*/
113+
public function setRawAttachments($rawAttachments) {
114+
$this->rawAttachments = $rawAttachments;
115+
}
116+
117+
/**
118+
*
119+
* @return mixed
120+
*/
121+
public function getHasRecipients() {
122+
return $this->hasRecipients;
123+
}
124+
125+
/**
126+
*
127+
* @param mixed $hasRecipients
128+
*/
129+
public function setHasRecipients($hasRecipients) {
130+
$this->hasRecipients = $hasRecipients;
131+
}
132+
133+
/**
134+
*
135+
* @return mixed
136+
*/
137+
public function getBcc() {
138+
return $this->bcc;
139+
}
140+
141+
/**
142+
*
143+
* @param mixed $bcc
144+
*/
145+
public function setBcc($bcc) {
146+
$this->bcc = $bcc;
147+
}
148+
149+
/**
150+
*
151+
* @return mixed
152+
*/
153+
public function getCc() {
154+
return $this->cc;
155+
}
156+
157+
/**
158+
*
159+
* @param mixed $cc
160+
*/
161+
public function setCc($cc) {
162+
$this->cc = $cc;
163+
}
164+
165+
/**
166+
*
167+
* @return mixed
168+
*/
169+
public function getBody() {
170+
return $this->body;
171+
}
172+
173+
/**
174+
*
175+
* @param mixed $body
176+
*/
177+
public function setBody($body) {
178+
$this->body = $body;
179+
}
180+
181+
/**
182+
*
183+
* @return string
184+
*/
185+
public function getName() {
186+
return $this->name;
187+
}
188+
189+
/**
190+
*
191+
* @return string
192+
*/
193+
public function getShortname() {
194+
return $this->shortname;
195+
}
196+
197+
/**
198+
*
199+
* @param string $name
200+
*/
201+
public function setName($name) {
202+
$this->name = $name;
203+
}
204+
205+
/**
206+
*
207+
* @param string $shortname
208+
*/
209+
public function setShortname($shortname) {
210+
$this->shortname = $shortname;
211+
}
212+
213+
/**
214+
*
215+
* @return mixed
216+
*/
217+
public function getTo() {
218+
return $this->to;
219+
}
220+
221+
/**
222+
*
223+
* @return mixed
224+
*/
225+
public function getFrom() {
226+
return $this->from;
227+
}
228+
229+
/**
230+
*
231+
* @param mixed $to
232+
*/
233+
public function setTo($to) {
234+
$this->to = $to;
235+
}
236+
237+
/**
238+
*
239+
* @param mixed $from
240+
*/
241+
public function setFrom($from) {
242+
$this->from = $from;
243+
}
244+
245+
/**
246+
*
247+
* @return mixed
248+
*/
249+
public function getSubject() {
250+
return $this->subject;
251+
}
252+
253+
/**
254+
*
255+
* @param mixed $subject
256+
*/
257+
public function setSubject($subject) {
258+
$this->subject = $subject;
259+
}
260+
261+
public static function init() {
262+
$result = [];
263+
$classes = MailerManager::getMailClasses(true);
264+
foreach ($classes as $class) {
265+
$result[] = self::initOne($class);
266+
}
267+
return $result;
268+
}
269+
270+
public static function initOne($class) {
271+
$mailclass = new static();
272+
$mailclass->setName($class);
273+
$mailclass->setShortname(ClassUtils::getClassSimpleName($class));
274+
$mail = new $class();
275+
$mailclass->to = $mail->to;
276+
$mailclass->from = $mail->from;
277+
$mailclass->cc = $mail->cc;
278+
$mailclass->bcc = $mail->bcc;
279+
$mailclass->hasRecipients = $mail->hasRecipients();
280+
$mailclass->subject = $mail->getSubject();
281+
$mailclass->body = $mail->body();
282+
$mailclass->bodyText = $mail->bodyText();
283+
$mailclass->attachments = $mail->attachments;
284+
$mailclass->rawAttachments = $mail->rawAttachments;
285+
$mailclass->attachmentsDir = $mail->getAttachmentsDir();
286+
return $mailclass;
287+
}
288+
289+
public static function initOneFromInfos($class, $mailInfos) {
290+
$mailclass = new static();
291+
$mailclass->setName($class);
292+
$mailclass->setShortname(ClassUtils::getClassSimpleName($class));
293+
foreach ($mailInfos as $key => $value) {
294+
if (\property_exists($mailclass, $key)) {
295+
$mailclass->$key = $value;
296+
}
297+
}
298+
$mailclass->hasRecipients = false;
299+
return $mailclass;
300+
}
301+
}
302+

0 commit comments

Comments
 (0)