Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.133 diff -u -F^f -r1.133 form.inc --- includes/form.inc 10 Aug 2006 15:42:32 -0000 1.133 +++ includes/form.inc 15 Aug 2006 01:20:38 -0000 @@ -399,6 +399,11 @@ function form_builder($form_id, $form) { // overlay $info onto $form, retaining preexisting keys in $form $form += $info; } + + if (isset($form['#access']) && !$form['#access']) { + $form['#type'] = 'value'; + $posted = FALSE; + } if (isset($form['#input']) && $form['#input']) { if (!isset($form['#name'])) { @@ -408,10 +413,12 @@ function form_builder($form_id, $form) { $form['#id'] = 'edit-' . implode('-', $form['#parents']); } - $posted = (isset($_POST['edit']) && ($_POST['edit']['form_id'] == $form_id)); - $edit = $posted ? $_POST['edit'] : array(); - foreach ($form['#parents'] as $parent) { - $edit = isset($edit[$parent]) ? $edit[$parent] : NULL; + if ($posted !== FALSE) { + $posted = (isset($_POST['edit']) && ($_POST['edit']['form_id'] == $form_id)); + $edit = $posted ? $_POST['edit'] : array(); + foreach ($form['#parents'] as $parent) { + $edit = isset($edit[$parent]) ? $edit[$parent] : NULL; + } } if (!isset($form['#value']) && !array_key_exists('#value', $form)) { if ($posted) { @@ -494,6 +501,11 @@ function form_builder($form_id, $form) { if (!isset($form[$key]['#tree'])) { $form[$key]['#tree'] = $form['#tree']; } + + // deny access to child elements if parent is denied + if (isset($form['#access']) && !isset($form[$key]['#access'])) { + $form[$key]['#access'] = $form['#access']; + } // don't squash existing parents value if (!isset($form[$key]['#parents'])) { Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.474 diff -u -F^f -r1.474 comment.module --- modules/comment/comment.module 10 Aug 2006 15:42:32 -0000 1.474 +++ modules/comment/comment.module 15 Aug 2006 01:20:40 -0000 @@ -277,27 +277,20 @@ function comment_form_alter($form_id, &$ elseif (isset($form['type'])) { if ($form['type']['#value'] .'_node_form' == $form_id) { $node = $form['#node']; - if (user_access('administer comments')) { - $form['comment_settings'] = array( - '#type' => 'fieldset', - '#title' => t('Comment settings'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#weight' => 30, - ); - $form['comment_settings']['comment'] = array( - '#type' => 'radios', - '#parents' => array('comment'), - '#default_value' => $node->comment, - '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')), - ); - } - else { - $form['comment_settings']['comment'] = array( - '#type' => 'value', - '#value' => $node->comment, - ); - } + $form['comment_settings'] = array( + '#type' => 'fieldset', + '#access' => user_access('administer comments'), + '#title' => t('Comment settings'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#weight' => 30, + ); + $form['comment_settings']['comment'] = array( + '#type' => 'radios', + '#parents' => array('comment'), + '#default_value' => $node->comment, + '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')), + ); } } } Index: modules/menu/menu.module =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v retrieving revision 1.78 diff -u -F^f -r1.78 menu.module --- modules/menu/menu.module 7 Aug 2006 15:04:15 -0000 1.78 +++ modules/menu/menu.module 15 Aug 2006 01:20:40 -0000 @@ -179,7 +179,7 @@ function menu_perm() { * Add menu item fields to the node form. */ function menu_form_alter($form_id, &$form) { - if (user_access('administer menu') && isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { + if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { $edit = isset($_POST['edit']) ? $_POST['edit'] : ''; $edit['nid'] = $form['nid']['#value']; @@ -193,6 +193,7 @@ function menu_form_alter($form_id, &$for $form['menu'] = array('#type' => 'fieldset', '#title' => t('Menu settings'), + '#access' => user_access('administer menu'), '#collapsible' => TRUE, '#collapsed' => empty($item['title']), '#tree' => TRUE, Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.669 diff -u -F^f -r1.669 node.module --- modules/node/node.module 10 Aug 2006 15:42:33 -0000 1.669 +++ modules/node/node.module 15 Aug 2006 01:20:41 -0000 @@ -1873,30 +1873,28 @@ function node_form_array($node) { } $form['#node'] = $node; - if (user_access('administer nodes')) { - // Node author information - $form['author'] = array('#type' => 'fieldset', '#title' => t('Authoring information'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 20); - $form['author']['name'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $node->name ? $node->name : '', '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => theme('placeholder', variable_get('anonymous', 'Anonymous'))))); - $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#description' => t('Format: %time. Leave blank to use the time of form submission.', array('%time' => $node->date))); - - if (isset($node->nid)) { - $form['author']['date']['#default_value'] = $node->date; - } - - // Node options for administrators - $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25); - $form['options']['status'] = array('#type' => 'checkbox', '#title' => t('Published'), '#default_value' => $node->status); - $form['options']['promote'] = array('#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote); - $form['options']['sticky'] = array('#type' => 'checkbox', '#title' => t('Sticky at top of lists'), '#default_value' => $node->sticky); - $form['options']['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision); - } - else { - // Put all of these through as values if the user doesn't have access to them. - foreach (array('uid', 'created') as $key) { - $form[$key] = array('#type' => 'value', '#value' => $node->$key); - } + // Node author information for administrators + $form['author'] = array('#type' => 'fieldset', '#access' => user_access('administer nodes'), '#title' => t('Authoring information'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 20); + $form['author']['name'] = array('#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, '#autocomplete_path' => 'user/autocomplete', '#default_value' => $node->name ? $node->name : '', '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => theme('placeholder', variable_get('anonymous', 'Anonymous'))))); + $form['author']['date'] = array('#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, '#description' => t('Format: %time. Leave blank to use the time of form submission.', array('%time' => $node->date))); + + if (isset($node->nid)) { + $form['author']['date']['#default_value'] = $node->date; + } + + // Node options for administrators + $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#access' => user_access('administer nodes'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25); + $form['options']['status'] = array('#type' => 'checkbox', '#title' => t('Published'), '#default_value' => $node->status); + $form['options']['promote'] = array('#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote); + $form['options']['sticky'] = array('#type' => 'checkbox', '#title' => t('Sticky at top of lists'), '#default_value' => $node->sticky); + $form['options']['revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision); + + // these values are used when user has no administrator accesss + foreach (array('uid', 'created') as $key) { + $form[$key] = array('#type' => 'value', '#value' => $node->$key); } + // Add the buttons. $form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 40); $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'), '#weight' => 45); Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.87 diff -u -F^f -r1.87 path.module --- modules/path/path.module 7 Aug 2006 15:04:15 -0000 1.87 +++ modules/path/path.module 15 Aug 2006 01:20:41 -0000 @@ -251,13 +251,15 @@ function path_nodeapi(&$node, $op, $arg) * Implementation of hook_form_alter(). */ function path_form_alter($form_id, &$form) { - if (user_access('create url aliases') && isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { + if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { $path = $form['#node']->path; + $access = user_access('create url aliases'); $form['path'] = array( '#type' => 'fieldset', '#title' => t('URL path settings'), '#collapsible' => TRUE, '#collapsed' => empty($path), + '#access' => $access, '#weight' => 30, ); $form['path']['path'] = array( Index: modules/upload/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v retrieving revision 1.118 diff -u -F^f -r1.118 upload.module --- modules/upload/upload.module 10 Aug 2006 15:42:33 -0000 1.118 +++ modules/upload/upload.module 15 Aug 2006 01:20:42 -0000 @@ -359,13 +359,14 @@ function upload_form_alter($form_id, &$f if (isset($form['type'])) { $node = $form['#node']; - if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE) && user_access('upload files')) { + if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE)) { drupal_add_js('misc/progress.js'); drupal_add_js('misc/upload.js'); // Attachments fieldset $form['attachments'] = array( '#type' => 'fieldset', + '#access' => user_access('upload files'), '#title' => t('File attachments'), '#collapsible' => TRUE, '#collapsed' => empty($node->files),