function flag_lists_ops_form_validate in Flag Lists 7.3
Same name and namespace in other branches
- 7 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 509 - 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':
$user_flag_lists = flag_lists_get_user_flags();
foreach ($user_flag_lists as $key => $op) {
$ops[$key] = explode('_', $key);
if (empty($ops[$key][3]) || !($flag = flag_lists_get_flag($ops[$key][3]))) {
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;
}