Esempio n. 1
0
 /**
  * Update nameservers for domain
  * @access public
  * @param Domain $domain Domain
  * @param IChangelist $changelist nameservers changelist 
  * @return Domain
  */
 public function UpdateDomainNameservers(Domain $domain, IChangelist $changes)
 {
     if (!$changes->HasChanges()) {
         throw new Exception(_("No changes in nameserver list"));
     }
     $this->FireEvent('BeforeUpdateDomainNameservers', $domain, $changes);
     $this->FireEvent('BeforeUpdateDomain', $domain, $this->DBDomain->GetInitialState($domain));
     $added = $changes->GetAdded();
     foreach ($added as $ns) {
         try {
             if ($ns instanceof NameserverHost == false) {
                 $this->CreateNameserver($ns);
             }
         } catch (ObjectExistsException $e) {
             // Ignore errors
         } catch (NotImplementedException $e) {
             // Ignore errors
         }
     }
     $Resp = $this->RegModule->UpdateDomainNameservers($domain, $changes);
     $this->ValidateModuleResponse($Resp, 'UpdateDomainNameserversResponse');
     if ($Resp->IsFailed()) {
         Log::Log(sprintf('UpdateDomainNameservers failed. Registry error: %s', $Resp->ErrMsg), E_USER_ERROR);
         throw new RegistryException($Resp->ErrMsg, $Resp->Code);
     }
     if ($Resp->Result) {
         if ($Resp->Succeed()) {
             $domain->SetNameserverList($changes->GetList());
             $this->DBDomain->Save($domain);
             // db operation
             $this->FireEvent('DomainOperation', $domain, self::OP_UPDATE);
             $this->FireEvent('DomainUpdated', $domain);
         } else {
             if ($Resp->Pending()) {
                 $this->AddPendingOperation($domain, self::OP_UPDATE, $Resp->OperationId);
             }
         }
     } else {
         throw new RegistryException(_('Registry was unable to update nameservers'));
     }
     return $domain;
 }