From ef6ed032aa1e45fe034f1c24394bef2e453e29f0 Mon Sep 17 00:00:00 2001
From: josebc <jose_bc@live.co.uk>
Date: Mon, 21 Jul 2014 17:19:22 +0300
Subject: [PATCH] Issue 1313192: enable per from id 7.x

---
 hide_submit.admin.inc |   25 +++++++++++++++++++++++++
 hide_submit.module    |   11 ++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/hide_submit.admin.inc b/hide_submit.admin.inc
index b87dc42..7c098a5 100644
--- a/hide_submit.admin.inc
+++ b/hide_submit.admin.inc
@@ -73,6 +73,31 @@ function hide_submit_settings() {
     '#description' => t('This text will be shown to the user instead of the submit buttons.'),
   );
 
+  $form['fieldset_advanced'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Advanced'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  $form['fieldset_advanced']['hide_submit_form_exclusion_mode'] = array(
+    '#type' => 'radios',
+    '#title' => t('Exclusion mode'),
+    '#default_value' => variable_get('hide_submit_form_exclusion_mode', HIDE_SUBMIT_EXCLUDE_LISTED_FORMS),
+    '#options' => array(
+      HIDE_SUBMIT_EXCLUDE_LISTED_FORMS   => t('Exclude listed forms'),
+      HIDE_SUBMIT_EXCLUDE_UNLISTED_FORMS => t('Exclude unlisted forms'),
+    ),
+    '#description' => t("Choose exclusion mode for listed forms. <br /> NOTE: Forms that are not part of drupal Form-API will not be affected by this configuration"),
+  );
+
+  $form['fieldset_advanced']['hide_submit_form_exclusion'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Form-id exclusion list'),
+    '#default_value' => variable_get('hide_submit_form_exclusion', ''),
+    '#description' => t("Here you can make a list of forms (form-id) you wish not to hide submit buttons . <br />For example you can exclude the login block submit button from hiding by typing <em>user_login_block</em>"),
+  );
+
   return system_settings_form($form);
 }
 
diff --git a/hide_submit.module b/hide_submit.module
index a853a21..4b73f64 100644
--- a/hide_submit.module
+++ b/hide_submit.module
@@ -8,6 +8,9 @@
  * Javascript enabled (which is a very high percent of users).
  */
 
+define('HIDE_SUBMIT_EXCLUDE_LISTED_FORMS',   0);
+define('HIDE_SUBMIT_EXCLUDE_UNLISTED_FORMS', 1);
+
 /**
  * Adds the settings.
  *
@@ -46,8 +49,14 @@ function hide_submit_add_settings() {
  * Implements hook_form_alter().
  */
 function hide_submit_form_alter(&$form, &$form_state, $form_id) {
-  if (hide_submit_add_settings()) {
 
+  $exclude_forms = explode("\r\n", variable_get('hide_submit_form_exclusion', ''));
+  $mode = variable_get('hide_submit_form_exclusion_mode', HIDE_SUBMIT_EXCLUDE_LISTED_FORMS);
+
+  $listed = ($mode == HIDE_SUBMIT_EXCLUDE_LISTED_FORMS && !in_array($form_id, $exclude_forms));
+  $unlisted = ($mode == HIDE_SUBMIT_EXCLUDE_UNLISTED_FORMS && in_array($form_id, $exclude_forms));
+
+  if(hide_submit_add_settings() && ($listed || $unlisted)) {
     // Add JavaScript.
     if (!isset($form['#attached']['js'])) {
       $form['#attached']['js'] = array();
-- 
1.7.9.5

