<?
/**
* LCC Sample Application (stand alone, not integrated)
*
* This File shows you, how to run LCC in stand-alone mode. Stand alone means that
* LCC dont use any user that is already logged in but defines its own "virtual"
* authenitcated user. In a production environment you usually want a custom
* login. For more Information on how to teach LCC to authenticate, see
* the comments below.
* The file is only a "demo" - it is only capable of handling one single user.
* This user is hardcoded - replace that piece of code with your own
* authentication program to get a full working LCC.
* LCC runs in "not-integrated" mode here, meaning that LCC runs on its own
* inside the main part of the HTML of this page.
*
* PHP Version 4
*
* @author <hide@address.com>
* @copyright Copyright (c) 2006, Benedikt Hallinger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/**
* Include LCC core class
*/
require dirname(__FILE__).'/core/lcc_core.class.php'; // LCC core
/**
* LCC Core configuration
*
* Here you can tune how the core behaves. Have a look into the documentation to
* learn what you can tune.
*/
$core_config = array(
'design' => 'default', // what design to use
'start_of_week' => 1 // Week starts at Monday
);
/**
* LCC Core initialisation
*
* Instantiate the LCC core and pass it the custom config we defined above.
* After that we set a custom ACL that overwrites only a part of the default ACL.
* Finally, we load the file based event driver and set a custom field.
* The file based driver is the default event driver, but since we want to change
* a user definable field, we must load it manually OR call $lcc_core->getEventDriverInstance() later.
*/
$lcc_core = new LCC_Core($core_config);
$lcc_core->setACL('event_add', 50, array('group1')); // Set custom ACL for adding Events
$lcc_core->setACL('event_mod', 100, array('group2')); // Set custom ACL for modifying Events
// Load file based EventDriver with emtpy config (= use drivers default config)
// and set 'description' field to be mandatory and disallow html
// If you want to use another storage method (maybe database) then just replace "File" with
// the driver type to load, for example "Mysql". Be sure to read the drivers configuration
// to get knowledge what you need to tune.
$event_driver =& $lcc_core->loadEventDriver('File', array());
$event_driver->setFieldSecurity('description', array('mandatory' => true, 'html' => false));
// Load NoteDriver; since we neither want a alternative driver nor want to set some custom
// note fields, we let LCC load the driver internally.
// >ou may uncomment the following line and change the driver type like explained above.
// $note_driver =& $lcc_core->loadNoteDriver('File', array());
/**
* Setup of UserDriver / Authentication
*
* Here is the place where you would usually include some authentication script.
* We want to keep LCC simple and flexible (thats why it is named "lightweight")
* so authentication is not LCCs job in cases where we have no connection to
* a external application/user source.
* If you need custom authentication, write a "login.php" and activate
* its inclusion here. The script should print a login mask and process login data.
* After everything is okay, you can set up the simple driver using the provided example.
*
* In the "demo" case here, we use the simple user driver to set up a single user.
* The simple driver will store the neccessary data somewhere (in sessions, but this should
* not concern us here) and provide it if the core asks.
*/
// include login.php // your custom login script that prints a login mask and handles login data
// Predefine some variables for configuration of LCC_UserDriver_Simple
$authedUser = 'Testuser'; // Currently logged in user
$user_data = array(
$authedUser => array( // The array key is the name of the user
'level' => 60, // Level of this user
'groups_leaded' => array('group1') // Groups this user leads
),
// Add another user here!
);
$group_data = array(
'group1' => array($authedUser, 'User2', 'User3'), // Memberships of "group1"
'group2' => array('User2', 'User3')
);
// Now load the driver!
$simple_config = array(
'username' => $authedUser,
'user_data' => $user_data,
'group_data' => $group_data
);
$lcc_core->loadUserDriver('Simple', $simple_config); // Tell LCC_Core that it should use the Simple UserDriver
/**
* Ok, now run LCC!
* If you want to integrate LCC into your Application, just call $lcc_core->startApplication();
* at the place where LCC should appear. This method will handle requests made by the user
* and displays the neccessary content.
* $lcc_core->printCSS() will print out the CSS provided by the selected design.
*/
?>
<html>
<head>
<TITLE>Lightweight Club Calendar <?php $lcc_core->getVersion(); ?></TITLE>
<?php $lcc_core->printCSS(); ?>
</head>
<body>
<a href="http://lc-calendar.sourceforge.net"><img border="0" src="core/img/lcc_logo.jpg" align="left"></a>
<h1>Lightweight Club Calendar <?php echo $lcc_core->getVersion(); ?></h1>
Welcome, <?php echo $lcc_core->getAuthedUser(); ?>!
<div style="width:800px;margin: 0 auto;">
<?php $lcc_core->startApplication(); ?>
</div>
<hr>
<!-- We want to show some upcoming events
Here we want to display at most the next 10 events inside at most
5 days in the future starting from today --->
<?php
$upcoming_events = $lcc_core->getUpcomingEvents(5, 10);
foreach ($upcoming_events as $id => $event) {
echo "<br>".$event['lcc_event_title'];
}
?>
</body>
</html>