function uc_product_store_status in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_product/uc_product.module \uc_product_store_status()
Display the status of the product image handlers.
See also
uc_product_image_defaults
File
- uc_product/
uc_product.module, line 1404 - The product module for Ubercart.
Code
function uc_product_store_status() {
if (!module_exists('imagefield') || !module_exists('imagecache')) {
$description = t('To automatically configure core image support, <a href="!url">enable</a> the <a href="http://drupal.org/project/cck">Content</a>, <a href="http://drupal.org/project/imagefield">CCK Image field</a>, and <a href="http://drupal.org/project/imagecache">Imagecache</a> modules. This action is not required.', array(
'!url' => url('admin/build/modules'),
));
}
else {
$result = db_query("SELECT field_name, type FROM {node_field} WHERE field_name = 'field_image_cache' AND type = 'image'");
$field_check = (bool) db_num_rows($result);
$result = db_query("SELECT field_name, type_name FROM {node_field_instance} WHERE field_name = 'field_image_cache' AND type_name = 'product'");
$product_field_check = (bool) db_num_rows($result);
$presets = array(
'product',
'product_list',
'uc_thumbnail',
);
if (module_exists('uc_catalog')) {
$presets[] = 'uc_category';
}
if (module_exists('uc_cart')) {
$presets[] = 'cart';
}
if (module_exists('uc_manufacturer')) {
$presets[] = 'manufacturer';
}
$result = db_query("SELECT presetid, presetname FROM {imagecache_preset} WHERE presetname IN ('" . implode("','", $presets) . "')");
$preset_check = db_num_rows($result) == count($presets);
$actions = array();
$good_presets = array();
while ($preset_id = db_fetch_array($result)) {
$good_presets[] = $preset_id['presetname'];
$actions[$preset_id['presetid']] = db_result(db_query("SELECT actionid FROM {imagecache_action} WHERE presetid = %d", $preset_id['presetid']));
}
$missing_presets = array_diff($presets, $good_presets);
$action_check = count(array_filter($actions)) == count($presets);
if ($field_check && $product_field_check && $preset_check && $action_check) {
$description = t('Product image support has been automatically configured by Ubercart.');
}
else {
$checks = ($field_check << 3) + ($product_field_check << 2) + ($preset_check << 1) + $action_check;
$description = t('<a href="!url">Click here</a> to automatically configure the following items for core image support:', array(
'!url' => url('admin/store/settings/products/defaults/' . $checks),
));
if (!$field_check) {
$items[] = t('The Image field has not been created for CCK.');
}
if (!$product_field_check) {
$items[] = t("The Image field has not been attached to Product nodes.");
}
if (!$preset_check) {
$items[] = t('The expected Imagecache presets ("!presets") have not been created.', array(
'!presets' => implode('", "', $missing_presets),
));
}
if (!$action_check) {
$items[] = t('The Imagecache presets do not contain actions to perform on images. Images may be displayed in their original formats.');
}
$description .= theme('item_list', $items) . t('(This action is not required and should not be taken if you do not need images or have implemented your own image support.)');
}
}
return array(
array(
'status' => 'ok',
'title' => t('Images'),
'desc' => $description,
),
);
}