function domain_admin_editor_form in Domain Access 5
FormsAPI for enabling domain editors
This function writes straight to the {node_access} table because we are adding a grant in addition to one that already exists.
File
- ./
domain_admin.inc, line 384 - Administration functions for the domain module.
Code
function domain_admin_editor_form($form_id, $form_values) {
$clear = FALSE;
if ($form_values['domain_editors_status'] == 0 && $form_values['domain_editors'] == 1) {
// Apply rules
$result = db_query("SELECT nid, gid FROM {node_access} WHERE realm = 'domain_id'");
while ($data = db_fetch_array($result)) {
db_query("INSERT INTO {node_access} VALUES (%d, %d, 'domain_editor', 0, 1, 1)", $data['nid'], $data['gid']);
db_query("INSERT INTO {domain_access} VALUES (%d, %d, 'domain_editor')", $data['nid'], $data['gid']);
}
$clear = TRUE;
}
else {
if ($form_values['domain_editors_status'] == 1 && $form_values['domain_editors'] == 0) {
// Remove rules
db_query("DELETE FROM {node_access} WHERE realm = 'domain_editor'");
db_query("DELETE FROM {domain_access} WHERE realm = 'domain_editor'");
$clear = TRUE;
}
}
// We have reset the node_access table and need to clear the cache.
if ($clear) {
cache_clear_all();
}
}