Move over to own Repository :)
This commit is contained in:
489
root/portal/includes/functions.php
Normal file
489
root/portal/includes/functions.php
Normal file
@@ -0,0 +1,489 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package - Board3portal
|
||||
* @version $Id$
|
||||
* @copyright (c) kevin / saint ( http://www.board3.de/ ), (c) nickvergessen ( http://mods.flying-bits.org/ ), (c) redbull254 ( http://www.digitalfotografie-foren.de )
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get portal config
|
||||
$sql = 'SELECT *
|
||||
FROM ' . PORTAL_CONFIG_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$portal_config_name = $row['config_name'];
|
||||
$portal_config_value = $row['config_value'];
|
||||
$portal_config[$portal_config_name] = $portal_config_value;
|
||||
}
|
||||
|
||||
//
|
||||
include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
|
||||
|
||||
// fetch post for news & announce
|
||||
function phpbb_fetch_posts($forum_sql, $number_of_posts, $text_length, $time, $type)
|
||||
{
|
||||
global $db, $phpbb_root_path, $auth, $bbcode_bitfield, $user, $forum_id;
|
||||
|
||||
$from_forum = ($forum_sql) ? 't.forum_id IN (' . $forum_sql . ') AND' : '';
|
||||
$post_time = ($time == 0) ? '' : 't.topic_last_post_time > ' . (time() - $time * 86400) . ' AND';
|
||||
|
||||
|
||||
if ($type == 'announcements')
|
||||
{
|
||||
// only global announcements for announcements block
|
||||
$topic_type = '(( t.topic_type = ' . POST_ANNOUNCE . ') OR ( t.topic_type = ' . POST_GLOBAL . ')) AND';
|
||||
|
||||
|
||||
$sql = 'SELECT
|
||||
t.forum_id,
|
||||
t.topic_id,
|
||||
t.topic_last_post_id,
|
||||
t.topic_last_post_time,
|
||||
t.topic_time,
|
||||
t.topic_title,
|
||||
t.topic_attachment,
|
||||
t.topic_views,
|
||||
t.poll_title,
|
||||
t.topic_replies,
|
||||
t.forum_id,
|
||||
t.topic_poster,
|
||||
u.username,
|
||||
u.user_id,
|
||||
u.user_type,
|
||||
u.user_colour,
|
||||
p.post_id,
|
||||
p.post_time,
|
||||
p.post_text,
|
||||
p.post_attachment,
|
||||
p.enable_smilies,
|
||||
p.enable_bbcode,
|
||||
p.enable_magic_url,
|
||||
p.bbcode_bitfield,
|
||||
p.bbcode_uid
|
||||
FROM
|
||||
' . TOPICS_TABLE . ' AS t,
|
||||
' . USERS_TABLE . ' AS u,
|
||||
' . POSTS_TABLE . ' AS p
|
||||
WHERE
|
||||
' . $topic_type . '
|
||||
' . $from_forum . '
|
||||
' . $post_time . '
|
||||
t.topic_poster = u.user_id AND
|
||||
t.topic_first_post_id = p.post_id AND
|
||||
t.topic_status <> 2 AND
|
||||
t.topic_approved = 1
|
||||
|
||||
ORDER BY
|
||||
t.topic_time DESC';
|
||||
|
||||
|
||||
// query the database
|
||||
if(!($result = $db->sql_query_limit($sql, $number_of_posts)))
|
||||
{
|
||||
die('Could not query topic information for board3 Portal announcements section');
|
||||
}
|
||||
|
||||
//
|
||||
// fetch all postings
|
||||
//
|
||||
|
||||
// Instantiate BBCode if need be
|
||||
if ($bbcode_bitfield !== '')
|
||||
{
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
||||
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
||||
}
|
||||
$posts = array();
|
||||
$i = 0;
|
||||
while ( ($row = $db->sql_fetchrow($result)) && ( ($i < $number_of_posts) || ($number_of_posts == '0') ) )
|
||||
{
|
||||
if ( ($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0') )
|
||||
{
|
||||
if ($row['user_id'] != ANONYMOUS && $row['user_colour'])
|
||||
{
|
||||
$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
|
||||
}
|
||||
$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
|
||||
$len_check = $row['post_text'];
|
||||
$maxlen = $text_length;
|
||||
if (($text_length != 0) && (strlen($len_check) > $text_length))
|
||||
{
|
||||
$posts[$i]['post_text'] = censor_text(get_sub_taged_string(str_replace("\n", '<br/> ', $row['post_text']), $row['bbcode_uid'], $maxlen));
|
||||
$posts[$i]['striped'] = true;
|
||||
} else $posts[$i]['post_text'] = censor_text($row['post_text']);
|
||||
|
||||
$posts[$i]['topic_id'] = $row['topic_id'];
|
||||
$posts[$i]['topic_last_post_id'] = $row['topic_last_post_id'];
|
||||
$posts[$i]['forum_id'] = $row['forum_id'];
|
||||
$posts[$i]['topic_replies'] = $row['topic_replies'];
|
||||
$posts[$i]['topic_time'] = $user->format_date($row['topic_time']);
|
||||
$posts[$i]['topic_last_post_time'] = $row['topic_last_post_time'];
|
||||
$posts[$i]['topic_title'] = $row['topic_title'];
|
||||
$posts[$i]['username'] = $row['username'];
|
||||
$posts[$i]['user_id'] = $row['user_id'];
|
||||
$posts[$i]['user_type'] = $row['user_type'];
|
||||
$posts[$i]['user_user_colour'] = $row['user_colour'];
|
||||
$posts[$i]['poll'] = ($row['poll_title']) ? true : false;
|
||||
$posts[$i]['attachment'] = ($row['topic_attachment']) ? true : false;
|
||||
$posts[$i]['topic_views'] = ($row['topic_views']);
|
||||
|
||||
$message = $posts[$i]['post_text'];
|
||||
$message = str_replace("\n", '<br />', $message);
|
||||
|
||||
|
||||
if ($auth->acl_get('f_html', $forum_id))
|
||||
{
|
||||
$message = preg_replace('#<!\-\-(.*?)\-\->#is', '', $message); // Remove Comments from post content
|
||||
}
|
||||
// Second parse bbcode here
|
||||
if ($row['bbcode_bitfield'])
|
||||
{
|
||||
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
||||
}
|
||||
$message = smiley_text($message); // Always process smilies after parsing bbcodes
|
||||
$posts[$i]['post_text']= ap_validate($message);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
// return the result
|
||||
return $posts;
|
||||
}
|
||||
|
||||
// news - get last post
|
||||
|
||||
else if ($type == 'news_all')
|
||||
{
|
||||
// not show global announcements
|
||||
$topic_type = '( t.topic_type != ' . POST_ANNOUNCE . ' ) AND ( t.topic_type != ' . POST_GLOBAL . ') AND';
|
||||
}
|
||||
else
|
||||
{
|
||||
// only normal topic
|
||||
$topic_type = 't.topic_type = ' . POST_NORMAL . ' AND';
|
||||
}
|
||||
|
||||
|
||||
$sql = 'SELECT
|
||||
t.forum_id,
|
||||
t.topic_id,
|
||||
t.topic_last_post_id,
|
||||
t.topic_last_post_time,
|
||||
t.topic_time,
|
||||
t.topic_title,
|
||||
t.topic_attachment,
|
||||
t.topic_views,
|
||||
t.poll_title,
|
||||
t.topic_replies,
|
||||
t.forum_id,
|
||||
t.topic_poster,
|
||||
u.username,
|
||||
u.user_id,
|
||||
u.user_type,
|
||||
u.user_colour,
|
||||
p.post_id,
|
||||
p.post_time,
|
||||
p.post_text,
|
||||
p.post_attachment,
|
||||
p.enable_smilies,
|
||||
p.enable_bbcode,
|
||||
p.enable_magic_url,
|
||||
p.bbcode_bitfield,
|
||||
p.bbcode_uid
|
||||
FROM
|
||||
' . TOPICS_TABLE . ' AS t,
|
||||
' . USERS_TABLE . ' AS u,
|
||||
' . POSTS_TABLE . ' AS p
|
||||
WHERE
|
||||
' . $topic_type . '
|
||||
' . $from_forum . '
|
||||
' . $post_time . '
|
||||
t.topic_last_poster_id = u.user_id AND
|
||||
t.topic_last_post_id = p.post_id AND
|
||||
t.topic_status <> 2 AND
|
||||
t.topic_approved = 1
|
||||
|
||||
ORDER BY
|
||||
t.topic_last_post_time DESC';
|
||||
|
||||
|
||||
// query the database
|
||||
if(!($result = $db->sql_query_limit($sql, $number_of_posts)))
|
||||
{
|
||||
die('Could not query topic information for board Portal news section');
|
||||
}
|
||||
|
||||
//
|
||||
// fetch all postings
|
||||
//
|
||||
|
||||
// Instantiate BBCode if need be
|
||||
if ($bbcode_bitfield !== '')
|
||||
{
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
||||
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
||||
}
|
||||
$posts = array();
|
||||
$i = 0;
|
||||
while ( ($row = $db->sql_fetchrow($result)) && ( ($i < $number_of_posts) || ($number_of_posts == '0') ) )
|
||||
{
|
||||
if ( ($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0') )
|
||||
{
|
||||
if ($row['user_id'] != ANONYMOUS && $row['user_colour'])
|
||||
{
|
||||
$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
|
||||
}
|
||||
$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
|
||||
$len_check = $row['post_text'];
|
||||
$maxlen = $text_length;
|
||||
if (($text_length != 0) && (strlen($len_check) > $text_length))
|
||||
{
|
||||
$posts[$i]['post_text'] = censor_text(get_sub_taged_string(str_replace("\n", '<br/> ', $row['post_text']), $row['bbcode_uid'], $maxlen));
|
||||
$posts[$i]['striped'] = true;
|
||||
} else $posts[$i]['post_text'] = censor_text($row['post_text']);
|
||||
|
||||
|
||||
$posts[$i]['topic_id'] = $row['topic_id'];
|
||||
$posts[$i]['topic_last_post_id'] = $row['topic_last_post_id'];
|
||||
$posts[$i]['forum_id'] = $row['forum_id'];
|
||||
$posts[$i]['topic_replies'] = $row['topic_replies'];
|
||||
$posts[$i]['topic_time'] = $user->format_date($row['topic_last_post_time']);
|
||||
$posts[$i]['topic_last_post_time'] = $row['topic_last_post_time'];
|
||||
$posts[$i]['topic_title'] = $row['topic_title'];
|
||||
$posts[$i]['username'] = $row['username'];
|
||||
$posts[$i]['user_id'] = $row['user_id'];
|
||||
$posts[$i]['user_type'] = $row['user_type'];
|
||||
$posts[$i]['user_user_colour'] = $row['user_colour'];
|
||||
$posts[$i]['poll'] = ($row['poll_title']) ? true : false;
|
||||
$posts[$i]['attachment'] = ($row['topic_attachment']) ? true : false;
|
||||
$posts[$i]['topic_views'] = ($row['topic_views']);
|
||||
|
||||
$message = $posts[$i]['post_text'];
|
||||
$message = str_replace("\n", '<br/> ', $message);
|
||||
|
||||
|
||||
if ($auth->acl_get('f_html', $forum_id))
|
||||
{
|
||||
$message = preg_replace('#<!\-\-(.*?)\-\->#is', '', $message); // Remove Comments from post content
|
||||
}
|
||||
// Second parse bbcode here
|
||||
if ($row['bbcode_bitfield'])
|
||||
{
|
||||
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
||||
}
|
||||
$message = smiley_text($message); // Always process smilies after parsing bbcodes
|
||||
$posts[$i]['post_text']= ap_validate($message);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
// return the result
|
||||
return $posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Censor title, return short title
|
||||
*
|
||||
* @param $title string title to censor
|
||||
* @param $limit int short title character limit
|
||||
*
|
||||
*/
|
||||
function character_limit(&$title, $limit = 0)
|
||||
{
|
||||
$title = censor_text($title);
|
||||
if ($limit > 0)
|
||||
{
|
||||
return (strlen(utf8_decode($title)) > $limit + 3) ? truncate_string($title, $limit) . '...' : $title;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user avatar / barroved from RC4
|
||||
*
|
||||
* @param string $avatar Users assigned avatar name
|
||||
* @param int $avatar_type Type of avatar
|
||||
* @param string $avatar_width Width of users avatar
|
||||
* @param string $avatar_height Height of users avatar
|
||||
* @param string $alt Optional language string for alt tag within image, can be a language key or text
|
||||
*
|
||||
* @return string Avatar image
|
||||
*/
|
||||
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR')
|
||||
{
|
||||
global $user, $portal_config, $config, $phpbb_root_path, $phpEx;
|
||||
|
||||
if (empty($avatar) || !$avatar_type)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$avatar_img = '';
|
||||
|
||||
switch ($avatar_type)
|
||||
{
|
||||
case AVATAR_UPLOAD:
|
||||
$avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
|
||||
break;
|
||||
|
||||
case AVATAR_GALLERY:
|
||||
$avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
|
||||
break;
|
||||
}
|
||||
|
||||
$avatar_img .= $avatar;
|
||||
return '<img src="' . $avatar_img . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user rank title and image / barroved from RC4
|
||||
*
|
||||
* @param int $user_rank the current stored users rank id
|
||||
* @param int $user_posts the users number of posts
|
||||
* @param string &$rank_title the rank title will be stored here after execution
|
||||
* @param string &$rank_img the rank image as full img tag is stored here after execution
|
||||
* @param string &$rank_img_src the rank image source is stored here after execution
|
||||
*
|
||||
*/
|
||||
function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
|
||||
{
|
||||
global $ranks, $config;
|
||||
|
||||
if (empty($ranks))
|
||||
{
|
||||
global $cache;
|
||||
$ranks = $cache->obtain_ranks();
|
||||
}
|
||||
|
||||
if (!empty($user_rank))
|
||||
{
|
||||
$rank_title = (isset($ranks['special'][$user_rank]['rank_title'])) ? $ranks['special'][$user_rank]['rank_title'] : '';
|
||||
$rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : '';
|
||||
$rank_img_src = (!empty($ranks['special'][$user_rank]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!empty($ranks['normal']))
|
||||
{
|
||||
foreach ($ranks['normal'] as $rank)
|
||||
{
|
||||
if ($user_posts >= $rank['rank_min'])
|
||||
{
|
||||
$rank_title = $rank['rank_title'];
|
||||
$rank_img = (!empty($rank['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
|
||||
$rank_img_src = (!empty($rank['rank_image'])) ? $config['ranks_path'] . '/' . $rank['rank_image'] : '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Don't let them mess up the complete portal layout in cut messages and do some real AP magic
|
||||
|
||||
function is_valid_bbtag($str, $bbuid) {
|
||||
return (substr($str,0,1) == '[') && (strpos($str, ':'.$bbuid.']') > 0);
|
||||
}
|
||||
|
||||
function get_end_bbtag($tag, $bbuid) {
|
||||
$etag = '';
|
||||
for($i=0;$i<strlen($tag);$i++) {
|
||||
if ($tag[$i] == '[') $etag .= $tag[$i] . '/';
|
||||
else if (($tag[$i] == '=') || ($tag[$i] == ':')) {
|
||||
if ($tag[1] == '*') $etag .= ':m:'.$bbuid.']';
|
||||
else if (strpos($tag, 'list')) $etag .= ':u:'.$bbuid.']';
|
||||
else $etag .= ':'.$bbuid.']';
|
||||
break;
|
||||
} else $etag .= $tag[$i];
|
||||
}
|
||||
|
||||
return $etag;
|
||||
}
|
||||
|
||||
function get_next_word($str) {
|
||||
$ret = '';
|
||||
for($i=0;$i<strlen($str);$i++) {
|
||||
switch ($str[$i]) {
|
||||
case ' ': //$ret .= ' '; break; break;
|
||||
return $ret . ' ';
|
||||
case '\\':
|
||||
if ($str[$i+1] == 'n') return $ret . '\n';
|
||||
case '[': if ($i != 0) return $ret;
|
||||
default: $ret .= $str[$i];
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function get_sub_taged_string($str, $bbuid, $maxlen) {
|
||||
$sl = $str;
|
||||
$ret = '';
|
||||
$ntext = '';
|
||||
$lret = '';
|
||||
$i = 0;
|
||||
$cnt = $maxlen;
|
||||
$last = '';
|
||||
$arr = array();
|
||||
|
||||
while((strlen($ntext) < $cnt) && (strlen($sl) > 0)) {
|
||||
$sr = '';
|
||||
if (substr($sl, 0, 1) == '[') $sr = substr($sl,0,strpos($sl,']')+1);
|
||||
/* GESCHLOSSENE HTML-TAGS BEACHTEN */
|
||||
if (substr($sl, 0, 1) == '<') {
|
||||
$sr = substr($sl,0,strpos($sl,'>')+1);
|
||||
$ret .= $sr;
|
||||
} else if (is_valid_bbtag($sr, $bbuid)) {
|
||||
if ($sr[1] == '/') {
|
||||
/* entfernt das endtag aus dem tag array */
|
||||
$tarr = array();
|
||||
$j = 0;
|
||||
foreach ($arr as $elem) {
|
||||
if (strcmp($elem[1],$sr) != 0) $tarr[$j++] = $elem;
|
||||
}
|
||||
$arr = $tarr;
|
||||
} else {
|
||||
$arr[$i][0] = $sr;
|
||||
$arr[$i++][1] = get_end_bbtag($sr, $bbuid);
|
||||
}
|
||||
$ret .= $sr;
|
||||
} else {
|
||||
$sr = get_next_word($sl);
|
||||
$ret .= $sr;
|
||||
$ntext .= $sr;
|
||||
$last = $sr;
|
||||
}
|
||||
$sl = trim(substr($sl, strlen($sr), strlen($sl)-strlen($sr)));
|
||||
}
|
||||
|
||||
$ret = trim($ret) . '...';
|
||||
|
||||
$ap = '';
|
||||
foreach ($arr as $elem) {
|
||||
$ap = $elem[1] . $ap;
|
||||
}
|
||||
$ret .= $ap;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function ap_validate($str) {
|
||||
$s = str_replace('<br />', '<br/>', $str);
|
||||
return str_replace('</li><br/>', '</li>', $s);
|
||||
}
|
||||
|
||||
?>
|
||||
7
root/portal/includes/index.html
Normal file
7
root/portal/includes/index.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF" text="#000000">
|
||||
</body>
|
||||
</html>
|
||||
307
root/portal/includes/mini_cal/calendarSuite.php
Normal file
307
root/portal/includes/mini_cal/calendarSuite.php
Normal file
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package - Board3portal
|
||||
* @version $Id$
|
||||
* @copyright (c) kevin / saint ( http://www.board3.de/ ), (c) nickvergessen ( http://mods.flying-bits.org/ ), (c) redbull254 ( http://www.digitalfotografie-foren.de )
|
||||
* @copyright (c) Adrian Cockburn - phpbb@netclectic.com (mini calendar)
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!defined('IN_MINI_CAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Features include: 11 languages, returns all data in one array,
|
||||
* intelligent linker function
|
||||
*
|
||||
* day[] = array(0 => 'dayNumeric', // e.g. 19
|
||||
* 1 => 'dayName', // e.g. Tue
|
||||
* 2 => 'dayNameL', // e.g. Tuesday
|
||||
* 3 => 'monthName', // e.g. March
|
||||
* 4 => 'monthNumeric' // e.g. 12
|
||||
* 5 => 'year' // e.g. 2002
|
||||
* 6 => 'timestamp' // e.g. 1020204000
|
||||
* 7 => 'dayOfWeek' // 0-6 ! e.g. sunday=0, monday=1...
|
||||
* 8 => 'dayOfYear' // day of year (001 - 366)
|
||||
* 9 => 'weekNum' // weeknumber of current year
|
||||
* 10 => 'link' // link from link function
|
||||
* 11 => 'mysqlDate' // contains date in mysql-format (YYYY-MM-DD)
|
||||
*
|
||||
*
|
||||
* language options:
|
||||
* 0 = english (default) 1 = german
|
||||
* 2 = french 3 = spanish
|
||||
* 4 = finish 5 = polish
|
||||
* 6 = portuguese 7 = italian
|
||||
* 8 = italian 9 = slovak
|
||||
* 10 = turkish
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* set language
|
||||
* @const language
|
||||
* default 0 / english
|
||||
**/
|
||||
define("language", "1");
|
||||
|
||||
|
||||
/**
|
||||
* set default date format
|
||||
* @const dateFormat
|
||||
* default
|
||||
**/
|
||||
define("dateFormat" , "0");
|
||||
|
||||
|
||||
class calendarSuite {
|
||||
|
||||
var $dateYYY; // year in numeric format (YYYY)
|
||||
var $dateMM; // month in numeric format (MM)
|
||||
var $dateDD; // day in numeric format (DD)
|
||||
var $ext_dateMM; // extended month (e.g. February)
|
||||
var $ext_dateDD; // extended day (e.g. Mon)
|
||||
var $daysMonth; // count of days in month
|
||||
var $nextMonth; // contains next month
|
||||
var $lastMonth; // contains last month
|
||||
var $stamp; // timestamp
|
||||
var $day; // return array s.a.
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Sets default values for e.g. language (default=english)
|
||||
**/
|
||||
function calendarSuite(){
|
||||
switch (language) {
|
||||
|
||||
case 0:
|
||||
$this->language = "en_EN";
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$this->language = "de_DE";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$this->language = "fr_FR";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$this->language = "es_ES";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$this->language = "fi_FI";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$this->language = "pl_PL";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$this->language = "pt_PT";
|
||||
break;
|
||||
|
||||
case 7:
|
||||
$this->language = "it_IT";
|
||||
break;
|
||||
|
||||
case 8:
|
||||
$this->language = "ru_RU";
|
||||
break;
|
||||
|
||||
case 9:
|
||||
$this->language = "sk_SK";
|
||||
break;
|
||||
|
||||
case 10:
|
||||
$this->language = "tr_TR";
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->language = "en_EN";
|
||||
|
||||
}
|
||||
setlocale (LC_TIME, $this->language); // set language
|
||||
|
||||
// end of function calendarSuite
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* determine the next month after current
|
||||
**/
|
||||
function nextMonth() {
|
||||
$this->nextMonth = $this->getMonth("+1 month");
|
||||
|
||||
// end of function nextMonth
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* determine the last month before current
|
||||
**/
|
||||
function lastMonth() {
|
||||
$this->lastMonth = $this->getMonth("-1 month");
|
||||
|
||||
// end of function lastMonth
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* convert date->timestamp
|
||||
**/
|
||||
function makeTimestamp($date) {
|
||||
|
||||
$this->stamp = strtotime($date);
|
||||
return ($this->stamp);
|
||||
|
||||
// end of function makeTimestamp
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get date listed in array
|
||||
**/
|
||||
function getMonth($callDate) {
|
||||
|
||||
$this->makeTimestamp($callDate);
|
||||
$this->dateYYYY = date("Y", $this->stamp);
|
||||
$this->dateMM = date("n", $this->stamp);
|
||||
$this->ext_dateMM = date("F", $this->stamp);
|
||||
$this->dateDD = date("d", $this->stamp);
|
||||
$this->daysMonth = date("t", $this->stamp);
|
||||
$this->monthStart = date("w", $this->stamp);
|
||||
|
||||
for($i=1; $i < $this->daysMonth+1; $i++) {
|
||||
$this->makeTimestamp("$i $this->ext_dateMM $this->dateYYYY");
|
||||
$this->day[] = array(
|
||||
"0" => "$i",
|
||||
"1" => (strftime('%a', $this->stamp)),
|
||||
"2" => (strftime('%A', $this->stamp)),
|
||||
"3" => (strftime("%B", $this->stamp)),
|
||||
"4" => $this->dateMM,
|
||||
"5" => $this->dateYYYY,
|
||||
"6" => $this->stamp,
|
||||
"7" => (date('w', $this->stamp)),
|
||||
"8" => (strftime('%j', $this->stamp)),
|
||||
"9" => (strftime('%U', $this->stamp)),
|
||||
"10" => $this->dateLinker($this->stamp),
|
||||
"11" => $this->formatDate($this->stamp, 99)
|
||||
);
|
||||
}
|
||||
|
||||
// end of function getMonth
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get detailed array of day
|
||||
**/
|
||||
function getDayDetail($stamp) {
|
||||
|
||||
$this->dateYYYY = date("Y", $stamp);
|
||||
$this->dateMM = date("n", $stamp);
|
||||
$this->dateDD = date("d", $stamp);
|
||||
$this->ext_dateMM = date("F", $stamp);
|
||||
$this->daysMonth = date("t", $stamp);
|
||||
$this->monthStart = date("w", $stamp);
|
||||
|
||||
$this->day = array(
|
||||
"0" => (date("j",$stamp)),
|
||||
"1" => (strftime('%a', $stamp)),
|
||||
"2" => (strftime('%A', $stamp)),
|
||||
"3" => $this->ext_dateMM,
|
||||
"4" => $this->dateMM,
|
||||
"5" => $this->dateYYYY,
|
||||
"6" => $stamp,
|
||||
"7" => (date('w', $stamp)),
|
||||
"8" => strftime('%j', $stamp),
|
||||
"9" => strftime('%U', $stamp)
|
||||
);
|
||||
|
||||
// end of function getDay
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* make links for every day
|
||||
**/
|
||||
function dateLinker($stamp) {
|
||||
$link = "?stamp=".$stamp;
|
||||
return $link;
|
||||
|
||||
// end of function dateLinker
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* format date in different forms
|
||||
**/
|
||||
function formatDate($stamp, $option = dateFormat) {
|
||||
|
||||
switch ($option) {
|
||||
|
||||
case 0:
|
||||
$this->formatted = date("d n Y", $stamp);
|
||||
return $this->formatted;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$this->formatted = date("d Y M", $stamp);
|
||||
return $this->formatted;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$this->formatted = date("M d Y", $stamp);
|
||||
return $this->formatted;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$this->formatted = date("M Y d", $stamp);
|
||||
return $this->formatted;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$this->formatted = date("Y M d", $stamp);
|
||||
return $this->formatted;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$this->formatted = date("Y d M", $stamp);
|
||||
return $this->formatted;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$this->formatted = date("d M Y", $stamp);
|
||||
return $this->formatted;
|
||||
break;
|
||||
|
||||
case 99:
|
||||
$this->formatted = date("Y-m-d", $stamp);
|
||||
return $this->formatted;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// end of function formatDate
|
||||
}
|
||||
|
||||
|
||||
// end of class
|
||||
}
|
||||
|
||||
?>
|
||||
7
root/portal/includes/mini_cal/index.html
Normal file
7
root/portal/includes/mini_cal/index.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body bgcolor="#FFFFFF" text="#000000">
|
||||
</body>
|
||||
</html>
|
||||
142
root/portal/includes/mini_cal/mini_cal_common.php
Normal file
142
root/portal/includes/mini_cal/mini_cal_common.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package - Board3portal
|
||||
* @version $Id$
|
||||
* @copyright (c) kevin / saint ( http://www.board3.de/ ), (c) nickvergessen ( http://mods.flying-bits.org/ ), (c) redbull254 ( http://www.digitalfotografie-foren.de )
|
||||
* @copyright (c) Adrian Cockburn - phpbb@netclectic.com (mini calendar)
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!defined('IN_MINI_CAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
getFormattedDate
|
||||
|
||||
version: 1.0.0
|
||||
parameters: $cal_weekday -
|
||||
$cal_month -
|
||||
$cal_monthday -
|
||||
$cal_year -
|
||||
$cal_hour -
|
||||
$cal_min -
|
||||
$cal_sec -
|
||||
|
||||
returns: a date formatted according to the MINI_CAL_DATE_PATTERNS
|
||||
set in mini_cal_config.php and the Mini_Cal_date_format
|
||||
set in lang_main_min_cal.php
|
||||
***************************************************************************/
|
||||
function getFormattedDate($cal_weekday, $cal_month, $cal_monthday, $cal_year, $cal_hour, $cal_min, $cal_sec, $format)
|
||||
{
|
||||
global $lang;
|
||||
|
||||
// initialise out date formatting patterns
|
||||
$cal_date_pattern = unserialize(MINI_CAL_DATE_PATTERNS);
|
||||
|
||||
$cal_date_replace = array(
|
||||
$lang['mini_cal']['day'][$cal_weekday],
|
||||
$lang['mini_cal']['month'][$cal_month],
|
||||
$cal_month,
|
||||
( (strlen($cal_monthday) < 2 ) ? '0' : '' ) . $cal_monthday,
|
||||
$cal_monthday,
|
||||
( (strlen($cal_month) < 2 ) ? '0' : '' ) . $cal_month,
|
||||
substr($cal_year, -2),
|
||||
$cal_year,
|
||||
( (strlen($cal_hour) < 2 ) ? '0' : '' ) . $cal_hour,
|
||||
$cal_hour,
|
||||
( (strlen($cal_hour) < 2 ) ? '0' : '' ) . ( ( $cal_hour > 12 ) ? $cal_hour-12 : $cal_hour ),
|
||||
( $cal_hour > 12 ) ? $cal_hour-12 : $cal_hour,
|
||||
$cal_min,
|
||||
$cal_sec,
|
||||
( $cal_hour < 12 ) ? 'AM' : 'PM'
|
||||
);
|
||||
|
||||
return preg_replace($cal_date_pattern, $cal_date_replace, $format);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
setQueryStringVal
|
||||
|
||||
version: 1.0.0
|
||||
parameters: $var - the variable who's value is to be replaced
|
||||
$value - the new value for the variable
|
||||
|
||||
returns: a modified querystring prefixed with ?
|
||||
***************************************************************************/
|
||||
function setQueryStringVal($var, $value)
|
||||
{
|
||||
$querystring = $_SERVER["QUERY_STRING"];
|
||||
|
||||
if (!stristr($querystring, $var))
|
||||
{
|
||||
$querystring .= ($querystring) ? '&' : '';
|
||||
$querystring .= "$var=$value";
|
||||
}
|
||||
else
|
||||
{
|
||||
$querystring = ereg_replace("($var=[[:digit:]]{1,3})", "$var=$value", $querystring);
|
||||
}
|
||||
return '?' . $querystring;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
getPostForumsList
|
||||
|
||||
version: 1.0.0
|
||||
parameters: $mini_cal_post_auth - a comma seperated list of forms with post rights
|
||||
|
||||
returns: adds a forums select list to the template output
|
||||
***************************************************************************/
|
||||
function getPostForumsList($mini_cal_post_auth, $and_post_auth_sql = '')
|
||||
{
|
||||
if ($mini_cal_post_auth)
|
||||
{
|
||||
global $db, $template, $lang;
|
||||
|
||||
// get a list of events forums
|
||||
$sql = 'SELECT c.cat_id, c.cat_title, f.forum_id, f.forum_name
|
||||
FROM ' . FORUMS_TABLE . ' f, ' . CATEGORIES_TABLE . ' c
|
||||
WHERE f.cat_id = c.cat_id
|
||||
AND f.forum_id IN (' . $mini_cal_post_auth . ')' .
|
||||
$and_post_auth_sql;
|
||||
|
||||
if( $result = $db->sql_query($sql) )
|
||||
{
|
||||
$num_rows = $db->sql_numrows($result);
|
||||
if ( $num_rows > 0 )
|
||||
{
|
||||
$template->assign_block_vars('switch_mini_cal_add_events', array());
|
||||
|
||||
$forums_list = '<select style="width: 100%" name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value > -1){ forms[\'mini_cal\'].submit() }">';
|
||||
|
||||
$cat_id = 0;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$forums_list .= '<option value="' . $row['forum_id'] . '"' . $selected . '> - ' . substr($row['forum_name'],0,20) . '</option>';
|
||||
}
|
||||
$forums_list .= '</select>';
|
||||
|
||||
$template->assign_vars( array(
|
||||
'S_MINI_CAL_EVENTS_FORUMS_LIST' => $forums_list
|
||||
)
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
88
root/portal/includes/mini_cal/mini_cal_config.php
Normal file
88
root/portal/includes/mini_cal/mini_cal_config.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package - Board3portal
|
||||
* @version $Id$
|
||||
* @copyright (c) kevin / saint ( http://www.board3.de/ ), (c) nickvergessen ( http://mods.flying-bits.org/ ), (c) redbull254 ( http://www.digitalfotografie-foren.de )
|
||||
* @copyright (c) Adrian Cockburn - phpbb@netclectic.com (mini calendar)
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!defined('IN_MINI_CAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
The following values are configurable to tailor the mini cal to your needs.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
// Defines which events calendar you are using, if any
|
||||
// possible values:
|
||||
// MYCAL - MyCalendar
|
||||
// PLUS - MyCalendar+
|
||||
// TOPIC - Topic Calendar
|
||||
// SNAIL - Websnail Calendar Pro
|
||||
// SNAILLITE - Websnail Calendar Lite
|
||||
// NONE - No Supported Calendar is installed
|
||||
define('MINI_CAL_CALENDAR_VERSION', 'NONE');
|
||||
|
||||
|
||||
// EVENTS CALENDAR USERS ONLY!
|
||||
// Limits the number of events shown on the mini cal
|
||||
define('MINI_CAL_LIMIT', 5);
|
||||
|
||||
|
||||
// EVENTS CALENDAR USERS ONLY!
|
||||
// Limits the number of days ahead in which time upcoming events will be shown
|
||||
// set to 0 (zero) for umlimited
|
||||
define('MINI_CAL_DAYS_AHEAD', 7);
|
||||
|
||||
|
||||
// Defines what type of search happens when a user clicks on a date in the calendar
|
||||
// possible values:
|
||||
// POSTS - will return all posts posted on that date
|
||||
// EVENTS - will return all events happening on that date (ONLY SUITABLE FOR EVENTS CALENDAR USERS).
|
||||
define('MINI_CAL_DATE_SEARCH', 'POSTS');
|
||||
|
||||
|
||||
// First Day of the Week - 0=Sunday, 1=Monday...6=Saturday
|
||||
// if you change this remember to change the short day names in lang_main_mini_cal.php
|
||||
define('MINI_CAL_FDOW', 1);
|
||||
|
||||
|
||||
// Defines the css class to use for mini cal days urls
|
||||
define('MINI_CAL_DAY_LINK_CLASS', 'gensmall');
|
||||
|
||||
// Defines the css class to use for mini cal today date
|
||||
define('MINI_CAL_TODAY_CLASS', 'gensmall');
|
||||
|
||||
|
||||
// defines the authentication level required to be able to view the upcoming events
|
||||
// this relates to the permission level assigned to forum
|
||||
// possible values:
|
||||
// auth_view, auth_read, auth_post, auth_reply, auth_edit,
|
||||
// auth_delte, auth_sticky, auth_announce, auth_vote, auth_pollcreate
|
||||
define('MINI_CAL_EVENT_AUTH_LEVEL', 'auth_view');
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
You should NOT modify any values below here.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
// DO NOT MODIFY THIS!
|
||||
define('MINI_CAL_DATE_PATTERNS', serialize(array('/%a/', '/%b/', '/%c/', '/%d/', '/%e/', '/%m/', '/%y/', '/%Y/',
|
||||
'/%H/', '/%k/', '/%h/', '/%l/', '/%i/', '/%s/', '/%p/')));
|
||||
|
||||
?>
|
||||
304
root/portal/includes/mini_cal/mini_cal_topic.php
Normal file
304
root/portal/includes/mini_cal/mini_cal_topic.php
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package - Board3portal
|
||||
* @version $Id$
|
||||
* @copyright (c) kevin / saint ( http://www.board3.de/ ), (c) nickvergessen ( http://mods.flying-bits.org/ ), (c) redbull254 ( http://www.digitalfotografie-foren.de )
|
||||
* @copyright (c) Adrian Cockburn - phpbb@netclectic.com (mini calendar)
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!defined('IN_MINI_CAL'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* set_var
|
||||
*
|
||||
* Set variable, used by {@link request_var the request_var function}
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
|
||||
/***************************************************************************
|
||||
getMiniCalForumsAuth
|
||||
|
||||
version: 1.0.0
|
||||
parameters: $userdata - an initialised $userdata array.
|
||||
returns: a two part array
|
||||
$mini_cal_auth['view'] - a comma seperated list of forums which the user has VIEW permissions for
|
||||
$mini_cal_auth['post'] - a comma seperated list of forums which the user has POST permissions for
|
||||
***************************************************************************/
|
||||
function getMiniCalForumsAuth($user)
|
||||
{
|
||||
global $db, $auth, $user;
|
||||
|
||||
// initialise our forums auth list
|
||||
$mini_cal_auth_ary = array();
|
||||
$mini_cal_auth_ary = $auth->acl($user->data);
|
||||
|
||||
$mini_cal_auth = array();
|
||||
$mini_cal_auth['view'] = '';
|
||||
$mini_cal_auth['post'] = '';
|
||||
|
||||
while ( list($mini_cal_forum_id, $mini_cal_auth_level) = each($mini_cal_auth_ary) )
|
||||
{
|
||||
if ( $mini_cal_auth_level[MINI_CAL_EVENT_AUTH_LEVEL] )
|
||||
{
|
||||
$mini_cal_auth['view'] .= ($mini_cal_auth['view'] == '') ? $mini_cal_forum_id : ', ' . $mini_cal_forum_id;
|
||||
}
|
||||
|
||||
if ( ($mini_cal_auth_level['auth_post']) && $mini_cal_auth_level['auth_cal'] )
|
||||
{
|
||||
$mini_cal_auth['post'] .= ($mini_cal_auth['post'] == '') ? $mini_cal_forum_id : ', ' . $mini_cal_forum_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $mini_cal_auth;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
getMiniCalEventDays
|
||||
|
||||
version: 1.0.0
|
||||
parameters: $auth_view_forums - a comma seperated list of forums which the user has VIEW permissions for
|
||||
returns: an array containing a list of day containing event the user has permission to view
|
||||
***************************************************************************/
|
||||
function getMiniCalEventDays($auth_view_forums)
|
||||
{
|
||||
global $db, $mini_cal_this_year, $mini_cal_this_month;
|
||||
|
||||
$mini_cal_event_days = array();
|
||||
|
||||
if ($auth_view_forums)
|
||||
{
|
||||
// start and end date
|
||||
$start_date = mktime(0,0,0, $mini_cal_this_month, 01, $mini_cal_this_year);
|
||||
$w_month = $mini_cal_this_month + 1;
|
||||
$w_year = $mini_cal_this_year;
|
||||
if ($w_month > 12)
|
||||
{
|
||||
$w_month = 01;
|
||||
$w_year++;
|
||||
}
|
||||
$end_date = mktime(0,0,0, $w_month, 01, $w_year);
|
||||
|
||||
// we consider the duration
|
||||
$sql = "SELECT DISTINCT topic_calendar_time, topic_calendar_duration
|
||||
FROM " . TOPICS_TABLE . "
|
||||
WHERE forum_id IN ($auth_view_forums)
|
||||
AND (topic_calendar_time + topic_calendar_duration) >= $start_date
|
||||
AND topic_calendar_time < $end_date
|
||||
AND topic_calendar_time IS NOT NULL
|
||||
AND topic_calendar_time <> 0";
|
||||
|
||||
if ( $result = $db->sql_query($sql) )
|
||||
{
|
||||
$mini_cal_event_days_ww = array();
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
$start_day = intval(date('d', $row['topic_calendar_time']));
|
||||
for ($i = 0; ( ($i <= intval($row['topic_calendar_duration'] / 86400)) && ( ($start_day + $i) <= 31) ); $i++)
|
||||
{
|
||||
$mini_cal_event_days_ww[ ($start_day + $i) ] = true;
|
||||
}
|
||||
}
|
||||
while (list($mini_cal_event_day, $mini_cal_event_present) = each($mini_cal_event_days_ww) )
|
||||
{
|
||||
$mini_cal_event_days[] = $mini_cal_event_day;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $mini_cal_event_days;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
getMiniCalEvents
|
||||
|
||||
version: 1.0.0
|
||||
parameters: $mini_cal_auth - a two part array
|
||||
$mini_cal_auth['view'] - a comma seperated list of forums which the user has VIEW permissions for
|
||||
$mini_cal_auth['post'] - a comma seperated list of forums which the user has POST permissions for
|
||||
|
||||
returns: nothing - it assigns variable to the template
|
||||
***************************************************************************/
|
||||
function getMiniCalEvents($mini_cal_auth)
|
||||
{
|
||||
global $template, $db, $phpEx, $lang, $mini_cal_today,
|
||||
$mini_cal_this_month, $mini_cal_this_year, $mini_cal_this_day;
|
||||
|
||||
// start and end date
|
||||
$start_date = mktime(0,0,0, intval(substr($mini_cal_today, 4, 2)), $mini_cal_this_day, $mini_cal_this_year);
|
||||
|
||||
$w_month = $mini_cal_this_month;
|
||||
$days_ahead_sql = '';
|
||||
if (MINI_CAL_DAYS_AHEAD > 0)
|
||||
{
|
||||
$w_year = $mini_cal_this_year;
|
||||
if ($w_month > 12)
|
||||
{
|
||||
$w_month = 01;
|
||||
$w_year++;
|
||||
}
|
||||
$end_date = mktime(0,0,0, $w_month, $mini_cal_this_day + MINI_CAL_DAYS_AHEAD, $w_year);
|
||||
$days_ahead_sql = " AND topic_calendar_time < $end_date ";
|
||||
}
|
||||
|
||||
// initialise some sql bits
|
||||
$mini_cal_auth_sql = ($mini_cal_auth['view']) ? ' AND t.forum_id in (' . $mini_cal_auth['view'] . ') ' : '';
|
||||
|
||||
// get events
|
||||
$sql = "SELECT t.topic_id, t.topic_calendar_time, t.topic_title, t.forum_id, t.topic_calendar_duration
|
||||
FROM " . TOPICS_TABLE . " t
|
||||
WHERE topic_calendar_time >= $start_date
|
||||
$days_ahead_sql
|
||||
AND topic_calendar_time IS NOT NULL
|
||||
AND topic_calendar_time <> 0
|
||||
$mini_cal_auth_sql
|
||||
ORDER BY
|
||||
t.topic_calendar_time ASC
|
||||
LIMIT
|
||||
0," . MINI_CAL_LIMIT;
|
||||
|
||||
// did we get a result?
|
||||
if( $result = $db->sql_query($sql) )
|
||||
{
|
||||
$template->assign_block_vars('switch_mini_cal_events', array());
|
||||
if ( $db->sql_numrows($result) > 0 )
|
||||
{
|
||||
// we've got some events
|
||||
|
||||
// now let's output our events in the given date format for the current language
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$cal_time = $row['topic_calendar_time'];
|
||||
$day_span = (date("Ymd", $cal_time) < date("Ymd", $cal_time+$row['topic_calendar_duration']));
|
||||
$include_time = date("His", $cal_time) > 0;
|
||||
$cal_date = getFormattedDate(
|
||||
date('w', $cal_time),
|
||||
date('n', $cal_time),
|
||||
date('d', $cal_time),
|
||||
date('Y', $cal_time),
|
||||
date('H', $cal_time),
|
||||
date('i', $cal_time),
|
||||
date('s', $cal_time),
|
||||
$lang['Mini_Cal_date_format'].((!$day_span && $include_time)?' '.$lang['Mini_Cal_date_format_Time']:'')
|
||||
);
|
||||
|
||||
if ($day_span || $row['topic_calendar_duration'] > 0)
|
||||
{
|
||||
$cal_time = $cal_time + $row['topic_calendar_duration'];
|
||||
$cal_date .= ' - ' . getFormattedDate(
|
||||
date('w', $cal_time),
|
||||
date('n', $cal_time),
|
||||
date('d', $cal_time),
|
||||
date('Y', $cal_time),
|
||||
date('H', $cal_time),
|
||||
date('i', $cal_time),
|
||||
date('s', $cal_time),
|
||||
((!$day_span)?$lang['Mini_Cal_date_format_Time']:$lang['Mini_Cal_date_format'])
|
||||
);
|
||||
}
|
||||
|
||||
$template->assign_block_vars('mini_cal_events', array(
|
||||
'MINI_CAL_EVENT_DATE' => $cal_date,
|
||||
'S_MINI_CAL_EVENT' => $row['topic_title'],
|
||||
'U_MINI_CAL_EVENT' => append_sid( $phpbb_root_path . "viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $row['topic_id'] )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no events :(
|
||||
$template->assign_block_vars('mini_cal_no_events', array());
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
getMiniCalSearchSql
|
||||
|
||||
version: 1.0.0
|
||||
parameters: $search_id - the type of search we're looking for
|
||||
$search_date - the date passed to the search
|
||||
|
||||
returns: an sql string
|
||||
***************************************************************************/
|
||||
function getMiniCalSearchSql($search_date)
|
||||
{
|
||||
$s_yy = intval(substr($search_date, 0, 4));
|
||||
$s_mm = intval(substr($search_date, 4, 2));
|
||||
$s_dd = intval(substr($search_date, 6, 2));
|
||||
$search_date = mktime(0,0,0, $s_mm, $s_dd, $s_yy);
|
||||
$nix_tomorrow = mktime (0,0,0, $s_mm, $s_dd + 1, $s_yy);
|
||||
|
||||
$sql = "SELECT topic_first_post_id as post_id
|
||||
FROM " . TOPICS_TABLE . "
|
||||
WHERE (topic_calendar_time + topic_calendar_duration) >= $search_date AND topic_calendar_time < $nix_tomorrow";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
getMiniCalSearchURL
|
||||
|
||||
version: 1.0.0
|
||||
parameters: $search_date - the date passed to the search
|
||||
|
||||
returns: an url string
|
||||
***************************************************************************/
|
||||
function getMiniCalSearchURL($search_date)
|
||||
{
|
||||
global $phpEx;
|
||||
|
||||
$s_yy = intval(substr($search_date, 0, 4));
|
||||
$s_mm = intval(substr($search_date, 4, 2));
|
||||
$s_dd = intval(substr($search_date, 6, 2));
|
||||
$search_date = mktime(0,0,0, $s_mm, $s_dd, $s_yy);
|
||||
|
||||
//$url = append_sid($phpbb_root_path . "search.$phpEx?search_id=mini_cal_events&d=" . $search_date);
|
||||
$url = append_sid($phpbb_root_path . "calendar_scheduler.$phpEx?d=" . $search_date);
|
||||
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
getMiniCalPostForumsList
|
||||
|
||||
version: 1.0.0
|
||||
parameters: $mini_cal_post_auth - a comma seperated list of forms with post rights
|
||||
|
||||
returns: adds a forums select list to the template output
|
||||
***************************************************************************/
|
||||
function getMiniCalPostForumsList($mini_cal_post_auth)
|
||||
{
|
||||
getPostForumsList($mini_cal_post_auth);
|
||||
}
|
||||
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_MINI_CAL_CALENDAR' => append_sid($phpbb_root_path . 'calendar.' . $phpEx),
|
||||
'U_MINI_CAL_ADD_EVENT' => append_sid($phpbb_root_path . 'posting.' . $phpEx . '?mode=newtopic&f=' . MINI_CAL_EVENTS_FORUM )
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user