Skip to content

Commit ca29622

Browse files
Merge pull request #397 from MikeAT/full-status-support
support all RFC5731 status fields from EPP schema
2 parents c28ecc6 + 3f541eb commit ca29622

File tree

4 files changed

+140
-8
lines changed

4 files changed

+140
-8
lines changed

Protocols/EPP/eppData/eppDomain.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,18 +361,40 @@ public function getPassword() {
361361

362362
/**
363363
*
364-
* @param string $status
364+
* @param string|eppStatus $status
365365
*/
366366
public function addStatus($status) {
367367
$this->statuses[] = $status;
368368
}
369369

370370
/**
371371
*
372+
* @param bool $fullobject
372373
* @return array
374+
*
373375
*/
374-
public function getStatuses() {
375-
return $this->statuses;
376+
public function getStatuses($fullobjects=false) {
377+
$return_statuses=[];
378+
379+
if ($fullobjects) { // return full eppStatus Objects
380+
foreach ($this->statuses as $status) {
381+
if ($status instanceof eppStatus) {
382+
$return_statuses[]=$status;
383+
} else {
384+
$return_statuses[]=new eppStatus($status);
385+
}
386+
}
387+
} else { // return just a list of statuses
388+
foreach ($this->statuses as $status) {
389+
if ($status instanceof eppStatus) {
390+
$return_statuses[]=$status->getStatusname();
391+
} else {
392+
$return_statuses[]=$status;
393+
}
394+
}
395+
}
396+
397+
return $return_statuses;
376398
}
377399

378400

Protocols/EPP/eppData/eppStatus.php

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
namespace Metaregistrar\EPP;
3+
4+
class eppStatus {
5+
#
6+
# These status values cannot be set, only viewed
7+
#
8+
const STATUS_OK = 'ok';
9+
const STATUS_SERVER_DELETE_PROHIBITED = 'serverDeleteProhibited';
10+
const STATUS_SERVER_UPDATE_PROHIBITED = 'serverUpdateProhibited';
11+
const STATUS_SERVER_RENEW_PROHIBITED = 'serverRenewProhibited';
12+
const STATUS_SERVER_TRANSFER_PROHIBITED = 'serverTransferProhibited';
13+
const STATUS_SERVER_HOLD = 'serverHold';
14+
const STATUS_INACTIVE = 'inactive';
15+
const STATUS_PENDING_CREATE = 'pendingCreate';
16+
const STATUS_PENDING_DELETE = 'pendingDelete';
17+
const STATUS_PENDING_TRANSFER = 'pendingTransfer';
18+
const STATUS_PENDING_UPDATE = 'pendingUpdate';
19+
const STATUS_PENDING_RENEW = 'pendingRenew';
20+
21+
#
22+
# These status values can be set
23+
#
24+
const STATUS_CLIENT_DELETE_PROHIBITED = 'clientDeleteProhibited';
25+
const STATUS_CLIENT_UPDATE_PROHIBITED = 'clientUpdateProhibited';
26+
const STATUS_CLIENT_RENEW_PROHIBITED = 'clientRenewProhibited';
27+
const STATUS_CLIENT_TRANSFER_PROHIBITED = 'clientTransferProhibited';
28+
const STATUS_CLIENT_HOLD = 'clientHold';
29+
30+
31+
32+
/**
33+
* Holds the status name
34+
* @var string
35+
*/
36+
private $statusname;
37+
38+
/**
39+
* Holds the language from the status
40+
* @var string
41+
*/
42+
private $language;
43+
44+
/**
45+
* Holds the status message
46+
* @var string
47+
*/
48+
private $message;
49+
50+
/**
51+
*
52+
* @param string $statusname
53+
* @param ?string $language
54+
* @param ?string $message
55+
*/
56+
public function __construct($statusname, $language = null, $message = null) {
57+
$this->setStatusname($statusname);
58+
if ($language) {
59+
$this->setLanguage($language);
60+
}
61+
if ($message) {
62+
$this->setMessage($message);
63+
}
64+
}
65+
66+
// getters
67+
public function getStatusname() {
68+
return $this->statusname;
69+
}
70+
71+
public function getLanguage() {
72+
return $this->language;
73+
}
74+
75+
public function getMessage() {
76+
return $this->message;
77+
}
78+
79+
80+
// setters
81+
public function setStatusname($statusname) {
82+
if (strlen($statusname) > 0) {
83+
$this->statusname = $statusname;
84+
} else {
85+
throw new eppException("Statusname cannot be empty on eppStatus object");
86+
}
87+
}
88+
89+
public function setLanguage($language) {
90+
$this->language = $language;
91+
}
92+
93+
public function setMessage($message) {
94+
$this->message = $message;
95+
}
96+
97+
}

Protocols/EPP/eppRequests/eppUpdateDomainRequest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function addDomainChanges($element, eppDomain $domain) {
8989
$this->addDomainContact($element, $contact->getContactHandle(), $contact->getContactType());
9090
}
9191
}
92-
$statuses = $domain->getStatuses();
92+
$statuses = $domain->getStatuses(true);
9393
if (is_array($statuses)) {
9494
foreach ($statuses as $status) {
9595
$this->addDomainStatus($element, $status);
@@ -114,11 +114,21 @@ protected function addDomainChanges($element, eppDomain $domain) {
114114
/**
115115
*
116116
* @param \domElement $element
117-
* @param string $status
117+
* @param string|eppStatus $status
118118
*/
119119
protected function addDomainStatus($element, $status) {
120120
$stat = $this->createElement('domain:status');
121-
$stat->setAttribute('s', $status);
121+
122+
if ($status instanceof eppStatus) {
123+
$stat = $this->createElement('domain:status',$status->getMessage());
124+
$stat->setAttribute('s', $status->getStatusname());
125+
if (!is_null($status->getLanguage())) {
126+
$stat->setAttribute('lang', $status->getLanguage());
127+
}
128+
129+
} else {
130+
$stat->setAttribute('s', $status);
131+
}
122132
$element->appendChild($stat);
123133
}
124134

Protocols/EPP/eppResponses/eppInfoDomainResponse.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ public function getDomainId() {
4949
public function getDomainStatuses() {
5050
$statuses = null;
5151
$xpath = $this->xPath();
52-
$result = $xpath->query('/epp:epp/epp:response/epp:resData/domain:infData/domain:status/@s');
52+
// $result = $xpath->query('/epp:epp/epp:response/epp:resData/domain:infData/domain:status/@s');
53+
$result = $xpath->query('/epp:epp/epp:response/epp:resData/domain:infData/domain:status');
5354
foreach ($result as $status) {
54-
$statuses[] = $status->nodeValue;
55+
$statuses[] = new eppStatus($status->getAttribute('s'),
56+
$status->getAttribute('lang'),
57+
$status->nodeValue);
5558
}
5659
return $statuses;
5760
}

0 commit comments

Comments
 (0)