From 5836b335984758e4db5cd37ee8e3707c12fa4894 Mon Sep 17 00:00:00 2001
From: James Silver <jamsilver@gmail.com>
Date: Wed, 2 May 2012 15:47:20 +0100
Subject: [PATCH] Allow disable checkbox for mobile sites

---
 mobile_tools.admin.inc |    6 ++++++
 mobile_tools.module    |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/mobile_tools.admin.inc b/mobile_tools.admin.inc
index 7f1b3b3..66bfc90 100644
--- a/mobile_tools.admin.inc
+++ b/mobile_tools.admin.inc
@@ -13,6 +13,12 @@
  */ 
 function mobile_tools_configuration_form() {
   global $base_url;
+  $form['mobile_tools_disable'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Disable mobile site'),
+    '#description' => 'Prevents redirection to mobile site and shows the desktop site to mobile browsers.',
+    '#default_value' => variable_get('mobile_tools_disable', FALSE),
+  );
   $form['mobile_tools_configuration'] = array(
     '#type' => 'fieldset',
     '#title' => 'General configuration',
diff --git a/mobile_tools.module b/mobile_tools.module
index 7c8f159..bb7ba9c 100755
--- a/mobile_tools.module
+++ b/mobile_tools.module
@@ -351,6 +351,9 @@ function mobile_tools_switch_theme($device) {
  */
 function mobile_tools_get_device() {
   global $cookie_domain, $mobile_tools_device;
+  if (variable_get('mobile_tools_disable', FALSE)) {
+    return array('type' => 'desktop', 'group' => '');
+  }
   // currently the boot method saves the result in a global variable.
   if(isset($mobile_tools_device)){
     return $mobile_tools_device;
@@ -512,6 +515,9 @@ function _mobile_tools_is_mobile_device() {
  *  Detection of the site type . the values comes out the configuration form.
  */
 function mobile_tools_site_type(){
+  if (variable_get('mobile_tools_disable', FALSE)) {
+    return 'desktop';
+  }
   $site_detection = variable_get('mobile-tools-site-type-detection', 'mobile_tools');
   drupal_load('module', $site_detection);
   if ($site_detection == 'mobile_tools') {
-- 
1.7.1

