Dotclear

Changeset 3030:1c346de31ad1 for inc


Ignore:
Timestamp:
07/03/15 10:44:49 (10 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add an blog option to disable internal search (404 on ?q= queries, search widget hidden), fixes #1888

Location:
inc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.core.php

    r3006 r3030  
    14301430                    array('use_smilies','boolean',false, 
    14311431                    'Show smilies on entries and comments'), 
     1432                    array('no_search','boolean',false, 
     1433                    'Disable search'), 
    14321434                    array('inc_subcats','boolean',false, 
    14331435                    'Include sub-categories in category page and category posts feed'), 
  • inc/dbschema/upgrade.php

    r3027 r3030  
    448448                              " AND setting_value = '/\\.php\$/i' "; 
    449449                    $core->con->execute($strReq); 
     450                    # Some new settings should be initialized, prepare db queries 
     451                    $strReq = 'INSERT INTO '.$core->prefix.'setting'. 
     452                              ' (setting_id,setting_ns,setting_value,setting_type,setting_label)'. 
     453                              ' VALUES(\'%s\',\'system\',\'%s\',\'boolean\',\'%s\')'; 
     454                    $core->con-execute(sprintf($strReq,'no_search','0','Disable internal search system')); 
    450455               } 
    451456 
  • inc/public/lib.urlhandlers.php

    r2919 r3030  
    226226          $core =& $GLOBALS['core']; 
    227227 
    228           $core->url->type='search'; 
    229  
    230           $GLOBALS['_search'] = !empty($_GET['q']) ? rawurldecode($_GET['q']) : ''; 
    231           if ($GLOBALS['_search']) { 
    232                $params = new ArrayObject(array('search' => $GLOBALS['_search'])); 
    233                $core->callBehavior('publicBeforeSearchCount',$params); 
    234                $GLOBALS['_search_count'] = $core->blog->getPosts($params,true)->f(0); 
    235           } 
    236  
    237           self::serveDocument('search.html'); 
     228          if ($core->blog->settings->system->no_search) { 
     229 
     230               # Search is disabled for this blog. 
     231               self::p404(); 
     232 
     233          } else { 
     234 
     235               $core->url->type='search'; 
     236 
     237               $GLOBALS['_search'] = !empty($_GET['q']) ? rawurldecode($_GET['q']) : ''; 
     238               if ($GLOBALS['_search']) { 
     239                    $params = new ArrayObject(array('search' => $GLOBALS['_search'])); 
     240                    $core->callBehavior('publicBeforeSearchCount',$params); 
     241                    $GLOBALS['_search_count'] = $core->blog->getPosts($params,true)->f(0); 
     242               } 
     243 
     244               self::serveDocument('search.html'); 
     245          } 
    238246     } 
    239247 
Note: See TracChangeset for help on using the changeset viewer.

Sites map