/** * Takes a product image id and description and updates the record in the database accordingly * * @param ISC_ADMIN_REMOTE $remote */ public function remoteUpdateImageDescription(ISC_ADMIN_REMOTE $remote) { $imageId = (int)$_POST['image']; $description = trim(@$_POST['description']); $response = array(); try { $image = new ISC_PRODUCT_IMAGE(); 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->loadFromDatabase($imageId); $image->setDescription($description); $image->saveToDatabase(false); $response[] = $remote->MakeXMLTag('success', GetLang('ProductImageDescriptionUpdated'), 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(), true); } $remote->SendXMLHeader(); $remote->SendXMLResponse($response); die(); }