From a06ffd2e49320c9602993394e5ff2ab5be2a68d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20H=C3=A4usler?= Date: Tue, 11 Oct 2011 22:24:33 +0200 Subject: [PATCH] #27 ical export, key reset --- includes/pages/user_myshifts.php | 21 ++++++++++++++++----- templates/user_myshifts_reset.html | 6 ++++++ 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 templates/user_myshifts_reset.html diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index 78fdf8a1..5a667974 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -7,7 +7,14 @@ function user_myshifts() { global $user, $privileges; $msg = ""; - if (isset ($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) { + if (isset ($_REQUEST['reset'])) { + if ($_REQUEST['reset'] == "ack") { + user_reset_ical_key(); + return success("Key geändert."); + } + return template_render('../templates/user_myshifts_reset.html', array ()); + } + elseif (isset ($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) { $id = $_REQUEST['edit']; $shift = sql_select("SELECT `ShiftEntry`.`Comment`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`Name` as `angel_type` FROM `ShiftEntry` JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`TID`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `id`=" . sql_escape($id) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1"); if (count($shift) > 0) { @@ -66,10 +73,8 @@ function user_myshifts() { if ($html == "") $html = 'Keine...Gehe zum Schichtplan um Dich für Schichten einzutragen.'; - if ($user['ical_key'] == "") { - $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"); - } + if ($user['ical_key'] == "") + user_reset_ical_key(); return template_render('../templates/user_myshifts.html', array ( 'h' => $LETZTES_AUSTRAGEN, @@ -79,4 +84,10 @@ function user_myshifts() { 'reset_link' => page_link_to('user_myshifts') . '&reset' )); } + +function user_reset_ical_key() { + global $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"); +} ?> \ No newline at end of file diff --git a/templates/user_myshifts_reset.html b/templates/user_myshifts_reset.html new file mode 100644 index 00000000..e8aae4e5 --- /dev/null +++ b/templates/user_myshifts_reset.html @@ -0,0 +1,6 @@ +

+ Wenn Du Deinen Key zurück setzt, ändert sich der Link zu Deinem iCal-Export! Du musst diesen dann an allen Stellen, wo Du ihn verwendest aktualisieren. +

+

+ Fortfahren » +