function opigno_forum_app_get_course_forum_id in Opigno Forum App 7
Helper function to the forum ID for the passed course ID.
Parameters
int $gid:
Return value
int|null
3 calls to opigno_forum_app_get_course_forum_id()
- opigno_forum_app_node_delete in ./
opigno_forum_app.module - opigno_forum_app_opigno_breadcrumbs in ./
opigno_forum_app.module - Implements hook_opigno_breadcrumbs().
- opigno_forum_app_opigno_tool in ./
opigno_forum_app.module
File
- ./
opigno_forum_app.module, line 63 - Module file. Defines module hooks.
Code
function opigno_forum_app_get_course_forum_id($gid) {
$subquery1 = db_select('taxonomy_term_data', 'tt');
$subquery1
->addField('tt', 'tid', 'tid');
$subquery1
->addField('tt', 'vid', 'vid');
$subquery2 = db_select('taxonomy_vocabulary', 'tv');
$subquery2
->addField('tv', 'vid', 'vid');
$subquery2
->addField('tv', 'machine_name', 'machine_name');
$subquery2
->condition('tv.machine_name', 'forums', '=');
$query = db_select('og_membership', 'og_m');
$query
->fields('og_m', array(
'etid',
'entity_type',
'gid',
));
$query
->join($subquery1, 'tt', 'og_m.etid=tt.tid');
$query
->join($subquery2, 'tv', 'tt.vid=tv.vid');
$query
->condition('og_m.entity_type', 'taxonomy_term', '=');
$query
->condition('og_m.gid', $gid, '=');
$query
->orderBy('og_m.etid', 'ASC');
$result1 = $query
->execute();
foreach ($result1 as $record) {
return $record->etid;
}
return NULL;
}