Closed (duplicate)
Project:
Simple Access
Version:
7.x-2.0-beta1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Mar 2011 at 19:59 UTC
Updated:
12 Jun 2012 at 04:28 UTC
Getting the following error when trying to edit a content type that had previously been configured with Simple Access (/admin/structure/types > Edit):
Notice: Undefined index: sa in simple_access_form_node_type_form_alter() (line 385 of .../sites/all/modules/simple_access/simple_access.module).
Comments
Comment #1
joekrukoskySame here - subscribing
Comment #2
joekrukoskyAlso get when submitting new content type:
Notice: Undefined index: simple_access in simple_access_node_type_submit() (line 397 of /home/cfwadmin/public_html/d7sites/sites/all/modules/simple_access/simple_access.module).
Comment #3
shadowmihai commentedsubscribing
Comment #4
nuezit appears that 'sa' is the wrong key of the array, it should be 'simple_access'.
Im not (yet ) familiar with creating patches, so i will put it just like that.
line 385:$form['simple_access'] = $tmp_form['sa'];
should be
$form['simple_access'] = $tmp_form['simple_access'];
---
now you can change the content type access, but it doesn´t work as an override. It simply gives the nodes to be created a predefined value of the access. It won´t change the access of all the nodes that already exist. It does makes sense when you think about it- it works in the same way as options like 'promoted for frontpage'. but maybe in the future there should be a ´bulk update´ option to update de access status of all the nodes belonging to a content type.
Comment #5
chriskd commentedsame here...
subscrbing
Comment #6
melandren commentedSame. Subscribing.
Comment #7
puravida commented+1
same behavior on a fresh install of D7.2 when editing any content-types.
I left the default "view" selected in settings, created access groups by role, and then created two access profiles, each one containing an access group.
As soon as I go to edit a content-type, this error is displayed.
Comment #8
puravida commented-- last post showed up late --
Comment #9
stfwi commentedHi, I check out the code, this could be the fix:
function simple_access_form_node_type_form_alter(&$form, &$form_state) {
$type = $form['old_type']['#value'];
$default = variable_get('simple_access_' . $type, array('simple_access' => array(), 'simple_access_profiles' => array(), 'simple_access_owner' => array()));
$tmp_form = simple_access_form((object)$default, TRUE);
// stfwi inserted >>>>>>
if(isset($tmp_form['sa'])) {
$form['simple_access'] = $tmp_form['sa']; // <<<<<<<<<<<< not existing
} else if(isset($tmp_form['simple_access'])) {
$form['simple_access'] = $tmp_form['simple_access']; // <<<<<<<<<<<< existing instead
} else {
debug($tmp_form);
watchdog('error', 'Simple access: form type template not existing.');
}
// <<<< stfwi inserted
$form['simple_access']['simple_access']['owner']['#parents'] = array('simple_access', 'simple_access_owner');
$form['simple_access']['#tree'] = TRUE;
$form['#submit'][] = 'simple_access_node_type_submit';
}
Comment #10
Jukebox commentedJust changing the title back.
Comment #11
damien_vancouver commentedThere is a proper reviewed patch for this at another issue.
Even though this one came first, that one has the patch so I'm marking this one as a duplicate.
Please see: #1211002: Notice: Undefined index: sa in simple_access_form_node_type_form_alter() (line 385 of ...simple_access.module). for the patch. It's basically the change from #4 above.