diff --git a/scheduler.install b/scheduler.install index 4584f80..a3fa248 100644 --- a/scheduler.install +++ b/scheduler.install @@ -63,6 +63,8 @@ function scheduler_uninstall() { $variables[] = "scheduler_unpublish_enable_" . $type_name; $variables[] = "scheduler_unpublish_required_" . $type_name; $variables[] = "scheduler_unpublish_revision_" . $type_name; + $variables[] = "scheduler_use_vertical_tabs_" . $type_name; + $variables[] = "scheduler_no_vert_tabs_get_weight_" . $type_name; } foreach ($variables as $variable) { @@ -105,6 +107,8 @@ function scheduler_update_6101() { variable_set('scheduler_publish_enable_'. $type_name, $publish_enable); variable_set('scheduler_unpublish_enable_'. $type_name, $publish_enable); variable_set('scheduler_publish_touch_'. $type_name, $publish_touch); + variable_set('scheduler_use_vertical_tabs_'. $type_name, 1); + variable_set('scheduler_no_vert_tabs_get_weight_'. $type_name, 35); variable_del('scheduler_touch_'. $type_name); variable_del('scheduler_'. $type_name); diff --git a/scheduler.module b/scheduler.module index 48b22d1..de7c6c3 100644 --- a/scheduler.module +++ b/scheduler.module @@ -54,6 +54,7 @@ function scheduler_menu() { 'description' => 'A lightweight cron handler to allow more frequent runs of Schedulers internal cron system.', 'page callback' => 'drupal_get_form', 'page arguments' => array('_scheduler_lightweight_cron'), + 'access callback' => TRUE, 'access arguments' => array('administer scheduler'), 'type' => MENU_LOCAL_TASK, 'weight' => 10, @@ -70,19 +71,7 @@ function scheduler_menu() { 'type' => MENU_LOCAL_TASK, 'title' => 'Scheduled', 'page callback' => 'scheduler_list', - 'page arguments' => array(NULL, NULL), - 'access callback' => 'scheduler_list_access_callback', - 'access arguments' => array(NULL, NULL), - 'description' => 'Display a list of scheduled nodes', - 'file' => NULL, - ); - $items['user/%/scheduler'] = array( - 'type' => MENU_LOCAL_TASK, - 'title' => 'Scheduled', - 'page callback' => 'scheduler_list', - 'page arguments' => array('user_only', 1), // This will pass the uid of the user account being viewed. 'access callback' => 'scheduler_list_access_callback', - 'access arguments' => array('user_only', 1), 'description' => 'Display a list of scheduled nodes', 'file' => NULL, ); @@ -93,11 +82,7 @@ function scheduler_menu() { * Return the users access to the scheduler list page. Separate function required because of the two access values to be checked. */ function scheduler_list_access_callback() { - $args = func_get_args(); - global $user; - // If this is called from the user account page then allow the tab to be shown if you are - // viewing your own account as an alternative to having 'administer nodes' permission. - return (user_access('administer nodes') || ($args[0] == 'user_only' && $args[1] == $user->uid)) && user_access('schedule (un)publishing of nodes'); + return user_access('administer nodes') && user_access('schedule (un)publishing of nodes'); } /** @@ -196,7 +181,7 @@ function scheduler_form_node_type_form_alter(&$form, $form_state) { drupal_add_css(drupal_get_path('module', 'scheduler') .'/scheduler.css'); $form['scheduler'] = array( '#type' => 'fieldset', - '#title' => 'Scheduler', + '#title' => 'Scheduler settings', '#weight' => 35, '#group' => 'additional_settings', '#attached' => array( @@ -208,52 +193,79 @@ function scheduler_form_node_type_form_alter(&$form, $form_state) { $form['scheduler']['publish'] = array( '#type' => 'fieldset', - '#title' => 'Publishing', - '#collapsible' => FALSE, + '#title' => 'Publishing settings', + '#collapsible' => TRUE, + '#collapsed' => TRUE, '#weight' => 1, '#group' => 'scheduler', ); + $form['scheduler']['publish']['scheduler_use_vertical_tabs'] = array( + '#type' => 'checkbox', + '#title' => t('Show Scheduling options in vertical tabs'), + '#default_value' => variable_get('scheduler_use_vertical_tabs_' . $form['#node_type']->type, 1), + '#description' => t('Uncheck this box if you\'d like to show these options apart from Vertical Tabs.'), + ); + $form['scheduler']['publish']['scheduler_no_vert_tabs_get_weight'] = array( + '#type' => 'textfield', + '#maxlength' => 3, + '#title' => t('Set the weight of \'Scheduling options\' here.'), + '#default_value' => variable_get('scheduler_no_vert_tabs_get_weight_' . $form['#node_type']->type, NULL), + '#description' => t('You\'ve chosen to display \'Scheduling options\' apart from Vertical Tabs. Please enter a weight here to move \'Scheduling options\' up or down on the \'node/add\' and \'node/edit pages\'.'), + '#attached' => array( + 'js' => array( + drupal_get_path('module', 'scheduler') . "/scheduler_no_vert_tabs_choose_weight.js" + ), + ), + ); $form['scheduler']['publish']['scheduler_publish_enable'] = array( '#type' => 'checkbox', - '#title' => t('Enable scheduled publishing for this content type'), + '#title' => t('Enable scheduled publishing'), '#default_value' => variable_get('scheduler_publish_enable_' . $form['#node_type']->type, 0), + '#description' => t('Check this box to enable scheduled publishing for this node type.') ); $form['scheduler']['publish']['scheduler_publish_touch'] = array( '#type' => 'checkbox', - '#title' => t('Change content creation time to match the scheduled publish time'), + '#title' => t('Alter published on time'), '#default_value' => variable_get('scheduler_publish_touch_' . $form['#node_type']->type, 0), + '#description' => t('Check this box to alter the published on time to match the scheduled time ("touch feature").') ); $form['scheduler']['publish']['scheduler_publish_required'] = array( '#type' => 'checkbox', - '#title' => t('Require scheduled publishing'), + '#title' => t('Publishing date/time is required.'), '#default_value' => variable_get('scheduler_publish_required_' . $form['#node_type']->type, 0), + '#description' => t('Check this box to if scheduled publishing is required (e.g. the user must enter a date/time).') ); $form['scheduler']['publish']['scheduler_publish_revision'] = array( '#type' => 'checkbox', '#title' => t('Create a new revision on publishing'), '#default_value' => variable_get('scheduler_publish_revision_' . $form['#node_type']->type, 0), + '#description' => t('Check this box if you want a new revision created when publishing.') ); $form['scheduler']['unpublish'] = array( '#type' => 'fieldset', - '#title' => 'Unpublishing', - '#collapsible' => FALSE, + '#title' => 'Unpublishing settings', + '#collapsible' => TRUE, + '#collapsed' => TRUE, '#weight' => 2, '#group' => 'scheduler', ); $form['scheduler']['unpublish']['scheduler_unpublish_enable'] = array( '#type' => 'checkbox', - '#title' => t('Enable scheduled unpublishing for this content type'), + '#title' => t('Enable scheduled unpublishing'), '#default_value' => variable_get('scheduler_unpublish_enable_' . $form['#node_type']->type, 0), + '#description' => t('Check this box to enable scheduled unpublishing for this node type.') ); $form['scheduler']['unpublish']['scheduler_unpublish_required'] = array( '#type' => 'checkbox', - '#title' => t('Require scheduled unpublishing'), + '#title' => t('Unpublishing date/time is required.'), '#default_value' => variable_get('scheduler_unpublish_required_' . $form['#node_type']->type, 0), + '#description' => t('Check this box to if scheduled unpublishing is required (e.g. the user must enter a date/time).') ); $form['scheduler']['unpublish']['scheduler_unpublish_revision'] = array( '#type' => 'checkbox', '#title' => t('Create a new revision on unpublishing'), '#default_value' => variable_get('scheduler_unpublish_revision_' . $form['#node_type']->type, 0), + '#description' => t('Check this box if you want a new revision created when unpublishing.') ); } @@ -305,6 +317,8 @@ function scheduler_form_alter(&$form, $form_state) { $publishing_required = variable_get('scheduler_publish_required_'. $form['type']['#value'], 0) == 1; $unpublishing_required = variable_get('scheduler_unpublish_required_'. $form['type']['#value'], 0) == 1; + $use_vertical_tabs = variable_get('scheduler_use_vertical_tabs_'. $form['type']['#value'], 1); + $no_vertical_tabs_weight = variable_get('scheduler_no_vert_tabs_get_weight_'. $form['type']['#value'], 35); $fieldset_extended = ( (isset($defaults->publish_on) && $defaults->publish_on != 0) @@ -313,19 +327,30 @@ function scheduler_form_alter(&$form, $form_state) { || $unpublishing_required ); - $form['scheduler_settings'] = array( + if (variable_get('scheduler_use_vertical_tabs_' . $form['type']['#value'], 0) == 1) { + $form['scheduler_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Scheduling options'), + '#collapsible' => TRUE, + '#collapsed' => !$fieldset_extended, + '#weight' => 35, + '#group' => 'additional_settings', + '#attached' => array( + 'js' => array( + 'vertical-tabs' => drupal_get_path('module', 'scheduler') . "/scheduler_vertical_tabs.js" + ), + ) + ); + } else { + $form['scheduler_settings'] = array( '#type' => 'fieldset', '#title' => t('Scheduling options'), '#collapsible' => TRUE, - '#collapsed' => !$fieldset_extended, - '#weight' => 35, - '#group' => 'additional_settings', - '#attached' => array( - 'js' => array( - 'vertical-tabs' => drupal_get_path('module', 'scheduler') . "/scheduler_vertical_tabs.js" - ), - ) - ); + '#collapsed' => FALSE, + '#weight' => $no_vertical_tabs_weight, + '#group' => FALSE, + ); + } $extra_info = variable_get('scheduler_extra_info', ''); if ($extra_info && $extra_info != '') { @@ -428,15 +453,6 @@ function scheduler_list() { $query->fields('s', array('publish_on', 'unpublish_on')); $query->fields('n', array('nid', 'uid', 'status', 'title')); $query->addField('u', 'name'); - - // If this function is being called from a user account page then only select the nodes owned by - // that user. If the current user is viewing another users profile and they do not have - // 'administer nodes' permission then it won't even get this far, as the tab will not be accessible. - $args = func_get_args(); - if ($args[0] == 'user_only') { - $query->condition('n.uid', $args[1], '='); - } - $query = $query ->extend('TableSort') ->orderByHeader($header);