function anonymous_publishing_cl_admin_unverified_submit in Anonymous Publishing 7
Submit for the notify_admin_unverified form.
File
- modules/
cl/ anonymous_publishing_cl.admin.inc, line 710 - Menu callbacks for the CL tabs on the module admin page.
Code
function anonymous_publishing_cl_admin_unverified_submit($form, &$form_state) {
if (!array_key_exists('unverified', $form_state['values'])) {
drupal_set_message(t('No unverified posts?'), 'error');
return;
}
$op = $form_state['values']['options']['operation'];
$selected = $approved = $deleted = $moved = 0;
$ownip = ip_address();
foreach ($form_state['values']['unverified'] as $id => $settings) {
// Don't block self.
if ($settings['select']) {
$selected++;
switch ($op) {
case 'approve':
anonymous_publishing_cl_activate($id);
$approved++;
break;
case 'banip':
if ($ownip == $settings['ip2']) {
drupal_set_message(t("You've tried to ban your own IP (request is ignored)."));
continue 2;
}
if (!empty($settings['ip2'])) {
$existp = db_query("SELECT ip FROM {blocked_ips} WHERE ip = :ip", array(
':ip' => $settings['ip2'],
))
->fetchAssoc();
if (FALSE == $existp) {
$res = db_insert('blocked_ips')
->fields(array(
'ip' => $settings['ip2'],
))
->execute();
}
else {
$res = TRUE;
}
if ($res) {
$res = db_delete('anonymous_publishing')
->condition('apid', $id)
->execute();
$moved++;
}
}
// Fallthrough. We want it deleted as well.
case 'delete':
if ($settings['cid']) {
comment_delete($settings['cid']);
$deleted++;
}
elseif ($settings['nid']) {
node_delete($settings['nid']);
$deleted++;
}
break;
}
}
}
$msg = NULL;
if (!$selected) {
$msg = t('Nothing was selected.');
}
else {
if ($approved) {
$msg = t('!mm approved.', array(
'!mm' => format_plural($approved, 'One message', '@count messages'),
));
$msg .= ' ';
}
elseif ($moved) {
$msg = t('!mm moved to <code>{blocked_ips}</code>', array(
'!mm' => format_plural($approved, 'One IP-address', '@count IP-addresses'),
));
$msg .= ' ';
}
if ($deleted) {
$msg .= t('!mm deleted.', array(
'!mm' => format_plural($approved, 'One message', '@count messages'),
));
}
if (empty($msg)) {
$msg = t('Nothing to do.');
}
}
drupal_set_message($msg);
}