if ($offset == $today) { $row_class = 'quote'; } // Old condition removed... //if ($days[$cur]) if ($cur != ' ') { $url = append_sid('calendar_scheduler.' . PHP_EXT . '?d=' . $offset . '&fid=' . $fid); $cur = sprintf('<a href="%s" class="gensmall"><b>%s</b></a>', $url, $cur); } $template->assign_block_vars('row.cell', array('CLASS' => $row_class, 'DAY' => $cur)); $offset = $offset + 86400; } } // list of topics $period = $mode == 'hour' ? 3600 - 1 : ''; $title = get_calendar_title_date($start_date, $period); // move events to topic_rowset format $topic_rowset = array(); for ($i = 0; $i < sizeof($events); $i++) { $row['topic_id'] = $events[$i]['event_id']; $row['topic_title'] = $events[$i]['event_title']; $row['topic_replies'] = $events[$i]['event_replies']; $row['topic_type'] = $events[$i]['event_type']; $row['topic_status'] = $events[$i]['event_status']; $row['topic_moved_id'] = $events[$i]['event_moved_id']; $row['post_time'] = $events[$i]['event_last_time']; $row['user_id'] = $events[$i]['event_author_id']; $row['username'] = $events[$i]['event_author']; $row['post_username'] = $events[$i]['event_author']; $row['topic_time'] = $events[$i]['event_time']; $row['id2'] = $events[$i]['event_last_author_id'];
function get_event_topics(&$events, &$number, $start_date, $end_date, $limit = false, $start = 0, $max_limit = -1, $fid = '') { global $tree, $template, $lang, $images, $user, $db, $cache, $config, $bbcode; if (!class_exists('bbcode')) { include IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT; } if (empty($bbcode)) { $bbcode = new bbcode(); } // get some parameter $topic_title_length = isset($config['calendar_title_length']) ? intval($config['calendar_title_length']) : 30; $topic_text_length = isset($config['calendar_text_length']) ? intval($config['calendar_text_length']) : 200; if ($max_limit < 0) { $max_limit = $config['topics_per_page']; } // get the forums authorized (compliency with categories hierarchy v2 mod) $cat_hierarchy = function_exists(get_auth_keys); $s_forums_ids = ''; if (!$cat_hierarchy) { // standard read $is_auth = array(); $is_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data); // forum or cat asked $is_ask = array(); if ($fid == 'Root' || $fid == POST_CAT_URL . 0) { $fid = ''; } if (!empty($fid)) { $type = substr($fid, 0, 1); $id = intval(substr($fid, 1)); if ($type == POST_CAT_URL) { $sql = "SELECT forum_id FROM " . FORUMS_TABLE . " WHERE parent_id = '" . $id . "'"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $is_ask[$row['forum_id']] = true; } $db->sql_freeresult($result); } elseif ($type == POST_FORUM_URL) { $is_ask[$id] = true; } else { return; } } // get the list of authorized forums while (list($forum_id, $forum_auth) = each($is_auth)) { if ($forum_auth['auth_read'] && (empty($fid) || isset($is_ask[$forum_id]))) { $s_forum_ids .= (empty($s_forum_ids) ? '' : ', ') . $forum_id; } } } else { if (empty($fid) || $fid == POST_CAT_URL . 0) { $fid = 'Root'; } // get auth key $keys = array(); $keys = get_auth_keys($fid, true, -1, -1, 'auth_read'); for ($i = 0; $i < sizeof($keys['id']); $i++) { if ($tree['type'][$keys['idx'][$i]] == POST_FORUM_URL && $tree['auth'][$keys['id'][$i]]['auth_read']) { $s_forum_ids .= (empty($s_forum_ids) ? '' : ', ') . $tree['id'][$keys['idx'][$i]]; } } } // no forums authed, return if (empty($s_forum_ids)) { return; } // select topics $sql_forums_field = ''; $sql_forums_file = ''; $sql_forums_match = ''; if (!$cat_hierarchy) { $sql_forums_field = ', f.forum_name'; $sql_forums_file = ', ' . FORUMS_TABLE . ' AS f'; $sql_forums_match = ' AND f.forum_id = t.forum_id'; } $sql = "SELECT\n\t\t\t\t\tt.*,\n\t\t\t\t\tp.poster_id, p.post_username, p.post_text, p.enable_bbcode, p.enable_html, p.enable_smilies,\n\t\t\t\t\tu.username, u.user_active, u.user_color,\n\t\t\t\t\tlp.poster_id AS lp_poster_id,\n\t\t\t\t\tlu.username AS lp_username,\n\t\t\t\t\tlp.post_username AS lp_post_username,\n\t\t\t\t\tlp.post_time AS lp_post_time\n\t\t\t\t\t{$sql_forums_field}\n\t\t\tFROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . POSTS_TABLE . " AS lp, " . USERS_TABLE . " lu {$sql_forums_file}\n\t\t\tWHERE\n\t\t\t\tt.forum_id IN ({$s_forum_ids})\n\t\t\t\tAND p.post_id = t.topic_first_post_id\n\t\t\t\tAND u.user_id = p.poster_id\n\t\t\t\tAND lp.post_id = t.topic_last_post_id\n\t\t\t\tAND lu.user_id = lp.poster_id\n\t\t\t\tAND t.topic_calendar_time < {$end_date}\n\t\t\t\tAND (t.topic_calendar_time + t.topic_calendar_duration) >= {$start_date}\n\t\t\t\tAND t.topic_status <> " . TOPIC_MOVED . "\n\t\t\t\t{$sql_forums_match}\n\t\t\tORDER BY\n\t\t\t\tt.topic_calendar_time, t.topic_calendar_duration DESC, t.topic_last_post_id DESC"; $result = $db->sql_query($sql); // get the number of occurences $number = $db->sql_numrows($result); // if limit per page asked, limit the number of results if ($limit) { $db->sql_freeresult($result); $sql .= " LIMIT {$start}, {$max_limit}"; $result = $db->sql_query($sql); } $bbcode->allow_html = $user->data['user_allowhtml'] && $config['allow_html'] ? 1 : 0; $bbcode->allow_bbcode = $user->data['user_allowbbcode'] && $config['allow_bbcode'] ? 1 : 0; $bbcode->allow_smilies = $user->data['user_allowsmile'] && $config['allow_smilies'] ? 1 : 0; // read the items while ($row = $db->sql_fetchrow($result)) { // prepare the message $topic_author_id = $row['poster_id']; $topic_author = $row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username']; $topic_time = $row['topic_time']; $topic_last_author_id = $row['lp_poster_id']; $topic_last_author = $row['lp_poster_id'] == ANONYMOUS ? $row['lp_post_username'] : $row['lp_username']; $topic_last_time = $row['lp_post_time']; $topic_views = $row['topic_views']; $topic_replies = $row['topic_replies']; $topic_icon = $row['topic_icon']; $topic_title = $row['topic_title']; $message = htmlspecialchars($row['post_text']); $topic_calendar_time = $row['topic_calendar_time']; $topic_calendar_duration = $row['topic_calendar_duration']; $topic_link = append_sid(IP_ROOT_PATH . CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $row['topic_id']); $topic_title = censor_text($topic_title); $message = censor_text($message); $short_title = strlen($topic_title) > $topic_title_length + 3 ? substr($topic_title, 0, $topic_title_length) . '...' : $topic_title; // Convert and clean special chars! $topic_title = htmlspecialchars_clean($topic_title); $short_title = htmlspecialchars_clean($short_title); // SMILEYS IN TITLE - BEGIN if ($config['smilies_topic_title'] && !$lofi) { $topic_title = $bbcode->parse_only_smilies($topic_title); $short_title = $bbcode->parse_only_smilies($short_title); } // SMILEYS IN TITLE - END $dsp_topic_icon = ''; if (function_exists('get_icon_title')) { $dsp_topic_icon = get_icon_title($topic_icon, 0, POST_CALENDAR); } // parse the message $message = substr($message, 0, $topic_text_length); // remove HTML if not allowed if (!$config['allow_html'] && $row['enable_html']) { $message = preg_replace('#(<)([\\/]?.*?)(>)#is', "<\\2>", $message); } $message = $bbcode->parse($message); // get the date format $fmt = $lang['DATE_FORMAT_CALENDAR']; if (!empty($topic_calendar_duration)) { $fmt = $config['default_dateformat']; } // replace \n with <br /> //$message = preg_replace("/[\n\r]{1,2}/", '<br />', $message); // build the overview $sav_tpl = $template->_tpldata; $det_handler = '_overview_topic_' . $row['topic_id']; $template->set_filenames(array($det_handler => 'calendar_overview_topic.tpl')); $nav_desc = ''; if ($cat_hierarchy) { $nav_desc = make_cat_nav_tree(POST_FORUM_URL . $row['forum_id'], '', '', 'gensmall'); } else { $nav_desc = '<a href="' . append_sid(IP_ROOT_PATH . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $row['forum_id']) . '" class="gensmall">' . $row['forum_name'] . '</a>'; } $template->assign_vars(array('L_CALENDAR_EVENT' => $lang['Calendar_event'], 'L_AUTHOR' => $lang['Author'], 'L_TOPIC_DATE' => $lang['Date'], 'L_FORUM' => $lang['Forum'], 'L_VIEWS' => $lang['Views'], 'L_REPLIES' => $lang['Replies'], 'TOPIC_TITLE' => $dsp_topic_icon . ' ' . $topic_title, 'CALENDAR_EVENT' => get_calendar_title_date($topic_calendar_time, $topic_calendar_duration), 'AUTHOR' => $topic_author, 'TOPIC_DATE' => create_date($user->data['user_dateformat'], $topic_time, $config['board_timezone']), 'NAV_DESC' => $nav_desc, 'CALENDAR_MESSAGE' => $message, 'VIEWS' => $topic_views, 'REPLIES' => $topic_replies)); $template->assign_var_from_handle('_calendar_overview', $det_handler); $message = $template->_tpldata['.'][0]['_calendar_overview']; $template->_tpldata = $sav_tpl; // remove \n remaining from the template $message = preg_replace("/[\n\r]{1,2}/", '', $message); // store only the new values $new_row = array(); $new_row['event_id'] = POST_TOPIC_URL . $row['topic_id']; $new_row['event_author_id'] = $topic_author_id; $new_row['event_author'] = $topic_author; $new_row['event_author_active'] = $row['user_active']; $new_row['event_author_color'] = $row['user_color']; $new_row['event_time'] = $topic_time; $new_row['event_last_author_id'] = $topic_last_author_id; $new_row['event_last_author'] = $topic_last_author; $new_row['event_last_time'] = $topic_last_time; $new_row['event_replies'] = $topic_replies; $new_row['event_views'] = $topic_views; $new_row['event_type'] = $row['topic_type']; $new_row['event_status'] = $row['topic_status']; $new_row['event_moved_id'] = $row['topic_moved_id']; $new_row['event_last_id'] = $row['topic_last_post_id']; $new_row['event_forum_id'] = $row['forum_id']; $new_row['event_forum_name'] = $row['forum_name']; $new_row['event_icon'] = $topic_icon; $new_row['event_title'] = $topic_title; $new_row['event_short_title'] = $short_title; $new_row['event_message'] = $message; $new_row['event_calendar_time'] = $topic_calendar_time; $new_row['event_calendar_duration'] = $topic_calendar_duration; $new_row['event_link'] = $topic_link; $new_row['event_birthday'] = false; $new_row['event_txt_class'] = 'genmed'; $new_row['event_type_icon'] = '<img src="' . $images['icon_tiny_topic'] . '" style="vertical-align: bottom;" alt="" hspace="2" />'; $events[] = $new_row; } $db->sql_freeresult($result); }