function tac_fields_recursive_update in Taxonomy Access Control 6
1 call to tac_fields_recursive_update()
- tac_fields_admin_form_submit in tac_fields/
tac_fields.admin.inc - Submit handler for permission administration form.
File
- tac_fields/
tac_fields.admin.inc, line 643 - Administrative interface for TAC Fields.
Code
function tac_fields_recursive_update($tid, $field, $rid, $grants) {
// First, process the original.
tac_fields_update_grants($tid, $field, $rid, $grants);
// Process the children.
$ran_tids = array();
// tids that have been processed.
$run_tids = array(
$tid,
);
// tids that are in the queue to be processed.
while (count($run_tids) > 0) {
foreach ($run_tids as $run_key => $run_tid) {
// Some basic loop protection.
if (!(array_search($run_tid, $ran_tids) === FALSE)) {
drupal_set_message(t("Loop detected for tid %run_tid. Stopping.", array(
'%run_tid' => $run_tid,
)));
$run_tids = array();
// stop the execution
}
else {
$result = db_query('SELECT th.tid FROM {term_hierarchy} th WHERE th.parent = %d', $run_tid);
// If this tid has children, update grants and queue the children
while ($row = db_fetch_array($result)) {
tac_fields_update_grants($row['tid'], $field, $rid, $grants);
$run_tids[] = $row['tid'];
}
// Remove this tid from the queue and mark as processed,
unset($run_tids[$run_key]);
$ran_tids[] = $run_tid;
}
}
}
}