55 *
66 */
77
8+
9+
810class 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 ' );
0 commit comments