|
1
|
|
|
<?php |
|
2
|
|
|
// Copyright 1999-2016. Parallels IP Holdings GmbH. |
|
3
|
|
|
|
|
4
|
|
|
namespace PleskX\Api\Operator; |
|
5
|
|
|
use PleskX\Api\Struct\Mail as Struct; |
|
6
|
|
|
|
|
7
|
|
|
class Mail extends \PleskX\Api\Operator |
|
8
|
|
|
{ |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @param string $name |
|
12
|
|
|
* @param integer $siteId |
|
13
|
|
|
* @param boolean $mailbox |
|
14
|
|
|
* @param string $password |
|
15
|
|
|
* @return Struct\Info |
|
16
|
|
|
*/ |
|
17
|
|
|
public function create($name, $siteId, $mailbox = false, $password = '') |
|
18
|
|
|
{ |
|
19
|
|
|
$packet = $this->_client->getPacket(); |
|
20
|
|
|
$info = $packet->addChild($this->_wrapperTag)->addChild('create'); |
|
21
|
|
|
|
|
22
|
|
|
$filter = $info->addChild('filter'); |
|
23
|
|
|
$filter->addChild('site-id', $siteId); |
|
24
|
|
|
$mailname = $filter->addChild('mailname'); |
|
25
|
|
|
$mailname->addChild('name', $name); |
|
26
|
|
|
if ($mailbox) { |
|
27
|
|
|
$mailname->addChild('mailbox')->addChild('enabled', 'true'); |
|
28
|
|
|
} |
|
29
|
|
|
if (!empty($password)) { |
|
30
|
|
|
$mailname->addChild('password')->addChild('value', $password); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
$response = $this->_client->request($packet); |
|
34
|
|
|
return new Struct\Info($response->mailname); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param string $field |
|
39
|
|
|
* @param integer|string $value |
|
40
|
|
|
* @param integer $siteId |
|
41
|
|
|
* @return bool |
|
42
|
|
|
*/ |
|
43
|
|
|
public function delete($field, $value, $siteId) |
|
44
|
|
|
{ |
|
45
|
|
|
$packet = $this->_client->getPacket(); |
|
46
|
|
|
$filter = $packet->addChild($this->_wrapperTag)->addChild('remove')->addChild('filter'); |
|
47
|
|
|
$filter->addChild('site-id', $siteId); |
|
48
|
|
|
$filter->addChild($field, $value); |
|
49
|
|
|
$response = $this->_client->request($packet); |
|
50
|
|
|
return 'ok' === (string)$response->status; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|