function photos_comment_form_submit in Album Photos 7.3
Same name and namespace in other branches
- 8.4 photos.module \photos_comment_form_submit()
- 6.2 photos.module \photos_comment_form_submit()
Implements hook_form_submit().
1 string reference to 'photos_comment_form_submit'
- photos_form_alter in ./
photos.module - Implements hook_form_alter().
File
- ./
photos.module, line 1046 - Implementation of photos.module.
Code
function photos_comment_form_submit($form, &$form_state) {
if (!empty($form_state['values']['photos_fid']) || !empty($form_state['input']['photos_fid'])) {
$fid = isset($form_state['values']['photos_fid']) ? $form_state['values']['photos_fid'] : $form_state['input']['photos_fid'];
$comment = $form_state['comment'];
// Record comment in photos_comment.
db_insert('photos_comment')
->fields(array(
'fid' => $fid,
'cid' => $comment->cid,
))
->execute();
db_query("UPDATE {photos_image} SET comcount = (SELECT COUNT(fid) FROM {photos_comment} WHERE fid = :fid) WHERE fid = :fid", array(
':fid' => $fid,
));
if (isset($form_state['complete form']['#node'])) {
$node = $form_state['complete form']['#node'];
}
else {
$node = node_load($form_state['values']['nid']);
}
$query = array();
// Find the current display page for this comment.
$page = comment_get_display_page($comment->cid, $node->type);
if ($page > 0) {
$query['page'] = $page;
}
// Redirect to the newly posted comment.
$redirect = array(
'photos/image/' . $fid,
array(
'query' => $query,
'fragment' => 'comment-' . $comment->cid,
),
);
$form_state['redirect'] = $redirect;
}
}