###############################################################################
# EventCal.pm #
# $Date: 09.01.14 $ #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.6.1 #
# Packaged: September 1, 2014 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2014 YaBB (www.yabbforum.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
# use strict;
#use warnings;
#no warnings qw(uninitialized once redefine);
use CGI::Carp qw(fatalsToBrowser);
use Time::Local;
our $VERSION = '2.6.1';
$eventcalpmver = 'YaBB 2.6.1 $Revision$';
if ( $action eq 'detailedversion' ) { return 1; }
LoadLanguage('EventCal');
LoadLanguage('Post');
LoadLanguage('LivePreview');
require Sources::SpamCheck;
require Sources::PostBox;
require Sources::Post;
get_micon();
get_template('Calendar');
if ( eval { require "$vardir/eventcalIcon.txt"; 1 } ) {
$i = 0;
while ( $CalIconURL[$i] ) {
$cal_icon{"$CalIconURL[$i]"} = qq~~;
$cal_icon_bg{"$CalIconURL[$i]"} = qq~$yyhtml_root/EventIcons/$CalIconURL[$i]~;
$var_cal{"$CalIconURL[$i]"} = $CalIDescription[$i];
$add_cal_icon[$i] = qq~$CalIconURL[$i]|$CalIDescription[$i]~;
$i++;
}
}
$jsCal = qq~
var jsCal = new Hash(
'eventinfo', '$cal_icon_bg{'eventinfo'}',
'eventmore', '$cal_icon_bg{'eventmore'}',
'eventmorebd', '$cal_icon_bg{'eventmore'}',
'eventmoreadd', '$cal_icon_bg{'eventmore'}',
'eventannounce', '$cal_icon_bg{'eventannounce'}',
'eventholiday', '$cal_icon_bg{'eventholiday'}',
'eventnote', '$cal_icon_bg{'eventnote'}',
'eventparty', '$cal_icon_bg{'eventparty'}',
'eventcelebration', '$cal_icon_bg{'eventcelebration'}',
'eventsport', '$cal_icon_bg{'eventsport'}',
'eventmedia', '$cal_icon_bg{'eventmedia'}',
'eventmeeting', '$cal_icon_bg{'eventmeeting'}'~;
for $i (@add_cal_icon) {
my($i_a,$i_b) = split /\|/xsm, $i;
$jsCal .= qq~,\n'$i_a', '$yyhtml_root/EventIcons/$i_a'~;
}
$jsCal .= qq~);\n~;
$jsCal_txt = qq~
var jsCaltxt = new Hash(
'eventinfo', '$var_cal{'eventinfo'}',
'eventannounce', '$var_cal{'eventannounce'}',
'eventholiday', '$var_cal{'eventholiday'}',
'eventnote', '$var_cal{'eventnote'}',
'eventparty', '$var_cal{'eventparty'}',
'eventcelebration', '$var_cal{'eventcelebration'}',
'eventsport', '$var_cal{'eventsport'}',
'eventmedia', '$var_cal{'eventmedia'}',
'eventmeeting', '$var_cal{'eventmeeting'}'~;
for $i (@add_cal_icon) {
my($i_a,$i_b) = split /\|/xsm, $i; #
$jsCal_txt .= qq~,\n'$i_a', '$i_b'~;
}
$jsCal_txt .= qq~);\n~;
sub eventcal {
my ( $ssicalmode, $ssicaldisplay ) = @_;
my ( $i, $eventfound );
## SSI Variables ##
# Access check to add events begin
if ( !$Show_EventCal || ( $iamguest && $Show_EventCal != 2 ) ) {
fatal_error('not_allowed');
}
my $Allow_Event_Imput = 0;
if ($iamadmin) { $Allow_Event_Imput = 1; }
elsif ( $CalEventPerms eq q{} ) { $Allow_Event_Imput = 1; }
elsif ( $iamguest && $CalEventPerms ) { $Allow_Event_Imput = 0; }
else {
TOPLOOP: foreach my $element ( split /,/xsm, $CalEventPerms ) {
if ( $element eq ${ $uid . $username }{'position'} ) {
$Allow_Event_Imput = 1;
last;
}
foreach ( split /,/xsm, $memberaddgroup{$username} ) {
if ( $element eq $_ ) { $Allow_Event_Imput = 1; last TOPLOOP; }
}
}
if ( !$Allow_Event_Imput && $CalEventMods ) {
foreach ( split /,/xsm, $CalEventMods ) {
if ( $_ eq $username ) { $Allow_Event_Imput = 1; last; }
}
}
}
# Access check to add events end
# GoTo Box begin
if ( $INFO{'calgotobox'} == 1 ) {
$goyear = $FORM{'calyear'};
$gomon = $FORM{'calmon'};
$goday = $FORM{'calday'};
if ($goday) {
$yySetLocation =
qq~$scripturl?action=eventcal;calshow=1;eventdate=$goyear$gomon$goday;showmini=1~;
redirectexit();
}
else {
$yySetLocation =
qq~$scripturl?action=eventcal;calshow=1;calmon=$gomon;calyear=$goyear~;
redirectexit();
}
}
# GoTo Box end
# Time/Days begin
my ( $sel_year, $sel_mon, $sel_day );
my $event_date = $INFO{'eventdate'};
if ($event_date) {
if ( $event_date =~ /(\d{4})(\d{2})(\d{2})/xsm ) {
( $sel_year, $sel_mon, $sel_day ) = ( $1, $2, $3 );
}
}
my $newdate = $date;
my $toffs = 0;
if ($enabletz) {
$toffs = toffs($date);
}
if ( $INFO{'calyear'} ) {
$ausgabe1 = qq~$INFO{'calmon'}/01/$INFO{'calyear'} am 00:00:00~;
$heute = stringtotime($ausgabe1);
$daterechnug = $heute;
}
else {
$heute = $date;
$daterechnug = $date;
}
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $dst ) =
gmtime( $heute + $toffs );
$year += 1900;
my ( undef, undef, undef, $callnewday, $callnewmonth, $callnewyear, undef )
= gmtime( $newdate + $toffs );
$callnewyear += 1900;
$callnewmonth++;
if ( $INFO{'calyear'} ) {
$year = $INFO{'calyear'};
$mon = $INFO{'calmon'} - 1;
}
# timeformatcal($date); # get only correct $mytimeselected
# Time/Days end
# Get Navi begin
if ( !$INFO{'calmon'} ) { $INFO{'calmon'} = $mon + 1; }
if ( !$INFO{'calmon'} > 12 ) { $INFO{'calmon'} = 12; }
$next_mon = $INFO{'calmon'} + 1;
$next_year = $year;
$st_mon = $next_mon;
if ( $st_mon < 10 ) { $st_mon = "0$st_mon"; }
$stnext = 'calmon_' . $st_mon;
$stnextname = $var_cal{$stnext};
$last_mon = $INFO{'calmon'} - 1;
$st_mon = "$last_mon";
if ( $st_mon < 10 ) { $st_mon = "0$st_mon"; }
$stlast = 'calmon_' . $st_mon;
$stlastname = $var_cal{$stlast};
$last_year = $year;
if ( $INFO{'calmon'} == 12 ) { $next_mon = 1; $next_year = $year + 1; }
if ( $INFO{'calmon'} == 1 ) { $last_mon = 12; $last_year = $year - 1; }
if ( $next_mon < 10 ) { $next_mon = "0$next_mon"; }
if ( $last_mon < 10 ) { $last_mon = "0$last_mon"; }
$next_link =
qq~ -»~;
$last_link =
qq~«- ~;
# Get Navi end
# EventCal System begin
$viewyear = $year;
$viewyear = substr $viewyear, 2, 4;
my @mon_days = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
$days = $mon_days[$mon];
$wday1 = ( gmtime( timegm( 0, 0, 0, 1, $mon, $year ) ) )[6];
if ($ShowSunday) { $wday1++; }
if ( $wday1 == 0 ) { $wday1 = 7; }
$mon++;
$caltoday = "$year" . sprintf( '%02d', $mon ) . sprintf '%02d', $mday;
$st_mon = "$mon";
if ( $st_mon < 10 ) { $st_mon = "0$st_mon"; }
$st = 'calmon_' . $st_mon;
$view_mon = $mon;
if ( $view_mon < 10 ) { $view_mon = "0$view_mon"; }
if ( !$Show_ColorLinks ) {
ManageMemberinfo('load');
}
# EventCal System end
# Add Events and GoTo begin
for my $i ( 1 .. 31 ) {
my $sel = q{};
if ( $mday == $i && !$sel_day ) {
$sel = ' selected="selected"';
}
elsif ( $sel_day == $i ) {
$sel = ' selected="selected"';
}
$sdays_inner .=
q~ \n~;
$boxdays_inner .=
q~ \n~;
}
for my $i ( 1 .. 12 ) {
my $sel = q{};
if ( $mon == $i && !$sel_mon ) {
$sel = ' selected="selected"';
}
elsif ( $sel_mon == $i ) {
$sel = ' selected="selected"';
}
$smonths_inner .=
q~ \n~;
$boxmonths_inner .=
q~ \n~;
}
my $gyears3 = $year - 3;
my $gyears2 = $year - 2;
my $gyears1 = $year - 1;
for my $i ( $year .. ( $year + 3 ) ) {
my $sel = q{};
if ( $year == $i && !$sel_year ) {
$sel = ' selected="selected"';
}
elsif ( $sel_year == $i ) {
$sel = ' selected="selected"';
}
$syears_inner .= qq~ \n~;
$boxyears_inner .= qq~ \n~;
}
## date selections - formated ##
my $sdays = qq~
~;
my $boxdays =
qq~
~;
my $smonths = qq~
~;
my $boxmonths =
qq~
~;
my $syears = qq~
~;
my $boxyears =
qq~
~;
my $addevdate;
if ( $mytimeselected == 8
|| $mytimeselected == 6
|| $mytimeselected == 3
|| $mytimeselected == 2 )
{
$addevdate .= $sdays . $smonths;
$calgotobox_dm .= $boxdays . $boxmonths;
}
else {
$addevdate .= $smonths . $sdays;
$calgotobox_dm .= $boxmonths . $boxdays;
}
$addevdate .= $syears;
my $calgotobox = qq~