function _discussthis_set_topic in Discuss This! 5
Same name and namespace in other branches
- 7.2 discussthis.node.inc \_discussthis_set_topic()
- 7 discussthis.node.inc \_discussthis_set_topic()
Store a mapping between the given nid and a forum topic (by topic)
1 call to _discussthis_set_topic()
- discussthis_nodeapi in ./
discussthis.module - hook_nodeapi implementation This is the meat of the module. Here we add the Discuss This link which will create a new forum topic if none exists, or link to the existing one if it does. Also adds forum override dropdown on add/edit screen for users…
File
- ./
discussthis.module, line 580
Code
function _discussthis_set_topic($nid, $title) {
// lookup the topic title first, and get a forum_nid from that
$sql = 'SELECT n.nid,n.title FROM {node} n WHERE n.title like "%s" and n.type = "forum"';
$result = db_query(db_rewrite_sql($sql), $title);
$topic = db_fetch_object($result);
if ($topic->nid) {
// now just store the mapping in the discussthis_forums table
_discussthis_set_tid($nid, $topic->nid);
}
else {
// if there was no match, ignore, and remove any existing mapping?
$sql = 'DELETE FROM {discussthis} WHERE nid=%d';
db_query($sql, $nid);
}
}