function uc_product_features in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_product/uc_product.module \uc_product_features()
- 7.3 uc_product/uc_product.admin.inc \uc_product_features()
Displays the product features tab on a product node edit form.
4 string references to 'uc_product_features'
- uc_file_feature_form_submit in uc_file/
uc_file.module - Submit handler for uc_file_feature_form().
- uc_product_menu in uc_product/
uc_product.module - Implements hook_menu().
- uc_product_update_6000 in uc_product/
uc_product.install - uc_roles_feature_form_submit in uc_roles/
uc_roles.module - Submission handler for uc_roles_feature_form().
File
- uc_product/
uc_product.admin.inc, line 393 - Product administration menu items.
Code
function uc_product_features($node) {
drupal_set_title(check_plain($node->title));
if (arg(4)) {
// First check to see if we're trying to remove a feature.
if (intval(arg(5)) > 0 && arg(6) == 'delete') {
$feature = uc_product_feature_load(intval(arg(5)), arg(4));
if (isset($feature)) {
// If the user confirmed the delete, process it!
if (isset($_POST['pf_delete']) && $_POST['pf_delete']) {
uc_product_feature_delete(intval(arg(5)));
drupal_set_message(t('The product feature has been deleted.'));
drupal_goto('node/' . arg(1) . '/edit/features');
}
// Show the confirmation form for deleting this feature.
$question = $node->title;
$description = t('Are you sure you wish to delete this %feature?', array(
'%feature' => uc_product_feature_data($feature['fid'], 'title'),
)) . '<div><b>' . t('Description') . ':</b><br />' . $feature['description'] . '</div><br />';
return drupal_get_form('confirm_form', $question, 'node/' . arg(1) . '/edit/features', $description, t('Delete'), t('Cancel'), 'pf_delete');
}
else {
drupal_set_message(t("That product feature doesn't exist."), 'error');
drupal_goto('node/' . arg(1) . '/edit/features');
}
}
// Handle adding or editing product features.
$func = uc_product_feature_data(arg(4), 'callback');
if (function_exists($func)) {
if (arg(5) == 'add') {
$output = drupal_get_form($func, $node, array());
}
elseif (intval(arg(5)) > 0) {
$feature = uc_product_feature_load(intval(arg(5)), arg(4));
if (isset($feature)) {
$output = drupal_get_form($func, $node, $feature);
}
}
}
else {
drupal_set_message(t('Error: Attempted to add a non-existent product feature type.'), 'error');
drupal_goto('node/' . $node->nid . '/edit/features');
}
if (empty($output)) {
drupal_set_message(t('Error: No form data was returned for that operation.'), 'error');
drupal_goto('node/' . $node->nid . '/edit/features');
}
return $output;
}
$header = array(
t('Type'),
t('Description'),
t('Operations'),
);
$features = uc_product_feature_load_multiple($node->nid);
if (empty($features)) {
$rows[] = array(
array(
'data' => t('No features found for this product.'),
'colspan' => 3,
),
);
}
else {
foreach ($features as $feature) {
$operations = array(
'edit' => array(
'title' => t('edit'),
'href' => 'node/' . $node->nid . '/edit/features/' . $feature->fid . '/' . $feature->pfid,
),
'delete' => array(
'title' => t('delete'),
'href' => 'node/' . $node->nid . '/edit/features/' . $feature->fid . '/' . $feature->pfid . '/delete',
),
);
$rows[] = array(
array(
'data' => uc_product_feature_data($feature->fid, 'title'),
),
array(
'data' => $feature->description,
),
theme('links', $operations, array(
'class' => 'links inline',
)),
);
}
}
$output = theme('table', $header, $rows, array(
'class' => 'uc-product-features',
)) . drupal_get_form('uc_product_feature_add_form');
return $output;
}