1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Tahaa Karim <[email protected]> |
4
|
|
|
* |
5
|
|
|
* ownCloud - Mail |
6
|
|
|
* |
7
|
|
|
* This code is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
9
|
|
|
* as published by the Free Software Foundation. |
10
|
|
|
* |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU Affero General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
17
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
18
|
|
|
* |
19
|
|
|
*/ |
20
|
|
|
namespace OCA\Mail\Service; |
21
|
|
|
|
22
|
|
|
use Exception; |
23
|
|
|
use OCA\Mail\Db\Alias; |
24
|
|
|
use OCA\Mail\Db\AliasMapper; |
25
|
|
|
|
26
|
|
|
class AliasesService { |
27
|
|
|
|
28
|
|
|
/** @var \OCA\Mail\Db\AliasMapper */ |
29
|
|
|
private $mapper; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param AliasMapper $mapper |
33
|
|
|
*/ |
34
|
|
|
public function __construct(AliasMapper $mapper) { |
35
|
|
|
$this->mapper = $mapper; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function findAll($accountId) { |
39
|
|
|
return $this->mapper->findAll($accountId); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function create($accountId, $alias_name) { |
43
|
|
|
$alias = new Alias(); |
44
|
|
|
$alias->setAccountId($accountId); |
45
|
|
|
$alias->setAlias($alias_name); |
46
|
|
|
return $this->mapper->insert($alias); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function delete($id) { |
50
|
|
|
$alias = $this->mapper->find($id); |
51
|
|
|
$this->mapper->delete($alias); |
52
|
|
|
return $alias; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function update($id, $alias_name) { |
56
|
|
|
$alias = $this->mapper->find($id); |
57
|
|
|
$alias->setAlias($alias_name); |
58
|
|
|
return $this->mapper->update($alias); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|