diff options
Diffstat (limited to 'includes/pages')
-rw-r--r-- | includes/pages/admin_free.php | 51 | ||||
-rw-r--r-- | includes/pages/admin_groups.php | 87 | ||||
-rw-r--r-- | includes/pages/admin_questions.php | 52 | ||||
-rw-r--r-- | includes/pages/admin_shifts.php | 43 | ||||
-rw-r--r-- | includes/pages/user_messages.php | 57 | ||||
-rw-r--r-- | includes/pages/user_myshifts.php | 5 | ||||
-rw-r--r-- | includes/pages/user_wakeup.php | 90 |
7 files changed, 168 insertions, 217 deletions
diff --git a/includes/pages/admin_free.php b/includes/pages/admin_free.php index 19a4c99f..836197db 100644 --- a/includes/pages/admin_free.php +++ b/includes/pages/admin_free.php @@ -29,7 +29,7 @@ function admin_free() { $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 = ""; + $free_users_table = array(); if ($search == "") $tokens = array(); else @@ -46,24 +46,41 @@ function admin_free() { if (! $match) continue; } - $table .= '<tr>'; - $table .= '<td>' . User_Nick_render($usr) . '</td>'; - $table .= '<td>' . $usr['DECT'] . '</td>'; - $table .= '<td>' . $usr['jabber'] . '</td>'; - if (in_array('admin_user', $privileges)) - $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>'; + $free_users_table[] = array( + 'name' => User_Nick_render($usr), + 'shift_state' => User_shift_mode_render(User_shift_state($usr)), + 'dect' => $usr['DECT'], + 'jabber' => $usr['jabber'], + 'email' => $usr['email'], + 'actions' => in_array('admin_user', $privileges) ? button(page_link_to('admin_user') . '&id=' . $usr['UID'], _("edit"), 'btn-xs') : '' + ); } - 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') + return page_with_title(admin_free_title(), array( + form(array( + div('row', array( + div('col-md-4', array( + form_text('search', _("Search"), $search) + )), + div('col-md-4', array( + form_select('angeltype', _("Angeltype"), $angel_types, $_REQUEST['angeltype']) + )), + div('col-md-2', array( + form_checkbox('confirmed_only', _("Only confirmed"), isset($_REQUEST['confirmed_only'])) + )), + div('col-md-2', array( + form_submit('submit', _("Search")) + )) + )) + )), + table(array( + 'name' => _("Nick"), + 'shift_state' => '', + 'dect' => _("DECT"), + 'jabber' => _("Jabber"), + 'email' => _("E-Mail"), + 'actions' => '' + ), $free_users_table) )); } ?> diff --git a/includes/pages/admin_groups.php b/includes/pages/admin_groups.php index 4d88e74e..3133cf8b 100644 --- a/includes/pages/admin_groups.php +++ b/includes/pages/admin_groups.php @@ -5,87 +5,76 @@ function admin_groups_title() { function admin_groups() { global $user; - + $html = ""; $groups = sql_select("SELECT * FROM `Groups` ORDER BY `Name`"); - if (!isset ($_REQUEST["action"])) { - $groups_html = ""; + if (! isset($_REQUEST["action"])) { + $groups_table = array(); foreach ($groups as $group) { - $groups_html .= sprintf( - '<tr><td>%s</td>', - $group['Name'] - ); $privileges = sql_select("SELECT * FROM `GroupPrivileges` JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `group_id`=" . sql_escape($group['UID'])); - $privileges_html = array (); - + $privileges_html = array(); + foreach ($privileges as $priv) $privileges_html[] = $priv['name']; - - $groups_html .= sprintf( - '<td>%s</td>' - . '<td><a href="%s&action=edit&id=%s">Ändern</a></td>', - join(', ', $privileges_html), - page_link_to("admin_groups"), - $group['UID'] + + $groups_table[] = array( + 'name' => $group['Name'], + 'privileges' => join(', ', $privileges_html), + 'actions' => button(page_link_to('admin_groups') . '&action=edit&id=' . $group['UID'], _("edit"), 'btn-xs') ); } - - return template_render('../templates/admin_groups.html', array ( - 'nick' => User_Nick_render($user), - 'groups' => $groups_html + + return page_with_title(admin_groups_title(), array( + table(array( + 'name' => _("Name"), + 'privileges' => _("Privileges"), + 'actions' => '' + ), $groups_table) )); } else { switch ($_REQUEST["action"]) { - case 'edit' : - if (isset ($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) + case 'edit': + if (isset($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) $id = $_REQUEST['id']; else return error("Incomplete call, missing Groups ID.", true); - + $room = sql_select("SELECT * FROM `Groups` WHERE `UID`=" . sql_escape($id) . " LIMIT 1"); if (count($room) > 0) { - list ($room) = $room; + list($room) = $room; $privileges = sql_select("SELECT `Privileges`.*, `GroupPrivileges`.`group_id` FROM `Privileges` LEFT OUTER JOIN `GroupPrivileges` ON (`Privileges`.`id` = `GroupPrivileges`.`privilege_id` AND `GroupPrivileges`.`group_id`=" . sql_escape($id) . ") ORDER BY `Privileges`.`name`"); $privileges_html = ""; - foreach ($privileges as $priv) - $privileges_html .= sprintf( - '<tr><td><input type="checkbox" ' - . 'name="privileges[]" value="%s" %s />' - . '</td> <td>%s</td> <td>%s</td></tr>', - $priv['id'], - ($priv['group_id'] != "" - ? 'checked="checked"' - : ''), - $priv['name'], - $priv['desc'] - ); - - $html .= template_render('../templates/admin_groups_edit_form.html', array ( - 'link' => page_link_to("admin_groups"), - 'id' => $id, - 'privileges' => $privileges_html + $privileges_form = array(); + foreach ($privileges as $priv) { + $privileges_form[] = form_checkbox('privileges[]', $priv['desc'] . ' (' . $priv['name'] . ')', $priv['group_id'] != "", $priv['id']); + $privileges_html .= sprintf('<tr><td><input type="checkbox" ' . 'name="privileges[]" value="%s" %s />' . '</td> <td>%s</td> <td>%s</td></tr>', $priv['id'], ($priv['group_id'] != "" ? 'checked="checked"' : ''), $priv['name'], $priv['desc']); + } + + $privileges_form[] = form_submit('submit', _("Save")); + $html .= page_with_title(_("Edit group"), array( + form($privileges_form, page_link_to('admin_groups') . '&action=save&id=' . $id) )); } else return error("No Group found.", true); break; - - case 'save' : - if (isset ($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) + + case 'save': + if (isset($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) $id = $_REQUEST['id']; else return error("Incomplete call, missing Groups ID.", true); - + $room = sql_select("SELECT * FROM `Groups` WHERE `UID`=" . sql_escape($id) . " LIMIT 1"); - if (!is_array($_REQUEST['privileges'])) - $_REQUEST['privileges'] = array (); + if (! is_array($_REQUEST['privileges'])) + $_REQUEST['privileges'] = array(); if (count($room) > 0) { - list ($room) = $room; + list($room) = $room; sql_query("DELETE FROM `GroupPrivileges` WHERE `group_id`=" . sql_escape($id)); $privilege_names = array(); foreach ($_REQUEST['privileges'] as $priv) { if (preg_match("/^[0-9]{1,}$/", $priv)) { $group_privileges_source = sql_select("SELECT * FROM `Privileges` WHERE `id`=" . sql_escape($priv) . " LIMIT 1"); - if(count($group_privileges_source) > 0) { + if (count($group_privileges_source) > 0) { sql_query("INSERT INTO `GroupPrivileges` SET `group_id`=" . sql_escape($id) . ", `privilege_id`=" . sql_escape($priv)); $privilege_names[] = $group_privileges_source[0]['name']; } diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index 8bdde714..1b4b9970 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -20,24 +20,26 @@ function admin_questions() { global $user; if (! isset($_REQUEST['action'])) { - $open_questions = ""; + $unanswered_questions_table = array(); $questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL"); foreach ($questions as $question) { $user_source = User($question['UID']); 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']) - )); + $unanswered_questions_table[] = array( + 'from' => User_Nick_render($user_source), + 'question' => str_replace("\n", "<br />", $question['Question']), + 'answer' => form(array( + form_textarea('answer', _("Answer"), ''), + form_submit('submit', _("Save")) + ), page_link_to('admin_questions') . '&action=answer&id=' . $question['QID']), + 'actions' => button(page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'], _("delete"), 'btn-xs') + ); } - $answered_questions = ""; + $answered_questions_table = array(); $questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL"); - foreach ($questions as $question) { $user_source = User($question['UID']); if ($user_source === false) @@ -46,21 +48,31 @@ function admin_questions() { $answer_user_source = User($question['AID']); 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), + $answered_questions_table[] = array( + 'from' => User_Nick_render($user_source), 'question' => str_replace("\n", "<br />", $question['Question']), - 'answer_nick' => User_Nick_render($answer_user_source), + 'answered_by' => User_Nick_render($answer_user_source), 'answer' => str_replace("\n", "<br />", $question['Answer']), - 'link' => page_link_to("admin_questions") - )); + 'actions' => button(page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'], _("delete"), 'btn-xs') + ); } - return template_render('../templates/admin_questions.html', array( - 'link' => page_link_to("admin_questions"), - 'open_questions' => $open_questions, - 'answered_questions' => $answered_questions + return page_with_title(admin_questions_title(), array( + '<h2>' . _("Unanswered questions") . '</h2>', + table(array( + 'from' => _("From"), + 'question' => _("Question"), + 'answer' => _("Answer"), + 'actions' => '' + ), $unanswered_questions_table), + '<h2>' . _("Answered questions") . '</h2>', + table(array( + 'from' => _("From"), + 'question' => _("Question"), + 'answered_by' => _("Answered by"), + 'answer' => _("Answer"), + 'actions' => '' + ), $answered_questions_table) )); } else { switch ($_REQUEST['action']) { diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php index 7e3cc3b3..473022eb 100644 --- a/includes/pages/admin_shifts.php +++ b/includes/pages/admin_shifts.php @@ -189,15 +189,17 @@ function admin_shifts() { } while ($shift_end < $end); } - $shifts_table = ""; + $shifts_table = array(); foreach ($shifts as $shift) { - $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']; + $shifts_table_entry = array( + 'timeslot' => '<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']], + 'entries' => $shift['name'] + ); foreach ($types as $type) { 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_entry['entries'] .= '<br /><span class="icon-icon_angel"></span> <b>' . $type['name'] . ':</b> ' . $needed_angel_types[$type['id']] . ' missing'; } - $shifts_table .= '</td></tr>'; + $shifts_table[] = $shifts_table_entry; } // Fürs Anlegen zwischenspeichern: @@ -206,18 +208,25 @@ function admin_shifts() { $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 + $hidden_types .= form_hidden('type_' . $type_id, $count); + return page_with_title(_("Preview"), array( + form(array( + $hidden_types, + form_hidden('name', $name), + form_hidden('rid', $rid), + form_hidden('start', date("Y-m-d H:i", $start)), + form_hidden('end', date("Y-m-d H:i", $end)), + form_hidden('mode', $mode), + form_hidden('length', $length), + form_hidden('change_hours', implode(', ', $change_hours)), + form_hidden('angelmode', $angelmode), + form_submit('back', _("back")), + table(array( + 'timeslot' => _("Timeslot"), + 'entries' => _("Entries") + ), $shifts_table), + form_submit('submit', _("Save")) + )) )); } diff --git a/includes/pages/user_messages.php b/includes/pages/user_messages.php index b0ac66b1..d1c51d56 100644 --- a/includes/pages/user_messages.php +++ b/includes/pages/user_messages.php @@ -8,7 +8,8 @@ function user_unread_messages() { if (isset($user)) { $new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`=" . sql_escape($user['UID'])); - return '<span class="badge">' . $new_messages . '</span>'; + if ($new_messages > 0) + return '<span class="badge">' . $new_messages . '</span>'; } return ''; } @@ -28,7 +29,6 @@ function user_messages() { $to_select = html_select_key('to', 'to', $to_select_data, ''); - $messages_html = ""; $messages = sql_select("SELECT * FROM `Messages` WHERE `SUID`=" . sql_escape($user['UID']) . " OR `RUID`=" . sql_escape($user['UID']) . " ORDER BY `isRead`,`Datum` DESC"); foreach ($messages as $message) { $sender_user_source = User($message['SUID']); @@ -38,32 +38,43 @@ function user_messages() { if ($receiver_user_source === false) engelsystem_error(_("Unable to load user.")); - $messages_html .= sprintf('<tr %s> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td><td>%s</td>', ($message['isRead'] == 'N' ? ' class="new_message"' : ''), ($message['isRead'] == 'N' ? '•' : ''), date("Y-m-d H:i", $message['Datum']), User_Nick_render($sender_user_source), User_Nick_render($receiver_user_source), str_replace("\n", '<br />', $message['Text'])); + $messages_table_entry = array( + 'new' => $message['isRead'] == 'N' ? '<span class="glyphicon glyphicon-envelope"></span>' : '', + 'timestamp' => date("Y-m-d H:i", $message['Datum']), + 'from' => User_Nick_render($sender_user_source), + 'to' => User_Nick_render($receiver_user_source), + 'text' => str_replace("\n", '<br />', $message['Text']) + ); - $messages_html .= '<td>'; if ($message['RUID'] == $user['UID']) { if ($message['isRead'] == 'N') - $messages_html .= '<a href="' . page_link_to("user_messages") . '&action=read&id=' . $message['id'] . '">' . _("mark as read") . '</a>'; - } else { - $messages_html .= '<a href="' . page_link_to("user_messages") . '&action=delete&id=' . $message['id'] . '">' . _("delete message") . '</a>'; - } - $messages_html .= '</td></tr>'; + $messages_table_entry['actions'] = button(page_link_to("user_messages") . '&action=read&id=' . $message['id'], _("mark as read"), 'btn-xs'); + } else + $messages_table_entry['actions'] = button(page_link_to("user_messages") . '&action=delete&id=' . $message['id'], _("delete message"), 'btn-xs'); + $messages_table[] = $messages_table_entry; } - - return template_render('../templates/user_messages.html', array( - 'title' => messages_title(), - 'link' => page_link_to("user_messages"), - 'greeting' => msg() . sprintf(_("Hello %s, here can you leave messages for other angels"), User_Nick_render($user)) . '<br /><br />', - 'messages' => $messages_html, - 'new_label' => _("New"), - 'date_label' => _("Date"), - 'from_label' => _("Transmitted"), - 'to_label' => _("Recipient"), - 'text_label' => _("Message"), - 'date' => date("Y-m-d H:i"), + $messages_table[] = array( + 'news' => '', + 'timestamp' => date("Y-m-d H:i"), 'from' => User_Nick_render($user), - 'to_select' => $to_select, - 'submit_label' => _("Save") + 'to' => $to_select, + 'text' => form_textarea('text', _("Message"), ''), + 'actions' => form_submit('submit', _("Save")) + ); + + return page_with_title(messages_title(), array( + msg(), + sprintf(_("Hello %s, here can you leave messages for other angels"), User_Nick_render($user)), + form(array( + table(array( + 'new' => _("New"), + 'timestamp' => _("Date"), + 'from' => _("Transmitted"), + 'to' => _("Recipient"), + 'text' => _("Message"), + 'actions' => '' + ), $messages_table) + ), page_link_to('user_messages') . '&action=send') )); } else { switch ($_REQUEST['action']) { diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index 333f9517..3a3f6712 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -23,7 +23,10 @@ function user_myshifts() { success(_("Key changed.")); redirect(page_link_to('user_myshifts')); } - return template_render('../templates/user_myshifts_reset.html', array()); + return page_with_title(_("Reset API key"), array( + error(_("If you reset the key, the url to your iCal- and JSON-export and your atom feed changes! You have to update it in every application using one of these exports."), true), + button(page_link_to('myshifts') . '&reset=ack', _("Continue"), 'btn-danger') + )); } elseif (isset($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) { $id = $_REQUEST['edit']; $shift = sql_select("SELECT diff --git a/includes/pages/user_wakeup.php b/includes/pages/user_wakeup.php deleted file mode 100644 index 4ac5c0b7..00000000 --- a/includes/pages/user_wakeup.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -function wakeup_title() { - return _("Wakeup"); -} - -function user_wakeup() { - global $user; - - $html = ""; - - if (isset ($_REQUEST['action'])) { - switch ($_REQUEST['action']) { - case 'create' : - $date = DateTime::createFromFormat("Y-m-d H:i", $_REQUEST['Date']); - if ($date != null) { - $date = $date->getTimestamp(); - $bemerkung = strip_request_item_nl('Bemerkung'); - $ort = strip_request_item('Ort'); - $SQL = "INSERT INTO `Wecken` (`UID`, `Date`, `Ort`, `Bemerkung`) " - . "VALUES ('" . sql_escape($user['UID']) . "', '" - . sql_escape($date) . "', '" . sql_escape($ort) . "', " . "'" - . sql_escape($bemerkung) . "')"; - sql_query($SQL); - $html .= success(_("Entry saved."), true); - } else - $html .= error(_("Broken date!"), 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 wake-up ID."), true); - - $wakeup = sql_select("SELECT * FROM `Wecken` WHERE `ID`=" . sql_escape($id) . " LIMIT 1"); - if (count($wakeup) > 0 && $wakeup[0]['UID'] == $user['UID']) { - sql_query("DELETE FROM `Wecken` WHERE `ID`=" . sql_escape($id) . " LIMIT 1"); - $html .= success(_("Wake-up call deleted."), true); - } else - return error(_("No wake-up found."), true); - break; - } - } - - $html .= '<p>' . sprintf(_("Hello %s, here you can register for a wake-up call. Simply say when and where the angel should come to wake you."), User_Nick_render($user)) . '</p>'; - $html .= _("All ordered wake-up calls, next first."); - $html .= ' - <table border="0" width="100%" class="border" cellpadding="2" cellspacing="1"> - <tr class="contenttopic"> - <th>' . _("Date") . '</th> - <th>' . _("Nick") . '</th> - <th>' . _("Place") . '</th> - <th>' . _("Notes") . '</th> - <th></th> - </tr> - '; - - $wecken_source = sql_select("SELECT * FROM `Wecken` ORDER BY `Date` ASC"); - foreach($wecken_source as $wecken) { - $html .= '<tr class="content">'; - $html .= '<td>' . date("Y-m-d H:i", $wecken['Date']) . ' </td>'; - - $user_source = User($wecken['UID']); - if($user_source === false) - engelsystem_error("Unable to load user."); - - $html .= '<td>' . User_Nick_render($user_source) . ' </td>'; - $html .= '<td>' . $wecken['Ort'] . ' </td>'; - $html .= '<td>' . $wecken['Bemerkung'] . ' </td>'; - if ($wecken['UID'] == $user['UID']) - $html .= '<td><a href="' . page_link_to("user_wakeup") . '&action=delete&id=' . $wecken['ID'] . "\">" . _("delete") . '</a></td>'; - else - $html .= '<td></td>'; - $html .= '</tr>'; - } - - $html .= '</table><hr />' . _("Schedule a new wake-up here:"); - - $html .= template_render('../templates/user_wakeup.html', array ( - 'wakeup_link' => page_link_to("user_wakeup"), - 'date_text' => _("Date"), - 'date_value' => date("Y-m-d H:i"), - 'place_text' => _("Place"), - 'comment_text' => _("Notes"), - 'comment_value' => "Knock knock Leo, follow the white rabbit to the blue tent", - 'submit_text' => _("Save") - )); - return $html; -} -?> |