Version 3.4.9
This commit is contained in:
1 parent
c603205a25
commit
f9e857d255
920 files changed
+28189
-6840
No files matched your search
@@ -0,0 +1,484 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.4.5
|
||||
* Calendar cache functions
|
||||
* Last Updated: $Date: 2013-01-03 17:27:27 -0500 (Thu, 03 Jan 2013) $
|
||||
* </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 5th January 2005
|
||||
* @version $Revision: 11781 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class calendar_cache
|
||||
{
|
||||
/**#@+
|
||||
* Registry objects
|
||||
*
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $registry;
|
||||
protected $DB;
|
||||
protected $settings;
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object $registry Registry object
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
/* Make object */
|
||||
$this->registry = $registry;
|
||||
$this->DB = $this->registry->DB();
|
||||
$this->settings =& $this->registry->fetchSettings();
|
||||
$this->request =& $this->registry->fetchRequest();
|
||||
$this->lang = $this->registry->getClass('class_localization');
|
||||
$this->member = $this->registry->member();
|
||||
$this->memberData =& $this->registry->member()->fetchMemberData();
|
||||
$this->cache = $this->registry->cache();
|
||||
$this->caches =& $this->registry->cache()->fetchCaches();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild calendar RSS cache
|
||||
*
|
||||
* @param mixed [$calendar_id] "all", or a specific calendar ID
|
||||
* @return string RSS document
|
||||
*/
|
||||
public function rebuildCalendarRSSCache( $calendar_id='all' )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Ensure calendar is installed
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$this->DB->checkForTable('cal_calendars') )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if( ! IPSLib::appIsInstalled( 'calendar' ) )
|
||||
{
|
||||
$this->cache->setCache( 'rss_calendar', array(), array( 'donow' => 1, 'array' => 1 ) );
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Init
|
||||
//-----------------------------------------
|
||||
|
||||
$seenids = array();
|
||||
$cache = array();
|
||||
|
||||
//--------------------------------------------
|
||||
// Get classes
|
||||
//--------------------------------------------
|
||||
|
||||
$classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir( 'calendar' ) . '/modules_public/calendar/view.php', 'public_calendar_calendar_view' );
|
||||
$calendar = new $classToLoad( $this->registry );
|
||||
$calendar->makeRegistryShortcuts( $this->registry );
|
||||
|
||||
if( !$calendar->initCalendar( true, true ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classRss.php', 'classRss' );
|
||||
$class_rss = new $classToLoad();
|
||||
$class_rss->doc_type = IPS_DOC_CHAR_SET;
|
||||
|
||||
//-----------------------------------------
|
||||
// Get calendars that support RSS and loop
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array(
|
||||
'select' => 'c.*',
|
||||
'from' => array( 'cal_calendars' => 'c' ),
|
||||
'where' => 'c.cal_rss_export_days > 0 AND c.cal_rss_export_max > 0 AND c.cal_rss_export=1',
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'p.*',
|
||||
'from' => array( 'permission_index' => 'p' ),
|
||||
'where' => "p.perm_type='calendar' AND perm_type_id=c.cal_id",
|
||||
'type' => 'left'
|
||||
)
|
||||
)
|
||||
) );
|
||||
$outer = $this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch( $outer ) )
|
||||
{
|
||||
$row['cal_rss_export_max'] = $row['cal_rss_export_max'] ? $row['cal_rss_export_max'] : 10;
|
||||
|
||||
if ( $row['cal_rss_export'] )
|
||||
{
|
||||
$cache[] = array( 'url' => $this->settings['board_url'] . '/index.php?app=core&module=global&section=rss&type=calendar&id=' . $row['cal_id'], 'title' => $row['cal_title'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Are we including events from this calendar?
|
||||
//-----------------------------------------
|
||||
|
||||
if( $calendar_id == $row['cal_id'] OR $calendar_id == 'all' )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Start channel
|
||||
//-----------------------------------------
|
||||
|
||||
$channel_id = $class_rss->createNewChannel( array(
|
||||
'title' => $row['cal_title'],
|
||||
'link' => $this->registry->output->buildSEOUrl( 'app=calendar&module=calendar&section=view&cal_id=' . $row['cal_id'], 'publicNoSession', $row['cal_title_seo'], 'cal_calendar' ),
|
||||
'pubDate' => $class_rss->formatDate( time() ),
|
||||
'ttl' => $row['cal_rss_update'] * 60,
|
||||
'description' => $row['cal_title']
|
||||
) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Verify if guests can view
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$this->registry->permissions->check( 'view', $row, explode( ',', IPSText::cleanPermString( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ) ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Sort out date stuff
|
||||
//-----------------------------------------
|
||||
|
||||
$row['cal_rss_export_days'] = intval($row['cal_rss_export_days']) + 1;
|
||||
$startTime = gmmktime( 0,0,0, gmstrftime( '%m' ), 1 );
|
||||
$endTime = gmmktime( 0,0,0, gmstrftime( '%m' ), gmstrftime( '%d' ) + $row['cal_rss_export_days'] );
|
||||
$nowTime = gmmktime( 0,0,0, gmstrftime( '%m' ), gmstrftime( '%d' ) - 1 );
|
||||
$items = 0;
|
||||
|
||||
list( $month, $day, $year ) = explode( '-', gmstrftime( '%m-%d-%Y' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Get the events
|
||||
//-----------------------------------------
|
||||
|
||||
$calendar->calendarGetEventsSQL( $month, $year, array( 'timenow' => $startTime, 'timethen' => $endTime, 'cal_id' => $row['cal_id'] ) );
|
||||
|
||||
//--------------------------------------------
|
||||
// Loop through events and cache
|
||||
//--------------------------------------------
|
||||
|
||||
for( $i = 0 ; $i <= $row['cal_rss_export_days'] ; $i++ )
|
||||
{
|
||||
list( $_month, $_day, $_year ) = explode( '-', gmstrftime( '%m-%d-%Y', $nowTime ) );
|
||||
|
||||
$eventcache = $calendar->calendarGetDayEvents( $_month, $_day, $_year );
|
||||
|
||||
foreach( $eventcache as $event )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Hit our max?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $row['cal_rss_export_max'] <= $items )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Can guests access?
|
||||
//-----------------------------------------
|
||||
|
||||
$permissionGroups = explode( ',', IPSText::cleanPermString( $event['event_perms'] ) );
|
||||
|
||||
if ( !$event['event_approved'] OR $event['event_private'] OR ( $event['event_perms'] != '*' AND !IPSMember::isInGroup( array( 'member_group_id' => $this->settings['guest_group'] ), $permissionGroups ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Check the event and add it
|
||||
//-----------------------------------------
|
||||
|
||||
if ( !in_array( $event['event_id'], $seenids ) )
|
||||
{
|
||||
if ( !$event['event_recurring'] OR $calendar->checkRecurring( $event, $_month, $_day, $_year ) )
|
||||
{
|
||||
$event = $calendar->calendarMakeEventHTML( $event, true );
|
||||
|
||||
if ( $event['event']['recurring'] )
|
||||
{
|
||||
$event['event']['event_content'] = $this->registry->output->getTemplate('calendar')->calendar_rss_recurring( $event['event'] );
|
||||
}
|
||||
else if ( $event['event']['single'] )
|
||||
{
|
||||
$event['event']['event_content'] = $this->registry->output->getTemplate('calendar')->calendar_rss_single( $event['event'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$event['event']['event_content'] = $this->registry->output->getTemplate('calendar')->calendar_rss_range( $event['event'] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Re-adjust the event time for the RSS feed
|
||||
// to represent the next occurrence of recurring
|
||||
// and ranged events
|
||||
//-----------------------------------------
|
||||
|
||||
if( $event['event']['event_recurring'] )
|
||||
{
|
||||
$_incrementor = 0;
|
||||
|
||||
switch( $event['event']['event_recurring'] )
|
||||
{
|
||||
case 1:
|
||||
$_incrementor = 604800;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$_incrementor = 2592000;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$_incrementor = 31536000;
|
||||
break;
|
||||
}
|
||||
|
||||
if( $event['event']['_start_time'] < gmmktime( 0 ) )
|
||||
{
|
||||
while( $event['event']['_start_time'] < gmmktime( 0 ) )
|
||||
{
|
||||
$event['event']['_start_time'] += $_incrementor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Ranged events
|
||||
//-----------------------------------------
|
||||
|
||||
else if( $event['event']['_end_time'] )
|
||||
{
|
||||
if( $event['event']['_start_time'] < gmmktime( 0 ) AND $event['event']['_end_time'] > gmmktime( 0 ) )
|
||||
{
|
||||
while( $event['event']['_start_time'] < gmmktime( 0 ) )
|
||||
{
|
||||
$event['event']['_start_time'] += 86400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Add to the channel
|
||||
//-----------------------------------------
|
||||
|
||||
$class_rss->addItemToChannel( $channel_id, array(
|
||||
'title' => $event['event']['event_title'],
|
||||
'link' => $this->registry->output->buildSEOUrl( 'app=calendar&module=calendar&section=view&do=showevent&event_id=' . $event['event']['event_id'], 'publicNoSession', $event['event']['event_title_seo'], 'cal_event' ),
|
||||
'description' => $event['event']['event_content'],
|
||||
'pubDate' => $class_rss->formatDate( $event['event']['_start_time'] ),
|
||||
'guid' => $event['event']['event_id']
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Increment counters and cache event
|
||||
//-----------------------------------------
|
||||
|
||||
$seenids[ $event['event']['event_id'] ] = $event['event']['event_id'];
|
||||
$items++;
|
||||
}
|
||||
}
|
||||
|
||||
$nowTime += 86400;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Create RSS document
|
||||
//-----------------------------------------
|
||||
|
||||
$class_rss->createRssDocument();
|
||||
|
||||
//-----------------------------------------
|
||||
// Update calendar RSS cache
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->update( 'cal_calendars', array( 'cal_rss_update_last' => time(), 'cal_rss_cache' => $class_rss->rss_document ), 'cal_id=' . $row['cal_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Update cache and return RSS document
|
||||
//-----------------------------------------
|
||||
|
||||
$this->cache->setCache( 'rss_calendar', $cache, array( 'donow' => 1, 'array' => 1 ) );
|
||||
|
||||
return $class_rss->rss_document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild upcoming events cache
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function rebuildCalendarEventsCache()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Ensure calendar is installed
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$this->DB->checkForTable('cal_calendars') )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! IPSLib::appIsInstalled( 'calendar' ) )
|
||||
{
|
||||
$this->cache->setCache( 'calendar_events', array(), array( 'array' => 1 ) );
|
||||
$this->cache->setCache( 'birthdays', array(), array( 'array' => 1 ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Init
|
||||
//-----------------------------------------
|
||||
|
||||
$this->settings['calendar_limit'] = ( intval( $this->settings['calendar_limit'] ) < 2 ? 1 : intval( $this->settings['calendar_limit'] ) ) + 1;
|
||||
|
||||
$birthdays = array();
|
||||
$events = array();
|
||||
$calendars = $this->cache->getCache('calendars');
|
||||
$seenids = array();
|
||||
|
||||
//--------------------------------------------
|
||||
// Set time stuff
|
||||
//--------------------------------------------
|
||||
|
||||
$startTime = gmmktime( 0,0,0, gmstrftime( '%m' ), 1 );
|
||||
$endTime = gmmktime( 0,0,0, gmstrftime( '%m' ), gmstrftime( '%d' ) + $this->settings['calendar_limit'] );
|
||||
$nowTime = gmmktime( 0,0,0, gmstrftime( '%m' ), gmstrftime( '%d' ) - 1 );
|
||||
|
||||
list( $month, $day, $year ) = explode( '-', gmstrftime( '%m-%d-%Y' ) );
|
||||
list( $last_month, $last_day, $last_year ) = explode( '-', gmstrftime( '%m-%d-%Y', $nowTime ) );
|
||||
list( $next_month, $next_day, $next_year ) = explode( '-', gmstrftime( '%m-%d-%Y', gmmktime( 0,0,0, gmstrftime( '%m' ), gmstrftime( '%d' ) + 1 ) ) );
|
||||
|
||||
//--------------------------------------------
|
||||
// Get classes
|
||||
//--------------------------------------------
|
||||
|
||||
$classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir( 'calendar' ) . '/modules_public/calendar/view.php', 'public_calendar_calendar_view' );
|
||||
$calendar = new $classToLoad( $this->registry );
|
||||
$calendar->makeRegistryShortcuts( $this->registry );
|
||||
|
||||
if( !$calendar->initCalendar( true, true ) )
|
||||
{
|
||||
$this->cache->setCache( 'calendar_events' , array(), array( 'array' => 1 ) );
|
||||
$this->cache->setCache( 'birthdays', array(), array( 'array' => 1 ) );
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
// Load the events
|
||||
//--------------------------------------------
|
||||
|
||||
$calendar->calendarGetEventsSQL( $month, $year, array( 'timenow' => $startTime, 'timethen' => $endTime, 'minimal' => true, 'no_date_convert' => true ) );
|
||||
|
||||
//--------------------------------------------
|
||||
// Loop through events and cache
|
||||
//--------------------------------------------
|
||||
|
||||
for( $i = 0 ; $i <= $this->settings['calendar_limit'] ; $i++ )
|
||||
{
|
||||
list( $_month, $_day, $_year ) = explode( '-', gmstrftime( '%m-%d-%Y', $nowTime ) );
|
||||
|
||||
$eventcache = $calendar->calendarGetDayEvents( $_month, $_day, $_year );
|
||||
|
||||
foreach( $eventcache as $event )
|
||||
{
|
||||
if ( $event['event_approved'] AND !in_array( $event['event_id'], $seenids ) )
|
||||
{
|
||||
if ( !$event['event_recurring'] OR $calendar->checkRecurring( $event, $_month, $_day, $_year ) )
|
||||
{
|
||||
unset( $event['event_content'], $event['event_smilies'] );
|
||||
|
||||
$event['perm_view'] = $calendars[ $event['event_calendar_id'] ]['perm_view'];
|
||||
$events[ $event['event_id'] ] = $event;
|
||||
}
|
||||
|
||||
$seenids[ $event['event_id'] ] = $event['event_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$nowTime += 86400;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Grab birthdays
|
||||
//-----------------------------------------
|
||||
|
||||
$append_string = "";
|
||||
|
||||
if( !gmdate("L") )
|
||||
{
|
||||
if( $month == 2 AND $day > 26 )
|
||||
{
|
||||
$append_string = " OR ( bday_month=2 AND bday_day=29 )";
|
||||
}
|
||||
}
|
||||
|
||||
$_days = array();
|
||||
|
||||
$this->DB->build( array(
|
||||
'select' => 'member_id, members_seo_name, members_display_name, member_group_id, bday_day, bday_month, bday_year',
|
||||
'from' => 'members',
|
||||
'where' => "member_banned=0 AND ( !" . IPSBWOptions::sql( 'bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has' ) . ")
|
||||
AND ( ( bday_day={$last_day} AND bday_month={$last_month} )
|
||||
OR ( bday_day={$day} AND bday_month={$month} )
|
||||
OR ( bday_day={$next_day} AND bday_month={$next_month} ) {$append_string} )"
|
||||
) );
|
||||
$this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
/* Only allow 6 per day, then the "upcoming birthdays" can display 5 and know there are more to display */
|
||||
$_days[ $r['bday_month'] . '.' . $r['bday_day'] ]++;
|
||||
|
||||
if( $_days[ $r['bday_month'] . '.' . $r['bday_day'] ] > 6 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$birthdays[ $r['member_id'] ] = $r;
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
// Update calendar array
|
||||
//--------------------------------------------
|
||||
|
||||
$this->cache->setCache( 'calendar_events' , $events, array( 'array' => 1 ) );
|
||||
$this->cache->setCache( 'birthdays', $birthdays, array( 'array' => 1 ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.4.5
|
||||
* Calendar functions
|
||||
* Last Updated: $Date: 2013-03-20 17:00:11 -0400 (Wed, 20 Mar 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
|
||||
* @since 5th January 2005
|
||||
* @version $Revision: 12096 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class app_calendar_classes_functions
|
||||
{
|
||||
/**#@+
|
||||
* Registry objects
|
||||
*
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $registry;
|
||||
protected $DB;
|
||||
protected $settings;
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Current calendar ID
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $calendarId;
|
||||
|
||||
/**
|
||||
* Calendar arrays (permissions checked)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $calendars = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object Registry object
|
||||
* @param bool Ignore permission check
|
||||
* @param bool Return instead of throwing an error
|
||||
* @return @e bool Initiated successfully
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry, $ignorePermissions=false, $return=false )
|
||||
{
|
||||
/* Make object */
|
||||
$this->registry = $registry;
|
||||
$this->DB = $this->registry->DB();
|
||||
$this->settings =& $this->registry->fetchSettings();
|
||||
$this->request =& $this->registry->fetchRequest();
|
||||
$this->lang = $this->registry->getClass('class_localization');
|
||||
$this->member = $this->registry->member();
|
||||
$this->memberData =& $this->registry->member()->fetchMemberData();
|
||||
$this->cache = $this->registry->cache();
|
||||
$this->caches =& $this->registry->cache()->fetchCaches();
|
||||
|
||||
//-----------------------------------------
|
||||
// Make sure calendar app is installed
|
||||
// (this is primarily here for API methods)
|
||||
//-----------------------------------------
|
||||
|
||||
if( ! IPSLib::appIsInstalled( 'calendar' ) AND ( !defined('IPS_IS_INSTALLER') OR !IPS_IS_INSTALLER ) AND ( !defined('IPS_IS_UPGRADER') OR !IPS_IS_UPGRADER ) )
|
||||
{
|
||||
if( $return )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->registry->output->showError( 'no_permission', 1076, null, null, 404 );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Check cache
|
||||
//-----------------------------------------
|
||||
|
||||
if( ! count( $this->caches['calendars'] ) )
|
||||
{
|
||||
$this->cache->rebuildCache( 'calendars', 'calendar' );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Loop through, check perms, etc.
|
||||
//-----------------------------------------
|
||||
|
||||
$_noPermission = array();
|
||||
|
||||
if ( count( $this->caches['calendars'] ) AND is_array( $this->caches['calendars'] ) )
|
||||
{
|
||||
foreach( $this->caches['calendars'] as $cal_id => $cal )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Automatic FURL fix
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$cal['cal_title_seo'] )
|
||||
{
|
||||
$cal['cal_title_seo'] = IPSText::makeSeoTitle( $cal['cal_title'] );
|
||||
|
||||
$this->DB->update( 'cal_calendars', array( 'cal_title_seo' => $cal['cal_title_seo'] ), 'cal_id=' . $cal_id );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Check permissions
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$this->registry->permissions->check( 'view', $cal ) AND !$ignorePermissions )
|
||||
{
|
||||
$_noPermission[] = $cal['cal_id'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->calendars[ $cal['cal_id'] ] = $cal;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// What calendar are we requesting?
|
||||
//-----------------------------------------
|
||||
|
||||
if( is_string( $this->request['cal_id'] ) AND !empty($this->request['cal_id']) AND isset( $this->calendars[ $this->request['cal_id'] ] ) )
|
||||
{
|
||||
$this->calendarId = intval($this->request['cal_id']);
|
||||
}
|
||||
else if( !empty($this->request['cal_id']) AND !IN_ACP )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Calendar requested but it's not in $this->calendars
|
||||
// Either the cal_id doesn't exist, or user does not have view permissions
|
||||
//-----------------------------------------
|
||||
|
||||
if( $return )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$_header = ( !empty($this->request['cal_id']) AND in_array( $this->request['cal_id'], $_noPermission ) ) ? 403 : 404;
|
||||
|
||||
$this->registry->output->showError( 'cal_no_perm', 1040, null, null, $_header );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->calendarId = ( is_array( $this->calendars ) ) ? key( $this->calendars ) : 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get calendar array
|
||||
*
|
||||
* @param integer [$calendar_id] Optional calendar ID to retrieve, otherwise defaults to calendar id in request, or default calendar set by admin
|
||||
* @return array
|
||||
*/
|
||||
public function getCalendar( $calendar_id=0 )
|
||||
{
|
||||
return $this->calendars[ !empty($calendar_id) ? ( isset( $this->calendars[ $calendar_id ] ) ? $calendar_id : $this->calendarId ) : $this->calendarId ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all calendars
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCalendars()
|
||||
{
|
||||
return $this->calendars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get calendar jump menu
|
||||
*
|
||||
* @param int [$cal_id] Default calendar ID to select
|
||||
* @param array [$extra] Additional permission bits to check
|
||||
* @return string
|
||||
*/
|
||||
public function getCalendarJump( $selected=0, $extra=array() )
|
||||
{
|
||||
$return = "";
|
||||
|
||||
foreach( $this->calendars as $calendar )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Check any extra permissions
|
||||
//-----------------------------------------
|
||||
|
||||
if( is_array($extra) AND count($extra) )
|
||||
{
|
||||
foreach( $extra as $_bit )
|
||||
{
|
||||
if( !$this->registry->permissions->check( $_bit, $calendar ) )
|
||||
{
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return .= "<option value='{$calendar['cal_id']}'" . ( $selected == $calendar['cal_id'] ? " selected='selected'" : '' ) . ">{$calendar['cal_title']}</option>\n";
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an HTML options list of days
|
||||
*
|
||||
* @param integer $day Default selected day
|
||||
* @return string HTML options
|
||||
*/
|
||||
public function returnDayDropdown( $day=0 )
|
||||
{
|
||||
$return = "";
|
||||
$day = intval($day);
|
||||
|
||||
for( $x = 1 ; $x <= 31 ; $x++ )
|
||||
{
|
||||
$return .= "\t<option value='" . $x . "'" . ( $x == $day ? " selected='selected'" : "" ) . ">" . $x . "</option>\n";
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an HTML options list of months
|
||||
*
|
||||
* @param integer $month Month to select by default
|
||||
* @return string HTML options
|
||||
*/
|
||||
public function returnMonthDropdown( $month=0 )
|
||||
{
|
||||
$return = "";
|
||||
$month = intval($month);
|
||||
|
||||
for( $x = 1 ; $x <= 12 ; $x++ )
|
||||
{
|
||||
$return .= "\t<option value='" . $x . "'" . ( $x == $month ? " selected='selected'" : "" ) . ">" . gmstrftime( '%B', gmmktime( 0, 0, 0, $x, 15 ) ) . "</option>\n";
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds a year dropdown
|
||||
*
|
||||
* @param integer $year Year to select by default
|
||||
* @return string HTML dropdown
|
||||
*/
|
||||
public function returnYearDropdown( $year=0 )
|
||||
{
|
||||
$return = "";
|
||||
$year = intval($year);
|
||||
|
||||
$this->settings['start_year'] = $this->settings['start_year'] ? ( $this->settings['start_year'] <= gmstrftime('%Y') ? $this->settings['start_year'] : gmstrftime('%Y') - 2 ) : gmstrftime('%Y') - 2;
|
||||
$this->settings['year_limit'] = $this->settings['year_limit'] ? $this->settings['year_limit'] : 5;
|
||||
|
||||
if( $this->settings['start_year'] + $this->settings['year_limit'] < gmstrftime('%Y') )
|
||||
{
|
||||
$this->settings['year_limit'] = gmstrftime('%Y') - $this->settings['start_year'];
|
||||
}
|
||||
|
||||
for( $x = $this->settings['start_year'], $xy = $this->settings['start_year'] + $this->settings['year_limit'] ; $x <= $xy ; $x++ )
|
||||
{
|
||||
$return .= "\t<option value='" . $x . "'" . ( $x == $year ? " selected='selected'" : "" ) . ">" . $x . "</option>\n";
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,384 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.4.5
|
||||
* Calendar hook function gateway
|
||||
* Last Updated: $Date: 2013-03-25 20:42:22 -0400 (Mon, 25 Mar 2013) $
|
||||
* </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 5th January 2005
|
||||
* @version $Revision: 12119 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class app_calendar_classes_hooks
|
||||
{
|
||||
/**#@+
|
||||
* Registry objects
|
||||
*
|
||||
* @access protected
|
||||
* @var object
|
||||
*/
|
||||
protected $registry;
|
||||
protected $DB;
|
||||
protected $settings;
|
||||
protected $request;
|
||||
protected $lang;
|
||||
protected $member;
|
||||
protected $memberData;
|
||||
protected $cache;
|
||||
protected $caches;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param object Registry object
|
||||
* @param bool Ignore permission check
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry, $ignorePermissions=false )
|
||||
{
|
||||
/* Make object */
|
||||
$this->registry = $registry;
|
||||
$this->DB = $this->registry->DB();
|
||||
$this->settings =& $this->registry->fetchSettings();
|
||||
$this->request =& $this->registry->fetchRequest();
|
||||
$this->lang = $this->registry->getClass('class_localization');
|
||||
$this->member = $this->registry->member();
|
||||
$this->memberData =& $this->registry->member()->fetchMemberData();
|
||||
$this->cache = $this->registry->cache();
|
||||
$this->caches =& $this->registry->cache()->fetchCaches();
|
||||
|
||||
$this->lang->loadLanguageFile( array( 'public_calendar' ), 'calendar' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve upcoming birthdays
|
||||
*
|
||||
* @return @e string
|
||||
* @note The recache function will recache up to 6 each day. That fulfills the 5 that are displayed + 1 more to know if we should show a link to view all.
|
||||
*/
|
||||
public function getUpcomingBirthdays()
|
||||
{
|
||||
if ( !$this->settings['show_birthdays'] OR !IPSLib::appIsInstalled( 'calendar' ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$a = explode( ',', gmdate( 'Y,n,j,G,i,s', time() + $this->registry->getClass('class_localization')->getTimeOffset() ) );
|
||||
$day = $a[2];
|
||||
$month = $a[1];
|
||||
$year = $a[0];
|
||||
|
||||
$birthstring = "";
|
||||
$count = 0;
|
||||
$lang = '';
|
||||
$users = array();
|
||||
$fetch = 5;
|
||||
|
||||
if ( is_array($this->caches['birthdays']) AND count( $this->caches['birthdays'] ) )
|
||||
{
|
||||
$_users = IPSMember::load( array_keys( $this->caches['birthdays'] ) );
|
||||
|
||||
foreach( $this->caches['birthdays'] as $u )
|
||||
{
|
||||
/* Age */
|
||||
$pyear = 0;
|
||||
|
||||
$u = array_merge( $_users[ $u['member_id'] ], $u );
|
||||
$u = IPSMember::buildDisplayData( $u );
|
||||
|
||||
if( $u['bday_year'] && $u['bday_year'] > 0 )
|
||||
{
|
||||
$pyear = $year - $u['bday_year'];
|
||||
}
|
||||
|
||||
$u['_pyear'] = $pyear;
|
||||
|
||||
if ( $u['bday_day'] == $day and $u['bday_month'] == $month )
|
||||
{
|
||||
if( $count < $fetch )
|
||||
{
|
||||
$users[] = $u;
|
||||
}
|
||||
|
||||
$count++;
|
||||
}
|
||||
else if( $day == 28 && $month == 2 && !date("L") )
|
||||
{
|
||||
if ( $u['bday_day'] == "29" and $u['bday_month'] == $month )
|
||||
{
|
||||
if( $count < $fetch )
|
||||
{
|
||||
$users[] = $u;
|
||||
}
|
||||
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get calendar info, but only if we need it
|
||||
//-----------------------------------------
|
||||
|
||||
$data = array();
|
||||
|
||||
if( $count >= count($users) )
|
||||
{
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'calendar' ) . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar' );
|
||||
$functions = new $classToLoad( $this->registry );
|
||||
|
||||
$calendars = $functions->getCalendars();
|
||||
|
||||
foreach( $calendars as $calendar )
|
||||
{
|
||||
/* We need to grab first calendar that allows birthdays */
|
||||
if( !$calendar['cal_bday_limit'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'id' => $calendar['cal_id'],
|
||||
'title' => $calendar['cal_title_seo'],
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
'day' => $day,
|
||||
'count' => $count,
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( $count >= count($users) AND !count($data) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Spin and print...
|
||||
//-----------------------------------------
|
||||
|
||||
return $this->registry->output->getTemplate('calendar')->boardIndexBirthdays( $users, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve upcoming events
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUpcomingEvents()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Make sure calendar app is installed
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$this->settings['show_calendar'] OR !IPSLib::appIsInstalled( 'calendar' ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get current date data
|
||||
//-----------------------------------------
|
||||
|
||||
$a = explode( ',', gmdate( 'Y,n,j,G,i,s', time() + $this->registry->class_localization->getTimeOffset() ) );
|
||||
$day = $a[2];
|
||||
$month = $a[1];
|
||||
$year = $a[0];
|
||||
|
||||
//-----------------------------------------
|
||||
// Check calendar limit
|
||||
//-----------------------------------------
|
||||
|
||||
$this->settings['calendar_limit'] = intval( $this->settings['calendar_limit'] ) < 2 ? 1 : intval( $this->settings['calendar_limit'] );
|
||||
|
||||
$our_unix = gmmktime( 0, 0, 0, $month, $day, $year);
|
||||
$max_date = $our_unix + ($this->settings['calendar_limit'] * 86400);
|
||||
$events = array();
|
||||
$show_events = array();
|
||||
|
||||
//-----------------------------------------
|
||||
// Loop over the cache
|
||||
//-----------------------------------------
|
||||
|
||||
if( is_array( $this->caches['calendar_events'] ) AND count( $this->caches['calendar_events'] ) )
|
||||
{
|
||||
foreach( $this->caches['calendar_events'] as $u )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Private?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $u['event_private'] == 1 and $this->memberData['member_id'] != $u['event_member_id'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Got perms?
|
||||
//-----------------------------------------
|
||||
|
||||
if( $u['event_perms'] != '*' )
|
||||
{
|
||||
$permissionGroups = explode( ',', IPSText::cleanPermString( $u['event_perms'] ) );
|
||||
|
||||
if( !IPSMember::isInGroup( $this->memberData, $permissionGroups ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Got calendar perms?
|
||||
//-----------------------------------------
|
||||
|
||||
if( !$this->registry->permissions->check( 'view', $u ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Times and dates
|
||||
//-----------------------------------------
|
||||
|
||||
$u['isoDate'] = gmdate( 'c', strtotime( $u['event_start_date'] ) );
|
||||
$u['_start_time'] = strtotime( $u['event_start_date'] );
|
||||
$u['_end_time'] = ( $u['event_end_date'] AND $u['event_end_date'] != '0000-00-00 00:00:00' ) ? strtotime( $u['event_end_date'] ) : 0;
|
||||
|
||||
if( !$u['event_all_day'] )
|
||||
{
|
||||
if( $this->memberData['member_id'] AND $this->memberData['time_offset'] )
|
||||
{
|
||||
$u['_start_time'] = $u['_start_time'] + ( $this->memberData['time_offset'] * 3600 );
|
||||
}
|
||||
else if( !$this->memberData['member_id'] AND $this->settings['time_offset'] )
|
||||
{
|
||||
$u['_start_time'] = $u['_start_time'] + ( $this->settings['time_offset'] * 3600 );
|
||||
}
|
||||
|
||||
if( $this->memberData['member_id'] AND $this->memberData['time_offset'] )
|
||||
{
|
||||
$u['_end_time'] = $u['_end_time'] ? ( $u['_end_time'] + ( $this->memberData['time_offset'] * 3600 ) ) : 0;
|
||||
}
|
||||
else if( !$this->memberData['member_id'] AND $this->settings['time_offset'] )
|
||||
{
|
||||
$u['_end_time'] = $u['_end_time'] ? ( $u['_end_time'] + ( $this->settings['time_offset'] * 3600 ) ) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// In range?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( !$u['event_recurring'] AND ( ( $u['_end_time'] >= $our_unix AND $u['_start_time'] <= $max_date )
|
||||
OR ( !$u['_end_time'] AND $u['_start_time'] >= $our_unix AND $u['_start_time'] <= $max_date ) ) )
|
||||
{
|
||||
if( $u['_end_time'] )
|
||||
{
|
||||
if( $u['_start_time'] < gmmktime( 0 ) )
|
||||
{
|
||||
$u['_start_time'] = gmmktime( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
$events[ str_pad( $u['_start_time'].$u['event_id'], 15, "0" ) ] = $u;
|
||||
}
|
||||
elseif( $u['event_recurring'] > 0 )
|
||||
{
|
||||
$cust_range_s = $u['_start_time'];
|
||||
|
||||
while( $cust_range_s <= $u['_end_time'] )
|
||||
{
|
||||
if( $cust_range_s >= $our_unix AND $cust_range_s <= $max_date )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Special case for "monthly" to ensure it lands on the same day
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $u['event_recurring'] != 1 )
|
||||
{
|
||||
$u['_start_time'] = gmmktime( 1, 1, 1, gmdate( 'n', $cust_range_s ), gmdate( 'j', $u['_start_time'] ), gmdate( 'Y', $cust_range_s ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$u['_start_time'] = $cust_range_s;
|
||||
}
|
||||
|
||||
$events[ str_pad( $u['_start_time'] . $u['event_id'], 15, "0" ) ] = $u;
|
||||
}
|
||||
|
||||
if( $u['event_recurring'] == 1 )
|
||||
{
|
||||
$cust_range_s += 604800;
|
||||
}
|
||||
elseif ( $u['event_recurring'] == 2 )
|
||||
{
|
||||
$cust_range_s += 2628000;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cust_range_s += 31536000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Sort and format
|
||||
//-----------------------------------------
|
||||
|
||||
ksort($events);
|
||||
|
||||
foreach( $events as $event )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Recurring?
|
||||
//-----------------------------------------
|
||||
|
||||
$c_time = gmstrftime( '%x', $event['_start_time'] );
|
||||
$url = $this->registry->output->buildSEOUrl( "app=calendar&module=calendar&section=view&do=showevent&event_id={$event['event_id']}", 'public', $event['event_title_seo'], 'cal_event' );
|
||||
|
||||
$show_events[] = array( 'url' => $url, 'isoDate' => $event['isoDate'], 'date' => $c_time, 'title' => $event['event_title'], 'calendar' => $this->caches['calendars'][ $event['event_calendar_id'] ] );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Send output to template and return HTML
|
||||
//-----------------------------------------
|
||||
|
||||
$this->lang->words['calender_f_title'] = sprintf( $this->lang->words['calender_f_title'], $this->settings['calendar_limit'] );
|
||||
|
||||
if ( count($show_events) > 0 )
|
||||
{
|
||||
$event_string = $show_events;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! $this->settings['autohide_calendar'] )
|
||||
{
|
||||
$event_string = $this->lang->words['no_calendar_events'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->registry->output->getTemplate('calendar')->boardIndexCalEvents( $event_string );
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head><title>IP.Board - Bulletin Board System</title></head>
|
||||
<body>
|
||||
<h1>403: IP.Board -> 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>
|
||||
Reference in new issue
Block a user