Skip to content

Commit 7030608

Browse files
Merge pull request #7 from exonet/upstream-sync/7827728
Sync with upstream metaregistrar/php-epp-client@7827728
2 parents 8a2f38c + 7827728 commit 7030608

5 files changed

Lines changed: 60 additions & 21 deletions

File tree

Protocols/EPP/eppExtensions/org-1.0/eppRequests/orgEppCreateRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
class orgEppCreateRequest extends eppCreateRequest {
3939
private \DOMElement|false $createobject;
40+
CONST TYPE_RESELLER = 'reseller';
4041

4142
/**
4243
* @param eppContact $createinfo

Protocols/EPP/eppExtensions/org-1.0/eppRequests/orgEppUpdateRequest.php

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,30 @@
55
*
66
*/
77

8+
9+
810
class orgEppUpdateRequest extends eppRequest {
911
private \DOMElement|false $updateobject;
1012

13+
/**
14+
* @param string $handle
15+
* @param $addinfo
16+
* @param $removeinfo
17+
* @param $updateinfo
18+
* @param $namespacesinroot
19+
* @param $usecdata
20+
* @throws \DOMException
21+
*
22+
* Update reseller information
23+
* $updateinfo allows updating of company and address data
24+
* $addinfo and $removeinfo allows adding and removing contact statuses and linked contact objects
25+
*/
1126
function __construct(string $handle, $addinfo = null, $removeinfo = null, $updateinfo = null, $namespacesinroot = true, $usecdata = true) {
1227
$this->setNamespacesinroot($namespacesinroot);
1328
parent::__construct();
1429
$this->setUseCdata($usecdata);
1530
$update = $this->createElement('update');
1631
$this->updateobject = $this->createElement('org:update');
17-
//$this->setContact($updateinfo, $type);
1832
$update->appendChild($this->updateobject);
1933
$this->getCommand()->appendChild($update);
2034
$this->updateContact($handle, $addinfo, $removeinfo, $updateinfo);
@@ -23,25 +37,27 @@ function __construct(string $handle, $addinfo = null, $removeinfo = null, $updat
2337

2438
public function updateContact($handle, $addInfo, $removeInfo, $updateInfo) {
2539
$this->updateobject->appendChild($this->createElement('org:id', $handle));
26-
if ($updateInfo instanceof eppContact) {
27-
$chgcmd = $this->createElement('org:chg');
28-
$this->addContactChanges($chgcmd, $updateInfo);
29-
if ($chgcmd->hasChildNodes()) {
30-
$this->updateobject->appendChild($chgcmd);
40+
if ($addInfo instanceof eppContact) {
41+
$addcmd = $this->createElement('org:add');
42+
$this->addContactStatus($addcmd, $addInfo);
43+
$this->addContactHandles($addcmd, $addInfo);
44+
if ($addcmd->hasChildNodes()) {
45+
$this->updateobject->appendChild($addcmd);
3146
}
3247
}
3348
if ($removeInfo instanceof eppContact) {
3449
$remcmd = $this->createElement('org:rem');
3550
$this->addContactStatus($remcmd, $removeInfo);
51+
$this->addContactHandles($remcmd, $removeInfo);
3652
if ($remcmd->hasChildNodes()) {
3753
$this->updateobject->appendChild($remcmd);
3854
}
3955
}
40-
if ($addInfo instanceof eppContact) {
41-
$addcmd = $this->createElement('org:add');
42-
$this->addContactStatus($addcmd, $addInfo);
43-
if ($addcmd->hasChildNodes()) {
44-
$this->updateobject->appendChild($addcmd);
56+
if ($updateInfo instanceof eppContact) {
57+
$chgcmd = $this->createElement('org:chg');
58+
$this->addContactChanges($chgcmd, $updateInfo);
59+
if ($chgcmd->hasChildNodes()) {
60+
$this->updateobject->appendChild($chgcmd);
4561
}
4662
}
4763
}
@@ -57,6 +73,16 @@ private function addContactStatus(\DOMElement $element, eppContact $contact) {
5773
}
5874
}
5975

76+
private function addContactHandles(\DOMElement $element, eppContact $contact) {
77+
if (is_string($contact->getId())) {
78+
$contactadd = $this->createElement('org:contact',$contact->getId());
79+
if (is_string($contact->getType())) {
80+
$contactadd->setAttribute('type',$contact->getType());
81+
}
82+
$element->appendChild($contactadd);
83+
}
84+
}
85+
6086
private function addContactChanges($element, eppContact $contact) {
6187
if ($contact->getPostalInfoLength() > 0) {
6288
$postal = $contact->getPostalInfo(0);
@@ -70,13 +96,11 @@ private function addContactChanges($element, eppContact $contact) {
7096
}
7197
}
7298
$postalinfo->setAttribute('type', $postal->getType());
73-
// Mandatory field
74-
if (is_string($postal->getName()) && strlen($postal->getName()) > 0) {
75-
$postalinfo->appendChild($this->createElement('org:name', $postal->getName()));
76-
}
7799
// Optional field
78100
if (!is_null($postal->getOrganisationName())) {
79-
$postalinfo->appendChild($this->createElement('org:org', $postal->getOrganisationName()));
101+
$postalinfo->appendChild($this->createElement('org:name', $postal->getOrganisationName()));
102+
} else {
103+
$postalinfo->appendChild($this->createElement('org:name', $postal->getName()));
80104
}
81105
if ((($postal->getStreetCount()) > 0) || strlen($postal->getCity()) || strlen($postal->getProvince()) || strlen($postal->getZipcode()) || strlen($postal->getCountrycode())) {
82106
$postaladdr = $this->createElement('org:addr');

Protocols/EPP/eppExtensions/org-1.0/eppResponses/orgEppInfoResponse.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function getOrgPostcode(): string {
7979
return $this->queryPath('/epp:epp/epp:response/epp:resData/org:infData/org:postalInfo/org:addr/org:pc');
8080
}
8181

82-
function getOrgState(): string {
82+
function getOrgState(): ?string {
8383
return $this->queryPath('/epp:epp/epp:response/epp:resData/org:infData/org:postalInfo/org:addr/org:sp');
8484
}
8585

@@ -91,15 +91,15 @@ function getOrgPhone(): string {
9191
return $this->queryPath('/epp:epp/epp:response/epp:resData/org:infData/org:voice');
9292
}
9393

94-
function getOrgFax(): string {
94+
function getOrgFax(): ?string {
9595
return $this->queryPath('/epp:epp/epp:response/epp:resData/org:infData/org:fax');
9696
}
9797

9898
function getOrgEmail(): string {
9999
return $this->queryPath('/epp:epp/epp:response/epp:resData/org:infData/org:email');
100100
}
101101

102-
function getOrgUrl(): string {
102+
function getOrgUrl(): ?string {
103103
return $this->queryPath('/epp:epp/epp:response/epp:resData/org:infData/org:url');
104104
}
105105

@@ -110,6 +110,21 @@ function getOrgUpdateDate(): string {
110110
return $this->queryPath('/epp:epp/epp:response/epp:resData/org:infData/org:upDate');
111111
}
112112

113+
function getOrgContacts(): array {
114+
$result = [];
115+
$xpath = $this->xPath();
116+
$data = $xpath->query('/epp:epp/epp:response/epp:resData/org:infData/org:contact');
117+
if ($data->length >0) {
118+
if ($data->length >0) {
119+
foreach ($data as $contact) {
120+
/* @var $contact \DOMElement */
121+
$result[$contact->getAttribute('type')][] = $contact->nodeValue;
122+
}
123+
}
124+
}
125+
return $result;
126+
}
127+
113128
public function getOrgPostalInfo() {
114129
$xpath = $this->xPath();
115130
$result = $xpath->query('/epp:epp/epp:response/epp:resData/org:infData/org:postalInfo');

Protocols/EPP/eppExtensions/org-1.0/includes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$this->addCommandResponse('Metaregistrar\EPP\orgEppCreateRequest', 'Metaregistrar\EPP\orgEppCreateResponse');
1919

2020
include_once(dirname(__FILE__) . '/eppRequests/orgEppUpdateRequest.php');
21-
$this->addCommandResponse('Metaregistrar\EPP\orgEppUpdateRequest', 'Metaregistrar\EPP\orgEppResponse');
21+
$this->addCommandResponse('Metaregistrar\EPP\orgEppUpdateRequest', 'Metaregistrar\EPP\eppUpdateResponse');
2222

2323
include_once(dirname(__FILE__) . '/eppRequests/orgEppDeleteRequest.php');
2424
$this->addCommandResponse('Metaregistrar\EPP\orgEppDeleteRequest', 'Metaregistrar\EPP\eppDeleteResponse');

Protocols/EPP/eppExtensions/rgp-1.0/eppRequests/eppRgpRestoreRequest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public function __construct(eppDomain $objectname, $addinfo = null, $removeinfo
2525
}
2626
parent::__construct($domainname, null, null, $updateinfo);
2727
$rgp = $this->createElement('rgp:update');
28-
//$this->addExtension('xmlns:rgp', 'urn:ietf:params:xml:ns:rgp-1.0');
2928
$restore = $this->createElement('rgp:restore');
3029
$restore->setAttribute('op', 'request');
3130
$rgp->appendChild($restore);

0 commit comments

Comments
 (0)