-
Notifications
You must be signed in to change notification settings - Fork 7
/
net9FicoraEppUpdateContactRequest.php
81 lines (69 loc) · 3.08 KB
/
net9FicoraEppUpdateContactRequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace FicoraEpp;
use Metaregistrar\EPP\eppContact;
use Metaregistrar\EPP\eppUpdateContactRequest;
use Metaregistrar\EPP\ficoraEppContactPostalInfo;
class net9FicoraEppUpdateContactRequest extends eppUpdateContactRequest
{
private $ficoraIdentityType;
public function __construct(
$objectname,
int $ficoraIdentityType,
$addinfo = null,
$removeinfo = null,
$updateinfo = null,
$namespacesinroot = true
) {
$this->ficoraIdentityType = $ficoraIdentityType;
parent::__construct($objectname, $addinfo, $removeinfo, $updateinfo, $namespacesinroot);
$this->addFicoraExtension();
$this->addSessionId();
}
private function addFicoraExtension()
{
$this->contactobject->setAttribute('xmlns:contact', 'urn:ietf:params:xml:ns:contact-1.0');
}
/**
* @param string $contactid
* @param eppContact $addInfo
* @param eppContact $removeInfo
* @param eppContact $updateInfo
*/
public function updateContact($contactid, $addInfo, $removeInfo, $updateInfo)
{
parent::updateContact($contactid, $addInfo, $removeInfo, $updateInfo);
/** @var ficoraEppContactPostalInfo $postalInfo */
$postalInfo = $updateInfo->getPostalInfo(0);
$contactPostalInfo = $this->getElementsByTagName('contact:postalInfo')->item(0);
/**
* This information as of February 2021 is required by Traficom API by update queries for no reason (these
* fields are not allwed to be updated regardless)
*
* There is no Metaregistrar EPP fix yet, pull request after this one is validated
*/
if ($postalInfo->getFirstName() && $this->ficoraIdentityType === 0) {
$contactPostalInfo->appendChild($this->createElement('contact:firstname', $postalInfo->getFirstName()));
}
if ($postalInfo->getLastName() && $this->ficoraIdentityType === 0) {
$contactPostalInfo->appendChild($this->createElement('contact:lastname', $postalInfo->getLastName()));
}
if ($postalInfo->getIdentity() && $this->ficoraIdentityType === 0) {
$contactPostalInfo->appendChild($this->createElement('contact:identity', $postalInfo->getIdentity()));
}
if ($postalInfo->getRegisterNumber() && $this->ficoraIdentityType !== 0) {
$contactPostalInfo->appendChild($this->createElement('contact:registernumber',
$postalInfo->getRegisterNumber()));
}
$this->getElementsByTagName('contact:chg')->item(0)
->appendChild($this->createElement('contact:type', $this->ficoraIdentityType));
/**
* Quick fix: remove empty contact:org as this breaks Traficom API since February 2021
*
* This is fixed in newer versions of Metaregistrar EPP, but the newer versions have other issues that are hard
* to fix at current date
*/
if(!$postalInfo->getOrganisationName() && $org = $this->getElementsByTagName('contact:org')->item(0)) {
$org->parentNode->removeChild($org);
}
}
}