2008-10-29, 05:48 PM
2008-10-29, 05:48 PM
2008-10-30, 02:28 AM
Nice.
Will come in handy for some holidays.
Will come in handy for some holidays.
2008-10-30, 03:40 AM
Hey, this is cool!
Would there be a way to add a warning within a few days of an event occurring?
Would there be a way to add a warning within a few days of an event occurring?
2008-10-30, 01:02 PM
(2008-10-30, 03:40 AM)Bey Brad Wrote: [ -> ]Hey, this is cool!
Would there be a way to add a warning within a few days of an event occurring?
Yes, you can do this already.
Open inc/plugins/calendar_warner.php and find:
$query = $db->query("SELECT e.*, cp.gid, cp.canviewcalendar
FROM ".TABLE_PREFIX."events e
LEFT JOIN ".TABLE_PREFIX."calendarpermissions cp ON (e.cid=cp.cid AND cp.gid='".$mybb->user['usergroup']."')
WHERE private='0' AND visible='1'
AND starttime<='".TIME_NOW."'
AND ((endtime='0' AND (starttime+86400)>='".time()."') OR endtime>='".time()."')");
Replace with:
$days_before = 5;
$days_after = 0;
$starttime = TIME_NOW-($days_before*86400);
$endtime = TIME_NOW-($days_after*86400);
$query = $db->query("SELECT e.*, cp.gid, cp.canviewcalendar
FROM ".TABLE_PREFIX."events e
LEFT JOIN ".TABLE_PREFIX."calendarpermissions cp ON (e.cid=cp.cid AND cp.gid='".$mybb->user['usergroup']."')
WHERE private='0' AND visible='1'
AND starttime<='".$starttime."'
AND ((endtime='0' AND (starttime+86400)>='".$endtime."') OR endtime>='".$endtime."')");
2008-10-30, 04:45 PM
Perfect. I can use this plugin now. Thanks!
2008-11-03, 08:59 PM
Is there any way to exclude birthdays from this?
2008-11-04, 07:00 PM
A birthday isn't an event, and so it isn't shown anyway
2008-11-05, 02:02 AM
(2008-11-04, 07:00 PM)Paretje Wrote: [ -> ]A birthday isn't an event, and so it isn't shown anyway
Ahh sorry!
I saw that birthdays are on the calendar, so I thought it would be listed.
2008-11-05, 01:43 PM
Nice plugin. Great job.
2009-04-07, 05:08 AM
Hello Paretja,
I recently installed your Calendar Warner plug-in, then found your code modification, so that the administrator can specify the number of days before and after "today" for which events will be displayed. Unfortunately, the mod. that you posted on 10-30-2008 did not work as I expected. I made changes to the SQL query and to the way the result is presented. My code still suffers from not taking into account the user's time zone and daylight savings time. Perhaps someone else can tackle that problem. Here is what I ended up with for the calendar_warner.php:
Could you make it possible for the administrator to set $daysBefore and $daysAfter in the Admin CP?
I recently installed your Calendar Warner plug-in, then found your code modification, so that the administrator can specify the number of days before and after "today" for which events will be displayed. Unfortunately, the mod. that you posted on 10-30-2008 did not work as I expected. I made changes to the SQL query and to the way the result is presented. My code still suffers from not taking into account the user's time zone and daylight savings time. Perhaps someone else can tackle that problem. Here is what I ended up with for the calendar_warner.php:
<?php
/***************************************************************************
*
* Calendar Warner for MyBB
* Copyright: © 2007-2008 Online - Urbanus
*
* Website: http://www.Online-Urbanus.be
*
* Last modified: 7/4/2009 by Gary Trachier (trachier at ruralvt dot com)
*
***************************************************************************/
/***************************************************************************
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
***************************************************************************/
if(!defined("IN_MYBB"))
{
die("This file cannot be accessed directly.");
}
$plugins->add_hook("pre_output_page", "calendar_warner_run");
function calendar_warner_info()
{
return array(
"name" => "Calender Warner",
"description" => "This plugin shows a warning when there is an event on the calendar.",
"website" => "http://www.Online-Urbanus.be",
"author" => "Paretje",
"authorsite" => "http://www.Online-Urbanus.be",
"version" => "1.1",
"guid" => "1f6b62cb0b189a094070d89f4715dbf0",
"compatibility" => "14*"
);
}
function calendar_warner_activate()
{
}
function calendar_warner_deactivate()
{
}
function calendar_warner_run($page)
{
global $mybb, $db, $theme;
$daysBefore = 1; // days before the current day ("yesterday" === 1)
$daysAfter = 5; // days after the current day ("one week" === 7)
$startTime = (TIME_NOW - (TIME_NOW % 86400)) - ($daysBefore * 86400); // earliest time that we are interested in
$endTime = (TIME_NOW - (TIME_NOW % 86400)) + (($daysAfter + 1) * 86400) - 1; // latest time that we are interested in
$queryString = "
SELECT e.*, cp.gid, cp.canviewcalendar
FROM mybb_events e
LEFT JOIN mybb_calendarpermissions cp
ON (e.cid=cp.cid AND cp.gid='2')
WHERE private='0'
AND visible='1'
AND ((usingtime='0' AND starttime>='{$startTime}' AND starttime<='{$endTime}')
OR (usingtime='1' AND NOT (endtime<'{$startTime}' OR starttime>'{$endTime}')))
";
// print "<pre>$queryString</pre>";
$query = $db->query ($queryString); // fetch from the database
if ($db->num_rows($query) > 0) { // are there any results?
$data = "<table border='0' cellspacing='" . $theme['borderwidth'] . "' cellpadding='" . $theme['tablespace'] . "' class='tborder'>
<thead>
<tr>
<td class='thead' colspan='3'>
<div class='expcolimage'>
<img src='images/collapse.gif' id='boardstats_img' class='expander' alt='[-]' title='[-]' name='boardstats_img'>
</div>
<div>
<strong>Recent and up-coming events from the calendar</strong>
</div>
</td>
</tr>
<tr>
<td class='thead'>Event</td>
<td class='thead'>Description</td>
<td class='thead'>Begins</td>
</tr>
</thead>
<tbody style='' id='boardstats_e'>"; // begin the table
while($events = $db->fetch_array($query)) {
if($events['gid'] != $mybb->user['usergroup'] || $events['canviewcalendar'] == 1) {
$data .= "
<tr class='trow1'>
<td>
<strong><a href='" . get_event_link($events['eid']) . "'>" . $events['name'] . "</a></strong>
</td>
<td>
" . $events['description'] . "
</td>
<td>
" . my_date($mybb->settings['dateformat'], $events['starttime']) . "
</td>
</tr>";
}
}
$data .= "</tbody></table><br />"; // end the table
preg_match('#'.preg_quote("<div id=\"content\">").'#i', $page, $matches);
if($matches[0]) {
$page = str_replace($matches[0], "<div id=\"content\">\n".$data, $page);
}
}
return $page;
}
?>
Could you make it possible for the administrator to set $daysBefore and $daysAfter in the Admin CP?