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,567 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.4.5
* Calendar Management
* Last Updated: $LastChangedDate: 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 27th January 2004
* @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class admin_calendar_calendar_calendars extends ipsCommand
{
/**
* Skin file
*
* @var object
*/
public $html;
/**
* Main execution method
*
* @param object ipsRegistry reference
* @return @e void
*/
public function doExecute( ipsRegistry $registry )
{
//-----------------------------------------
// Init
//-----------------------------------------
$this->html = $this->registry->output->loadTemplate( 'cp_skin_calendar' );
$this->html->form_code = 'module=calendar&amp;section=calendars';
$this->html->form_code_js = 'module=calendar&section=calendars';
$this->lang->loadLanguageFile( array( 'admin_calendar' ) );
//-----------------------------------------
// What are we doing
//-----------------------------------------
switch( $this->request['do'] )
{
case 'calendar_delete':
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'calendar_delete' );
$this->calendarDelete();
break;
case 'calendar_add':
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'calendar_manage' );
$this->calendarForm( 'new' );
break;
case 'calendar_add_do':
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'calendar_manage' );
$this->calendarSave( 'new' );
break;
case 'calendar_edit':
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'calendar_manage' );
$this->calendarForm( 'edit' );
break;
case 'calendar_edit_do':
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'calendar_manage' );
$this->calendarSave( 'edit' );
break;
case 'calendar_move':
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'calendar_manage' );
$this->calendarMove();
break;
case 'calendar_rebuildcache':
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'calendar_manage' );
$this->cache->rebuildCache( 'calendar_events', 'calendar' );
$this->registry->output->global_message = $this->lang->words['c_recached'];
$this->calendarsList();
break;
case 'calendar_rss_cache':
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'calendar_manage' );
$this->calendarRSSCache( intval( $this->request['cal_id'] ) );
$this->registry->output->global_message = $this->lang->words['c_rssrecached'];
$this->calendarsList();
break;
case 'calendars_list':
default:
$this->calendarsList();
break;
}
//-----------------------------------------
// Output
//-----------------------------------------
$this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
$this->registry->output->sendOutput();
}
/**
* Update the calendar position
*
* @return @e void
*/
public function calendarMove()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
$ajax = new $classToLoad();
//-----------------------------------------
// Checks...
//-----------------------------------------
if( $this->registry->adminFunctions->checkSecurityKey( $this->request['md5check'], true ) === false )
{
$ajax->returnString( $this->lang->words['postform_badmd5'] );
exit();
}
//-----------------------------------------
// Save new position
//-----------------------------------------
$position = 1;
if( is_array($this->request['calendars']) AND count($this->request['calendars']) )
{
foreach( $this->request['calendars'] as $this_id )
{
$this->DB->update( 'cal_calendars', array( 'cal_position' => $position ), 'cal_id=' . $this_id );
$position++;
}
}
$this->calendarsRebuildCache();
$ajax->returnString( 'OK' );
exit();
}
/**
* Delete a calendar
*
* @return @e void
*/
public function calendarDelete()
{
//-----------------------------------------
// Init
//-----------------------------------------
$cal_id = intval( $this->request['cal_id'] );
if ( ! $cal_id )
{
$this->registry->output->global_message = $this->lang->words['c_noid'];
$this->calendarsList();
return;
}
//-----------------------------------------
// Delete
//-----------------------------------------
$this->DB->delete( 'cal_calendars', 'cal_id=' . $cal_id );
$this->DB->delete( 'permission_index', "app='calendar' AND perm_type='calendar' AND perm_type_id=" . $cal_id );
//-----------------------------------------
// Get feeds for removal
//-----------------------------------------
$_feedIds = array();
$this->DB->build( array( 'select' => 'feed_id', 'from' => 'cal_import_feeds', 'where' => 'feed_calendar_id=' . $cal_id ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$_feedIds[] = $r['feed_id'];
}
$this->DB->delete( 'cal_import_feeds', 'feed_calendar_id=' . $cal_id );
if( count($_feedIds) )
{
$this->DB->delete( 'cal_import_map', 'import_feed_id IN(' . implode( ',', $_feedIds ) . ')' );
}
//-----------------------------------------
// Get event ids for comments/ratings
//-----------------------------------------
$_eventIds = array();
$this->DB->build( array( 'select' => 'event_id', 'from' => 'cal_events', 'where' => 'event_calendar_id=' . $cal_id ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$_eventIds[] = $r['event_id'];
}
if( count($_eventIds) )
{
$this->DB->delete( 'cal_event_comments', 'comment_eid IN(' . implode( ',', $_eventIds ) . ')' );
$this->DB->delete( 'cal_event_ratings', 'rating_eid IN(' . implode( ',', $_eventIds ) . ')' );
$this->DB->delete( 'cal_event_rsvp', 'rsvp_event_id IN(' . implode( ',', $_eventIds ) . ')' );
//-----------------------------------------
// 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( $_eventIds );
}
$this->DB->delete( 'cal_events', 'event_calendar_id=' . $cal_id );
//-----------------------------------------
// Remove likes
//-----------------------------------------
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
$_like = classes_like::bootstrap( 'calendar', 'calendars' );
$_like->remove( $cal_id );
//-----------------------------------------
// Rebuild caches
//-----------------------------------------
$this->calendarsRebuildCache();
$this->cache->rebuildCache( 'calendar_events', 'calendar' );
$this->cache->rebuildCache( 'rss_calendar', 'calendar' );
//-----------------------------------------
// Redirect
//-----------------------------------------
$this->registry->output->global_message = $this->lang->words['c_removed'];
$this->calendarsList();
}
/**
* Handles the calednar new/edit form
*
* @param string $type Either new or edit
* @return @e void
*/
public function calendarSave( $type='new' )
{
//-----------------------------------------
// Init
//-----------------------------------------
$cal_id = intval( $this->request['cal_id'] );
$cal_title = trim( IPSText::stripslashes( IPSText::htmlspecialchars( $_POST['cal_title'] ) ) );
$cal_moderate = intval( $this->request['cal_moderate'] );
$cal_comment_moderate = intval( $this->request['cal_comment_moderate'] );
$cal_event_limit = intval( $this->request['cal_event_limit'] );
$cal_bday_limit = intval( $this->request['cal_bday_limit'] );
$cal_rss_export = intval( $this->request['cal_rss_export'] );
$cal_rss_export_days = intval( $this->request['cal_rss_export_days'] );
$cal_rss_export_max = intval( $this->request['cal_rss_export_max'] );
$cal_rss_update = intval( $this->request['cal_rss_update'] );
$cal_rsvp = intval( $this->request['cal_rsvp_owner'] );
//-----------------------------------------
// Error checking
//-----------------------------------------
if ( $type == 'edit' )
{
if ( ! $cal_id )
{
$this->registry->output->global_message = $this->lang->words['c_noid'];
$this->calendarsList();
return;
}
}
if ( ! $cal_title )
{
$this->registry->output->global_message = $this->lang->words['c_completeform'];
$this->calendarForm( $type );
return;
}
//-----------------------------------------
// Format for DB update
//-----------------------------------------
$array = array( 'cal_title' => $cal_title,
'cal_title_seo' => IPSText::makeSeoTitle( $cal_title ),
'cal_moderate' => $cal_moderate,
'cal_comment_moderate' => $cal_comment_moderate,
'cal_event_limit' => $cal_event_limit,
'cal_bday_limit' => $cal_bday_limit,
'cal_rss_export' => $cal_rss_export,
'cal_rss_export_days' => $cal_rss_export_days,
'cal_rss_export_max' => $cal_rss_export_max,
'cal_rss_update' => $cal_rss_update,
'cal_rsvp_owner' => $cal_rsvp,
);
//-----------------------------------------
// Insert or update
//-----------------------------------------
if ( $type == 'new' )
{
$this->DB->insert( 'cal_calendars', $array );
$cal_id = $this->DB->getInsertId();
$this->registry->output->global_message = $this->lang->words['c_added'];
}
else
{
$this->DB->update( 'cal_calendars', $array, 'cal_id=' . $cal_id );
$this->registry->output->global_message = $this->lang->words['c_edited'];
}
//-----------------------------------------
// Save permissions
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions' );
$permissions = new $classToLoad( $this->registry );
$permissions->savePermMatrix( $this->request['perms'], $cal_id, 'calendar' );
//-----------------------------------------
// Rebuild caches and redirect
//-----------------------------------------
$this->calendarsRebuildCache();
$this->cache->rebuildCache( 'calendar_events', 'calendar' );
$this->calendarRSSCache( $cal_id );
$this->cache->rebuildCache( 'rss_output_cache' );
$this->calendarsList();
}
/**
* Add/Edit Calendar Form
*
* @param string $type Either new or edit
* @return @e void
*/
public function calendarForm( $type='new' )
{
//-----------------------------------------
// Init
//-----------------------------------------
$cal_id = $this->request['cal_id'] ? intval( $this->request['cal_id'] ) : 0;
$form = array();
//-----------------------------------------
// Defaults
//-----------------------------------------
if ( $type == 'new' )
{
$formcode = 'calendar_add_do';
$title = $this->lang->words['c_addcal'];
$button = $this->lang->words['c_addcal'];
$calendar = array(
'cal_title' => '',
'cal_moderate' => 0,
'cal_comment_moderate' => 0,
'cal_rsvp_owner' => 0,
'cal_event_limit' => '',
'cal_bday_limit' => '',
'cal_rss_export' => '',
'cal_rss_update' => '',
'cal_rss_export_days' => '',
'cal_rss_export_max' => '',
'cal_id' => 0
);
}
else
{
$formcode = 'calendar_edit_do';
$title = $this->lang->words['c_editbutton'].$calendar['cal_title'];
$button = $this->lang->words['c_savebutton'];
$calendar = $this->DB->buildAndFetch( array(
'select' => 'c.*',
'from' => array( 'cal_calendars' => 'c' ),
'where' => 'c.cal_id=' . $cal_id,
'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',
)
)
) );
if ( ! $calendar['cal_id'] )
{
$this->registry->output->global_message = $this->lang->words['c_noid'];
$this->calendarsList();
return;
}
}
//-----------------------------------------
// Permissions
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions' );
$permissions = new $classToLoad( $this->registry );
//-----------------------------------------
// Form elements
//-----------------------------------------
$form['perm_matrix'] = $permissions->adminPermMatrix( 'calendar', $calendar, 'calendar', '', false );
$form['cal_title'] = $this->registry->output->formInput( 'cal_title' , !empty( $_POST['cal_title'] ) ? $_POST['cal_title'] : $calendar['cal_title'] );
$form['cal_moderate'] = $this->registry->output->formYesNo( 'cal_moderate' , !empty( $this->request['cal_moderate'] ) ? $this->request['cal_moderate'] : $calendar['cal_moderate'] );
$form['cal_moderatec'] = $this->registry->output->formYesNo( 'cal_comment_moderate' , !empty( $this->request['cal_comment_moderate'] ) ? $this->request['cal_comment_moderate'] : $calendar['cal_comment_moderate'] );
$form['cal_event_limit'] = $this->registry->output->formSimpleInput( 'cal_event_limit' , !empty( $this->request['cal_event_limit'] ) ? $this->request['cal_event_limit'] : $calendar['cal_event_limit'], 5 );
$form['cal_bday_limit'] = $this->registry->output->formSimpleInput( 'cal_bday_limit' , !empty( $this->request['cal_bday_limit'] ) ? $this->request['cal_bday_limit'] : $calendar['cal_bday_limit'], 5 );
$form['cal_rss_export'] = $this->registry->output->formYesNo( 'cal_rss_export' , !empty( $this->request['cal_rss_export'] ) ? $this->request['cal_rss_export'] : $calendar['cal_rss_export'] );
$form['cal_rss_update'] = $this->registry->output->formSimpleInput( 'cal_rss_update' , !empty( $this->request['cal_rss_update'] ) ? $this->request['cal_rss_update'] : $calendar['cal_rss_update'], 5 );
$form['cal_rss_export_days'] = $this->registry->output->formSimpleInput( 'cal_rss_export_days' , !empty( $this->request['cal_rss_export_days'] ) ? $this->request['cal_rss_export_days'] : $calendar['cal_rss_export_days'], 5 );
$form['cal_rss_export_max'] = $this->registry->output->formSimpleInput( 'cal_rss_export_max' , !empty( $this->request['cal_rss_export_max'] ) ? $this->request['cal_rss_export_max'] : $calendar['cal_rss_export_max'], 5 );
$form['cal_rsvp'] = $this->registry->output->formYesNo( 'cal_rsvp_owner' , !empty( $this->request['cal_rsvp_owner'] ) ? $this->request['cal_rsvp_owner'] : $calendar['cal_rsvp_owner'] );
//-----------------------------------------
// Output
//-----------------------------------------
$this->registry->output->html .= $this->html->calendarForm( $form, $title, $formcode, $button, $calendar );
}
/**
* List Calendars
*
* @return @e void
*/
public function calendarsList()
{
//-----------------------------------------
// Init
//-----------------------------------------
$rows = array();
//-----------------------------------------
// Get calendars
//-----------------------------------------
$this->DB->build( array( 'select' => '*', 'from' => 'cal_calendars', 'order' => 'cal_position ASC' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$rows[] = $r;
}
//-----------------------------------------
// Output
//-----------------------------------------
$this->registry->output->html .= $this->html->calendarOverviewScreen( $rows );
}
/**
* Rebuild the RSS Cache
*
* @param mixed $calendar_id Specify which calendar to rebuild, all is default
* @return @e void
*/
public function calendarRSSCache( $calendar_id='all' )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('calendar') . '/sources/cache.php', 'calendar_cache', 'calendar' );
$library = new $classToLoad( $this->registry );
$library->rebuildCalendarRSSCache( $calendar_id );
}
/**
* Builds a cache of the current calendars
*
* @return bool Returns true
*/
public function calendarsRebuildCache()
{
//-----------------------------------------
// Verify calendar is installed
//-----------------------------------------
if( !$this->DB->checkForTable('cal_calendars') )
{
return;
}
//-----------------------------------------
// Init
//-----------------------------------------
$cache = array();
//-----------------------------------------
// Get calendars
//-----------------------------------------
$this->DB->build( array(
'select' => 'c.*',
'from' => array( 'cal_calendars' => 'c' ),
'order' => 'c.cal_position ASC',
'add_join' => array(
array(
'select' => 'p.*',
'from' => array( 'permission_index' => 'p' ),
'where' => "p.perm_type='calendar' AND p.perm_type_id=c.cal_id",
'type' => 'left',
)
)
) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$cache[ $r['cal_id'] ] = $r;
}
//-----------------------------------------
// Save cache and return
//-----------------------------------------
$this->cache->setCache( 'calendars', $cache, array( 'array' => 1 ) );
return TRUE;
}
}
@@ -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 = 'calendars';
@@ -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,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,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<menu>
<tabitems>
<item>
<title>Calendar Management</title>
<subitems>
<subitem>
<subitemtitle>Calendar Management</subitemtitle>
<subitemlang>calendars</subitemlang>
<subsection>calendars</subsection>
<subitemurl>do=overview</subitemurl>
<subitemrolekey></subitemrolekey>
<subisredirect>0</subisredirect>
</subitem>
</subitems>
</item>
</tabitems>
</menu>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<permissions>
<group>
<grouptitle>Calendar Management</grouptitle>
<grouplang>calendar_mt</grouplang>
<items>
<item>
<key>calendar_manage</key>
<string>Can add/edit calendars?</string>
</item>
<item>
<key>calendar_delete</key>
<string>Can delete calendars?</string>
</item>
</items>
</group>
</permissions>
@@ -0,0 +1,13 @@
<?php
/**
* @file defaultSection.php Define the default section for the 'icalendar' 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 = 'ical';
@@ -0,0 +1,571 @@
<?php
/**
* @file ical.php Management of iCalendar feed imports
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: ips_terabyte $
* @since Feb 8th 2011
* $LastChangedDate: 2012-01-06 06:20:45 -0500 (Fri, 06 Jan 2012) $
* @version v3.4.5
* $Revision: 10095 $
*/
if ( ! defined( 'IN_ACP' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
/**
*
* @class admin_calendar_icalendar_ical
* @brief Management of iCalendar feed imports
*
*/
class admin_calendar_icalendar_ical extends ipsCommand
{
/**
* Skin file
*
* @var $html
*/
public $html;
/**
* Calendar functions
*
* @var object
*/
protected $functions;
/**
* Main execution method
*
* @param object $registry ipsRegistry reference
* @return @e void
*/
public function doExecute( ipsRegistry $registry )
{
//-----------------------------------------
// Init
//-----------------------------------------
$this->html = $this->registry->output->loadTemplate( 'cp_skin_calendar' );
$this->html->form_code = 'module=icalendar&amp;section=ical';
$this->html->form_code_js = 'module=icalendar&section=ical';
$this->lang->loadLanguageFile( array( 'admin_calendar' ) );
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'calendar_ical' );
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'calendar' ) . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar' );
$this->functions = new $classToLoad( $this->registry, true );
//-----------------------------------------
// What are we doing
//-----------------------------------------
switch( $this->request['do'] )
{
case 'delete':
$this->deleteFeed();
break;
case 'add':
$this->feedForm( 'add' );
break;
case 'doadd':
$this->feedSave( 'add' );
break;
case 'edit':
$this->feedForm( 'edit' );
break;
case 'doedit':
$this->feedSave( 'edit' );
break;
case 'import':
$this->importIcsFile();
break;
case 'recache':
$this->recacheFeed( intval($this->request['id']) );
break;
case 'list':
default:
$this->listFeeds();
break;
}
//-----------------------------------------
// Output
//-----------------------------------------
$this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
$this->registry->output->sendOutput();
}
/**
* Delete a feed import
*
* @return @e void
*/
public function deleteFeed()
{
//-----------------------------------------
// Init
//-----------------------------------------
$id = intval( $this->request['id'] );
if ( ! $id )
{
$this->registry->output->global_message = $this->lang->words['feed_noiddel'];
$this->listFeeds();
return;
}
$feed = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_import_feeds', 'where' => 'feed_id=' . $id ) );
if ( ! $feed['feed_id'] )
{
$this->registry->output->global_message = $this->lang->words['feed_noiddel'];
$this->listFeeds();
return;
}
//-----------------------------------------
// Delete just the feed, or all events as well?
//-----------------------------------------
if( !$this->request['confirm'] )
{
$this->registry->output->html .= $this->html->deleteConfirm( $feed );
return;
}
//-----------------------------------------
// Deleting all events too?
//-----------------------------------------
if( $this->request['delete_events'] )
{
$_eventIds = array();
$this->DB->build( array( 'select' => 'import_event_id', 'from' => 'cal_import_map', 'where' => 'import_feed_id=' . $id ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$_eventIds[] = $r['import_event_id'];
}
if( count($_eventIds) )
{
$this->DB->delete( 'cal_events', 'event_id IN(' . implode( ',', $_eventIds ) . ')' );
$this->DB->delete( 'cal_event_comments', 'comment_eid IN(' . implode( ',', $_eventIds ) . ')' );
$this->DB->delete( 'cal_event_ratings', 'rating_eid IN(' . implode( ',', $_eventIds ) . ')' );
$this->DB->delete( 'cal_event_rsvp', 'rsvp_event_id IN(' . implode( ',', $_eventIds ) . ')' );
}
}
//-----------------------------------------
// Delete
//-----------------------------------------
$this->DB->delete( 'cal_import_feeds', 'feed_id=' . $id );
$this->DB->delete( 'cal_import_map', 'import_feed_id=' . $id );
//-----------------------------------------
// Redirect
//-----------------------------------------
$this->registry->output->global_message = $this->lang->words['feed_importremoved'];
$this->listFeeds();
}
/**
* Save the added/edited feed
*
* @param string $type Either add or edit
* @return @e void
*/
public function feedSave( $type='add' )
{
//-----------------------------------------
// Init
//-----------------------------------------
$id = intval( $this->request['id'] );
//-----------------------------------------
// Error checking
//-----------------------------------------
if ( $type == 'edit' )
{
if ( ! $id )
{
$this->registry->output->global_message = $this->lang->words['feed_notfoundedit'];
$this->listFeeds();
return;
}
$feed = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_import_feeds', 'where' => 'feed_id=' . $id ) );
if ( ! $feed['feed_id'] )
{
$this->registry->output->global_message = $this->lang->words['feed_notfoundedit'];
$this->listFeeds();
return;
}
}
//-----------------------------------------
// Check member
//-----------------------------------------
$memberName = trim($this->request['feed_member_id']);
$member = $this->DB->buildAndFetch( array( 'select' => 'member_id, name', 'from' => 'members', 'where' => "members_l_display_name='" . $this->DB->addSlashes( strtolower( $memberName ) ) . "'" ) );
if( !$member['member_id'] )
{
$this->registry->output->showError( $this->lang->words['feed_importicsmme'], 1149 );
}
//-----------------------------------------
// Format for DB update
//-----------------------------------------
$array = array( 'feed_title' => trim($this->request['feed_title']),
'feed_url' => trim($this->request['feed_url']),
'feed_recache_freq' => intval($this->request['feed_recache_freq']),
'feed_calendar_id' => intval($this->request['feed_calendar_id']),
'feed_member_id' => $member['member_id'],
);
if( $array['feed_recache_freq'] < 60 )
{
$array['feed_recache_freq'] = 60;
}
if( !in_array( substr( $array['feed_url'], 0, strpos( $array['feed_url'], '://' ) ), array( 'http', 'https', 'webcal' ) ) )
{
$this->registry->output->showError( $this->lang->words['invalid_feed_url'], 1141 );
}
if( !$array['feed_title'] )
{
$this->registry->output->showError( $this->lang->words['no_feed_title'], 1142 );
}
//-----------------------------------------
// Insert or update
//-----------------------------------------
if ( $type == 'add' )
{
$array['feed_added'] = time();
$this->DB->insert( 'cal_import_feeds', $array );
$id = $this->DB->getInsertId();
$this->registry->output->global_message = $this->lang->words['feed_added'];
}
else
{
$this->DB->update( 'cal_import_feeds', $array, 'feed_id=' . $id );
$this->registry->output->global_message = $this->lang->words['feed_updated'];
}
//-----------------------------------------
// Rebuild caches
//-----------------------------------------
$this->recacheFeed( $id, true );
$this->listFeeds();
}
/**
* Show form to add/edit a feed import
*
* @param string $type Either add or edit
* @return @e void
*/
public function feedForm( $type='add' )
{
//-----------------------------------------
// Init
//-----------------------------------------
$id = intval( $this->request['id'] );
$form = array();
//-----------------------------------------
// Defaults
//-----------------------------------------
if ( $type == 'add' )
{
$formcode = 'doadd';
$title = $this->lang->words['feed_addnewtext'];
$button = $this->lang->words['feed_addnewtext'];
$feed = array(
'feed_title' => '',
'feed_url' => '',
'feed_recache_freq' => 60,
'feed_id' => 0,
'feed_calendar_id' => 0,
'feed_member_id' => $this->memberData['member_id'],
);
}
else
{
if( !$id )
{
$this->registry->output->global_message = $this->lang->words['feed_notfoundedit'];
$this->listFeeds();
return;
}
$feed = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_import_feeds', 'where' => 'feed_id=' . $id ) );
if ( ! $feed['feed_id'] )
{
$this->registry->output->global_message = $this->lang->words['feed_notfoundedit'];
$this->listFeeds();
return;
}
$formcode = 'doedit';
$title = $this->lang->words['feed_edit_title'] . ' ' . $feed['feed_title'];
$button = $this->lang->words['feed_editbutton'];
}
//-----------------------------------------
// Form elements
//-----------------------------------------
$_member = IPSMember::load( $feed['feed_member_id'] );
$form['feed_title'] = $this->registry->output->formInput( 'feed_title' , !empty( $_POST['feed_title'] ) ? $_POST['feed_title'] : $feed['feed_title'] );
$form['feed_url'] = $this->registry->output->formInput( 'feed_url' , !empty( $this->request['feed_url'] ) ? $this->request['feed_url'] : $feed['feed_url'] );
$form['feed_member_id'] = $this->registry->output->formInput( 'feed_member_id' , !empty( $this->request['feed_member_id'] ) ? $this->request['feed_member_id'] : $_member['members_display_name'] );
$form['feed_recache_freq'] = $this->registry->output->formSimpleInput( 'feed_recache_freq' , !empty( $this->request['feed_recache_freq'] ) ? $this->request['feed_recache_freq'] : $feed['feed_recache_freq'] );
$calendars = $this->functions->getCalendars();
$_calendars = array();
foreach( $calendars as $_cal )
{
$_calendars[] = array( $_cal['cal_id'], $_cal['cal_title'] );
}
$form['feed_calendar_id'] = $this->registry->output->formDropdown( 'feed_calendar_id' , $_calendars, !empty( $this->request['feed_calendar_id'] ) ? $this->request['feed_calendar_id'] : $feed['feed_calendar_id'] );
//-----------------------------------------
// Output
//-----------------------------------------
$this->registry->output->html .= $this->html->feedForm( $form, $title, $formcode, $button, $feed );
}
/**
* List feeds
*
* @return @e void
*/
public function listFeeds()
{
//-----------------------------------------
// Init
//-----------------------------------------
$feeds = array();
//-----------------------------------------
// Get feeds
//-----------------------------------------
$this->DB->build( array( 'select' => '*', 'from' => 'cal_import_feeds' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$feeds[] = $r;
}
//-----------------------------------------
// Output
//-----------------------------------------
$this->registry->output->html .= $this->html->feedsList( $feeds, $this->functions->getCalendars() );
}
/**
* Reimport a feed
*
* @param int $id Specify which feed to reimport
* @param bool $return Whether to return (false will result in a redirect back to feeds list)
* @return @e mixed
*/
public function recacheFeed( $id, $return=false )
{
//-----------------------------------------
// Init
//-----------------------------------------
if( !$id )
{
if( $return )
{
return false;
}
else
{
$this->registry->output->global_message = $this->lang->words['feed_notfoundrecache'];
$this->listFeeds();
return;
}
}
$feed = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'cal_import_feeds', 'where' => 'feed_id=' . $id ) );
if ( ! $feed['feed_id'] )
{
$this->registry->output->global_message = $this->lang->words['feed_notfoundrecache'];
$this->listFeeds();
return;
}
//-----------------------------------------
// Fetch the feed
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
$fetcher = new $classToLoad();
$content = $fetcher->getFileContents( str_replace( 'webcal://', 'http://', $feed['feed_url'] ) );
if( !$content )
{
$this->registry->output->global_message = $this->lang->words['feed_importwcalnone'];
$this->listFeeds();
return;
}
//-----------------------------------------
// Send content to be processed
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('calendar') . '/sources/icalendar.php', 'app_calendar_classes_icalendarOutput', 'calendar' );
$ical = new $classToLoad( $this->registry, $feed['feed_calendar_id'] );
$result = $ical->import( $content, $feed['feed_member_id'], $feed['feed_id'] );
//-----------------------------------------
// Show error if any
//-----------------------------------------
if( $error = $ical->getError() )
{
if( $return )
{
return false;
}
else
{
$this->registry->output->showError( $error, 1144 );
}
}
//-----------------------------------------
// Update last update date and next run date
//-----------------------------------------
$this->DB->update( 'cal_import_feeds', array( 'feed_lastupdated' => time(), 'feed_next_run' => time() + ( $feed['feed_recache_freq'] * 60 ) ), 'feed_id=' . $id );
//-----------------------------------------
// Show success message/redirect
//-----------------------------------------
if( $return )
{
return true;
}
else
{
$this->registry->output->global_message = sprintf( $this->lang->words['feed_successwebcal'], $result['skipped'], $result['imported'] );
$this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->html->form_code );
}
}
/**
* Import an .ics file
*
* @return @e void
*/
public function importIcsFile()
{
//-----------------------------------------
// Get upload content
//-----------------------------------------
$content = $this->registry->getClass('adminFunctions')->importXml();
if( !$content )
{
$this->registry->output->global_message = $this->lang->words['feed_importicsnone'];
$this->listFeeds();
return;
}
//-----------------------------------------
// Get member
//-----------------------------------------
$memberName = trim($this->request['member_name']);
$member = $this->DB->buildAndFetch( array( 'select' => 'member_id, name', 'from' => 'members', 'where' => "members_l_display_name='" . $this->DB->addSlashes( strtolower( $memberName ) ) . "'" ) );
if( !$member['member_id'] )
{
$this->registry->output->global_message = $this->lang->words['feed_importicsmme'];
$this->listFeeds();
return;
}
//-----------------------------------------
// Send content to be processed
//-----------------------------------------
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('calendar') . '/sources/icalendar.php', 'app_calendar_classes_icalendarOutput', 'calendar' );
$ical = new $classToLoad( $this->registry, intval($this->request['calendar_id']) );
$result = $ical->import( $content, $member['member_id'] );
//-----------------------------------------
// Show error if any
//-----------------------------------------
if( $error = $ical->getError() )
{
$this->registry->output->showError( $error, 1143 );
}
//-----------------------------------------
// Show success message/redirect
//-----------------------------------------
$this->registry->output->global_message = sprintf( $this->lang->words['feed_successimport'], $result['skipped'], $result['imported'] );
$this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->html->form_code );
}
}
@@ -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,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,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<menu>
<tabitems>
<item>
<title>Import iCalendar Feeds</title>
<subitems>
<subitem>
<subitemtitle>Import iCalendar Feeds</subitemtitle>
<subitemlang>icalendar</subitemlang>
<subsection>ical</subsection>
<subitemurl></subitemurl>
<subitemrolekey></subitemrolekey>
<subisredirect>0</subisredirect>
</subitem>
</subitems>
</item>
</tabitems>
</menu>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<permissions>
<group>
<grouptitle>Import iCalendar Feeds</grouptitle>
<grouplang>calendar_import</grouplang>
<items>
<item>
<key>calendar_ical</key>
<string>Can import ical and webcal feeds?</string>
</item>
</items>
</group>
</permissions>
@@ -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,13 @@
<?php
/**
* @file defaultSection.php Define the default section for the 'settings' 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 = 'settings';
@@ -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,85 @@
<?php
/**
* @file settings.php Control calendar settings
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: ips_terabyte $
* @since March 24 2011
* $LastChangedDate: 2012-01-06 06:20:45 -0500 (Fri, 06 Jan 2012) $
* @version v3.4.5
* $Revision: 10095 $
*/
if ( ! defined( 'IN_ACP' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
/**
*
* @class admin_calendar_settings_settings
* @brief Control calendar settings
*
*/
class admin_calendar_settings_settings extends ipsCommand
{
/**
* Shortcut for url
*
* @access protected
* @var string URL shortcut
*/
protected $form_code;
/**
* Shortcut for url (javascript)
*
* @access protected
* @var string JS URL shortcut
*/
protected $form_code_js;
/**
* Main class entry point
*
* @access public
* @param object ipsRegistry reference
* @return @e void [Outputs to screen]
*/
public function doExecute( ipsRegistry $registry )
{
//-----------------------------------------
// Set up stuff
//-----------------------------------------
$this->form_code = 'module=settings&amp;section=settings';
$this->form_code_js = 'module=settings&section=settings';
//-------------------------------
// Grab, init and load settings
//-------------------------------
$classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir('core') . '/modules_admin/settings/settings.php', 'admin_core_settings_settings' );
$settings = new $classToLoad( $this->registry );
$settings->makeRegistryShortcuts( $this->registry );
ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_tools' ), 'core' );
$settings->html = $this->registry->output->loadTemplate( 'cp_skin_settings', 'core' );
$settings->form_code = $settings->html->form_code = 'module=settings&amp;section=settings';
$settings->form_code_js = $settings->html->form_code_js = 'module=settings&section=settings';
$this->request['conf_title_keyword'] = 'calendar';
$settings->return_after_save = $this->settings['base_url'] . $this->form_code;
$settings->_viewSettings();
//-----------------------------------------
// Pass to CP output hander
//-----------------------------------------
$this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
$this->registry->getClass('output')->sendOutput();
}
}
@@ -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,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<menu>
<tabitems>
<item>
<title>Calendar Settings</title>
<subitems>
<subitem>
<subitemtitle>Calendar Settings</subitemtitle>
<subitemlang>cal_settings</subitemlang>
<subsection>settings</subsection>
<subitemurl></subitemurl>
<subitemrolekey></subitemrolekey>
<subisredirect>0</subisredirect>
</subitem>
</subitems>
</item>
</tabitems>
</menu>