php shopping cart
free shopping cart   shopping cart software

Free Shopping Cart PHP Software

afc_check_if_image_is_used_elsewhere

Back to Functions List
This Function Has Been Available Since:
(AFCommerce v 2.1,     Functions v 1.1)

Checks to see if the same image is being used by another product, manufacture or category.

Description

bool = afc_check_if_image_is_used_elsewhere (imagename)

This function checks to see if the image being passed is still going to be needed by another product or category if we delete the product or category that we are currently deleting. I built this function because whenever the same image was used more than once, and a store owner deleted one of the products or categories using the image, the image would be deleted and would not be available by the other products or categories that still needed it. So, this function should be called anytime you delete an image to make sure its not needed by anything else. Version 2 now allows multiple images for each product, and manufactures are assigned images now too, so this function was necessary to stop required images from being deleted.

Please note: I still believe using the same image twice is a bad idea, before you start adding images, you should make some sort of naming system for your images. This function does work, so you won't lose the images that are used multiple times, but I think to be properly organized with all aspects of your store is truly important. So you should name product images so they can easily be identified by you without needing your admin area, so you can simply scan your file system, and find them. This is why all images go inside of one directory instead of there being sub directories for certain categories, manufactures, etc. This way, whenever I build new features, its makes the scripts easier to write, making them more powerful and flexible.


Parameters

imagename (string) - file path to the image, including the image name. So for scripts in the main AFCommerce directory, "images/imagename.jpg", and in the admin area, "../images/imagename.jpg". You should always use relative paths, they are much more flexible.

Return Values

Returns true if the image IS being used somewhere else, and false if the image is NOT being used.

Open Source: Yes

Paul's Examples


if (!afc_check_if_image_is_used_elsewhere ($oldpic)) {
unlink ("../images/$oldpic"); }


Back to Functions List




afc_check_if_image_is_used_elsewhere

There are currently no posts for this topic.











AFCommerce Documentation


High End Website DevelopmentCompletely Free
Dating Service
Copyright 2004 - 2006
www.afcommerce.com
AFCommerce Website
And Cart Builder