function workflow_access_form_submit in Workflow 7
Same name and namespace in other branches
- 5.2 workflow_access.module \workflow_access_form_submit()
- 5 workflow_access.module \workflow_access_form_submit()
- 6.2 workflow_access/workflow_access.module \workflow_access_form_submit()
- 6 workflow_access/workflow_access.module \workflow_access_form_submit()
- 7.2 workflow_access/workflow_access.pages.inc \workflow_access_form_submit()
Store permission settings for workflow states.
1 string reference to 'workflow_access_form_submit'
- workflow_access_form in workflow_access/
workflow_access.module - Implements hook_form().
File
- workflow_access/
workflow_access.module, line 216 - Provides node access permissions based on workflow states.
Code
function workflow_access_form_submit($form, &$form_state) {
foreach ($form_state['values'] as $sid => $access) {
// Ignore irrelevant keys.
if (!is_numeric($sid)) {
continue;
}
$grants = array();
foreach ($access['view'] as $rid => $checked) {
$data = array(
'sid' => $sid,
'rid' => $rid,
'grant_view' => !empty($checked) ? (bool) $checked : 0,
'grant_update' => !empty($access['update'][$rid]) ? (bool) $access['update'][$rid] : 0,
'grant_delete' => !empty($access['delete'][$rid]) ? (bool) $access['delete'][$rid] : 0,
);
$id = workflow_access_insert_workflow_access_by_sid($data);
}
// Update all nodes having same workflow state to reflect new settings.
foreach (workflow_get_workflow_node_by_sid($sid) as $data) {
// Instead of trying to construct what the grants should be per node as we save.
// Let's fall back on existing node grant systems that will find it for us.
$entity_type = 'node';
// @todo: add support for other entity types in workflow_access_form_submit()
$node = node_load($data->nid);
node_access_acquire_grants($node);
}
}
drupal_set_message(t('Workflow access permissions updated.'));
$form_state['redirect'] = 'admin/config/workflow/workflow/' . $form['#wid'];
}