? .project ? filter_access.patch ? filter_access_no_form_alter.patch ? sites/default/files ? sites/default/settings.php Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.309 diff -u -p -r1.309 block.module --- modules/block/block.module 21 Aug 2008 19:36:36 -0000 1.309 +++ modules/block/block.module 7 Sep 2008 16:24:53 -0000 @@ -196,9 +196,7 @@ function block_block($op = 'list', $delt if ($delta) { $box = block_box_get($delta); } - if (filter_access($box['format'])) { - return block_box_form($box); - } + return block_box_form($box); break; case 'save': @@ -322,7 +320,7 @@ function block_box_form($edit = array()) if (!isset($edit['format'])) { $edit['format'] = FILTER_FORMAT_DEFAULT; } - $form['body_field']['format'] = filter_form($edit['format'], -16); + $form['body_field']['format'] = filter_form($edit['format'], 'body_field', t('Block body'), $form, -16); return $form; } Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.648 diff -u -p -r1.648 comment.module --- modules/comment/comment.module 6 Sep 2008 08:36:19 -0000 1.648 +++ modules/comment/comment.module 7 Sep 2008 16:24:54 -0000 @@ -1351,7 +1351,7 @@ function comment_form(&$form_state, $edi if (!isset($edit['format'])) { $edit['format'] = FILTER_FORMAT_DEFAULT; } - $form['comment_filter']['format'] = filter_form($edit['format']); + $form['comment_filter']['format'] = filter_form($edit['format'], 'comment_filter', t('Comment'), $form); $form['cid'] = array( '#type' => 'value', Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.225 diff -u -p -r1.225 filter.module --- modules/filter/filter.module 6 Sep 2008 08:36:20 -0000 1.225 +++ modules/filter/filter.module 7 Sep 2008 16:24:56 -0000 @@ -463,6 +463,12 @@ function check_markup($text, $format = F * @see filter_form_validate() * @param $value * The ID of the format that is currently selected. + * @param $element + * The form element the format is being attached too. + * @param $title + * The title of the form element. + * @param $original_form + * The original form passed by reference to alter the access to an element if necessary. * @param $weight * The weight of the input format. * @param $parents @@ -470,10 +476,27 @@ function check_markup($text, $format = F * @return * HTML for the form element. */ -function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = array('format')) { +function filter_form($value = FILTER_FORMAT_DEFAULT, $element, $title, &$original_form, $weight = NULL, $parents = array('format')) { $value = filter_resolve_format($value); $formats = filter_formats(); + // Check if the user has sufficient permissions to edit this element. + if (!filter_access($value)) { + foreach (element_children($original_form) as $key) { + if ($key == $element) { + $original_form[$key]['#access'] = FALSE; + $original_form['disabled_' . $key]['format'] = array('#type' => 'value', '#value' => $value); + $original_form['disabled_' . $key]['#markup'] = '

' . t('%title has been disabled because you do not have sufficient permissions to edit this field.', array('%title' => $title)) . '

'; + } + // Special case, see if 'teaser_js', 'teaser_include' are also available. + if ($key == 'teaser_js' || $key == 'teaser_include') { + $original_form[$key]['#access'] = FALSE; + $original_form[$key]['#access'] = FALSE; + } + } + return; + } + $extra = theme('filter_tips_more_info'); if (count($formats) > 1) { Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.974 diff -u -p -r1.974 node.module --- modules/node/node.module 6 Sep 2008 08:36:20 -0000 1.974 +++ modules/node/node.module 7 Sep 2008 16:24:57 -0000 @@ -2071,10 +2071,6 @@ function node_access($op, $node, $accoun if (empty($account)) { $account = $user; } - // If the node is in a restricted format, disallow editing. - if ($op == 'update' && !filter_access($node->format)) { - return FALSE; - } if (user_access('administer nodes', $account)) { return TRUE; Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.35 diff -u -p -r1.35 node.pages.inc --- modules/node/node.pages.inc 6 Sep 2008 08:36:20 -0000 1.35 +++ modules/node/node.pages.inc 7 Sep 2008 16:24:57 -0000 @@ -297,7 +297,7 @@ function node_body_field(&$node, $label, '#required' => ($word_count > 0), ); - $form['format'] = filter_form($node->format); + $form['format'] = filter_form($node->format, 'body', check_plain($label), $form); return $form; }