Index: override_node_options.module =================================================================== --- override_node_options.module (revision 154) +++ override_node_options.module (working copy) @@ -1,5 +1,5 @@ 'Control which node publishing overrides users have.', + 'title' => 'Override Node Options', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('override_node_options_admin_settings'), + 'access arguments' => array('administer site configuration'), + ); + + return $items; +} + +/** * Implementation of hook_form_alter(). */ -function override_node_options_form_alter($form_id, &$form) { +function override_node_options_form_alter(&$form, $form_state, $form_id) { // Allow users with 'override node publishing options' to change node // options. Taken from node_form_array(). // TODO: Once in core, remove adminster nodes check. + if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && user_access('override node publishing options') && !user_access('administer nodes')) { $node = $form['#node']; - $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25); - $form['options']['override_publishing_status'] = array('#type' => 'checkbox', '#title' => t('Published'), '#default_value' => $node->status); - $form['options']['override_publishing_promote'] = array('#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote); - $form['options']['override_publishing_sticky'] = array('#type' => 'checkbox', '#title' => t('Sticky at top of lists'), '#default_value' => $node->sticky); - $form['options']['override_publishing_revision'] = array('#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision); + $allowed = variable_get('override_node_options_publishing', 0); + $options = array( + 'status' => array('title' => t('Published'), 'default_value' => $node->status), + 'promote' => array('title' => t('Promoted to front page'), 'default_value' => $node->promote), + 'sticky' => array('title' => t('Sticky at top of lists'), 'default_value' => $node->sticky), + 'revision' => array('title' => t('Create new revision'), 'default_value' => $node->revision), + ); + // Check to make sure at least one option was specified by admin + if (is_array($allowed)) { + $form['options'] = array('#type' => 'fieldset', '#title' => t('Publishing options'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 25); + foreach ($allowed as $key => $value) { + if ($value) { + $form['options']['override_publishing_'.$key] = array('#type' => 'checkbox', '#title' => $options[$key]['title'], '#default_value' => $options[$key]['default_value']); + } + } + } } } @@ -36,7 +63,7 @@ */ function override_node_options_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { - case 'submit': + case 'presave': // Allow users with 'override node publishing options' to change node // options. // TODO: Once in core, remove adminster nodes check. @@ -56,3 +83,24 @@ break; } } + +/** + * Admin settings form + */ +function override_node_options_admin_settings() { + $options = array( + 'status' => t('Published'), + 'promote' => t('Promoted to front page'), + 'sticky' => t('Sticky at top of lists'), + 'revision' => t('Create new revision'), + ); + + $form['override_node_options_publishing'] = array( + '#type' => 'checkboxes', + '#title' => t('Available publishing overrides'), + '#default_value' => variable_get('override_node_options_publishing', $options), + '#options' => $options, + '#description' => t('Check only those options you want users to be able to override. This setting applies to all users with the permission to override node options.') + ); + return system_settings_form($form); +} \ No newline at end of file Index: override_node_options.info =================================================================== --- override_node_options.info (revision 154) +++ override_node_options.info (working copy) @@ -1,3 +1,4 @@ ; $Id: override_node_options.info,v 1.2.2.1 2007/06/18 23:06:56 dww Exp $ name = Override Node Publishing Options description = "Allow non-admins to override the default publishing options for nodes they can edit." +core = 6.x