summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanillo Brito2014-03-27 08:01:35 (GMT)
committerDave Hall2014-03-27 08:01:35 (GMT)
commit0fd53f58c8f457c75a175905504e9d49e1d73f68 (patch)
tree7e7a11cf4216c1f55e87541ad1c1c6fe3a5d508f
Initial commit7.x-1.0-beta1
-rw-r--r--README.md21
-rw-r--r--hide_vtabs.info4
-rw-r--r--hide_vtabs.install16
-rw-r--r--hide_vtabs.module68
4 files changed, 109 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..905ce2b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,21 @@
+# Hide Vertical Tabs
+
+Hide VTabs is a module to control visibility over the vertical tabs on a per
+content type basis.
+
+You have three options for setting the visibility:
+- Hide vertical tabs
+ This will hide all the options that are selectable by the user that are under
+ vertical tabs group (additional_settings);
+
+- Show vertical tabs
+ This is the Default option for vertical tabs, it will show all the tabs
+ normally;
+
+- Show revision only
+ This option will remove the revision from the vertical tabs group
+ (additional_settings), and then hide the other items.
+
+## Development
+
+Hide VTabs is jointly developed by [CI&T](http://www.ciandt.com/) and [Dave Hall Consulting](http://davehall.com.au).
diff --git a/hide_vtabs.info b/hide_vtabs.info
new file mode 100644
index 0000000..5d2f0ba
--- /dev/null
+++ b/hide_vtabs.info
@@ -0,0 +1,4 @@
+name = Hide Vertical Tabs
+description = Controls the display of vertical tabs on a per content type basis
+core = "7.x"
+project = "hide_vtabs"
diff --git a/hide_vtabs.install b/hide_vtabs.install
new file mode 100644
index 0000000..f6d566e
--- /dev/null
+++ b/hide_vtabs.install
@@ -0,0 +1,16 @@
+<?php
+/**
+ * @file
+ * Hide Vertical Tabs module installation functions.
+ */
+
+/**
+ * Implements hook_install().
+ */
+function hide_vtabs_install() {
+ // To work properly, hide_vtabs must be the last module to load.
+ db_update('system')
+ ->fields(array('weight' => '9999'))
+ ->condition('name', 'hide_vtabs')
+ ->execute();
+}
diff --git a/hide_vtabs.module b/hide_vtabs.module
new file mode 100644
index 0000000..aec7578
--- /dev/null
+++ b/hide_vtabs.module
@@ -0,0 +1,68 @@
+<?php
+/**
+ * @file
+ * Handle the display of vertical tabs on a per content type basis.
+ */
+
+define('HIDE_VTAB_STATUS_HIDDEN', 0);
+define('HIDE_VTAB_STATUS_ENABLED', 1);
+define('HIDE_VTAB_STATUS_REVISION_ONLY', 2);
+
+/**
+ * Implement hook_form_BASE_FORM_ID_alter().
+ */
+function hide_vtabs_form_node_type_form_alter(&$form, &$form_state) {
+ $node_type = $form['#node_type']->type;
+
+ $options = array(
+ HIDE_VTAB_STATUS_ENABLED => 'Show vertical tabs',
+ HIDE_VTAB_STATUS_HIDDEN => 'Hide vertical tabs',
+ HIDE_VTAB_STATUS_REVISION_ONLY => 'Show revision only',
+ );
+
+ $form['hide_vtabs'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Hide Vertical Tabs'),
+ '#collapsible' => TRUE,
+ '#group' => 'additional_settings',
+ '#description' => t('Specify display settings of vertical tabs on current content type.'),
+ );
+
+ $form['hide_vtabs']['vtabs_status'] = array(
+ '#type' => 'radios',
+ '#default_value' => variable_get('hide_vtab_node_' . $node_type . '_status', HIDE_VTAB_STATUS_ENABLED),
+ '#options' => $options,
+ '#description' => t('Options available for vertical tabs visibility. "Show revision only" option will become a fieldset.'),
+ );
+
+ $form['#submit'][] = 'hide_vtabs_node_type_submit';
+}
+
+/**
+ * Submit handler to input the vertical tabs status.
+ */
+function hide_vtabs_node_type_submit(&$form, &$form_state) {
+ $node_type = $form['#node_type']->type;
+ variable_set('hide_vtab_node_' . $node_type . '_status', $form_state['values']['vtabs_status']);
+}
+
+/**
+ * Implements hook_form_BASE_FORM_ID_alter().
+ */
+function hide_vtabs_form_node_form_alter(&$form, &$form_state) {
+ $node_type = $form['type']['#value'];
+ $vtabs_status = variable_get('hide_vtab_node_' . $node_type . '_status', HIDE_VTAB_STATUS_ENABLED);
+
+ if (HIDE_VTAB_STATUS_ENABLED != $vtabs_status) {
+ if (HIDE_VTAB_STATUS_REVISION_ONLY == $vtabs_status) {
+ unset($form['revision_information']['#group']);
+ $form['revision_information']['#collapsible'] = FALSE;
+ }
+ unset($form['additional_settings']);
+ foreach ($form as $key => $value) {
+ if (is_array($form[$key]) && isset($form[$key]['#group'])) {
+ unset($form[$key]);
+ }
+ }
+ }
+}