Version 3.4.9

This commit is contained in:
Neo committed 2025-12-19 00:44:43 -08:00
1 parent c603205a25
commit f9e857d255
920 files changed
+28189 -6840

No files matched your search

@@ -0,0 +1,13 @@
<?php
/**
* @file defaultSection.php Define the default section for the 'ajax' module
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: ips_terabyte $
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
* @version v3.4.5
* $Revision: 8655 $
*/
$DEFAULT_SECTION = 'rating';
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -0,0 +1,196 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* Add rating AJAX
* Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Calendar
* @link http://www.invisionpower.com
* @since 25th January 2011
* @version $Revision: 10721 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class public_calendar_ajax_rating extends ipsAjaxCommand
{
/**
* Class entry point
*
* @access public
* @param object Registry reference
* @return @e void [Outputs to screen/redirects]
*/
public function doExecute( ipsRegistry $registry )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$event_id = intval($this->request['event_id']);
$rating_id = intval($this->request['rating']);
$this->registry->class_localization->loadLanguageFile( array( 'public_calendar' ) );
//-----------------------------------------
// Functions class
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'calendar' ) . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar' );
$functions = new $classToLoad( $this->registry );
//-----------------------------------------
// Get data
//-----------------------------------------
if ( ! $event_id )
{
$this->returnJsonArray( array( 'error_key' => 'topics_no_tid', 'error_code' => '104101.1' ) );
}
$event = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_events', 'where' => 'event_id=' . $event_id ) );
if( !$event['event_id'] )
{
$this->returnJsonArray( array( 'error_key' => 'topics_no_tid', 'error_code' => '104102.1' ) );
}
//-----------------------------------------
// Check permissions
//-----------------------------------------
if( !$event['event_approved'] )
{
$this->returnJsonArray( array( 'error_key' => 'topics_no_tid', 'error_code' => '104103.1' ) );
}
if( $event['event_private'] )
{
if( ! $this->memberData['member_id'] OR $this->memberData['member_id'] != $event['event_member_id'] )
{
$this->returnJsonArray( array( 'error_key' => 'topics_no_tid', 'error_code' => '104104.1' ) );
}
}
if( $event['event_perms'] != '*' )
{
$permissionGroups = explode( ',', IPSText::cleanPermString( $event['event_perms'] ) );
if( !IPSMember::isInGroup( $this->memberData, $permissionGroups ) )
{
$this->returnJsonArray( array( 'error_key' => 'topics_no_tid', 'error_code' => '104105.1' ) );
}
}
//-----------------------------------------
// Get our calendar
//-----------------------------------------
$calendar = $functions->getCalendar( $event['event_calendar_id'] );
if( !$calendar['cal_id'] OR $calendar['cal_id'] != $event['event_calendar_id'] )
{
$this->returnJsonArray( array( 'error_key' => 'topics_no_tid', 'error_code' => '104106.1' ) );
}
//-----------------------------------------
// Can we rate?
//-----------------------------------------
$_can_rate = ( $this->memberData['member_id'] AND $this->registry->permissions->check( 'rate', $calendar ) ) ? intval( $this->memberData['g_topic_rate_setting'] ) : 0;
if ( ! $_can_rate )
{
$this->returnJsonArray( array( 'error_key' => 'topic_rate_no_perm', 'error_code' => '104107.1' ) );
}
//-----------------------------------------
// Sneaky members rating more than 5?
//-----------------------------------------
if( $rating_id > 5 )
{
$rating_id = 5;
}
if( $rating_id < 0 )
{
$rating_id = 0;
}
//-----------------------------------------
// Have we rated before?
//-----------------------------------------
$rating = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_event_ratings', 'where' => "rating_eid={$event['event_id']} and rating_member_id=" . $this->memberData['member_id'] ) );
if ( $rating['rating_id'] )
{
//-----------------------------------------
// Do we allow re-ratings?
//-----------------------------------------
if ( $this->memberData['g_topic_rate_setting'] == 2 )
{
if ( $rating_id != $rating['rating_value'] )
{
$new_rating = $rating_id - $rating['rating_value'];
$this->DB->update( 'cal_event_ratings', array( 'rating_value' => $rating_id ), 'rating_id=' . $rating['rating_id'] );
$this->DB->update( 'topics', array(
'event_rating_total' => intval($event['event_rating_total']) + $new_rating,
'event_rating_avg' => round( ( intval($event['event_rating_total']) + $new_rating ) / $event['event_rating_hits'] )
), 'event_id=' . $event['event_id'] );
}
$this->returnJsonArray( array(
'rated' => 'update',
'message' => $this->lang->words['event_rating_changed'],
'topic_rating_total' => intval($event['event_rating_total']) + $new_rating,
'topic_rating_hits' => $event['event_rating_hits']
) );
}
else
{
$this->returnJsonArray( array( 'error_key' => 'topic_rated_already', 'error_code' => 0 ) );
}
}
else
{
$this->DB->insert( 'cal_event_ratings', array(
'rating_eid' => $event['event_id'],
'rating_member_id' => $this->memberData['member_id'],
'rating_value' => $rating_id,
'rating_ip_address' => $this->member->ip_address,
) );
$this->DB->update( 'cal_events', array(
'event_rating_total' => intval( $event['event_rating_total'] ) + $rating_id,
'event_rating_hits' => intval( $event['event_rating_hits'] ) + 1,
'event_rating_avg' => round( ( intval( $event['event_rating_total'] ) + $rating_id ) / ( intval( $event['event_rating_hits'] ) + 1 ) ),
), 'event_id=' . $event_id );
$this->returnJsonArray( array(
'rated' => 'new',
'message' => $this->lang->words['event_rating_done'],
'topic_rating_total' => intval( $event['event_rating_total'] ) + $rating_id,
'topic_rating_hits' => intval( $event['event_rating_hits'] ) + 1,
'_rate_int' => round( ( intval( $event['event_rating_total'] ) + $rating_id ) / ( intval( $event['event_rating_hits'] ) + 1 ) )
) );
}
}
}
@@ -0,0 +1,146 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* RSVP for event
* Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Calendar
* @link http://www.invisionpower.com
* @since 25th January 2011
* @version $Revision: 10721 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class public_calendar_ajax_rsvp extends ipsAjaxCommand
{
/**
* Class entry point
*
* @access public
* @param object Registry reference
* @return @e void [Outputs to screen/redirects]
*/
public function doExecute( ipsRegistry $registry )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$event_id = intval($this->request['event_id']);
$this->registry->class_localization->loadLanguageFile( array( 'public_calendar' ) );
//-----------------------------------------
// Functions class
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'calendar' ) . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar' );
$functions = new $classToLoad( $this->registry );
//-----------------------------------------
// Get data
//-----------------------------------------
if ( ! $event_id )
{
$this->returnJsonError( $this->lang->words['rsvp__no_event'] );
}
$event = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_events', 'where' => 'event_id=' . $event_id ) );
if( !$event['event_id'] )
{
$this->returnJsonError( $this->lang->words['rsvp__no_event'] );
}
//-----------------------------------------
// Check permissions
//-----------------------------------------
if( !$event['event_approved'] )
{
$this->returnJsonError( $this->lang->words['rsvp__no_event'] );
}
if( $event['event_private'] )
{
if( ! $this->memberData['member_id'] OR $this->memberData['member_id'] != $event['event_member_id'] )
{
$this->returnJsonError( $this->lang->words['rsvp__no_event'] );
}
}
if( $event['event_perms'] != '*' )
{
$permissionGroups = explode( ',', IPSText::cleanPermString( $event['event_perms'] ) );
if( !IPSMember::isInGroup( $this->memberData, $permissionGroups ) )
{
$this->returnJsonError( $this->lang->words['rsvp__no_event'] );
}
}
//-----------------------------------------
// Get our calendar
//-----------------------------------------
$calendar = $functions->getCalendar( $event['event_calendar_id'] );
if( !$calendar['cal_id'] OR $calendar['cal_id'] != $event['event_calendar_id'] )
{
$this->returnJsonError( $this->lang->words['rsvp__no_event'] );
}
//-----------------------------------------
// Can we RSVP?
//-----------------------------------------
$_can_rsvp = ( $this->memberData['member_id'] AND $this->registry->permissions->check( 'rsvp', $calendar ) AND $event['event_rsvp'] ) ? 1 : 0;
if ( ! $_can_rsvp )
{
$this->returnJsonError( $this->lang->words['rsvp__no_perm'] );
}
//-----------------------------------------
// Have we already RSVP?
//-----------------------------------------
$_check = $this->DB->buildAndFetch( array( 'select' => 'rsvp_id', 'from' => 'cal_event_rsvp', 'where' => 'rsvp_event_id=' . $event['event_id'] . ' AND rsvp_member_id=' . $this->memberData['member_id'] ) );
if( $_check['rsvp_id'] )
{
$this->returnJsonError( $this->lang->words['rsvp__already_rsvp'] );
}
//-----------------------------------------
// Store RSVP
//-----------------------------------------
$_insert = array(
'rsvp_event_id' => $event['event_id'],
'rsvp_member_id' => $this->memberData['member_id'],
'rsvp_date' => time(),
);
$this->DB->insert( 'cal_event_rsvp', $_insert );
$rsvp_id = $this->DB->getInsertId();
$this->returnJsonArray( array( 'html' => $this->registry->output->getTemplate( 'calendar' )->eventAttendee( array_merge( array( 'rsvp_id' => $rsvp_id, 'rsvp_date' => time() ), $this->memberData ), $event ) ) );
}
}
@@ -0,0 +1,13 @@
<?php
/**
* @file defaultSection.php Define the default section for the 'calendar' module
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: ips_terabyte $
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
* @version v3.4.5
* $Revision: 8655 $
*/
$DEFAULT_SECTION = 'view';
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -0,0 +1,322 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* Calendar View
* Last Updated: $Date: 2013-02-08 20:52:39 -0500 (Fri, 08 Feb 2013) $
* </pre>
*
* @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Calendar
* @link http://www.invisionpower.com
* @version $Rev: 11970 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class public_calendar_calendar_moderate extends ipsCommand
{
/**
* Calendar data
*
* @var array
*/
protected $calendar = array();
/**
* Calendar functions
*
* @var object
*/
protected $functions;
/**
* Class entry point
*
* @param object Registry reference
* @return @e void [Outputs to screen/redirects]
*/
public function doExecute( ipsRegistry $registry )
{
//-----------------------------------------
// Init
//-----------------------------------------
$this->registry->class_localization->loadLanguageFile( array( 'public_calendar' ), 'calendar' );
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'calendar' ) . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar' );
$this->functions = new $classToLoad( $this->registry );
$this->calendar = $this->functions->getCalendar();
//-----------------------------------------
// Switch
//-----------------------------------------
switch( $this->request['do'] )
{
case 'calendarEventApprove':
$this->calendarEventApprove();
break;
case 'delete':
$this->calendarEventDelete();
break;
case 'calendarRSVPRemove':
$this->removeRSVPAttendee();
break;
}
}
/**
* Deletes an attendee from RSVP list
*
* @return @e void
*/
public function removeRSVPAttendee()
{
//-----------------------------------------
// Init
//-----------------------------------------
$event_id = intval( $this->request['event_id'] );
$rsvp_id = intval( $this->request['attendee_id'] );
$md5check = trim( $this->request['md5check'] );
if ( !$event_id OR !$rsvp_id )
{
$this->registry->output->showError( 'attendee_bad_delete', 1043.1, null, null, 404 );
}
if ( $md5check != $this->member->form_hash )
{
$this->registry->output->showError( 'calendar_bad_key', 2040.1, null, null, 403 );
}
//-----------------------------------------
// Get event and check permissions
//-----------------------------------------
$event = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_events', 'where' => "event_id=" . $event_id . " AND event_calendar_id=" . $this->calendar['cal_id'] ) );
$rsvp = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_event_rsvp', 'where' => 'rsvp_id=' . $rsvp_id ) );
if ( ! $this->memberData['g_is_supmod'] )
{
if( !$this->calendar['cal_rsvp_owner'] OR !$this->memberData['member_id'] OR ( $this->memberData['member_id'] != $event['event_member_id'] AND $this->memberData['member_id'] != $rsvp['rsvp_member_id'] ) )
{
$this->registry->output->showError( 'calendar_delete_no_perm', 1042.1, null, null, 403 );
}
}
//-----------------------------------------
// Delete attendee
//-----------------------------------------
$this->DB->delete( 'cal_event_rsvp', 'rsvp_id=' . $rsvp_id );
//-----------------------------------------
// Redirect
//-----------------------------------------
$this->registry->output->redirectScreen( $this->lang->words['cal_event_rsvpdelete'] , $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id=" . $event['event_id'], $event['event_title_seo'], 'cal_event' );
}
/**
* Deletes an event from the calendar
*
* @return @e void
*/
public function calendarEventDelete()
{
//-----------------------------------------
// Init
//-----------------------------------------
$event_id = intval( $this->request['event_id'] );
$md5check = trim( $this->request['md5check'] );
if ( !$event_id )
{
$this->registry->output->showError( 'calendar_bad_delete', 1041, null, null, 404 );
}
if ( $md5check != $this->member->form_hash )
{
$this->registry->output->showError( 'calendar_bad_key', 2040, null, null, 403 );
}
//-----------------------------------------
// Get event and check permissions
//-----------------------------------------
$event = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_events', 'where' => "event_id=" . $event_id . " AND event_calendar_id=" . $this->calendar['cal_id'] ) );
if ( ! $this->memberData['g_is_supmod'] )
{
if( !$this->memberData['member_id'] OR $this->memberData['member_id'] != $event['event_member_id'] )
{
$this->registry->output->showError( 'calendar_delete_no_perm', 1042, null, null, 403 );
}
}
//-----------------------------------------
// Delete event
//-----------------------------------------
$this->DB->delete( 'cal_events', 'event_id=' . $event_id );
$this->DB->delete( 'cal_event_ratings', 'rating_eid=' . $event_id );
$this->DB->delete( 'cal_event_comments', 'comment_eid=' . $event_id );
$this->DB->delete( 'cal_event_rsvp', 'rsvp_event_id=' . $event_id );
$this->DB->delete( 'cal_import_map', 'import_event_id=' . $event_id );
//-----------------------------------------
// Delete attachments
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
$class_attach = new $classToLoad( $this->registry );
$class_attach->type = 'event';
$class_attach->init();
$class_attach->bulkRemoveAttachment( array( $event_id ) );
//-----------------------------------------
// Remove likes
//-----------------------------------------
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
$_like = classes_like::bootstrap( 'calendar', 'events' );
$_like->remove( $event_id );
//-----------------------------------------
// Recache
//-----------------------------------------
$this->cache->rebuildCache( 'calendar_events', 'calendar' );
//-----------------------------------------
// Redirect
//-----------------------------------------
if ( $this->request['modcp'] == 'unapprovedevents' )
{
$this->registry->output->silentRedirect( $this->settings['base_url'] . 'app=core&module=modcp&fromapp=calendar&tab=unapprovedevents' );
}
else
{
$this->registry->output->redirectScreen( $this->lang->words['cal_event_delete'] , $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id=" . $this->calendar['cal_id'], $this->calendar['cal_title_seo'], 'cal_calendar' );
}
}
/**
* Approves an event
*
* @return @e void
*/
public function calendarEventApprove()
{
//-----------------------------------------
// Init
//-----------------------------------------
$event_id = intval( $this->request['event_id'] );
$md5check = trim( $this->request['md5check'] );
if ( ! $this->memberData['g_is_supmod'] )
{
$this->registry->output->showError( 'calendar_bad_approve', 1043, null, null, 403 );
}
if ( $md5check != $this->member->form_hash )
{
$this->registry->output->showError( 'calendar_bad_key', 2041, null, null, 403 );
}
//-----------------------------------------
// Get event
//-----------------------------------------
$event = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_events', 'where' => "event_id=" . $event_id . " AND event_calendar_id=" . $this->calendar['cal_id'] ) );
if( ! $event['event_id'] )
{
$this->registry->output->showError( 'calendar_event_not_found', 1045, null, null, 404 );
}
//-----------------------------------------
// Event approved?
//-----------------------------------------
$eventApproved = ( $event['event_approved'] ) ? 0 : 1;
//-----------------------------------------
// Update event
//-----------------------------------------
$this->DB->update( 'cal_events', array( 'event_approved' => $event['event_approved'] ? 0 : 1 ), 'event_id=' . $event_id );
//-----------------------------------------
// Hide likes
//-----------------------------------------
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
$_like = classes_like::bootstrap( 'calendar', 'events' );
$_like->toggleVisibility( $event_id, $event['event_approved'] ? 0 : 1 );
//-----------------------------------------
// Send notifications if approved
//-----------------------------------------
if ( $eventApproved )
{
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
$_like = classes_like::bootstrap( 'calendar', $type == 'edit' ? 'events' : 'calendars' );
$_url = $this->registry->output->buildSEOUrl( 'app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id=' . $event_id, 'public', $event['event_title_seo'], 'cal_event' );
$_author = IPSMember::load( $event['event_member_id'] );
$_like->sendNotifications( $event['event_calendar_id'], array( 'immediate', 'offline' ),
array(
'notification_key' => 'new_event',
'notification_url' => $_url,
'email_template' => 'add_event_follow',
'email_subject' => sprintf( $this->lang->words[ 'add_event_follow_subject'], $_url, $event['event_title'] ),
'build_message_array' => array(
'NAME' => '-member:members_display_name-',
'AUTHOR' => $_author['members_display_name'],
'TITLE' => $event['event_title'],
'URL' => $_url,
)
) );
}
//-----------------------------------------
// Recache
//-----------------------------------------
$this->cache->rebuildCache( 'calendar_events', 'calendar' );
//-----------------------------------------
// Redirect
//-----------------------------------------
$_dateData = explode( ' ', $event['event_start_date'] );
$_dateBits = explode( '-', $_dateData[0] );
if ( $this->request['modcp'] == 'unapprovedevents' )
{
$this->registry->output->silentRedirect( $this->settings['base_url'] . 'app=core&module=modcp&fromapp=calendar&tab=unapprovedevents' );
}
else
{
$this->registry->output->silentRedirect( $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}&amp;do=showday&amp;y={$_dateBits[0]}&amp;m={$_dateBits[1]}&amp;d={$_dateBits[2]}&amp;modfilter={$this->request['modfilter']}", $this->calendar['cal_title_seo'], true, 'cal_day' );
}
}
}
@@ -0,0 +1,921 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* Calendar View
* Last Updated: $Date: 2012-10-11 17:27:04 -0400 (Thu, 11 Oct 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Calendar
* @link http://www.invisionpower.com
* @version $Rev: 11446 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class public_calendar_calendar_post extends ipsCommand
{
/**
* Calendar data
*
* @var array
*/
protected $calendar = array();
/**
* Calendar functions
*
* @var object
*/
protected $functions;
/**
* Class entry point
*
* @param object Registry reference
* @return @e void [Outputs to screen/redirects]
*/
public function doExecute( ipsRegistry $registry )
{
//-----------------------------------------
// Init
//-----------------------------------------
$this->registry->class_localization->loadLanguageFile( array( 'public_calendar' ), 'calendar' );
$this->registry->class_localization->loadLanguageFile( array( 'public_usercp' ), 'core' );
$this->registry->class_localization->loadLanguageFile( array( 'public_post' ), 'forums' );
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'calendar' ) . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar' );
$this->functions = new $classToLoad( $this->registry );
$this->calendar = $this->functions->getCalendar();
$this->timezone = ( $this->memberData['time_offset'] OR $this->memberData['time_offset'] === '0' OR $this->memberData['time_offset'] === 0 ) ? $this->memberData['time_offset'] : $this->settings['time_offset'];
//-----------------------------------------
// Check permissions
//-----------------------------------------
if ( !$this->memberData['member_id'] )
{
$this->registry->output->showError( 'calendar_no_guests', 1046, null, null, 403 );
}
if ( !$this->registry->permissions->check( 'start', $this->calendar ) )
{
$this->registry->output->showError( 'calendar_no_post_perm', 1047, null, null, 403 );
}
//-----------------------------------------
// Start output stuff
//-----------------------------------------
$this->registry->output->addNavigation( $this->lang->words['cal_page_title'], 'app=calendar', 'false', 'app=calendar' );
$this->registry->output->addNavigation( $this->calendar['cal_title'], "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id={$this->calendar['cal_id']}", $this->calendar['cal_title_seo'], 'cal_calendar' );
//-----------------------------------------
// What are we doing
//-----------------------------------------
switch( $this->request['do'] )
{
case 'newevent':
$this->calendarEventForm( 'add' );
break;
case 'addnewevent':
$this->calendarEventSave( 'add' );
break;
case 'edit':
$this->calendarEventForm( 'edit' );
break;
case 'doedit':
$this->calendarEventSave( 'edit' );
break;
}
//-----------------------------------------
// Output
//-----------------------------------------
$this->registry->output->setTitle( $this->lang->words['cal_page_title'] . ' - ' . $this->settings['board_name'] );
$this->registry->output->addContent( $this->output );
$this->registry->output->sendOutput();
}
/**
* Form for creating/modifying calendar events
*
* @param string $type Either add or edit
* @return @e void
*/
public function calendarEventForm( $type='add' )
{
//-----------------------------------------
// Init
//-----------------------------------------
$event_id = $this->request['event_id'] ? intval( $this->request['event_id'] ) : 0;
$calendar_jump = $this->functions->getCalendarJump( $this->calendar['cal_id'], array( 'start' ) );
$group_select = '';
$allDay = 1;
//-----------------------------------------
// Output stuff
//-----------------------------------------
$this->registry->output->addToDocumentHead( 'javascript', "{$this->settings['js_base_url']}js/3rd_party/calendar_date_select/calendar_date_select.js" );
if( $this->settings['calendar_date_select_locale'] AND $this->settings['calendar_date_select_locale'] != 'en' )
{
$this->registry->output->addToDocumentHead( 'javascript', "{$this->settings['js_base_url']}js/3rd_party/calendar_date_select/locale/{$this->settings['calendar_date_select_locale']}.js" );
}
$this->registry->output->addToDocumentHead( 'javascript', "{$this->settings['js_base_url']}js/3rd_party/calendar_date_select/format_{$this->settings['cal_date_format']}.js" );
$this->registry->output->addToDocumentHead( 'importcss', "{$this->settings['css_base_url']}style_css/{$this->registry->output->skin['_csscacheid']}/calendar_select.css" );
//-----------------------------------------
// Adding or editing?
//-----------------------------------------
if( $type == 'add' )
{
if( $this->timezone )
{
$_offset = ( $this->timezone * 3600 );
}
$nd = $this->request['d'] ? str_pad( $this->request['d'], 2, '0', STR_PAD_LEFT ) : gmstrftime( '%d', time() + $_offset );
$nm = $this->request['m'] ? str_pad( $this->request['m'], 2, '0', STR_PAD_LEFT ) : gmstrftime( '%m', time() + $_offset );
$ny = $this->request['y'] ? $this->request['y'] : gmstrftime( '%Y', time() + $_offset );
$nh = $this->settings['cal_time_format'] == 'standard' ? gmstrftime( '%I', time() + $_offset ) : gmstrftime( '%H', time() + $_offset );
$nmi = '00';
$nap = gmstrftime( '%p', time() + $_offset );
$_fauxEndTime = strtotime( "now + 2 hours" );
$fd = gmstrftime( '%d', $_fauxEndTime + $_offset );
$fm = gmstrftime( '%m', $_fauxEndTime + $_offset );
$fy = gmstrftime( '%Y', $_fauxEndTime + $_offset );
$fh = $this->settings['cal_time_format'] == 'standard' ? gmstrftime( '%I', $_fauxEndTime + $_offset ) : gmstrftime( '%H', $_fauxEndTime + $_offset );
$fmi = '00';
$fap = gmstrftime( '%p', $_fauxEndTime + $_offset );
$_setEndTime = false;
$event = array(
'event_smilies' => 1,
'event_content' => '',
'event_timeset' => '',
'event_recurring' => 0,
'event_id' => 0,
'event_post_key' => $this->request['post_key'] ? $this->request['post_key'] : md5( uniqid( microtime(), true ) ),
);
}
else
{
//-----------------------------------------
// Get event
//-----------------------------------------
if ( !$event_id )
{
$this->registry->output->showError( 'calendar_event_not_found', 1048, null, null, 404 );
}
$event = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_events', 'where' => 'event_id=' . $event_id ) );
if ( !$event['event_id'] )
{
$this->registry->output->showError( 'calendar_event_not_found', 1049, null, null, 404 );
}
//-----------------------------------------
// Check permissions
//-----------------------------------------
if ( $event['event_perms'] != '*' )
{
$permissionGroups = explode( ',', IPSText::cleanPermString( $event['event_perms'] ) );
if( !IPSMember::isInGroup( $this->memberData, $permissionGroups ) )
{
$this->registry->output->showError( 'calendar_event_not_found', 10411, null, null, 404 );
}
}
if ( !$this->memberData['g_is_supmod'] AND $this->memberData['member_id'] != $event['event_member_id'] )
{
$this->registry->output->showError( 'calendar_no_edit_perm', 10410, null, null, 403 );
}
//-----------------------------------------
// Date stuff
//-----------------------------------------
$_eventStart = strtotime( $event['event_start_date'] );
$_eventEnd = ( $event['event_end_date'] AND $event['event_end_date'] != '0000-00-00 00:00:00' ) ? strtotime( $event['event_end_date'] ) : 0;
//-----------------------------------------
// Apply timezone offset for editing user
//-----------------------------------------
if( $this->timezone AND !$event['event_all_day'] )
{
$_eventStart += ( $this->timezone * 3600 );
$_eventEnd = $_eventEnd ? ( $_eventEnd + ( $this->timezone * 3600 ) ) : 0;
}
$_hour = $this->settings['cal_time_format'] == 'standard' ? '%I' : '%H';
list( $nd, $nm, $ny, $nh, $nmi, $nap, $_nh ) = explode( '-', gmstrftime( "%d-%m-%Y-{$_hour}-%M-%p-%H", $_eventStart ) );
if( $_eventEnd )
{
list( $fd, $fm, $fy, $fh, $fmi, $fap ) = explode( '-', gmstrftime( "%d-%m-%Y-{$_hour}-%M-%p", $_eventEnd ) );
$_setEndTime = true;
}
else
{
$fd = $fm = $fy = $fh = $fmi = $fap = 0;
$_setEndTime = false;
}
$allDay = $event['event_all_day'];
}
//-----------------------------------------
// If we are previewing, reset..
//-----------------------------------------
if( $this->request['preview'] )
{
$event['event_title'] = $this->request['event_title'];
$event['event_recurring'] = $this->request['set_recurfields'] ? $this->request['recur_unit'] : 0;
$event['event_private'] = $this->request['e_type'] == 'public' ? 0 : 1;
$event['event_smilies'] = $this->request['event_smilies'];
$event['event_content'] = $_POST['Post'];
$event['event_perms'] = count($this->request['e_groups']) ? implode( ",", $this->request['e_groups'] ) : '*';
$_ndate = $this->request['start_date'];
$_stTime = explode( ':', $this->request['start_time'] );
$nh = $_stTime[0];
$nmi = $_stTime[1];
$nap = $this->request['start_time_ampm'];
$_edate = $this->request['end_date'];
$_etTime = explode( ':', $this->request['end_time'] );
$fh = $_etTime[0];
$fmi = $_etTime[1];
$fap = $this->request['end_time_ampm'];
$allDay = $this->request['all_day'];
$_setEndTime = $this->request['set_enddate'];
$this->timezone = $this->request['event_timezone'];
}
//-----------------------------------------
// Time zone dropdown
//-----------------------------------------
$_timeZoneOptions = '';
foreach( $this->lang->words as $_key => $_word )
{
if( preg_match( "/^time_(-?[\d\.]+)$/", $_key, $match ) )
{
$_timeZoneOptions .= "<option value='{$match[1]}'" . ( $this->timezone == $match[1] ? " selected='selected'" : '' ) . ">{$_word}</option>\n";
}
}
//-----------------------------------------
// Get editor
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
$editor = new $classToLoad();
//-----------------------------------------
// Build group select menu
//-----------------------------------------
if( $this->memberData['g_access_cp'] )
{
foreach( $this->caches['group_cache'] as $r )
{
$selected = IPSMember::isInGroup( array( 'member_group_id' => $r['g_id'], 'mgroup_others' => '' ), explode( ',', IPSText::cleanPermString( $event['event_perms'] ) ), false ) ? " selected='selected'" : '';
$group_select .= "<option value='" . $r['g_id'] . "'" . $selected . ">" . $r['g_title'] . "</option>\n";
}
}
//-----------------------------------------
// Unparse event content for editing
//-----------------------------------------
if ( $event['event_content'] )
{
$editor->setContent( $event['event_content'], 'calendar' );
}
//-----------------------------------------
// Get attachments class
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
$class_attach = new $classToLoad( $this->registry );
$class_attach->type = 'event';
$class_attach->attach_post_key = $event['event_post_key'];
$class_attach->init();
$class_attach->getUploadFormSettings();
//-----------------------------------------
// Date (formatted based on setting)
//-----------------------------------------
if( !$this->request['preview'] )
{
switch( $this->settings['cal_date_format'] )
{
case 'american':
default:
$_ndate = $nm . '/' . $nd . '/' . $ny;
$_edate = $fm ? $fm . '/' . $fd . '/' . $fy : '';
break;
case 'danish':
$_ndate = $ny . '/' . $nm . '/' . $nd;
$_edate = $fm ? $fy . '/' . $fm . '/' . $fd : '';
break;
case 'italian':
$_ndate = $nd . '/' . $nm . '/' . $ny;
$_edate = $fm ? $fd . '/' . $fm . '/' . $fy : '';
break;
case 'db':
$_ndate = $ny . '-' . $nm . '-' . $nd;
$_edate = $fm ? $fy . '-' . $fm . '-' . $fd : '';
break;
}
}
//-----------------------------------------
// Output
//-----------------------------------------
$this->output .= $this->registry->output->getTemplate( 'calendar' )->calendarEventForm(
array(
'event' => $event,
'calendar' => $this->calendar,
'code' => $type == 'edit' ? 'doedit' : 'addnewevent',
'jump' => $calendar_jump,
'timezone' => $this->timezone,
'_time_zones' => $_timeZoneOptions,
'_can_set_rsvp' => $this->registry->permissions->check( 'askrsvp', $this->calendar ),
'dates' => array(
'nd' => $nd,
'nm' => $nm,
'ny' => $ny,
'nh' => $nh,
'nmi' => $nmi,
'nap' => $nap,
'fd' => $fd,
'fm' => $fm,
'fy' => $fy,
'fh' => $fh,
'fmi' => $fmi,
'fap' => $fap,
'allday' => $allDay,
'enddate' => $_setEndTime,
'ndate' => $_ndate,
'edate' => $_edate,
),
'_groupSelect' => $group_select,
'editor' => $editor->show( 'Post' ),
'button' => $type == 'edit' ? $this->lang->words['calendar_edit_submit'] : $this->lang->words['calendar_submit'],
'uploadForm' => $this->memberData['g_attach_max'] != -1 ?
$this->registry->getClass('output')->getTemplate('post')->uploadForm( $event['event_post_key'], 'event', $class_attach->attach_stats, $event['event_id'], 0 ) :
"",
)
);
$this->registry->output->addNavigation( $this->lang->words['post_new_event'] );
}
/**
* Saves the add/edit calendar event form
*
* @param string $type Either add or edit
* @return @e void
*/
public function calendarEventSave( $type='add' )
{
//-----------------------------------------
// Check permissions
//-----------------------------------------
if ( $this->request['auth_key'] != $this->member->form_hash )
{
$this->registry->output->showError( 'no_permission', 10410, null, null, 403 );
}
if( $this->request['preview'] )
{
return $this->calendarEventForm( $type );
}
//-----------------------------------------
// Init
//-----------------------------------------
$event_id = intval( $this->request['event_id'] );
$calendar_id = intval( $this->request['event_calendar_id'] );
$_calendar = $this->functions->getCalendar( $calendar_id );
$event_title = IPSText::getTextClass( 'bbcode' )->stripBadWords( trim( $this->request['event_title'] ) );
$start_date = '';
$end_date = '';
$recurring = 0;
//-----------------------------------------
// Verify start date/time
//-----------------------------------------
switch( $this->settings['cal_date_format'] )
{
case 'american':
default:
$_startBits = explode( '/', $this->request['start_date'] );
if( $this->request['set_enddate'] )
{
$_endBits = $this->request['end_date'] ? explode( '/', $this->request['end_date'] ) : array();
}
break;
case 'danish':
$_inputStart = explode( '/', $this->request['start_date'] );
$_startBits = array(
0 => $_inputStart[1],
1 => $_inputStart[2],
2 => $_inputStart[0],
);
if( $this->request['set_enddate'] )
{
$_inputEnd = $this->request['end_date'] ? explode( '/', $this->request['end_date'] ) : array();
$_endBits = array(
0 => $_inputEnd[1],
1 => $_inputEnd[2],
2 => $_inputEnd[0],
);
}
break;
case 'italian':
$_inputStart = explode( '/', $this->request['start_date'] );
$_startBits = array(
0 => $_inputStart[1],
1 => $_inputStart[0],
2 => $_inputStart[2],
);
if( $this->request['set_enddate'] )
{
$_inputEnd = $this->request['end_date'] ? explode( '/', $this->request['end_date'] ) : array();
$_endBits = array(
0 => $_inputEnd[1],
1 => $_inputEnd[0],
2 => $_inputEnd[2],
);
}
break;
case 'db':
$_inputStart = explode( '-', $this->request['start_date'] );
$_startBits = array(
0 => $_inputStart[1],
1 => $_inputStart[2],
2 => $_inputStart[0],
);
if( $this->request['set_enddate'] )
{
$_inputEnd = $this->request['end_date'] ? explode( '-', $this->request['end_date'] ) : array();
$_endBits = array(
0 => $_inputEnd[1],
1 => $_inputEnd[2],
2 => $_inputEnd[0],
);
}
break;
}
if( !$this->request['start_date'] OR count($_startBits) != 3 )
{
$this->registry->output->showError( 'calendar_invalid_date', 10427.0 );
}
else if( !@checkdate( $_startBits[0], $_startBits[1], $_startBits[2] ) )
{
$this->registry->output->showError( 'calendar_invalid_date', 10427.1 );
}
if( $this->request['all_day'] )
{
$start_date = gmmktime( 0, 0, 0, $_startBits[0], $_startBits[1], $_startBits[2] );
}
else
{
$_time = explode( ':', $this->request['start_time'] );
if( $this->settings['cal_time_format'] == 'standard' )
{
if( count($_time) != 2 OR $_time[0] > 12 OR $_time[1] > 59 )
{
$this->registry->output->showError( 'calendar_invalid_time', 10427.2 );
}
if( $this->request['start_time_ampm'] == 'PM' AND $_time[0] < 12 )
{
$_time[0] += 12;
}
else if( $this->request['start_time_ampm'] == 'AM' AND $_time[0] == 12 )
{
$_time[0] = 0;
}
}
else
{
if( count($_time) != 2 OR $_time[0] > 23 OR $_time[1] > 59 )
{
$this->registry->output->showError( 'calendar_invalid_time', 10427.2 );
}
}
$start_date = gmmktime( $_time[0], $_time[1], 0, $_startBits[0], $_startBits[1], $_startBits[2] );
}
//-----------------------------------------
// Verify end date/time
//-----------------------------------------
if( $this->request['set_enddate'] )
{
if( count($_endBits) != 3 )
{
$this->registry->output->showError( 'calendar_invalid_date', 10427.3 );
}
else if( !@checkdate( $_endBits[0], $_endBits[1], $_endBits[2] ) )
{
$this->registry->output->showError( 'calendar_invalid_date', 10427.4 );
}
if( $this->request['all_day'] )
{
$end_date = gmmktime( 0, 0, 0, $_endBits[0], $_endBits[1], $_endBits[2] );
}
else
{
$_time = explode( ':', $this->request['end_time'] );
if( $this->settings['cal_time_format'] == 'standard' )
{
if( count($_time) != 2 OR $_time[0] > 12 OR $_time[1] > 59 )
{
$this->registry->output->showError( 'calendar_invalid_date', 10427.5 );
}
if( $this->request['end_time_ampm'] == 'PM' )
{
$_time[0] += 12;
}
}
else
{
if( count($_time) != 2 OR $_time[0] > 23 OR $_time[1] > 59 )
{
$this->registry->output->showError( 'calendar_invalid_date', 10427.5 );
}
}
$end_date = gmmktime( $_time[0], $_time[1], 0, $_endBits[0], $_endBits[1], $_endBits[2] );
}
}
if( $end_date AND $end_date < $start_date )
{
$this->registry->output->showError( 'calendar_range_wrong', 10421 );
}
else if( $this->request['end_date'] AND $this->request['set_enddate'] AND !$end_date )
{
$this->registry->output->showError( 'calendar_range_wrong', 10421.1 );
}
//-----------------------------------------
// Set recurring flag
//-----------------------------------------
if( $this->request['set_recurfields'] )
{
if( !$end_date )
{
$this->registry->output->showError( 'recurring_requires_enddate', 10427.6 );
}
$recurring = intval($this->request['recur_unit']);
}
//-----------------------------------------
// Adjust to GMT
//-----------------------------------------
if( $this->request['event_timezone'] AND !$this->request['all_day'] )
{
$start_date = $start_date - ( $this->request['event_timezone'] * 3600 );
if( $end_date )
{
$end_date = $end_date - ( $this->request['event_timezone'] * 3600 );
}
}
$start_date = gmstrftime( "%Y-%m-%d %H:%M:00", $start_date );
$end_date = $end_date ? gmstrftime( "%Y-%m-%d %H:%M:00", $end_date ) : 0;
//-----------------------------------------
// Check posted content for errors
//-----------------------------------------
if ( strlen( trim( IPSText::removeControlCharacters( IPSText::br2nl( $_POST['Post'] ) ) ) ) < 1 )
{
$this->registry->output->showError( 'calendar_post_too_short', 10417, null, null, 403 );
}
$this->settings['max_post_length'] = $this->settings['max_post_length'] ? $this->settings['max_post_length'] : 2140000;
if( IPSText::mbstrlen( $_POST['Post'] ) > ( $this->settings['max_post_length'] * 1024 ) )
{
$this->registry->output->showError( 'calendar_post_too_long', 10418, null, null, 403 );
}
if( !$event_title OR IPSText::mbstrlen( $event_title ) < 2 )
{
$this->registry->output->showError( 'calendar_no_title', 10419, null, null, 403 );
}
if( IPSText::mbstrlen( $event_title ) > 200 )
{
$this->registry->output->showError( 'calendar_title_too_long', 10420, null, null, 403 );
}
//-----------------------------------------
// Adding or editing?
//-----------------------------------------
if ( $type == 'edit' )
{
//-----------------------------------------
// Get event
//-----------------------------------------
if ( ! $event_id )
{
$this->registry->output->showError( 'calendar_event_not_found', 10414, null, null, 404 );
}
$event = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_events', 'where' => 'event_id=' . $event_id ) );
if ( !$event['event_id'] )
{
$this->registry->output->showError( 'calendar_event_not_found', 10415, null, null, 404 );
}
//-----------------------------------------
// Do we have permission to edit?
//-----------------------------------------
if ( !$this->memberData['g_is_supmod'] AND $this->memberData['member_id'] != $event['event_member_id'] )
{
$this->registry->output->showError( 'calendar_no_edit_perm', 10416, null, null, 403 );
}
}
//-----------------------------------------
// Set event view permissions
//-----------------------------------------
if( $this->memberData['g_access_cp'] )
{
if( is_array( $this->request['e_groups'] ) )
{
foreach( $this->cache->getCache('group_cache') as $group )
{
if( $group['g_access_cp'] )
{
$this->request['e_groups'][] = $group['g_id'];
}
}
$read_perms = implode( ",", $this->request['e_groups'] );
}
}
$read_perms = $read_perms ? $read_perms : '*';
//-----------------------------------------
// Get editor and format post
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
$editor = new $classToLoad();
$event_content = $editor->process( $_POST['Post'] );
IPSText::getTextClass( 'bbcode' )->parse_html = 0;
IPSText::getTextClass( 'bbcode' )->parse_smilies = intval($this->request['enableemo']);
IPSText::getTextClass( 'bbcode' )->parse_bbcode = 1;
IPSText::getTextClass( 'bbcode' )->parsing_section = 'calendar';
$event_content = IPSText::getTextClass( 'bbcode' )->preDbParse( $event_content );
//-----------------------------------------
// Event approved?
//-----------------------------------------
if( $this->request['e_type'] == 'private' )
{
$event_approved = 1;
}
else
{
$event_approved = $this->registry->permissions->check( 'nomod', $_calendar ) ? 1 : ( $_calendar['cal_moderate'] ? 0 : 1 );
}
//-----------------------------------------
// Store the event
//-----------------------------------------
if ( $type == 'add' )
{
//-----------------------------------------
// Format array for storage
//-----------------------------------------
$_eventData = array(
'event_calendar_id' => $calendar_id,
'event_member_id' => $this->memberData['member_id'],
'event_content' => $event_content,
'event_title' => $event_title,
'event_title_seo' => IPSText::makeSeoTitle( $event_title ),
'event_smilies' => intval($this->request['enableemo']),
'event_comments' => 0,
'event_perms' => $read_perms,
'event_private' => $this->request['e_type'] == 'private' ? 1 : 0,
'event_approved' => $event_approved,
'event_saved' => time(),
'event_lastupdated' => time(),
'event_recurring' => $recurring,
'event_start_date' => $start_date,
'event_end_date' => $end_date,
'event_post_key' => $this->request['post_key'],
'event_rsvp' => $this->registry->permissions->check( 'askrsvp', $_calendar ) ? intval($this->request['event_rsvp']) : 0,
'event_sequence' => 0,
'event_all_day' => intval($this->request['all_day']),
);
//-----------------------------------------
// Data hooks
//-----------------------------------------
IPSLib::doDataHooks( $_eventData, 'calendarAddEvent' );
//-----------------------------------------
// Insert
//-----------------------------------------
$this->DB->insert( 'cal_events', $_eventData );
$event_id = $this->DB->getInsertId();
//-----------------------------------------
// Set language strings
//-----------------------------------------
$_langString = $event_approved ? $this->lang->words['new_event_redirect'] : $this->lang->words['new_event_mod'];
}
else
{
//-----------------------------------------
// Format array for storage
//-----------------------------------------
$_eventData = array(
'event_calendar_id' => $calendar_id,
'event_content' => $event_content,
'event_title' => $event_title,
'event_title_seo' => IPSText::makeSeoTitle( $event_title ),
'event_smilies' => intval($this->request['enableemo']),
'event_perms' => $read_perms,
'event_private' => $this->request['e_type'] == 'private' ? 1 : 0,
'event_approved' => $event_approved,
'event_lastupdated' => time(),
'event_recurring' => $recurring,
'event_start_date' => $start_date,
'event_end_date' => $end_date,
'event_post_key' => $this->request['post_key'],
'event_rsvp' => $this->registry->permissions->check( 'askrsvp', $_calendar ) ? intval($this->request['event_rsvp']) : $event['event_rsvp'],
'event_sequence' => intval($event['event_rsvp']) + 1,
'event_all_day' => intval($this->request['all_day']),
);
//-----------------------------------------
// Data hooks
//-----------------------------------------
IPSLib::doDataHooks( $_eventData, 'calendarEditEvent' );
//-----------------------------------------
// Update database
//-----------------------------------------
$this->DB->update( 'cal_events', $_eventData, 'event_id=' . $event_id );
//-----------------------------------------
// Set language strings
//-----------------------------------------
$_langString = $event_approved ? $this->lang->words['edit_event_redirect'] : $this->lang->words['new_event_mod'];
}
//-----------------------------------------
// Upload attachments
//-----------------------------------------
if( $this->memberData['g_attach_max'] != -1 )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
$class_attach = new $classToLoad( $this->registry );
$class_attach->type = 'event';
$class_attach->attach_post_key = $_eventData['event_post_key'];
$class_attach->attach_rel_id = $event_id;
$class_attach->init();
$class_attach->processMultipleUploads();
$class_attach->postProcessUpload( array() );
}
//-----------------------------------------
// Send notifications
//-----------------------------------------
if ( $event_approved )
{
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
$_like = classes_like::bootstrap( 'calendar', $type == 'edit' ? 'events' : 'calendars' );
$_url = $this->registry->output->buildSEOUrl( 'app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id=' . $event_id, 'public', $_eventData['event_title_seo'], 'cal_event' );
$_like->sendNotifications( $type == 'edit' ? $event_id : $_eventData['event_calendar_id'], array( 'immediate', 'offline' ),
array(
'notification_key' => $type == 'edit' ? 'updated_event' : 'new_event',
'notification_url' => $_url,
'email_template' => $type. '_event_follow',
'email_subject' => sprintf( $this->lang->words[ $type . '_event_follow_subject'], $_url, $_eventData['event_title'] ),
'build_message_array' => array(
'NAME' => '-member:members_display_name-',
'AUTHOR' => $this->memberData['members_display_name'],
'TITLE' => $_eventData['event_title'],
'URL' => $_url,
)
) );
}
//-----------------------------------------
// Rebuild cache
//-----------------------------------------
$this->cache->rebuildCache( 'calendar_events', 'calendar' );
//-----------------------------------------
// Redirect
//-----------------------------------------
if ( $event_approved )
{
$this->registry->output->redirectScreen( $_langString, $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id=" . $event_id, $_eventData['event_title_seo'], 'cal_event' );
}
else
{
$this->registry->output->redirectScreen( $_langString, $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;section=view&amp;cal_id=" . $calendar_id, $this->caches['calendars'][ $calendar_id ]['cal_title_seo'], 'cal_calendar' );
}
}
}
@@ -0,0 +1,194 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* Add rating fallback
* Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Calendar
* @link http://www.invisionpower.com
* @since 25th January 2011
* @version $Revision: 10721 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class public_calendar_calendar_rating extends ipsCommand
{
/**
* Class entry point
*
* @access public
* @param object Registry reference
* @return @e void [Outputs to screen/redirects]
*/
public function doExecute( ipsRegistry $registry )
{
//-----------------------------------------
// Check key
//-----------------------------------------
if ( $this->request['secure_key'] != $this->member->form_hash )
{
$this->registry->output->showError( 'usercp_forums_bad_key', 104100, null, null, 403 );
}
//-----------------------------------------
// INIT
//-----------------------------------------
$event_id = intval($this->request['event_id']);
$rating_id = intval($this->request['rating']);
$this->registry->class_localization->loadLanguageFile( array( 'public_calendar' ) );
//-----------------------------------------
// Functions class
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'calendar' ) . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar' );
$functions = new $classToLoad( $this->registry );
//-----------------------------------------
// Get data
//-----------------------------------------
if ( ! $event_id )
{
$this->registry->output->showError( 'no_event_for_rate', 104101, null, null, 404 );
}
$event = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_events', 'where' => 'event_id=' . $event_id ) );
if( !$event['event_id'] )
{
$this->registry->output->showError( 'no_event_for_rate', 104102, null, null, 404 );
}
//-----------------------------------------
// Check permissions
//-----------------------------------------
if( !$event['event_approved'] )
{
$this->registry->output->showError( 'no_event_for_rate', 104103, null, null, 404 );
}
if( $event['event_private'] )
{
if( ! $this->memberData['member_id'] OR $this->memberData['member_id'] != $event['event_member_id'] )
{
$this->registry->output->showError( 'no_event_for_rate', 104104, null, null, 404 );
}
}
if( $event['event_perms'] != '*' )
{
$permissionGroups = explode( ',', IPSText::cleanPermString( $event['event_perms'] ) );
if( !IPSMember::isInGroup( $this->memberData, $permissionGroups ) )
{
$this->registry->output->showError( 'no_event_for_rate', 104105, null, null, 404 );
}
}
//-----------------------------------------
// Get our calendar
//-----------------------------------------
$calendar = $functions->getCalendar( $event['event_calendar_id'] );
if( !$calendar['cal_id'] OR $calendar['cal_id'] != $event['event_calendar_id'] )
{
$this->registry->output->showError( 'no_event_for_rate', 104106, null, null, 404 );
}
//-----------------------------------------
// Can we rate?
//-----------------------------------------
$_can_rate = ( $this->memberData['member_id'] AND $this->registry->permissions->check( 'rate', $calendar ) ) ? intval( $this->memberData['g_topic_rate_setting'] ) : 0;
if ( ! $_can_rate )
{
$this->registry->output->showError( 'no_rate_permission', 104107, null, null, 403 );
}
//-----------------------------------------
// Sneaky members rating more than 5?
//-----------------------------------------
if( $rating_id > 5 )
{
$rating_id = 5;
}
if( $rating_id < 0 )
{
$rating_id = 0;
}
//-----------------------------------------
// Have we rated before?
//-----------------------------------------
$rating = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_event_ratings', 'where' => "rating_eid={$event['event_id']} and rating_member_id=" . $this->memberData['member_id'] ) );
if ( $rating['rating_id'] )
{
//-----------------------------------------
// Do we allow re-ratings?
//-----------------------------------------
if ( $this->memberData['g_topic_rate_setting'] == 2 )
{
if ( $rating_id != $rating['rating_value'] )
{
$new_rating = $rating_id - $rating['rating_value'];
$this->DB->update( 'cal_event_ratings', array( 'rating_value' => $rating_id ), 'rating_id=' . $rating['rating_id'] );
$this->DB->update( 'cal_events', array(
'event_rating_total' => intval($event['event_rating_total']) + $new_rating,
'event_rating_avg' => round( ( intval($event['event_rating_total']) + $new_rating ) / $event['event_rating_hits'] )
), 'event_id=' . $event['event_id'] );
}
$this->registry->output->redirectScreen( $this->lang->words['event_rating_changed'] , $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id={$event['event_id']}", $event['event_title_seo'], 'cal_event' );
}
else
{
$this->registry->output->redirectScreen( $this->lang->words['event_rated_already'] , $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id={$event['event_id']}", $event['event_title_seo'], 'cal_event' );
}
}
else
{
$this->DB->insert( 'cal_event_ratings', array(
'rating_eid' => $event['event_id'],
'rating_member_id' => $this->memberData['member_id'],
'rating_value' => $rating_id,
'rating_ip_address' => $this->member->ip_address,
) );
$this->DB->update( 'cal_events', array(
'event_rating_total' => intval( $event['event_rating_total'] ) + $rating_id,
'event_rating_hits' => intval( $event['event_rating_hits'] ) + 1,
'event_rating_avg' => round( ( intval( $event['event_rating_total'] ) + $rating_id ) / ( intval( $event['event_rating_hits'] ) + 1 ) ),
), 'event_id=' . $event_id );
}
$this->registry->output->redirectScreen( $this->lang->words['event_rating_done'] , $this->settings['base_url'] . "app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id={$event['event_id']}", $event['event_title_seo'], 'cal_event' );
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,13 @@
<?php
/**
* @file defaultSection.php Define the default section for the 'feed' module
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: ips_terabyte $
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
* @version v3.4.5
* $Revision: 8655 $
*/
$DEFAULT_SECTION = 'output';
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -0,0 +1,126 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* Calendar iCalendar/webcal output
* Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
* </pre>
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Calendar
* @link http://www.invisionpower.com
* @version $Rev: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class public_calendar_feed_output extends ipsCommand
{
/**
* Calendar data
*
* @var array
*/
protected $calendar = array();
/**
* Calendar functions
*
* @var object
*/
protected $functions;
/**
* Class entry point
*
* @param object Registry reference
* @return @e void [Outputs to screen/redirects]
*/
public function doExecute( ipsRegistry $registry )
{
//-----------------------------------------
// Init
//-----------------------------------------
$this->registry->class_localization->loadLanguageFile( array( 'public_calendar' ), 'calendar' );
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'calendar' ) . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar' );
$this->functions = new $classToLoad( $this->registry );
$this->calendar = $this->functions->getCalendar();
//-----------------------------------------
// Switch
//-----------------------------------------
switch( $this->request['do'] )
{
default:
case 'download':
$this->downloadIcalFeed();
break;
}
}
/**
* Serve the iCalendar feed (valid for both download as .ics and webcal:// protocol)
*
* @return @e void
*/
public function downloadIcalFeed()
{
//-----------------------------------------
// Get main view class
//-----------------------------------------
$classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir( 'calendar' ) . '/modules_public/calendar/view.php', 'public_calendar_calendar_view' );
$calendar = new $classToLoad( $this->registry );
$calendar->makeRegistryShortcuts( $this->registry );
$calendar->initCalendar();
//-----------------------------------------
// Load (all) events
//-----------------------------------------
$calendar->calendarGetEventsSQL( gmstrftime( '%m' ), gmstrftime( '%Y' ), array( 'timenow' => '1', 'timethen' => '2000000000', 'cal_id' => $this->calendar['cal_id'], 'honor_permissions' => true, 'no_date_convert' => true ) );
$events = $calendar->calendarGetAllEvents();
//-----------------------------------------
// Load iCalendar class
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'calendar' ) . "/sources/icalendar.php", 'app_calendar_classes_icalendarOutput', 'calendar' );
$iCalendar = new $classToLoad( $this->registry, $this->calendar['cal_id'] );
//-----------------------------------------
// Send data to iCalendar class and get output
//-----------------------------------------
foreach( $events as $event )
{
$event = $calendar->calendarMakeEventHTML( $event, true );
$iCalendar->addEvent( $event );
}
$feed = $iCalendar->buildICalendarFeed();
//-----------------------------------------
// Output
//-----------------------------------------
@header( "Content-type: text/calendar; charset=" . IPS_DOC_CHAR_SET );
@header( "Content-Disposition: inline; filename=calendarEvents.ics" );
print $feed;
exit;
}
}
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>