summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/controller/shifts_controller.php23
-rw-r--r--includes/controller/users_controller.php2
-rw-r--r--includes/model/ShiftEntry_model.php1
-rw-r--r--includes/model/Shifts_model.php7
-rw-r--r--includes/model/User_model.php2
-rw-r--r--includes/pages/user_atom.php3
-rw-r--r--includes/pages/user_ical.php3
-rw-r--r--includes/sys_template.php2
-rw-r--r--includes/view/AngelTypes_view.php6
-rw-r--r--includes/view/ShiftTypes_view.php1
-rw-r--r--includes/view/Shifts_view.php6
-rw-r--r--public/css/theme4.css4
-rw-r--r--themes/theme4.less2
13 files changed, 27 insertions, 35 deletions
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index 1500b449..1e04c5a8 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -1,6 +1,6 @@
<?php
-
use Engelsystem\ShiftSignupState;
+
function shift_link($shift) {
return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID'];
}
@@ -286,7 +286,7 @@ function shifts_json_export_all_controller() {
* (Like iCal Export or shifts view)
*/
function shifts_json_export_controller() {
- global $ical_shifts, $user;
+ global $user;
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
engelsystem_error("Missing key.");
@@ -295,9 +295,6 @@ function shifts_json_export_controller() {
$key = $_REQUEST['key'];
$user = User_by_api_key($key);
- if ($user === false) {
- engelsystem_error("Unable to find user.");
- }
if ($user == null) {
engelsystem_error("Key invalid.");
}
@@ -305,25 +302,17 @@ function shifts_json_export_controller() {
engelsystem_error("No privilege for shifts_json_export.");
}
- $ical_shifts = load_ical_shifts();
+ $shifts = load_ical_shifts();
header("Content-Type: application/json; charset=utf-8");
- raw_output(json_encode($ical_shifts));
+ raw_output(json_encode($shifts));
}
/**
- * Returns shifts to export.
- * Users shifts or user_shifts filter based shifts if export=user_shifts is given as param.
+ * Returns users shifts to export.
*/
function load_ical_shifts() {
- global $user, $ical_shifts;
-
- if (isset($_REQUEST['export']) && $_REQUEST['export'] == 'user_shifts') {
- require_once realpath(__DIR__ . '/user_shifts.php');
- view_user_shifts();
-
- return $ical_shifts;
- }
+ global $user;
return Shifts_by_user($user);
}
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php
index 33abe764..26ca8d00 100644
--- a/includes/controller/users_controller.php
+++ b/includes/controller/users_controller.php
@@ -151,7 +151,7 @@ function user_controller() {
}
}
- $shifts = Shifts_by_user($user_source);
+ $shifts = Shifts_by_user($user_source, in_array("user_shifts_admin", $privileges));
foreach ($shifts as &$shift) {
// TODO: Move queries to model
$shift['needed_angeltypes'] = sql_select("SELECT DISTINCT `AngelTypes`.* FROM `ShiftEntry` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "' ORDER BY `AngelTypes`.`name`");
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php
index 99f67028..dca7e1c1 100644
--- a/includes/model/ShiftEntry_model.php
+++ b/includes/model/ShiftEntry_model.php
@@ -115,6 +115,7 @@ function ShiftEntries_finished_by_user($user) {
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
WHERE `ShiftEntry`.`UID`=" . sql_escape($user['UID']) . "
AND `Shifts`.`end` < " . sql_escape(time()) . "
+ AND `ShiftEntry`.`freeloaded` = 0
ORDER BY `Shifts`.`end`
");
}
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 2db0a3d3..b1d4ca5e 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -261,9 +261,12 @@ function Shift_create($shift) {
/**
* Return users shifts.
*/
-function Shifts_by_user($user) {
+function Shifts_by_user($user, $include_freeload_comments = false) {
$result = sql_select("
- SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`, `ShiftEntry`.*, `Shifts`.*, `Room`.*
+ SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`,
+ `ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
+ " . ($include_freeload_comments ? "`ShiftEntry`.`freeload_comment`, " : "") . "
+ `Shifts`.*, `Room`.*
FROM `ShiftEntry`
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index 344a3886..3ebd3bf9 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -284,7 +284,7 @@ function User($user_id) {
function User_by_api_key($api_key) {
$user = sql_select("SELECT * FROM `User` WHERE `api_key`='" . sql_escape($api_key) . "' LIMIT 1");
if ($user === false) {
- return false;
+ engelsystem_error("Unable to find user by api key.");
}
if (count($user) == 0) {
return null;
diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php
index 1313d92c..9a765634 100644
--- a/includes/pages/user_atom.php
+++ b/includes/pages/user_atom.php
@@ -10,9 +10,6 @@ function user_atom() {
$key = $_REQUEST['key'];
$user = User_by_api_key($key);
- if ($user === false) {
- engelsystem_error("Unable to find user.");
- }
if ($user == null) {
engelsystem_error("Key invalid.");
}
diff --git a/includes/pages/user_ical.php b/includes/pages/user_ical.php
index 553b8860..34860b70 100644
--- a/includes/pages/user_ical.php
+++ b/includes/pages/user_ical.php
@@ -12,9 +12,6 @@ function user_ical() {
$key = $_REQUEST['key'];
$user = User_by_api_key($key);
- if ($user === false) {
- engelsystem_error("Unable to find user.");
- }
if ($user == null) {
engelsystem_error("Key invalid.");
}
diff --git a/includes/sys_template.php b/includes/sys_template.php
index d2247062..3679328b 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -33,7 +33,7 @@ function label($content, $class = 'default') {
}
function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '') {
- return '<div class="progress"><div class="progress-bar ' . $class . '" role="progressbar" aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" style="width: ' . (($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
+ return '<div class="progress"><div class="progress-bar ' . $class . '" role="progressbar" aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" style="width: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
}
/**
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index a48f8d4c..04c0e286 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -49,7 +49,7 @@ function AngelType_delete_view($angeltype) {
/**
* Render angeltype edit form.
- *
+ *
* @param Angeltype $angeltype
* The angeltype to edit
* @param boolean $supporter_mode
@@ -193,8 +193,8 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
*/
function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $supporter, $user_driver_license, $user) {
$page = [
- msg(),
- AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user)
+ AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
+ msg()
];
$page[] = '<h3>' . _("Description") . '</h3>';
diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php
index 163d6646..3e4cccc6 100644
--- a/includes/view/ShiftTypes_view.php
+++ b/includes/view/ShiftTypes_view.php
@@ -55,6 +55,7 @@ function ShiftType_view($shifttype, $angeltype) {
button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'delete')
]),
+ heading(_("Description"), 2),
$parsedown->parse($shifttype['description'])
]);
}
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 885d1ad9..fbd71d54 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -81,7 +81,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
]),
div('col-sm-3 col-xs-6', [
'<h4>' . _('Location') . '</h4>',
- '<p class="lead">' . glyph('map-marker') . $room['Name'] . '</p>'
+ '<p class="lead">' . Room_name_render($room) . '</p>'
])
]),
div('row', [
@@ -113,7 +113,9 @@ function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shi
$needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '</div>';
$needed_angels .= '<h3>' . AngelType_name_render($angeltypes[$needed_angeltype['TID']]) . '</h3>';
- $needed_angels .= progress_bar(0, $needed_angeltype['count'], min($needed_angeltype['taken'], $needed_angeltype['count']), $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
+ $bar_max = max($needed_angeltype['count']*10, $needed_angeltype['taken']*10, 10);
+ $bar_value = max(1, $needed_angeltype['taken'] * 10);
+ $needed_angels .= progress_bar(0, $bar_max, $bar_value, $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
$angels = [];
foreach ($shift['ShiftEntry'] as $shift_entry) {
diff --git a/public/css/theme4.css b/public/css/theme4.css
index f4ff0d7b..4e641efb 100644
--- a/public/css/theme4.css
+++ b/public/css/theme4.css
@@ -7027,6 +7027,8 @@ a.thumbnail.active {
color: #fff;
}
.label-warning,
-.label-success {
+.label-success,
+.progress-bar-warning,
+.progress-bar-success {
color: #222222;
}
diff --git a/themes/theme4.less b/themes/theme4.less
index 6e221bc1..750a35cc 100644
--- a/themes/theme4.less
+++ b/themes/theme4.less
@@ -1046,6 +1046,6 @@ a.thumbnail.active {
}
}
-.label-warning, .label-success {
+.label-warning, .label-success, .progress-bar-warning, .progress-bar-success {
color: @gray-darker;
}