| | @@ -739,11 +739,11 @@ |
| 739 | 739 | |
| 740 | 740 | db_find_and_open_repository(0, 0); |
| 741 | 741 | verify_all_options(); |
| 742 | 742 | if( g.argc<3 ) return; |
| 743 | 743 | login_set_capabilities("s", 0); |
| 744 | | - if( search_restrict(srchFlags, 1)==0 ){ |
| 744 | + if( search_restrict(srchFlags)==0 && (srchFlags & SRCH_HELP)==0 ){ |
| 745 | 745 | const char *zC1 = 0, *zPlural = "s"; |
| 746 | 746 | if( srchFlags & SRCH_TECHNOTE ){ zC1 = "technote"; } |
| 747 | 747 | if( srchFlags & SRCH_TKT ){ zC1 = "ticket"; } |
| 748 | 748 | if( srchFlags & SRCH_FORUM ){ zC1 = "forum"; zPlural = ""; } |
| 749 | 749 | if( srchFlags & SRCH_DOC ){ zC1 = "document"; } |
| | @@ -861,11 +861,11 @@ |
| 861 | 861 | ** the revised search flags mask. |
| 862 | 862 | ** |
| 863 | 863 | ** If bFlex is true, that means allow through the SRCH_HELP option |
| 864 | 864 | ** even if it is not explicitly enabled. |
| 865 | 865 | */ |
| 866 | | -unsigned int search_restrict(unsigned int srchFlags, int bFlex){ |
| 866 | +unsigned int search_restrict(unsigned int srchFlags){ |
| 867 | 867 | static unsigned int knownGood = 0; |
| 868 | 868 | static unsigned int knownBad = 0; |
| 869 | 869 | static const struct { unsigned m; const char *zKey; } aSetng[] = { |
| 870 | 870 | { SRCH_CKIN, "search-ci" }, |
| 871 | 871 | { SRCH_DOC, "search-doc" }, |
| | @@ -888,11 +888,10 @@ |
| 888 | 888 | knownGood |= m; |
| 889 | 889 | }else{ |
| 890 | 890 | knownBad |= m; |
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | | - if( bFlex ) knownBad &= ~SRCH_HELP; |
| 894 | 893 | return srchFlags & ~knownBad; |
| 895 | 894 | } |
| 896 | 895 | |
| 897 | 896 | /* |
| 898 | 897 | ** When this routine is called, there already exists a table |
| | @@ -1296,11 +1295,11 @@ |
| 1296 | 1295 | int nLimit = db_get_int("search-limit", 100); |
| 1297 | 1296 | |
| 1298 | 1297 | if( P("searchlimit")!=0 ){ |
| 1299 | 1298 | nLimit = atoi(P("searchlimit")); |
| 1300 | 1299 | } |
| 1301 | | - srchFlags = search_restrict(srchFlags, 1); |
| 1300 | + srchFlags = search_restrict(srchFlags) | (srchFlags & SRCH_HELP); |
| 1302 | 1301 | if( srchFlags==0 ) return 0; |
| 1303 | 1302 | search_sql_setup(g.db); |
| 1304 | 1303 | add_content_sql_commands(g.db); |
| 1305 | 1304 | db_multi_exec( |
| 1306 | 1305 | "CREATE TEMP TABLE x(label,url,score,id,date,snip);" |
| | @@ -1365,29 +1364,35 @@ |
| 1365 | 1364 | ** |
| 1366 | 1365 | ** 0x02 Show nothing if search is disabled. |
| 1367 | 1366 | ** |
| 1368 | 1367 | ** Return true if there are search results. |
| 1369 | 1368 | */ |
| 1370 | | -int search_screen(unsigned srchFlags, int mFlags){ |
| 1369 | +int search_screen(unsigned srchAllowed, int mFlags){ |
| 1371 | 1370 | const char *zType = 0; |
| 1372 | 1371 | const char *zClass = 0; |
| 1373 | 1372 | const char *zDisable1; |
| 1374 | 1373 | const char *zDisable2; |
| 1375 | 1374 | const char *zPattern; |
| 1376 | 1375 | int fDebug = PB("debug"); |
| 1377 | 1376 | int haveResult = 0; |
| 1378 | | - srchFlags = search_restrict(srchFlags, 0); |
| 1379 | | - switch( srchFlags ){ |
| 1377 | + int srchThisTime; |
| 1378 | + const char *zY = PD("y","all"); |
| 1379 | + if( zY[0]=='h' && zY[1]==0 ){ |
| 1380 | + srchAllowed = search_restrict(srchAllowed) | (srchAllowed & SRCH_HELP); |
| 1381 | + }else{ |
| 1382 | + srchAllowed = search_restrict(srchAllowed); |
| 1383 | + } |
| 1384 | + switch( srchAllowed ){ |
| 1380 | 1385 | case SRCH_CKIN: zType = " Check-ins"; zClass = "Ckin"; break; |
| 1381 | 1386 | case SRCH_DOC: zType = " Docs"; zClass = "Doc"; break; |
| 1382 | 1387 | case SRCH_TKT: zType = " Tickets"; zClass = "Tkt"; break; |
| 1383 | 1388 | case SRCH_WIKI: zType = " Wiki"; zClass = "Wiki"; break; |
| 1384 | 1389 | case SRCH_TECHNOTE: zType = " Tech Notes"; zClass = "Note"; break; |
| 1385 | 1390 | case SRCH_FORUM: zType = " Forum"; zClass = "Frm"; break; |
| 1386 | 1391 | case SRCH_HELP: zType = " Help"; zClass = "Hlp"; break; |
| 1387 | 1392 | } |
| 1388 | | - if( srchFlags==0 ){ |
| 1393 | + if( srchAllowed==0 ){ |
| 1389 | 1394 | if( mFlags & 0x02 ) return 0; |
| 1390 | 1395 | zDisable1 = " disabled"; |
| 1391 | 1396 | zDisable2 = " disabled"; |
| 1392 | 1397 | zPattern = ""; |
| 1393 | 1398 | }else{ |
| | @@ -1400,42 +1405,46 @@ |
| 1400 | 1405 | @ <div class='searchForm searchForm%s(zClass)'> |
| 1401 | 1406 | }else{ |
| 1402 | 1407 | @ <div class='searchForm'> |
| 1403 | 1408 | } |
| 1404 | 1409 | @ <input type="text" name="s" size="40" value="%h(zPattern)"%s(zDisable1)> |
| 1405 | | - if( (mFlags & 0x01)!=0 && (srchFlags & (srchFlags-1))!=0 ){ |
| 1406 | | - static const struct { const char *z; const char *zNm; unsigned m; } aY[] = { |
| 1410 | + srchThisTime = srchAllowed; |
| 1411 | + if( (mFlags & 0x01)!=0 && (srchAllowed & (srchAllowed-1))!=0 ){ |
| 1412 | + static const struct { |
| 1413 | + const char *z; |
| 1414 | + const char *zNm; |
| 1415 | + unsigned m; |
| 1416 | + } aY[] = { |
| 1407 | 1417 | { "all", "All", SRCH_ALL }, |
| 1408 | 1418 | { "c", "Check-ins", SRCH_CKIN }, |
| 1409 | 1419 | { "d", "Docs", SRCH_DOC }, |
| 1410 | 1420 | { "t", "Tickets", SRCH_TKT }, |
| 1411 | 1421 | { "w", "Wiki", SRCH_WIKI }, |
| 1412 | 1422 | { "e", "Tech Notes", SRCH_TECHNOTE }, |
| 1413 | 1423 | { "f", "Forum", SRCH_FORUM }, |
| 1414 | 1424 | { "h", "Help", SRCH_HELP }, |
| 1415 | 1425 | }; |
| 1416 | | - const char *zY = PD("y","all"); |
| 1417 | | - unsigned newFlags = srchFlags; |
| 1418 | 1426 | int i; |
| 1419 | 1427 | @ <select size='1' name='y'> |
| 1420 | 1428 | for(i=0; i<count(aY); i++){ |
| 1421 | | - if( (aY[i].m & srchFlags)==0 ) continue; |
| 1429 | + if( (aY[i].m & srchAllowed)==0 ) continue; |
| 1430 | + if( aY[i].m==SRCH_HELP && fossil_strcmp(zY,"h")!=0 |
| 1431 | + && search_restrict(SRCH_HELP)==0 ) continue; |
| 1422 | 1432 | cgi_printf("<option value='%s'", aY[i].z); |
| 1423 | 1433 | if( fossil_strcmp(zY,aY[i].z)==0 ){ |
| 1424 | | - newFlags &= aY[i].m; |
| 1434 | + srchThisTime &= aY[i].m; |
| 1425 | 1435 | cgi_printf(" selected"); |
| 1426 | 1436 | } |
| 1427 | 1437 | cgi_printf(">%s</option>\n", aY[i].zNm); |
| 1428 | 1438 | } |
| 1429 | 1439 | @ </select> |
| 1430 | | - srchFlags = newFlags; |
| 1431 | 1440 | } |
| 1432 | 1441 | if( fDebug ){ |
| 1433 | 1442 | @ <input type="hidden" name="debug" value="1"> |
| 1434 | 1443 | } |
| 1435 | 1444 | @ <input type="submit" value="Search%s(zType)"%s(zDisable2)> |
| 1436 | | - if( srchFlags==0 ){ |
| 1445 | + if( srchAllowed==0 && srchThisTime==0 ){ |
| 1437 | 1446 | @ <p class="generalError">Search is disabled</p> |
| 1438 | 1447 | } |
| 1439 | 1448 | @ </div></form> |
| 1440 | 1449 | while( fossil_isspace(zPattern[0]) ) zPattern++; |
| 1441 | 1450 | if( zPattern[0] ){ |
| | @@ -1442,11 +1451,11 @@ |
| 1442 | 1451 | if( zClass ){ |
| 1443 | 1452 | @ <div class='searchResult searchResult%s(zClass)'> |
| 1444 | 1453 | }else{ |
| 1445 | 1454 | @ <div class='searchResult'> |
| 1446 | 1455 | } |
| 1447 | | - if( search_run_and_output(zPattern, srchFlags, fDebug)==0 ){ |
| 1456 | + if( search_run_and_output(zPattern, srchThisTime, fDebug)==0 ){ |
| 1448 | 1457 | @ <p class='searchEmpty'>No matches for: <span>%h(zPattern)</span></p> |
| 1449 | 1458 | } |
| 1450 | 1459 | @ </div> |
| 1451 | 1460 | haveResult = 1; |
| 1452 | 1461 | } |
| | @@ -2245,11 +2254,11 @@ |
| 2245 | 2254 | void search_rebuild_index(void){ |
| 2246 | 2255 | fossil_print("rebuilding the search index..."); |
| 2247 | 2256 | fflush(stdout); |
| 2248 | 2257 | search_create_index(); |
| 2249 | 2258 | search_fill_index(); |
| 2250 | | - search_update_index(search_restrict(SRCH_ALL, 0)); |
| 2259 | + search_update_index(search_restrict(SRCH_ALL)); |
| 2251 | 2260 | if( db_table_exists("repository","chat") ){ |
| 2252 | 2261 | chat_rebuild_index(1); |
| 2253 | 2262 | } |
| 2254 | 2263 | fossil_print(" done\n"); |
| 2255 | 2264 | } |
| 2256 | 2265 | |