/** * activate * Activate an order item * @param $orderItemId * @return true|false */ public static function activate($orderItemId) { Shineisp_Commons_Utilities::log(__METHOD__ . " - Activate Detail ID #" . $orderItemId); $orderItemId = intval($orderItemId); if ($orderItemId < 1) { // missing order item id from arguments return false; } // Get OrderItem $ordersItem = self::find($orderItemId); $ordersItem = $ordersItem->toArray(); $OrderItem = array_shift($ordersItem); if (!$OrderItem) { // order item not found return false; } // Get customerId related to this order $customerId = Orders::getCustomer($OrderItem['order_id']); /* * START ACTIVATIONS CODE */ $upgrade = Orders::isUpgrade($OrderItem['order_id']); $upgrade_uuid = false; if ($upgrade !== false) { $orderItem = OrdersItems::getDetail($upgrade); Shineisp_Commons_Utilities::logs(__METHOD__ . " - OITEM::" . print_r($orderItem, true)); $oldOrderId = $orderItem['order_id']; Orders::set_status($oldOrderId, Statuses::id("changed", "orders")); // Close the old order ::status changed OrdersItems::set_status($upgrade, Statuses::id("changed", "orders")); $upgrade_uuid = $orderItem['uuid']; // log Shineisp_Commons_Utilities::logs(__METHOD__ . " - Order changed from #" . $oldOrderId . " to #" . $OrderItem['order_id']); } if (empty($OrderItem['parameters'])) { Shineisp_Commons_Utilities::logs(__METHOD__ . " - Order items setup parameters empty"); return false; } // Is this an hosting? execute panel task // TODO: this should call an hook or an even bound to the panel if (isset($OrderItem['Products']) && isset($OrderItem['Products']['type']) && $OrderItem['Products']['type'] == 'hosting') { Shineisp_Commons_Utilities::logs(__METHOD__ . " Hosting task queued"); PanelsActions::AddTask($customerId, $OrderItem['detail_id'], "fullProfile", $OrderItem['parameters']); return true; } // Is this a domain? execute domain task if (isset($OrderItem['tld_id']) && intval($OrderItem['tld_id']) > 0) { $parameters = json_decode($OrderItem['parameters']); if (empty($parameters->domain)) { Shineisp_Commons_Utilities::logs(__METHOD__ . " Domain has been not set in the order detail #{$orderItemId}"); return false; } // Create the domain record $domain = Domains::Create($parameters->domain, intval($OrderItem['tld_id']), intval($customerId), $orderItemId); // Create the domain task if (!empty($parameters->domain) && !empty($parameters->action)) { $domains[] = array('domain' => $parameters->domain, 'action' => $parameters->action); $retval = DomainsTasks::AddTasks($domains); Shineisp_Commons_Utilities::logs(__METHOD__ . " Domain task queued"); } return $retval; } }
private static function CreateDomainTasks($OrderID) { // Check if the order contains domains if (is_numeric($OrderID)) { $domains = self::getDomainsFromOrder($OrderID); if (count($domains) > 0) { // Create the new domains for ($i = 0; $i < count($domains); $i++) { $domains[$i]['domain_id'] = Domains::Create($domains[$i]['domain'], $domains[$i]['tld_id'], $domains[$i]['customer_id'], $domains[$i]['orderitem_id']); } // Add the tasks in order to register or transfer them $retval = DomainsTasks::AddTasks($domains); if ($retval === true) { return true; } else { return $retval; } } } }