Skip to content
Snippets Groups Projects
Commit a89b09d1 authored by Gisle Hannemyr's avatar Gisle Hannemyr
Browse files

Revert "Issue #2984644 by fmr: Content type restriction is not respected"

This reverts commit 3ea7e94f.
parent d01277f9
No related branches found
No related tags found
No related merge requests found
......@@ -92,7 +92,7 @@ function flexiaccess_user($form, &$form_state, $user) {
'#value' => t('Add Node'),
'#ajax' => array(
'callback' => 'flexiaccess_user_ajax_callback',
'wrapper' => 'flexiaccess-user',
'wrapper' => 'flexiaccess-user-acl-table',
'method' => 'replace',
'effect' => 'fade',
),
......@@ -113,12 +113,25 @@ function flexiaccess_user($form, &$form_state, $user) {
// This is 1 when a row is being added via ajax.
if ($form_state['rebuild']) {
// Make sure the input text is an integer.
$nid = (empty($form_state['values']['add'])) ? 0 : (int) $form_state['values']['add'];
// Check if there are previously added, but uncommitted rows.
if (empty($form_state['uncommitted'])) {
$form_state['uncommitted'] = array();
}
// Check if node exists.
if (node_load($nid)) {
$form_state['uncommitted'][] = $nid;
}
else {
// Invalid node number.
// @todo: Error msg. But how?
}
// Find the correct node titles.
// @todo: It seems silly to re-query the titles every time. is there another way...?
if (!empty($form_state['uncommitted'])) {
$result = db_query('SELECT nid,title, 0 AS grant_view, 0 AS grant_update, 0 AS grant_delete FROM {node} WHERE nid IN (:nids)', array(':nids' => $form_state['uncommitted']));
......@@ -141,7 +154,7 @@ function flexiaccess_user($form, &$form_state, $user) {
*/
function flexiaccess_user_ajax_callback($form, $form_state) {
// Return the part of the (rebuilt) form to be replaced.
return $form;
return $form['acl'];
}
/**
......@@ -215,25 +228,3 @@ function flexiaccess_user_submit($form, &$form_state) {
cache_clear_all();
drupal_set_message(t('Your changes to the ACL has been saved.'));
}
function flexiaccess_user_validate($form, &$form_state) {
$types = array_filter(variable_get('flexiaccess_types', array()));
$node = node_load($form_state['values']['add']);
if (!is_numeric($form_state['values']['add'])) {
form_set_error('add', t('Enter a node ID, or type the title and select a node from the autocomplete list.'));
}
if (!$node) {
form_set_error('add', t('Could not find a node with ID @nid', array('@nid' => $form_state['values']['add'])));
return;
}
if (!in_array($node->type, $types)) {
form_set_error('add', t('Flexiaccess is not configured to manage nodes of type <code>!type</code>.', array(
'!type' => $node->type
)));
return;
}
// If all is OK, add the new nid to the list of uncommitted nodes.
$form_state['uncommitted'][] = $node->nid;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment