function flag_lists_ops_form_validate in Flag Lists 7
Same name and namespace in other branches
- 7.3 flag_lists.module \flag_lists_ops_form_validate()
1 call to flag_lists_ops_form_validate()
1 string reference to 'flag_lists_ops_form_validate'
- flag_lists_form_alter in ./
flag_lists.module - Implementation of hook_form_alter().
File
- ./
flag_lists.module, line 488 - The Flag Lists module.
Code
function flag_lists_ops_form_validate(&$form, &$form_state) {
global $user;
$error_count = 0;
// Check to see if an items are selected, if not fail right away.
if (!isset($_REQUEST['flag_lists_ops']) || empty($_REQUEST['flag_lists_ops'])) {
form_set_error('', t('No content selected.'));
$error_count++;
return $error_count;
}
switch ($form_state['values']['flag_lists_' . $form_state['flo_operation']]['operation']) {
case 'unflag':
$ops = $_REQUEST['flag_lists_ops'];
foreach ($ops as $key => $op) {
$ops[$key] = explode('-', $op);
if (empty($ops[$key][1]) || !($flag = flag_lists_get_flag($ops[$key][1]))) {
form_set_error('flag_lists][remove', t('Invalid options list selected to remove from.'));
$error_count++;
}
else {
if ($flag->uid != $user->uid) {
form_set_error('flag_lists][remove', t('You are only allowed to remove content from your own lists.'));
$error_count++;
}
}
}
break;
default:
if (empty($form_state['values']['flag_lists_' . $form_state['flo_operation']]['list'])) {
form_set_error('flag_lists][list', t('No list selected. Please select a list to add to.'));
$error_count++;
}
else {
if (!($flag = flag_lists_get_flag($form_state['values']['flag_lists_' . $form_state['flo_operation']]['list']))) {
form_set_error('flag_lists][list', t('Invalid list selected. Please select a list to add to.'));
$error_count++;
}
else {
if ($flag->uid != $user->uid) {
form_set_error('flag_lists][list', t('Invalid list selected. Please select a list to add to.'));
$error_count++;
}
}
}
break;
}
return $error_count;
}