function tft_og_add_term in Taxonomy File Tree 7
Create a term for in the Taxonomy File Tree vocabulary for this new OG.
File
- ./
tft.module, line 463 - Module hooks.
Code
function tft_og_add_term(&$object, $context = array()) {
if ($object->type == 'og' && $object->nid) {
$tid = db_select('tft_tid_og_nid', 't')
->fields('t', array(
'tid',
))
->condition('og_nid', $object->nid)
->execute()
->fetchField();
if (!$tid) {
module_load_include('inc', 'tft', 'tft.admin');
$form_state = array();
$form_state['values']['name'] = $object->title . ' (og/' . $object->nid . ')';
$form_state['values']['parent'] = 0;
$tid = tft_add_term_form_submit(array(), $form_state);
db_insert('tft_tid_og_nid')
->fields(array(
'tid' => $tid,
'og_nid' => $object->nid,
))
->execute();
// Add an "Archive" folder
$form_state = array();
$form_state['values']['name'] = "Archives";
$form_state['values']['parent'] = $tid;
tft_add_term_form_submit(array(), $form_state);
}
}
}