Example #1
0
 private function doDomainTask($task)
 {
     if (!isset($task['Domains']) || !isset($task['Domains']['Customers']) || !isset($task['Domains']['Customers']['customer_id'])) {
         PanelsActions::UpdateTaskLog($task['action_id'], $this->translations->translate('customer_id not found'));
     }
     $customer_id = intval($task['Domains']['Customers']['customer_id']);
     $ISP = Isp::getByCustomerId($customer_id);
     if (!$ISP || !isset($ISP['isp_id']) || !is_numeric($ISP['isp_id'])) {
         PanelsActions::UpdateTaskLog($task['action_id'], $this->translations->translate('isp_id not found'));
         return false;
     }
     try {
         // Getting domains details
         $domain = Domains::find($task['domain_id'], null, true);
         if (!empty($domain[0])) {
             $domain_name = $domain[0]['domain'] . "." . $domain[0]['tld'];
             // Get the associated registrar for the domain selected
             $registrar = Registrars::getRegistrarId($task['registrars_id']);
             if (!empty($registrar['class'])) {
                 // Create the class registrar object
                 $class = $registrar['class'];
                 $regclass = new $class();
                 $action = $task['action'];
                 // Check if the task is REGISTER or TRANSFER the domain name
                 if ($action == "registerDomain") {
                     $regclass->registerDomain($task['domain_id']);
                     // Set the DNS ZONES
                     DomainsTasks::AddTask($domain_name, "setDomainHosts");
                     // Update the domain information
                     DomainsTasks::AddTask($domain_name, "updateDomain");
                 } elseif ($action == "transferDomain") {
                     $regclass->transferDomain($task['domain_id']);
                 } elseif ($action == "renewDomain") {
                     $regclass->renewDomain($task['domain_id']);
                     // Update the domain information
                     DomainsTasks::AddTask($domain_name, "updateDomain");
                 } elseif ($action == "lockDomain") {
                     $regclass->lockDomain($task['domain_id']);
                 } elseif ($action == "unlockDomain") {
                     $regclass->unlockDomain($task['domain_id']);
                     // Update the domain information
                     DomainsTasks::AddTask($domain_name, "updateDomain");
                 } elseif ($action == "setNameServers") {
                     $regclass->setNameServers($task['domain_id']);
                 } elseif ($action == "setDomainHosts") {
                     $regclass->setDomainHosts($task['domain_id']);
                 } else {
                     $regclass->{$action}($task['domain_id']);
                 }
                 // Update the log description of the task
                 DomainsTasks::UpdateTaskLog($task['task_id'], $this->translations->translate("Your request has been executed."));
                 // Update the status of the task
                 DomainsTasks::UpdateTaskStatus($task['task_id'], Statuses::id('complete', 'domains_tasks'));
                 // Set the task as "Complete"
                 // Increment the task counter number
                 DomainsTasks::UpdateTaskCounter($task['task_id']);
                 // Set the status as Active
                 Domains::setStatus($task['domain_id'], Statuses::id('active', 'domains_tasks'));
             }
         }
     } catch (Exception $e) {
         DomainsTasks::UpdateTaskLog($task['task_id'], $this->translations->translate($e->getMessage()));
         Shineisp_Commons_Utilities::SendEmail($ISP['email'], $ISP['email'], null, "Task error message: " . $task['Domains']['domain'] . "." . $task['Domains']['tld'], $e->getMessage());
         Shineisp_Commons_Utilities::logs("Task error message: " . $task['Domains']['domain'] . "." . $task['Domains']['tld'] . ":" . $e->getMessage(), "tasks.log");
     }
     return true;
 }