Location: PHPKode > projects > SiteX > calendar_events.php
<?PHP
ob_start();
session_start();

include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");

protectComponentPage(8);

// View past events
if(isset($sxViewPastEvents))
{
	$sxOrderDirection = "DESC";
	$sxDateRange = "end_timestamp < '$NOW'";
}
// View current events
else
{
	$sxOrderDirection = "ASC";
	$sxDateRange = "end_timestamp >= '$NOW'";
}

// Page turning code
$query = "SELECT id FROM $DB_Events WHERE $sxDateRange";
$result = mysql_query($query, $Link) or queryError("903", mysql_error());
$totalElements = mysql_num_rows($result);

$elements_per_page = $sxThemeConfig['EventsPerPage'];
if(!$page)
	$page = 1;
else
	$page = intval($page);

$start = ($page - 1)*$elements_per_page;

$sxTitleAddendum = getComponentName("8");
include("themes/$THEME_FOLDER/header.php");
?>
  <div class="bodyWrapper">
	<h1><?PHP echo getComponentName("8"); ?></h1>
	<?PHP if((userAdmin()) OR ((userEditor()) AND ($sxSetup['EditorRightsEventsAdd'])))
	echo '<div class="journalAdd"><a href="admin/event_add.php">' .$sxLang['EventButtonAddEventNew'] . '</a></div>'; 
	?>
	<table border="0" cellpadding="5" cellspacing="2" width="<?PHP echo $sxThemeConfig['ContentWidth']-10; ?>" align="center">
	  <tr>
		<td align="left"><?PHP
		if(!$sxViewPastEvents) echo '<a href="' . $PHP_SELF . "?sxViewPastEvents=true&page=$page" . '">' . $sxLang['EventFilterPast'] . '</a>';
		else echo '<a href="' . $PHP_SELF . "?page=$page" . '">' . $sxLang['EventFilterUpcoming'] . '</a>';
		?></td>
		<td align="right"><div class="pageTurns"><?PHP pageTurns("$PHP_SELF?sxViewPastEvents=$sxViewPastEvents&", $totalElements, $page, $elements_per_page); ?></div></td>
	  </tr>
	  <tr>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemDate']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['EventItemEvent']; ?></td>
	  </tr>
		<?PHP
		$query = "SELECT * FROM $DB_Events WHERE $sxDateRange AND active='1' ORDER BY start_timestamp $sxOrderDirection LIMIT $start, $elements_per_page";
		$result = mysql_query($query, $Link) or queryError("71", mysql_error());			
		
		if(!mysql_num_rows($result))
			echo '<tr><td colspan="2">' . $sxLang['NoEvents'] . '</td></tr>';
		else
		{
			while($ROW = mysql_fetch_object($result))
			{
				if(eventAccess($ROW->id))
				{
					if($sxThemeConfig['EventsSimpleMode'] == 1)
					{
						echo '<tr><td width="200" valign="top">';
						echo getFormattedEventDate($ROW->allday, $ROW->start_timestamp, $ROW->end_timestamp, 0);
						echo '</td>'."\n";
						echo '<td valign="top"><a href="calendar_day.php?sxTimestamp=' . $ROW->start_timestamp . '#' . $ROW->id . '">';
						echo stripslashes($ROW->longname);
						echo '</a></td></tr>'."\n";
						
					}
					else
					{	
						echo '<tr><td width="200" valign="top"><a href="calendar_day.php?sxTimestamp=' . $ROW->start_timestamp . '#' . $ROW->id . '">';
						echo getFormattedEventDate($ROW->allday, $ROW->start_timestamp, $ROW->end_timestamp, 0);
						echo '</a></td>'."\n";
						echo '<td valign="top"><div class="eventNameLong"><a href="calendar_day.php?sxTimestamp=' . $ROW->start_timestamp . '#' . $ROW->id . '">' . stripslashes($ROW->longname) . '</a></div>';
						echo '<div class="postedBy">' . $sxLang['PostedBy'] . ': <a href="admin/profile_view.php?user=' . getUsername($ROW->userid) . '">' . getUserFullName($ROW->userid) . '</a></div>'."\n";
						echo '<div class="eventDescription">' . limitString(stripslashes($ROW->description),500) . '</div>'."\n";
						
						if(userAdmin())
						{
							echo '<div class="eventAdminLinks"><a href="admin/event_edit.php?eventid=' . $ROW->id . '">' . $sxLang['EventButtonEditEvent'] . '</a>';
							echo ' &nbsp;&nbsp;<a href="admin/event_add.php?sxThisTimestamp=' . $sxDayStart . '">' . $sxLang['EventButtonAddEvent'] . '</a></div>'."\n";
						}
						echo '</td></tr>'."\n";
					}
				}
			}
		}
		?>
	  <tr>
		<td nowrap="nowrap"><a href="calendar.php"><?PHP echo $sxLang['EventSwitchToCalendar']; ?></a></td>
		<td align="right"><div class="pageTurns"><?PHP pageTurns("$PHP_SELF?sxViewPastEvents=$sxViewPastEvents&", $totalElements, $page, $elements_per_page); ?></div></td>
	  </tr>
	</table>
  </div>
<?PHP
include("themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX