2 include_once $gfplugins.'webcalendar/www/includes/init.php';
6 $keywords = getValue ( "keywords" );
7 $advanced = getValue ( "advanced" );
9 if ( strlen ( $keywords ) == 0 )
10 $error = translate("You must enter one or more search keywords") . ".";
14 $search_others = true;
16 if ( empty ( $users ) || empty ( $users[0] ) )
17 $search_others = false;
18 if ( $login == "__public__" && $public_access_others != "Y" )
19 $search_others = false;
20 if ( $readonly == "Y" || $single_user == "Y" )
21 $search_others = false;
26 <h2><?php etranslate("Search Results")?></h2>
29 if ( ! empty ( $error ) ) {
30 echo "<span style=\"font-weight:bold;\">" . translate("Error") . ":</span> $error";
33 $words = split ( " ", $keywords );
34 for ( $i = 0; $i < count ( $words ); $i++ ) {
35 // Note: we only search approved events
36 $sql = "SELECT webcal_entry.cal_id, webcal_entry.cal_name, " .
37 "webcal_entry.cal_date " .
38 "FROM webcal_entry, webcal_entry_user " .
39 "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " .
40 "AND webcal_entry_user.cal_status in ('A','W') " .
41 "AND webcal_entry_user.cal_login IN ( ";
42 if ( $search_others ) {
43 if ( empty ( $users[0] ) )
45 for ( $j = 0; $j < count ( $users ); $j++ ) {
48 $sql .= " '$users[$j]'";
53 if ( $search_others ) {
54 // Don't search confidential entries of other users.
55 $sql .= "AND ( webcal_entry_user.cal_login = '$login' OR " .
56 "( webcal_entry_user.cal_login != '$login' AND " .
57 "webcal_entry.cal_access = 'P' ) ) ";
59 $sql .= "AND ( UPPER(webcal_entry.cal_name) " .
60 "LIKE UPPER('%" . $words[$i] . "%') " .
61 "OR UPPER(webcal_entry.cal_description) " .
62 "LIKE UPPER('%" . $words[$i] . "%') ) " .
64 //echo "SQL: $sql<br />";
65 $res = dbi_query ( $sql );
67 while ( $row = dbi_fetch_row ( $res ) ) {
69 $idstr = strval ( $row[0] );
70 if ( empty ( $ids[$idstr] ) )
74 $info[$idstr] = "$row[1] (" . date_to_str ($row[2]) .
78 dbi_free_result ( $res );
83 $matches = count ( $ids );
86 echo "<span style=\"font-weight:bold;\">$matches " . translate("match found") . ".</span><br /><br />";
87 else if ( $matches > 0 )
88 echo "<span style=\"font-weight:bold;\">$matches " . translate("matches found") . ".</span><br /><br />";
90 echo translate("No matches found") . ".";
92 // now sort by number of hits
93 if ( empty ( $error ) ) {
96 for ( reset ( $ids ); $key = key ( $ids ); next ( $ids ) ) {
97 echo "<li><a class=\"nav\" href=\"view_entry.php?id=$key\">" . $info[$key] . "</a></li>\n";
105 <?php print_trailer(); ?>