Created
May 30, 2016 21:29
-
-
Save kvnm/37d96431308b1da393a3cc792b68d2c2 to your computer and use it in GitHub Desktop.
Retroactively bulk assign all existing nodes with taxonomy terms to their respective workbench_access sections. Useful if you've got a workbench_access scheme based on taxonomy terms that have existed for some time before launching access control.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Retroactively bulk assigns all existing nodes w/ taxonomy terms | |
* to their respective workbench_access sections. | |
*/ | |
function custom_workbench_retroactive_assign_all() { | |
$active = workbench_access_get_active_tree(); | |
if (!$active) { | |
return; | |
} | |
$tree = $active['tree']; | |
workbench_access_build_tree($tree); | |
$options = workbench_access_options($tree, $active['active']); | |
if (empty($options)) { | |
return; | |
} | |
foreach ($tree as $tid => $leaf) { | |
$nids = array(); | |
if (is_numeric($tid)) { | |
$nids = taxonomy_select_nodes($tid, FALSE, FALSE); | |
} | |
if (!empty($nids)) { | |
workbench_access_mass_update($nids, $tid, $active['access_scheme']); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment