function anonymous_publishing_lr_form_submit in Anonymous Publishing 7
Handle post-validation form submission.
File
- modules/
lr/ anonymous_publishing_lr.module, line 63 - Hooks for the Anonymous Publishing LR module.
Code
function anonymous_publishing_lr_form_submit($form, &$form_state) {
global $user;
$claim = $form_state['values']['anonymous_publishing_lr_options'];
if ('leave' == $claim) {
drupal_goto('<front>');
}
$sql = "SELECT a.nid, a.cid, n.title FROM {anonymous_publishing} a JOIN {node} n ON a.nid = n.nid WHERE email = :mail ORDER BY n.created ASC";
$rows = db_query($sql, array(
':mail' => $user->mail,
))
->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
if ($row['cid']) {
$comment = comment_load($row['cid']);
$comment->uid = $user->uid;
$comment->name = $user->name;
$comment->mail = $user->mail;
comment_save($comment);
}
else {
$context = array(
'owner_uid' => $user->uid,
);
$node = node_load($row['nid']);
node_assign_owner_action($node, $context);
node_save($node);
}
db_delete('anonymous_publishing')
->condition('nid', $row['nid'], '=')
->condition('cid', $row['cid'], '=')
->execute();
}
drupal_goto('<front>');
}