" . $vocab["advanced_search"] . " "; echo "
"; echo $vocab["search_for"] . " :   "; echo ucfirst( $vocab["from"]). " : "; genDateSelector ("", $day, $month, $year,""); echo "  
(".$vocab["dans les champs suivants : "]."".$vocab["sum_by_creator"]." - ".$vocab["sum_by_descrip"]." - ".$vocab["match_descr"].")
"; } if (!$search_str) { echo "

" . $vocab["invalid_search"] . "

"; include "trailer.inc.php"; exit; } # now is used so that we only display entries newer than the current time $search_date=mktime(0,0,0,$month,$day,$year); echo "

" . $vocab["search_results"] . " \"$search_str\" (".$vocab["from"]." : ".strftime($dformat, $search_date).")

\n"; $now = mktime(0, 0, 0, $month, $day, $year); # This is the main part of the query predicate, used in both queries: $sql_pred = "( " . sql_syntax_caseless_contains("E.create_by", $search_text) . " OR " . sql_syntax_caseless_contains("E.name", $search_text) . " OR " . sql_syntax_caseless_contains("E.description", $search_text) . ") "; // Si l'utilisateur n'est pas administrateur, seuls les domaines auxquels il a accès sont pris en compte if(authGetUserLevel(getUserName(),-1) < 5) $sql_pred .= " and ((j.login='".$_SESSION['login']."' and j.id_area=a.id and a.access='r') or (a.access='a')) and R.area_id =a.id "; $sql_pred .= " AND E.end_time > $now"; # The first time the search is called, we get the total # number of matches. This is passed along to subsequent # searches so that we don't have to run it for each page. if(!isset($total)) $sql2 = "SELECT distinct E.id FROM grr_entry E, grr_room R"; // Si l'utilisateur n'est pas administrateur, seuls les domaines auxquels il a accès sont pris en compte // On adapte la requête (voir $sql_pred plus haut) if(authGetUserLevel(getUserName(),-1) < 5) $sql2 .= ", grr_j_user_area j, grr_area a "; $sql2 .= " WHERE $sql_pred AND E.room_id = R.id"; $result2 = sql_query($sql2); $total = sql_count($result2); if($total <= 0) { echo "" . $vocab["nothing_found"] . "\n"; include "trailer.inc.php"; exit; } else { // Affichage d'un lien pour format imprimable if ( !isset($_GET['pview']) or ($_GET['pview'] != 1)) { echo '

' . $vocab["ppreview"] . '

'; } } if(!isset($search_pos) || ($search_pos <= 0)) $search_pos = 0; elseif($search_pos >= $total) $search_pos = $total - ($total % $search["count"]); # Now we set up the "real" query using LIMIT to just get the stuff we want. $sql = "SELECT distinct E.id, E.create_by, E.name, E.description, E.start_time, R.area_id, R.room_name FROM grr_entry E, grr_room R "; // Si l'utilisateur n'est pas administrateur, seuls les domaines auxquels il a accès sont pris en compte // On adapte la requête (voir $sql_pred plus haut) if(authGetUserLevel(getUserName(),-1) < 5) $sql .= ", grr_j_user_area j, grr_area a "; $sql .=" WHERE $sql_pred AND E.room_id = R.id ORDER BY E.start_time asc " . sql_syntax_limit($search["count"], $search_pos); # this is a flag to tell us not to display a "Next" link $result = sql_query($sql); if (! $result) fatal_error(0, sql_error()); $num_records = sql_count($result); $has_prev = $search_pos > 0; $has_next = $search_pos < ($total-$search["count"]); if($has_prev || $has_next) { echo "" . $vocab["records"] . ($search_pos+1) . $vocab["through"] . ($search_pos+$num_records) . $vocab["of"] . $total . "
"; # display a "Previous" button if necessary if($has_prev) { echo ""; } echo "" . $vocab["previous"] . ""; if($has_prev) echo ""; # print a separator for Next and Previous echo(" | "); # display a "Previous" button if necessary if($has_next) { echo ""; } echo "". $vocab["next"] .""; if($has_next) echo ""; } ?>

"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // generate a link to the day.php $link = getdate($row[4]); echo ""; echo "\n"; } echo "
$row[6] - $vocab[view]" . htmlspecialchars($row[1]) . "" . htmlspecialchars($row[2]) . "" . htmlspecialchars($row[3]) . " " . time_date_string($row[4],$dformat) . "
\n"; include "trailer.inc.php"; ?>