/** * Validates that a product can be deleted * * @param array $d The input vars * @return boolean Validation sucessful? */ function validate_delete( $product_id, &$d ) { global $vmLogger, $VM_LANG; require_once(CLASSPATH . 'imageTools.class.php' ); /* Check that ps_vendor_id and product_id match if (!$this->check_vendor($d)) { $d["error"] = "ERROR: Cannot delete product. Wrong product or vendor." ; return false; }*/ if (empty($product_id)) { $vmLogger->err( $VM_LANG->_('VM_PRODUCT_SPECIFY_DELETE',false) ); return false; } /* Get the image filenames from the database */ $db = new ps_DB; $q = "SELECT product_thumb_image,product_full_image "; $q .= "FROM #__{vm}_product "; $q .= "WHERE product_id='$product_id'"; $db->setQuery($q); $db->query(); $db->next_record(); /* Prepare product_thumb_image for Deleting */ if( !stristr( $db->f("product_thumb_image"), "http") ) { $_REQUEST["product_thumb_image_curr"] = $db->f("product_thumb_image"); $d["product_thumb_image_action"] = "delete"; if (!vmImageTools::validate_image($d,"product_thumb_image","product")) { $vmLogger->err( $VM_LANG->_('VM_PRODUCT_IMGDEL_FAILED',false) ); return false; } } /* Prepare product_full_image for Deleting */ if( !stristr( $db->f("product_full_image"), "http") ) { $_REQUEST["product_full_image_curr"] = $db->f("product_full_image"); $d["product_full_image_action"] = "delete"; if (!vmImageTools::validate_image($d,"product_full_image","product")) { return false; } } return true; }