diff options
author | Bot <bot@myigel.name> | 2017-01-03 03:22:48 +0100 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2017-01-03 03:22:48 +0100 |
commit | 356b2582f3e6a43ecf2607acad4a7fe0b37f659a (patch) | |
tree | e02c9214b23a0b9ec33aa725db962d565bd30a82 /includes/pages | |
parent | d71e7bbfad2f07f82df0c515608996d250fd4182 (diff) |
PPHDoc, formatting, fixes, cleanup
Diffstat (limited to 'includes/pages')
-rw-r--r-- | includes/pages/admin_active.php | 13 | ||||
-rw-r--r-- | includes/pages/admin_arrive.php | 8 | ||||
-rw-r--r-- | includes/pages/admin_free.php | 6 | ||||
-rw-r--r-- | includes/pages/admin_groups.php | 7 | ||||
-rw-r--r-- | includes/pages/admin_import.php | 31 | ||||
-rw-r--r-- | includes/pages/admin_log.php | 6 | ||||
-rw-r--r-- | includes/pages/admin_news.php | 12 | ||||
-rw-r--r-- | includes/pages/admin_questions.php | 10 | ||||
-rw-r--r-- | includes/pages/admin_rooms.php | 9 | ||||
-rw-r--r-- | includes/pages/admin_shifts.php | 17 | ||||
-rw-r--r-- | includes/pages/admin_user.php | 13 | ||||
-rw-r--r-- | includes/pages/guest_credits.php | 7 | ||||
-rw-r--r-- | includes/pages/guest_login.php | 18 | ||||
-rw-r--r-- | includes/pages/guest_start.php | 1 | ||||
-rw-r--r-- | includes/pages/user_atom.php | 18 | ||||
-rw-r--r-- | includes/pages/user_ical.php | 3 | ||||
-rw-r--r-- | includes/pages/user_messages.php | 11 | ||||
-rw-r--r-- | includes/pages/user_myshifts.php | 14 | ||||
-rw-r--r-- | includes/pages/user_news.php | 73 | ||||
-rw-r--r-- | includes/pages/user_questions.php | 8 | ||||
-rw-r--r-- | includes/pages/user_settings.php | 28 | ||||
-rw-r--r-- | includes/pages/user_shifts.php | 41 |
22 files changed, 295 insertions, 59 deletions
diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index 38edbfdb..34b9eb14 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -1,10 +1,16 @@ <?php +/** + * @return string + */ function admin_active_title() { return _("Active angels"); } +/** + * @return string + */ function admin_active() { global $tshirt_sizes, $shift_sum_formula; @@ -110,7 +116,10 @@ function admin_active() } $users = sql_select(" - SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, ${shift_sum_formula} as `shift_length` + SELECT + `User`.*, + COUNT(`ShiftEntry`.`id`) AS `shift_count`, + ${shift_sum_formula} AS `shift_length` FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` " . ($show_all_shifts ? "" : "AND (`Shifts`.`end` < " . time() . " OR `Shifts`.`end` IS NULL)") . " WHERE `User`.`Gekommen` = 1 @@ -186,7 +195,7 @@ function admin_active() form_text('count', _("How much angels should be active?"), $count), form_submit('set_active', _("Preview")) ]) : $set_active, - msg(), + $msg . msg(), table([ 'nick' => _("Nickname"), 'shirt_size' => _("Size"), diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php index cd910bd0..d0ed4ffc 100644 --- a/includes/pages/admin_arrive.php +++ b/includes/pages/admin_arrive.php @@ -1,10 +1,16 @@ <?php +/** + * @return string + */ function admin_arrive_title() { return _("Arrived angels"); } +/** + * @return string + */ function admin_arrive() { $msg = ""; @@ -138,7 +144,7 @@ function admin_arrive() } return page_with_title(admin_arrive_title(), [ - msg(), + $msg . msg(), form([ form_text('search', _("Search"), $search), form_submit('submit', _("Search")) diff --git a/includes/pages/admin_free.php b/includes/pages/admin_free.php index 947dd93b..7d11c3a3 100644 --- a/includes/pages/admin_free.php +++ b/includes/pages/admin_free.php @@ -1,10 +1,16 @@ <?php +/** + * @return string + */ function admin_free_title() { return _("Free angels"); } +/** + * @return string + */ function admin_free() { global $privileges; diff --git a/includes/pages/admin_groups.php b/includes/pages/admin_groups.php index d170c374..7b97ca30 100644 --- a/includes/pages/admin_groups.php +++ b/includes/pages/admin_groups.php @@ -1,10 +1,16 @@ <?php +/** + * @return string + */ function admin_groups_title() { return _("Grouprights"); } +/** + * @return string + */ function admin_groups() { $html = ""; @@ -53,7 +59,6 @@ function admin_groups() $group = sql_select("SELECT * FROM `Groups` WHERE `UID`='" . sql_escape($group_id) . "' LIMIT 1"); if (count($group) > 0) { - list($group) = $group; $privileges = sql_select(" SELECT `Privileges`.*, `GroupPrivileges`.`group_id` FROM `Privileges` diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php index 46c13ac7..bef2b86e 100644 --- a/includes/pages/admin_import.php +++ b/includes/pages/admin_import.php @@ -1,10 +1,16 @@ <?php +/** + * @return string + */ function admin_import_title() { return _("Frab import"); } +/** + * @return string + */ function admin_import() { global $rooms_import; @@ -290,6 +296,10 @@ function admin_import() ]); } +/** + * @param string $file + * @return array + */ function prepare_rooms($file) { global $rooms_import; @@ -323,6 +333,13 @@ function prepare_rooms($file) ]; } +/** + * @param string $file + * @param int $shifttype_id + * @param int $add_minutes_start + * @param int $add_minutes_end + * @return array + */ function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_end) { global $rooms_import; @@ -384,6 +401,10 @@ function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_e ]; } +/** + * @param string $file + * @return SimpleXMLElement + */ function read_xml($file) { global $xml_import; @@ -393,6 +414,11 @@ function read_xml($file) return $xml_import; } +/** + * @param array $shifts + * @param array $shifttypes + * @return array + */ function shifts_printable($shifts, $shifttypes) { global $rooms_import; @@ -417,6 +443,11 @@ function shifts_printable($shifts, $shifttypes) return $shifts_printable; } +/** + * @param array $shift_a + * @param array $shift_b + * @return int + */ function shift_sort($shift_a, $shift_b) { return ($shift_a['start'] < $shift_b['start']) ? -1 : 1; diff --git a/includes/pages/admin_log.php b/includes/pages/admin_log.php index fc07cc87..8a0b91ec 100644 --- a/includes/pages/admin_log.php +++ b/includes/pages/admin_log.php @@ -1,10 +1,16 @@ <?php +/** + * @return string + */ function admin_log_title() { return _("Log"); } +/** + * @return string + */ function admin_log() { $filter = ""; diff --git a/includes/pages/admin_news.php b/includes/pages/admin_news.php index 1a35f04a..68a1dbae 100644 --- a/includes/pages/admin_news.php +++ b/includes/pages/admin_news.php @@ -1,5 +1,8 @@ <?php +/** + * @return string + */ function admin_news() { global $user; @@ -19,12 +22,10 @@ function admin_news() if (empty($news)) { return error("No News found.", true); } + switch ($_REQUEST["action"]) { - default: - redirect(page_link_to('news')); case 'edit': list($news) = $news; - $user_source = User($news['UID']); $html .= form([ @@ -42,8 +43,6 @@ function admin_news() break; case 'save': - list($news) = $news; - sql_query("UPDATE `News` SET `Datum`='" . sql_escape(time()) . "', `Betreff`='" . sql_escape($_POST["eBetreff"]) . "', @@ -58,12 +57,13 @@ function admin_news() case 'delete': list($news) = $news; - sql_query("DELETE FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1"); engelsystem_log("News deleted: " . $news['Betreff']); success(_("News entry deleted.")); redirect(page_link_to("news")); break; + default: + redirect(page_link_to('news')); } return $html . '</div>'; } diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index c65280d5..032b010e 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -1,5 +1,8 @@ <?php +/** + * @return string + */ function admin_questions_title() { return _("Answer questions"); @@ -7,6 +10,8 @@ function admin_questions_title() /** * Renders a hint for new questions to answer. + * + * @return string|null */ function admin_new_questions() { @@ -25,6 +30,9 @@ function admin_new_questions() return null; } +/** + * @return string + */ function admin_questions() { global $user; @@ -136,4 +144,6 @@ function admin_questions() break; } } + + return ''; } diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php index 9a596f15..9bd60bcc 100644 --- a/includes/pages/admin_rooms.php +++ b/includes/pages/admin_rooms.php @@ -1,10 +1,16 @@ <?php +/** + * @return string + */ function admin_rooms_title() { return _("Rooms"); } +/** + * @return string + */ function admin_rooms() { $rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`"); @@ -28,6 +34,7 @@ function admin_rooms() $from_pentabarf = ""; $public = 'Y'; $number = ""; + $room_id = 0; $angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`"); $angeltypes = []; @@ -99,7 +106,7 @@ function admin_rooms() $angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id]; } else { $valid = false; - $msg .= error(sprintf(_("Please enter needed angels for type %s.", $angeltype)), true); + $msg .= error(sprintf(_("Please enter needed angels for type %s."), $angeltype), true); } } diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php index b2a67786..d3bcea53 100644 --- a/includes/pages/admin_shifts.php +++ b/includes/pages/admin_shifts.php @@ -1,16 +1,22 @@ <?php +/** + * @return string + */ function admin_shifts_title() { return _("Create shifts"); } -// Assistent zum Anlegen mehrerer neuer Schichten +/** + * Assistent zum Anlegen mehrerer neuer Schichten + * + * @return string + */ function admin_shifts() { $valid = true; - $rid = 0; $start = parse_date("Y-m-d H:i", date("Y-m-d") . " 00:00"); $end = $start; $mode = 'single'; @@ -177,9 +183,9 @@ function admin_shifts() 'shifttype_id' => $shifttype_id ]; } elseif ($mode == 'multi') { - $shift_start = $start; + $shift_start = (int)$start; do { - $shift_end = $shift_start + $length * 60; + $shift_end = $shift_start + (int)$length * 60; if ($shift_end > $end) { $shift_end = $end; @@ -298,6 +304,7 @@ function admin_shifts() redirect(page_link_to('admin_shifts')); } + $needed_angel_types_info = []; foreach ($_SESSION['admin_shifts_shifts'] as $shift) { $shift['URL'] = null; $shift['PSID'] = null; @@ -312,7 +319,7 @@ function admin_shifts() . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']) ); - $needed_angel_types_info = []; + 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) { diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 12d92720..c6ce628f 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -1,13 +1,19 @@ <?php +/** + * @return string + */ function admin_user_title() { return _("All Angels"); } +/** + * @return string + */ function admin_user() { - global $user, $privileges, $tshirt_sizes, $privileges; + global $user, $tshirt_sizes, $privileges; $html = ''; @@ -109,7 +115,7 @@ function admin_user() $groups = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($user_id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group) . "' ORDER BY `Groups`.`Name`"); foreach ($groups as $group) { - $html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group['UID'] . '"' . ($group['group_id'] != "" ? ' checked="checked"' : '') . ' /></td><td>' . $group['Name'] . '</td></tr>'; + $html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group['UID'] . '" ' . ($group['group_id'] != "" ? ' checked="checked"' : '') . ' /></td><td>' . $group['Name'] . '</td></tr>'; } $html .= '</table>'; @@ -167,6 +173,7 @@ function admin_user() case 'save': $force_active = $user['force_active']; + $user_source = User($user_id); if (in_array('admin_active', $privileges)) { $force_active = $_REQUEST['force_active']; } @@ -178,7 +185,7 @@ function admin_user() `Handy` = '" . sql_escape($_POST["eHandy"]) . "', `Alter` = '" . sql_escape($_POST["eAlter"]) . "', `DECT` = '" . sql_escape($_POST["eDECT"]) . "', - " . ($user_source['email_by_human_allowed'] ? "`email` = '" . sql_escape($_POST["eemail"]) . "'" : "") . " + " . ($user_source['email_by_human_allowed'] ? "`email` = '" . sql_escape($_POST["eemail"]) . "'," : "") . " `jabber` = '" . sql_escape($_POST["ejabber"]) . "', `Size` = '" . sql_escape($_POST["eSize"]) . "', `Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "', diff --git a/includes/pages/guest_credits.php b/includes/pages/guest_credits.php index 00b12f73..2e652b6f 100644 --- a/includes/pages/guest_credits.php +++ b/includes/pages/guest_credits.php @@ -1,9 +1,16 @@ <?php + +/** + * @return string + */ function credits_title() { return _("Credits"); } +/** + * @return string + */ function guest_credits() { return template_render(__DIR__ . '/../../templates/guest_credits.html', []); diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 482b7670..258532ee 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -1,21 +1,34 @@ <?php +/** + * @return string + */ function login_title() { return _("Login"); } +/** + * @return string + */ function register_title() { return _("Register"); } +/** + * @return string + */ function logout_title() { return _("Logout"); } -// Engel registrieren +/** + * Engel registrieren + * + * @return string + */ function guest_register() { global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user, $min_password_length; @@ -335,6 +348,7 @@ function guest_logout() { session_destroy(); redirect(page_link_to("start")); + return true; } function guest_login() @@ -368,7 +382,7 @@ function guest_login() error(_("Please enter a nickname.")); } - if ($valid) { + if ($valid && !empty($login_user)) { $_SESSION['uid'] = $login_user['UID']; $_SESSION['locale'] = $login_user['Sprache']; diff --git a/includes/pages/guest_start.php b/includes/pages/guest_start.php index c89f680e..4cd2fa42 100644 --- a/includes/pages/guest_start.php +++ b/includes/pages/guest_start.php @@ -2,4 +2,5 @@ function guest_start() { redirect(page_link_to('login')); + return true; } diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php index ee4ddae5..42217a3a 100644 --- a/includes/pages/user_atom.php +++ b/includes/pages/user_atom.php @@ -1,9 +1,11 @@ <?php -// publically available page to feed the news to feedreaders +/** + * Publically available page to feed the news to feedreaders + */ function user_atom() { - global $user, $DISPLAY_NEWS; + global $user, $display_news; if (!isset($_REQUEST['key']) || !preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) { engelsystem_error("Missing key."); @@ -18,7 +20,13 @@ function user_atom() engelsystem_error("No privilege for atom."); } - $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 " . (int)$display_news + ); $output = make_atom_entries_from_news($news); @@ -27,6 +35,10 @@ function user_atom() raw_output($output); } +/** + * @param array[] $news_entries + * @return string + */ function make_atom_entries_from_news($news_entries) { $html = '<?xml version="1.0" encoding="utf-8"?> diff --git a/includes/pages/user_ical.php b/includes/pages/user_ical.php index 05c67d51..929dc7c7 100644 --- a/includes/pages/user_ical.php +++ b/includes/pages/user_ical.php @@ -47,7 +47,8 @@ function send_ical_from_shifts($shifts) /** * Renders an ical vevent from given shift. * - * @param Shift $shift + * @param array $shift + * @return string */ function make_ical_entry_from_shift($shift) { diff --git a/includes/pages/user_messages.php b/includes/pages/user_messages.php index b7ff093f..5e8c2491 100644 --- a/includes/pages/user_messages.php +++ b/includes/pages/user_messages.php @@ -1,10 +1,16 @@ <?php +/** + * @return string + */ function messages_title() { return _("Messages"); } +/** + * @return string + */ function user_unread_messages() { global $user; @@ -18,6 +24,9 @@ function user_unread_messages() return ''; } +/** + * @return string + */ function user_messages() { global $user; @@ -138,4 +147,6 @@ function user_messages() return error(_("Wrong action."), true); } } + + return ''; } diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index 8c2d9442..f9050cdd 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -1,14 +1,21 @@ <?php +/** + * @return string + */ function myshifts_title() { return _("My shifts"); } -// Zeigt die Schichten an, die ein Benutzer belegt +/** + * Zeigt die Schichten an, die ein Benutzer belegt + * + * @return string + */ function user_myshifts() { - global $LETZTES_AUSTRAGEN; + global $last_unsubscribe; global $user, $privileges; if ( @@ -120,7 +127,7 @@ function user_myshifts() WHERE `ShiftEntry`.`id`='" . sql_escape($user_id) . "' AND `UID`='" . sql_escape($shifts_user['UID']) . "'"); if (count($shift) > 0) { $shift = $shift[0]; - if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) { + if (($shift['start'] > time() + $last_unsubscribe * 3600) || in_array('user_shifts_admin', $privileges)) { $result = ShiftEntry_delete($user_id); if ($result === false) { engelsystem_error('Unable to delete shift entry.'); @@ -146,4 +153,5 @@ function user_myshifts() } redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']); + return ''; } diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php index 31f38eaa..01da8d27 100644 --- a/includes/pages/user_news.php +++ b/includes/pages/user_news.php @@ -1,23 +1,35 @@ <?php +/** + * @return string + */ function user_news_comments_title() { return _("News comments"); } +/** + * @return string + */ function news_title() { return _("News"); } +/** + * @return string + */ function meetings_title() { return _("Meetings"); } +/** + * @return string + */ function user_meetings() { - global $DISPLAY_NEWS; + global $display_news; $html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg(); @@ -27,12 +39,18 @@ function user_meetings() $page = 0; } - $news = sql_select("SELECT * FROM `News` WHERE `Treffen`=1 ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS)); + $news = sql_select(" + SELECT * + FROM `News` + WHERE `Treffen`=1 + ORDER BY `Datum`DESC + LIMIT " . sql_escape($page * $display_news) . ", " . sql_escape($display_news) + ); foreach ($news as $entry) { $html .= display_news($entry); } - $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); + $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']) { @@ -49,6 +67,10 @@ function user_meetings() return $html; } +/** + * @param array $news + * @return string + */ function display_news($news) { global $privileges, $page; @@ -72,13 +94,21 @@ function display_news($news) $html .= User_Nick_render($user_source); if ($page != "news_comments") { - $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 .= ' <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; } +/** + * @return string + */ function user_news_comments() { global $user; @@ -93,7 +123,15 @@ function user_news_comments() 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"]) . "')"); + 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); } @@ -125,9 +163,12 @@ function user_news_comments() return $html . '</div>'; } +/** + * @return string + */ function user_news() { - global $DISPLAY_NEWS, $privileges, $user; + global $display_news, $privileges, $user; $html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg(); @@ -135,7 +176,16 @@ function user_news() 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')); @@ -147,12 +197,17 @@ function user_news() $page = 0; } - $news = sql_select("SELECT * FROM `News` ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS)); + $news = sql_select(" + SELECT * + FROM `News` + ORDER BY `Datum` + DESC LIMIT " . sql_escape($page * $display_news) . ", " . sql_escape($display_news) + ); foreach ($news as $entry) { $html .= display_news($entry); } - $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); + $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']) { diff --git a/includes/pages/user_questions.php b/includes/pages/user_questions.php index d1a90292..fa66e8db 100644 --- a/includes/pages/user_questions.php +++ b/includes/pages/user_questions.php @@ -1,10 +1,16 @@ <?php +/** + * @return string + */ function questions_title() { return _("Ask the Heaven"); } +/** + * @return string + */ function user_questions() { global $user; @@ -62,4 +68,6 @@ function user_questions() break; } } + + return ''; } diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index 831936c4..fe9bb215 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -1,5 +1,8 @@ <?php +/** + * @return string + */ function settings_title() { return _("Settings"); @@ -8,8 +11,10 @@ function settings_title() /** * Change user main attributes (name, dates, etc.) * - * @param User $user_source - * The user + * @param array $user_source The user + * @param bool $enable_tshirt_size + * @param array $tshirt_sizes + * @return array */ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) { @@ -86,8 +91,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) /** * Change user password. * - * @param User $user_source - * The user + * @param array $user_source The user */ function user_settings_password($user_source) { @@ -112,10 +116,9 @@ function user_settings_password($user_source) /** * Change user theme * - * @param User $user_sources - * The user - * @param array <String> $themes - * List of available themes + * @param array $user_source The user + * @param array $themes List of available themes + * @return mixed */ function user_settings_theme($user_source, $themes) { @@ -140,10 +143,9 @@ function user_settings_theme($user_source, $themes) /** * Change use locale * - * @param User $user_source - * The user - * @param array <String> $locales - * List of available locales + * @param array $user_source The user + * @param array $locales List of available locales + * @return array */ function user_settings_locale($user_source, $locales) { @@ -168,6 +170,8 @@ function user_settings_locale($user_source, $locales) /** * Main user settings page/controller + * + * @return string */ function user_settings() { diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index e325989c..405b36ab 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -1,6 +1,9 @@ <?php use Engelsystem\ShiftsFilter; +/** + * @return string + */ function shifts_title() { return _("Shifts"); @@ -12,6 +15,8 @@ function shifts_title() * Transform into shift controller and shift entry controller. * Split actions into shift edit, shift delete, shift entry edit, shift entry delete * Introduce simpler and beautiful actions for shift entry join/leave for users + * + * @return string */ function user_shifts() { @@ -23,7 +28,8 @@ function user_shifts() // Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins if (isset($_REQUEST['entry_id'])) { - return shift_entry_delete_controller(); + shift_entry_delete_controller(); + return ''; } elseif (isset($_REQUEST['edit_shift'])) { return shift_edit_controller(); } elseif (isset($_REQUEST['delete_shift'])) { @@ -38,8 +44,8 @@ function user_shifts() * Helper function that updates the start and end time from request data. * Use update_ShiftsFilter(). * - * @param ShiftsFilter $shiftsFilter - * The shiftfilter to update. + * @param ShiftsFilter $shiftsFilter The shiftfilter to update. + * @param string[] $days */ function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days) { @@ -80,16 +86,22 @@ function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $da update_ShiftsFilter_timerange($shiftsFilter, $days); } +/** + * @return array + */ function load_rooms() { $rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`"); - if (count($rooms) == 0) { + if (!$rooms || count($rooms) == 0) { error(_("The administration has not configured any rooms yet.")); redirect('?'); } return $rooms; } +/** + * @return array + */ function load_days() { $days = sql_select_single_col(" @@ -103,6 +115,9 @@ function load_days() return $days; } +/** + * @return array|false + */ function load_types() { global $user; @@ -136,10 +151,12 @@ function load_types() return $types; } +/** + * @return string + */ function view_user_shifts() { - global $user, $privileges; - global $ical_shifts; + global $user, $privileges, $ical_shifts; $ical_shifts = []; $days = load_days(); @@ -197,9 +214,9 @@ function view_user_shifts() 'task_notice' => '<sup>1</sup>' . _("The tasks shown here are influenced by the angeltypes you joined already!") - . " <a href=\"" . page_link_to('angeltypes') . '&action=about' . "\">" + . ' <a href="' . page_link_to('angeltypes') . '&action=about' . '">' . _("Description of the jobs.") - . "</a>", + . '</a>', 'shifts_table' => msg() . $shiftCalendarRenderer->render(), '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>)."), @@ -213,6 +230,10 @@ function view_user_shifts() ]); } +/** + * @param array $array + * @return array + */ function get_ids_from_array($array) { return $array["id"]; @@ -227,9 +248,9 @@ function make_select($items, $selected, $name, $title = null) foreach ($items as $i) { $html_items[] = '<div class="checkbox">' - . '<label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"' + . '<label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '" ' . (in_array($i['id'], $selected) ? ' checked="checked"' : '') - . '> ' . $i['name'] . '</label>' + . ' > ' . $i['name'] . '</label>' . (!isset($i['enabled']) || $i['enabled'] ? '' : glyph("lock")) . '</div><br />'; } |