/** * Takes a product image id and makes it the base thumbnail image for it's product. * * @param ISC_ADMIN_REMOTE $remote */ public function remoteUpdateBaseThumbnail(ISC_ADMIN_REMOTE $remote) { $imageId = (int)$_POST['image']; $response = array(); try { $image = new ISC_PRODUCT_IMAGE($imageId); if ($image->getProductHash()) { if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Create_Product)) { throw new Exception(GetLang('Unauthorized')); } } else if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Products)) { throw new Exception(GetLang('Unauthorized')); } $image->setIsThumbnail(true); $image->saveToDatabase(false); $response[] = $remote->MakeXMLTag('success', GetLang('ProductImageBaseThumbnailUpdated'), true); } catch (Exception $exception) { // if necessary, capture specific exceptions to create friendly error messages, but, for the most part, the exceptions generated by ISC_PRODUCT_IMAGE are language based $response[] = $remote->MakeXMLTag('error', $exception->getMessage()); } $remote->SendXMLHeader(); $remote->SendXMLResponse($response); die(); }