#119 added basic shift json export support using same pattern like ical export

This commit is contained in:
Philip Häusler 2013-09-10 14:27:31 +02:00
parent 4b22847976
commit a47b1935cb
10 changed files with 290 additions and 227 deletions

View File

@ -127,61 +127,6 @@ INSERT INTO `FAQ` (`FID`, `Frage_de`, `Antwort_de`, `Frage_en`, `Antwort_en`, `S
-- -------------------------------------------------------- -- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `GroupPrivileges`
--
DROP TABLE IF EXISTS `GroupPrivileges`;
CREATE TABLE IF NOT EXISTS `GroupPrivileges` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL,
`privilege_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `group_id` (`group_id`,`privilege_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=191 ;
--
-- Daten für Tabelle `GroupPrivileges`
--
INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES
(187, -3, 28),
(24, -1, 5),
(177, -2, 24),
(176, -2, 8),
(23, -1, 2),
(142, -5, 16),
(141, -5, 28),
(175, -2, 11),
(174, -2, 26),
(86, -6, 21),
(140, -5, 6),
(139, -5, 12),
(173, -2, 9),
(138, -5, 14),
(137, -5, 13),
(136, -5, 7),
(172, -2, 17),
(87, -6, 18),
(171, -2, 15),
(85, -6, 10),
(170, -2, 3),
(88, -1, 1),
(186, -3, 19),
(169, -2, 4),
(109, -4, 27),
(135, -5, 31),
(184, -3, 27),
(143, -5, 5),
(144, -5, 33),
(188, -3, 16),
(185, -3, 32),
(189, -3, 33),
(168, -2, 34),
(190, -3, 25);
-- --------------------------------------------------------
-- --
-- Tabellenstruktur für Tabelle `Groups` -- Tabellenstruktur für Tabelle `Groups`
-- --
@ -322,6 +267,62 @@ CREATE TABLE IF NOT EXISTS `news_comments` (
-- --
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `GroupPrivileges`
--
DROP TABLE IF EXISTS `GroupPrivileges`;
CREATE TABLE IF NOT EXISTS `GroupPrivileges` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL,
`privilege_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `group_id` (`group_id`,`privilege_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=203 ;
--
-- Daten für Tabelle `GroupPrivileges`
--
INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES
(187, -3, 28),
(24, -1, 5),
(200, -2, 11),
(199, -2, 26),
(23, -1, 2),
(142, -5, 16),
(141, -5, 28),
(198, -2, 9),
(197, -2, 17),
(86, -6, 21),
(140, -5, 6),
(139, -5, 12),
(196, -2, 35),
(138, -5, 14),
(137, -5, 13),
(136, -5, 7),
(195, -2, 15),
(87, -6, 18),
(194, -2, 3),
(85, -6, 10),
(193, -2, 4),
(88, -1, 1),
(186, -3, 19),
(192, -2, 30),
(109, -4, 27),
(135, -5, 31),
(184, -3, 27),
(143, -5, 5),
(144, -5, 33),
(188, -3, 16),
(185, -3, 32),
(189, -3, 33),
(191, -2, 34),
(190, -3, 25),
(201, -2, 8),
(202, -2, 24);
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -335,19 +336,19 @@ CREATE TABLE IF NOT EXISTS `Privileges` (
`desc` varchar(1024) NOT NULL, `desc` varchar(1024) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`) UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=35 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=36 ;
-- --
-- Daten für Tabelle `Privileges` -- Daten für Tabelle `Privileges`
-- --
INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES
(1, 'start', 'Startseite für Gäste/Nicht eingeloggte User'), (1, 'start', 'Startseite für Gäste/Nicht eingeloggte User'),
(2, 'login', 'Logindialog'), (2, 'login', 'Logindialog'),
(3, 'news', 'Anzeigen der News-Seite'), (3, 'news', 'Anzeigen der News-Seite'),
(4, 'logout', 'User darf sich ausloggen'), (4, 'logout', 'User darf sich ausloggen'),
(5, 'register', 'Einen neuen Engel registerieren'), (5, 'register', 'Einen neuen Engel registerieren'),
(6, 'admin_rooms', 'Räume administrieren'), (6, 'admin_rooms', 'Räume administrieren'),
(7, 'admin_angel_types', 'Engel Typen administrieren'), (7, 'admin_angel_types', 'Engel Typen administrieren'),
(8, 'user_settings', 'User profile settings'), (8, 'user_settings', 'User profile settings'),
(9, 'user_messages', 'Writing and reading messages from user to user'), (9, 'user_messages', 'Writing and reading messages from user to user'),
@ -374,7 +375,9 @@ INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES
(31, 'admin_active', 'Mark angels as active and if they got a t-shirt.'), (31, 'admin_active', 'Mark angels as active and if they got a t-shirt.'),
(32, 'admin_free', 'Show a list of free/unemployed angels.'), (32, 'admin_free', 'Show a list of free/unemployed angels.'),
(33, 'admin_user_angeltypes', 'Confirm restricted angel types'), (33, 'admin_user_angeltypes', 'Confirm restricted angel types'),
(34, 'atom', ' Atom news export'); (34, 'atom', ' Atom news export'),
(35, 'shifts_json_export', 'Export shifts in JSON format');
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -1216,18 +1219,18 @@ CREATE TABLE IF NOT EXISTS `User` (
`Art` varchar(30) DEFAULT NULL, `Art` varchar(30) DEFAULT NULL,
`kommentar` text, `kommentar` text,
`Hometown` varchar(255) NOT NULL DEFAULT '', `Hometown` varchar(255) NOT NULL DEFAULT '',
`ical_key` varchar(32) NOT NULL, `api_key` varchar(32) NOT NULL,
PRIMARY KEY (`UID`,`Nick`), PRIMARY KEY (`UID`,`Nick`),
UNIQUE KEY `Nick` (`Nick`), UNIQUE KEY `Nick` (`Nick`),
KEY `ical_key` (`ical_key`) KEY `api_key` (`api_key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
-- --
-- Daten für Tabelle `User` -- Daten für Tabelle `User`
-- --
INSERT INTO `User` (`UID`, `Nick`, `Name`, `Vorname`, `Alter`, `Telefon`, `DECT`, `Handy`, `email`, `ICQ`, `jabber`, `Size`, `Passwort`, `Gekommen`, `Aktiv`, `Tshirt`, `color`, `Sprache`, `Avatar`, `Menu`, `lastLogIn`, `CreateDate`, `Art`, `kommentar`, `Hometown`, `ical_key`) VALUES INSERT INTO `User` (`UID`, `Nick`, `Name`, `Vorname`, `Alter`, `Telefon`, `DECT`, `Handy`, `email`, `ICQ`, `jabber`, `Size`, `Passwort`, `Gekommen`, `Aktiv`, `Tshirt`, `color`, `Sprache`, `Avatar`, `Menu`, `lastLogIn`, `CreateDate`, `Art`, `kommentar`, `Hometown`, `api_key`) VALUES
(1, 'admin', 'Gates', 'Bill', 42, '', '', '', '', '', '', '', '$23PstrXfk7Nw', 1, 1, 0, 10, 'DE', 115, 'L', 1371899094, '0000-00-00 00:00:00', '', '', '', '1b02f4586319e75000b3919380624ab5'); (1, 'admin', 'Gates', 'Bill', 42, '', '', '', '', '', '', '', '$23PstrXfk7Nw', 1, 1, 0, 10, 'DE', 115, 'L', 1371899094, '0000-00-00 00:00:00', '', '', '', '');
-- -------------------------------------------------------- -- --------------------------------------------------------

View File

@ -0,0 +1,34 @@
<?php
/**
* Export filtered shifts via JSON. (Like iCal Export or shifts view)
*/
function shifts_json_export_controller() {
global $ical_shifts, $user;
if (isset ($_REQUEST['key']) && preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key']))
$key = $_REQUEST['key'];
else
die("Missing key.");
$user = User_by_api_key($key);
if($user === false)
die("Unable to find user.");
if($user == null)
die("Key invalid.");
if(!in_array('shifts_json_export', privileges_for_user($user['UID'])))
die("No privilege for shifts_json_export.");
if (isset ($_REQUEST['export']) && $_REQUEST['export'] == 'user_shifts') {
require_once ('includes/pages/user_shifts.php');
view_user_shifts();
} else {
$ical_shifts = sql_select("SELECT `Shifts`.*, `Room`.`Name` as `room_name` FROM `ShiftEntry` INNER JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) INNER JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `UID`=" . sql_escape($user['UID']) . " ORDER BY `start`");
}
header("Content-Type: application/json; charset=utf-8");
echo json_encode($ical_shifts);
die();
}
?>

View File

@ -11,4 +11,28 @@ function User($id) {
return null; return null;
} }
/**
* Returns User by api_key.
* @param string $api_key User api key
* @return Matching user, null or false on error
*/
function User_by_api_key($api_key) {
$user = sql_select("SELECT * FROM `User` WHERE `api_key`='" . sql_escape($api_key) . "' LIMIT 1");
if($user === false)
return false;
if (count($user) == 0)
return null;
return $user[0];
}
/**
* Generates a new api key for given user.
* @param User $user
*/
function User_reset_api_key($user) {
$user['api_key'] = md5($user['Nick'] . time() . rand());
sql_query("UPDATE `User` SET `api_key`='" . sql_escape($user['api_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
engelsystem_log("API key resetted.");
}
?> ?>

View File

@ -12,7 +12,7 @@ function admin_shifts() {
$mode = ''; $mode = '';
$angelmode = ''; $angelmode = '';
$length = ''; $length = '';
$change_hours = ''; $change_hours = array();
// Locations laden (auch unsichtbare - fuer Erzengel ist das ok) // Locations laden (auch unsichtbare - fuer Erzengel ist das ok)
$rooms = sql_select("SELECT * FROM `Room` ORDER BY `Name`"); $rooms = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
@ -209,7 +209,6 @@ function admin_shifts() {
$hidden_types = ""; $hidden_types = "";
foreach ($needed_angel_types as $type_id => $count) foreach ($needed_angel_types as $type_id => $count)
$hidden_types .= '<input type="hidden" name="type_' . $type_id . '" value="' . $count . '" />'; $hidden_types .= '<input type="hidden" name="type_' . $type_id . '" value="' . $count . '" />';
sort($change_hours);
return template_render('../templates/admin_shift_preview.html', array ( return template_render('../templates/admin_shift_preview.html', array (
'shifts_table' => $shifts_table, 'shifts_table' => $shifts_table,
'name' => $name, 'name' => $name,

View File

@ -9,16 +9,19 @@ function user_atom() {
else else
die("Missing key."); die("Missing key.");
$user = sql_select("SELECT * FROM `User` WHERE `ical_key`='" . sql_escape($key) . "' LIMIT 1"); $user = User_by_api_key($key);
if (count($user) == 0) if($user === false)
die("Unable to find user.");
if($user == null)
die("Key invalid."); die("Key invalid.");
if(!in_array('atom', privileges_for_user($user['UID'])))
die("No privilege for atom.");
$user = $user[0];
$news = sql_select("SELECT * FROM `News` " . (empty($_REQUEST['meetings'])? '' : 'WHERE `Treffen` = 1 ') . "ORDER BY `ID` DESC LIMIT " . sql_escape($DISPLAY_NEWS)); $news = sql_select("SELECT * FROM `News` " . (empty($_REQUEST['meetings'])? '' : 'WHERE `Treffen` = 1 ') . "ORDER BY `ID` DESC LIMIT " . sql_escape($DISPLAY_NEWS));
header('Content-Type: application/atom+xml; charset=utf-8'); header('Content-Type: application/atom+xml; charset=utf-8');
$html = '<?xml version="1.0" encoding="utf-8"?> $html = '<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<title>Engelsystem</title> <title>Engelsystem</title>
<id>' . $_SERVER['HTTP_HOST'] . htmlspecialchars(preg_replace('#[&?]key=[a-f0-9]{32}#', '', $_SERVER['REQUEST_URI'])) . '</id> <id>' . $_SERVER['HTTP_HOST'] . htmlspecialchars(preg_replace('#[&?]key=[a-f0-9]{32}#', '', $_SERVER['REQUEST_URI'])) . '</id>
<updated>' . date('Y-m-d\TH:i:sP', $news[0]['Datum']) . "</updated>\n"; <updated>' . date('Y-m-d\TH:i:sP', $news[0]['Datum']) . "</updated>\n";
@ -29,11 +32,11 @@ function user_atom() {
<id>" . preg_replace('#^https?://#', '', page_link_to_absolute("news")) . "-${news_entry['ID']}</id> <id>" . preg_replace('#^https?://#', '', page_link_to_absolute("news")) . "-${news_entry['ID']}</id>
<updated>" . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . "</updated> <updated>" . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . "</updated>
<summary type=\"html\">" . htmlspecialchars($news_entry['Text']) . "</summary> <summary type=\"html\">" . htmlspecialchars($news_entry['Text']) . "</summary>
</entry>\n"; </entry>\n";
} }
$html .= "</feed>"; $html .= "</feed>";
header("Content-Length: " . strlen($html)); header("Content-Length: " . strlen($html));
echo $html; echo $html;
die(); die();
} }
?> ?>

View File

@ -10,11 +10,13 @@ function user_ical() {
else else
die("Missing key."); die("Missing key.");
$user = sql_select("SELECT * FROM `User` WHERE `ical_key`='" . sql_escape($key) . "' LIMIT 1"); $user = User_by_api_key($key);
if (count($user) == 0) if($user === false)
die("Unable to find user.");
if($user == null)
die("Key invalid."); die("Key invalid.");
if(!in_array('ical', privileges_for_user($user['UID'])))
$user = $user[0]; die("No privilege for ical.");
if (isset ($_REQUEST['export']) && $_REQUEST['export'] == 'user_shifts') { if (isset ($_REQUEST['export']) && $_REQUEST['export'] == 'user_shifts') {
require_once ('includes/pages/user_shifts.php'); require_once ('includes/pages/user_shifts.php');

View File

@ -17,7 +17,7 @@ function user_myshifts() {
if (isset ($_REQUEST['reset'])) { if (isset ($_REQUEST['reset'])) {
if ($_REQUEST['reset'] == "ack") { if ($_REQUEST['reset'] == "ack") {
user_reset_ical_key($user); User_reset_api_key($user);
success("Key geändert."); success("Key geändert.");
redirect(page_link_to('user_myshifts')); redirect(page_link_to('user_myshifts'));
} }
@ -118,7 +118,7 @@ function user_myshifts() {
'actions' => "Aktion" 'actions' => "Aktion"
), $myshifts_table), ), $myshifts_table),
$id == $user['UID'] && count($shifts) == 0 ? error(sprintf(Get_Text('pub_myshifts_goto_shifts'), page_link_to('user_shifts')), true) : '', $id == $user['UID'] && count($shifts) == 0 ? error(sprintf(Get_Text('pub_myshifts_goto_shifts'), page_link_to('user_shifts')), true) : '',
"<h2>iCal Export</h2>" . sprintf(Get_Text('inc_schicht_ical_text'), page_link_to_absolute('ical') . '&key=' . $shifts_user['ical_key'], page_link_to('user_myshifts') . '&reset') "<h2>iCal Export</h2>" . sprintf(Get_Text('inc_schicht_ical_text'), page_link_to_absolute('ical') . '&key=' . $shifts_user['api_key'], page_link_to('user_myshifts') . '&reset')
)); ));
} }
?> ?>

View File

@ -690,8 +690,8 @@ function view_user_shifts() {
), $shifts_table); ), $shifts_table);
} }
if ($user['ical_key'] == "") if ($user['api_key'] == "")
user_reset_ical_key($user); User_reset_api_key($user);
return msg() . template_render('../templates/user_shifts.html', array ( return msg() . template_render('../templates/user_shifts.html', array (
'room_select' => make_select($rooms, $_SESSION['user_shifts']['rooms'], "rooms", ucfirst(Get_Text("rooms"))), 'room_select' => make_select($rooms, $_SESSION['user_shifts']['rooms'], "rooms", ucfirst(Get_Text("rooms"))),
@ -704,7 +704,7 @@ return msg() . template_render('../templates/user_shifts.html', array (
'task_notice' => '<sup>1</sup>' . Get_Text("pub_schichtplan_tasks_notice"), 'task_notice' => '<sup>1</sup>' . Get_Text("pub_schichtplan_tasks_notice"),
'new_style_checkbox' => '<label><input type="checkbox" name="new_style" value="1" ' . ($_SESSION['user_shifts']['new_style']? ' checked' : '') . '> Use new style if possible</label>', 'new_style_checkbox' => '<label><input type="checkbox" name="new_style" value="1" ' . ($_SESSION['user_shifts']['new_style']? ' checked' : '') . '> Use new style if possible</label>',
'shifts_table' => $shifts_table, 'shifts_table' => $shifts_table,
'ical_text' => sprintf(Get_Text('inc_schicht_ical_text'), htmlspecialchars(make_user_shifts_ical_link($user['ical_key'])), page_link_to('user_myshifts') . '&amp;reset'), 'ical_text' => sprintf(Get_Text('inc_schicht_ical_text'), htmlspecialchars(make_user_shifts_ical_link($user['api_key'])), page_link_to('user_myshifts') . '&amp;reset'),
'filter' => ucfirst(Get_Text("to_filter")), 'filter' => ucfirst(Get_Text("to_filter")),
)); ));
} }

View File

@ -28,12 +28,6 @@ $tshirt_sizes = array (
'XL-G' => "XL Girl" 'XL-G' => "XL Girl"
); );
function user_reset_ical_key($user) {
$user['ical_key'] = md5($user['Nick'] . time() . rand());
sql_query("UPDATE `User` SET `ical_key`='" . sql_escape($user['ical_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
engelsystem_log("iCal key resetted.");
}
function UID2Nick($UID) { function UID2Nick($UID) {
if ($UID > 0) if ($UID > 0)
$SQL = "SELECT Nick FROM `User` WHERE UID='" . sql_escape($UID) . "'"; $SQL = "SELECT Nick FROM `User` WHERE UID='" . sql_escape($UID) . "'";

View File

@ -29,161 +29,165 @@ load_auth();
// JSON Authorisierung gewünscht? // JSON Authorisierung gewünscht?
if (isset ($_REQUEST['auth'])) if (isset ($_REQUEST['auth']))
json_auth_service(); json_auth_service();
// Gewünschte Seite/Funktion // Gewünschte Seite/Funktion
$p = isset ($user) ? "news" : "login"; $p = isset ($user) ? "news" : "login";
if (isset ($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && ($_REQUEST['p'] == 'stats' || (sql_num_query("SELECT * FROM `Privileges` WHERE `name`='" . sql_escape($_REQUEST['p']) . "' LIMIT 1") > 0))) if (isset ($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && ($_REQUEST['p'] == 'stats' || (sql_num_query("SELECT * FROM `Privileges` WHERE `name`='" . sql_escape($_REQUEST['p']) . "' LIMIT 1") > 0)))
$p = $_REQUEST['p']; $p = $_REQUEST['p'];
$title = Get_Text($p); $title = Get_Text($p);
$content = ""; $content = "";
if ($p == "ical") { if ($p == "ical") {
require_once ('includes/pages/user_ical.php'); require_once ('includes/pages/user_ical.php');
user_ical(); user_ical();
} }
elseif ($p == "atom") { elseif ($p == "atom") {
require_once ('includes/pages/user_atom.php'); require_once ('includes/pages/user_atom.php');
user_atom(); user_atom();
}
elseif ($p == "shifts_json_export") {
require_once ('includes/controller/shifts_controller.php');
shifts_json_export_controller();
} }
elseif ($p == "stats") { elseif ($p == "stats") {
require_once ('includes/pages/guest_stats.php'); require_once ('includes/pages/guest_stats.php');
guest_stats(); guest_stats();
} }
// Recht dafür vorhanden? // Recht dafür vorhanden?
elseif (in_array($p, $privileges)) { elseif (in_array($p, $privileges)) {
if ($p == "news") { if ($p == "news") {
require_once ('includes/pages/user_news.php'); require_once ('includes/pages/user_news.php');
$content = user_news(); $content = user_news();
} }
elseif ($p == "news_comments") { elseif ($p == "news_comments") {
require_once ('includes/pages/user_news.php'); require_once ('includes/pages/user_news.php');
$content = user_news_comments(); $content = user_news_comments();
} }
elseif ($p == "user_meetings") { elseif ($p == "user_meetings") {
require_once ('includes/pages/user_news.php'); require_once ('includes/pages/user_news.php');
$content = user_meetings(); $content = user_meetings();
} }
elseif ($p == "user_myshifts") { elseif ($p == "user_myshifts") {
require_once ('includes/pages/user_myshifts.php'); require_once ('includes/pages/user_myshifts.php');
$content = user_myshifts(); $content = user_myshifts();
} }
elseif ($p == "user_shifts") { elseif ($p == "user_shifts") {
require_once ('includes/pages/user_shifts.php'); require_once ('includes/pages/user_shifts.php');
$content = user_shifts(); $content = user_shifts();
} }
elseif ($p == "user_messages") { elseif ($p == "user_messages") {
$content = user_messages(); $content = user_messages();
} }
elseif ($p == "user_questions") { elseif ($p == "user_questions") {
require_once ('includes/pages/user_questions.php'); require_once ('includes/pages/user_questions.php');
$content = user_questions(); $content = user_questions();
} }
elseif ($p == "user_wakeup") { elseif ($p == "user_wakeup") {
require_once ('includes/pages/user_wakeup.php'); require_once ('includes/pages/user_wakeup.php');
$content = user_wakeup(); $content = user_wakeup();
} }
elseif ($p == "user_settings") { elseif ($p == "user_settings") {
require_once ('includes/pages/user_settings.php'); require_once ('includes/pages/user_settings.php');
$content = user_settings(); $content = user_settings();
} }
elseif ($p == "login") { elseif ($p == "login") {
require_once ('includes/pages/guest_login.php'); require_once ('includes/pages/guest_login.php');
$content = guest_login(); $content = guest_login();
} }
elseif ($p == "register") { elseif ($p == "register") {
require_once ('includes/pages/guest_login.php'); require_once ('includes/pages/guest_login.php');
$content = guest_register(); $content = guest_register();
} }
elseif ($p == "logout") { elseif ($p == "logout") {
require_once ('includes/pages/guest_login.php'); require_once ('includes/pages/guest_login.php');
$content = guest_logout(); $content = guest_logout();
} }
elseif ($p == "admin_questions") { elseif ($p == "admin_questions") {
$content = admin_questions(); $content = admin_questions();
} }
elseif ($p == "admin_user") { elseif ($p == "admin_user") {
require_once ('includes/pages/admin_user.php'); require_once ('includes/pages/admin_user.php');
$content = admin_user(); $content = admin_user();
} }
elseif ($p == "admin_user_angeltypes") { elseif ($p == "admin_user_angeltypes") {
require_once ('includes/pages/admin_user_angeltypes.php'); require_once ('includes/pages/admin_user_angeltypes.php');
$content = admin_user_angeltypes(); $content = admin_user_angeltypes();
} }
elseif ($p == "admin_arrive") { elseif ($p == "admin_arrive") {
require_once ('includes/pages/admin_arrive.php'); require_once ('includes/pages/admin_arrive.php');
$content = admin_arrive(); $content = admin_arrive();
} }
elseif ($p == "admin_active") { elseif ($p == "admin_active") {
require_once ('includes/pages/admin_active.php'); require_once ('includes/pages/admin_active.php');
$content = admin_active(); $content = admin_active();
} }
elseif ($p == "admin_free") { elseif ($p == "admin_free") {
require_once ('includes/pages/admin_free.php'); require_once ('includes/pages/admin_free.php');
$content = admin_free(); $content = admin_free();
} }
elseif ($p == "admin_news") { elseif ($p == "admin_news") {
require_once ('includes/pages/admin_news.php'); require_once ('includes/pages/admin_news.php');
$content = admin_news(); $content = admin_news();
} }
elseif ($p == "admin_angel_types") { elseif ($p == "admin_angel_types") {
require_once ('includes/pages/admin_angel_types.php'); require_once ('includes/pages/admin_angel_types.php');
$content = admin_angel_types(); $content = admin_angel_types();
} }
elseif ($p == "admin_rooms") { elseif ($p == "admin_rooms") {
require_once ('includes/pages/admin_rooms.php'); require_once ('includes/pages/admin_rooms.php');
$content = admin_rooms(); $content = admin_rooms();
} }
elseif ($p == "admin_groups") { elseif ($p == "admin_groups") {
require_once ('includes/pages/admin_groups.php'); require_once ('includes/pages/admin_groups.php');
$content = admin_groups(); $content = admin_groups();
} }
elseif ($p == "admin_faq") { elseif ($p == "admin_faq") {
require_once ('includes/pages/admin_faq.php'); require_once ('includes/pages/admin_faq.php');
$content = admin_faq(); $content = admin_faq();
} }
elseif ($p == "admin_language") { elseif ($p == "admin_language") {
require_once ('includes/pages/admin_language.php'); require_once ('includes/pages/admin_language.php');
$content = admin_language(); $content = admin_language();
} }
elseif ($p == "admin_import") { elseif ($p == "admin_import") {
require_once ('includes/pages/admin_import.php'); require_once ('includes/pages/admin_import.php');
$content = admin_import(); $content = admin_import();
} }
elseif ($p == "admin_shifts") { elseif ($p == "admin_shifts") {
require_once ('includes/pages/admin_shifts.php'); require_once ('includes/pages/admin_shifts.php');
$content = admin_shifts(); $content = admin_shifts();
} }
elseif ($p == "admin_log") { elseif ($p == "admin_log") {
require_once ('includes/pages/admin_log.php'); require_once ('includes/pages/admin_log.php');
$content = admin_log(); $content = admin_log();
} else { } else {
require_once ('includes/pages/guest_start.php'); require_once ('includes/pages/guest_start.php');
$content = guest_start(); $content = guest_start();
} }
} }
elseif ($p == "credits") { elseif ($p == "credits") {
require_once ('includes/pages/guest_credits.php'); require_once ('includes/pages/guest_credits.php');
$content = guest_credits(); $content = guest_credits();
} }
elseif ($p == "faq") { elseif ($p == "faq") {
require_once ('includes/pages/guest_faq.php'); require_once ('includes/pages/guest_faq.php');
$content = guest_faq(); $content = guest_faq();
} else { } else {
// Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen // Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen
if (isset ($user)) { if (isset ($user)) {
$title = Get_Text("no_access_title"); $title = Get_Text("no_access_title");
$content = Get_Text("no_access_text"); $content = Get_Text("no_access_text");
} else { } else {
// Sonst zur Loginseite leiten // Sonst zur Loginseite leiten
redirect(page_link_to("login")); redirect(page_link_to("login"));
} }
} }
// Hinweis für ungelesene Nachrichten // Hinweis für ungelesene Nachrichten
if (isset ($user) && $p != "user_messages") if (isset ($user) && $p != "user_messages")
$content = user_unread_messages() . $content; $content = user_unread_messages() . $content;
// Hinweis für Engel, die noch nicht angekommen sind // Hinweis für Engel, die noch nicht angekommen sind
if(isset($user) && $user['Gekommen'] == 0) if(isset($user) && $user['Gekommen'] == 0)
@ -191,18 +195,18 @@ if(isset($user) && $user['Gekommen'] == 0)
// Erzengel Hinweis für unbeantwortete Fragen // Erzengel Hinweis für unbeantwortete Fragen
if (isset ($user) && $p != "admin_questions") if (isset ($user) && $p != "admin_questions")
$content = admin_new_questions() . $content; $content = admin_new_questions() . $content;
// Erzengel Hinweis für freizuschaltende Engeltypen // Erzengel Hinweis für freizuschaltende Engeltypen
if (isset ($user) && $p != "admin_user_angeltypes") if (isset ($user) && $p != "admin_user_angeltypes")
$content = admin_new_user_angeltypes() . $content; $content = admin_new_user_angeltypes() . $content;
echo template_render('../templates/layout.html', array ( echo template_render('../templates/layout.html', array (
'theme' => isset ($user) ? $user['color'] : $default_theme, 'theme' => isset ($user) ? $user['color'] : $default_theme,
'title' => $title, 'title' => $title,
'atom_link' => ($p == 'news' || $p == 'user_meetings')? '<link href="' . page_link_to('atom') . (($p == 'user_meetings')? '&amp;meetings=1' : '') . '&amp;key=' . $user['ical_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '', 'atom_link' => ($p == 'news' || $p == 'user_meetings')? '<link href="' . page_link_to('atom') . (($p == 'user_meetings')? '&amp;meetings=1' : '') . '&amp;key=' . $user['api_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '',
'menu' => make_menu(), 'menu' => make_menu(),
'content' => $content 'content' => $content
)); ));
counter(); counter();