private function _addNs(Server_Account $a, $domainId) { $params = array('dns' => array()); if ($a->getNs1()) { $params['dns']['add_rec1'] = array('domain_id' => $domainId, 'type' => 'NS', 'host' => '', 'value' => $a->getNs1()); } if ($a->getNs2()) { $params['dns']['add_rec2'] = array('domain_id' => $domainId, 'type' => 'NS', 'host' => '', 'value' => $a->getNs2()); } if ($a->getNs3()) { $params['dns']['add_rec3'] = array('domain_id' => $domainId, 'type' => 'NS', 'host' => '', 'value' => $a->getNs3()); } if ($a->getNs4()) { $params['dns']['add_rec4'] = array('domain_id' => $domainId, 'type' => 'NS', 'host' => '', 'value' => $a->getNs4()); } if (empty($params['dns'])) { return true; } $oldNs = $this->_getNs($a, $domainId); $this->_removeDns($oldNs); $response = $this->_makeRequest($params); if (isset($response->system->status) && $response->system->status == 'error') { throw new Server_Exception('Plesk error: ' . $response->system->errcode . ' - ' . $response->system->errtext); } foreach ($response->dns->add_rec as $ns) { if (isset($ns->result->status) && $ns->result->status == 'error') { throw new Server_Exception('Plesk error: ' . $ns->result->errcode . ' - ' . $ns->result->errtext); } } return true; }
private function _modifyReseller(Server_Account $a) { if (!$this->_checkCommand('modify-reseller')) { throw new Server_Exception('Modify reseller command is only available in Virtualmin PRO version'); } $p = $a->getPackage(); $client = $a->getClient(); $params = array('name' => $a->getUsername(), 'pass' => $a->getPassword(), 'email' => $client->getEmail(), 'max-doms' => $p->getMaxDomains() == 'unlimited' ? 'UNLIMITED' : $p->getMaxDomains(), 'max-aliasdoms' => $p->getMaxDomains() == 'unlimited' ? 'UNLIMITED' : $p->getMaxDomains(), 'max-realdoms' => $p->getMaxDomains() == 'unlimited' ? 'UNLIMITED' : $p->getMaxDomains(), 'max-quota' => $p->getQuota() == 'unlimited' ? 'UNLIMITED' : (int) $p->getQuota() * 1024, 'max-mailboxes' => (int) $p->getMaxPop(), 'max-aliases' => (int) $p->getMaxDomains() ? $p->getMaxDomains() : 1, 'max-dbs' => $p->getMaxSql() == 'unlimited' ? 'UNLIMITED' : (int) $p->getMaxSql(), 'max-bw' => $p->getBandwidth() == 'unlimited' ? 'UNLIMITED' : (int) $p->getBandwidth() * 1024 * 1024, 'allow1' => 'dns', 'allow2' => 'web', 'allow3' => 'webmin', 'allow4' => 'dir', 'allow5' => 'virt', 'nameserver1' => $a->getNs1(), 'nameserver2' => $a->getNs2(), 'nameserver3' => $a->getNs3(), 'nameserver4' => $a->getNs4()); if ($p->getMaxPop()) { $params['allow6'] = 'mail'; } if ($p->getHasSsl()) { $params['allow7'] = 'ssl'; } if ($p->getMaxFtp() > 0) { $params['allow8'] = 'ftp'; } if ($p->getHasSpamFilter()) { $params['allow9'] = 'spam'; } if ($p->getMaxSql() > 0) { $params['allow10'] = 'mysql'; } $response = $this->_makeRequest('modify-reseller', $params); if (isset($response['status']) && $response['status'] == 'success') { return true; } else { throw new Server_Exception('Failed to create reseller\'s account'); } return false; }