function domain_taxonomy_form_term_submit in Domain Taxonomy 7
Same name and namespace in other branches
- 6 domain_taxonomy.module \domain_taxonomy_form_term_submit()
- 7.3 domain_taxonomy.module \domain_taxonomy_form_term_submit()
1 string reference to 'domain_taxonomy_form_term_submit'
File
- ./
domain_taxonomy.module, line 463
Code
function domain_taxonomy_form_term_submit($form, $form_state) {
$term = (object) $form_state['values'];
// inherit access from parent term
if ($form_state['values']['domain_load_fromparent']) {
$parent_tids = $form_state['values']['parent'];
if (is_array($parent_tids)) {
$parent_tid = array_shift($parent_tids);
}
else {
$parent_tid = $parent_tids;
}
$parent_term = taxonomy_term_load($parent_tid);
if ($parent_term) {
domain_taxonomy_load_term($parent_term);
if ($parent_term) {
$term->domains = $parent_term->domains;
$term->domain_site = $parent_term->domain_site;
$term->domain_source = $parent_term->domain_source;
}
}
}
if (_domain_taxonomy_is_debug()) {
drupal_set_message(t('Saving term with options:'));
drupal_set_message(_domain_taxonomy_get_access_info($term->domains ? $term->domains : $term->domains_raw, $term->domain_site, $term->domain_source));
}
// save term access
domain_taxonomy_save_term($term);
// update subterms access
if ($term->domain_update_subterm) {
if (_domain_taxonomy_is_debug()) {
drupal_set_message(t('Domain rules inheritance applied from current term to child terms'), 'status');
}
$terms = taxonomy_get_tree($term->vid, $term->tid);
if (count($terms) > 0) {
foreach ($terms as $subterm) {
if (_domain_taxonomy_is_debug()) {
drupal_set_message(t('Saving domain rules for child term @name', array(
'@name' => $subterm->name,
)));
}
$subterm->domains = $term->domains;
$subterm->domain_site = $term->domain_site;
$subterm->domain_source = $term->domain_source;
domain_taxonomy_save_term($subterm);
}
}
}
// update subnodes access
if ($term->domain_update_subnodes) {
if (_domain_taxonomy_is_debug()) {
drupal_set_message(t('Domain rules inheritance applied from current term to child nodes'), 'status');
}
$nodes = domain_taxonomy_select_nodes(array(
$term->tid,
), 'all');
foreach ($nodes as $node) {
if (_domain_taxonomy_is_debug()) {
drupal_set_message(t('Saving domain rules for child node @nid: @title', array(
'@nid' => $node->nid,
'@title' => $node->title,
)));
}
$node->domains = $term->domains;
$node->domain_site = $term->domain_site;
$node->domain_source = $term->domain_source;
node_access_acquire_grants($node);
}
}
}