Version 3.0.5

This commit is contained in:
Neo committed 2025-12-19 00:31:03 -08:00
1 parent 19b38c7c74
commit 1d4720f3e2
3755 files changed
+508378 -664541

No files matched your search

@@ -0,0 +1,166 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Calendar core extensions
* Last Updated: $LastChangedDate: 2009-07-28 20:26:37 -0400 (Tue, 28 Jul 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @since 27th January 2004
* @version $Rev: 4948 $
*
*/
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 calendarPermMappingCalendar
{
/**
* Mapping of keys to columns
*
* @access private
* @var array
*/
private $mapping = array(
'view' => 'perm_view',
'start' => 'perm_2',
'nomod' => 'perm_3',
);
/**
* Mapping of keys to names
*
* @access private
* @var array
*/
private $perm_names = array(
'view' => 'Show Calendar',
'start' => 'Create Events',
'nomod' => 'Bypass Moderation',
);
/**
* Mapping of keys to background colors for the form
*
* @access private
* @var array
*/
private $perm_colors = array(
'view' => '#fff0f2',
'start' => '#effff6',
'nomod' => '#edfaff',
);
/**
* Method to pull the key/column mapping
*
* @access public
* @return array
*/
public function getMapping()
{
return $this->mapping;
}
/**
* Method to pull the key/name mapping
*
* @access public
* @return array
*/
public function getPermNames()
{
return $this->perm_names;
}
/**
* Method to pull the key/color mapping
*
* @access public
* @return array
*/
public function getPermColors()
{
return $this->perm_colors;
}
}
/**
* Invision Power Services
* IP.Board v3.0.5
* Library: Handle public session data
* Last Updated: $Date: 2009-07-28 20:26:37 -0400 (Tue, 28 Jul 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @since 12th March 2002
* @version $Revision: 4948 $
*
*/
class publicSessions__calendar
{
/**
* Return session variables for this application
*
* current_appcomponent, current_module and current_section are automatically
* stored. This function allows you to add specific variables in.
*
* @access public
* @author Matt Mecham
* @return array
* @todo [Future] Store which event or calendar a user is viewing?
*/
public function getSessionVariables()
{
return array();
}
/**
* Parse/format the online list data for the records
*
* @access public
* @author Brandon Farber
* @param array Online list rows to check against
* @return array Online list rows parsed
*/
public function parseOnlineEntries( $rows )
{
if( !is_array($rows) OR !count($rows) )
{
return $rows;
}
$final = array();
//-----------------------------------------
// Extract the topic/forum data
//-----------------------------------------
foreach( $rows as $row )
{
if( $row['current_appcomponent'] == 'calendar' )
{
$row['where_line'] = ipsRegistry::getClass( 'class_localization' )->words['WHERE_calendar'];
$row['where_link'] = 'app=calendar&amp;module=calendar&amp;section=calendars';
}
$final[ $row['id'] ] = $row;
}
return $final;
}
}
@@ -0,0 +1,62 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Core variables for calendar
*
* @author $author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @version $Rev: 5462 $
**/
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();
}
$_LOAD = array();
$_LOAD['calendars'] = 1;
$CACHE['calendars'] = array(
'array' => 1,
'allow_unload' => 0,
'default_load' => 1,
'recache_file' => IPSLib::getAppDir( 'calendar' ) . '/modules_admin/calendar/calendars.php',
'recache_class' => 'admin_calendar_calendar_calendars',
'recache_function' => 'calendarsRebuildCache'
);
$CACHE['birthdays'] = array(
'array' => 1,
'allow_unload' => 0,
'default_load' => 1,
'recache_file' => IPSLib::getAppDir( 'calendar' ) . '/modules_admin/calendar/calendars.php',
'recache_class' => 'admin_calendar_calendar_calendars',
'recache_function' => 'calendarRebuildCache'
);
$CACHE['calendar'] = array(
'array' => 1,
'allow_unload' => 0,
'default_load' => 1,
'recache_file' => IPSLib::getAppDir( 'calendar' ) . '/modules_admin/calendar/calendars.php',
'recache_class' => 'admin_calendar_calendar_calendars',
'recache_function' => 'calendarRebuildCache'
);
$CACHE['rss_calendar'] = array(
'array' => 1,
'allow_unload' => 0,
'default_load' => 1,
'skip_rebuild_when_upgrading' => 1,
'recache_file' => IPSLib::getAppDir( 'calendar' ) . '/modules_admin/calendar/calendars.php',
'recache_class' => 'admin_calendar_calendar_calendars',
'recache_function' => 'calendarRSSCache'
);
@@ -0,0 +1,34 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* BBCode Management : Determines if bbcode can be used in this section
* Last Updated: $LastChangedDate: 2009-07-28 20:26:37 -0400 (Tue, 28 Jul 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @since 27th January 2004
* @version $Rev: 4948 $
*
*/
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();
}
/*
* An array of key => value pairs
* When going to parse, the key should be passed to the editor
* to determine which bbcodes should be parsed in the section
*
*/
$BBCODE = array(
'calendar' => ipsRegistry::getClass('class_localization')->words['ctype__calendar'],
);
@@ -0,0 +1,75 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Sets up SEO templates
* Last Updated: $Date$
*
* @author $Author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Forums
* @link http://www.iinvisionpower.com
* @version $Rev$
*
*/
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();
}
$_SEOTEMPLATES = array(
'cal_week' => array(
'app' => 'calendar',
'allowRedirect' => 1,
'out' => array( '#app=calendar(?:&|&amp;)module=calendar(?:&|&amp;)cal_id=(\d+?)(?:&|&amp;)do=showweek(?:&|&amp;)week=(\d+?)(?:&|$)#i', 'calendar/\\1/week-\\2' ),
'in' => array(
'regex' => "#/calendar/(\d+?)/week-(\d+?)(/|$)#i",
'matches' => array( array( 'app' , 'calendar' ),
array( 'module' , 'calendar' ),
array( 'do' , 'showweek' ),
array( 'cal_id' , '$1' ),
array( 'week', '$2' ) )
) ),
'event' => array(
'app' => 'calendar',
'allowRedirect' => 1,
'out' => array( '#app=calendar(?:&|&amp;)module=calendar(?:&|&amp;)cal_id=(\d+?)(?:&|&amp;)do=showevent(?:&|&amp;)event_id=(\d+?)(?:&|$)#i', 'calendar/\\1/event-\\2' ),
'in' => array(
'regex' => "#/calendar/(\d+?)/event-(\d+?)(/|$)#i",
'matches' => array( array( 'app' , 'calendar' ),
array( 'module' , 'calendar' ),
array( 'do' , 'showevent' ),
array( 'cal_id' , '$1' ),
array( 'event_id', '$2' ) )
) ),
'cal_day' => array(
'app' => 'calendar',
'allowRedirect' => 1,
'out' => array( '#app=calendar(?:&|&amp;)module=calendar(?:&|&amp;)cal_id=(.+?)(?:&|&amp;)do=showday(?:&|&amp;)y=(.+?)&amp;m=(.+?)&amp;d=(.+?)(?:&|$)#i', 'calendar/\\1/day-\\2-\\3-\\4' ),
'in' => array(
'regex' => "#/calendar/(\d+?)/day-(\d+?)-(\d+?)-(\d+?)(/|$)#i",
'matches' => array( array( 'app' , 'calendar' ),
array( 'module' , 'calendar' ),
array( 'do' , 'showday' ),
array( 'cal_id' , '$1' ),
array( 'y' , '$2' ),
array( 'm' , '$3' ),
array( 'd' , '$4' ) )
) ),
'app=calendar' => array(
'app' => 'calendar',
'allowRedirect' => 1,
'out' => array( '#app=calendar$#i', 'calendar/' ),
'in' => array(
'regex' => "#/calendar/?$#i",
'matches' => array( array( 'app', 'calendar' ) )
)
),
);
@@ -0,0 +1 @@
<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.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
@@ -0,0 +1,90 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Calendar core extensions
* Last Updated: $LastChangedDate: 2009-02-23 21:27:51 +0000 (Mon, 23 Feb 2009) $
*
* @author $Author: josh $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @since 27th January 2004
* @version $Rev: 4081 $
*
*/
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();
}
/**
* Member Synchronization extensions
*
* @author $author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @version $Rev: 4081 $
**/
class calendarMemberSync
{
/**
* Registry reference
*
* @access public
* @var object
*/
public $registry;
/**
* CONSTRUCTOR
*
* @access public
* @return void
**/
public function __construct()
{
$this->registry = ipsRegistry::instance();
}
/**
* This method is called after a member account has been removed
*
* @access public
* @param string $ids SQL IN() clause
* @return void
**/
public function onDelete( $mids )
{
if( $this->registry->DB()->checkForTable( 'cal_events' ) )
{
$this->registry->DB()->update( 'cal_events', array( 'event_member_id' => 0 ), 'event_member_id' . $mids );
}
}
/**
* This method is called after a member's account has been merged into another member's account
*
* @access public
* @param array $member Member account being kept
* @param array $member2 Member account being removed
* @return void
**/
public function onMerge( $member, $member2 )
{
IPSDebug::addLogMessage( "Markers init done:", 'merge', $member );
if( $this->registry->DB()->checkForTable( 'cal_events' ) )
{
$this->registry->DB()->update( 'cal_events', array( 'event_member_id' => intval($member['member_id']) ), "event_member_id=" . $member2['member_id'] );
}
}
}
@@ -0,0 +1,75 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Portal plugin: calendar
* Last Updated: $Date: 2009-07-28 20:26:37 -0400 (Tue, 28 Jul 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @since 1st march 2002
* @version $Revision: 4948 $
*
*/
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();
}
/**
* This file must be named {file_name_minus_php}-cfg.php
*
* Please see each variable for more information
* $PORTAL_CONFIG is OK for each file, do not change
* this array name.
*/
$PORTAL_CONFIG = array();
/**
* Main plug in title
*
*/
$PORTAL_CONFIG['pc_title'] = 'Календарь';
/**
* Plug in mini description
*
*/
$PORTAL_CONFIG['pc_desc'] = "Блок мини-календаря на текущий месяц";
/**
* Keyword for settings. This is the keyword
* entered into ibf_conf_settings_titles -> conf_title_keyword
* Can be left blank.
* PLEASE stick to the naming convention when entering a setting
* keyword: portal_{file_name_minus_php} This will prevent
* other keyword clashes. Likewise, when creating settings, choose
* NOT to cache them (they will be loaded at run time) and always
* prefix with {file_name_minus_php}_setting_key - for example
* If you had a setting called "export_forums" then please name it
* "recent_topics_export_forums". This will be available in
* $this->settings['recent_topics_export_forums'] in the
* main module.
*/
$PORTAL_CONFIG['pc_settings_keyword'] = "";
/**
* Exportable tags key must be in the naming format of:
* {file_name_minus_php}-tag. The value *MUST* be the function
* which it corresponds to. For example:
* 'recent_topics_last_x' => 'recent_topics_last_x'
* The portal will look for function 'recent_topics_last_x' in
* module "sources/portal_plugins/recent_topics.php" when it parses
* the tag <!--::recent_topics_last_x::-->
*
* @param array[ TAG ] = array( FUNCTION NAME, DESCRIPTION );
*/
$PORTAL_CONFIG['pc_exportable_tags']['calendar_show_current_month'] = array( 'calendar_show_current_month', 'Показать мини-календарь на текущий месяц' );
@@ -0,0 +1,85 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Portal plugin: calendar
* Last Updated: $Date: 2009-10-13 17:40:38 -0400 (Tue, 13 Oct 2009) $
*
* @author $Author: josh $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @since 1st march 2002
* @version $Revision: 5228 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
exit();
}
class ppi_calendar extends public_portal_portal_portal
{
/**
* Initialize module
*
* @access public
* @return void
*/
public function init()
{
}
/**
* Show the current calendar month on the portal
*
* @access public
* @return string HTML content to replace tag with
*/
public function calendar_show_current_month()
{
/* If the calendar is not installed, just return */
if( ! IPSLib::appIsInstalled( 'calendar' ) )
{
return '';
}
//-----------------------------------------
// Grab calendar class
//-----------------------------------------
require_once( IPSLib::getAppDir( 'calendar', 'calendar' ) . '/calendars.php' );
$calendar = new public_calendar_calendar_calendars();
$calendar->makeRegistryShortcuts( $this->registry );
$calendar->initCalendar(true);
if( ! is_array( $calendar->calendar ) OR ! count( $calendar->calendar ) OR ! $calendar->can_read )
{
return'';
}
//-----------------------------------------
// What now?
//-----------------------------------------
$a = explode( ',', gmdate( 'Y,n,j,G,i,s', time() + ipsRegistry::getClass( 'class_localization')->getTimeOffset() ) );
$now_date = array(
'year' => $a[0],
'mon' => $a[1],
'mday' => $a[2],
'hours' => $a[3],
'minutes' => $a[4],
'seconds' => $a[5]
);
$content = $calendar->getMiniCalendar( $now_date['mon'], $now_date['year'] );
return $this->registry->getClass('output')->getTemplate('portal')->calendarWrap( $content );
}
}
@@ -0,0 +1 @@
<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.invisionboard.com/">IP.Board</a>␍</body>␍</html>␍
@@ -0,0 +1,153 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* RSS output plugin :: calendar
* Last Updated: $Date: 2009-12-07 21:57:46 -0500 (Mon, 07 Dec 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @since 6/24/2008
* @version $Revision: 5529 $
*/
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 rss_output_calendar
{
/**
* Expiration date
*
* @access private
* @var integer Expiration timestamp
*/
private $expires = 0;
/**
* Grab the RSS links
*
* @access public
* @return string RSS document
*/
public function getRssLinks()
{
if( !IPSLib::appIsInstalled('calendar') )
{
return array();
}
$return = array();
$_calendarCache = ipsRegistry::cache()->getCache('calendars');
if( is_array($_calendarCache) AND count($_calendarCache) )
{
foreach( $_calendarCache as $r )
{
/* Got a perm */
if( ! ipsRegistry::getClass( 'permissions' )->check( 'view', $r ) )
{
continue;
}
$return[] = array( 'title' => $r['cal_title'], 'url' => ipsRegistry::getClass('output')->formatUrl( ipsRegistry::$settings['board_url'] . "/index.php?app=core&amp;module=global&amp;section=rss&amp;type=calendar&amp;id=" . $r['cal_id'], '%%' . $r['cal_title'] . '%%', 'section=rss2' ) );
}
}
return $return;
}
/**
* Grab the RSS document content and return it
*
* @access public
* @return string RSS document
*/
public function returnRSSDocument()
{
if( !IPSLib::appIsInstalled('calendar') )
{
return array();
}
//-----------------------------------------
// INIT
//-----------------------------------------
$cal_id = intval( ipsRegistry::$request['id'] );
$rss_data = array();
$to_print = '';
$this->expires = time();
//-----------------------------------------
// Get RSS export
//-----------------------------------------
$rss_data = ipsRegistry::DB()->buildAndFetch( array( 'select' => '*',
'from' => 'cal_calendars',
'where' => 'cal_id=' . $cal_id ) );
//-----------------------------------------
// Got one?
//-----------------------------------------
if ( $rss_data['cal_id'] AND $rss_data['cal_rss_export'] )
{
//-----------------------------------------
// Correct expires time
//-----------------------------------------
$this->expires = $this->expires + ($rss_data['cal_rss_update'] * 60);
//-----------------------------------------
// Need to recache?
//-----------------------------------------
$time_check = time() - ( $rss_data['cal_rss_update'] * 60 );
if ( ( ! $rss_data['cal_rss_cache'] ) OR $time_check > $rss_data['cal_rss_update_last'] )
{
//-----------------------------------------
// Yes
//-----------------------------------------
define( 'IN_ACP', 1 );
require_once( IPSLib::getAppDir( 'calendar' ) . '/modules_admin/calendar/calendars.php' );
$rss_export = new admin_calendar_calendar_calendars();
$rss_export->makeRegistryShortcuts( ipsRegistry::instance() );
return $rss_export->calendarRSSCache( $rss_data['cal_id'], 0 );
}
else
{
//-----------------------------------------
// No
//-----------------------------------------
return $rss_data['cal_rss_cache'];
}
}
}
/**
* Grab the RSS document expiration timestamp
*
* @access public
* @return integer Expiration timestamp
*/
public function grabExpiryDate()
{
return $this->expires ? $this->expires : time();
}
}
@@ -0,0 +1,74 @@
<?php
/**
* Formats calendar search results
*
* @author $author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @version $Rev: 4948 $
**/
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 calendarSearchDisplay implements iSearchDisplay
{
/**
* The search plugin for this app
*
* @access public
* @var object
*/
public $search_plugin;
/**
* Formats the calendar search result for display
*
* @access public
* @param array $search_row Array of data from search_index
* @return string Formatted content, ready for display
*/
public function formatContent( $search_row )
{
/* Format as a topic */
if( $search_row['misc'] )
{
return ipsRegistry::getClass( 'output' )->getTemplate( 'search' )->calEventRangedSearchResult( $search_row, $this->search_plugin->onlyTitles );
}
/* Format as a forum */
else
{
return ipsRegistry::getClass( 'output' )->getTemplate( 'search' )->calEventSearchResult( $search_row, $this->search_plugin->onlyTitles );
}
}
/**
* Retuns the html for displaying the calendar filter on the advanced search page
*
* @access public
* @return string
*/
public function getFilterHTML()
{
return '';
//return ipsRegistry::getClass( 'output' )->getTemplate( 'search' )->forumAdvancedSearchFilters();
}
/**
* Builds the SQL filter query
*
* @access public
* @param array
* @return array
*/
public function buildFilterSQL( $data )
{
return array();
}
}
@@ -0,0 +1,458 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Basic Calendar Search
* Last Updated: $Date: 2009-01-09 15:37:32 -0500 (Fri, 09 Jan 2009) $
*
* @author $Author: josh $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Calendar
* @link http://www.iinvisionpower.com
* @version $Rev: 3627 $
*/
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 searchCalendarPlugin implements iSearchIndexPlugin
{
/**
* Database object
*
* @access private
* @var object
*/
private $DB;
/**
* Date range restriction start
*
* @access private
* @var integer
*/
private $search_begin_timestamp = 0;
/**
* Date range restriction end
*
* @access private
* @var integer
*/
private $search_end_timestamp = 0;
/**
* Array of conditions for this search
*
* @access private
* @var array
*/
private $whereConditions = array();
/**
* Remoe self from search results
*
* @access public
* @var boolean
*/
public $removeSelf = false;
/**
* Only display title
*
* @access public
* @var boolean
*/
public $onlyTitles = false;
/**
* Setup registry objects
*
* @access public
* @param object ipsRegistry $registry
* @return void
*/
public function __construct( ipsRegistry $registry )
{
$this->DB = $registry->DB();
$this->member = $registry->member();
$this->memberData =& $registry->member()->fetchMemberData();
}
/**
* Performs search and returns an array of results
*
* @access public
* @param string $search_term
* @param array $limit_clause The erray should be array( begin, end )
* @param string $sort_by Column to sort by
* @param string $group_by Column to group by
* @param bool $content_title_only Only search title records
* @return array
*/
public function getSearchResults( $search_term, $limit_clause, $sort_by, $group_by='', $content_title_only=false, $sort_order='' )
{
/* Group By */
if( $group_by )
{
$group_by = 'c.' . $group_by;
}
/* User prefs */
$order_dir = ( $sort_order == 'asc' ) ? 'asc' : 'desc';
/* Do the search */
$this->DB->build( array(
'select' => "c.*",
'from' => array( 'cal_events' => 'c' ),
'where' => $this->_buildWhereStatement( $search_term, $content_title_only ),
'limit' => $limit_clause,
'order' => "c.event_unix_from " . $order_dir,
'group' => $group_by,
'add_join' => array(
array(
'select' => 'i.*',
'from' => array( 'permission_index' => 'i' ),
'where' => "i.perm_type='calendar' AND i.perm_type_id=c.event_calendar_id",
'type' => 'left',
),
array(
'select' => 'mem.members_display_name, mem.member_group_id, mem.mgroup_others',
'from' => array( 'members' => 'mem' ),
'where' => "mem.member_id=c.event_member_id",
'type' => 'left',
),
array(
'from' => array( 'profile_friends' => 'friend' ),
'where' => 'friend.friends_member_id=c.event_member_id AND friend.friends_friend_id=' . $this->memberData['member_id'],
'type' => 'left',
),
)
) );
$this->DB->execute();
/* Build result array */
$rows = array();
while( $r = $this->DB->fetch() )
{
/* Reassign stuff to match the search_index */
$rows[] = $this->formatFieldsForIndex( $r );
}
return $rows;
}
/**
* Performs live search and returns an array of results
* NOT AVAILABLE IN BASIC SEARCH
*
* @access public
* @param string $search_term
* @return array
*/
public function getLiveSearchResults( $search_term )
{
return array();
}
/**
* Returns the total number of results the search will return
*
* @access public
* @param string $search_term Search term
* @param string $group_by Column to group by
* @param bool $content_title_only Only search title records
* @return integer
*/
public function getSearchCount( $search_term, $group_by='', $content_title_only=false )
{
/* Group By */
if( $group_by )
{
$group_by = 'c.' . $group_by;
}
/* Query the count */
$this->DB->build( array(
'select' => 'COUNT(*) as total_results',
'from' => array( 'cal_events' => 'c' ),
'where' => $this->_buildWhereStatement( $search_term, $content_title_only ),
'group' => $group_by,
'add_join' => array(
array(
'from' => array( 'permission_index' => 'i' ),
'where' => "i.perm_type='calendar' AND i.perm_type_id=c.event_calendar_id",
'type' => 'left',
),
array(
'from' => array( 'profile_friends' => 'friend' ),
'where' => 'friend.friends_member_id=c.event_member_id AND friend.friends_friend_id=' . $this->memberData['member_id'],
'type' => 'left',
),
)
) );
$this->DB->execute();
$search = $this->DB->fetch();
/* Return the count */
return $search['total_results'];
}
/**
* Restrict the date range that the search is performed on
*
* @access public
* @param int $begin Start timestamp
* @param int [$end] End timestamp
* @return void
*/
public function setDateRange( $begin, $end=0 )
{
$this->search_begin_timestamp = $begin;
$this->search_end_timestamp = $end;
}
/**
* mySQL function for adding special search conditions
*
* @access public
* @param string $column sql table column for this condition
* @param string $operator Operation to perform for this condition, ex: =, <>, IN, NOT IN
* @param mixed $value Value to check with
* @param string $comp Comparison type
* @return void
*/
public function setCondition( $column, $operator, $value, $comp='AND' )
{
/* Remap */
$column = $column == 'member_id' ? 'event_member_id' : $column;
$column = $column == 'content_title' ? 'event_title' : $column;
if( $column == 'app' OR $column == 'type_id' )
{
return;
}
/* Build the condition based on operator */
switch( strtoupper( $operator ) )
{
case 'IN':
case 'NOT IN':
$this->whereConditions[$comp][] = "c.{$column} {$operator} ( {$value} )";
break;
default:
$this->whereConditions[$comp][] = "c.{$column} {$operator} {$value}";
break;
}
}
/**
* Allows you to specify multiple conditions that are chained together
*
* @access public
* @param array $conditions Array of conditions, each element has 3 keys: column, operator, value, see the setCondition function for information on each
* @param string $inner_comp Comparison operator to use inside the chain
* @param string $outer_comp Comparison operator to use outside the chain
* @return void
*/
public function setMultiConditions( $conditions, $inner_comp='OR', $outer_comp='AND' )
{
/* Loop through the conditions to build the statement */
$_temp = array();
foreach( $conditions as $r )
{
/* REMAP */
$r['column'] = ( $r['column'] == 'type_id' ) ? 'event_calendar_id' : $r['column'];
if( $r['column'] == 'app' )
{
continue;
}
switch( strtoupper( $r['operator'] ) )
{
case 'IN':
case 'NOT IN':
$_temp[] = "c.{$r['column']} {$r['operator']} ( {$r['value']} )";
break;
default:
$_temp[] = "c.{$r['column']} {$r['operator']} {$r['value']}";
break;
}
}
$this->whereConditions[$outer_comp][] = '( ' . implode( $_temp, ' ' . $inner_comp . ' ' ) . ' ) ';
}
/**
* Set search conditions for "View unread content"
*
* @access public
* @return void
*/
public function setUnreadConditions()
{
$this->setDateRange( intval( $this->memberData['last_visit'] ), time() );
}
/**
* Builds the where portion of a search string
*
* @access private
* @param string $search_term The string to use in the search
* @param bool $content_title_only Search only title records
* @return string
**/
private function _buildWhereStatement( $search_term, $content_title_only=false )
{
/* INI */
$where_clause = array();
if( $search_term )
{
if( $content_title_only )
{
$where_clause[] = "c.event_title LIKE '%{$search_term}%'";
}
else
{
$where_clause[] = "c.event_title LIKE '%{$search_term}%' OR c.event_content LIKE '%{$search_term}%'";
}
}
/* Exclude some items */
if( !$this->memberData['g_is_supmod'] )
{
/* Owner only */
$where_clause[] = '(i.owner_only=0 OR c.event_member_id=' . $this->memberData['member_id'] . ')';
/* Friend only */
$where_clause[] = '(i.friend_only=0 OR friend.friends_id ' . $this->DB->buildIsNull( false ) . ')';
/* Authorized users only */
$where_clause[] = '(i.authorized_users ' . $this->DB->buildIsNull() . " OR i.authorized_users='' OR c.event_member_id=" . $this->memberData['member_id'] . " OR i.authorized_users LIKE '%," . $this->memberData['member_id'] . ",%')";
}
/* Date Restrict */
if( $this->search_begin_timestamp && $this->search_end_timestamp )
{
$where_clause[] = $this->DB->buildBetween( "c.event_unix_from", $this->search_begin_timestamp, $this->search_end_timestamp );
}
else
{
if( $this->search_begin_timestamp )
{
$where_clause[] = "c.event_unix_from > {$this->search_begin_timestamp}";
}
if( $this->search_end_timestamp )
{
$where_clause[] = "c.event_unix_from < {$this->search_end_timestamp}";
}
}
/* Add in AND where conditions */
if( isset( $this->whereConditions['AND'] ) && count( $this->whereConditions['AND'] ) )
{
$where_clause = array_merge( $where_clause, $this->whereConditions['AND'] );
}
/* ADD in OR where conditions */
if( isset( $this->whereConditions['OR'] ) && count( $this->whereConditions['OR'] ) )
{
$where_clause[] = '( ' . implode( ' OR ', $this->whereConditions['OR'] ) . ' )';
}
/* Permissions */
$where_clause[] = $this->DB->buildRegexp( "i.perm_view", $this->member->perm_id_array );
/* Event permissions */
$where_clause[] = "((c.event_private=1 AND c.event_member_id=" . $this->memberData['member_id'] . ") OR (c.event_private=0 AND " . $this->DB->buildRegexp( "c.event_perms", $this->member->perm_id_array ) . "))";
/* Build and return the string */
return implode( " AND ", $where_clause );
}
/**
* Reassigns fields in a way the index exepcts
*
* @param array $r
* @return array
**/
public function formatFieldsForIndex( $r )
{
$r['app'] = 'calendar';
$r['content'] = $r['event_content'];
$r['content_title'] = $r['event_title'];
$r['updated'] = $r['event_unix_from'];
$r['type_2'] = 'event';
$r['type_id_2'] = $r['event_id'];
$r['misc'] = $r['event_unix_to'];
$r['member_id'] = $r['event_member_id'];
return $r;
}
/**
* This function grabs the actual results for display
*
* @param array $ids
* @return query result
**/
public function getResultsForSphinx( $ids )
{
$this->DB->build( array(
'select' => "c.*",
'from' => array( 'cal_events' => 'c' ),
'where' => 'c.event_id IN( ' . implode( ',', $ids ) . ')',
'order' => 'c.event_unix_from DESC',
'add_join' => array(
array(
'select' => 'mem.members_display_name, mem.member_group_id, mem.mgroup_others',
'from' => array( 'members' => 'mem' ),
'where' => "mem.member_id=c.event_member_id",
'type' => 'left',
)
)
) );
return $this->DB->execute();
}
/**
* Gets the name of the field this search index uses for dates.... >_<
*
* @return string
**/
public function getDateField()
{
return 'event_unix_from';
}
/**
* Gets field names for other conditions
*
* @param string Column
* @return string
**/
public function getConditionField( $column )
{
switch( $column )
{
case 'member_id':
return 'event_member_id';
break;
}
return $column;
}
}
@@ -0,0 +1,93 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Sphinx template file
* Last Updated: $Date: 2009-07-28 20:26:37 -0400 (Tue, 28 Jul 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Calendar
* @link http://www.iinvisionpower.com
* @version $Rev: 4948 $
* @since 3.0.0
*
*/
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();
}
$appSphinxTemplate = <<<EOF
############################# --- CALENDAR --- ##############################
source calendar_search_main : ipb_source_config
{
# Set our forum PID counter
sql_query_pre = REPLACE INTO <!--SPHINX_DB_PREFIX-->cache_store VALUES( 'sphinx_calendar_counter', (SELECT max(event_id) FROM <!--SPHINX_DB_PREFIX-->cal_events), '', 0, UNIX_TIMESTAMP() )
# Query posts for the main source
sql_query = SELECT e.*, e.event_id as search_id, \
REPLACE( pi.perm_view, '*', 0 ) as perm_view, \
CASE WHEN pi.authorized_users IS NULL THEN 0 ELSE pi.authorized_users END AS authorized_users, \
CASE WHEN pi.friend_only=0 THEN 0 ELSE e.event_member_id END AS friend_only, \
CASE WHEN pi.owner_only=0 THEN 0 ELSE e.event_member_id END AS owner_only \
FROM <!--SPHINX_DB_PREFIX-->cal_events e \
LEFT JOIN <!--SPHINX_DB_PREFIX-->permission_index pi ON ( pi.perm_type_id=e.event_calendar_id AND pi.perm_type='calendar' ) \
WHERE e.event_id <= ( SELECT cs_value FROM <!--SPHINX_DB_PREFIX-->cache_store WHERE cs_key='sphinx_calendar_counter' )
# Fields
sql_attr_uint = search_id
sql_attr_uint = friend_only
sql_attr_uint = owner_only
sql_attr_timestamp = event_unix_from
sql_attr_multi = uint perm_view from field
sql_attr_multi = uint authorized_users from field
sql_attr_uint = event_member_id
sql_ranged_throttle = 0
}
source calendar_search_delta : calendar_search_main
{
# Override the base sql_query_pre
sql_query_pre =
# Query posts for the main source
sql_query = SELECT e.*, e.event_id as search_id, \
REPLACE( pi.perm_view, '*', 0 ) as perm_view, \
CASE WHEN pi.authorized_users IS NULL THEN 0 ELSE pi.authorized_users END AS authorized_users, \
CASE WHEN pi.friend_only=0 THEN 0 ELSE e.event_member_id END AS friend_only, \
CASE WHEN pi.owner_only=0 THEN 0 ELSE e.event_member_id END AS owner_only \
FROM <!--SPHINX_DB_PREFIX-->cal_events e \
LEFT JOIN <!--SPHINX_DB_PREFIX-->permission_index pi ON ( pi.perm_type_id=e.event_calendar_id AND pi.perm_type='calendar' ) \
WHERE e.event_id > ( SELECT cs_value FROM <!--SPHINX_DB_PREFIX-->cache_store WHERE cs_key='sphinx_calendar_counter' )
}
index calendar_search_main
{
source = calendar_search_main
path = <!--SPHINX_BASE_PATH-->/calendar_search_main
docinfo = extern
mlock = 0
morphology = none
min_word_len = 2
charset_type = sbcs
html_strip = 0
}
index calendar_search_delta : calendar_search_main
{
source = calendar_search_delta
path = <!--SPHINX_BASE_PATH-->/calendar_search_delta
}
EOF;