egroupware_official/calendar/search.php

98 lines
3.4 KiB
PHP
Raw Normal View History

2000-08-18 05:24:22 +02:00
<?php php_track_vars?>
<?php
/**************************************************************************\
* phpGroupWare - Calendar *
* http://www.phpgroupware.org *
* Based on Webcalendar by Craig Knudsen <cknudsen@radix.net> *
* http://www.radix.net/~cknudsen *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_info["flags"] = array("currentapp" => "calendar", "enable_calendar_class" => True, "enable_nextmatchs_class" => True);
2000-08-18 05:24:22 +02:00
if (! $keywords) {
// If we reach this it becuase they didn't search for anything,
// attempt to send them back to where they where.
Header("Location: " . $phpgw->link($from,"date=$datemonth=$month&day=$day&year=$year"));
}
2000-08-18 05:24:22 +02:00
include("../header.inc.php");
$error = "";
2000-08-18 05:24:22 +02:00
if (strlen($keywords) == 0)
2000-09-07 22:49:55 +02:00
$error = lang("You must enter one or more search keywords.");
2000-08-18 05:24:22 +02:00
$matches = 0;
?>
2000-09-07 22:49:55 +02:00
<H2><FONT COLOR="<?php echo $H2COLOR . "\">" . lang("Search Results"); ?></FONT></H2>
2000-08-18 05:24:22 +02:00
<?php
// There is currently a problem searching in with repeated events.
// It spits back out the date it was entered. I would like to to say that
// it is a repeated event.
if (strlen($error)) {
2000-09-07 22:49:55 +02:00
echo "<B>" . lang("Error") . ":</B> $error";
2000-08-18 05:24:22 +02:00
} else {
$ids = array();
$words = split(" ", $keywords);
for ($i = 0; $i < count($words); $i++) {
2000-12-02 09:17:19 +01:00
$sql = "SELECT DISTINCT calendar_entry.cal_id, calendar_entry.cal_name, "
. "calendar_entry.cal_datetime "
. "FROM calendar_entry, calendar_entry_user "
. "WHERE "
. "(UPPER(calendar_entry.cal_name) LIKE UPPER('%".$words[$i]."%') OR "
. " UPPER(calendar_entry.cal_description) LIKE UPPER('%".$words[$i]."%')) AND "
. "calendar_entry_user.cal_id=calendar_entry.cal_id AND "
. "(((calendar_entry_user.cal_login=".$phpgw_info["user"]["account_id"].") AND "
. "(calendar_entry.cal_access='private')) "
. $phpgw->calendar->group_search()
. "OR calendar_entry.cal_access='public') "
. "ORDER BY cal_datetime";
2000-08-18 05:24:22 +02:00
$phpgw->db->query($sql);
while ($phpgw->db->next_record()) {
$matches++;
$ids[strval( $phpgw->db->f(0) )]++;
$info[strval( $phpgw->db->f(0) )] = $phpgw->db->f(1) . " ("
2000-12-02 09:17:19 +01:00
. $phpgw->common->show_date($phpgw->db->f(2)) . ")";
2000-08-18 05:24:22 +02:00
}
}
}
if ($matches > 0)
$matches = count($ids);
if ($matches == 1)
echo "<B>1 match found.</B><P>";
else if ($matches > 0)
2000-09-07 22:49:55 +02:00
echo "<B>" . lang("x matches found",$matches) . ".</B><P>";
2000-08-18 05:24:22 +02:00
else
2000-09-07 22:49:55 +02:00
$error = lang("no matches found.");
2000-08-18 05:24:22 +02:00
// now sort by number of hits
if (! strlen($error)) {
arsort ($ids);
for (reset($ids); $key = key($ids); next($ids)) {
echo "<LI><A HREF=\"" . $phpgw->link("view.php","id=$key") . "\">" . $info[$key] . "</A>\n";
2000-08-18 05:24:22 +02:00
}
} else {
echo $error;
}
?>
<P>
<?php
$phpgw->common->phpgw_footer();
?>