private function restoreOrderActionHandler ($orderId) { if (!$this->auth->HasPermission(AUTH_Undelete_Orders)) { return array( 'success' => false, ); } $orderId = (int)$orderId; if (!$orderId) { return array( 'success' => false, ); } $order = GetOrder($orderId, false, false, true); if (!$order) { return array( 'success' => false, ); } $entity = new ISC_ENTITY_ORDER; if (!$entity->undelete($orderId)) { return array( 'success' => false, ); } FlashMessage(GetLang('iphoneRestoreOrderSuccess', array( 'orderId' => $orderId, )), MSG_SUCCESS); return array( 'success' => true, ); }
protected function UndeleteOrders () { // final permission checks $canManage = $this->auth->HasPermission(AUTH_Manage_Orders); $canUndelete = $this->auth->HasPermission(AUTH_Undelete_Orders); if (!$canUndelete) { if ($canManage) { $this->ManageOrders(GetLang('Unauthorized'), MSG_ERROR); return; } $this->engine->DoHomePage(GetLang('Unauthorized'), MSG_ERROR); return; } // input validation $orderIds = array(); if (isset($_POST['orders']) && is_array($_POST['orders']) && !empty($_POST['orders'])) { $orderIds = array_map('intval', $_POST['orders']); } if (empty($orderIds)) { if ($canManage) { $this->ManageOrders(); return; } $this->engine->DoHomePage(); return; } // do the order delete $GLOBALS['ISC_CLASS_LOG']->LogAdminAction(count($orderIds)); $entity = new ISC_ENTITY_ORDER; foreach ($orderIds as $orderId) { if (!$entity->undelete($orderId)) { if ($canManage) { $this->ManageOrders($entity->getError(), MSG_ERROR); return; } $this->engine->DoHomePage($entity->getError(), MSG_ERROR); return; } } if ($canManage) { $this->ManageOrders(GetLang('OrdersUndeletedSuccessfully'), MSG_SUCCESS); return; } $this->engine->DoHomePage(GetLang('OrdersUndeletedSuccessfully'), MSG_SUCCESS); }