merged master and issue

This commit is contained in:
jwacalex 2016-11-30 23:23:49 +01:00
commit 45cda10479
34 changed files with 8635 additions and 432 deletions

View File

@ -1,4 +1,5 @@
<?php
use Engelsystem\ShiftSignupState;
function shift_link($shift) {
return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID'];
@ -200,13 +201,13 @@ function shift_controller() {
$angeltypes = AngelTypes();
$user_shifts = Shifts_by_user($user);
$shift_signup_state = null;
$shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
foreach ($angeltypes as $angeltype) {
$angeltype_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, $user_shifts);
if ($shift_signup_state == null) {
$shift_signup_state = $angeltype_signup_state;
} else {
$shift_signup_state = $shift_signup_state->combineWith($angeltype_signup_state);
$shift_signup_state->combineWith($angeltype_signup_state);
}
}
@ -285,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.");
@ -294,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.");
}
@ -304,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);
}

View File

@ -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`");

View File

@ -26,6 +26,7 @@ require_once realpath(__DIR__ . '/../includes/model/UserAngelTypes_model.php');
require_once realpath(__DIR__ . '/../includes/model/UserDriverLicenses_model.php');
require_once realpath(__DIR__ . '/../includes/model/UserGroups_model.php');
require_once realpath(__DIR__ . '/../includes/model/User_model.php');
require_once realpath(__DIR__ . '/../includes/model/ValidationResult.php');
require_once realpath(__DIR__ . '/../includes/view/AngelTypes_view.php');
require_once realpath(__DIR__ . '/../includes/view/EventConfig_view.php');

View File

@ -1,4 +1,5 @@
<?php
use Engelsystem\ValidationResult;
/**
* Returns an array containing the basic attributes of angeltypes.

View File

@ -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`
");
}

View File

@ -263,9 +263,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`)

View File

@ -1,4 +1,5 @@
<?php
use Engelsystem\ValidationResult;
/**
* User model
@ -273,23 +274,6 @@ function User($user_id) {
return null;
}
/**
* TODO: Merge into normal user function
* Returns user by id (limit informations.
*
* @param $user_id UID
*/
function mUser_Limit($user_id) {
$user_source = sql_select("SELECT `UID`, `Nick`, `Name`, `Vorname`, `Telefon`, `DECT`, `Handy`, `email`, `jabber` FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
if ($user_source === false) {
return false;
}
if (count($user_source) > 0) {
return $user_source[0];
}
return null;
}
/**
* Returns User by api_key.
*
@ -300,7 +284,7 @@ function mUser_Limit($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;

View File

@ -0,0 +1,42 @@
<?php
namespace Engelsystem;
/**
* BO that represents the result of an entity attribute validation.
* It contains the validated value and a bool for validation success.
*/
class ValidationResult {
private $valid;
private $value;
/**
* Constructor.
*
* @param boolean $valid
* Is the value valid?
* @param * $value
* The validated value
*/
public function __construct($valid, $value) {
$this->valid = $valid;
$this->value = $value;
}
/**
* Is the value valid?
*/
public function isValid() {
return $this->valid;
}
/**
* The parsed/validated value.
*/
public function getValue() {
return $this->value;
}
}
?>

View File

@ -106,7 +106,7 @@ function guest_register() {
$msg .= error(sprintf(_("Your password is too short (please use at least %s characters)."), MIN_PASSWORD_LENGTH), true);
}
if (isset($_REQUEST['planned_arrival_date']) && $tmp = parse_date("Y-m-d", $_REQUEST['planned_arrival_date'])) {
if (isset($_REQUEST['planned_arrival_date']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_arrival_date'] . " 00:00")) {
$planned_arrival_date = $tmp;
} else {
$valid = false;
@ -212,7 +212,7 @@ function guest_register() {
]),
div('col-sm-8', [
form_email('mail', _("E-Mail") . ' ' . entry_required(), $mail),
form_checkbox('email_shiftinfo', _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), $email_shiftinfo),
form_checkbox('email_shiftinfo', _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), $email_shiftinfo),
form_checkbox('email_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $email_by_human_allowed)
])
]),
@ -233,7 +233,7 @@ function guest_register() {
])
]),
form_checkboxes('angel_types', _("What do you want to do?") . sprintf(" (<a href=\"%s\">%s</a>)", page_link_to('angeltypes') . '&action=about', _("Description of job types")), $angel_types, $selected_angel_types),
form_info("", _("Restricted angel types need will be confirmed later by an archangel. You can change your selection in the options section."))
form_info("", _("Restricted angel types need will be confirmed later by a supporter. You can change your selection in the options section."))
]),
div('col-md-6', [
div('row', [
@ -286,9 +286,9 @@ function guest_login() {
$nick = "";
unset($_SESSION['uid']);
$valid = true;
if (isset($_REQUEST['submit'])) {
$valid = true;
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) {
$nick = User_validate_Nick($_REQUEST['nick']);
@ -306,7 +306,7 @@ function guest_login() {
}
} else {
$valid = false;
error(_("No user was found with that Nickname. Please try again. If you are still having problems, ask an Dispatcher."));
error(_("No user was found with that Nickname. Please try again. If you are still having problems, ask a Dispatcher."));
}
} else {
$valid = false;
@ -326,25 +326,37 @@ function guest_login() {
return page([
div('col-md-12', [
div('row', [
div('col-md-4', [
EventConfig_countdown_page($event_config)
]),
div('col-md-4', [
heading(login_title(), 2),
msg(),
form([
form_text('nick', _("Nick"), $nick),
form_password('password', _("Password")),
form_submit('submit', _("Login")),
buttons([
button(page_link_to('user_password_recovery'), _("I forgot my password"))
EventConfig_countdown_page($event_config)
]),
div('row', [
div('col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4', [
div('panel panel-primary first', [
div('panel-heading', [
'<span class="icon-icon_angel"></span> ' . _("Login")
]),
info(_("Please note: You have to activate cookies!"), true)
div('panel-body', [
msg(),
form([
form_text_placeholder('nick', _("Nick"), $nick),
form_password_placeholder('password', _("Password")),
form_submit('submit', _("Login")),
! $valid ? buttons([
button(page_link_to('user_password_recovery'), _("I forgot my password"))
]) : ''
])
]),
div('panel-footer', [
glyph('info-sign') . _("Please note: You have to activate cookies!")
])
])
]),
div('col-md-4', [
])
]),
div('row', [
div('col-sm-6 text-center', [
heading(register_title(), 2),
get_register_hint(),
get_register_hint()
]),
div('col-sm-6 text-center', [
heading(_("What can I do?"), 2),
'<p>' . _("Please read about the jobs you can do to help us.") . '</p>',
buttons([

View File

@ -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.");
}

View File

@ -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.");
}

View File

@ -1,7 +1,7 @@
<?php
function questions_title() {
return _("Ask an archangel");
return _("Ask the Heaven");
}
function user_questions() {

View File

@ -44,7 +44,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) {
}
if (isset($_REQUEST['planned_arrival_date'])) {
$tmp = parse_date("Y-m-d", $_REQUEST['planned_arrival_date']);
$tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_arrival_date'] . " 00:00");
$result = User_validate_planned_arrival_date($tmp);
$user_source['planned_arrival_date'] = $result->getValue();
if (! $result->isValid()) {
@ -54,7 +54,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) {
}
if (isset($_REQUEST['planned_departure_date'])) {
$tmp = parse_date("Y-m-d", $_REQUEST['planned_departure_date']);
$tmp = parse_date("Y-m-d H:i", $_REQUEST['planned_departure_date'] . " 00:00");
$result = User_validate_planned_departure_date($user_source['planned_arrival_date'], $tmp);
$user_source['planned_departure_date'] = $result->getValue();
if (! $result->isValid()) {

View File

@ -175,6 +175,23 @@ function form_text($name, $label, $value, $disabled = false) {
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
}
/**
* Renders a text input with placeholder instead of label.
*
* @param String $name
* Input name
* @param String $placeholder
* Placeholder
* @param String $value
* The value
* @param Boolean $disabled
* Is the field enabled?
*/
function form_text_placeholder($name, $placeholder, $value, $disabled = false) {
$disabled = $disabled ? ' disabled="disabled"' : '';
return form_element('', '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" placeholder="' . $placeholder . '" ' . $disabled . '/>');
}
/**
* Rendert ein Formular-Emailfeld
*/
@ -198,6 +215,14 @@ function form_password($name, $label, $disabled = false) {
return form_element($label, '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>', 'form_' . $name);
}
/**
* Renders a password input with placeholder instead of label.
*/
function form_password_placeholder($name, $placeholder, $disabled = false) {
$disabled = $disabled ? ' disabled="disabled"' : '';
return form_element('', '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" placeholder="' . $placeholder . '" ' . $disabled . '/>', 'form_' . $name);
}
/**
* Rendert ein Formular-Textfeld
*/

View File

@ -1,4 +1,5 @@
<?php
use Engelsystem\ValidationResult;
/**
* Provide page/request helper functions
@ -131,7 +132,7 @@ function check_request_date($name, $error_message = null, $null_allowed = false)
* @return ValidationResult containing the parsed date
*/
function check_date($input, $error_message = null, $null_allowed = false) {
if ($tmp = parse_date("Y-m-d", trim($input))) {
if ($tmp = parse_date("Y-m-d H:i", trim($input) . " 00:00")) {
return new ValidationResult(true, $tmp);
}
if ($null_allowed) {
@ -187,38 +188,4 @@ function check_email($email) {
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
}
class ValidationResult {
private $valid;
private $value;
/**
* Constructor.
*
* @param boolean $valid
* Is the value valid?
* @param * $value
* The validated value
*/
public function ValidationResult($valid, $value) {
$this->valid = $valid;
$this->value = $value;
}
/**
* Is the value valid?
*/
public function isValid() {
return $this->valid;
}
/**
* The parsed/validated value.
*/
public function getValue() {
return $this->value;
}
}
?>

View File

@ -4,7 +4,8 @@
* Liste der verfügbaren Themes
*/
$themes = [
'3' => "Engelsystem 32c3",
'4' => "Engelsystem 33c3 (2016)",
'3' => "Engelsystem 32c3 (2015)",
"2" => "Engelsystem cccamp15",
"0" => "Engelsystem light",
"1" => "Engelsystem dark"
@ -32,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>';
}
/**

View File

@ -49,7 +49,7 @@ function AngelType_delete_view($angeltype) {
/**
* Render angeltype edit form.
*
*
* @param Angeltype $angeltype
* The angeltype to edit
* @param boolean $supporter_mode
@ -66,8 +66,7 @@ function AngelType_edit_view($angeltype, $supporter_mode) {
$supporter_mode ? form_info(_("Restricted"), $angeltype['restricted'] ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $angeltype['restricted']),
$supporter_mode ? form_info(_("No Self Sign Up"), $angeltype['no_self_signup'] ? _("Yes") : _("No")) : form_checkbox('no_self_signup', _("No Self Sign Up"), $angeltype['no_self_signup']),
$supporter_mode ? form_info(_("Requires driver license"), $angeltype['requires_driver_license'] ? _("Yes") : _("No")) : form_checkbox('requires_driver_license', _("Requires driver license"), $angeltype['requires_driver_license']),
form_info("", _("Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in).")),
form_info("", _("Disabled Self Sign Up prevents angels form self assigning to a shift. They have to been added by coordinator.")),
form_info("", _("Restricted angel types can only be used by an angel if enabled by a supporter (double opt-in).")),
form_textarea('description', _("Description"), $angeltype['description']),
form_info("", _("Please use markdown for the description.")),
form_submit('submit', _("Save"))
@ -195,8 +194,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>';
@ -292,9 +291,6 @@ function AngelTypes_about_view_angeltype($angeltype) {
if ($angeltype['restricted']) {
$html .= info(_("This angeltype is restricted by double-opt-in by a team supporter. Please show up at the according introduction meetings."), true);
}
if ($angeltype['no_self_signup']) {
$html .= info(_("This angeltype is unable to self sign up for shifts. Please show up at the according introduction meetings."), true);
}
if ($angeltype['description'] != "") {
$html .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
}

View File

@ -6,33 +6,49 @@
*/
function EventConfig_countdown_page($event_config) {
if ($event_config == null) {
return info(_("We got no information about the event right now."), true);
return div('col-md-12 text-center', [
heading(sprintf(_("Welcome to the %s!"), '<span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
]);
}
$elements = [];
if ($event_config['event_name'] != null) {
$elements[] = heading($event_config['event_name'], 2);
}
if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
$elements[] = sprintf(_("from %s to %s"), date("Y-m-d", $event_config['event_start_date']), date("Y-m-d", $event_config['event_end_date']));
$elements[] = div('col-sm-12 text-center', [
heading(sprintf(_("Welcome to the %s!"), $event_config['event_name'] . ' <span class="icon-icon_angel"></span> ENGELSYSTEM'), 2)
]);
}
if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) {
$elements[] = '<h2 class="moment-countdown" data-timestamp="' . $event_config['buildup_start_date'] . '">' . _("Buildup starts in %c") . '</h2>';
$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>',
'<small>' . date(_("Y-m-d"), $event_config['buildup_start_date']) . '</small>'
]);
}
if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) {
$elements[] = '<h2 class="moment-countdown" data-timestamp="' . $event_config['event_start_date'] . '">' . _("Event starts in %c") . '</h2>';
$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>',
'<small>' . date(_("Y-m-d"), $event_config['event_start_date']) . '</small>'
]);
}
if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date'] && ($event_config['event_start_date'] == null || time() > $event_config['event_start_date'])) {
$elements[] = '<h2 class="moment-countdown" data-timestamp="' . $event_config['event_end_date'] . '">' . _("Event ends in %c") . '</h2>';
if ($event_config['event_end_date'] != null && 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>',
'<small>' . date(_("Y-m-d"), $event_config['event_end_date']) . '</small>'
]);
}
if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date'] && ($event_config['event_start_date'] == null || time() > $event_config['event_start_date'])) {
$elements[] = '<h2 class="moment-countdown" data-timestamp="' . $event_config['teardown_end_date'] . '">' . _("Teardown ends in %c") . '</h2>';
if ($event_config['teardown_end_date'] != null && 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>',
'<small>' . date(_("Y-m-d"), $event_config['teardown_end_date']) . '</small>'
]);
}
return join("", $elements);

View File

@ -26,7 +26,7 @@ function Questions_view($open_questions, $answered_questions, $ask_action) {
'Answer' => _("Answer"),
'actions' => ""
], $answered_questions),
heading(_("Ask an archangel"), 2),
heading(_("Ask the Heaven"), 2),
form([
form_textarea('question', _("Your Question:"), ""),
form_submit('submit', _("Save"))

View File

@ -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'])
]);
}

View File

@ -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) {

View File

@ -223,67 +223,83 @@ function User_shift_state_render($user) {
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>';
}
function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) {
function User_view_shiftentries($needed_angel_type) {
$shift_info = '<br><b>' . $needed_angel_type['name'] . ':</b> ';
$shift_entries = [];
foreach ($needed_angel_type['users'] as $user_shift) {
$member = User_Nick_render($user_shift);
if ($user_shift['freeloaded']) {
$member = '<strike>' . $member . '</strike>';
}
$shift_entries[] = $member;
}
$shift_info .= join(", ", $shift_entries);
return $shift_info;
}
/**
* Helper that renders a shift line for user view
*/
function User_view_myshift($shift, $user_source, $its_me) {
global $LETZTES_AUSTRAGEN, $privileges;
$user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
if ($shift['title']) {
$shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
}
foreach ($shift['needed_angeltypes'] as $needed_angel_type) {
$shift_info .= User_view_shiftentries($needed_angel_type);
}
$myshift = [
'date' => date("Y-m-d", $shift['start']),
'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']),
'room' => $shift['Name'],
'shift_info' => $shift_info,
'comment' => $shift['Comment']
];
if ($shift['freeloaded']) {
if (in_array("user_shifts_admin", $privileges)) {
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>';
} else {
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>';
}
}
$myshift['actions'] = [
button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs')
];
if ($its_me || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs');
}
if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button(page_link_to('user_myshifts') . ((! $its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs');
}
$myshift['actions'] = table_buttons($myshift['actions']);
return $myshift;
}
/**
* Helper that prepares the shift table for user view
*/
function User_view_myshifts($shifts, $user_source, $its_me) {
$myshifts_table = [];
$timesum = 0;
foreach ($shifts as $shift) {
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
if ($shift['title']) {
$shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
}
foreach ($shift['needed_angeltypes'] as $needed_angel_type) {
$shift_info .= '<br><b>' . $needed_angel_type['name'] . ':</b> ';
$shift_entries = [];
foreach ($needed_angel_type['users'] as $user_shift) {
$member = User_Nick_render($user_shift);
if ($user_shift['freeloaded']) {
$member = '<strike>' . $member . '</strike>';
}
$shift_entries[] = $member;
}
$shift_info .= join(", ", $shift_entries);
}
$myshift = [
'date' => date("Y-m-d", $shift['start']),
'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']),
'room' => $shift['Name'],
'shift_info' => $shift_info,
'comment' => $shift['Comment']
];
if ($shift['freeloaded']) {
if (in_array("user_shifts_admin", $privileges)) {
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>';
} else {
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>';
}
}
$myshift['actions'] = [
button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs')
];
if ($its_me || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs');
}
if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button(page_link_to('user_myshifts') . ((! $its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs');
}
$myshift['actions'] = table_buttons($myshift['actions']);
$myshifts_table[] = User_view_myshift($shift, $user_source, $its_me);
if ($shift['freeloaded']) {
$timesum += (- 2 * ($shift['end'] - $shift['start']));
} else {
$timesum += ($shift['end'] - $shift['start']);
}
$myshifts_table[] = $myshift;
}
if (count($myshifts_table) > 0) {
$myshifts_table[] = [
'date' => '<b>' . _("Sum:") . '</b>',
@ -294,6 +310,15 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
'actions' => ""
];
}
return $myshifts_table;
}
/**
* Renders view for a single user
*/
function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) {
$user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
$myshifts_table = User_view_myshifts($shifts, $user_source, $its_me);
return page_with_title('<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>', [
msg(),

File diff suppressed because it is too large Load Diff

View File

@ -6730,6 +6730,15 @@ body {
.footer a {
color: #777777;
}
.first {
margin-top: 30px;
}
.text-big {
display: block;
font-size: 30px;
line-height: 30px;
margin: 0px;
}
.panel-primary .panel-heading a {
color: #ffffff;
}

View File

@ -6753,6 +6753,15 @@ body {
.footer a {
color: #888888;
}
.first {
margin-top: 30px;
}
.text-big {
display: block;
font-size: 30px;
line-height: 30px;
margin: 0px;
}
.panel-primary .panel-heading a {
color: #ffffff;
}

View File

@ -6730,6 +6730,15 @@ body {
.footer a {
color: #777777;
}
.first {
margin-top: 30px;
}
.text-big {
display: block;
font-size: 30px;
line-height: 30px;
margin: 0px;
}
.panel-primary .panel-heading a {
color: #ffffff;
}

View File

@ -6739,6 +6739,15 @@ body {
.footer a {
color: #777777;
}
.first {
margin-top: 30px;
}
.text-big {
display: block;
font-size: 30px;
line-height: 30px;
margin: 0px;
}
.panel-primary .panel-heading a {
color: #ffffff;
}

7034
public/css/theme4.css Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,8 @@
<?php
class LogEntriesModelTest extends PHPUnit_Framework_TestCase {
namespace Engelsystem\Test;
class LogEntriesModelTest extends \PHPUnit_Framework_TestCase {
public function create_LogEntry() {
LogEntry_create('test', 'test');

View File

@ -1,6 +1,8 @@
<?php
class RoomModelTest extends PHPUnit_Framework_TestCase {
namespace Engelsystem\Test;
class RoomModelTest extends \PHPUnit_Framework_TestCase {
private $room_id = null;

View File

@ -10,6 +10,17 @@ body {
color: @text-muted;
}
.first {
margin-top: 30px;
}
.text-big {
display: block;
font-size: 30px;
line-height: 30px;
margin: 0px;
}
.panel-primary .panel-heading a {
color: @panel-primary-text;
}

View File

@ -4,3 +4,4 @@ lessc theme0.less > ../public/css/theme0.css
lessc theme1.less > ../public/css/theme1.css
lessc theme2.less > ../public/css/theme2.css
lessc theme3.less > ../public/css/theme3.css
lessc theme4.less > ../public/css/theme4.css

1051
themes/theme4.less Normal file

File diff suppressed because it is too large Load Diff