function uc_cart_links_form in Ubercart 6.2
Same name and namespace in other branches
- 7.3 uc_cart_links/uc_cart_links.pages.inc \uc_cart_links_form()
Preprocess a cart link and confirm with the user if a destructive action is included.
See also
1 string reference to 'uc_cart_links_form'
- uc_cart_links_menu in uc_cart_links/
uc_cart_links.module - Implements hook_menu().
File
- uc_cart_links/
uc_cart_links.pages.inc, line 14 - Cart links menu items.
Code
function uc_cart_links_form($form_state, $arg1) {
// Fail if the link is restricted.
$data = variable_get('uc_cart_links_restrictions', '');
if (!empty($data)) {
$restrictions = explode("\n", variable_get('uc_cart_links_restrictions', ''));
$restrictions = array_map('trim', $restrictions);
if (!empty($restrictions) && !in_array($arg1, $restrictions)) {
$url = variable_get('uc_cart_links_invalid_page', '');
if (empty($url)) {
$url = '<front>';
}
unset($_REQUEST['destination']);
drupal_goto($url);
}
}
// Confirm with the user if the form contains a destructive action.
$items = uc_cart_get_contents();
if (variable_get('uc_cart_links_empty', TRUE) && !empty($items)) {
$actions = explode('-', urldecode($arg1));
foreach ($actions as $action) {
$action = drupal_substr($action, 0, 1);
if ($action == 'e' || $action == 'E') {
return confirm_form(array(), t('The current contents of your shopping cart will be lost. Are you sure you want to continue?'), variable_get('uc_cart_links_invalid_page', ''));
}
}
}
// No destructive actions, so process the link immediately.
uc_cart_links_process($arg1);
}