From a47b1935cb6310e05e4e6b15512b21b7cd4eec3c Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Tue, 10 Sep 2013 14:27:31 +0200 Subject: #119 added basic shift json export support using same pattern like ical export --- includes/pages/user_atom.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'includes/pages/user_atom.php') diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php index fd28510f..c9420c91 100644 --- a/includes/pages/user_atom.php +++ b/includes/pages/user_atom.php @@ -9,16 +9,19 @@ function user_atom() { else die("Missing key."); - $user = sql_select("SELECT * FROM `User` WHERE `ical_key`='" . sql_escape($key) . "' LIMIT 1"); - if (count($user) == 0) + $user = User_by_api_key($key); + if($user === false) + die("Unable to find user."); + if($user == null) 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)); header('Content-Type: application/atom+xml; charset=utf-8'); $html = ' - + Engelsystem ' . $_SERVER['HTTP_HOST'] . htmlspecialchars(preg_replace('#[&?]key=[a-f0-9]{32}#', '', $_SERVER['REQUEST_URI'])) . ' ' . date('Y-m-d\TH:i:sP', $news[0]['Datum']) . "\n"; @@ -29,11 +32,11 @@ function user_atom() { " . preg_replace('#^https?://#', '', page_link_to_absolute("news")) . "-${news_entry['ID']} " . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . " " . htmlspecialchars($news_entry['Text']) . " - \n"; - } - $html .= ""; - header("Content-Length: " . strlen($html)); - echo $html; - die(); + \n"; +} +$html .= ""; +header("Content-Length: " . strlen($html)); +echo $html; +die(); } ?> -- cgit v1.3.1