function uc_product_feature_save in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_product/uc_product.module \uc_product_feature_save()
- 5 uc_product/uc_product.module \uc_product_feature_save()
- 6.2 uc_product/uc_product.module \uc_product_feature_save()
Saves a product feature to a product node.
Parameters
$data: An array consisting of the following keys:
- pfid: (optional) When editing an existing product feature, the numeric ID of the feature.
- nid: The numeric ID of the product node.
- fid: The string ID of the feature type.
- description: The string describing the feature for the overview table.
2 calls to uc_product_feature_save()
- uc_file_feature_form_submit in uc_file/
uc_file.module - Form submission handler for uc_file_feature_form().
- uc_roles_feature_form_submit in uc_roles/
uc_roles.module - Submission handler for uc_roles_feature_form().
File
- uc_product/
uc_product.module, line 1607 - The product module for Ubercart.
Code
function uc_product_feature_save(&$data) {
if (empty($data['nid']) && arg(0) == 'node' && intval(arg(1)) > 0) {
$data['nid'] = intval(arg(1));
}
if (empty($data['pfid'])) {
if (arg(0) == 'node' && arg(3) == 'features' && intval(arg(5)) > 0) {
$data['pfid'] = intval(arg(5));
}
}
// First attempt to update an existing row.
$result = drupal_write_record('uc_product_features', $data, !empty($data['pfid']) ? 'pfid' : array());
// Otherwise insert this feature as a new row.
if ($result == SAVED_NEW) {
drupal_set_message(t('The product feature has been added.'));
}
elseif ($result == SAVED_UPDATED) {
drupal_set_message(t('The product feature has been updated.'));
}
else {
drupal_set_message(t('The product feature was unable to be saved.'));
}
return 'node/' . $data['nid'] . '/edit/features';
}