Index: discussthis.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/discussthis/discussthis.module,v
retrieving revision 1.7
diff -u -p -r1.7 discussthis.module
--- discussthis.module 25 Jun 2008 14:20:44 -0000 1.7
+++ discussthis.module 23 Dec 2008 02:26:23 -0000
@@ -124,6 +126,17 @@ function discussthis_nodeapi(&$node, $op
}
elseif ($node->type == 'forum') {
switch ($op) {
+ case 'view':
+ if (_discussthis_get_nid_from_topic($node->nid)) {
+ $default_body = 'Following is a discussion on the [node-type-name] item titled: [node-link]'.
+ '.
Below is the discussion so far. Feel free to add your own comments!
';
+ $forum_body = variable_get('discussthis_newtemplate', $default_body);
+ $node->content['discussthis'] = array(
+ '#weight' => 0,
+ '#value' => token_replace($forum_body, 'discussthis', $node),
+ );
+ }
+ break;
case 'delete':
// drop db row for this forum nid
$sql = 'DELETE FROM {discussthis} WHERE topic_nid = %d';
@@ -480,9 +493,7 @@ function _discussthis_new_topic($nid) {
$values['name'] = variable_get('discussthis_author', $admin->name);
$values['title'] = token_replace(variable_get('discussthis_newsubject','[node-title]'), 'discussthis', $node);
- $default_body = 'Following is a discussion on the [node-type-name] item titled: [node-link]'.
- '.
Below is the discussion so far. Feel free to add your own comments!
';
- $values['body'] = token_replace(variable_get('discussthis_newtemplate',$default_body), 'discussthis', $node);
+ $values['body'] = '';
$values['taxonomy'][1] = $tid;
$values['status'] = 1;
@@ -509,6 +520,12 @@ function _discussthis_new_topic($nid) {
return $topic->nid;
}
+function _discussthis_get_nid_from_topic($topic_nid) {
+ $sql = 'SELECT nid FROM {discussthis} WHERE topic_nid = %d';
+ $nid = db_result(db_query($sql, $topic_nid));
+ return $nid;
+}
+
// Theme Functions
function theme_discussthis_comment($topic_nid,$comment) {