Further tweak on MOBILE front-end versus not backend, a=chris

Chris Pollett [2012-05-15 20:32:04]
Further tweak on MOBILE front-end versus not backend, a=chris
Filename
controllers/search_controller.php
index.php
diff --git a/controllers/search_controller.php b/controllers/search_controller.php
index 057fdad..78741f4 100755
--- a/controllers/search_controller.php
+++ b/controllers/search_controller.php
@@ -403,14 +403,17 @@ class SearchController extends Controller implements CrawlConstants

         $original_query = $query;
         $query = preg_replace('/no:cache/', "", $query);
-
         $use_cache_if_possible = ($original_query == $query) ? true : false;
+        $network_work_query = $query;
+        $query = preg_replace('/no:network/', "", $query);
+        $use_network = ($network_work_query == $query) ? true : false;
         $index_archive_name= self::index_data_base_name.$index_name;
         if(file_exists( CRAWL_DIR."/cache/$index_archive_name/no_network.txt")){
             $_REQUEST['network'] = false;
             //if default index says no network queries then no network queries
         }
-        if(!isset($_REQUEST['network']) || $_REQUEST['network'] == "true") {
+        if($use_network &&
+            (!isset($_REQUEST['network']) || $_REQUEST['network'] == "true")) {
             $queue_servers = $this->machineModel->getQueueServerUrls();
             if($queue_servers != array() && file_exists(
                 CRAWL_DIR.'/cache/'.self::index_data_base_name.
diff --git a/index.php b/index.php
index 4b63149..8e6b460 100755
--- a/index.php
+++ b/index.php
@@ -126,11 +126,13 @@ if(!PROFILE ) {
     $controller_name = "admin";
 }

-//check if mobile should be used or not
+//check if mobile css and formatting should be used or not
 $agent = $_SERVER['HTTP_USER_AGENT'];
+$is_admin = strcmp($controller_name, "admin") == 0;
 if((stristr($agent, "mobile") || stristr($agent, "fennec")) &&
-    !stristr($agent, "ipad") && (strcmp($controller_name, "admin") != 0
-    || !isset($_REQUEST['a']) || strcmp($_REQUEST['a'], "signin") !=0 )) {
+    !stristr($agent, "ipad") && (!$is_admin || ($is_admin &&
+    !(isset($_REQUEST['a']) || isset($_REQUEST['u']) ||
+        isset($_SESSION['USER_ID'] ))))) {
     define("MOBILE", true);
 } else {
     define("MOBILE", false);
ViewGit