function flag_lists_ops_form_submit in Flag Lists 7.3
Same name and namespace in other branches
- 7 flag_lists.module \flag_lists_ops_form_submit()
1 call to flag_lists_ops_form_submit()
1 string reference to 'flag_lists_ops_form_submit'
- flag_lists_form_alter in ./
flag_lists.module - Implementation of hook_form_alter().
File
- ./
flag_lists.module, line 561 - The Flag Lists module.
Code
function flag_lists_ops_form_submit($form, &$form_state) {
// Get the $ops from the originating form.
$ops = $_REQUEST['flag_lists_ops'];
$ops = is_array($ops) ? $ops : array(
$ops,
);
$success_count = 0;
// Get the operation, or set it
switch ($form_state['values']['flag_lists_' . $form_state['flo_operation']]['operation']) {
case 'unflag':
$operation = 'unflag';
$message = 'removed from';
$user_flag_lists = flag_lists_get_user_flags();
foreach ($user_flag_lists as $key => $op) {
// Iterate over all flags by this user
list($k1, $k2, $owner, $ofid) = explode('_', $key);
foreach ($ops as $op) {
// Iterate over all selected items
list($nid, $fid) = array_merge(explode('-', $op), array(
FALSE,
));
if ($fid != 0 && $fid == $ofid) {
if (($flag = flag_lists_get_flag($fid)) && ($node = node_load($nid))) {
if (flag_lists_do_flag($flag, $operation, $nid)) {
$success_count++;
}
}
}
}
}
break;
default:
$operation = 'flag';
$message = 'added to';
if ($flag = flag_lists_get_flag($form_state['values']['flag_lists_' . $form_state['flo_operation']]['list'])) {
foreach ($ops as $nid) {
if (flag_lists_do_flag($flag, $operation, $nid)) {
$success_count++;
}
}
}
break;
}
if (!empty($flag->title) && $success_count != 0) {
$message = t('@count item(s) ' . $message . ' !listname !title', array(
'@count' => $success_count,
'!listname' => variable_get('flag_lists_name', 'list'),
'!title' => $flag->title,
));
}
else {
$message = t('No items affected.');
}
if ($_GET['q'] != 'system/ajax') {
drupal_set_message($message);
}
else {
return $message;
}
}