From 952c7892f3ac7bfadf8419062e44ff1af66ecc57 Mon Sep 17 00:00:00 2001 From: Bot Date: Mon, 25 Dec 2017 23:12:52 +0100 Subject: Formatting & Docstrings --- includes/pages/admin_active.php | 3 ++- includes/pages/admin_groups.php | 6 +++++- includes/pages/admin_import.php | 20 ++++++++++++++------ includes/pages/admin_questions.php | 4 +++- includes/pages/admin_rooms.php | 37 ++++++++++++++++++++++++------------- includes/pages/admin_shifts.php | 36 +++++++++++++++++++++++++++++------- includes/pages/admin_user.php | 17 +++++++++++++---- includes/pages/guest_login.php | 3 +-- includes/pages/guest_stats.php | 6 +++++- includes/pages/user_atom.php | 10 +++++++++- includes/pages/user_ical.php | 2 +- includes/pages/user_news.php | 17 +++++++++++++---- includes/pages/user_settings.php | 4 ++-- includes/pages/user_shifts.php | 35 +++++++++++++++++++++++++++++------ 14 files changed, 150 insertions(+), 50 deletions(-) (limited to 'includes/pages') diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index 0612202f..576cdc49 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -173,7 +173,8 @@ function admin_active() } $usr['nick'] = User_Nick_render($usr); $usr['shirt_size'] = $tshirt_sizes[$usr['Size']]; - $usr['work_time'] = round($usr['shift_length'] / 60) . ' min (' . round($usr['shift_length'] / 3600) . ' h)'; + $usr['work_time'] = round($usr['shift_length'] / 60) + . ' min (' . round($usr['shift_length'] / 3600) . ' h)'; $usr['active'] = glyph_bool($usr['Aktiv'] == 1); $usr['force_active'] = glyph_bool($usr['force_active'] == 1); $usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1); diff --git a/includes/pages/admin_groups.php b/includes/pages/admin_groups.php index e0260320..92b6a3ea 100644 --- a/includes/pages/admin_groups.php +++ b/includes/pages/admin_groups.php @@ -85,7 +85,11 @@ function admin_groups() 'privilege-' . $privilege['name'] ); $privileges_html .= sprintf( - ' %s %s', + '' + . '' + . '%s' + . '%s' + . '', $privilege['id'], ($privilege['group_id'] != '' ? 'checked="checked"' : ''), $privilege['name'], diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php index 4b0f35de..3688259b 100644 --- a/includes/pages/admin_import.php +++ b/includes/pages/admin_import.php @@ -34,7 +34,7 @@ function admin_import() $test_handle = @fopen($import_dir . '/tmp', 'w'); fclose($test_handle); @unlink($import_dir . '/tmp'); - } catch(Exception $e) { + } catch (Exception $e) { error(_('Webserver has no write-permission on import directory.')); } @@ -63,8 +63,9 @@ function admin_import() error(_('Please select a shift type.')); } - if ($request->has('add_minutes_start') && is_numeric(trim($request->input('add_minutes_start')))) { - $add_minutes_start = trim($request->input('add_minutes_start')); + $minutes_start = trim($request->input('add_minutes_start')); + if ($request->has('add_minutes_start') && is_numeric($minutes_start)) { + $add_minutes_start = $minutes_start; } else { $valid = false; error(_('Please enter an amount of minutes to add to a talk\'s begin.')); @@ -106,7 +107,11 @@ function admin_import() ); } else { $html .= div('well well-sm text-center', [ - _('File Upload') . mute(glyph('arrow-right')) . mute(_('Validation')) . mute(glyph('arrow-right')) . mute(_('Import')) + _('File Upload') + . mute(glyph('arrow-right')) + . mute(_('Validation')) + . mute(glyph('arrow-right')) + . mute(_('Import')) ]) . div('row', [ div('col-md-offset-3 col-md-6', [ form([ @@ -164,7 +169,10 @@ function admin_import() 'well well-sm text-center', [ '' . _('File Upload') . glyph('ok-circle') . '' - . mute(glyph('arrow-right')) . _('Validation') . mute(glyph('arrow-right')) . mute(_('Import')) + . mute(glyph('arrow-right')) + . _('Validation') + . mute(glyph('arrow-right')) + . mute(_('Import')) ] ) . form( @@ -315,7 +323,7 @@ function prepare_rooms($file) // Contains all rooms from db and frab $rooms_import = []; foreach ($rooms as $room) { - if($room['from_frab']) { + if ($room['from_frab']) { $rooms_db[] = $room['Name']; } $rooms_db_all[] = $room['Name']; diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index 5f2e3a2b..0636a1d9 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -24,7 +24,9 @@ function admin_new_questions() $new_messages = count(DB::select('SELECT `QID` FROM `Questions` WHERE `AID` IS NULL')); if ($new_messages > 0) { - return '' . _('There are unanswered questions!') . ''; + return '' + . _('There are unanswered questions!') + . ''; } } } diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php index b1db9509..8144b328 100644 --- a/includes/pages/admin_rooms.php +++ b/includes/pages/admin_rooms.php @@ -18,17 +18,25 @@ function admin_rooms() foreach ($rooms_source as $room) { $rooms[] = [ - 'name' => Room_name_render($room), + 'name' => Room_name_render($room), 'from_frab' => glyph_bool($room['from_frab']), - 'map_url' => glyph_bool(!empty($room['map_url'])), - 'actions' => table_buttons([ - button(page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]), _('edit'), 'btn-xs'), - button(page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room['RID']]), _('delete'), 'btn-xs') + 'map_url' => glyph_bool(!empty($room['map_url'])), + 'actions' => table_buttons([ + button( + page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]), + _('edit'), + 'btn-xs' + ), + button( + page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room['RID']]), + _('delete'), + 'btn-xs' + ) ]) ]; } - $room = null; + $room = null; if ($request->has('show')) { $msg = ''; $name = ''; @@ -69,7 +77,7 @@ function admin_rooms() if ($request->has('name') && strlen(strip_request_item('name')) > 0) { $result = Room_validate_name(strip_request_item('name'), $room_id); - if(!$result->isValid()) { + if (!$result->isValid()) { $valid = false; $msg .= error(_('This name is already in use.'), true); } else { @@ -87,7 +95,7 @@ function admin_rooms() } if ($request->has('description')) { - $description= strip_request_item_nl('description'); + $description = strip_request_item_nl('description'); } foreach ($angeltypes as $angeltype_id => $angeltype) { @@ -101,7 +109,10 @@ function admin_rooms() $angeltypes_count[$angeltype_id] = $request->input($queryKey); } 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); } } @@ -118,7 +129,7 @@ function admin_rooms() $angeltype = AngelType($angeltype_id); if ($angeltype != null) { NeededAngelType_add(null, $angeltype_id, $room_id, $angeltype_count); - if($angeltype_count > 0) { + if ($angeltype_count > 0) { $needed_angeltype_info[] = $angeltype['name'] . ': ' . $angeltype_count; } } @@ -197,10 +208,10 @@ function admin_rooms() ]), msg(), table([ - 'name' => _('Name'), + 'name' => _('Name'), 'from_frab' => _('Frab import'), - 'map_url' => _('Map'), - 'actions' => '' + 'map_url' => _('Map'), + 'actions' => '' ], $rooms) ]); } diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php index 22ce7635..c80603a1 100644 --- a/includes/pages/admin_shifts.php +++ b/includes/pages/admin_shifts.php @@ -113,10 +113,16 @@ function admin_shifts() } elseif ($request->input('mode') == 'variable') { if ( $request->has('change_hours') - && preg_match('/^(\d{2}(,|$))/', trim(str_replace(' ', '', $request->input('change_hours')))) + && preg_match( + '/^(\d{2}(,|$))/', + trim(str_replace(' ', '', $request->input('change_hours'))) + ) ) { $mode = 'variable'; - $change_hours = array_map('trim', explode(',', $request->input('change_hours'))); + $change_hours = array_map( + 'trim', + explode(',', $request->input('change_hours')) + ); } else { $valid = false; error(_('Please split the shift-change hours by colons.')); @@ -264,7 +270,8 @@ function admin_shifts() ]; foreach ($types as $type) { if (isset($needed_angel_types[$type['id']]) && $needed_angel_types[$type['id']] > 0) { - $shifts_table_entry['needed_angels'] .= '' . AngelType_name_render($type) . ': ' . $needed_angel_types[$type['id']] . '
'; + $shifts_table_entry['needed_angels'] .= '' . AngelType_name_render($type) . ': ' + . $needed_angel_types[$type['id']] . '
'; } } $shifts_table[] = $shifts_table_entry; @@ -327,6 +334,7 @@ function admin_shifts() FROM `AngelTypes` WHERE `id` = ? LIMIT 1', [$type_id]); + if (!empty($angel_type_source)) { DB::insert(' INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`) @@ -338,7 +346,8 @@ function admin_shifts() $count ] ); - if($count > 0) { + + if ($count > 0) { $needed_angel_types_info[] = $angel_type_source['name'] . ': ' . $count; } } @@ -380,7 +389,13 @@ function admin_shifts() 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'), $request->has('length') ? $request->input('length') : '120'), + form_text( + 'length', + _('Length'), + $request->has('length') + ? $request->input('length') + : '120' + ), form_radio( 'mode', _('Create multiple shifts with variable length'), @@ -390,7 +405,9 @@ function admin_shifts() form_text( 'change_hours', _('Shift change hours'), - $request->has('change_hours') ? $request->input('input') : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22' + $request->has('change_hours') + ? $request->input('input') + : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22' ) ]), div('col-md-6', [ @@ -401,7 +418,12 @@ function admin_shifts() $angelmode == 'location', 'location' ), - form_radio('angelmode', _('The following angels are needed'), $angelmode == 'manually', 'manually'), + form_radio( + 'angelmode', + _('The following angels are needed'), + $angelmode == 'manually', + 'manually' + ), div('row', [ $angel_types ]) diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 0620155b..8da09e81 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -235,7 +235,8 @@ function admin_user() } $user_source = User($user_id); engelsystem_log( - 'Set groups of ' . User_Nick_render($user_source) . ' to: ' . join(', ', $user_groups_info) + 'Set groups of ' . User_Nick_render($user_source) . ' to: ' + . join(', ', $user_groups_info) ); $html .= success('Benutzergruppen gespeichert.', true); } else { @@ -261,7 +262,9 @@ function admin_user() `Handy` = ?, `Alter` =?, `DECT` = ?, - ' . ($user_source['email_by_human_allowed'] ? '`email` = ' . DB::getPdo()->quote($request->postData('eemail')) . ',' : '') . ' + ' . ($user_source['email_by_human_allowed'] + ? '`email` = ' . DB::getPdo()->quote($request->postData('eemail')) . ',' + : '') . ' `jabber` = ?, `Size` = ?, `Gekommen`= ?, @@ -298,13 +301,19 @@ function admin_user() break; case 'change_pw': - if ($request->postData('new_pw') != '' && $request->postData('new_pw') == $request->postData('new_pw2')) { + if ( + $request->postData('new_pw') != '' + && $request->postData('new_pw') == $request->postData('new_pw2') + ) { set_password($user_id, $request->postData('new_pw')); $user_source = User($user_id); engelsystem_log('Set new password for ' . User_Nick_render($user_source)); $html .= success('Passwort neu gesetzt.', true); } else { - $html .= error('Die Eingaben müssen übereinstimmen und dürfen nicht leer sein!', true); + $html .= error( + 'Die Eingaben müssen übereinstimmen und dürfen nicht leer sein!', + true + ); } break; } diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 0f8137d0..bed42ee5 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -183,7 +183,7 @@ function guest_register() $tel = strip_request_item('tel'); } if ($request->has('dect')) { - if(strlen(strip_request_item('dect')) <= 5) { + if (strlen(strip_request_item('dect')) <= 5) { $dect = strip_request_item('dect'); } else { $valid = false; @@ -392,7 +392,6 @@ function guest_register() form_info(entry_required() . ' = ' . _('Entry required!')) ]) ]), - // form_textarea('comment', _('Did you help at former CCC events and which tasks have you performed then?'), $comment), form_submit('submit', _('Register')) ]) ]); diff --git a/includes/pages/guest_stats.php b/includes/pages/guest_stats.php index bf1814a3..bb07f4dc 100644 --- a/includes/pages/guest_stats.php +++ b/includes/pages/guest_stats.php @@ -14,7 +14,11 @@ function guest_stats() list($user_count) = DB::select('SELECT count(*) AS `user_count` FROM `User`'); $stats['user_count'] = $user_count['user_count']; - list($arrived_user_count) = DB::select('SELECT count(*) AS `user_count` FROM `User` WHERE `Gekommen`=1'); + list($arrived_user_count) = DB::select(' + SELECT count(*) AS `user_count` + FROM `User` + WHERE `Gekommen`=1 + '); $stats['arrived_user_count'] = $arrived_user_count['user_count']; $done_shifts_seconds = DB::selectOne(' diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php index c9d9398e..c36e1dfd 100644 --- a/includes/pages/user_atom.php +++ b/includes/pages/user_atom.php @@ -63,13 +63,21 @@ function make_atom_entries_from_news($news_entries) return $html; } +/** + * @param array $news_entry + * @return string + */ function make_atom_entry_from_news($news_entry) { return ' ' . htmlspecialchars($news_entry['Betreff']) . ' - ' . preg_replace('#^https?://#', '', page_link_to('news_comments', ['nid' => $news_entry['ID']])) . ' + ' . preg_replace( + '#^https?://#', + '', + page_link_to('news_comments', ['nid' => $news_entry['ID']]) + ) . ' ' . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . ' ' . htmlspecialchars($news_entry['Text']) . ' ' . "\n"; diff --git a/includes/pages/user_ical.php b/includes/pages/user_ical.php index 4ebbb9a2..69a260a2 100644 --- a/includes/pages/user_ical.php +++ b/includes/pages/user_ical.php @@ -30,7 +30,7 @@ function user_ical() /** * Renders an ical calendar from given shifts array. * - * @param array $shifts + * @param array $shifts Shift */ function send_ical_from_shifts($shifts) { diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php index ba5ed53e..0ec93627 100644 --- a/includes/pages/user_news.php +++ b/includes/pages/user_news.php @@ -73,11 +73,12 @@ function user_meetings() /** * Renders the text content of a news entry - * + * * @param array $news * @return string HTML */ -function news_text($news) { +function news_text($news) +{ $text = ReplaceSmilies($news['Text']); $text = preg_replace("/\r\n\r\n/m", '

', $text); return $text; @@ -101,7 +102,11 @@ function display_news($news) $html .= '