summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/controller/shifts_controller.php26
-rw-r--r--includes/controller/users_controller.php2
-rw-r--r--includes/engelsystem_provider.php1
-rw-r--r--includes/model/AngelType_model.php1
-rw-r--r--includes/model/ShiftEntry_model.php1
-rw-r--r--includes/model/Shifts_model.php7
-rw-r--r--includes/model/User_model.php20
-rw-r--r--includes/model/ValidationResult.php42
-rw-r--r--includes/pages/guest_login.php54
-rw-r--r--includes/pages/user_atom.php3
-rw-r--r--includes/pages/user_ical.php3
-rw-r--r--includes/pages/user_questions.php2
-rw-r--r--includes/pages/user_settings.php4
-rw-r--r--includes/sys_form.php25
-rw-r--r--includes/sys_page.php37
-rw-r--r--includes/sys_template.php5
-rw-r--r--includes/view/AngelTypes_view.php12
-rw-r--r--includes/view/EventConfig_view.php40
-rw-r--r--includes/view/Questions_view.php2
-rw-r--r--includes/view/ShiftTypes_view.php1
-rw-r--r--includes/view/Shifts_view.php6
-rw-r--r--includes/view/User_view.php121
22 files changed, 238 insertions, 177 deletions
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index f273c097..1e04c5a8 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -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);
}
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/engelsystem_provider.php b/includes/engelsystem_provider.php
index fb3c0f18..595af9f9 100644
--- a/includes/engelsystem_provider.php
+++ b/includes/engelsystem_provider.php
@@ -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');
diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php
index 2ccba2ea..dc26fce9 100644
--- a/includes/model/AngelType_model.php
+++ b/includes/model/AngelType_model.php
@@ -1,4 +1,5 @@
<?php
+use Engelsystem\ValidationResult;
/**
* Returns an array containing the basic attributes of angeltypes.
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 6a29c540..1e1bd97d 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -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`)
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index c1376abd..3ebd3bf9 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -1,4 +1,5 @@
<?php
+use Engelsystem\ValidationResult;
/**
* User model
@@ -274,23 +275,6 @@ function User($user_id) {
}
/**
- * 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.
*
* @param string $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;
diff --git a/includes/model/ValidationResult.php b/includes/model/ValidationResult.php
new file mode 100644
index 00000000..0fc24161
--- /dev/null
+++ b/includes/model/ValidationResult.php
@@ -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;
+ }
+}
+?> \ No newline at end of file
diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php
index 69201161..cba5717b 100644
--- a/includes/pages/guest_login.php
+++ b/includes/pages/guest_login.php
@@ -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")
+ ]),
+ 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"))
+ ]) : ''
+ ])
]),
- info(_("Please note: You have to activate cookies!"), true)
+ 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([
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/pages/user_questions.php b/includes/pages/user_questions.php
index 7acdee78..4abceb92 100644
--- a/includes/pages/user_questions.php
+++ b/includes/pages/user_questions.php
@@ -1,7 +1,7 @@
<?php
function questions_title() {
- return _("Ask an archangel");
+ return _("Ask the Heaven");
}
function user_questions() {
diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php
index 02c61a20..a147b437 100644
--- a/includes/pages/user_settings.php
+++ b/includes/pages/user_settings.php
@@ -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()) {
diff --git a/includes/sys_form.php b/includes/sys_form.php
index 960be401..98ef2134 100644
--- a/includes/sys_form.php
+++ b/includes/sys_form.php
@@ -176,6 +176,23 @@ function form_text($name, $label, $value, $disabled = false) {
}
/**
+ * 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
*/
function form_email($name, $label, $value, $disabled = false) {
@@ -199,6 +216,14 @@ function form_password($name, $label, $disabled = false) {
}
/**
+ * 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
*/
function form_textarea($name, $label, $value, $disabled = false) {
diff --git a/includes/sys_page.php b/includes/sys_page.php
index ad4d15de..82ce9896 100644
--- a/includes/sys_page.php
+++ b/includes/sys_page.php
@@ -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;
- }
-}
-
?>
diff --git a/includes/sys_template.php b/includes/sys_template.php
index 4ae046e6..3679328b 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -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>';
}
/**
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index 77e2fbb6..ce316bb7 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
@@ -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>';
}
diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php
index d184166f..37a19839 100644
--- a/includes/view/EventConfig_view.php
+++ b/includes/view/EventConfig_view.php
@@ -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);
diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php
index bdcb8a86..a44a29d1 100644
--- a/includes/view/Questions_view.php
+++ b/includes/view/Questions_view.php
@@ -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"))
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/includes/view/User_view.php b/includes/view/User_view.php
index 09509c3d..65cb36b3 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -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(),