/** * * @param eppContact $contact * @return \domElement * @throws eppException */ public function setContact(eppContact $contact) { # # Object create structure # $this->setContactId($contact->generateContactId()); $this->setPostalInfo($contact->getPostalInfo(0)); $this->setVoice($contact->getVoice()); $this->setFax($contact->getFax()); $this->setEmail($contact->getEmail()); $this->setPassword($contact->getPassword()); $this->setDisclose($contact->getDisclose()); }
/** * * @param \DOMElement $element * @param eppContact $contact */ private function addContactChanges($element, eppContact $contact) { if ($contact->getPostalInfoLength() > 0) { $postal = $contact->getPostalInfo(0); $postalinfo = $this->createElement('contact:postalInfo'); if ($postal->getType() == eppContact::TYPE_AUTO) { // If all fields are ascii, type = int (international) else type = loc (localization) if (self::isAscii($postal->getName()) && self::isAscii($postal->getOrganisationName()) && self::isAscii($postal->getStreet(0))) { $postal->setType(eppContact::TYPE_INT); } else { $postal->setType(eppContact::TYPE_LOC); } } $postalinfo->setAttribute('type', $postal->getType()); if (!$postal->getName() == '') { $postalinfo->appendChild($this->createElement('contact:name', $postal->getName())); } if (!$postal->getOrganisationName() == '') { $postalinfo->appendChild($this->createElement('contact:org', $postal->getOrganisationName())); } if ($postal->getStreetCount() > 0 || strlen($postal->getCity()) || strlen($postal->getProvince()) || strlen($postal->getZipcode()) || strlen($postal->getCountrycode())) { $postaladdr = $this->createElement('contact:addr'); if (($count = $postal->getStreetCount()) > 0) { for ($i = 0; $i < $count; $i++) { $postaladdr->appendChild($this->createElement('contact:street', $postal->getStreet($i))); } } if (strlen($postal->getCity())) { $postaladdr->appendChild($this->createElement('contact:city', $postal->getCity())); } if (strlen($postal->getProvince())) { $postaladdr->appendChild($this->createElement('contact:sp', $postal->getProvince())); } if (strlen($postal->getZipcode())) { $postaladdr->appendChild($this->createElement('contact:pc', $postal->getZipcode())); } if (strlen($postal->getCountrycode())) { $postaladdr->appendChild($this->createElement('contact:cc', $postal->getCountrycode())); } $postalinfo->appendChild($postaladdr); } $element->appendChild($postalinfo); } if (strlen($contact->getVoice())) { $element->appendChild($this->createElement('contact:voice', $contact->getVoice())); } if (strlen($contact->getFax())) { $element->appendChild($this->createElement('contact:fax', $contact->getFax())); } if (strlen($contact->getEmail())) { $element->appendChild($this->createElement('contact:email', $contact->getEmail())); } if ($contact->getPassword()) { $authinfo = $this->createElement('contact:authInfo'); $authinfo->appendChild($this->createElement('contact:pw', $contact->getPassword())); $element->appendChild($authinfo); } if (!is_null($contact->getDisclose())) { $type = $contact->getType(); if ($type == $contact::TYPE_AUTO) { $type = $contact::TYPE_LOC; } $disclose = $this->createElement('contact:disclose'); $disclose->setAttribute('flag', $contact->getDisclose()); $name = $this->createElement('contact:name'); if ($contact->getDisclose() == 1) { $name->setAttribute('type', $type); } $disclose->appendChild($name); $org = $this->createElement('contact:org'); if ($contact->getDisclose() == 1) { $org->setAttribute('type', $type); } $disclose->appendChild($org); $addr = $this->createElement('contact:addr'); if ($contact->getDisclose() == 1) { $addr->setAttribute('type', $type); } $disclose->appendChild($addr); $disclose->appendChild($this->createElement('contact:voice')); $disclose->appendChild($this->createElement('contact:email')); $element->appendChild($disclose); } }
/** * * @param eppContact $contact * @return \domElement */ public function setContact(eppContact $contact) { # # Object create structure # $create = $this->createElement('create'); $this->contactobject = $this->createElement('contact:create'); $this->contactobject->appendChild($this->createElement('contact:id', $contact->generateContactId())); $postalinfo = $this->createElement('contact:postalInfo'); $postal = $contact->getPostalInfo(0); if (!$postal instanceof eppContactPostalInfo) { throw new eppException('PostalInfo must be filled on eppCreateContact request'); } if ($postal->getType() == eppContact::TYPE_AUTO) { // If all fields are ascii, type = int (international) else type = loc (localization) if ($this->isAscii($postal->getName()) && $this->isAscii($postal->getOrganisationName()) && $this->isAscii($postal->getStreet(0))) { $postal->setType(eppContact::TYPE_INT); } else { $postal->setType(eppContact::TYPE_LOC); } } $postalinfo->setAttribute('type', $postal->getType()); $postalinfo->appendChild($this->createElement('contact:name', $postal->getName())); if ($postal->getOrganisationName()) { $postalinfo->appendChild($this->createElement('contact:org', $postal->getOrganisationName())); } $postaladdr = $this->createElement('contact:addr'); $count = $postal->getStreetCount(); for ($i = 0; $i < $count; $i++) { $postaladdr->appendChild($this->createElement('contact:street', $postal->getStreet($i))); } $postaladdr->appendChild($this->createElement('contact:city', $postal->getCity())); if ($postal->getProvince()) { $postaladdr->appendChild($this->createElement('contact:sp', $postal->getProvince())); } $postaladdr->appendChild($this->createElement('contact:pc', $postal->getZipcode())); $postaladdr->appendChild($this->createElement('contact:cc', $postal->getCountrycode())); $postalinfo->appendChild($postaladdr); $this->contactobject->appendChild($postalinfo); $this->contactobject->appendChild($this->createElement('contact:voice', $contact->getVoice())); if ($contact->getFax()) { $this->contactobject->appendChild($this->createElement('contact:fax', $contact->getFax())); } $this->contactobject->appendChild($this->createElement('contact:email', $contact->getEmail())); if (!is_null($contact->getPassword())) { $authinfo = $this->createElement('contact:authInfo'); $authinfo->appendChild($this->createElement('contact:pw', $contact->getPassword())); $this->contactobject->appendChild($authinfo); } if (!is_null($contact->getDisclose())) { $disclose = $this->createElement('contact:disclose'); $disclose->setAttribute('flag', $contact->getDisclose()); $name = $this->createElement('contact:name'); if ($contact->getDisclose() == 1) { $name->setAttribute('type', eppContact::TYPE_LOC); } $disclose->appendChild($name); $org = $this->createElement('contact:org'); if ($contact->getDisclose() == 1) { $org->setAttribute('type', eppContact::TYPE_LOC); } $disclose->appendChild($org); $addr = $this->createElement('contact:addr'); if ($contact->getDisclose() == 1) { $addr->setAttribute('type', eppContact::TYPE_LOC); } $disclose->appendChild($addr); $disclose->appendChild($this->createElement('contact:voice')); $disclose->appendChild($this->createElement('contact:email')); $this->contactobject->appendChild($disclose); } $create->appendChild($this->contactobject); $this->getCommand()->appendChild($create); }