You are here

function discussthis_new in Discuss This! 6

Same name and namespace in other branches
  1. 5 discussthis.module \discussthis_new()

\brief User is creating a new comment.

This function redirects the user so he/she can post a comment on the concerned node.

The forum topic will be created later once the comment is actually posted to us.

\param[in] $nid The node identifier

1 string reference to 'discussthis_new'
_discussthis_menu in ./discussthis.admin.inc
\brief Actual implementation of hook_menu().

File

./discussthis.module, line 708
Associations discussions in forums with specific nodes

Code

function discussthis_new($nid) {

  //$topic_nid = _discussthis_new_topic($nid);

  //if ($topic_nid) {

  //  drupal_goto('comment/reply/'. $topic_nid, NULL, 'comment-form');

  //}

  // current user has the right to do that?!
  if (!user_access('initiate discuss this topics')) {
    drupal_access_denied();
    return;
  }

  // topic already exists?
  $topic_nid = _discussthis_get_topic($nid);
  if ($topic_nid) {

    // just open a comment window
    drupal_goto('comment/reply/' . $topic_nid, NULL, 'comment-form');
  }

  // we goto because of the possibility of a preview
  // but we still have a problem with duplicates
  // (i.e. two people could access the form at the same time
  // and then both create a new forum topic, argh!)
  drupal_goto('discussthis/create/' . $nid);

  //return drupal_get_form('discussthis_create_form', $nid);
}