News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Calendar events in news topic

Started by Springer, August 24, 2004, 01:02:20 AM

Previous topic - Next topic

Springer

Is there any way to make calendar events become the news topic the day of the event?

Jack.R.Abbit™

#1
yes.  I don't know if this is the best way but it works so here it goes.  This is mostly code adapted from other parts of the sources.

search for this line in Subs.php:
$context['news_lines'] = explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))));

Add this after:
require_once($sourcedir . '/Calendar.php');
$low_date = strftime('%Y-%m-%d', forum_time(false) - 24 * 3600);
$high_date = strftime('%Y-%m-%d', forum_time(false));
$events = calendarEventArray($low_date, $high_date, false);
$day = (int) strftime('%d', forum_time());
$duplicates = array();
if (isset($events[$day]))
foreach ($events[$day] as $ev => $event)
{
if (count(array_intersect($user_info['groups'], $event['allowed_groups'])) != 0 || allowedTo('admin_forum'))
{
$this_event = &$events[$day][$ev];
$this_event['href'] = $scripturl . '?topic=' . $this_event['topic'] . '.0';
if (isset($duplicates[$this_event['topic']]) && $duplicates[$this_event['topic']] == $this_event['title'])
unset($events[$i][$ev]);
$duplicates[$this_event['topic']] = $this_event['title'];
}
else
unset($events[$day][$ev]);
if (isset($this_event))
$context['news_lines'][] = '[url=' . $this_event['href'] . ']' . $this_event['title'] . '[/url]';
}

You will also need to add "$sourcedir" to the list of globals for the function we are modifying here... setupThemeContext()

EDIT: I've just added this feature to my Calendar Pack (still not released until SMF 1.0 Final)

Advertisement: