diff options
author | Philip Häusler <msquare@notrademark.de> | 2014-08-22 22:34:13 +0200 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2014-08-22 22:34:13 +0200 |
commit | 74647e16d37fac9425a4561b49618b52cdc3e75c (patch) | |
tree | 7bfd868f8ef2646e65ffd8dbdf63dd8bf91723e3 /includes/pages | |
parent | 721aa7f160db36e53d03081bbda73970b702eeb7 (diff) |
add basic bootstrap theme
Diffstat (limited to 'includes/pages')
-rw-r--r-- | includes/pages/admin_active.php | 2 | ||||
-rw-r--r-- | includes/pages/admin_arrive.php | 10 | ||||
-rw-r--r-- | includes/pages/admin_free.php | 45 | ||||
-rw-r--r-- | includes/pages/admin_log.php | 18 | ||||
-rw-r--r-- | includes/pages/admin_news.php | 124 | ||||
-rw-r--r-- | includes/pages/admin_questions.php | 90 | ||||
-rw-r--r-- | includes/pages/admin_rooms.php | 143 | ||||
-rw-r--r-- | includes/pages/admin_shifts.php | 238 | ||||
-rw-r--r-- | includes/pages/admin_user.php | 4 | ||||
-rw-r--r-- | includes/pages/guest_login.php | 12 | ||||
-rw-r--r-- | includes/pages/user_messages.php | 12 | ||||
-rw-r--r-- | includes/pages/user_myshifts.php | 2 | ||||
-rw-r--r-- | includes/pages/user_news.php | 205 | ||||
-rw-r--r-- | includes/pages/user_questions.php | 17 | ||||
-rw-r--r-- | includes/pages/user_settings.php | 4 | ||||
-rw-r--r-- | includes/pages/user_shifts.php | 55 |
16 files changed, 467 insertions, 514 deletions
diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index 805c8357..24628d0e 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -137,7 +137,7 @@ function admin_active() { 'count' => '<b>' . sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Tshirt`=1") . '</b>' ); - return page(array( + return page_with_title(admin_active_title(), array( form(array( form_text('search', _("Search angel:"), $search), form_submit('submit', _("Search")) diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php index 001da9ba..bec1ae56 100644 --- a/includes/pages/admin_arrive.php +++ b/includes/pages/admin_arrive.php @@ -15,18 +15,18 @@ function admin_arrive() { if ($user_source != null) { sql_query("UPDATE `User` SET `Gekommen`=0 WHERE `UID`=" . sql_escape($id) . " LIMIT 1"); engelsystem_log("User set to not arrived: " . User_Nick_render($user_source)); - $msg = success("Reset done. Angel has not arrived.", true); + $msg = success(_("Reset done. Angel has not arrived."), true); } else - $msg = error("Angel not found.", true); + $msg = error(_("Angel not found."), true); } elseif (isset($_REQUEST['arrived']) && preg_match("/^[0-9]*$/", $_REQUEST['arrived'])) { $id = $_REQUEST['arrived']; $user_source = User($id); if ($user_source != null) { sql_query("UPDATE `User` SET `Gekommen`=1 WHERE `UID`=" . sql_escape($id) . " LIMIT 1"); engelsystem_log("User set has arrived: " . User_Nick_render($user_source)); - $msg = success("Angel has been marked as arrived.", true); + $msg = success(_("Angel has been marked as arrived."), true); } else - $msg = error("Angel not found.", true); + $msg = error(_("Angel not found."), true); } $users = sql_select("SELECT * FROM `User` ORDER BY `Nick`"); @@ -60,7 +60,7 @@ function admin_arrive() { $table .= '</tr>'; $users_matched[] = $usr; } - return page(array( + return page_with_title(admin_arrive_title(), array( msg(), form(array( form_text('search', _("Search"), $search), diff --git a/includes/pages/admin_free.php b/includes/pages/admin_free.php index 86bd38a1..19a4c99f 100644 --- a/includes/pages/admin_free.php +++ b/includes/pages/admin_free.php @@ -5,31 +5,33 @@ function admin_free_title() { function admin_free() { global $privileges; - + $search = ""; - if (isset ($_REQUEST['search'])) + if (isset($_REQUEST['search'])) $search = strip_request_item('search'); - + $angeltypesearch = ""; - if (empty ($_REQUEST['angeltype'])) + if (empty($_REQUEST['angeltype'])) $_REQUEST['angeltype'] = ''; else { $angeltypesearch = " INNER JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id` = '" . sql_escape($_REQUEST['angeltype']) . "' AND `UserAngelTypes`.`user_id` = `User`.`UID`"; - if (isset ($_REQUEST['confirmed_only'])) + if (isset($_REQUEST['confirmed_only'])) $angeltypesearch .= " AND `UserAngelTypes`.`confirm_user_id`"; $angeltypesearch .= ") "; } - + $angel_types_source = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`"); - $angel_types = array('' => 'alle Typen'); + $angel_types = array( + '' => 'alle Typen' + ); foreach ($angel_types_source as $angel_type) $angel_types[$angel_type['id']] = $angel_type['name']; - + $users = sql_select("SELECT `User`.* FROM `User` ${angeltypesearch} LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID` AND `Shifts`.`start` < " . sql_escape(time()) . " AND `Shifts`.`end` > " . sql_escape(time()) . ") WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL GROUP BY `User`.`UID` ORDER BY `Nick`"); - + $table = ""; if ($search == "") - $tokens = array (); + $tokens = array(); else $tokens = explode(" ", $search); foreach ($users as $usr) { @@ -38,10 +40,10 @@ function admin_free() { $index = join("", $usr); foreach ($tokens as $t) if (stristr($index, trim($t))) { - $match = true; - break; - } - if (!$match) + $match = true; + break; + } + if (! $match) continue; } $table .= '<tr>'; @@ -52,15 +54,16 @@ function admin_free() { $table .= '<td><a href="' . page_link_to('admin_user') . '&id=' . $usr['UID'] . '">edit</a></td>'; else $table .= '<td>' . User_Nick_render($usr) . '</td>'; - + $table .= '</tr>'; } - return template_render('../templates/admin_free.html', array ( - 'search' => $search, - 'angeltypes' => html_select_key('angeltype', 'angeltype', $angel_types, $_REQUEST['angeltype']), - 'confirmed_only' => isset($_REQUEST['confirmed_only'])? 'checked' : '', - 'table' => $table, - 'link' => page_link_to('admin_free') + return template_render('../templates/admin_free.html', array( + 'title' => admin_free_title(), + 'search' => $search, + 'angeltypes' => html_select_key('angeltype', 'angeltype', $angel_types, $_REQUEST['angeltype']), + 'confirmed_only' => isset($_REQUEST['confirmed_only']) ? 'checked' : '', + 'table' => $table, + 'link' => page_link_to('admin_free') )); } ?> diff --git a/includes/pages/admin_log.php b/includes/pages/admin_log.php index 2dfc169a..b60a9fca 100644 --- a/includes/pages/admin_log.php +++ b/includes/pages/admin_log.php @@ -6,18 +6,18 @@ function admin_log_title() { function admin_log() { $log_entries_source = LogEntries(); $log_entries = array(); - foreach($log_entries_source as $log_entry) { + foreach ($log_entries_source as $log_entry) { $log_entry['date'] = date("H:i", $log_entry['timestamp']); $log_entries[] = $log_entry; } - - return page(array( - msg(), - table(array( - 'date' => "Time", - 'nick' => "Angel", - 'message' => "Log Entry" - ), $log_entries) + + return page_with_title(admin_log_title(), array( + msg(), + table(array( + 'date' => "Time", + 'nick' => "Angel", + 'message' => "Log Entry" + ), $log_entries) )); } ?> diff --git a/includes/pages/admin_news.php b/includes/pages/admin_news.php index 25807151..39b37068 100644 --- a/includes/pages/admin_news.php +++ b/includes/pages/admin_news.php @@ -1,93 +1,61 @@ <?php function admin_news() { global $user; - - if (!isset ($_GET["action"])) { + + if (! isset($_GET["action"])) { redirect(page_link_to("news")); } else { - $html = ""; - switch ($_GET["action"]) { - case 'edit' : - if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) - $id = $_REQUEST['id']; - else - return error("Incomplete call, missing News ID.", true); - - $news = sql_select("SELECT * FROM `News` WHERE `ID`=" . sql_escape($id) . " LIMIT 1"); - if (count($news) > 0) { - list ($news) = $news; - + $html = '<div class="col-md-10"><h1>' . _("Edit news entry") . '</h1>'; + if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) + $id = $_REQUEST['id']; + else + return error("Incomplete call, missing News ID.", true); + + $news = sql_select("SELECT * FROM `News` WHERE `ID`=" . sql_escape($id) . " LIMIT 1"); + if (count($news) > 0) { + switch ($_REQUEST["action"]) { + default: + redirect(page_link_to('news')); + case 'edit': + list($news) = $news; + $user_source = User($news['UID']); - if($user_source === false) + if ($user_source === false) engelsystem_error("Unable to load user."); - - $html .= '<a href="' . page_link_to("news") . '">« Back</a>'; - - $html .= "<form action=\"" . page_link_to("admin_news") . "&action=save\" method=\"post\">\n"; - - $html .= "<table>\n"; - $html .= " <tr><td>Datum</td><td>" . - date("Y-m-d H:i", $news['Datum']) . "</td></tr>\n"; - $html .= " <tr><td>Betreff</td><td><input type=\"text\" size=\"40\" name=\"eBetreff\" value=\"" . - $news["Betreff"] . "\"></td></tr>\n"; - $html .= " <tr><td>Text</td><td><textarea rows=\"10\" cols=\"80\" name=\"eText\">" . - $news["Text"] . "</textarea></td></tr>\n"; - $html .= " <tr><td>Engel</td><td>" . - User_Nick_render($user_source) . "</td></tr>\n"; - $html .= " <tr><td>Treffen</td><td>" . html_select_key('eTreffen', 'eTreffen', array ( - '1' => "Ja", - '0' => "Nein" - ), $news['Treffen']) . "</td></tr>\n"; - $html .= "</table>"; - - $html .= "<input type=\"hidden\" name=\"id\" value=\"" . $id . "\">\n"; - $html .= "<input type=\"submit\" name=\"submit\" value=\"Speichern\">\n"; - $html .= "</form>"; - - $html .= "<form action=\"" . page_link_to("admin_news") . "&action=delete\" method=\"POST\">\n"; - $html .= "<input type=\"hidden\" name=\"id\" value=\"" . $id . "\">\n"; - $html .= "<input type=\"submit\" name=\"submit\" value=\"Löschen\">\n"; - $html .= "</form>"; - } else - return error("No News found.", true); - break; - - case 'save' : - if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) - $id = $_REQUEST['id']; - else - return error("Incomplete call, missing News ID.", true); - - $news = sql_select("SELECT * FROM `News` WHERE `ID`=" . sql_escape($id) . " LIMIT 1"); - if (count($news) > 0) { - list ($news) = $news; - - sql_query("UPDATE `News` SET `Datum`='" . sql_escape(time()) . "', `Betreff`='" . sql_escape($_POST["eBetreff"]) . "', `Text`='" . sql_escape($_POST["eText"]) . "', `UID`='" . sql_escape($user['UID']) . - "', `Treffen`='" . sql_escape($_POST["eTreffen"]) . "' WHERE `ID`=".sql_escape($id)." LIMIT 1"); + + $html .= form(array( + form_info(_("Date"), date("Y-m-d H:i", $news['Datum'])), + form_info(_("Author"), User_Nick_render($user_source)), + form_text('eBetreff', _("Subject"), $news['Betreff']), + form_textarea('eText', _("Message"), $news['Text']), + form_checkbox('eTreffen', _("Meeting"), $news['Treffen'] == 1, 1), + form_submit('submit', _("Save")) + ), page_link_to('admin_news&action=save&id=' . $id)); + + $html .= '<a class="btn btn-danger" href="' . page_link_to('admin_news&action=delete&id=' . $id) . '"><span class="glyphicon glyphicon-trash"></span> ' . _("Delete") . '</a>'; + break; + + case 'save': + list($news) = $news; + + sql_query("UPDATE `News` SET `Datum`='" . sql_escape(time()) . "', `Betreff`='" . sql_escape($_POST["eBetreff"]) . "', `Text`='" . sql_escape($_POST["eText"]) . "', `UID`='" . sql_escape($user['UID']) . "', `Treffen`='" . sql_escape($_POST["eTreffen"]) . "' WHERE `ID`=" . sql_escape($id) . " LIMIT 1"); engelsystem_log("News updated: " . $_POST["eBetreff"]); + success(_("News entry updated.")); redirect(page_link_to("news")); - } else - return error("No News found.", true); - break; - - case 'delete' : - if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) - $id = $_REQUEST['id']; - else - return error("Incomplete call, missing News ID.", true); - - $news = sql_select("SELECT * FROM `News` WHERE `ID`=" . sql_escape($id) . " LIMIT 1"); - if (count($news) > 0) { - list ($news) = $news; - + break; + + case 'delete': + list($news) = $news; + sql_query("DELETE FROM `News` WHERE `ID`=" . sql_escape($id) . " LIMIT 1"); engelsystem_log("News deleted: " . $news['Betreff']); + success(_("News entry deleted.")); redirect(page_link_to("news")); - } else - return error("No News found.", true); - break; - } + break; + } + } else + return error("No News found.", true); } - return $html; + return $html . '</div>'; } ?>
\ No newline at end of file diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index b70495f6..5d4fbd61 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -5,77 +5,75 @@ function admin_questions_title() { function admin_new_questions() { global $user, $privileges; - + if (in_array("admin_questions", $privileges)) { - $new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID`=0"); - + $new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID` IS NULL"); + if ($new_messages > 0) - return '<p class="info"><a href="' . page_link_to("admin_questions") . '">Es gibt unbeantwortete Fragen!</a></p><hr />'; + return info('<a href="' . page_link_to("admin_questions") . '">Es gibt unbeantwortete Fragen!</a>', true); } - + return ""; } function admin_questions() { global $user; - - if (!isset ($_REQUEST['action'])) { + + if (! isset($_REQUEST['action'])) { $open_questions = ""; - $questions = sql_select("SELECT * FROM `Questions` WHERE `AID`=0"); + $questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL"); foreach ($questions as $question) { $user_source = User($question['UID']); - if($user_source === false) + if ($user_source === false) engelsystem_error("Unable to load user."); - - $open_questions .= template_render( - '../templates/admin_question_unanswered.html', array ( - 'question_nick' => User_Nick_render($user_source), - 'question_id' => $question['QID'], - 'link' => page_link_to("admin_questions"), - 'question' => str_replace("\n", '<br />', $question['Question']) - )); + + $open_questions .= template_render('../templates/admin_question_unanswered.html', array( + 'question_nick' => User_Nick_render($user_source), + 'question_id' => $question['QID'], + 'link' => page_link_to("admin_questions"), + 'question' => str_replace("\n", '<br />', $question['Question']) + )); } - + $answered_questions = ""; - $questions = sql_select("SELECT * FROM `Questions` WHERE `AID`>0"); - + $questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL"); + foreach ($questions as $question) { $user_source = User($question['UID']); - if($user_source === false) + if ($user_source === false) engelsystem_error("Unable to load user."); - + $answer_user_source = User($question['AID']); - if($answer_user_source === false) + if ($answer_user_source === false) engelsystem_error("Unable to load user."); - - $answered_questions .= template_render( - '../templates/admin_question_answered.html', array ( - 'question_id' => $question['QID'], - 'question_nick' => User_Nick_render($user_source), - 'question' => str_replace("\n", "<br />", $question['Question']), - 'answer_nick' => User_Nick_render($answer_user_source), - 'answer' => str_replace("\n", "<br />", $question['Answer']), - 'link' => page_link_to("admin_questions"), - )); + + $answered_questions .= template_render('../templates/admin_question_answered.html', array( + 'question_id' => $question['QID'], + 'question_nick' => User_Nick_render($user_source), + 'question' => str_replace("\n", "<br />", $question['Question']), + 'answer_nick' => User_Nick_render($answer_user_source), + 'answer' => str_replace("\n", "<br />", $question['Answer']), + 'link' => page_link_to("admin_questions") + )); } - - return template_render('../templates/admin_questions.html', array ( - 'link' => page_link_to("admin_questions"), - 'open_questions' => $open_questions, - 'answered_questions' => $answered_questions + + return template_render('../templates/admin_questions.html', array( + 'link' => page_link_to("admin_questions"), + 'open_questions' => $open_questions, + 'answered_questions' => $answered_questions )); } else { switch ($_REQUEST['action']) { - case 'answer' : - if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) + case 'answer': + if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) $id = $_REQUEST['id']; else return error("Incomplete call, missing Question ID.", true); - + $question = sql_select("SELECT * FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1"); - if (count($question) > 0 && $question[0]['AID'] == "0") { + if (count($question) > 0 && $question[0]['AID'] == null) { $answer = trim(preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['answer']))); - + if ($answer != "") { sql_query("UPDATE `Questions` SET `AID`=" . sql_escape($user['UID']) . ", `Answer`='" . sql_escape($answer) . "' WHERE `QID`=" . sql_escape($id) . " LIMIT 1"); engelsystem_log("Question " . $question[0]['Question'] . " answered: " . $answer); @@ -85,12 +83,12 @@ function admin_questions() { } else return error("No question found.", true); break; - case 'delete' : - if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) + case 'delete': + if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) $id = $_REQUEST['id']; else return error("Incomplete call, missing Question ID.", true); - + $question = sql_select("SELECT * FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1"); if (count($question) > 0) { sql_query("DELETE FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1"); diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php index 5e880adb..08d450b8 100644 --- a/includes/pages/admin_rooms.php +++ b/includes/pages/admin_rooms.php @@ -5,32 +5,32 @@ function admin_rooms_title() { function admin_rooms() { global $user; - + $rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`"); - $rooms = array (); + $rooms = array(); foreach ($rooms_source as $room) - $rooms[] = array ( - 'name' => $room['Name'], - 'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '✓' : '', - 'public' => $room['show'] == 'Y' ? '✓' : '', - 'actions' => '<a class="ection edit" href="' . page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'] . '">edit</a> <a class="action delete" href="' . page_link_to('admin_rooms') . '&show=delete&id=' . $room['RID'] . '">delete</a>' + $rooms[] = array( + 'name' => $room['Name'], + 'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '✓' : '', + 'public' => $room['show'] == 'Y' ? '✓' : '', + 'actions' => '<a class="ection edit" href="' . page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'] . '">edit</a> <a class="action delete" href="' . page_link_to('admin_rooms') . '&show=delete&id=' . $room['RID'] . '">delete</a>' ); - - if (isset ($_REQUEST['show'])) { + + if (isset($_REQUEST['show'])) { $msg = ""; $name = ""; $from_pentabarf = ""; $public = 'Y'; $number = ""; - + $angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`"); - $angeltypes = array (); - $angeltypes_count = array (); + $angeltypes = array(); + $angeltypes_count = array(); foreach ($angeltypes_source as $angeltype) { $angeltypes[$angeltype['id']] = $angeltype['name']; $angeltypes_count[$angeltype['id']] = 0; } - + if (test_request_int('id')) { $room = sql_select("SELECT * FROM `Room` WHERE `RID`=" . sql_escape($_REQUEST['id'])); if (count($room) > 0) { @@ -44,120 +44,119 @@ function admin_rooms() { } else redirect(page_link_to('admin_rooms')); } - + if ($_REQUEST['show'] == 'edit') { - if (isset ($_REQUEST['submit'])) { + if (isset($_REQUEST['submit'])) { $ok = true; - - if (isset ($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) + + if (isset($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) $name = strip_request_item('name'); else { $ok = false; $msg .= error("Please enter a name.", true); } - - if (isset ($_REQUEST['from_pentabarf'])) + + if (isset($_REQUEST['from_pentabarf'])) $from_pentabarf = 'Y'; else $from_pentabarf = ''; - - if (isset ($_REQUEST['public'])) + + if (isset($_REQUEST['public'])) $public = 'Y'; else $public = ''; - - if (isset ($_REQUEST['number'])) + + if (isset($_REQUEST['number'])) $number = strip_request_item('number'); else $ok = false; - + foreach ($angeltypes as $angeltype_id => $angeltype) { - if (isset ($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}$/", $_REQUEST['angeltype_count_' . $angeltype_id])) + if (isset($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}$/", $_REQUEST['angeltype_count_' . $angeltype_id])) $angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id]; else { $ok = false; $msg .= error(sprintf("Please enter needed angels for type %s.", $angeltype), true); } } - + if ($ok) { - if(isset($id)) { + if (isset($id)) { sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`=" . sql_escape($id) . " LIMIT 1"); engelsystem_log("Room updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number); } else { - sql_query("INSERT INTO `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "'");
+ sql_query("INSERT INTO `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "'"); $id = sql_id(); engelsystem_log("Room created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number); } - + sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`=" . sql_escape($id)); $needed_angeltype_info = array(); foreach ($angeltypes_count as $angeltype_id => $angeltype_count) { $angeltype_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($angeltype_id) . " LIMIT 1"); - if(count($angeltype_source) > 0) { + if (count($angeltype_source) > 0) { sql_query("INSERT INTO `NeededAngelTypes` SET `room_id`=" . sql_escape($id) . ", `angel_type_id`=" . sql_escape($angeltype_id) . ", `count`=" . sql_escape($angeltype_count)); $needed_angeltype_info[] = $angeltypes_source[0]['name'] . ": " . $angeltype_count; } } - + engelsystem_log("Set needed angeltypes of room " . $name . " to: " . join(", ", $needed_angeltype_info)); success("Room saved."); redirect(page_link_to("admin_rooms")); } } - $angeltypes_count_form = array (); + $angeltypes_count_form = array(); foreach ($angeltypes as $angeltype_id => $angeltype) $angeltypes_count_form[] = form_text('angeltype_count_' . $angeltype_id, $angeltype, $angeltypes_count[$angeltype_id]); - - return page(array ( - buttons(array ( - button(page_link_to('admin_rooms'), "Back", 'back') - )), - $msg, - form(array ( - form_text('name', "Name", $name), - form_checkbox('from_pentabarf', "Pentabarf-Import", $from_pentabarf), - form_checkbox('public', "Public", $public), - form_text('number', "Number", $number), - form_info("Needed angels:", ""), - join($angeltypes_count_form), - form_submit('submit', 'Save') - )) + + return page_with_title(admin_rooms_title(), array( + buttons(array( + button(page_link_to('admin_rooms'), "Back", 'back') + )), + $msg, + form(array( + form_text('name', "Name", $name), + form_checkbox('from_pentabarf', "Pentabarf-Import", $from_pentabarf), + form_checkbox('public', "Public", $public), + form_text('number', "Number", $number), + form_info("Needed angels:", ""), + join($angeltypes_count_form), + form_submit('submit', 'Save') + )) )); - } - elseif ($_REQUEST['show'] == 'delete') { - if (isset ($_REQUEST['ack'])) { + } elseif ($_REQUEST['show'] == 'delete') { + if (isset($_REQUEST['ack'])) { sql_query("DELETE FROM `Room` WHERE `RID`=" . sql_escape($id) . " LIMIT 1"); sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`=" . sql_escape($id) . " LIMIT 1"); - + engelsystem_log("Room deleted: " . $name); success(sprintf("Room %s deleted.", $name)); redirect(page_link_to('admin_rooms')); } - - return page(array ( - buttons(array ( - button(page_link_to('admin_rooms'), "Back", 'back') - )), - sprintf("Do you want to delete room %s?", $name), - buttons(array ( - button(page_link_to('admin_rooms') . '&show=delete&id=' . $id . '&ack', "Delete", 'delete') - )) + + return page_with_title(admin_rooms_title(), array( + buttons(array( + button(page_link_to('admin_rooms'), "Back", 'back') + )), + sprintf("Do you want to delete room %s?", $name), + buttons(array( + button(page_link_to('admin_rooms') . '&show=delete&id=' . $id . '&ack', "Delete", 'delete') + )) )); } } - - return page(array ( - buttons(array ( - button(page_link_to('admin_rooms') . '&show=edit', "Add", 'add') - )), - msg(), - table(array ( - 'name' => "Name", - 'from_pentabarf' => "Pentabarf-Import", - 'public' => "Public", - 'actions' => "" - ), $rooms) + + return page_with_title(admin_rooms_title(), array( + buttons(array( + button(page_link_to('admin_rooms') . '&show=edit', "Add", 'add') + )), + msg(), + table(array( + 'name' => "Name", + 'from_pentabarf' => "Pentabarf-Import", + 'public' => "Public", + 'actions' => "" + ), $rooms) )); } ?> diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php index 1f17cf6e..7e3cc3b3 100644 --- a/includes/pages/admin_shifts.php +++ b/includes/pages/admin_shifts.php @@ -7,74 +7,73 @@ function admin_shifts_title() { function admin_shifts() { $msg = ""; $ok = true; - + $rid = 0; - $start = DateTime :: createFromFormat("Y-m-d H:i", date("Y-m-d") . " 00:00")->getTimestamp(); - $end = $start +24 * 60 * 60; - $mode = ''; - $angelmode = ''; + $start = DateTime::createFromFormat("Y-m-d H:i", date("Y-m-d") . " 00:00")->getTimestamp(); + $end = $start + 24 * 60 * 60; + $mode = 'single'; + $angelmode = 'location'; $length = ''; $change_hours = array(); - + $name = ""; + // Locations laden (auch unsichtbare - fuer Erzengel ist das ok) $rooms = sql_select("SELECT * FROM `Room` ORDER BY `Name`"); - $room_array = array (); + $room_array = array(); foreach ($rooms as $room) $room_array[$room['RID']] = $room['Name']; - - // Engeltypen laden + + // Engeltypen laden $types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`"); - $needed_angel_types = array (); + $needed_angel_types = array(); foreach ($types as $type) $needed_angel_types[$type['id']] = 0; - - if (isset ($_REQUEST['preview']) || isset ($_REQUEST['back'])) { + + if (isset($_REQUEST['preview']) || isset($_REQUEST['back'])) { // Name/Bezeichnung der Schicht, darf leer sein $name = strip_request_item('name'); - + // Auswahl der sichtbaren Locations für die Schichten - if (isset ($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset ($room_array[$_REQUEST['rid']])) + if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room_array[$_REQUEST['rid']])) $rid = $_REQUEST['rid']; else { $ok = false; $rid = $rooms[0]['RID']; $msg .= error("Wähle bitte einen Raum aus.", true); } - - if (isset ($_REQUEST['start']) && $tmp = DateTime :: createFromFormat("Y-m-d H:i", trim($_REQUEST['start']))) + + if (isset($_REQUEST['start']) && $tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['start']))) $start = $tmp->getTimestamp(); else { $ok = false; $msg .= error("Bitte gib einen Startzeitpunkt für die Schichten an.", true); } - - if (isset ($_REQUEST['end']) && $tmp = DateTime :: createFromFormat("Y-m-d H:i", trim($_REQUEST['end']))) + + if (isset($_REQUEST['end']) && $tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['end']))) $end = $tmp->getTimestamp(); else { $ok = false; $msg .= error("Bitte gib einen Endzeitpunkt für die Schichten an.", true); } - + if ($start >= $end) { $ok = false; $msg .= error("Das Ende muss nach dem Startzeitpunkt liegen!", true); } - - if (isset ($_REQUEST['mode'])) { + + if (isset($_REQUEST['mode'])) { if ($_REQUEST['mode'] == 'single') { $mode = 'single'; - } - elseif ($_REQUEST['mode'] == 'multi') { - if (isset ($_REQUEST['length']) && preg_match("/^[0-9]+$/", trim($_REQUEST['length']))) { + } elseif ($_REQUEST['mode'] == 'multi') { + if (isset($_REQUEST['length']) && preg_match("/^[0-9]+$/", trim($_REQUEST['length']))) { $mode = 'multi'; $length = trim($_REQUEST['length']); } else { $ok = false; $msg .= error("Bitte gib eine Schichtlänge in Minuten an.", true); } - } - elseif ($_REQUEST['mode'] == 'variable') { - if (isset ($_REQUEST['change_hours']) && preg_match("/^([0-9]{2}(,|$))/", trim(str_replace(" ", "", $_REQUEST['change_hours'])))) { + } elseif ($_REQUEST['mode'] == 'variable') { + if (isset($_REQUEST['change_hours']) && preg_match("/^([0-9]{2}(,|$))/", trim(str_replace(" ", "", $_REQUEST['change_hours'])))) { $mode = 'variable'; $change_hours = array_map('trim', explode(",", $_REQUEST['change_hours'])); } else { @@ -86,15 +85,14 @@ function admin_shifts() { $ok = false; $msg .= error("Bitte wähle einen Modus.", true); } - - if (isset ($_REQUEST['angelmode'])) { + + if (isset($_REQUEST['angelmode'])) { if ($_REQUEST['angelmode'] == 'location') { $angelmode = 'location'; - } - elseif ($_REQUEST['angelmode'] == 'manually') { + } elseif ($_REQUEST['angelmode'] == 'manually') { $angelmode = 'manually'; foreach ($types as $type) { - if (isset ($_REQUEST['type_' . $type['id']]) && preg_match("/^[0-9]+$/", trim($_REQUEST['type_' . $type['id']]))) { + if (isset($_REQUEST['type_' . $type['id']]) && preg_match("/^[0-9]+$/", trim($_REQUEST['type_' . $type['id']]))) { $needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]); } else { $ok = false; @@ -113,51 +111,49 @@ function admin_shifts() { $ok = false; $msg .= error("Bitte wähle benötigte Engel.", true); } - + // Beim Zurück-Knopf das Formular zeigen - if (isset ($_REQUEST['back'])) + if (isset($_REQUEST['back'])) $ok = false; - - // Alle Eingaben in Ordnung + + // Alle Eingaben in Ordnung if ($ok) { if ($angelmode == 'location') { - $needed_angel_types = array (); + $needed_angel_types = array(); $needed_angel_types_location = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`=" . sql_escape($rid)); foreach ($needed_angel_types_location as $type) $needed_angel_types[$type['angel_type_id']] = $type['count']; } - $shifts = array (); + $shifts = array(); if ($mode == 'single') { - $shifts[] = array ( - 'start' => $start, - 'end' => $end, - 'RID' => $rid, - 'name' => $name + $shifts[] = array( + 'start' => $start, + 'end' => $end, + 'RID' => $rid, + 'name' => $name ); - } - elseif ($mode == 'multi') { + } elseif ($mode == 'multi') { $shift_start = $start; do { $shift_end = $shift_start + $length * 60; - + if ($shift_end > $end) $shift_end = $end; if ($shift_start >= $shift_end) break; - - $shifts[] = array ( - 'start' => $shift_start, - 'end' => $shift_end, - 'RID' => $rid, - 'name' => $name + + $shifts[] = array( + 'start' => $shift_start, + 'end' => $shift_end, + 'RID' => $rid, + 'name' => $name ); - + $shift_start = $shift_end; } while ($shift_end < $end); - } - elseif ($mode == 'variable') { + } elseif ($mode == 'variable') { rsort($change_hours); - $day = DateTime :: createFromFormat("Y-m-d H:i", date("Y-m-d", $start) . " 00:00")->getTimestamp(); + $day = DateTime::createFromFormat("Y-m-d H:i", date("Y-m-d", $start) . " 00:00")->getTimestamp(); $change_index = 0; // Ersten/nächsten passenden Schichtwechsel suchen foreach ($change_hours as $i => $change_hour) { @@ -165,71 +161,70 @@ function admin_shifts() { $change_index = $i; elseif ($start == $day + $change_hour * 60 * 60) { // Start trifft Schichtwechsel - $change_index = ($i +count($change_hours) - 1) % count($change_hours); + $change_index = ($i + count($change_hours) - 1) % count($change_hours); break; } else break; } - + $shift_start = $start; do { - $day = DateTime :: createFromFormat("Y-m-d H:i", date("Y-m-d", $shift_start) . " 00:00")->getTimestamp(); + $day = DateTime::createFromFormat("Y-m-d H:i", date("Y-m-d", $shift_start) . " 00:00")->getTimestamp(); $shift_end = $day + $change_hours[$change_index] * 60 * 60; - + if ($shift_end > $end) $shift_end = $end; if ($shift_start >= $shift_end) $shift_end += 24 * 60 * 60; - - $shifts[] = array ( - 'start' => $shift_start, - 'end' => $shift_end, - 'RID' => $rid, - 'name' => $name + + $shifts[] = array( + 'start' => $shift_start, + 'end' => $shift_end, + 'RID' => $rid, + 'name' => $name ); - + $shift_start = $shift_end; - $change_index = ($change_index +count($change_hours) - 1) % count($change_hours); + $change_index = ($change_index + count($change_hours) - 1) % count($change_hours); } while ($shift_end < $end); } - + $shifts_table = ""; foreach ($shifts as $shift) { - $shifts_table .= '<tr><td>' . date("Y-m-d H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . '<br />' . $room_array[$shift['RID']] . '</td>'; + $shifts_table .= '<tr><td><span class="glyphicon glyphicon-time"></span> ' . date("Y-m-d H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . '<br /><span class="glyphicon glyphicon-map-marker"></span> ' . $room_array[$shift['RID']] . '</td>'; $shifts_table .= '<td>' . $shift['name']; foreach ($types as $type) { - if (isset ($needed_angel_types[$type['id']]) && $needed_angel_types[$type['id']] > 0) - $shifts_table .= '<br /><b>' . $type['name'] . ':</b> ' . $needed_angel_types[$type['id']] . ' missing'; + if (isset($needed_angel_types[$type['id']]) && $needed_angel_types[$type['id']] > 0) + $shifts_table .= '<br /><span class="icon-icon_angel"></span> <b>' . $type['name'] . ':</b> ' . $needed_angel_types[$type['id']] . ' missing'; } $shifts_table .= '</td></tr>'; } - + // Fürs Anlegen zwischenspeichern: $_SESSION['admin_shifts_shifts'] = $shifts; $_SESSION['admin_shifts_types'] = $needed_angel_types; - + $hidden_types = ""; foreach ($needed_angel_types as $type_id => $count) $hidden_types .= '<input type="hidden" name="type_' . $type_id . '" value="' . $count . '" />'; - return template_render('../templates/admin_shift_preview.html', array ( - 'shifts_table' => $shifts_table, - 'name' => $name, - 'rid' => $rid, - 'start' => date("Y-m-d H:i", $start), - 'end' => date("Y-m-d H:i", $end), - 'mode' => $mode, - 'length' => $length, - 'change_hours' => implode(', ', $change_hours), - 'angelmode' => $angelmode, - 'needed_angel_types' => $hidden_types + return template_render('../templates/admin_shift_preview.html', array( + 'shifts_table' => $shifts_table, + 'name' => $name, + 'rid' => $rid, + 'start' => date("Y-m-d H:i", $start), + 'end' => date("Y-m-d H:i", $end), + 'mode' => $mode, + 'length' => $length, + 'change_hours' => implode(', ', $change_hours), + 'angelmode' => $angelmode, + 'needed_angel_types' => $hidden_types )); } - - } - elseif (isset ($_REQUEST['submit'])) { - if (!is_array($_SESSION['admin_shifts_shifts']) || !is_array($_SESSION['admin_shifts_types'])) + + } elseif (isset($_REQUEST['submit'])) { + if (! is_array($_SESSION['admin_shifts_shifts']) || ! is_array($_SESSION['admin_shifts_types'])) redirect(page_link_to('admin_shifts')); - + foreach ($_SESSION['admin_shifts_shifts'] as $shift) { sql_query("INSERT INTO `Shifts` SET `start`=" . sql_escape($shift['start']) . ", `end`=" . sql_escape($shift['end']) . ", `RID`=" . sql_escape($shift['RID']) . ", `name`='" . sql_escape($shift['name']) . "'"); $shift_id = sql_id(); @@ -237,43 +232,54 @@ function admin_shifts() { $needed_angel_types_info = array(); foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) { $angel_type_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1"); - if(count($angel_type_source) > 0) { + if (count($angel_type_source) > 0) { sql_query("INSERT INTO `NeededAngelTypes` SET `shift_id`=" . sql_escape($shift_id) . ", `angel_type_id`=" . sql_escape($type_id) . ", `count`=" . sql_escape($count)); $needed_angel_types_info[] = $angel_type_source[0]['name'] . ": " . $count; } } } - + engelsystem_log("Shift needs following angel types: " . join(", ", $needed_angel_types_info)); $msg = success("Schichten angelegt.", true); } else { - unset ($_SESSION['admin_shifts_shifts']); - unset ($_SESSION['admin_shifts_types']); + unset($_SESSION['admin_shifts_shifts']); + unset($_SESSION['admin_shifts_types']); } - + + if (! isset($_REQUEST['rid'])) + $_REQUEST['rid'] = null; $room_select = html_select_key('rid', 'rid', $room_array, $_REQUEST['rid']); $angel_types = ""; - foreach ($types as $type) { - $angel_types .= template_render('../templates/admin_shifts_angel_types.html', array ( - 'id' => $type['id'], - 'type' => $type['name'], - 'value' => $needed_angel_types[$type['id']] - )); - } - return template_render('../templates/admin_shifts.html', array ( - 'angel_types' => $angel_types, - 'room_select' => $room_select, - 'msg' => $msg, - 'name' => $name, - 'start' => date("Y-m-d H:i", $start), - 'end' => date("Y-m-d H:i", $end), - 'mode_single_selected' => $_REQUEST['mode'] == 'single' ? 'checked="checked"' : '', - 'mode_multi_selected' => $_REQUEST['mode'] == 'multi' ? 'checked="checked"' : '', - 'mode_multi_length' => !empty ($_REQUEST['length']) ? $_REQUEST['length'] : '120', - 'mode_variable_selected' => $_REQUEST['mode'] == 'variable' ? 'checked="checked"' : '', - 'mode_variable_hours' => !empty ($_REQUEST['change_hours']) ? $_REQUEST['change_hours'] : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22', - 'angelmode_location_selected' => $_REQUEST['angelmode'] == 'location' ? 'checked="checked"' : '', - 'angelmode_manually_selected' => $_REQUEST['angelmode'] == 'manually' ? 'checked="checked"' : '' + foreach ($types as $type) + $angel_types .= form_spinner('type_' . $type['id'], $type['name'], $needed_angel_types[$type['id']]); + + return page_with_title(admin_shifts_title(), array( + msg(), + $msg, + form(array( + form_text('name', _("Name"), $name), + // TODO: form_textarea('description', _("Description"), ''), + form_select('rid', _("Room"), $room_array, $_REQUEST['rid']), + '<div class="row">', + '<div class="col-md-6">', + form_text('start', _("Start"), date("Y-m-d H:i", $start)), + form_text('end', _("End"), date("Y-m-d H:i", $end)), + form_info(_("Mode"), ''), + form_radio('mode', _("Create one shift"), $mode == 'single', 'single'), + form_radio('mode', _("Create multiple shifts"), $mode == 'multi', 'multi'), + form_text('length', _("Length"), ! empty($_REQUEST['length']) ? $_REQUEST['length'] : '120'), + form_radio('mode', _("Create multiple shifts with variable length"), $mode == 'variable', 'variable'), + form_text('change_hours', _("Shift change hours"), ! empty($_REQUEST['change_hours']) ? $_REQUEST['change_hours'] : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22'), + '</div>', + '<div class="col-md-6">', + form_info(_("Needed angels"), ''), + form_radio('angelmode', _("Take needed angels from room settings"), $angelmode == 'location', 'location'), + form_radio('angelmode', _("The following angels are needed"), $angelmode == 'manually', 'manually'), + $angel_types, + '</div>', + '</div>', + form_submit('preview', _("Preview")) + )) )); } ?> diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 67ec93f7..7df39d0d 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -6,7 +6,7 @@ function admin_user_title() { function admin_user() { global $user, $privileges, $tshirt_sizes, $privileges; - $html = ""; + $html = '<div class="col-md-10">'; if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['id']) && sql_num_query("SELECT * FROM `User` WHERE `UID`=" . sql_escape($_REQUEST['id'])) > 0) { $id = $_REQUEST['id']; @@ -346,6 +346,6 @@ function admin_user() { 'edit' => '' ), $angels); } - return $html; + return $html . '</div>'; } ?> diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index e4188151..29487f99 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -135,7 +135,7 @@ function guest_register() { } } - return page(array( + return page_with_title(register_title(), array( _("By completing this form you're registering as a Chaos-Angel. This script will create you an account in the angel task sheduler."), $msg, msg(), @@ -208,17 +208,20 @@ function guest_login() { } } - return page(array( + return page_with_title(login_title(), array( msg(), + '<div class="container"><div class="col-md-6">', form(array( form_text('nick', _("Nick"), $nick), form_password('password', _("Password")), + form_submit('submit', _("Login")), form_info("", buttons(array( button(page_link_to('user_password_recovery'), _("I forgot my password")) ))), - form_submit('submit', _("Login")), info(_("Please note: You have to activate cookies!"), true) )), + '</div>', + '<div class="col-md-6">', '<h2>' . register_title() . '</h2>', '<p>' . _("Please sign up, if you want to help us!") . '</p>', buttons(array( @@ -228,7 +231,8 @@ function guest_login() { '<p>' . _("Please read about the jobs you can do to help us.") . '</p>', buttons(array( button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' »') - )) + )), + '</div></div>' )); } ?> diff --git a/includes/pages/user_messages.php b/includes/pages/user_messages.php index 7a05491c..a1b565ec 100644 --- a/includes/pages/user_messages.php +++ b/includes/pages/user_messages.php @@ -4,16 +4,13 @@ function messages_title() { } function user_unread_messages() { - global $user, $privileges; + global $user; - if (in_array("user_messages", $privileges)) { + if (isset($user)) { $new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`=" . sql_escape($user['UID'])); - - if ($new_messages > 0) - return sprintf('<p class="info"><a href="%s">%s</a></p><hr />', page_link_to("user_messages"), sprintf(ngettext("You have %s new message.", "You have %s new messages.", $new_messages), $new_messages)); + return '<span class="badge">' . $new_messages . '</span>'; } - - return ""; + return ''; } function user_messages() { @@ -54,6 +51,7 @@ function user_messages() { } return template_render('../templates/user_messages.html', array( + 'title' => messages_title(), 'link' => page_link_to("user_messages"), 'greeting' => sprintf(_("Hello %s, here can you leave messages for other angels"), User_Nick_render($user)) . '<br /><br />', 'messages' => $messages_html, diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index 1395d3bf..12ba5562 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -143,7 +143,7 @@ function user_myshifts() { 'actions' => "" ); - return page(array( + return page_with_title(myshifts_title(), array( msg(), $id == $user['UID'] ? sprintf(_('These are your shifts.<br/>Please try to appear <b>15 minutes</b> before your shift begins!<br/>You can remove yourself from a shift up to %d hours before it starts.'), $LETZTES_AUSTRAGEN) : '', $id != $user['UID'] ? info(sprintf("You are viewing %s's shifts.", $shifts_user['Nick']), true) : '', diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php index c85a6243..b8879e62 100644 --- a/includes/pages/user_news.php +++ b/includes/pages/user_news.php @@ -13,182 +13,153 @@ function meetings_title() { function user_meetings() { global $DISPLAY_NEWS, $privileges, $user; - - $html = ""; - - if (isset ($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) + + $html = '<div class="col-md-10"><h1>' . meetings_title() . '</h1>'; + + if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) $page = $_REQUEST['page']; else $page = 0; - + $news = sql_select("SELECT * FROM `News` WHERE `Treffen`=1 ORDER BY `ID` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS)); foreach ($news as $entry) $html .= display_news($entry); - - $html .= "<div class=\"pagination\">\n\n"; - $dis_rows = ceil(sql_num_query("SELECT * FROM `News` WHERE `Treffen`=1") / $DISPLAY_NEWS); - - $html .= _("Page:"); - - for ($i = 0; $i < $dis_rows; $i++) { + + $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); + $html .= '<div class="text-center">' . '<ul class="pagination">'; + for ($i = 0; $i < $dis_rows; $i ++) { if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) - $html .= ($i +1) . " "; + $html .= '<li class="active">'; + elseif (! isset($_REQUEST['page']) && $i == 0) + $html .= '<li class="active">'; else - $html .= '<a href="' . page_link_to("news") . '&page=' . $i . '">' . ($i +1) . '</a> '; + $html .= '<li>'; + $html .= '<a href="' . page_link_to("user_meetings") . '&page=' . $i . '">' . ($i + 1) . '</a></li>'; } - $html .= '</div>'; + $html .= '</ul></div></div>'; + return $html; } function display_news($news) { global $privileges, $p; - - $html = ""; - $html .= '<article class="news' . ($news['Treffen'] == 1 ? ' meeting' : '') . '">'; - $html .= '<details>'; - $html .= date("Y-m-d H:i", $news['Datum']) . ', '; - + + $html = ''; + $html .= '<div class="panel' . ($news['Treffen'] == 1 ? ' panel-info' : ' panel-default') . '">'; + $html .= '<div class="panel-heading">'; + $html .= '<h3 class="panel-title">' . ($news['Treffen'] == 1 ? '[Meeting] ' : '') . ReplaceSmilies($news['Betreff']) . '</h3>'; + $html .= '</div>'; + $html .= '<div class="panel-body">' . ReplaceSmilies(nl2br($news['Text'])) . '</div>'; + + $html .= '<div class="panel-footer text-muted">'; + if (in_array("admin_news", $privileges)) + $html .= '<div class="pull-right"><a class="btn btn-xs btn-default" href="' . page_link_to("admin_news") . '&action=edit&id=' . $news['ID'] . '">' . _("edit") . '</a></div>'; + + $html .= '<span class="glyphicon glyphicon-time"></span> ' . date("Y-m-d H:i", $news['Datum']) . ' '; + $user_source = User($news['UID']); - if($user_source === false) + if ($user_source === false) engelsystem_error(_("Unable to load user.")); - + $html .= User_Nick_render($user_source); if ($p != "news_comments") - $html .= ', <a href="' . page_link_to("news_comments") . '&nid=' . $news['ID'] . '">' . _("Comments") . ' (' . sql_num_query("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($news['ID']) . "'") . ') »</a>'; - $html .= '</details>'; - $html .= '<h3>' . ($news['Treffen'] == 1 ? '[Meeting] ' : '') . ReplaceSmilies($news['Betreff']) . '</h3>'; - $html .= '<p>' . ReplaceSmilies(nl2br($news['Text'])) . '</p>'; - if (in_array("admin_news", $privileges)) - $html .= '<details><a href="' . page_link_to("admin_news") . '&action=edit&id=' . $news['ID'] . '">' . _("edit") . '</a></details>'; - - $html .= '</article>'; + $html .= ' <a href="' . page_link_to("news_comments") . '&nid=' . $news['ID'] . '"><span class="glyphicon glyphicon-comment"></span> ' . _("Comments") . ' »</a> <span class="badge">' . sql_num_query("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($news['ID']) . "'") . '</span>'; + $html .= '</div>'; + $html .= '</div>'; return $html; } function user_news_comments() { global $user; - - $html = ""; - if (isset ($_REQUEST["nid"]) && preg_match("/^[0-9]{1,}$/", $_REQUEST['nid']) && sql_num_query("SELECT * FROM `News` WHERE `ID`=" . sql_escape($_REQUEST['nid']) . " LIMIT 1") > 0) { + + $html = '<div class="col-md-10"><h1>' . user_news_comments_title() . '</h1>'; + if (isset($_REQUEST["nid"]) && preg_match("/^[0-9]{1,}$/", $_REQUEST['nid']) && sql_num_query("SELECT * FROM `News` WHERE `ID`=" . sql_escape($_REQUEST['nid']) . " LIMIT 1") > 0) { $nid = $_REQUEST["nid"]; - list ($news) = sql_select("SELECT * FROM `News` WHERE `ID`=" . sql_escape($nid) . " LIMIT 1"); - if (isset ($_REQUEST["text"])) { + list($news) = sql_select("SELECT * FROM `News` WHERE `ID`=" . sql_escape($nid) . " LIMIT 1"); + if (isset($_REQUEST["text"])) { $text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['text'])); sql_query("INSERT INTO `NewsComments` (`Refid`, `Datum`, `Text`, `UID`) VALUES ('" . sql_escape($nid) . "', '" . date("Y-m-d H:i:s") . "', '" . sql_escape($text) . "', '" . sql_escape($user["UID"]) . "')"); engelsystem_log("Created news_comment: " . $text); $html .= success(_("Entry saved."), true); } - - $html .= '<a href="' . page_link_to("news") . '">« ' . _("back") . '</a>'; + $html .= display_news($news); - - $html .= '<h2>' . _("Comments") . '</h2>'; - + $comments = sql_select("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($nid) . "' ORDER BY 'ID'"); foreach ($comments as $comment) { $user_source = User($comment['UID']); - if($user_source === false) + if ($user_source === false) engelsystem_error(_("Unable to load user.")); - - $html .= '<article class="news_comment">'; - $html .= User_Avatar_render($user_source); - $html .= '<details>'; - $html .= $comment['Datum'] . ', '; + + $html .= '<div class="panel panel-default">'; + $html .= '<div class="panel-body">' . nl2br($comment['Text']) . '</div>'; + $html .= '<div class="panel-footer text-muted">'; + $html .= '<span class="glyphicon glyphicon-time"></span> ' . $comment['Datum'] . ' '; $html .= User_Nick_render($user_source); - $html .= '</details>'; - $html .= '<p>' . nl2br($comment['Text']) . '</p>'; - $html .= '</article>'; + $html .= '</div>'; + $html .= '</div>'; } - - $html .= "</table>"; - $html .= ' - <br /> - <hr> - <h2>' . _("New Comment:") . '</h2> - <a name="Neu"> </a> - - <form action="' . page_link_to("news_comments") . '" method="post"> - <input type="hidden" name="nid" value="' . $_REQUEST["nid"] . '"> - <table> - <tr> - <td align="right" valign="top">' . _("Message:") . '</td> - <td><textarea name="text" cols="50" rows="10"></textarea></td> - </tr> - </table> - <br /> - <input type="submit" value="' . _("Save") . '"> - </form>'; + + $html .= '<hr /><h2>' . _("New Comment:") . '</h2>'; + $html .= form(array( + form_textarea('text', _("Message"), ''), + form_submit('submit', _("Save")) + ), page_link_to('news_comments') . '&nid=' . $news['ID']); + } else { $html .= _("Invalid request."); } - - return $html; + + return $html . '</div>'; } function user_news() { global $DISPLAY_NEWS, $privileges, $user; - - $html = msg(); - - if (isset ($_POST["text"]) && isset ($_POST["betreff"]) && in_array("admin_news", $privileges)) { - if (!isset ($_POST["treffen"]) || !in_array("admin_news", $privileges)) + + $html = '<div class="col-md-10"><h1>' . news_title() . '</h1>' . msg(); + + if (isset($_POST["text"]) && isset($_POST["betreff"]) && in_array("admin_news", $privileges)) { + if (! isset($_POST["treffen"]) || ! in_array("admin_news", $privileges)) $_POST["treffen"] = 0; - sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . - "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . - "', '" . sql_escape($_POST["treffen"]) . "');"); + sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . "', '" . sql_escape($_POST["treffen"]) . "');"); engelsystem_log("Created news: " . $_POST["betreff"] . ", treffen: " . $_POST["treffen"]); success(_("Entry saved.")); redirect(page_link_to('news')); } - - if (isset ($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) + + if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) $page = $_REQUEST['page']; else $page = 0; - + $news = sql_select("SELECT * FROM `News` ORDER BY `ID` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS)); foreach ($news as $entry) $html .= display_news($entry); - - $html .= "<div class=\"pagination\">\n\n"; + $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); - - $html .= _("Page:"); - - for ($i = 0; $i < $dis_rows; $i++) { + $html .= '<div class="text-center">' . '<ul class="pagination">'; + for ($i = 0; $i < $dis_rows; $i ++) { if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) - $html .= ($i +1) . " "; + $html .= '<li class="active">'; + elseif (! isset($_REQUEST['page']) && $i == 0) + $html .= '<li class="active">'; else - $html .= '<a href="' . page_link_to("news") . '&page=' . $i . '">' . ($i +1) . '</a> '; + $html .= '<li>'; + $html .= '<a href="' . page_link_to("news") . '&page=' . $i . '">' . ($i + 1) . '</a></li>'; } - $html .= '</div>'; + $html .= '</ul></div>'; + if (in_array("admin_news", $privileges)) { - $html .= '<br /><hr /> - <h2>' . _("Create news:") . '</h2> - <a name="Neu"> </a> - - <form action="" method="post"> - <table> - <tr> - <td align="right">' . _("Subject") . ':</td> - <td><input type="text" name="betreff" size="60"></td> - </tr> - <tr> - <td align="right">' . _("Message") . ':</td> - <td><textarea name="text" cols="50" rows="10"></textarea></td> - </tr>'; - if (in_array('admin_news', $privileges)) { - $html .= ' <tr> - <td align="right">' . _("Meeting") . ':</td> - <td><input type="checkbox" name="treffen" size="1" value="1"></td> - </tr>'; - - } - $html .= '</table> - <br /> - <input type="submit" value="' . _("Save") . '"> - </form>'; + $html .= '<hr />'; + $html .= '<h2>' . _("Create news:") . '</h2>'; + + $html .= form(array( + form_text('betreff', _("Subject"), ''), + form_textarea('text', _("Message"), ''), + form_checkbox('treffen', _("Meeting"), false, 1), + form_submit('submit', _("Save")) + )); } - return $html; + return $html . '</div>'; } ?>
\ No newline at end of file diff --git a/includes/pages/user_questions.php b/includes/pages/user_questions.php index 0ed1339c..be7f9930 100644 --- a/includes/pages/user_questions.php +++ b/includes/pages/user_questions.php @@ -7,9 +7,9 @@ function user_questions() { global $user; if (! isset($_REQUEST['action'])) { - $open_questions = sql_select("SELECT * FROM `Questions` WHERE `AID`=0 AND `UID`=" . sql_escape($user['UID'])); + $open_questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`=" . sql_escape($user['UID'])); - $answered_questions = sql_select("SELECT * FROM `Questions` WHERE `AID`>0 AND `UID`=" . sql_escape($user['UID'])); + $answered_questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL AND `UID`=" . sql_escape($user['UID'])); foreach ($answered_questions as &$question) { $answer_user_source = User($question['AID']); if ($answer_user_source === false) @@ -23,10 +23,15 @@ function user_questions() { case 'ask': $question = strip_request_item_nl('question'); if ($question != "") { - sql_query("INSERT INTO `Questions` SET `UID`=" . sql_escape($user['UID']) . ", `Question`='" . sql_escape($question) . "'"); + $result = sql_query("INSERT INTO `Questions` SET `UID`=" . sql_escape($user['UID']) . ", `Question`='" . sql_escape($question) . "'"); + if ($result === false) + engelsystem_error(_("Unable to save question.")); + success(_("You question was saved.")); redirect(page_link_to("user_questions")); } else - return error(_("Please enter a question!"), true); + return page_with_title(questions_title(), array( + error(_("Please enter a question!"), true) + )); break; case 'delete': if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) @@ -39,7 +44,9 @@ function user_questions() { sql_query("DELETE FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1"); redirect(page_link_to("user_questions")); } else - return error(_("No question found."), true); + return page_with_title(questions_title(), array( + error(_("No question found."), true) + )); break; } } diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index 2a54a485..da671b0b 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -162,7 +162,7 @@ function user_settings() { } } - return page(array( + return page_with_title(settings_title(), array( sprintf(_("Hello %s, here you can change your personal settings i.e. password, color settings etc."), User_Nick_render($user)), $msg, msg(), @@ -180,7 +180,7 @@ function user_settings() { form_text('jabber', _("Jabber"), $jabber), form_text('hometown', _("Hometown"), $hometown), $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $tshirt_size) : '', - form_checkboxes('angel_types', _("What do you want to do?") . sprintf("<br>(<a href=\"%s\">%s</a>)", page_link_to('angeltypes') . '&action=about', _("Description of job types")), $angel_types, $selected_angel_types), + form_checkboxes('angel_types', _("What do you want to do?") . sprintf(" (<a href=\"%s\">%s</a>)", page_link_to('angeltypes') . '&action=about', _("Description of job types")), $angel_types, $selected_angel_types), form_submit('submit', _("Save")) )), form(array( diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 1e94b99f..2adce0d5 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -138,15 +138,10 @@ function user_shifts() { $room_select = html_select_key('rid', 'rid', $room_array, $rid); $angel_types = ""; - foreach ($types as $type) { - $angel_types .= template_render('../templates/admin_shifts_angel_types.html', array( - 'id' => $type['id'], - 'type' => $type['name'], - 'value' => $needed_angel_types[$type['id']] - )); - } + foreach ($types as $type) + $angel_types .= form_spinner('type_' . $type['id'], $type['name'], $needed_angel_types[$type['id']]); - return page(array( + return page_with_title(shifts_title(), array( msg(), '<noscript>' . info(_("This page is much more comfortable with javascript."), true) . '</noscript>', form(array( @@ -182,7 +177,7 @@ function user_shifts() { redirect(page_link_to('user_shifts')); } - return page(array( + return page_with_title(shifts_title(), array( error(sprintf(_("Do you want to delete the shift %s from %s to %s?"), $shift['name'], date("Y-m-d H:i", $shift['start']), date("H:i", $shift['end'])), true), '<a class="button" href="?p=user_shifts&delete_shift=' . $shift_id . '&delete">' . _("delete") . '</a>' )); @@ -457,7 +452,7 @@ function view_user_shifts() { $shifts[$k]['own'] = in_array($shift['SID'], array_keys($ownshifts)); } - $shifts_table = '<table id="shifts" class="scrollable"><thead><tr><th>-</th>'; + $shifts_table = '<table id="shifts" class="table scrollable"><thead><tr><th>-</th>'; foreach ($myrooms as $key => $room) { $rid = $room["id"]; if (array_sum($block[$rid]) == 0) { @@ -734,19 +729,25 @@ function view_user_shifts() { if ($user['api_key'] == "") User_reset_api_key($user); - return msg() . template_render('../templates/user_shifts.html', array( - 'room_select' => make_select($rooms, $_SESSION['user_shifts']['rooms'], "rooms", _("Rooms")), - 'start_select' => html_select_key("start_day", "start_day", array_combine($days, $days), $_SESSION['user_shifts']['start_day']), - 'start_time' => $_SESSION['user_shifts']['start_time'], - 'end_select' => html_select_key("end_day", "end_day", array_combine($days, $days), $_SESSION['user_shifts']['end_day']), - 'end_time' => $_SESSION['user_shifts']['end_time'], - 'type_select' => make_select($types, $_SESSION['user_shifts']['types'], "types", _("Tasks") . '<sup>1</sup>'), - 'filled_select' => make_select($filled, $_SESSION['user_shifts']['filled'], "filled", _("Occupancy")), - 'task_notice' => '<sup>1</sup>' . _("The tasks shown here are influenced by the preferences you defined in your settings!") . " <a href=\"" . page_link_to('angeltypes') . '&action=about' . "\">" . _("Description of the jobs.") . "</a>", - '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, - 'ical_text' => '<h2>' . _("iCal export") . '</h2><p>' . sprintf(_("Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%s\">reset the api key</a>)."), page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to('user_myshifts') . '&reset') . '</p>', - 'filter' => _("Filter") + return page(array( + '<div class="col-md-10">', + msg(), + template_render('../templates/user_shifts.html', array( + 'title' => shifts_title(), + 'room_select' => make_select($rooms, $_SESSION['user_shifts']['rooms'], "rooms", _("Rooms")), + 'start_select' => html_select_key("start_day", "start_day", array_combine($days, $days), $_SESSION['user_shifts']['start_day']), + 'start_time' => $_SESSION['user_shifts']['start_time'], + 'end_select' => html_select_key("end_day", "end_day", array_combine($days, $days), $_SESSION['user_shifts']['end_day']), + 'end_time' => $_SESSION['user_shifts']['end_time'], + 'type_select' => make_select($types, $_SESSION['user_shifts']['types'], "types", _("Tasks") . '<sup>1</sup>'), + 'filled_select' => make_select($filled, $_SESSION['user_shifts']['filled'], "filled", _("Occupancy")), + 'task_notice' => '<sup>1</sup>' . _("The tasks shown here are influenced by the preferences you defined in your settings!") . " <a href=\"" . page_link_to('angeltypes') . '&action=about' . "\">" . _("Description of the jobs.") . "</a>", + '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, + 'ical_text' => '<h2>' . _("iCal export") . '</h2><p>' . sprintf(_("Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%s\">reset the api key</a>)."), page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to('user_myshifts') . '&reset') . '</p>', + 'filter' => _("Filter") + )), + '</div>' )); } @@ -771,14 +772,12 @@ function get_ids_from_array($array) { function make_select($items, $selected, $name, $title = null) { $html_items = array(); if (isset($title)) - $html_items[] = '<li class="heading">' . $title . '</li>' . "\n"; + $html_items[] = '<h4>' . $title . '</h4>' . "\n"; foreach ($items as $i) - $html_items[] = '<li><label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"' . (in_array($i['id'], $selected) ? ' checked="checked"' : '') . '> ' . $i['name'] . '</label>' . (! isset($i['enabled']) || $i['enabled'] ? '' : ' <img src="pic/icons/lock.png" alt="unconfirmed" title="Du bist für diesen Engeltyp noch nicht freigeschaltet." />') . '</li>'; - $html = '<div class="selection ' . $name . '">' . "\n"; - $html .= '<ul id="selection_' . $name . '">' . "\n"; + $html_items[] = '<div class="checkbox"><label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"' . (in_array($i['id'], $selected) ? ' checked="checked"' : '') . '> ' . $i['name'] . '</label>' . (! isset($i['enabled']) || $i['enabled'] ? '' : ' <img src="pic/icons/lock.png" alt="unconfirmed" title="Du bist für diesen Engeltyp noch nicht freigeschaltet." />') . '</div><br />'; + $html = '<div id="selection_' . $name . '" class="selection ' . $name . '">' . "\n"; $html .= implode("\n", $html_items); - $html .= '</ul>' . "\n"; $html .= buttons(array( button("javascript: check_all('selection_" . $name . "')", _("All"), ""), button("javascript: uncheck_all('selection_" . $name . "')", _("None"), "") |