1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @author Christoph Wurst <[email protected]> |
5
|
|
|
* @author Jan-Christoph Borchardt <[email protected]> |
6
|
|
|
* @author Lukas Reschke <[email protected]> |
7
|
|
|
* @author Thomas Müller <[email protected]> |
8
|
|
|
* |
9
|
|
|
* Mail |
10
|
|
|
* |
11
|
|
|
* This code is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
13
|
|
|
* as published by the Free Software Foundation. |
14
|
|
|
* |
15
|
|
|
* This program is distributed in the hope that it will be useful, |
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
* GNU Affero General Public License for more details. |
19
|
|
|
* |
20
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace OCA\Mail\Db; |
26
|
|
|
|
27
|
|
|
use OCP\AppFramework\Db\Entity; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class MailAccount |
31
|
|
|
* |
32
|
|
|
* @package OCA\Mail\Db |
33
|
|
|
* |
34
|
|
|
* @method string getUserId() |
35
|
|
|
* @method void setUserId(string $userId) |
36
|
|
|
* @method string getName() |
37
|
|
|
* @method void setName(string $name) |
38
|
|
|
* @method string getEmail() |
39
|
|
|
* @method void setEmail(string $email) |
40
|
|
|
* @method string getInboundHost() |
41
|
|
|
* @method void setInboundHost(string $inboundHost) |
42
|
|
|
* @method integer getInboundPort() |
43
|
|
|
* @method void setInboundPort(integer $inboundPort) |
44
|
|
|
* @method string getInboundSslMode() |
45
|
|
|
* @method void setInboundSslMode(string $inboundSslMode) |
46
|
|
|
* @method string getInboundUser() |
47
|
|
|
* @method void setInboundUser(string $inboundUser) |
48
|
|
|
* @method string getInboundPassword() |
49
|
|
|
* @method void setInboundPassword(string $inboundPassword) |
50
|
|
|
* @method string getOutboundHost() |
51
|
|
|
* @method void setOutboundHost(string $outboundHost) |
52
|
|
|
* @method integer getOutboundPort() |
53
|
|
|
* @method void setOutboundPort(integer $outboundPort) |
54
|
|
|
* @method string getOutboundSslMode() |
55
|
|
|
* @method void setOutboundSslMode(string $outboundSslMode) |
56
|
|
|
* @method string getOutboundUser() |
57
|
|
|
* @method void setOutboundUser(string $outboundUser) |
58
|
|
|
* @method string getOutboundPassword() |
59
|
|
|
* @method void setOutboundPassword(string $outboundPassword) |
60
|
|
|
*/ |
61
|
|
|
class MailAccount extends Entity { |
62
|
|
|
|
63
|
|
|
public $userId; |
64
|
|
|
public $name; |
65
|
|
|
public $email; |
66
|
|
|
public $inboundHost; |
67
|
|
|
public $inboundPort; |
68
|
|
|
public $inboundSslMode; |
69
|
|
|
public $inboundUser; |
70
|
|
|
public $inboundPassword; |
71
|
|
|
public $outboundHost; |
72
|
|
|
public $outboundPort; |
73
|
|
|
public $outboundSslMode; |
74
|
|
|
public $outboundUser; |
75
|
|
|
public $outboundPassword; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param array $params |
79
|
|
|
*/ |
80
|
5 |
|
public function __construct(array $params=[]) { |
81
|
|
|
|
82
|
5 |
|
if (isset($params['accountId'])) { |
83
|
1 |
|
$this->setId($params['accountId']); |
84
|
1 |
|
} |
85
|
5 |
|
if (isset($params['accountName'])) { |
86
|
1 |
|
$this->setName($params['accountName']); |
87
|
1 |
|
} |
88
|
5 |
|
if (isset($params['emailAddress'])) { |
89
|
1 |
|
$this->setEmail($params['emailAddress']); |
90
|
1 |
|
} |
91
|
|
|
|
92
|
5 |
|
if (isset($params['imapHost'])) { |
93
|
1 |
|
$this->setInboundHost($params['imapHost']); |
94
|
1 |
|
} |
95
|
5 |
|
if (isset($params['imapPort'])) { |
96
|
1 |
|
$this->setInboundPort($params['imapPort']); |
97
|
1 |
|
} |
98
|
5 |
|
if (isset($params['imapSslMode'])) { |
99
|
1 |
|
$this->setInboundSslMode($params['imapSslMode']); |
100
|
1 |
|
} |
101
|
5 |
|
if (isset($params['imapUser'])) { |
102
|
1 |
|
$this->setInboundUser($params['imapUser']); |
103
|
1 |
|
} |
104
|
5 |
|
if (isset($params['imapPassword'])) { |
105
|
|
|
$this->setInboundPassword($params['imapPassword']); |
106
|
|
|
} |
107
|
|
|
|
108
|
5 |
|
if (isset($params['smtpHost'])) { |
109
|
1 |
|
$this->setOutboundHost($params['smtpHost']); |
110
|
1 |
|
} |
111
|
5 |
|
if (isset($params['smtpPort'])) { |
112
|
1 |
|
$this->setOutboundPort($params['smtpPort']); |
113
|
1 |
|
} |
114
|
5 |
|
if (isset($params['smtpSslMode'])) { |
115
|
1 |
|
$this->setOutboundSslMode($params['smtpSslMode']); |
116
|
1 |
|
} |
117
|
5 |
|
if (isset($params['smtpUser'])) { |
118
|
1 |
|
$this->setOutboundUser($params['smtpUser']); |
119
|
1 |
|
} |
120
|
5 |
|
if (isset($params['smtpPassword'])) { |
121
|
|
|
$this->setOutboundPassword($params['smtpPassword']); |
122
|
|
|
} |
123
|
5 |
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return array |
127
|
|
|
*/ |
128
|
3 |
|
public function toJson() { |
129
|
|
|
$result = [ |
130
|
3 |
|
'accountId' => $this->getId(), |
131
|
3 |
|
'name' => $this->getName(), |
132
|
3 |
|
'emailAddress' => $this->getEmail(), |
133
|
3 |
|
'imapHost' => $this->getInboundHost(), |
134
|
3 |
|
'imapPort' => $this->getInboundPort(), |
135
|
3 |
|
'imapUser' => $this->getInboundUser(), |
136
|
3 |
|
'imapSslMode' => $this->getInboundSslMode(), |
137
|
3 |
|
]; |
138
|
|
|
|
139
|
3 |
|
if (!is_null($this->getOutboundHost())) { |
140
|
3 |
|
$result['smtpHost'] = $this->getOutboundHost(); |
141
|
3 |
|
$result['smtpPort'] = $this->getOutboundPort(); |
142
|
3 |
|
$result['smtpUser'] = $this->getOutboundUser(); |
143
|
3 |
|
$result['smtpSslMode'] = $this->getOutboundSslMode(); |
144
|
3 |
|
} |
145
|
|
|
|
146
|
3 |
|
return $result; |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|