summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-20 20:58:51 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-20 21:07:57 +0200
commitd6c8f1a61475fefa9594141aaf12a28d220bdaf8 (patch)
tree905051fdb1307f947c3a3a7be240609f8bc00e59 /includes/view
parentbf6efe532c8f2de84e95b090911280a9b1b61ce8 (diff)
parent2f41b9e4418def9b69cf237312bc592364585025 (diff)
Merge branch 'master' to 'rebuild-database'
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php14
-rw-r--r--includes/view/EventConfig_view.php26
-rw-r--r--includes/view/ShiftCalendarRenderer.php2
-rw-r--r--includes/view/ShiftCalendarShiftRenderer.php4
-rw-r--r--includes/view/Shifts_view.php8
-rw-r--r--includes/view/UserHintsRenderer.php2
-rw-r--r--includes/view/UserWorkLog_view.php30
-rw-r--r--includes/view/User_view.php66
8 files changed, 91 insertions, 61 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index 6cefbb24..93fa03b5 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -28,9 +28,9 @@ function AngelType_name_render($angeltype)
*/
function AngelType_render_membership($user_angeltype)
{
- if ($user_angeltype['user_angeltype_id'] != null) {
+ if (!empty($user_angeltype['user_angeltype_id'])) {
if ($user_angeltype['restricted']) {
- if ($user_angeltype['confirm_user_id'] == null) {
+ if (empty($user_angeltype['confirm_user_id'])) {
return glyph('lock') . _('Unconfirmed');
} elseif ($user_angeltype['supporter']) {
return glyph_bool(true) . _('Supporter');
@@ -145,18 +145,18 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
);
}
- if ($user_angeltype == null) {
+ if (is_null($user_angeltype)) {
$buttons[] = button(
page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
_('join'),
'add'
);
} else {
- if ($angeltype['requires_driver_license'] && $user_driver_license == null) {
+ if ($angeltype['requires_driver_license'] && empty($user_driver_license)) {
error(_('This angeltype requires a driver license. Please enter your driver license information!'));
}
- if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) {
+ if ($angeltype['restricted'] && empty($user_angeltype['confirm_user_id'])) {
error(sprintf(
_('You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed.'),
$angeltype['name']
@@ -212,7 +212,7 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
$member['has_license_forklift'] = glyph_bool($member['has_license_forklift']);
}
- if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
+ if ($angeltype['restricted'] && empty($member['confirm_user_id'])) {
$member['actions'] = table_buttons([
button(
page_link_to(
@@ -526,7 +526,7 @@ function AngelTypes_about_view_angeltype($angeltype)
if (isset($angeltype['user_angeltype_id'])) {
$buttons = [];
- if ($angeltype['user_angeltype_id'] != null) {
+ if (!empty($angeltype['user_angeltype_id'])) {
$buttons[] = button(
page_link_to(
'user_angeltypes',
diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php
index 25c4b225..fe6de670 100644
--- a/includes/view/EventConfig_view.php
+++ b/includes/view/EventConfig_view.php
@@ -8,7 +8,7 @@
*/
function EventConfig_countdown_page($event_config)
{
- if ($event_config == null) {
+ if (empty($event_config)) {
return div('col-md-12 text-center', [
heading(sprintf(_('Welcome to the %s!'), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
]);
@@ -16,7 +16,7 @@ function EventConfig_countdown_page($event_config)
$elements = [];
- if ($event_config['event_name'] != null) {
+ if (!is_null($event_config['event_name'])) {
$elements[] = div('col-sm-12 text-center', [
heading(sprintf(
_('Welcome to the %s!'),
@@ -25,7 +25,7 @@ function EventConfig_countdown_page($event_config)
]);
}
- if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) {
+ if (!is_null($event_config['buildup_start_date']) && time() < $event_config['buildup_start_date']) {
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(_('Buildup starts'), 4),
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['buildup_start_date'] . '">%c</span>',
@@ -33,7 +33,7 @@ function EventConfig_countdown_page($event_config)
]);
}
- if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) {
+ if (!is_null($event_config['event_start_date']) && time() < $event_config['event_start_date']) {
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(_('Event starts'), 4),
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_start_date'] . '">%c</span>',
@@ -41,7 +41,7 @@ function EventConfig_countdown_page($event_config)
]);
}
- if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date']) {
+ if (!is_null($event_config['event_end_date']) && time() < $event_config['event_end_date']) {
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(_('Event ends'), 4),
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['event_end_date'] . '">%c</span>',
@@ -49,7 +49,7 @@ function EventConfig_countdown_page($event_config)
]);
}
- if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date']) {
+ if (!is_null($event_config['teardown_end_date']) && time() < $event_config['teardown_end_date']) {
$elements[] = div('col-sm-3 text-center hidden-xs', [
heading(_('Teardown ends'), 4),
'<span class="moment-countdown text-big" data-timestamp="' . $event_config['teardown_end_date'] . '">%c</span>',
@@ -68,15 +68,15 @@ function EventConfig_countdown_page($event_config)
*/
function EventConfig_info($event_config)
{
- if ($event_config == null) {
+ if (empty($event_config)) {
return '';
}
// Event name, start+end date are set
if (
- $event_config['event_name'] != null
- && $event_config['event_start_date'] != null
- && $event_config['event_end_date'] != null
+ !is_null($event_config['event_name'])
+ && !is_null($event_config['event_start_date'])
+ && !is_null($event_config['event_end_date'])
) {
return sprintf(
_('%s, from %s to %s'),
@@ -87,7 +87,7 @@ function EventConfig_info($event_config)
}
// Event name, start date are set
- if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) {
+ if (!is_null($event_config['event_name']) && !is_null($event_config['event_start_date'])) {
return sprintf(
_('%s, starting %s'), $event_config['event_name'],
date(_('Y-m-d'), $event_config['event_start_date'])
@@ -95,7 +95,7 @@ function EventConfig_info($event_config)
}
// Event start+end date are set
- if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
+ if (!is_null($event_config['event_start_date']) && !is_null($event_config['event_end_date'])) {
return sprintf(
_('Event from %s to %s'),
date(_('Y-m-d'), $event_config['event_start_date']),
@@ -104,7 +104,7 @@ function EventConfig_info($event_config)
}
// Only event name is set
- if ($event_config['event_name'] != null) {
+ if (!is_null($event_config['event_name'])) {
return sprintf($event_config['event_name']);
}
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index 98f40d49..731d063a 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -129,7 +129,7 @@ class ShiftCalendarRenderer
*/
public function getBlocksPerSlot()
{
- if ($this->blocksPerSlot == null) {
+ if (is_null($this->blocksPerSlot)) {
$this->blocksPerSlot = $this->calcBlocksPerSlot();
}
return $this->blocksPerSlot;
diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php
index 8bfb18ea..9643f195 100644
--- a/includes/view/ShiftCalendarShiftRenderer.php
+++ b/includes/view/ShiftCalendarShiftRenderer.php
@@ -116,7 +116,7 @@ class ShiftCalendarShiftRenderer
$angeltype,
$user
);
- if ($shift_signup_state == null) {
+ if (is_null($shift_signup_state)) {
$shift_signup_state = $angeltype_signup_state;
} else {
$shift_signup_state->combineWith($angeltype_signup_state);
@@ -124,7 +124,7 @@ class ShiftCalendarShiftRenderer
$html .= $angeltype_html;
}
}
- if ($shift_signup_state == null) {
+ if (is_null($shift_signup_state)) {
$shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
}
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 755fab74..c5680578 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -50,14 +50,14 @@ function Shift_view_header($shift, $room)
function Shift_editor_info_render($shift)
{
$info = [];
- if ($shift['created_by_user_id'] != null) {
+ if (!empty($shift['created_by_user_id'])) {
$info[] = sprintf(
glyph('plus') . _('created at %s by %s'),
date('Y-m-d H:i', $shift['created_at_timestamp']),
User_Nick_render(User($shift['created_by_user_id']))
);
}
- if ($shift['edited_by_user_id'] != null) {
+ if (!empty($shift['edited_by_user_id'])) {
$info[] = sprintf(
glyph('pencil') . _('edited at %s by %s'),
date('Y-m-d H:i', $shift['edited_at_timestamp']),
@@ -77,13 +77,13 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
{
global $user;
- if ($user_angeltype == null) {
+ if (empty($user_angeltype)) {
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
}
if ($angeltype['shift_signup_state']->isSignupAllowed()) {
return button(shift_entry_create_link($shift, $angeltype), _('Sign up'));
- } elseif ($user_angeltype == null) {
+ } elseif (empty($user_angeltype)) {
return button(
page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
sprintf(_('Become %s'),
diff --git a/includes/view/UserHintsRenderer.php b/includes/view/UserHintsRenderer.php
index a2bc62f9..8d749ee9 100644
--- a/includes/view/UserHintsRenderer.php
+++ b/includes/view/UserHintsRenderer.php
@@ -36,7 +36,7 @@ class UserHintsRenderer
*/
public function addHint($hint, $important = false)
{
- if ($hint != null && $hint != '') {
+ if (!empty($hint)) {
if ($important) {
$this->important = true;
$this->hints[] = error($hint, true);
diff --git a/includes/view/UserWorkLog_view.php b/includes/view/UserWorkLog_view.php
index 79c049b3..772d4aee 100644
--- a/includes/view/UserWorkLog_view.php
+++ b/includes/view/UserWorkLog_view.php
@@ -2,13 +2,18 @@
/**
* Delete work log entry.
- * @param User $user_source
- * @param UserWorkLog $userWorkLog
+ *
+ * @param array $user_source
+ * @param array $userWorkLog
+ * @return string
*/
function UserWorkLog_delete_view($user_source, $userWorkLog)
{
return page_with_title(UserWorkLog_delete_title(), [
- info(sprintf(_('Do you want to delete the worklog entry for %s?'), User_Nick_render($user_source)), true),
+ info(sprintf(
+ _('Do you want to delete the worklog entry for %s?'),
+ User_Nick_render($user_source)
+ ), true),
buttons([
button(user_link($user_source), glyph('remove') . _('cancel')),
button(user_worklog_delete_link($userWorkLog, [
@@ -28,9 +33,10 @@ function UserWorkLog_delete_title()
/**
* Render edit table.
- *
- * @param User $user_source
- * @param UserWorkLog $userWorkLog
+ *
+ * @param array $user_source
+ * @param array $userWorkLog
+ * @return string
*/
function UserWorkLog_edit_form($user_source, $userWorkLog)
{
@@ -46,8 +52,9 @@ function UserWorkLog_edit_form($user_source, $userWorkLog)
/**
* Form for edit a user work log entry.
*
- * @param User $user_source
- * @param UserWorkLog $userWorkLog
+ * @param array $user_source
+ * @param array $userWorkLog
+ * @return string
*/
function UserWorkLog_edit_view($user_source, $userWorkLog)
{
@@ -63,8 +70,9 @@ function UserWorkLog_edit_view($user_source, $userWorkLog)
/**
* Form for adding a user work log entry.
*
- * @param User $user_source
- * @param UserWorkLog $userWorkLog
+ * @param array $user_source
+ * @param array $userWorkLog
+ * @return string
*/
function UserWorkLog_add_view($user_source, $userWorkLog)
{
@@ -92,5 +100,3 @@ function UserWorkLog_add_title()
{
return _('Add work log entry');
}
-
-?> \ No newline at end of file
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 2f53e641..8eee610a 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -406,10 +406,21 @@ function User_view_myshift($shift, $user_source, $its_me)
* @param array[] $shifts
* @param array $user_source
* @param bool $its_me
+ * @param int $tshirt_score
+ * @param bool $tshirt_admin
+ * @param array[] $user_worklogs
+ * @param $admin_user_worklog_privilege
* @return array
*/
-function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin, $user_worklogs, $admin_user_worklog_privilege)
-{
+function User_view_myshifts(
+ $shifts,
+ $user_source,
+ $its_me,
+ $tshirt_score,
+ $tshirt_admin,
+ $user_worklogs,
+ $admin_user_worklog_privilege
+) {
$myshifts_table = [];
$timesum = 0;
foreach ($shifts as $shift) {
@@ -420,8 +431,8 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi
}
}
- if($its_me || $admin_user_worklog_privilege) {
- foreach($user_worklogs as $worklog) {
+ if ($its_me || $admin_user_worklog_privilege) {
+ foreach ($user_worklogs as $worklog) {
$myshifts_table[$worklog['work_timestamp']] = User_view_worklog($worklog, $admin_user_worklog_privilege);
$timesum += $worklog['work_hours'] * 3600;
}
@@ -453,12 +464,15 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi
/**
* Renders table entry for user work log
- * @param UserWorkLog $worklog
- * @param bool $admin_user_worklog_privilege
+ *
+ * @param array $worklog
+ * @param bool $admin_user_worklog_privilege
+ * @return array
*/
-function User_view_worklog($worklog, $admin_user_worklog_privilege) {
+function User_view_worklog($worklog, $admin_user_worklog_privilege)
+{
$actions = '';
- if($admin_user_worklog_privilege) {
+ if ($admin_user_worklog_privilege) {
$actions = table_buttons([
button(
user_worklog_edit_link($worklog),
@@ -472,18 +486,18 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege) {
)
]);
}
-
+
return [
'date' => glyph('calendar') . date('Y-m-d', $worklog['work_timestamp']),
'duration' => '<b>' . sprintf('%.2f', $worklog['work_hours']) . '</b>',
'room' => '',
'shift_info' => _('Work log entry'),
'comment' => $worklog['comment'] . '<br>'
- . sprintf(
- _('Added by %s at %s'),
- User_Nick_render(User($worklog['created_user_id'])),
- date('Y-m-d H:i', $worklog['created_timestamp'])
- ),
+ . sprintf(
+ _('Added by %s at %s'),
+ User_Nick_render(User($worklog['created_user_id'])),
+ date('Y-m-d H:i', $worklog['created_timestamp'])
+ ),
'actions' => $actions
];
}
@@ -500,6 +514,8 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege) {
* @param bool $its_me
* @param int $tshirt_score
* @param bool $tshirt_admin
+ * @param bool $admin_user_worklog_privilege
+ * @param array[] $user_worklogs
* @return string
*/
function User_view(
@@ -517,9 +533,17 @@ function User_view(
) {
$user_name = htmlspecialchars($user_source['Vorname']) . ' ' . htmlspecialchars($user_source['Name']);
$myshifts_table = '';
- if($its_me || $admin_user_privilege) {
- $my_shifts = User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin, $user_worklogs, $admin_user_worklog_privilege);
- if(count($my_shifts) > 0) {
+ if ($its_me || $admin_user_privilege) {
+ $my_shifts = User_view_myshifts(
+ $shifts,
+ $user_source,
+ $its_me,
+ $tshirt_score,
+ $tshirt_admin,
+ $user_worklogs,
+ $admin_user_worklog_privilege
+ );
+ if (count($my_shifts) > 0) {
$myshifts_table = table([
'date' => _('Day &amp; time'),
'duration' => _('Duration'),
@@ -528,7 +552,7 @@ function User_view(
'comment' => _('Comment'),
'actions' => _('Action')
], $my_shifts);
- } elseif($user_source['force_active']) {
+ } elseif ($user_source['force_active']) {
$myshifts_table = success(_('You have done enough to get a t-shirt.'), true);
}
}
@@ -748,7 +772,7 @@ function User_angeltypes_render($user_angeltypes)
$output = [];
foreach ($user_angeltypes as $angeltype) {
$class = 'text-success';
- if ($angeltype['restricted'] == 1 && $angeltype['confirm_user_id'] == null) {
+ if ($angeltype['restricted'] == 1 && empty($angeltype['confirm_user_id'])) {
$class = 'text-warning';
}
$output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">'
@@ -821,7 +845,7 @@ function render_user_departure_date_hint()
{
global $user;
- if (!isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
+ if (!isset($user['planned_departure_date']) || empty($user['planned_departure_date'])) {
$text = _('Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.');
return render_profile_link($text, null, 'alert-link');
}
@@ -857,7 +881,7 @@ function render_user_arrived_hint()
if ($user['Gekommen'] == 0) {
$event_config = EventConfig();
- if (!is_null($event_config)
+ if (!empty($event_config)
&& !is_null($event_config['buildup_start_date'])
&& time() > $event_config['buildup_start_date']) {
return _('You are not marked as arrived. Please go to heaven\'s desk, get your angel badge and/or tell them that you arrived already.');