summaryrefslogtreecommitdiff
path: root/includes/pages
diff options
context:
space:
mode:
authorBot <bot@myigel.name>2017-12-25 23:12:52 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-12-25 23:51:15 +0100
commit952c7892f3ac7bfadf8419062e44ff1af66ecc57 (patch)
tree69a85e8e4719801a064b8fa2d521fe000f959cd5 /includes/pages
parent879918864a9c6da0fe9be1aca6c443ec8df0afc3 (diff)
Formatting & Docstrings
Diffstat (limited to 'includes/pages')
-rw-r--r--includes/pages/admin_active.php3
-rw-r--r--includes/pages/admin_groups.php6
-rw-r--r--includes/pages/admin_import.php20
-rw-r--r--includes/pages/admin_questions.php4
-rw-r--r--includes/pages/admin_rooms.php37
-rw-r--r--includes/pages/admin_shifts.php36
-rw-r--r--includes/pages/admin_user.php17
-rw-r--r--includes/pages/guest_login.php3
-rw-r--r--includes/pages/guest_stats.php6
-rw-r--r--includes/pages/user_atom.php10
-rw-r--r--includes/pages/user_ical.php2
-rw-r--r--includes/pages/user_news.php17
-rw-r--r--includes/pages/user_settings.php4
-rw-r--r--includes/pages/user_shifts.php35
14 files changed, 150 insertions, 50 deletions
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(
- '<tr><td><input type="checkbox" name="privileges[]" value="%s" %s /></td> <td>%s</td> <td>%s</td></tr>',
+ '<tr>'
+ . '<td><input type="checkbox" name="privileges[]" value="%s" %s /></td>'
+ . '<td>%s</td>'
+ . '<td>%s</td>'
+ . '</tr>',
$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',
[
'<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>'
- . 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 '<a href="' . page_link_to('admin_questions') . '">' . _('There are unanswered questions!') . '</a>';
+ return '<a href="' . page_link_to('admin_questions') . '">'
+ . _('There are unanswered questions!')
+ . '</a>';
}
}
}
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'] .= '<b>' . AngelType_name_render($type) . ':</b> ' . $needed_angel_types[$type['id']] . '<br />';
+ $shifts_table_entry['needed_angels'] .= '<b>' . AngelType_name_render($type) . ':</b> '
+ . $needed_angel_types[$type['id']] . '<br />';
}
}
$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 '
<entry>
<title>' . htmlspecialchars($news_entry['Betreff']) . '</title>
<link href="' . page_link_to('news_comments', ['nid' => $news_entry['ID']]) . '"/>
- <id>' . preg_replace('#^https?://#', '', page_link_to('news_comments', ['nid' => $news_entry['ID']])) . '</id>
+ <id>' . preg_replace(
+ '#^https?://#',
+ '',
+ page_link_to('news_comments', ['nid' => $news_entry['ID']])
+ ) . '</id>
<updated>' . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . '</updated>
<summary>' . htmlspecialchars($news_entry['Text']) . '</summary>
</entry>' . "\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 <Shift> $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", '<br><br>', $text);
return $text;
@@ -101,7 +102,11 @@ function display_news($news)
$html .= '<div class="panel-footer text-muted">';
if (in_array('admin_news', $privileges)) {
$html .= '<div class="pull-right">'
- . button_glyph(page_link_to('admin_news', ['action' => 'edit', 'id' => $news['ID']]), 'edit', 'btn-xs')
+ . button_glyph(
+ page_link_to('admin_news', ['action' => 'edit', 'id' => $news['ID']]),
+ 'edit',
+ 'btn-xs'
+ )
. '</div>';
}
$html .= '<span class="glyphicon glyphicon-time"></span> ' . date('Y-m-d H:i', $news['Datum']) . '&emsp;';
@@ -140,7 +145,11 @@ function user_news_comments()
$nid = $request->input('nid');
$news = DB::selectOne('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$nid]);
if ($request->has('text')) {
- $text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($request->input('text')));
+ $text = preg_replace(
+ "/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui",
+ '',
+ strip_tags($request->input('text'))
+ );
DB::insert('
INSERT INTO `NewsComments` (`Refid`, `Datum`, `Text`, `UID`)
VALUES (?, ?, ?, ?)
diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php
index 83d593ad..bdc8b70d 100644
--- a/includes/pages/user_settings.php
+++ b/includes/pages/user_settings.php
@@ -78,7 +78,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
$user_source['Vorname'] = strip_request_item('prename', $user_source['Vorname']);
$user_source['Alter'] = strip_request_item('age', $user_source['Alter']);
$user_source['Telefon'] = strip_request_item('tel', $user_source['Telefon']);
- if(strlen(strip_request_item('dect')) <= 5) {
+ if (strlen(strip_request_item('dect')) <= 5) {
$user_source['DECT'] = strip_request_item('dect', $user_source['DECT']);
} else {
$valid = false;
@@ -126,7 +126,7 @@ function user_settings_password($user_source)
*
* @param array $user_source The user
* @param array $themes List of available themes
- * @return mixed
+ * @return array
*/
function user_settings_theme($user_source, $themes)
{
diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php
index b3db0391..2d294ff4 100644
--- a/includes/pages/user_shifts.php
+++ b/includes/pages/user_shifts.php
@@ -56,8 +56,18 @@ function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days)
$end_time = $start_time + 24 * 60 * 60;
}
- $shiftsFilter->setStartTime(check_request_datetime('start_day', 'start_time', $days, $start_time));
- $shiftsFilter->setEndTime(check_request_datetime('end_day', 'end_time', $days, $end_time));
+ $shiftsFilter->setStartTime(check_request_datetime(
+ 'start_day',
+ 'start_time',
+ $days,
+ $start_time
+ ));
+ $shiftsFilter->setEndTime(check_request_datetime(
+ 'end_day',
+ 'end_time',
+ $days,
+ $end_time
+ ));
if ($shiftsFilter->getStartTime() > $shiftsFilter->getEndTime()) {
$shiftsFilter->setEndTime($shiftsFilter->getStartTime() + 24 * 60 * 60);
@@ -115,7 +125,7 @@ function load_days()
}
/**
- * @return array|false
+ * @return array[]|false
*/
function load_types()
{
@@ -210,9 +220,19 @@ function view_user_shifts()
view(__DIR__ . '/../../templates/user_shifts.html', [
'title' => shifts_title(),
'room_select' => make_select($rooms, $shiftsFilter->getRooms(), 'rooms', _('Rooms')),
- 'start_select' => html_select_key('start_day', 'start_day', array_combine($days, $days), $start_day),
+ 'start_select' => html_select_key(
+ 'start_day',
+ 'start_day',
+ array_combine($days, $days),
+ $start_day
+ ),
'start_time' => $start_time,
- 'end_select' => html_select_key('end_day', 'end_day', array_combine($days, $days), $end_day),
+ 'end_select' => html_select_key(
+ 'end_day',
+ 'end_day',
+ array_combine($days, $days),
+ $end_day
+ ),
'end_time' => $end_time,
'type_select' => make_select(
$types,
@@ -242,7 +262,10 @@ function view_user_shifts()
'set_last_4h' => _('last 4h'),
'set_next_4h' => _('next 4h'),
'set_next_8h' => _('next 8h'),
- 'buttons' => button(public_dashboard_link(), glyph('dashboard') . _('Public Dashboard'))
+ 'buttons' => button(
+ public_dashboard_link(),
+ glyph('dashboard') . _('Public Dashboard')
+ )
])
])
]);