summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-11-28 15:43:51 +0100
committerGitHub <noreply@github.com>2017-11-28 15:43:51 +0100
commit599f2fd264bfc7b1b6826fe206442806e317340f (patch)
tree50cf84d7d07d11bd65b45c2c17f37632f6cd8eff
parenta5fc5bd0979e8de1fce8a8addd351a6e7bd6aeb8 (diff)
parenteda7f7788ea8012bd8be46405c56a666c11f3fa5 (diff)
Merge pull request #365 from engelsystem/feature-igel-rewrite
Feature igel rewrite
-rw-r--r--.gitignore8
-rw-r--r--.gitlab-ci.yml91
-rw-r--r--.gitmodules6
-rw-r--r--README-ENG.md25
-rw-r--r--README.md52
-rw-r--r--composer.json38
-rw-r--r--config/app.php17
-rw-r--r--config/config.default.php189
-rw-r--r--db/anonymize.sql10
-rw-r--r--db/install.sql4
-rw-r--r--db/update.sql29
-rw-r--r--includes/autoload.php9
-rw-r--r--includes/controller/angeltypes_controller.php469
-rw-r--r--includes/controller/event_config_controller.php216
-rw-r--r--includes/controller/rooms_controller.php171
-rw-r--r--includes/controller/shift_entries_controller.php421
-rw-r--r--includes/controller/shifts_controller.php633
-rw-r--r--includes/controller/shifttypes_controller.php296
-rw-r--r--includes/controller/user_angeltypes_controller.php693
-rw-r--r--includes/controller/user_driver_licenses_controller.php220
-rw-r--r--includes/controller/users_controller.php694
-rw-r--r--includes/engelsystem.php63
-rw-r--r--includes/engelsystem_provider.php104
-rw-r--r--includes/helper/email_helper.php66
-rw-r--r--includes/helper/error_helper.php7
-rw-r--r--includes/helper/graph_helper.php56
-rw-r--r--includes/helper/internationalization_helper.php94
-rw-r--r--includes/helper/message_helper.php78
-rw-r--r--includes/includes.php86
-rw-r--r--includes/mailer/shifts_mailer.php211
-rw-r--r--includes/mailer/users_mailer.php13
-rw-r--r--includes/model/AngelType_model.php334
-rw-r--r--includes/model/EventConfig_model.php97
-rw-r--r--includes/model/LogEntries_model.php56
-rw-r--r--includes/model/Message_model.php77
-rw-r--r--includes/model/NeededAngelTypes_model.php127
-rw-r--r--includes/model/Room_model.php89
-rw-r--r--includes/model/ShiftEntry_model.php265
-rw-r--r--includes/model/ShiftSignupState.php234
-rw-r--r--includes/model/ShiftTypes_model.php93
-rw-r--r--includes/model/ShiftsFilter.php242
-rw-r--r--includes/model/Shifts_model.php809
-rw-r--r--includes/model/UserAngelTypes_model.php281
-rw-r--r--includes/model/UserDriverLicenses_model.php156
-rw-r--r--includes/model/UserGroups_model.php27
-rw-r--r--includes/model/User_model.php559
-rw-r--r--includes/model/ValidationResult.php62
-rw-r--r--includes/mysqli_provider.php216
-rw-r--r--includes/pages/admin_active.php468
-rw-r--r--includes/pages/admin_arrive.php405
-rw-r--r--includes/pages/admin_free.php210
-rw-r--r--includes/pages/admin_groups.php231
-rw-r--r--includes/pages/admin_import.php817
-rw-r--r--includes/pages/admin_log.php61
-rw-r--r--includes/pages/admin_news.php153
-rw-r--r--includes/pages/admin_questions.php254
-rw-r--r--includes/pages/admin_rooms.php419
-rw-r--r--includes/pages/admin_shifts.php715
-rw-r--r--includes/pages/admin_user.php500
-rw-r--r--includes/pages/guest_credits.php18
-rw-r--r--includes/pages/guest_login.php877
-rw-r--r--includes/pages/guest_start.php7
-rw-r--r--includes/pages/guest_stats.php71
-rw-r--r--includes/pages/user_atom.php109
-rw-r--r--includes/pages/user_ical.php96
-rw-r--r--includes/pages/user_messages.php289
-rw-r--r--includes/pages/user_myshifts.php267
-rw-r--r--includes/pages/user_news.php388
-rw-r--r--includes/pages/user_questions.php129
-rw-r--r--includes/pages/user_settings.php372
-rw-r--r--includes/pages/user_shifts.php398
-rw-r--r--includes/sys_auth.php192
-rw-r--r--includes/sys_form.php427
-rw-r--r--includes/sys_log.php41
-rw-r--r--includes/sys_menu.php352
-rw-r--r--includes/sys_page.php245
-rw-r--r--includes/sys_template.php477
-rw-r--r--includes/view/AngelTypes_view.php774
-rw-r--r--includes/view/EventConfig_view.php250
-rw-r--r--includes/view/Questions_view.php81
-rw-r--r--includes/view/Rooms_view.php50
-rw-r--r--includes/view/ShiftCalendarLane.php125
-rw-r--r--includes/view/ShiftCalendarRenderer.php530
-rw-r--r--includes/view/ShiftCalendarShiftRenderer.php414
-rw-r--r--includes/view/ShiftEntry_view.php59
-rw-r--r--includes/view/ShiftTypes_view.php205
-rw-r--r--includes/view/ShiftsFilterRenderer.php127
-rw-r--r--includes/view/Shifts_view.php356
-rw-r--r--includes/view/UserAngelTypes_view.php263
-rw-r--r--includes/view/UserDriverLicenses_view.php87
-rw-r--r--includes/view/UserHintsRenderer.php105
-rw-r--r--includes/view/User_view.php1053
-rw-r--r--locale/de_DE.UTF-8/LC_MESSAGES/default.mobin40950 -> 41242 bytes
-rw-r--r--locale/de_DE.UTF-8/LC_MESSAGES/default.po1732
-rw-r--r--phpunit.xml39
-rw-r--r--public/.htaccess8
-rw-r--r--public/css/theme0.css7
-rw-r--r--public/css/theme1.css7
-rw-r--r--public/css/theme2.css7
-rw-r--r--public/css/theme3.css7
-rw-r--r--public/css/theme4.css7
-rw-r--r--public/index.php360
-rw-r--r--public/js/forms.js32
-rw-r--r--public/js/moment-countdown.js28
-rw-r--r--public/js/sticky-headers.js37
-rw-r--r--public/maintenance.html72
-rw-r--r--public/overwhelmed.html57
l---------public/vendor/bootstrap2
-rw-r--r--shift_markup.html86
-rw-r--r--src/Application.php137
-rw-r--r--src/Config/Config.php100
-rw-r--r--src/Config/ConfigServiceProvider.php26
-rw-r--r--src/Container/Container.php10
-rw-r--r--src/Container/ServiceProvider.php31
-rw-r--r--src/Database/DatabaseServiceProvider.php31
-rw-r--r--src/Database/Db.php188
-rw-r--r--src/Exceptions/ExceptionsServiceProvider.php58
-rw-r--r--src/Exceptions/Handler.php135
-rw-r--r--src/Exceptions/Handlers/HandlerInterface.php21
-rw-r--r--src/Exceptions/Handlers/Legacy.php42
-rw-r--r--src/Exceptions/Handlers/LegacyDevelopment.php57
-rw-r--r--src/Exceptions/Handlers/Whoops.php85
-rw-r--r--src/Http/Request.php67
-rw-r--r--src/Http/RequestServiceProvider.php14
-rw-r--r--src/Http/SessionServiceProvider.php52
-rw-r--r--src/Logger/EngelsystemLogger.php74
-rw-r--r--src/Logger/LoggerServiceProvider.php18
-rw-r--r--src/Renderer/EngineInterface.php21
-rw-r--r--src/Renderer/HtmlEngine.php34
-rw-r--r--src/Renderer/Renderer.php47
-rw-r--r--src/Renderer/RendererServiceProvider.php36
-rw-r--r--src/Routing/RoutingServiceProvider.php14
-rw-r--r--src/Routing/UrlGenerator.php25
-rw-r--r--src/helpers.php144
-rw-r--r--templates/guest_credits.html59
-rw-r--r--templates/layout.html89
-rw-r--r--templates/maintenance.html86
-rw-r--r--templates/user_shifts.html97
-rw-r--r--test/model/LogEntriesModelTest.php34
-rw-r--r--test/model/RoomModelTest.php35
-rw-r--r--tests/Feature/Database/DatabaseServiceProviderTest.php40
-rw-r--r--tests/Feature/Database/DatabaseTest.php25
-rw-r--r--tests/Feature/Logger/EngelsystemLoggerTest.php150
-rw-r--r--tests/Feature/Model/LogEntriesModelTest.php38
-rw-r--r--tests/Feature/Model/RoomModelTest.php40
-rw-r--r--tests/Unit/ApplicationTest.php171
-rw-r--r--tests/Unit/Config/ConfigServiceProviderTest.php45
-rw-r--r--tests/Unit/Config/ConfigTest.php115
-rw-r--r--tests/Unit/Container/ServiceProviderTest.php22
-rw-r--r--tests/Unit/Container/Stub/ServiceProviderImplementation.php10
-rw-r--r--tests/Unit/Database/DatabaseServiceProviderTest.php37
-rw-r--r--tests/Unit/Database/DbTest.php192
-rw-r--r--tests/Unit/Exceptions/ExceptionsServiceProviderTest.php109
-rw-r--r--tests/Unit/Exceptions/HandlerTest.php140
-rw-r--r--tests/Unit/Exceptions/Handlers/LegacyDevelopmentTest.php35
-rw-r--r--tests/Unit/Exceptions/Handlers/LegacyTest.php55
-rw-r--r--tests/Unit/Exceptions/Handlers/WhoopsTest.php83
-rw-r--r--tests/Unit/HelpersTest.php208
-rw-r--r--tests/Unit/Http/RequestServiceProviderTest.php29
-rw-r--r--tests/Unit/Http/RequestTest.php99
-rw-r--r--tests/Unit/Http/SessionServiceProviderTest.php128
-rw-r--r--tests/Unit/Logger/LoggerServiceProviderTest.php37
-rw-r--r--tests/Unit/Renderer/HtmlEngineTest.php67
-rw-r--r--tests/Unit/Renderer/RendererServiceProviderTest.php81
-rw-r--r--tests/Unit/Renderer/RendererTest.php59
-rw-r--r--tests/Unit/Routing/RoutingServiceProviderTest.php29
-rw-r--r--tests/Unit/Routing/UrlGeneratorTest.php51
-rw-r--r--tests/Unit/ServiceProviderTest.php50
-rw-r--r--tests/autoload.php8
m---------themes/assets/bootstrap0
-rw-r--r--themes/base.less136
-rw-r--r--themes/theme1.less2
-rw-r--r--themes/theme2.less2
-rw-r--r--themes/theme3.less2
-rw-r--r--themes/theme4.less2
m---------vendor/parsedown0
176 files changed, 18104 insertions, 10808 deletions
diff --git a/.gitignore b/.gitignore
index febc6812..eb12eae7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,9 +14,15 @@ Thumbs.db
_vimrc_local.vim
.sass-cache
-# PHPstorm config
+# PHPstorm files
/.idea/
+/.phpstorm.meta.php
# Project files
/config/config.php
/test/coverage
+/public/coverage
+
+# Composer files
+/vendor/
+/composer.lock
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 00000000..6dde2330
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,91 @@
+image: php
+
+cache:
+ paths:
+ - .composer
+
+services:
+ - mariadb:10.2
+
+variables:
+ MYSQL_DATABASE: engelsystem
+ MYSQL_USER: engel
+ MYSQL_PASSWORD: engelsystem
+ MYSQL_HOST: mariadb
+ COMPOSER_HOME: .composer
+ MYSQL_RANDOM_ROOT_PASSWORD: "yes"
+
+before_script:
+ # Fix permissions after gitlab messed them up
+ - find . -type f -exec chmod 644 {} \;
+ - find . -type d -exec chmod 755 {} \;
+ # Install required Packages
+ - apt update -yqq
+ - apt install -yqq git unzip mariadb-client
+ - docker-php-ext-install pdo pdo_mysql gettext
+ # Install xdebug
+ - pecl install xdebug
+ - docker-php-ext-enable xdebug
+ # MySQL DB
+ - mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/install.sql
+ - mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/update.sql
+ # Install Composer
+ - curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer
+ - /usr/local/bin/composer --no-ansi install
+
+.test_template: &test_definition
+ artifacts:
+ name: "${CI_JOB_NAME}_${CI_PROJECT_ID}_${PHP_VERSION}"
+ expire_in: 1 week
+ paths:
+ - ./coverage/
+ coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
+ script: vendor/bin/phpunit --colors=never --coverage-text --coverage-html ./coverage/
+
+test:7.0:
+ image: php:7.0
+ <<: *test_definition
+
+test:7.1:
+ image: php:7.1
+ <<: *test_definition
+
+deploy_staging:
+ stage: deploy
+ only:
+ - master
+ script:
+ - |-
+ if [ -z "${SSH_PRIVATE_KEY}" ] || [ -z "${REMOTE}" ] || [ -z "${REMOTE_PATH}" ]; then
+ echo "Skipping deployment";
+ exit
+ fi
+ - mkdir -p ~/.ssh
+ - echo "$SSH_PRIVATE_KEY" | sed -e 's/\r//g' > ~/.ssh/id_ed25519
+ - chmod 600 ~/.ssh/id_ed25519
+ - apt update && apt install -yqq rsync openssh-client
+ - /usr/local/bin/composer --no-ansi install --no-dev
+ - /usr/local/bin/composer --no-ansi dump-autoload --optimize
+ - echo "syncing ${PWD}/ to ${REMOTE}:${REMOTE_PATH}/${CI_JOB_ID}-${CI_COMMIT_SHA}/"
+ - |-
+ rsync -vAax --exclude '.git*' --exclude .composer/ \
+ -e "ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" \
+ ./ "${REMOTE}:${REMOTE_PATH}/${CI_JOB_ID}-${CI_COMMIT_SHA}/"
+ - |-
+ ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${REMOTE}" "
+ set -e
+
+ if [[ -f \"${REMOTE_PATH}/current/config/config.php\" ]]; then
+ echo \"Config backup\"
+ cp \"${REMOTE_PATH}/current/config/config.php\" config.php
+ fi
+
+ echo \"Changing symlink\"
+ unlink \"${REMOTE_PATH}/current\"
+ ln -s \"${REMOTE_PATH}/${CI_JOB_ID}-${CI_COMMIT_SHA}\" \"${REMOTE_PATH}/current\"
+
+ if [[ -f config.php ]]; then
+ echo \"Restoring config\"
+ cp config.php \"${REMOTE_PATH}/current/config/config.php\"
+ fi
+ "
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 0aa8483a..00000000
--- a/.gitmodules
+++ /dev/null
@@ -1,6 +0,0 @@
-[submodule "vendor/parsedown"]
- path = vendor/parsedown
- url = https://github.com/erusev/parsedown.git
-[submodule "vendor/bootstrap"]
- path = themes/assets/bootstrap
- url = https://github.com/twbs/bootstrap.git
diff --git a/README-ENG.md b/README-ENG.md
deleted file mode 100644
index 3632882c..00000000
--- a/README-ENG.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Installation of Engelsystem
-
-## Requirements:
- * PHP 5.4.x (cgi-fcgi)
- * MySQL-Server 5.5.x
- * Webserver, i.e. lighttpd, nginx, or Apache
-
-## Directions:
- * Clone the master branch with the submodules: `git clone --recursive https://github.com/engelsystem/engelsystem.git`
- * Webserver must have write access to the 'import' directory and read access for all other directories
- * Webserver must be public.
-
- * Recommended: Directory Listing should be disabled.
- * There must a be MySQL database created with a user who has full rights to that database.
- * It must be created by the db/install.sql and db/update.sql files.
- * If necessary, create a config/config.php to override values from config/config.default.php.
- * In the browser, login with credentials admin:asdfasdf and change the password.
-
-Engelsystem can now be used.
-
-## Session Settings:
- * Make sure the config allows for sessions.
- * Both Apache and Nginx allow for different VirtualHost configurations.
-
-Report Bugs: https://github.com/engelsystem/engelsystem/issues
diff --git a/README.md b/README.md
index 57d81d52..2b61ebe8 100644
--- a/README.md
+++ b/README.md
@@ -1,28 +1,42 @@
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/20b3b0b4e93344a29da6bec77f329e7a)](https://www.codacy.com/app/engelsystem/engelsystem)
[![GPL](https://img.shields.io/github/license/engelsystem/engelsystem.svg?maxAge=2592000)]()
-# Installation eines frischen Engelsystems
+# Engelsystem
-## Mindestvorrausetzungen (bzw. getestet unter):
- * PHP 5.4.x (cgi-fcgi)
- * MySQL-Server 5.5.x
- * Webserver mit PHP-Anbindung, z.B. lighttpd, nginx oder Apache
+Please visit https://engelsystem.de for a feature list.
-## Vorgehen:
- * Klonen des `master` inkl. submodules in lokales Verzeichnis: `git clone --recursive https://github.com/engelsystem/engelsystem.git`
- * Der Webserver muss Schreibrechte auf das Verzeichnis `import` bekommen, für alle anderen Dateien reichen Leserechte.
- * Der Webserver muss auf `public` als http-root zeigen.
+## Installation
- * Empfehlung: Dirlisting sollte deaktiviert sein.
- * Es muss eine MySQL-Datenbank angelegt werden und ein User existieren, der alle Rechte auf dieser Datenbank besitzt.
- * Es muss die db/install.sql und die db/update.sql importiert/ausgeführt werden.
- * Erstelle bei Bedarf eine config/config.php, die die Werte (z.B. DB-Zugang) aus der config/config.default.php überschreibt.
- * Engelsystem im Browser aufrufen, Anmeldung mit admin:asdfasdf vornehmen und Admin-Passwort ändern.
+### Requirements:
+ * PHP >= 7.0.0
+ * MySQL-Server >= 5.5.x
+ * Webserver, i.e. lighttpd, nginx, or Apache
-Das Engelsystem ist jetzt einsatzbereit.
+### Directions:
+ * Clone the master branch: `git clone https://github.com/engelsystem/engelsystem.git`
+ * Install [Composer](https://getcomposer.org/download/)
+ * Install project dependencies: `composer install`
+ * Webserver must have write access to the 'import' directory and read access for all other directories
+ * Webserver must point to the public directory.
-## Session Einstellungen:
- * Einstellungen für Cookies und Sessions bitte in der PHP Config des Servers vornehmen.
- * Sowohl Apache als auch nginx bieten Möglichkeiten für verschiedene Konfigurationen pro VirtualHost an
+ * Recommended: Directory Listing should be disabled.
+ * There must a be MySQL database created with a user who has full rights to that database.
+ * It must be created by the db/install.sql and db/update.sql files.
+ * If necessary, create a config/config.php to override values from config/config.default.php.
+ * In the browser, login with credentials admin:asdfasdf and change the password.
-Fehler bitte auf Github melden: https://github.com/engelsystem/engelsystem/issues
+Engelsystem can now be used.
+
+### Session Settings:
+ * Make sure the config allows for sessions.
+ * Both Apache and Nginx allow for different VirtualHost configurations.
+
+Report Bugs: https://github.com/engelsystem/engelsystem/issues
+
+## Development
+Since the engelsystem is open source, you can help to improve the system. We really love to get pull requests containing fixes or implementations of our Github issues.
+
+Please create single pull requests for every feature instead of creating one big monster of pull request containing a complete rewrite.
+
+### Codestyle
+Please ensure that your pull requests follow [PSR-2](http://www.php-fig.org/psr/psr-2/) and [PSR-4](http://www.php-fig.org/psr/psr-4/).
diff --git a/composer.json b/composer.json
new file mode 100644
index 00000000..ed34ba03
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,38 @@
+{
+ "name": "engelsystem/engelsystem",
+ "description": "Shift planning system for chaos events",
+ "type": "project",
+ "license": "GPL-2.0",
+ "authors": [
+ {
+ "name": "msquare",
+ "email": "msquare@notrademark.de"
+ },
+ {
+ "name": "MyIgel",
+ "email": "igor.scheller@igorshp.de"
+ }
+ ],
+ "require": {
+ "php": ">=7.0.0",
+ "erusev/parsedown": "^1.6",
+ "illuminate/container": "5.5.*",
+ "psr/container": "^1.0",
+ "psr/log": "^1.0",
+ "symfony/http-foundation": "^3.3",
+ "twbs/bootstrap": "^3.3"
+ },
+ "require-dev": {
+ "filp/whoops": "^2.1",
+ "phpunit/phpunit": "^6.3",
+ "symfony/var-dumper": "^3.3"
+ },
+ "autoload": {
+ "psr-4": {
+ "Engelsystem\\": "src/"
+ },
+ "files": [
+ "src/helpers.php"
+ ]
+ }
+}
diff --git a/config/app.php b/config/app.php
new file mode 100644
index 00000000..74eb2991
--- /dev/null
+++ b/config/app.php
@@ -0,0 +1,17 @@
+<?php
+
+// Application config
+
+return [
+ // Service providers
+ 'providers' => [
+ \Engelsystem\Logger\LoggerServiceProvider::class,
+ \Engelsystem\Exceptions\ExceptionsServiceProvider::class,
+ \Engelsystem\Config\ConfigServiceProvider::class,
+ \Engelsystem\Routing\RoutingServiceProvider::class,
+ \Engelsystem\Renderer\RendererServiceProvider::class,
+ \Engelsystem\Database\DatabaseServiceProvider::class,
+ \Engelsystem\Http\RequestServiceProvider::class,
+ \Engelsystem\Http\SessionServiceProvider::class,
+ ],
+];
diff --git a/config/config.default.php b/config/config.default.php
index 59f7bbc6..7594346a 100644
--- a/config/config.default.php
+++ b/config/config.default.php
@@ -1,70 +1,125 @@
<?php
-// Enable maintenance mode (showin a static page)
-$maintenance_mode = false;
-
-// URL to the angel faq and job description
-$faq_url = "https://events.ccc.de/congress/2013/wiki/Static:Volunteers";
-
-// contact email address, linked on every page
-$contact_email = "mailto:ticket@c3heaven.de";
-$no_reply_email = "noreply@engelsystem.de";
-
-// Default-Theme auf der Startseite, 1=style1.css usw.
-$default_theme = 1;
-
-// Anzahl der News, die auf einer Seite ausgeben werden koennen...
-$DISPLAY_NEWS = 6;
-
-// Anzahl Stunden bis zum Austragen eigener Schichten
-$LETZTES_AUSTRAGEN = 3;
-
-// Setzt den zu verwendenden Crypto-Algorismus (entsprechend der Dokumentation von crypt()).
-// Falls ein Benutzerpasswort in einem anderen Format gespeichert ist,
-// wird es bei der ersten Benutzung des Klartext-Passworts in das neue Format
-// konvertiert.
-// $crypt_alg = '$1'; // MD5
-// $crypt_alg = '$2y$13'; // Blowfish
-// $crypt_alg = '$5$rounds=5000'; // SHA-256
-$crypt_alg = '$6$rounds=5000'; // SHA-512
-
-$min_password_length = 8;
-
-// Wenn Engel beim Registrieren oder in ihrem Profil eine T-Shirt Größe angeben sollen, auf true setzen:
-$enable_tshirt_size = true;
-
-// Number of shifts to freeload until angel is locked for shift signup.
-$max_freeloadable_shifts = 2;
-
-// local timezone
-date_default_timezone_set("Europe/Berlin");
-
-// multiply "night shifts" and freeloaded shifts (start or end between 2 and 6 exclusive) by 2
-$shift_sum_formula = "SUM(
- (1+(
- (HOUR(FROM_UNIXTIME(`Shifts`.`end`)) > 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) < 6)
- OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) > 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`start`)) < 6)
- OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) <= 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) >= 6)
- ))*(`Shifts`.`end` - `Shifts`.`start`)*(1 - 3 * `ShiftEntry`.`freeloaded`)
-)";
-
-// voucher calculation
-$voucher_settings = [
- "initial_vouchers" => 2,
- "shifts_per_voucher" => 1
+// To change settings create a config.php
+
+return [
+ // MySQL-Connection Settings
+ 'database' => [
+ 'host' => env('MYSQL_HOST', (env('CI', false) ? 'mariadb' : 'localhost')),
+ 'user' => env('MYSQL_USER', 'root'),
+ 'pw' => env('MYSQL_PASSWORD', ''),
+ 'db' => env('MYSQL_DATABASE', 'engelsystem'),
+ ],
+
+ // For accessing stats
+ 'api_key' => '',
+
+ // Enable maintenance mode (show a static page)
+ 'maintenance' => false,
+
+ // Set to development to enable debugging messages
+ 'environment' => 'production',
+
+ // URL to the angel faq and job description
+ 'faq_url' => 'https://events.ccc.de/congress/2013/wiki/Static:Volunteers',
+
+ // Contact email address, linked on every page
+ 'contact_email' => 'mailto:ticket@c3heaven.de',
+
+ // From address of all emails
+ 'no_reply_email' => 'noreply@engelsystem.de',
+
+ // Default theme, 1=style1.css
+ 'theme' => 1,
+
+ // Available themes
+ 'available_themes' => [
+ '4' => 'Engelsystem 33c3 (2016)',
+ '3' => 'Engelsystem 32c3 (2015)',
+ '2' => 'Engelsystem cccamp15',
+ '0' => 'Engelsystem light',
+ '1' => 'Engelsystem dark'
+ ],
+
+ // Number of News shown on one site
+ 'display_news' => 6,
+
+ // Users are able to sign up
+ 'registration_enabled' => true,
+
+ // Only arrived angels can sign up for shifts
+ 'signup_requires_arrival' => false,
+
+ // Anzahl Stunden bis zum Austragen eigener Schichten
+ 'last_unsubscribe' => 3,
+
+ // Setzt den zu verwendenden Crypto-Algorithmus (entsprechend der Dokumentation von crypt()).
+ // Falls ein Benutzerpasswort in einem anderen Format gespeichert ist,
+ // wird es bei der ersten Benutzung des Klartext-Passworts in das neue Format
+ // konvertiert.
+ // MD5 '$1'
+ // Blowfish '$2y$13'
+ // SHA-256 '$5$rounds=5000'
+ // SHA-512 '$6$rounds=5000'
+ 'crypt_alg' => '$6$rounds=5000',
+
+ 'min_password_length' => 8,
+
+ // Wenn Engel beim Registrieren oder in ihrem Profil eine T-Shirt Größe angeben sollen, auf true setzen:
+ 'enable_tshirt_size' => true,
+
+ // Number of shifts to freeload until angel is locked for shift signup.
+ 'max_freeloadable_shifts' => 2,
+
+ // local timezone
+ 'timezone' => 'Europe/Berlin',
+
+ // weigh every shift the same
+ //'shift_sum_formula' => 'SUM(`end` - `start`)',
+
+ // Multiply 'night shifts' and freeloaded shifts (start or end between 2 and 6 exclusive) by 2
+ 'shift_sum_formula' => '
+ SUM(
+ (1 +
+ (
+ (HOUR(FROM_UNIXTIME(`Shifts`.`end`)) > 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) < 6)
+ OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) > 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`start`)) < 6)
+ OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) <= 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) >= 6)
+ )
+ )
+ * (`Shifts`.`end` - `Shifts`.`start`)
+ * (1 - 3 * `ShiftEntry`.`freeloaded`)
+ )
+ ',
+
+ // Voucher calculation
+ 'voucher_settings' => [
+ 'initial_vouchers' => 2,
+ 'shifts_per_voucher' => 1,
+ ],
+
+ // Available locales in /locale/
+ 'locales' => [
+ 'de_DE.UTF-8' => 'Deutsch',
+ 'en_US.UTF-8' => 'English',
+ ],
+
+ 'default_locale' => 'en_US.UTF-8',
+
+ // Available T-Shirt sizes, set value to null if not available
+ 'tshirt_sizes' => [
+ '' => _('Please select...'),
+ 'S' => 'S',
+ 'M' => 'M',
+ 'L' => 'L',
+ 'XL' => 'XL',
+ '2XL' => '2XL',
+ '3XL' => '3XL',
+ '4XL' => '4XL',
+ '5XL' => '5XL',
+ 'S-G' => 'S Girl',
+ 'M-G' => 'M Girl',
+ 'L-G' => 'L Girl',
+ 'XL-G' => 'XL Girl',
+ ],
];
-
-// weigh every shift the same
-// $shift_sum_formula = "SUM(`end` - `start`)";
-
-// For accessing stats
-$api_key = "";
-
-// MySQL-Connection Settings
-$config = [
- 'host' => "localhost",
- 'user' => "root",
- 'pw' => "",
- 'db' => "engelsystem"
-];
-?>
diff --git a/db/anonymize.sql b/db/anonymize.sql
new file mode 100644
index 00000000..ba420d79
--- /dev/null
+++ b/db/anonymize.sql
@@ -0,0 +1,10 @@
+update User set Nick=concat('User',UID), Name=concat('Name',UID), Vorname=concat('Prename',UID), `Alter`=0, Telefon='', DECT='', Handy='', email=concat('engel', UID, '@engelsystem.de'), jabber='', Hometown='';
+update Messages set Text=concat('Message', id);
+update News set Betreff=concat('Subject', ID), Text=concat('News', ID);
+update NewsComments set Text=concat('Comment', ID);
+update Questions set Question=concat('Question', QID), Answer=concat('Answer', QID);
+update ShiftEntry set Comment='', freeload_comment='';
+update ShiftTypes set name=concat('Shifttype',id), description='Description';
+update AngelTypes set name=concat('Angeltype',id), description=concat('Description of angeltype',id);
+TRUNCATE TABLE LogEntries;
+
diff --git a/db/install.sql b/db/install.sql
index 0222dc08..3c3e41e6 100644
--- a/db/install.sql
+++ b/db/install.sql
@@ -205,7 +205,7 @@ DROP TABLE IF EXISTS `NewsComments`;
CREATE TABLE `NewsComments` (
`ID` bigint(11) NOT NULL,
`Refid` int(11) NOT NULL DEFAULT '0',
- `Datum` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `Datum` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`Text` text NOT NULL,
`UID` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -395,7 +395,7 @@ CREATE TABLE `User` (
`Sprache` char(64) NOT NULL,
`Menu` char(1) NOT NULL DEFAULT 'L',
`lastLogIn` int(11) NOT NULL,
- `CreateDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `CreateDate` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`Art` varchar(30) DEFAULT NULL,
`kommentar` text,
`Hometown` varchar(255) NOT NULL DEFAULT '',
diff --git a/db/update.sql b/db/update.sql
index dd203a86..c5187675 100644
--- a/db/update.sql
+++ b/db/update.sql
@@ -8,19 +8,30 @@ ALTER TABLE `User` ADD COLUMN `email_by_human_allowed` BOOLEAN NOT NULL;
-- No Self Sign Up for some Angel Types
ALTER TABLE AngelTypes ADD no_self_signup TINYINT(1) NOT NULL;
-ALTER TABLE `AngelTypes`
- ADD `contact_user_id` INT NULL,
- ADD `contact_name` VARCHAR(250) NULL,
- ADD `contact_dect` VARCHAR(5) NULL,
- ADD `contact_email` VARCHAR(250) NULL,
+ALTER TABLE `AngelTypes`
+ ADD `contact_user_id` INT NULL,
+ ADD `contact_name` VARCHAR(250) NULL,
+ ADD `contact_dect` VARCHAR(5) NULL,
+ ADD `contact_email` VARCHAR(250) NULL,
ADD INDEX (`contact_user_id`);
-ALTER TABLE `AngelTypes`
+ALTER TABLE `AngelTypes`
ADD FOREIGN KEY (`contact_user_id`) REFERENCES `User`(`UID`) ON DELETE SET NULL ON UPDATE CASCADE;
-
INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES (NULL, 'shiftentry_edit_angeltype_supporter', 'If user with this privilege is angeltype supporter, he can put users in shifts for their angeltype');
-
-- DB Performance
ALTER TABLE `Shifts` ADD INDEX(`start`);
-ALTER TABLE `NeededAngelTypes` ADD INDEX(`count`); \ No newline at end of file
+ALTER TABLE `NeededAngelTypes` ADD INDEX(`count`);
+
+-- Security
+UPDATE `Groups` SET UID = UID * 10;
+INSERT INTO `Groups` (Name, UID) VALUES ('News Admin', -65);
+INSERT INTO `Privileges` (id, name, `desc`) VALUES (42, 'admin_news_html', 'Use HTML in news');
+INSERT INTO `GroupPrivileges` (group_id, privilege_id) VALUES (-65, 14), (-65, 42);
+
+-- Add log level to LogEntries
+ALTER TABLE `LogEntries` CHANGE COLUMN `nick` `level` VARCHAR(20) NOT NULL;
+
+-- Angeltype contact update
+ALTER TABLE `AngelTypes` DROP FOREIGN KEY angeltypes_ibfk_1;
+ALTER TABLE `AngelTypes` DROP `contact_user_id`; \ No newline at end of file
diff --git a/includes/autoload.php b/includes/autoload.php
new file mode 100644
index 00000000..0cd9d355
--- /dev/null
+++ b/includes/autoload.php
@@ -0,0 +1,9 @@
+<?php
+
+// Check for autoloader
+if (!is_readable(__DIR__ . '/../vendor/autoload.php')) {
+ die('Please run composer.phar install');
+}
+
+// Include composer autoloader
+$loader = require __DIR__ . '/../vendor/autoload.php';
diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php
index cd2aa3e4..a47c1340 100644
--- a/includes/controller/angeltypes_controller.php
+++ b/includes/controller/angeltypes_controller.php
@@ -1,226 +1,357 @@
<?php
+use Engelsystem\ShiftsFilter;
+use Engelsystem\ShiftsFilterRenderer;
/**
* Text for Angeltype related links.
+ *
+ * @return string
*/
-function angeltypes_title() {
- return _("Angeltypes");
+function angeltypes_title()
+{
+ return _('Angeltypes');
}
/**
* Route angeltype actions.
+ *
+ * @return array
*/
-function angeltypes_controller() {
- $action = strip_request_item('action', 'list');
-
- switch ($action) {
- default:
- case 'list':
- return angeltypes_list_controller();
- case 'view':
- return angeltype_controller();
- case 'edit':
- return angeltype_edit_controller();
- case 'delete':
- return angeltype_delete_controller();
- case 'about':
- return angeltypes_about_controller();
- }
+function angeltypes_controller()
+{
+ $action = strip_request_item('action', 'list');
+
+ switch ($action) {
+ case 'view':
+ return angeltype_controller();
+ case 'edit':
+ return angeltype_edit_controller();
+ case 'delete':
+ return angeltype_delete_controller();
+ case 'about':
+ return angeltypes_about_controller();
+ case 'list':
+ default:
+ return angeltypes_list_controller();
+ }
}
/**
* Path to angeltype view.
*
- * @param AngelType $angeltype_id
+ * @param int $angeltype_id AngelType id
+ * @return string
*/
-function angeltype_link($angeltype_id) {
- return page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype_id;
+function angeltype_link($angeltype_id)
+{
+ return page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype_id]);
}
/**
* Job description for all angeltypes (public to everyone)
+ *
+ * @return array
*/
-function angeltypes_about_controller() {
- global $user;
-
- if (isset($user)) {
- $angeltypes = AngelTypes_with_user($user);
- } else {
- $angeltypes = AngelTypes();
- }
-
- return [
- _("Teams/Job description"),
- AngelTypes_about_view($angeltypes, isset($user))
- ];
+function angeltypes_about_controller()
+{
+ global $user;
+
+ if (isset($user)) {
+ $angeltypes = AngelTypes_with_user($user);
+ } else {
+ $angeltypes = AngelTypes();
+ }
+
+ return [
+ _('Teams/Job description'),
+ AngelTypes_about_view($angeltypes, isset($user))
+ ];
}
/**
* Delete an Angeltype.
+ *
+ * @return array
*/
-function angeltype_delete_controller() {
- global $privileges;
-
- if (! in_array('admin_angel_types', $privileges)) {
- redirect(page_link_to('angeltypes'));
- }
-
- $angeltype = load_angeltype();
-
- if (isset($_REQUEST['confirmed'])) {
- AngelType_delete($angeltype);
- success(sprintf(_("Angeltype %s deleted."), AngelType_name_render($angeltype)));
- redirect(page_link_to('angeltypes'));
- }
-
- return [
- sprintf(_("Delete angeltype %s"), $angeltype['name']),
- AngelType_delete_view($angeltype)
- ];
+function angeltype_delete_controller()
+{
+ global $privileges;
+
+ if (!in_array('admin_angel_types', $privileges)) {
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $angeltype = load_angeltype();
+
+ if (request()->has('confirmed')) {
+ AngelType_delete($angeltype);
+ success(sprintf(_('Angeltype %s deleted.'), AngelType_name_render($angeltype)));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ return [
+ sprintf(_('Delete angeltype %s'), $angeltype['name']),
+ AngelType_delete_view($angeltype)
+ ];
}
/**
* Change an Angeltype.
+ *
+ * @return array
*/
-function angeltype_edit_controller() {
- global $privileges, $user;
-
- // In supporter mode only allow to modify description
- $supporter_mode = ! in_array('admin_angel_types', $privileges);
-
- if (isset($_REQUEST['angeltype_id'])) {
- // Edit existing angeltype
- $angeltype = load_angeltype();
-
- if (! User_is_AngelType_supporter($user, $angeltype)) {
- redirect(page_link_to('angeltypes'));
- }
- } else {
- // New angeltype
- if ($supporter_mode) {
- // Supporters aren't allowed to create new angeltypes.
- redirect(page_link_to('angeltypes'));
+function angeltype_edit_controller()
+{
+ global $privileges, $user;
+
+ // In supporter mode only allow to modify description
+ $supporter_mode = !in_array('admin_angel_types', $privileges);
+ $request = request();
+
+ if ($request->has('angeltype_id')) {
+ // Edit existing angeltype
+ $angeltype = load_angeltype();
+
+ if (!User_is_AngelType_supporter($user, $angeltype)) {
+ redirect(page_link_to('angeltypes'));
+ }
+ } else {
+ // New angeltype
+ if ($supporter_mode) {
+ // Supporters aren't allowed to create new angeltypes.
+ redirect(page_link_to('angeltypes'));
+ }
+ $angeltype = AngelType_new();
}
- $angeltype = AngelType_new();
- }
-
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (! $supporter_mode) {
- if (isset($_REQUEST['name'])) {
- $result = AngelType_validate_name($_REQUEST['name'], $angeltype);
- $angeltype['name'] = $result->getValue();
- if (! $result->isValid()) {
- $valid = false;
- error(_("Please check the name. Maybe it already exists."));
+
+ if ($request->has('submit')) {
+ $valid = true;
+
+ if (!$supporter_mode) {
+ if ($request->has('name')) {
+ $result = AngelType_validate_name($request->postData('name'), $angeltype);
+ $angeltype['name'] = $result->getValue();
+ if (!$result->isValid()) {
+ $valid = false;
+ error(_('Please check the name. Maybe it already exists.'));
+ }
+ }
+
+ $angeltype['restricted'] = $request->has('restricted');
+ $angeltype['no_self_signup'] = $request->has('no_self_signup');
+
+ $angeltype['requires_driver_license'] = $request->has('requires_driver_license');
}
- }
-
- $angeltype['restricted'] = isset($_REQUEST['restricted']);
- $angeltype['no_self_signup'] = isset($_REQUEST['no_self_signup']);
- $angeltype['requires_driver_license'] = isset($_REQUEST['requires_driver_license']);
+ $angeltype['description'] = strip_request_item_nl('description', $angeltype['description']);
+
+ $angeltype['contact_name'] = strip_request_item('contact_name', $angeltype['contact_name']);
+ $angeltype['contact_dect'] = strip_request_item('contact_dect', $angeltype['contact_dect']);
+ $angeltype['contact_email'] = strip_request_item('contact_email', $angeltype['contact_email']);
+
+ if ($valid) {
+ if ($angeltype['id'] != null) {
+ AngelType_update($angeltype);
+ } else {
+ $angeltype = AngelType_create($angeltype);
+ }
+
+ success('Angel type saved.');
+ redirect(angeltype_link($angeltype['id']));
+ }
}
+
+ return [
+ sprintf(_('Edit %s'), $angeltype['name']),
+ AngelType_edit_view($angeltype, $supporter_mode)
+ ];
+}
+
+/**
+ * View details of a given angeltype.
+ *
+ * @return array
+ */
+function angeltype_controller()
+{
+ global $privileges, $user;
+
+ if (!in_array('angeltypes', $privileges)) {
+ redirect(page_link_to('/'));
+ }
+
+ $angeltype = load_angeltype();
+ $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
+ $user_driver_license = UserDriverLicense($user['UID']);
+ $members = Users_by_angeltype($angeltype);
+
+ $days = angeltype_controller_shiftsFilterDays($angeltype);
+ $shiftsFilter = angeltype_controller_shiftsFilter($angeltype, $days);
- $angeltype['description'] = strip_request_item_nl('description', $angeltype['description']);
+ $shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter);
+ $shiftsFilterRenderer->enableDaySelection($days);
- if ($valid) {
- if ($angeltype['id'] != null) {
- AngelType_update($angeltype);
- } else {
- $angeltype = AngelType_create($angeltype);
- }
-
- success("Angel type saved.");
- redirect(angeltype_link($angeltype['id']));
+ $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
+ $request = request();
+ $tab = 0;
+ if($request->has('shifts_filter_day')) {
+ $tab = 1;
}
- }
-
- return [
- sprintf(_("Edit %s"), $angeltype['name']),
- AngelType_edit_view($angeltype, $supporter_mode)
- ];
+
+ return [
+ sprintf(_('Team %s'), $angeltype['name']),
+ AngelType_view(
+ $angeltype,
+ $members,
+ $user_angeltype,
+ in_array('admin_user_angeltypes', $privileges) || $user_angeltype['supporter'],
+ in_array('admin_angel_types', $privileges),
+ $user_angeltype['supporter'],
+ $user_driver_license,
+ $user,
+ $shiftsFilterRenderer,
+ $shiftCalendarRenderer,
+ $tab
+ )
+ ];
}
/**
- * View details of a given angeltype.
+ * On which days do shifts for this angeltype occur? Needed for shiftCalendar.
+ *
+ * @param Angeltype $angeltype
+ * @return array
*/
-function angeltype_controller() {
- global $privileges, $user;
-
- if (! in_array('angeltypes', $privileges)) {
- redirect('?');
- }
-
- $angeltype = load_angeltype();
- $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- $user_driver_license = UserDriverLicense($user['UID']);
- $members = Users_by_angeltype($angeltype);
-
- return [
- sprintf(_("Team %s"), $angeltype['name']),
- AngelType_view($angeltype, $members, $user_angeltype, in_array('admin_user_angeltypes', $privileges) || $user_angeltype['supporter'], in_array('admin_angel_types', $privileges), $user_angeltype['supporter'], $user_driver_license, $user)
- ];
+function angeltype_controller_shiftsFilterDays($angeltype) {
+ $all_shifts = Shifts_by_angeltype($angeltype);
+ $days = [];
+ foreach ($all_shifts as $shift) {
+ $day = date('Y-m-d', $shift['start']);
+ if (!in_array($day, $days)) {
+ $days[] = $day;
+ }
+ }
+ return $days;
}
/**
- * View a list of all angeltypes.
+ * Sets up the shift filter for the angeltype.
+ *
+ * @param Angeltype $angeltype
+ * @param array $days
+ * @return ShiftsFilter
*/
-function angeltypes_list_controller() {
- global $privileges, $user;
-
- if (! in_array('angeltypes', $privileges)) {
- redirect('?');
- }
-
- $angeltypes = AngelTypes_with_user($user);
-
- foreach ($angeltypes as &$angeltype) {
- $actions = [
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("view"), "btn-xs")
- ];
+function angeltype_controller_shiftsFilter($angeltype, $days) {
+ global $privileges;
- if (in_array('admin_angel_types', $privileges)) {
- $actions[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), "btn-xs");
- $actions[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), "btn-xs");
+ $request = request();
+ $shiftsFilter = new ShiftsFilter(
+ in_array('user_shifts_admin', $privileges),
+ Room_ids(),
+ [$angeltype['id']]
+ );
+ $selected_day = date('Y-m-d');
+ if (!empty($days)) {
+ $selected_day = $days[0];
}
-
- $angeltype['membership'] = AngelType_render_membership($angeltype);
- if ($angeltype['user_angeltype_id'] != null) {
- $actions[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), "btn-xs");
- } else {
- $actions[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), "btn-xs");
+ if ($request->has('shifts_filter_day')) {
+ $selected_day = $request->input('shifts_filter_day');
}
+ $shiftsFilter->setStartTime(parse_date('Y-m-d H:i', $selected_day . ' 00:00'));
+ $shiftsFilter->setEndTime(parse_date('Y-m-d H:i', $selected_day . ' 23:59'));
- $angeltype['restricted'] = $angeltype['restricted'] ? glyph('lock') : '';
- $angeltype['no_self_signup'] = $angeltype['no_self_signup'] ? '' : glyph('share');
+ return $shiftsFilter;
+}
- $angeltype['name'] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'] . '">' . $angeltype['name'] . '</a>';
-
- $angeltype['actions'] = table_buttons($actions);
- }
-
- return [
- angeltypes_title(),
- AngelTypes_list_view($angeltypes, in_array('admin_angel_types', $privileges))
- ];
+/**
+ * View a list of all angeltypes.
+ *
+ * @return array
+ */
+function angeltypes_list_controller()
+{
+ global $privileges, $user;
+
+ if (!in_array('angeltypes', $privileges)) {
+ redirect(page_link_to('/'));
+ }
+
+ $angeltypes = AngelTypes_with_user($user);
+
+ foreach ($angeltypes as &$angeltype) {
+ $actions = [
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('view'),
+ 'btn-xs'
+ )
+ ];
+
+ if (in_array('admin_angel_types', $privileges)) {
+ $actions[] = button(
+ page_link_to('angeltypes', ['action' => 'edit', 'angeltype_id' => $angeltype['id']]),
+ _('edit'),
+ 'btn-xs'
+ );
+ $actions[] = button(
+ page_link_to('angeltypes', ['action' => 'delete', 'angeltype_id' => $angeltype['id']]),
+ _('delete'),
+ 'btn-xs'
+ );
+ }
+
+ $angeltype['membership'] = AngelType_render_membership($angeltype);
+ if ($angeltype['user_angeltype_id'] != null) {
+ $actions[] = button(
+ page_link_to('user_angeltypes',
+ ['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']]
+ ),
+ _('leave'),
+ 'btn-xs'
+ );
+ } else {
+ $actions[] = button(
+ page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
+ _('join'),
+ 'btn-xs'
+ );
+ }
+
+ $angeltype['restricted'] = $angeltype['restricted'] ? glyph('lock') : '';
+ $angeltype['no_self_signup'] = $angeltype['no_self_signup'] ? '' : glyph('share');
+
+ $angeltype['name'] = '<a href="'
+ . page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']])
+ . '">'
+ . $angeltype['name']
+ . '</a>';
+
+ $angeltype['actions'] = table_buttons($actions);
+ }
+
+ return [
+ angeltypes_title(),
+ AngelTypes_list_view($angeltypes, in_array('admin_angel_types', $privileges))
+ ];
}
/**
* Loads an angeltype from given angeltype_id request param.
+ *
+ * @return array
*/
-function load_angeltype() {
- if (! isset($_REQUEST['angeltype_id'])) {
- redirect(page_link_to('angeltypes'));
- }
-
- $angeltype = AngelType($_REQUEST['angeltype_id']);
- if ($angeltype == null) {
- error(_("Angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- return $angeltype;
+function load_angeltype()
+{
+ $request = request();
+ if (!$request->has('angeltype_id')) {
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $angeltype = AngelType($request->input('angeltype_id'));
+ if ($angeltype == null) {
+ error(_('Angeltype doesn\'t exist . '));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ return $angeltype;
}
-?>
diff --git a/includes/controller/event_config_controller.php b/includes/controller/event_config_controller.php
index 4f07fe4c..aa328802 100644
--- a/includes/controller/event_config_controller.php
+++ b/includes/controller/event_config_controller.php
@@ -1,103 +1,129 @@
<?php
-function event_config_title() {
- return _("Event config");
+/**
+ * @return string
+ */
+function event_config_title()
+{
+ return _('Event config');
}
-function event_config_edit_controller() {
- global $privileges;
-
- if (! in_array('admin_event_config', $privileges)) {
- redirect('?');
- }
-
- $event_name = null;
- $event_welcome_msg = null;
- $buildup_start_date = null;
- $event_start_date = null;
- $event_end_date = null;
- $teardown_end_date = null;
-
- $event_config = EventConfig();
- if ($event_config != null) {
- $event_name = $event_config['event_name'];
- $buildup_start_date = $event_config['buildup_start_date'];
- $event_start_date = $event_config['event_start_date'];
- $event_end_date = $event_config['event_end_date'];
- $teardown_end_date = $event_config['teardown_end_date'];
- $event_welcome_msg = $event_config['event_welcome_msg'];
- }
-
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (isset($_REQUEST['event_name'])) {
- $event_name = strip_request_item('event_name');
- }
- if ($event_name == '') {
- $event_name = null;
- }
-
- if (isset($_REQUEST['event_welcome_msg'])) {
- $event_welcome_msg = strip_request_item_nl('event_welcome_msg');
- }
- if ($event_welcome_msg == '') {
- $event_welcome_msg = null;
- }
-
- $result = check_request_date('buildup_start_date', _("Please enter buildup start date."), true);
- $buildup_start_date = $result->getValue();
- $valid &= $result->isValid();
-
- $result = check_request_date('event_start_date', _("Please enter event start date."), true);
- $event_start_date = $result->getValue();
- $valid &= $result->isValid();
-
- $result = check_request_date('event_end_date', _("Please enter event end date."), true);
- $event_end_date = $result->getValue();
- $valid &= $result->isValid();
-
- $result = check_request_date('teardown_end_date', _("Please enter teardown end date."), true);
- $teardown_end_date = $result->getValue();
- $valid &= $result->isValid();
-
- if ($buildup_start_date != null && $event_start_date != null && $buildup_start_date > $event_start_date) {
- $valid = false;
- error(_("The buildup start date has to be before the event start date."));
- }
-
- if ($event_start_date != null && $event_end_date != null && $event_start_date > $event_end_date) {
- $valid = false;
- error(_("The event start date has to be before the event end date."));
- }
-
- if ($event_end_date != null && $teardown_end_date != null && $event_end_date > $teardown_end_date) {
- $valid = false;
- error(_("The event end date has to be before the teardown end date."));
+/**
+ * @return array
+ */
+function event_config_edit_controller()
+{
+ global $privileges;
+
+ if (!in_array('admin_event_config', $privileges)) {
+ redirect(page_link_to('/'));
}
-
- if ($buildup_start_date != null && $teardown_end_date != null && $buildup_start_date > $teardown_end_date) {
- $valid = false;
- error(_("The buildup start date has to be before the teardown end date."));
+
+ $request = request();
+ $event_name = null;
+ $event_welcome_msg = null;
+ $buildup_start_date = null;
+ $event_start_date = null;
+ $event_end_date = null;
+ $teardown_end_date = null;
+
+ $event_config = EventConfig();
+ if ($event_config != null) {
+ $event_name = $event_config['event_name'];
+ $buildup_start_date = $event_config['buildup_start_date'];
+ $event_start_date = $event_config['event_start_date'];
+ $event_end_date = $event_config['event_end_date'];
+ $teardown_end_date = $event_config['teardown_end_date'];
+ $event_welcome_msg = $event_config['event_welcome_msg'];
}
-
- if ($valid) {
- $result = EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg);
-
- if ($result === false) {
- engelsystem_error("Unable to update event config.");
- }
-
- engelsystem_log("Changed event config: $event_name, $event_welcome_msg, " . date("Y-m-d", $buildup_start_date) . ", " . date("Y-m-d", $event_start_date) . ", " . date("Y-m-d", $event_end_date) . ", " . date("Y-m-d", $teardown_end_date));
- success(_("Settings saved."));
- redirect(page_link_to('admin_event_config'));
+
+ if ($request->has('submit')) {
+ $valid = true;
+
+ if ($request->has('event_name')) {
+ $event_name = strip_request_item('event_name');
+ }
+ if ($event_name == '') {
+ $event_name = null;
+ }
+
+ if ($request->has('event_welcome_msg')) {
+ $event_welcome_msg = strip_request_item_nl('event_welcome_msg');
+ }
+ if ($event_welcome_msg == '') {
+ $event_welcome_msg = null;
+ }
+
+ $result = check_request_date('buildup_start_date', _('Please enter buildup start date.'), true);
+ $buildup_start_date = $result->getValue();
+ $valid &= $result->isValid();
+
+ $result = check_request_date('event_start_date', _('Please enter event start date.'), true);
+ $event_start_date = $result->getValue();
+ $valid &= $result->isValid();
+
+ $result = check_request_date('event_end_date', _('Please enter event end date.'), true);
+ $event_end_date = $result->getValue();
+ $valid &= $result->isValid();
+
+ $result = check_request_date('teardown_end_date', _('Please enter teardown end date.'), true);
+ $teardown_end_date = $result->getValue();
+ $valid &= $result->isValid();
+
+ if ($buildup_start_date != null && $event_start_date != null && $buildup_start_date > $event_start_date) {
+ $valid = false;
+ error(_('The buildup start date has to be before the event start date.'));
+ }
+
+ if ($event_start_date != null && $event_end_date != null && $event_start_date > $event_end_date) {
+ $valid = false;
+ error(_('The event start date has to be before the event end date.'));
+ }
+
+ if ($event_end_date != null && $teardown_end_date != null && $event_end_date > $teardown_end_date) {
+ $valid = false;
+ error(_('The event end date has to be before the teardown end date.'));
+ }
+
+ if ($buildup_start_date != null && $teardown_end_date != null && $buildup_start_date > $teardown_end_date) {
+ $valid = false;
+ error(_('The buildup start date has to be before the teardown end date.'));
+ }
+
+ if ($valid) {
+ EventConfig_update(
+ $event_name,
+ $buildup_start_date,
+ $event_start_date,
+ $event_end_date,
+ $teardown_end_date,
+ $event_welcome_msg
+ );
+
+ engelsystem_log(
+ sprintf('Changed event config: %s, %s, %s, %s, %s, %s',
+ $event_name,
+ $event_welcome_msg,
+ date('Y-m-d', $buildup_start_date),
+ date('Y-m-d', $event_start_date),
+ date('Y-m-d', $event_end_date),
+ date('Y-m-d', $teardown_end_date)
+ )
+ );
+ success(_('Settings saved.'));
+ redirect(page_link_to('admin_event_config'));
+ }
}
- }
-
- return [
- event_config_title(),
- EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date)
- ];
-}
-?> \ No newline at end of file
+ return [
+ event_config_title(),
+ EventConfig_edit_view(
+ $event_name,
+ $event_welcome_msg,
+ $buildup_start_date,
+ $event_start_date,
+ $event_end_date,
+ $teardown_end_date
+ )
+ ];
+}
diff --git a/includes/controller/rooms_controller.php b/includes/controller/rooms_controller.php
index bba38bb5..d6da9709 100644
--- a/includes/controller/rooms_controller.php
+++ b/includes/controller/rooms_controller.php
@@ -1,7 +1,7 @@
<?php
-use Engelsystem\ShiftsFilterRenderer;
+
use Engelsystem\ShiftsFilter;
-use Engelsystem\ShiftCalendarRenderer;
+use Engelsystem\ShiftsFilterRenderer;
/**
* Room controllers for managing everything room related.
@@ -9,93 +9,114 @@ use Engelsystem\ShiftCalendarRenderer;
/**
* View a room with its shifts.
+ *
+ * @return array
*/
-function room_controller() {
- global $privileges;
-
- if (! in_array('view_rooms', $privileges)) {
- redirect(page_link_to());
- }
-
-
- $room = load_room();
-
- if($room['show'] != 'Y' && !in_array('admin_rooms', $privileges)) {
- redirect(page_link_to());
- }
-
- $all_shifts = Shifts_by_room($room);
- $days = [];
- foreach ($all_shifts as $shift) {
- $day = date("Y-m-d", $shift['start']);
- if (! in_array($day, $days)) {
- $days[] = $day;
+function room_controller()
+{
+ global $privileges;
+
+ if (!in_array('view_rooms', $privileges)) {
+ redirect(page_link_to());
}
- }
-
- $shiftsFilter = new ShiftsFilter(true, [
- $room['RID']
- ], AngelType_ids());
- $selected_day = date("Y-m-d");
- if (! empty($days)) {
- $selected_day = $days[0];
- }
- if (isset($_REQUEST['shifts_filter_day'])) {
- $selected_day = $_REQUEST['shifts_filter_day'];
- }
- $shiftsFilter->setStartTime(parse_date("Y-m-d H:i", $selected_day . ' 00:00'));
- $shiftsFilter->setEndTime(parse_date("Y-m-d H:i", $selected_day . ' 23:59'));
-
- $shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter);
- $shiftsFilterRenderer->enableDaySelection($days);
-
- $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
-
- return [
- $room['Name'],
- Room_view($room, $shiftsFilterRenderer, $shiftCalendarRenderer)
- ];
+
+ $request = request();
+ $room = load_room(false);
+ if ($room['show'] != 'Y' && !in_array('admin_rooms', $privileges)) {
+ redirect(page_link_to());
+ }
+
+ $all_shifts = Shifts_by_room($room);
+ $days = [];
+ foreach ($all_shifts as $shift) {
+ $day = date('Y-m-d', $shift['start']);
+ if (!in_array($day, $days)) {
+ $days[] = $day;
+ }
+ }
+
+ $shiftsFilter = new ShiftsFilter(
+ true,
+ [$room['RID']],
+ AngelType_ids()
+ );
+ $selected_day = date('Y-m-d');
+ if (!empty($days)) {
+ $selected_day = $days[0];
+ }
+ if ($request->has('shifts_filter_day')) {
+ $selected_day = $request->input('shifts_filter_day');
+ }
+ $shiftsFilter->setStartTime(parse_date('Y-m-d H:i', $selected_day . ' 00:00'));
+ $shiftsFilter->setEndTime(parse_date('Y-m-d H:i', $selected_day . ' 23:59'));
+
+ $shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter);
+ $shiftsFilterRenderer->enableDaySelection($days);
+
+ $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
+
+ return [
+ $room['Name'],
+ Room_view($room, $shiftsFilterRenderer, $shiftCalendarRenderer)
+ ];
}
/**
* Dispatch different room actions.
+ *
+ * @return array
*/
-function rooms_controller() {
- if (! isset($_REQUEST['action'])) {
- $_REQUEST['action'] = 'list';
- }
-
- switch ($_REQUEST['action']) {
- default:
- case 'list':
- redirect(page_link_to('admin_rooms'));
- case 'view':
- return room_controller();
- }
+function rooms_controller()
+{
+ $request = request();
+ $action = $request->input('action');
+ if (!$request->has('action')) {
+ $action = 'list';
+ }
+
+ switch ($action) {
+ case 'view':
+ return room_controller();
+ case 'list':
+ default:
+ redirect(page_link_to('admin_rooms'));
+ }
}
-function room_link($room) {
- return page_link_to('rooms') . '&action=view&room_id=' . $room['RID'];
+/**
+ * @param array $room
+ * @return string
+ */
+function room_link($room)
+{
+ return page_link_to('rooms', ['action' => 'view', 'room_id' => $room['RID']]);
}
-function room_edit_link($room) {
- return page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID'];
+/**
+ * @param array $room
+ * @return string
+ */
+function room_edit_link($room)
+{
+ return page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]);
}
/**
* Loads room by request param room_id
+ *
+ * @param bool $onlyVisible
+ * @return array
*/
-function load_room() {
- if (! test_request_int('room_id')) {
- redirect(page_link_to());
- }
-
- $room = Room($_REQUEST['room_id']);
- if ($room == null) {
- redirect(page_link_to());
- }
-
- return $room;
-}
+function load_room($onlyVisible = true)
+{
+ if (!test_request_int('room_id')) {
+ redirect(page_link_to());
+ }
-?> \ No newline at end of file
+ $room = Room(request()->input('room_id'), $onlyVisible);
+ if ($room == null) {
+ redirect(page_link_to());
+ }
+
+ return $room;
+}
diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php
index d0a12288..6a471122 100644
--- a/includes/controller/shift_entries_controller.php
+++ b/includes/controller/shift_entries_controller.php
@@ -1,187 +1,290 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Sign up for a shift.
+ *
+ * @return string
*/
-function shift_entry_add_controller() {
- global $privileges, $user;
-
- if (isset($_REQUEST['shift_id']) && preg_match("/^[0-9]*$/", $_REQUEST['shift_id'])) {
- $shift_id = $_REQUEST['shift_id'];
- } else {
- redirect(page_link_to('user_shifts'));
- }
-
- // Locations laden
- $rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
- $room_array = [];
- foreach ($rooms as $room) {
- $room_array[$room['RID']] = $room['Name'];
- }
-
- $shift = Shift($shift_id);
- $shift['Name'] = $room_array[$shift['RID']];
- if ($shift == null) {
- redirect(page_link_to('user_shifts'));
- }
-
- if (isset($_REQUEST['type_id']) && preg_match("/^[0-9]*$/", $_REQUEST['type_id'])) {
- $type_id = $_REQUEST['type_id'];
- } else {
- redirect(page_link_to('user_shifts'));
- }
-
- if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
- $type = AngelType($type_id);
- } else {
- $type = sql_select("SELECT * FROM `UserAngelTypes` JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`) WHERE `AngelTypes`.`id` = '" . sql_escape($type_id) . "' AND (`AngelTypes`.`restricted` = 0 OR (`UserAngelTypes`.`user_id` = '" . sql_escape($user['UID']) . "' AND NOT `UserAngelTypes`.`confirm_user_id` IS NULL))");
- $type = $type[0];
- }
-
- if ($type == null) {
- redirect(page_link_to('user_shifts'));
- }
-
- if (isset($_REQUEST['user_id']) && preg_match("/^[0-9]*$/", $_REQUEST['user_id']) && (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges))) {
- $user_id = $_REQUEST['user_id'];
- } else {
- $user_id = $user['UID'];
- }
-
- $needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $type);
- $shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $type['id']);
-
- $shift_signup_allowed = Shift_signup_allowed(User($user_id), $shift, $type, null, null, $needed_angeltype, $shift_entries);
- if (! $shift_signup_allowed->isSignupAllowed()) {
- error(_("You are not allowed to sign up for this shift. Maybe shift is full or already running."));
- redirect(shift_link($shift));
- }
-
- if (isset($_REQUEST['submit'])) {
- $selected_type_id = $type_id;
- if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
-
- if (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1") == 0) {
+function shift_entry_add_controller()
+{
+ global $privileges, $user;
+
+ $request = request();
+ $shift_id = 0;
+ if ($request->has('shift_id') && preg_match('/^\d+$/', $request->input('shift_id'))) {
+ $shift_id = $request->input('shift_id');
+ } else {
redirect(page_link_to('user_shifts'));
- }
-
- if (isset($_REQUEST['angeltype_id']) && test_request_int('angeltype_id') && sql_num_query("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($_REQUEST['angeltype_id']) . "' LIMIT 1") > 0) {
- $selected_type_id = $_REQUEST['angeltype_id'];
- }
}
-
- if (sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`='" . sql_escape($shift['SID']) . "' AND `UID` = '" . sql_escape($user_id) . "'")) {
- return error("This angel does already have an entry for this shift.", true);
+
+ // Locations laden
+ $rooms = Rooms();
+ $room_array = [];
+ foreach ($rooms as $room) {
+ $room_array[$room['RID']] = $room['Name'];
}
-
- $freeloaded = $shift['freeloaded'];
- $freeload_comment = $shift['freeload_comment'];
- if (in_array("user_shifts_admin", $privileges)) {
- $freeloaded = isset($_REQUEST['freeloaded']);
- $freeload_comment = strip_request_item_nl('freeload_comment');
+
+ $shift = Shift($shift_id);
+ if ($shift == null) {
+ redirect(page_link_to('user_shifts'));
+ }
+ $shift['Name'] = $room_array[$shift['RID']];
+
+ $type_id = null;
+ if ($request->has('type_id') && preg_match('/^\d+$/', $request->input('type_id'))) {
+ $type_id = $request->input('type_id');
}
-
- $comment = strip_request_item_nl('comment');
- $result = ShiftEntry_create([
- 'SID' => $shift_id,
- 'TID' => $selected_type_id,
- 'UID' => $user_id,
- 'Comment' => $comment,
- 'freeloaded' => $freeloaded,
- 'freeload_comment' => $freeload_comment
- ]);
- if ($result === false) {
- engelsystem_error('Unable to create shift entry.');
+
+ if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
+ if($type_id == null) {
+ // If no angeltype id is given, then select first existing angeltype.
+ $needed_angeltypes = NeededAngelTypes_by_shift($shift_id);
+ if(count($needed_angeltypes) > 0) {
+ $type_id = $needed_angeltypes[0]['id'];
+ }
+ }
+ $type = AngelType($type_id);
+ } else {
+ // TODO: Move queries to model
+ $type = DB::selectOne('
+ SELECT *
+ FROM `UserAngelTypes`
+ JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`)
+ WHERE `AngelTypes`.`id` = ?
+ AND (
+ `AngelTypes`.`restricted` = 0
+ OR (
+ `UserAngelTypes`.`user_id` = ?
+ AND NOT `UserAngelTypes`.`confirm_user_id` IS NULL
+ )
+ )
+ ', [$type_id, $user['UID']]);
}
-
- if ($type['restricted'] == 0 && sql_num_query("SELECT * FROM `UserAngelTypes` INNER JOIN `AngelTypes` ON `AngelTypes`.`id` = `UserAngelTypes`.`angeltype_id` WHERE `angeltype_id` = '" . sql_escape($selected_type_id) . "' AND `user_id` = '" . sql_escape($user_id) . "'") == 0) {
- sql_query("INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES ('" . sql_escape($user_id) . "', '" . sql_escape($selected_type_id) . "')");
+
+ if (empty($type)) {
+ redirect(page_link_to('user_shifts'));
}
-
- $user_source = User($user_id);
- engelsystem_log("User " . User_Nick_render($user_source) . " signed up for shift " . $shift['name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']));
- success(_("You are subscribed. Thank you!") . ' <a href="' . page_link_to('user_myshifts') . '">' . _("My shifts") . ' &raquo;</a>');
- redirect(shift_link($shift));
- }
-
- if (in_array('user_shifts_admin', $privileges)) {
- $users = sql_select("SELECT *, (SELECT count(*) FROM `ShiftEntry` WHERE `freeloaded`=1 AND `ShiftEntry`.`UID`=`User`.`UID`) AS `freeloaded` FROM `User` ORDER BY `Nick`");
- $users_select = [];
- foreach ($users as $usr) {
- $users_select[$usr['UID']] = $usr['Nick'] . ($usr['freeloaded'] == 0 ? "" : " (" . _("Freeloader") . ")");
+
+ if (
+ $request->has('user_id')
+ && preg_match('/^\d+$/', $request->input('user_id'))
+ && (
+ in_array('user_shifts_admin', $privileges)
+ || in_array('shiftentry_edit_angeltype_supporter', $privileges)
+ )
+ ) {
+ $user_id = $request->input('user_id');
+ } else {
+ $user_id = $user['UID'];
}
- $user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
-
- $angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
- $angeltypes = [];
- foreach ($angeltypes_source as $angeltype) {
- $angeltypes[$angeltype['id']] = $angeltype['name'];
+
+ $needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $type);
+ $shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $type['id']);
+
+ $shift_signup_allowed = Shift_signup_allowed(
+ User($user_id),
+ $shift,
+ $type,
+ null,
+ null,
+ $needed_angeltype,
+ $shift_entries
+ );
+ if (!$shift_signup_allowed->isSignupAllowed()) {
+ error(_('You are not allowed to sign up for this shift. Maybe shift is full or already running.'));
+ redirect(shift_link($shift));
}
- $angeltype_select = html_select_key('angeltype_id', 'angeltype_id', $angeltypes, $type['id']);
- } elseif (in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
- $users = Users_by_angeltype($type);
- $users_select = [];
- foreach ($users as $usr) {
- if (! $type['restricted'] || $usr['confirm_user_id'] != null) {
- $users_select[$usr['UID']] = $usr['Nick'];
- }
+
+ if ($request->has('submit')) {
+ $selected_type_id = $type_id;
+ if (in_array('user_shifts_admin', $privileges) || in_array('shiftentry_edit_angeltype_supporter',
+ $privileges)
+ ) {
+
+ if (count(DB::select('SELECT `UID` FROM `User` WHERE `UID`=? LIMIT 1', [$user_id])) == 0) {
+ redirect(page_link_to('user_shifts'));
+ }
+
+ if (
+ $request->has('angeltype_id')
+ && test_request_int('angeltype_id')
+ && count(DB::select(
+ 'SELECT `id` FROM `AngelTypes` WHERE `id`=? LIMIT 1',
+ [$request->input('angeltype_id')]
+ )) > 0
+ ) {
+ $selected_type_id = $request->input('angeltype_id');
+ }
+ }
+
+ if (count(DB::select(
+ 'SELECT `id` FROM `ShiftEntry` WHERE `SID`= ? AND `UID` = ?',
+ [$shift['SID'], $user_id]))
+ ) {
+ return error('This angel does already have an entry for this shift.', true);
+ }
+
+ $freeloaded = isset($shift['freeloaded']) ? $shift['freeloaded'] : false;
+ $freeload_comment = isset($shift['freeload_comment']) ? $shift['freeload_comment'] : '';
+ if (in_array('user_shifts_admin', $privileges)) {
+ $freeloaded = $request->has('freeloaded');
+ $freeload_comment = strip_request_item_nl('freeload_comment');
+ }
+
+ $comment = strip_request_item_nl('comment');
+ ShiftEntry_create([
+ 'SID' => $shift_id,
+ 'TID' => $selected_type_id,
+ 'UID' => $user_id,
+ 'Comment' => $comment,
+ 'freeloaded' => $freeloaded,
+ 'freeload_comment' => $freeload_comment
+ ]);
+
+ if (
+ $type['restricted'] == 0
+ && count(DB::select('
+ SELECT `UserAngelTypes`.`id` FROM `UserAngelTypes`
+ INNER JOIN `AngelTypes` ON `AngelTypes`.`id` = `UserAngelTypes`.`angeltype_id`
+ WHERE `angeltype_id` = ?
+ AND `user_id` = ?
+ ', [$selected_type_id, $user_id])) == 0
+ ) {
+ DB::insert(
+ 'INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`) VALUES (?, ?)',
+ [$user_id, $selected_type_id]
+ );
+ }
+
+ $user_source = User($user_id);
+ engelsystem_log(
+ 'User ' . User_Nick_render($user_source)
+ . ' signed up for shift ' . $shift['name']
+ . ' from ' . date('Y-m-d H:i', $shift['start'])
+ . ' to ' . date('Y-m-d H:i', $shift['end'])
+ );
+ success(_('You are subscribed. Thank you!') . ' <a href="' . page_link_to('user_myshifts') . '">' . _('My shifts') . ' &raquo;</a>');
+ redirect(shift_link($shift));
}
- $user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
-
- $angeltypes_source = User_angeltypes($user);
- $angeltypes = [];
- foreach ($angeltypes_source as $angeltype) {
- if ($angeltype['supporter']) {
- $angeltypes[$angeltype['id']] = $angeltype['name'];
- }
- $angeltype_select = html_select_key('angeltype_id', 'angeltype_id', $angeltypes, $type['id']);
+
+ $angeltype_select = '';
+ if (in_array('user_shifts_admin', $privileges)) {
+ $users = DB::select('
+ SELECT *,
+ (
+ SELECT count(*)
+ FROM `ShiftEntry`
+ WHERE `freeloaded`=1
+ AND `ShiftEntry`.`UID`=`User`.`UID`
+ ) AS `freeloaded`
+ FROM `User`
+ ORDER BY `Nick`
+ ');
+ $users_select = [];
+ foreach ($users as $usr) {
+ $users_select[$usr['UID']] = $usr['Nick'] . ($usr['freeloaded'] == 0 ? '' : ' (' . _('Freeloader') . ')');
+ }
+ $user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
+
+ $angeltypes_source = DB::select('SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`');
+ $angeltypes = [];
+ foreach ($angeltypes_source as $angeltype) {
+ $angeltypes[$angeltype['id']] = $angeltype['name'];
+ }
+ $angeltype_select = html_select_key('angeltype_id', 'angeltype_id', $angeltypes, $type['id']);
+ } elseif (in_array('shiftentry_edit_angeltype_supporter', $privileges)) {
+ $users = Users_by_angeltype($type);
+ $users_select = [];
+ foreach ($users as $usr) {
+ if (!$type['restricted'] || $usr['confirm_user_id'] != null) {
+ $users_select[$usr['UID']] = $usr['Nick'];
+ }
+ }
+ $user_text = html_select_key('user_id', 'user_id', $users_select, $user['UID']);
+
+ $angeltypes_source = User_angeltypes($user);
+ $angeltypes = [];
+ foreach ($angeltypes_source as $angeltype) {
+ if ($angeltype['supporter']) {
+ $angeltypes[$angeltype['id']] = $angeltype['name'];
+ }
+ $angeltype_select = html_select_key('angeltype_id', 'angeltype_id', $angeltypes, $type['id']);
+ }
+ } else {
+ $user_text = User_Nick_render($user);
+ $angeltype_select = $type['name'];
}
- } else {
- $user_text = User_Nick_render($user);
- $angeltype_select = $type['name'];
- }
-
- return ShiftEntry_edit_view($user_text, date("Y-m-d H:i", $shift['start']) . ' &ndash; ' . date('Y-m-d H:i', $shift['end']) . ' (' . shift_length($shift) . ')', $shift['Name'], $shift['name'], $angeltype_select, "", false, null, in_array('user_shifts_admin', $privileges));
+
+ return ShiftEntry_edit_view(
+ $user_text,
+ date('Y-m-d H:i', $shift['start'])
+ . ' &ndash; '
+ . date('Y-m-d H:i', $shift['end'])
+ . ' (' . shift_length($shift) . ')',
+ $shift['Name'],
+ $shift['name'],
+ $angeltype_select, '',
+ false,
+ null,
+ in_array('user_shifts_admin', $privileges)
+ );
}
/**
* Remove somebody from a shift.
*/
-function shift_entry_delete_controller() {
- global $privileges, $user;
-
- if (! isset($_REQUEST['entry_id']) || ! test_request_int('entry_id')) {
- redirect(page_link_to('user_shifts'));
- }
- $entry_id = $_REQUEST['entry_id'];
-
- $shift_entry_source = sql_select("
- SELECT `User`.`Nick`, `ShiftEntry`.`Comment`, `ShiftEntry`.`UID`, `ShiftTypes`.`name`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type`, `AngelTypes`.`id` as `angeltype_id`
+function shift_entry_delete_controller()
+{
+ global $privileges, $user;
+ $request = request();
+
+ if (!$request->has('entry_id') || !test_request_int('entry_id')) {
+ redirect(page_link_to('user_shifts'));
+ }
+ $entry_id = $request->input('entry_id');
+
+ $shift_entry_source = DB::selectOne('
+ SELECT
+ `User`.`Nick`,
+ `User`.`Gekommen`,
+ `ShiftEntry`.`Comment`,
+ `ShiftEntry`.`UID`,
+ `ShiftTypes`.`name`,
+ `Shifts`.*,
+ `Room`.`Name`,
+ `AngelTypes`.`name` AS `angel_type`,
+ `AngelTypes`.`id` AS `angeltype_id`
FROM `ShiftEntry`
JOIN `User` ON (`User`.`UID`=`ShiftEntry`.`UID`)
JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`)
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
- WHERE `ShiftEntry`.`id`='" . sql_escape($entry_id) . "'");
- if (count($shift_entry_source) > 0) {
- $shift_entry_source = $shift_entry_source[0];
-
- if (!in_array('user_shifts_admin', $privileges) && (!in_array('shiftentry_edit_angeltype_supporter', $privileges) || !User_is_AngelType_supporter($user, AngelType($shift_entry_source['angeltype_id'])))) {
- redirect(page_link_to('user_shifts'));
- }
-
- $result = ShiftEntry_delete($entry_id);
- if ($result === false) {
- engelsystem_error('Unable to delete shift entry.');
+ WHERE `ShiftEntry`.`id`=?',
+ [$entry_id]
+ );
+ if (!empty($shift_entry_source)) {
+ if (!in_array('user_shifts_admin', $privileges) && (!in_array('shiftentry_edit_angeltype_supporter',
+ $privileges) || !User_is_AngelType_supporter($user, AngelType($shift_entry_source['angeltype_id'])))
+ ) {
+ redirect(page_link_to('user_shifts'));
+ }
+
+ ShiftEntry_delete($entry_id);
+
+ engelsystem_log(
+ 'Deleted ' . User_Nick_render($shift_entry_source) . '\'s shift: ' . $shift_entry_source['name']
+ . ' at ' . $shift_entry_source['Name']
+ . ' from ' . date('Y-m-d H:i', $shift_entry_source['start'])
+ . ' to ' . date('Y-m-d H:i', $shift_entry_source['end'])
+ . ' as ' . $shift_entry_source['angel_type']
+ );
+ success(_('Shift entry deleted.'));
+ } else {
+ error(_('Entry not found.'));
}
-
- engelsystem_log("Deleted " . User_Nick_render($shift_entry_source) . "'s shift: " . $shift_entry_source['name'] . " at " . $shift_entry_source['Name'] . " from " . date("Y-m-d H:i", $shift_entry_source['start']) . " to " . date("Y-m-d H:i", $shift_entry_source['end']) . " as " . $shift_entry_source['angel_type']);
- success(_("Shift entry deleted."));
- } else {
- error(_("Entry not found."));
- }
- redirect(shift_link($shift_entry_source));
-}
-?> \ No newline at end of file
+ redirect(shift_link($shift_entry_source));
+}
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index 9ac8a766..739ba009 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -1,324 +1,405 @@
<?php
+
use Engelsystem\ShiftSignupState;
-function shift_link($shift) {
- return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID'];
+/**
+ * @param array $shift
+ * @return string
+ */
+function shift_link($shift)
+{
+ $parameters = ['action' => 'view'];
+ if (isset($shift['SID'])) {
+ $parameters['shift_id'] = $shift['SID'];
+ }
+
+ $link = page_link_to('shifts', $parameters);
+
+ return $link;
}
-function shift_delete_link($shift) {
- return page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'];
+/**
+ * @param array $shift
+ * @return string
+ */
+function shift_delete_link($shift)
+{
+ return page_link_to('user_shifts', ['delete_shift' => $shift['SID']]);
}
-function shift_edit_link($shift) {
- return page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'];
+/**
+ * @param array $shift
+ * @return string
+ */
+function shift_edit_link($shift)
+{
+ return page_link_to('user_shifts', ['edit_shift' => $shift['SID']]);
}
/**
* Edit a single shift.
+ *
+ * @return string
*/
-function shift_edit_controller() {
- global $privileges;
-
- // Schicht bearbeiten
- $msg = "";
- $valid = true;
-
- if (! in_array('admin_shifts', $privileges)) {
- redirect(page_link_to('user_shifts'));
- }
-
- if (! isset($_REQUEST['edit_shift']) || ! test_request_int('edit_shift')) {
- redirect(page_link_to('user_shifts'));
- }
- $shift_id = $_REQUEST['edit_shift'];
-
- $shift = Shift($shift_id);
-
- $room = select_array(Rooms(), 'RID', 'Name');
- $angeltypes = select_array(AngelTypes(), 'id', 'name');
- $shifttypes = select_array(ShiftTypes(), 'id', 'name');
-
- $needed_angel_types = select_array(NeededAngelTypes_by_shift($shift_id), 'id', 'count');
- foreach (array_keys($angeltypes) as $angeltype_id) {
- if (! isset($needed_angel_types[$angeltype_id])) {
- $needed_angel_types[$angeltype_id] = 0;
+function shift_edit_controller()
+{
+ global $privileges;
+
+ // Schicht bearbeiten
+ $msg = '';
+ $valid = true;
+ $request = request();
+
+ if (!in_array('admin_shifts', $privileges)) {
+ redirect(page_link_to('user_shifts'));
+ }
+
+ if (!$request->has('edit_shift') || !test_request_int('edit_shift')) {
+ redirect(page_link_to('user_shifts'));
}
- }
-
- $shifttype_id = $shift['shifttype_id'];
- $title = $shift['title'];
- $rid = $shift['RID'];
- $start = $shift['start'];
- $end = $shift['end'];
-
- if (isset($_REQUEST['submit'])) {
- // Name/Bezeichnung der Schicht, darf leer sein
- $title = strip_request_item('title');
-
- // Auswahl der sichtbaren Locations für die Schichten
- if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room[$_REQUEST['rid']])) {
- $rid = $_REQUEST['rid'];
- } else {
- $valid = false;
- $msg .= error(_("Please select a room."), true);
+ $shift_id = $request->input('edit_shift');
+
+ $shift = Shift($shift_id);
+
+ $room = select_array(Rooms(), 'RID', 'Name');
+ $angeltypes = select_array(AngelTypes(), 'id', 'name');
+ $shifttypes = select_array(ShiftTypes(), 'id', 'name');
+
+ $needed_angel_types = select_array(NeededAngelTypes_by_shift($shift_id), 'angel_type_id', 'count');
+ foreach (array_keys($angeltypes) as $angeltype_id) {
+ if (!isset($needed_angel_types[$angeltype_id])) {
+ $needed_angel_types[$angeltype_id] = 0;
+ }
}
-
- if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
- $shifttype_id = $_REQUEST['shifttype_id'];
- } else {
- $valid = false;
- $msg .= error(_('Please select a shifttype.'), true);
+
+ $shifttype_id = $shift['shifttype_id'];
+ $title = $shift['title'];
+ $rid = $shift['RID'];
+ $start = $shift['start'];
+ $end = $shift['end'];
+
+ if ($request->has('submit')) {
+ // Name/Bezeichnung der Schicht, darf leer sein
+ $title = strip_request_item('title');
+
+ // Auswahl der sichtbaren Locations für die Schichten
+ if (
+ $request->has('rid')
+ && preg_match('/^\d+$/', $request->input('rid'))
+ && isset($room[$request->input('rid')])
+ ) {
+ $rid = $request->input('rid');
+ } else {
+ $valid = false;
+ $msg .= error(_('Please select a room.'), true);
+ }
+
+ if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) {
+ $shifttype_id = $request->input('shifttype_id');
+ } else {
+ $valid = false;
+ $msg .= error(_('Please select a shifttype.'), true);
+ }
+
+ if ($request->has('start') && $tmp = parse_date('Y-m-d H:i', $request->input('start'))) {
+ $start = $tmp;
+ } else {
+ $valid = false;
+ $msg .= error(_('Please enter a valid starting time for the shifts.'), true);
+ }
+
+ if ($request->has('end') && $tmp = parse_date('Y-m-d H:i', $request->input('end'))) {
+ $end = $tmp;
+ } else {
+ $valid = false;
+ $msg .= error(_('Please enter a valid ending time for the shifts.'), true);
+ }
+
+ if ($start >= $end) {
+ $valid = false;
+ $msg .= error(_('The ending time has to be after the starting time.'), true);
+ }
+
+ foreach ($needed_angel_types as $needed_angeltype_id => $count) {
+ $needed_angel_types[$needed_angeltype_id] = 0;
+
+ $queryKey = 'type_' . $needed_angeltype_id;
+ if ($request->has($queryKey)) {
+ if (test_request_int($queryKey)) {
+ $needed_angel_types[$needed_angeltype_id] = trim($request->input($queryKey));
+ } else {
+ $valid = false;
+ $msg .= error(sprintf(
+ _('Please check your input for needed angels of type %s.'),
+ $angeltypes[$needed_angeltype_id]
+ ), true);
+ }
+ }
+ }
+
+ if ($valid) {
+ $shift['shifttype_id'] = $shifttype_id;
+ $shift['title'] = $title;
+ $shift['RID'] = $rid;
+ $shift['start'] = $start;
+ $shift['end'] = $end;
+
+ Shift_update($shift);
+ NeededAngelTypes_delete_by_shift($shift_id);
+ $needed_angel_types_info = [];
+ foreach ($needed_angel_types as $type_id => $count) {
+ NeededAngelType_add($shift_id, $type_id, null, $count);
+ $needed_angel_types_info[] = $angeltypes[$type_id] . ': ' . $count;
+ }
+
+ engelsystem_log(
+ 'Updated shift \'' . $shifttypes[$shifttype_id] . ', ' . $title
+ . '\' from ' . date('Y-m-d H:i', $start)
+ . ' to ' . date('Y-m-d H:i', $end)
+ . ' with angel types ' . join(', ', $needed_angel_types_info)
+ );
+ success(_('Shift updated.'));
+
+ redirect(shift_link([
+ 'SID' => $shift_id
+ ]));
+ }
}
-
- if (isset($_REQUEST['start']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['start'])) {
- $start = $tmp;
- } else {
- $valid = false;
- $msg .= error(_("Please enter a valid starting time for the shifts."), true);
+
+ $angel_types_spinner = '';
+ foreach ($angeltypes as $angeltype_id => $angeltype_name) {
+ $angel_types_spinner .= form_spinner('type_' . $angeltype_id, $angeltype_name,
+ $needed_angel_types[$angeltype_id]);
}
-
- if (isset($_REQUEST['end']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['end'])) {
- $end = $tmp;
- } else {
- $valid = false;
- $msg .= error(_("Please enter a valid ending time for the shifts."), true);
+
+ return page_with_title(
+ shifts_title(),
+ [
+ msg(),
+ '<noscript>' . info(_('This page is much more comfortable with javascript.'), true) . '</noscript>',
+ form([
+ form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
+ form_text('title', _('Title'), $title),
+ form_select('rid', _('Room:'), $room, $rid),
+ form_text('start', _('Start:'), date('Y-m-d H:i', $start)),
+ form_text('end', _('End:'), date('Y-m-d H:i', $end)),
+ '<h2>' . _('Needed angels') . '</h2>',
+ $angel_types_spinner,
+ form_submit('submit', _('Save'))
+ ])
+ ]
+ );
+}
+
+/**
+ * @return string
+ */
+function shift_delete_controller()
+{
+ global $privileges;
+ $request = request();
+
+ if (!in_array('user_shifts_admin', $privileges)) {
+ redirect(page_link_to('user_shifts'));
}
-
- if ($start >= $end) {
- $valid = false;
- $msg .= error(_("The ending time has to be after the starting time."), true);
+
+ // Schicht komplett löschen (nur für admins/user mit user_shifts_admin privileg)
+ if (!$request->has('delete_shift') || !preg_match('/^\d+$/', $request->input('delete_shift'))) {
+ redirect(page_link_to('user_shifts'));
}
-
- foreach ($needed_angel_types as $needed_angeltype_id => $needed_angeltype_name) {
- if (isset($_REQUEST['type_' . $needed_angeltype_id]) && test_request_int('type_' . $needed_angeltype_id)) {
- $needed_angel_types[$needed_angeltype_id] = trim($_REQUEST['type_' . $needed_angeltype_id]);
- } else {
- $valid = false;
- $msg .= error(sprintf(_("Please check your input for needed angels of type %s."), $needed_angeltype_name), true);
- }
+ $shift_id = $request->input('delete_shift');
+
+ $shift = Shift($shift_id);
+ if ($shift == null) {
+ redirect(page_link_to('user_shifts'));
}
-
- if ($valid) {
- $shift['shifttype_id'] = $shifttype_id;
- $shift['title'] = $title;
- $shift['RID'] = $rid;
- $shift['start'] = $start;
- $shift['end'] = $end;
-
- $result = Shift_update($shift);
- if ($result === false) {
- engelsystem_error('Unable to update shift.');
- }
- NeededAngelTypes_delete_by_shift($shift_id);
- $needed_angel_types_info = [];
- foreach ($needed_angel_types as $type_id => $count) {
- NeededAngelType_add($shift_id, $type_id, null, $count);
- $needed_angel_types_info[] = $angeltypes[$type_id] . ": " . $count;
- }
-
- engelsystem_log("Updated shift '" . $shifttypes[$shifttype_id] . ", " . $title . "' from " . date("Y-m-d H:i", $start) . " to " . date("Y-m-d H:i", $end) . " with angel types " . join(", ", $needed_angel_types_info));
- success(_("Shift updated."));
-
- redirect(shift_link([
- 'SID' => $shift_id
- ]));
+
+ // Schicht löschen bestätigt
+ if ($request->has('delete')) {
+ Shift_delete($shift_id);
+
+ engelsystem_log(
+ 'Deleted shift ' . $shift['name']
+ . ' from ' . date('Y-m-d H:i', $shift['start'])
+ . ' to ' . date('Y-m-d H:i', $shift['end'])
+ );
+ success(_('Shift deleted.'));
+ redirect(page_link_to('user_shifts'));
}
- }
-
- $angel_types_spinner = "";
- foreach ($angeltypes as $angeltype_id => $angeltype_name) {
- $angel_types_spinner .= form_spinner('type_' . $angeltype_id, $angeltype_name, $needed_angel_types[$angeltype_id]);
- }
-
- return page_with_title(shifts_title(), [
- msg(),
- '<noscript>' . info(_("This page is much more comfortable with javascript."), true) . '</noscript>',
- form([
- form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
- form_text('title', _("Title"), $title),
- form_select('rid', _("Room:"), $room, $rid),
- form_text('start', _("Start:"), date("Y-m-d H:i", $start)),
- form_text('end', _("End:"), date("Y-m-d H:i", $end)),
- '<h2>' . _("Needed angels") . '</h2>',
- $angel_types_spinner,
- form_submit('submit', _("Save"))
- ])
- ]);
-}
-function shift_delete_controller() {
- global $privileges;
-
- if (! in_array('user_shifts_admin', $privileges)) {
- redirect(page_link_to('user_shifts'));
- }
-
- // Schicht komplett löschen (nur für admins/user mit user_shifts_admin privileg)
- if (! isset($_REQUEST['delete_shift']) || ! preg_match("/^[0-9]*$/", $_REQUEST['delete_shift'])) {
- redirect(page_link_to('user_shifts'));
- }
- $shift_id = $_REQUEST['delete_shift'];
-
- $shift = Shift($shift_id);
- if ($shift == null) {
- redirect(page_link_to('user_shifts'));
- }
-
- // Schicht löschen bestätigt
- if (isset($_REQUEST['delete'])) {
- Shift_delete($shift_id);
-
- engelsystem_log("Deleted shift " . $shift['name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']));
- success(_("Shift deleted."));
- redirect(page_link_to('user_shifts'));
- }
-
- return page_with_title(shifts_title(), [
- error(sprintf(_("Do you want to delete the shift %s from %s to %s?"), $shift['name'], date("Y-m-d H:i", $shift['start']), date("H:i", $shift['end'])), true),
- '<a class="button" href="?p=user_shifts&delete_shift=' . $shift_id . '&delete">' . _("delete") . '</a>'
- ]);
+ return page_with_title(shifts_title(), [
+ error(sprintf(
+ _('Do you want to delete the shift %s from %s to %s?'),
+ $shift['name'],
+ date('Y-m-d H:i', $shift['start']),
+ date('H:i', $shift['end'])
+ ), true),
+ '<a class="button" href="'
+ . page_link_to('user_shifts', ['delete_shift' => $shift_id, 'delete' => 1]) .
+ '">' . _('delete') . '</a>'
+ ]);
}
-function shift_controller() {
- global $user, $privileges;
-
- if (! in_array('user_shifts', $privileges)) {
- redirect(page_link_to('?'));
- }
-
- if (! isset($_REQUEST['shift_id'])) {
- redirect(page_link_to('user_shifts'));
- }
-
- $shift = Shift($_REQUEST['shift_id']);
- if ($shift == null) {
- error(_("Shift could not be found."));
- redirect(page_link_to('user_shifts'));
- }
-
- $shifttype = ShiftType($shift['shifttype_id']);
- $room = Room($shift['RID']);
- $angeltypes = AngelTypes();
- $user_shifts = Shifts_by_user($user);
-
- $shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
- foreach ($angeltypes as &$angeltype) {
- $needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
- $shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
-
- $angeltype_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, $user_shifts, $needed_angeltype, $shift_entries);
- if ($shift_signup_state == null) {
- $shift_signup_state = $angeltype_signup_state;
- } else {
- $shift_signup_state->combineWith($angeltype_signup_state);
+/**
+ * @return array
+ */
+function shift_controller()
+{
+ global $user, $privileges;
+ $request = request();
+
+ if (!in_array('user_shifts', $privileges)) {
+ redirect(page_link_to('/'));
+ }
+
+ if (!$request->has('shift_id')) {
+ redirect(page_link_to('user_shifts'));
+ }
+
+ $shift = Shift($request->input('shift_id'));
+ if ($shift == null) {
+ error(_('Shift could not be found.'));
+ redirect(page_link_to('user_shifts'));
+ }
+
+ $shifttype = ShiftType($shift['shifttype_id']);
+ $room = Room($shift['RID']);
+ $angeltypes = AngelTypes();
+ $user_shifts = Shifts_by_user($user);
+
+ $shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
+ foreach ($angeltypes as &$angeltype) {
+ $needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
+ $shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
+
+ $angeltype_signup_state = Shift_signup_allowed(
+ $user,
+ $shift,
+ $angeltype,
+ null,
+ $user_shifts,
+ $needed_angeltype,
+ $shift_entries
+ );
+ if ($shift_signup_state == null) {
+ $shift_signup_state = $angeltype_signup_state;
+ } else {
+ $shift_signup_state->combineWith($angeltype_signup_state);
+ }
+ $angeltype['shift_signup_state'] = $angeltype_signup_state;
}
- $angeltype['shift_signup_state'] = $angeltype_signup_state;
- }
-
- return [
- $shift['name'],
- Shift_view($shift, $shifttype, $room, $angeltypes, $shift_signup_state)
- ];
+
+ return [
+ $shift['name'],
+ Shift_view($shift, $shifttype, $room, $angeltypes, $shift_signup_state)
+ ];
}
-function shifts_controller() {
- if (! isset($_REQUEST['action'])) {
- redirect(page_link_to('user_shifts'));
- }
-
- switch ($_REQUEST['action']) {
- default:
- redirect(page_link_to('?'));
- case 'view':
- return shift_controller();
- case 'next':
- return shift_next_controller();
- }
+/**
+ * @return array|false
+ */
+function shifts_controller()
+{
+ $request = request();
+ if (!$request->has('action')) {
+ redirect(page_link_to('user_shifts'));
+ }
+
+ switch ($request->input('action')) {
+ case 'view':
+ return shift_controller();
+ case 'next':
+ return shift_next_controller();
+ default:
+ redirect(page_link_to('/'));
+ }
+
+ return false;
}
/**
* Redirects the user to his next shift.
*/
-function shift_next_controller() {
- global $user, $privileges;
-
- if (! in_array('user_shifts', $privileges)) {
- redirect(page_link_to('?'));
- }
-
- $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
- if ($upcoming_shifts === false) {
- return false;
- }
-
- if (count($upcoming_shifts) > 0) {
- redirect(shift_link($upcoming_shifts[0]));
- }
-
- redirect(page_link_to('user_shifts'));
+function shift_next_controller()
+{
+ global $user, $privileges;
+
+ if (!in_array('user_shifts', $privileges)) {
+ redirect(page_link_to('/'));
+ }
+
+ $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
+
+ if (!empty($upcoming_shifts)) {
+ redirect(shift_link($upcoming_shifts[0]));
+ }
+
+ redirect(page_link_to('user_shifts'));
}
/**
* Export all shifts using api-key.
*/
-function shifts_json_export_all_controller() {
- global $api_key;
-
- if ($api_key == "") {
- engelsystem_error("Config contains empty apikey.");
- }
-
- if (! isset($_REQUEST['api_key'])) {
- engelsystem_error("Missing parameter api_key.");
- }
-
- if ($_REQUEST['api_key'] != $api_key) {
- engelsystem_error("Invalid api_key.");
- }
-
- $shifts_source = Shifts();
- if ($shifts_source === false) {
- engelsystem_error("Unable to load shifts.");
- }
-
- header("Content-Type: application/json; charset=utf-8");
- raw_output(json_encode($shifts_source));
+function shifts_json_export_all_controller()
+{
+ $api_key = config('api_key');
+ $request = request();
+
+ if (empty($api_key)) {
+ engelsystem_error('Config contains empty apikey.');
+ }
+
+ if (!$request->has('api_key')) {
+ engelsystem_error('Missing parameter api_key.');
+ }
+
+ if ($request->input('api_key') != $api_key) {
+ engelsystem_error('Invalid api_key.');
+ }
+
+ $shifts_source = Shifts();
+
+ header('Content-Type: application/json; charset=utf-8');
+ raw_output(json_encode($shifts_source));
}
/**
* Export filtered shifts via JSON.
* (Like iCal Export or shifts view)
*/
-function shifts_json_export_controller() {
- global $user;
-
- if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
- engelsystem_error("Missing key.");
- }
-
- $key = $_REQUEST['key'];
-
- $user = User_by_api_key($key);
- if ($user == null) {
- engelsystem_error("Key invalid.");
- }
- if (! in_array('shifts_json_export', privileges_for_user($user['UID']))) {
- engelsystem_error("No privilege for shifts_json_export.");
- }
-
- $shifts = load_ical_shifts();
-
- header("Content-Type: application/json; charset=utf-8");
- raw_output(json_encode($shifts));
+function shifts_json_export_controller()
+{
+ global $user;
+ $request = request();
+
+ if (!$request->has('key') || !preg_match('/^[\da-f]{32}$/', $request->input('key'))) {
+ engelsystem_error('Missing key.');
+ }
+
+ $key = $request->input('key');
+
+ $user = User_by_api_key($key);
+ if ($user == null) {
+ engelsystem_error('Key invalid.');
+ }
+ if (!in_array('shifts_json_export', privileges_for_user($user['UID']))) {
+ engelsystem_error('No privilege for shifts_json_export.');
+ }
+
+ $shifts = load_ical_shifts();
+
+ header('Content-Type: application/json; charset=utf-8');
+ raw_output(json_encode($shifts));
}
/**
* Returns users shifts to export.
+ *
+ * @return array
*/
-function load_ical_shifts() {
- global $user;
-
- return Shifts_by_user($user);
-}
+function load_ical_shifts()
+{
+ global $user;
-?> \ No newline at end of file
+ return Shifts_by_user($user);
+}
diff --git a/includes/controller/shifttypes_controller.php b/includes/controller/shifttypes_controller.php
index 456e39ae..4e7cd92c 100644
--- a/includes/controller/shifttypes_controller.php
+++ b/includes/controller/shifttypes_controller.php
@@ -1,179 +1,187 @@
<?php
-function shifttype_link($shifttype) {
- return page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'];
+/**
+ * @param array $shifttype
+ * @return string
+ */
+function shifttype_link($shifttype)
+{
+ return page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype['id']]);
}
/**
* Delete a shifttype.
+ *
+ * @return array
*/
-function shifttype_delete_controller() {
- if (! isset($_REQUEST['shifttype_id'])) {
- redirect(page_link_to('shifttypes'));
- }
-
- $shifttype = ShiftType($_REQUEST['shifttype_id']);
- if ($shifttype === false) {
- engelsystem_error('Unable to load shifttype.');
- }
-
- if ($shifttype == null) {
- redirect(page_link_to('shifttypes'));
- }
-
- if (isset($_REQUEST['confirmed'])) {
- $result = ShiftType_delete($shifttype['id']);
- if ($result === false) {
- engelsystem_error('Unable to delete shifttype.');
+function shifttype_delete_controller()
+{
+ $request = request();
+ if (!$request->has('shifttype_id')) {
+ redirect(page_link_to('shifttypes'));
+ }
+
+ $shifttype = ShiftType($request->input('shifttype_id'));
+
+ if ($shifttype == null) {
+ redirect(page_link_to('shifttypes'));
}
-
- engelsystem_log('Deleted shifttype ' . $shifttype['name']);
- success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
- redirect(page_link_to('shifttypes'));
- }
-
- return [
- sprintf(_("Delete shifttype %s"), $shifttype['name']),
- ShiftType_delete_view($shifttype)
- ];
+
+ if ($request->has('confirmed')) {
+ ShiftType_delete($shifttype['id']);
+
+ engelsystem_log('Deleted shifttype ' . $shifttype['name']);
+ success(sprintf(_('Shifttype %s deleted.'), $shifttype['name']));
+ redirect(page_link_to('shifttypes'));
+ }
+
+ return [
+ sprintf(_('Delete shifttype %s'), $shifttype['name']),
+ ShiftType_delete_view($shifttype)
+ ];
}
/**
* Edit or create shift type.
+ *
+ * @return array
*/
-function shifttype_edit_controller() {
- $shifttype_id = null;
- $name = "";
- $angeltype_id = null;
- $description = "";
-
- $angeltypes = AngelTypes();
-
- if (isset($_REQUEST['shifttype_id'])) {
- $shifttype = ShiftType($_REQUEST['shifttype_id']);
- if ($shifttype === false) {
- engelsystem_error('Unable to load shifttype.');
- }
- if ($shifttype == null) {
- error(_('Shifttype not found.'));
- redirect(page_link_to('shifttypes'));
- }
- $shifttype_id = $shifttype['id'];
- $name = $shifttype['name'];
- $angeltype_id = $shifttype['angeltype_id'];
- $description = $shifttype['description'];
- }
-
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
- $name = strip_request_item('name');
- } else {
- $valid = false;
- error(_('Please enter a name.'));
- }
-
- if (isset($_REQUEST['angeltype_id']) && preg_match("/^[0-9]+$/", $_REQUEST['angeltype_id'])) {
- $angeltype_id = $_REQUEST['angeltype_id'];
- } else {
- $angeltype_id = null;
- }
-
- if (isset($_REQUEST['description'])) {
- $description = strip_request_item_nl('description');
+function shifttype_edit_controller()
+{
+ $shifttype_id = null;
+ $name = '';
+ $angeltype_id = null;
+ $description = '';
+
+ $angeltypes = AngelTypes();
+ $request = request();
+
+ if ($request->has('shifttype_id')) {
+ $shifttype = ShiftType($request->input('shifttype_id'));
+ if ($shifttype == null) {
+ error(_('Shifttype not found.'));
+ redirect(page_link_to('shifttypes'));
+ }
+ $shifttype_id = $shifttype['id'];
+ $name = $shifttype['name'];
+ $angeltype_id = $shifttype['angeltype_id'];
+ $description = $shifttype['description'];
}
-
- if ($valid) {
- if ($shifttype_id) {
- $result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
- if ($result === false) {
- engelsystem_error('Unable to update shifttype.');
+
+ if ($request->has('submit')) {
+ $valid = true;
+
+ if ($request->has('name') && $request->input('name') != '') {
+ $name = strip_request_item('name');
+ } else {
+ $valid = false;
+ error(_('Please enter a name.'));
}
- engelsystem_log('Updated shifttype ' . $name);
- success(_('Updated shifttype.'));
- } else {
- $shifttype_id = ShiftType_create($name, $angeltype_id, $description);
- if ($shifttype_id === false) {
- engelsystem_error('Unable to create shifttype.');
+
+ if ($request->has('angeltype_id') && preg_match('/^\d+$/', $request->input('angeltype_id'))) {
+ $angeltype_id = $request->input('angeltype_id');
+ } else {
+ $angeltype_id = null;
+ }
+
+ if ($request->has('description')) {
+ $description = strip_request_item_nl('description');
+ }
+
+ if ($valid) {
+ if ($shifttype_id) {
+ ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
+
+ engelsystem_log('Updated shifttype ' . $name);
+ success(_('Updated shifttype.'));
+ } else {
+ $shifttype_id = ShiftType_create($name, $angeltype_id, $description);
+
+ engelsystem_log('Created shifttype ' . $name);
+ success(_('Created shifttype.'));
+ }
+ redirect(page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype_id]));
}
- engelsystem_log('Created shifttype ' . $name);
- success(_('Created shifttype.'));
- }
- redirect(page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype_id);
}
- }
-
- return [
- shifttypes_title(),
- ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
- ];
+
+ return [
+ shifttypes_title(),
+ ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
+ ];
}
-function shifttype_controller() {
- if (! isset($_REQUEST['shifttype_id'])) {
- redirect(page_link_to('shifttypes'));
- }
- $shifttype = ShiftType($_REQUEST['shifttype_id']);
- if ($shifttype === false) {
- engelsystem_error('Unable to load shifttype.');
- }
- if ($shifttype == null) {
- redirect(page_link_to('shifttypes'));
- }
-
- $angeltype = null;
- if ($shifttype['angeltype_id'] != null) {
- $angeltype = AngelType($shifttype['angeltype_id']);
- }
-
- return [
- $shifttype['name'],
- ShiftType_view($shifttype, $angeltype)
- ];
+/**
+ * @return array
+ */
+function shifttype_controller()
+{
+ $request = request();
+ if (!$request->has('shifttype_id')) {
+ redirect(page_link_to('shifttypes'));
+ }
+ $shifttype = ShiftType($request->input('shifttype_id'));
+ if ($shifttype == null) {
+ redirect(page_link_to('shifttypes'));
+ }
+
+ $angeltype = null;
+ if ($shifttype['angeltype_id'] != null) {
+ $angeltype = AngelType($shifttype['angeltype_id']);
+ }
+
+ return [
+ $shifttype['name'],
+ ShiftType_view($shifttype, $angeltype)
+ ];
}
/**
* List all shift types.
+ *
+ * @return array
*/
-function shifttypes_list_controller() {
- $shifttypes = ShiftTypes();
- if ($shifttypes === false) {
- engelsystem_error("Unable to load shifttypes.");
- }
-
- return [
- shifttypes_title(),
- ShiftTypes_list_view($shifttypes)
- ];
+function shifttypes_list_controller()
+{
+ $shifttypes = ShiftTypes();
+
+ return [
+ shifttypes_title(),
+ ShiftTypes_list_view($shifttypes)
+ ];
}
/**
* Text for shift type related links.
+ *
+ * @return string
*/
-function shifttypes_title() {
- return _("Shifttypes");
+function shifttypes_title()
+{
+ return _('Shifttypes');
}
/**
* Route shift type actions
+ *
+ * @return array
*/
-function shifttypes_controller() {
- if (! isset($_REQUEST['action'])) {
- $_REQUEST['action'] = 'list';
- }
-
- switch ($_REQUEST['action']) {
- default:
- case 'list':
- return shifttypes_list_controller();
- case 'view':
- return shifttype_controller();
- case 'edit':
- return shifttype_edit_controller();
- case 'delete':
- return shifttype_delete_controller();
- }
-}
+function shifttypes_controller()
+{
+ $request = request();
+ $action = 'list';
+ if ($request->has('action')) {
+ $action = $request->input('action');
+ }
-?> \ No newline at end of file
+ switch ($action) {
+ case 'view':
+ return shifttype_controller();
+ case 'edit':
+ return shifttype_edit_controller();
+ case 'delete':
+ return shifttype_delete_controller();
+ case 'list':
+ default:
+ return shifttypes_list_controller();
+ }
+}
diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php
index 6ef894c7..fa4f5777 100644
--- a/includes/controller/user_angeltypes_controller.php
+++ b/includes/controller/user_angeltypes_controller.php
@@ -2,362 +2,421 @@
/**
* Display a hint for team/angeltype supporters if there are unconfirmed users for his angeltype.
+ *
+ * @return string|null
*/
-function user_angeltypes_unconfirmed_hint() {
- global $user;
-
- $unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
- if (count($unconfirmed_user_angeltypes) == 0) {
- return null;
- }
-
- $unconfirmed_links = [];
- foreach ($unconfirmed_user_angeltypes as $user_angeltype) {
- $unconfirmed_links[] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $user_angeltype['angeltype_id'] . '">' . $user_angeltype['name'] . ' (+' . $user_angeltype['count'] . ')' . '</a>';
- }
-
- return sprintf(ngettext("There is %d unconfirmed angeltype.", "There are %d unconfirmed angeltypes.", count($unconfirmed_user_angeltypes)), count($unconfirmed_user_angeltypes)) . " " . _('Angel types which need approvals:') . ' ' . join(', ', $unconfirmed_links);
+function user_angeltypes_unconfirmed_hint()
+{
+ global $user;
+
+ $unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
+ if (count($unconfirmed_user_angeltypes) == 0) {
+ return null;
+ }
+
+ $unconfirmed_links = [];
+ foreach ($unconfirmed_user_angeltypes as $user_angeltype) {
+ $unconfirmed_links[] = '<a href="'
+ . page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $user_angeltype['angeltype_id']])
+ . '">' . $user_angeltype['name']
+ . ' (+' . $user_angeltype['count'] . ')'
+ . '</a>';
+ }
+
+ return sprintf(ngettext('There is %d unconfirmed angeltype.', 'There are %d unconfirmed angeltypes.',
+ count($unconfirmed_user_angeltypes)),
+ count($unconfirmed_user_angeltypes)) . ' ' . _('Angel types which need approvals:') . ' ' . join(', ',
+ $unconfirmed_links);
}
/**
* Remove all unconfirmed users from a specific angeltype.
+ *
+ * @return array
*/
-function user_angeltypes_delete_all_controller() {
- global $user;
-
- if (! isset($_REQUEST['angeltype_id'])) {
- error(_("Angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $angeltype = AngelType($_REQUEST['angeltype_id']);
- if ($angeltype == null) {
- error(_("Angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (! User_is_AngelType_supporter($user, $angeltype)) {
- error(_("You are not allowed to delete all users for this angeltype."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (isset($_REQUEST['confirmed'])) {
- UserAngelTypes_delete_all($angeltype['id']);
-
- engelsystem_log(sprintf("Denied all users for angeltype %s", AngelType_name_render($angeltype)));
- success(sprintf(_("Denied all users for angeltype %s."), AngelType_name_render($angeltype)));
- redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
- }
-
- return [
- _("Deny all users"),
- UserAngelTypes_delete_all_view($angeltype)
- ];
+function user_angeltypes_delete_all_controller()
+{
+ global $user;
+ $request = request();
+
+ if (!$request->has('angeltype_id')) {
+ error(_('Angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $angeltype = AngelType($request->input('angeltype_id'));
+ if ($angeltype == null) {
+ error(_('Angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if (!User_is_AngelType_supporter($user, $angeltype)) {
+ error(_('You are not allowed to delete all users for this angeltype.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if ($request->has('confirmed')) {
+ UserAngelTypes_delete_all($angeltype['id']);
+
+ engelsystem_log(sprintf('Denied all users for angeltype %s', AngelType_name_render($angeltype)));
+ success(sprintf(_('Denied all users for angeltype %s.'), AngelType_name_render($angeltype)));
+ redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
+ }
+
+ return [
+ _('Deny all users'),
+ UserAngelTypes_delete_all_view($angeltype)
+ ];
}
/**
* Confirm all unconfirmed users for an angeltype.
+ *
+ * @return array
*/
-function user_angeltypes_confirm_all_controller() {
- global $user, $privileges;
-
- if (! isset($_REQUEST['angeltype_id'])) {
- error(_("Angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $angeltype = AngelType($_REQUEST['angeltype_id']);
- if ($angeltype == null) {
- error(_("Angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- if ($user_angeltype == null) {
- error(_("User angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (! in_array('admin_user_angeltypes', $privileges) && ! $user_angeltype['supporter']) {
- error(_("You are not allowed to confirm all users for this angeltype."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (isset($_REQUEST['confirmed'])) {
- UserAngelTypes_confirm_all($angeltype['id'], $user);
-
- engelsystem_log(sprintf("Confirmed all users for angeltype %s", AngelType_name_render($angeltype)));
- success(sprintf(_("Confirmed all users for angeltype %s."), AngelType_name_render($angeltype)));
- redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
- }
-
- return [
- _("Confirm all users"),
- UserAngelTypes_confirm_all_view($angeltype)
- ];
+function user_angeltypes_confirm_all_controller()
+{
+ global $user, $privileges;
+ $request = request();
+
+ if (!$request->has('angeltype_id')) {
+ error(_('Angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $angeltype = AngelType($request->input('angeltype_id'));
+ if ($angeltype == null) {
+ error(_('Angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
+ if ($user_angeltype == null) {
+ error(_('User angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if (!in_array('admin_user_angeltypes', $privileges) && !$user_angeltype['supporter']) {
+ error(_('You are not allowed to confirm all users for this angeltype.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if ($request->has('confirmed')) {
+ UserAngelTypes_confirm_all($angeltype['id'], $user);
+
+ engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype)));
+ success(sprintf(_('Confirmed all users for angeltype %s.'), AngelType_name_render($angeltype)));
+ redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
+ }
+
+ return [
+ _('Confirm all users'),
+ UserAngelTypes_confirm_all_view($angeltype)
+ ];
}
/**
* Confirm an user for an angeltype.
+ *
+ * @return array
*/
-function user_angeltype_confirm_controller() {
- global $user;
-
- if (! isset($_REQUEST['user_angeltype_id'])) {
- error(_("User angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
- if ($user_angeltype == null) {
- error(_("User angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $angeltype = AngelType($user_angeltype['angeltype_id']);
- if ($angeltype == null) {
- error(_("Angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (! User_is_AngelType_supporter($user, $angeltype)) {
- error(_("You are not allowed to confirm this users angeltype."));
- redirect(page_link_to('angeltypes'));
- }
-
- $user_source = User($user_angeltype['user_id']);
- if ($user_source == null) {
- error(_("User doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (isset($_REQUEST['confirmed'])) {
- $result = UserAngelType_confirm($user_angeltype['id'], $user);
- if ($result === false) {
- engelsystem_error("Unable to confirm user angeltype.");
- }
-
- engelsystem_log(sprintf("%s confirmed for angeltype %s", User_Nick_render($user_source), AngelType_name_render($angeltype)));
- success(sprintf(_("%s confirmed for angeltype %s."), User_Nick_render($user_source), AngelType_name_render($angeltype)));
- redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
- }
-
- return [
- _("Confirm angeltype for user"),
- UserAngelType_confirm_view($user_angeltype, $user_source, $angeltype)
- ];
+function user_angeltype_confirm_controller()
+{
+ global $user;
+ $request = request();
+
+ if (!$request->has('user_angeltype_id')) {
+ error(_('User angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $user_angeltype = UserAngelType($request->input('user_angeltype_id'));
+ if ($user_angeltype == null) {
+ error(_('User angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $angeltype = AngelType($user_angeltype['angeltype_id']);
+ if ($angeltype == null) {
+ error(_('Angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if (!User_is_AngelType_supporter($user, $angeltype)) {
+ error(_('You are not allowed to confirm this users angeltype.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $user_source = User($user_angeltype['user_id']);
+ if ($user_source == null) {
+ error(_('User doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if ($request->has('confirmed')) {
+ UserAngelType_confirm($user_angeltype['id'], $user);
+
+ engelsystem_log(sprintf(
+ '%s confirmed for angeltype %s',
+ User_Nick_render($user_source),
+ AngelType_name_render($angeltype)
+ ));
+ success(sprintf(
+ _('%s confirmed for angeltype %s.'),
+ User_Nick_render($user_source),
+ AngelType_name_render($angeltype)
+ ));
+ redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
+ }
+
+ return [
+ _('Confirm angeltype for user'),
+ UserAngelType_confirm_view($user_angeltype, $user_source, $angeltype)
+ ];
}
/**
* Remove a user from an Angeltype.
+ *
+ * @return array
*/
-function user_angeltype_delete_controller() {
- global $user;
-
- if (! isset($_REQUEST['user_angeltype_id'])) {
- error(_("User angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
- if ($user_angeltype == null) {
- error(_("User angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $angeltype = AngelType($user_angeltype['angeltype_id']);
- if ($angeltype == null) {
- error(_("Angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $user_source = User($user_angeltype['user_id']);
- if ($user_source == null) {
- error(_("User doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- if ($user['UID'] != $user_angeltype['user_id'] && ! User_is_AngelType_supporter($user, $angeltype)) {
- error(_("You are not allowed to delete this users angeltype."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (isset($_REQUEST['confirmed'])) {
- $result = UserAngelType_delete($user_angeltype);
- if ($result === false) {
- engelsystem_error("Unable to delete user angeltype.");
- }
-
- $success_message = sprintf(_("User %s removed from %s."), User_Nick_render($user_source), $angeltype['name']);
- engelsystem_log($success_message);
- success($success_message);
-
- redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
- }
-
- return [
- _("Remove angeltype"),
- UserAngelType_delete_view($user_angeltype, $user_source, $angeltype)
- ];
+function user_angeltype_delete_controller()
+{
+ global $user;
+ $request = request();
+
+ if (!$request->has('user_angeltype_id')) {
+ error(_('User angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $user_angeltype = UserAngelType($request->input('user_angeltype_id'));
+ if ($user_angeltype == null) {
+ error(_('User angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $angeltype = AngelType($user_angeltype['angeltype_id']);
+ if ($angeltype == null) {
+ error(_('Angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $user_source = User($user_angeltype['user_id']);
+ if ($user_source == null) {
+ error(_('User doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if ($user['UID'] != $user_angeltype['user_id'] && !User_is_AngelType_supporter($user, $angeltype)) {
+ error(_('You are not allowed to delete this users angeltype.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if ($request->has('confirmed')) {
+ UserAngelType_delete($user_angeltype);
+
+ $success_message = sprintf(_('User %s removed from %s.'), User_Nick_render($user_source), $angeltype['name']);
+ engelsystem_log($success_message);
+ success($success_message);
+
+ redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
+ }
+
+ return [
+ _('Remove angeltype'),
+ UserAngelType_delete_view($user_angeltype, $user_source, $angeltype)
+ ];
}
/**
* Update an UserAngelType.
+ *
+ * @return array
*/
-function user_angeltype_update_controller() {
- global $privileges;
-
- if (! in_array('admin_angel_types', $privileges)) {
- error(_("You are not allowed to set supporter rights."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (! isset($_REQUEST['user_angeltype_id'])) {
- error(_("User angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (isset($_REQUEST['supporter']) && preg_match("/^[01]$/", $_REQUEST['supporter'])) {
- $supporter = $_REQUEST['supporter'] == "1";
- } else {
- error(_("No supporter update given."));
- redirect(page_link_to('angeltypes'));
- }
-
- $user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
- if ($user_angeltype == null) {
- error(_("User angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $angeltype = AngelType($user_angeltype['angeltype_id']);
- if ($angeltype == null) {
- error(_("Angeltype doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- $user_source = User($user_angeltype['user_id']);
- if ($user_source == null) {
- error(_("User doesn't exist."));
- redirect(page_link_to('angeltypes'));
- }
-
- if (isset($_REQUEST['confirmed'])) {
- UserAngelType_update($user_angeltype['id'], $supporter);
-
- $success_message = sprintf($supporter ? _("Added supporter rights for %s to %s.") : _("Removed supporter rights for %s from %s."), AngelType_name_render($angeltype), User_Nick_render($user_source));
- engelsystem_log($success_message);
- success($success_message);
-
- redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
- }
-
- return [
- $supporter ? _("Add supporter rights") : _("Remove supporter rights"),
- UserAngelType_update_view($user_angeltype, $user_source, $angeltype, $supporter)
- ];
+function user_angeltype_update_controller()
+{
+ global $privileges;
+ $supporter = false;
+ $request = request();
+
+ if (!in_array('admin_angel_types', $privileges)) {
+ error(_('You are not allowed to set supporter rights.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if (!$request->has('user_angeltype_id')) {
+ error(_('User angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if ($request->has('supporter') && preg_match('/^[01]$/', $request->input('supporter'))) {
+ $supporter = $request->input('supporter') == '1';
+ } else {
+ error(_('No supporter update given.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $user_angeltype = UserAngelType($request->input('user_angeltype_id'));
+ if ($user_angeltype == null) {
+ error(_('User angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $angeltype = AngelType($user_angeltype['angeltype_id']);
+ if ($angeltype == null) {
+ error(_('Angeltype doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ $user_source = User($user_angeltype['user_id']);
+ if ($user_source == null) {
+ error(_('User doesn\'t exist.'));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if ($request->has('confirmed')) {
+ UserAngelType_update($user_angeltype['id'], $supporter);
+
+ $success_message = sprintf(
+ $supporter ? _('Added supporter rights for %s to %s.') : _('Removed supporter rights for %s from %s.'),
+ AngelType_name_render($angeltype),
+ User_Nick_render($user_source)
+ );
+ engelsystem_log($success_message);
+ success($success_message);
+
+ redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
+ }
+
+ return [
+ $supporter ? _('Add supporter rights') : _('Remove supporter rights'),
+ UserAngelType_update_view($user_angeltype, $user_source, $angeltype, $supporter)
+ ];
}
/**
* User joining an Angeltype (Or supporter doing this for him).
*/
-function user_angeltype_add_controller() {
- global $user;
-
- $angeltype = load_angeltype();
-
- // User is joining by itself
- if (! User_is_AngelType_supporter($user, $angeltype)) {
- return user_angeltype_join_controller($angeltype);
- }
-
- // Allow to add any user
-
- // Default selection
- $user_source = $user;
-
- // Load possible users, that are not in the angeltype already
- $users_source = Users_by_angeltype_inverted($angeltype);
-
- if (isset($_REQUEST['submit'])) {
- $user_source = load_user();
-
- if (! UserAngelType_exists($user_source, $angeltype)) {
- $user_angeltype_id = UserAngelType_create($user_source, $angeltype);
-
- engelsystem_log(sprintf("User %s added to %s.", User_Nick_render($user_source), AngelType_name_render($angeltype)));
- success(sprintf(_("User %s added to %s."), User_Nick_render($user_source), AngelType_name_render($angeltype)));
-
- UserAngelType_confirm($user_angeltype_id, $user_source);
- engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
-
- redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
- }
- }
-
- return [
- _("Add user to angeltype"),
- UserAngelType_add_view($angeltype, $users_source, $user_source['UID'])
- ];
+function user_angeltype_add_controller()
+{
+ global $user;
+ $angeltype = load_angeltype();
+
+ // User is joining by itself
+ if (!User_is_AngelType_supporter($user, $angeltype)) {
+ return user_angeltype_join_controller($angeltype);
+ }
+
+ // Allow to add any user
+
+ // Default selection
+ $user_source = $user;
+
+ // Load possible users, that are not in the angeltype already
+ $users_source = Users_by_angeltype_inverted($angeltype);
+
+ if (request()->has('submit')) {
+ $user_source = load_user();
+
+ if (!UserAngelType_exists($user_source, $angeltype)) {
+ $user_angeltype_id = UserAngelType_create($user_source, $angeltype);
+
+ engelsystem_log(sprintf(
+ 'User %s added to %s.',
+ User_Nick_render($user_source),
+ AngelType_name_render($angeltype)
+ ));
+ success(sprintf(
+ _('User %s added to %s.'),
+ User_Nick_render($user_source),
+ AngelType_name_render($angeltype)
+ ));
+
+ UserAngelType_confirm($user_angeltype_id, $user_source);
+ engelsystem_log(sprintf(
+ 'User %s confirmed as %s.',
+ User_Nick_render($user),
+ AngelType_name_render($angeltype)
+ ));
+
+ redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
+ }
+ }
+
+ return [
+ _('Add user to angeltype'),
+ UserAngelType_add_view($angeltype, $users_source, $user_source['UID'])
+ ];
}
/**
* A user joins an angeltype.
+ *
+ * @param array $angeltype
+ * @return array
*/
-function user_angeltype_join_controller($angeltype) {
- global $user, $privileges;
-
- $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- if ($user_angeltype != null) {
- error(sprintf(_("You are already a %s."), $angeltype['name']));
- redirect(page_link_to('angeltypes'));
- }
-
- if (isset($_REQUEST['confirmed'])) {
- $user_angeltype_id = UserAngelType_create($user, $angeltype);
-
- $success_message = sprintf(_("You joined %s."), $angeltype['name']);
- engelsystem_log(sprintf("User %s joined %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
- success($success_message);
-
- if (in_array('admin_user_angeltypes', $privileges)) {
- UserAngelType_confirm($user_angeltype_id, $user);
- engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
- }
-
- redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
- }
-
- return [
- sprintf(_("Become a %s"), $angeltype['name']),
- UserAngelType_join_view($user, $angeltype)
- ];
+function user_angeltype_join_controller($angeltype)
+{
+ global $user, $privileges;
+
+ $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
+ if ($user_angeltype != null) {
+ error(sprintf(_('You are already a %s.'), $angeltype['name']));
+ redirect(page_link_to('angeltypes'));
+ }
+
+ if (request()->has('confirmed')) {
+ $user_angeltype_id = UserAngelType_create($user, $angeltype);
+
+ $success_message = sprintf(_('You joined %s.'), $angeltype['name']);
+ engelsystem_log(sprintf('User %s joined %s.', User_Nick_render($user), AngelType_name_render($angeltype)));
+ success($success_message);
+
+ if (in_array('admin_user_angeltypes', $privileges)) {
+ UserAngelType_confirm($user_angeltype_id, $user);
+ engelsystem_log(sprintf(
+ 'User %s confirmed as %s.',
+ User_Nick_render($user),
+ AngelType_name_render($angeltype)
+ ));
+ }
+
+ redirect(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]));
+ }
+
+ return [
+ sprintf(_('Become a %s'), $angeltype['name']),
+ UserAngelType_join_view($user, $angeltype)
+ ];
}
/**
* Route UserAngelType actions.
+ *
+ * @return array
*/
-function user_angeltypes_controller() {
- if (! isset($_REQUEST['action'])) {
- redirect(page_link_to('angeltypes'));
- }
-
- switch ($_REQUEST['action']) {
- case 'delete_all':
- return user_angeltypes_delete_all_controller();
- case 'confirm_all':
- return user_angeltypes_confirm_all_controller();
- case 'confirm':
- return user_angeltype_confirm_controller();
- case 'delete':
- return user_angeltype_delete_controller();
- case 'update':
- return user_angeltype_update_controller();
- case 'add':
- return user_angeltype_add_controller();
- default:
- redirect(page_link_to('angeltypes'));
- }
-}
+function user_angeltypes_controller()
+{
+ $request = request();
+ if (!$request->has('action')) {
+ redirect(page_link_to('angeltypes'));
+ }
-?> \ No newline at end of file
+ switch ($request->input('action')) {
+ case 'delete_all':
+ return user_angeltypes_delete_all_controller();
+ case 'confirm_all':
+ return user_angeltypes_confirm_all_controller();
+ case 'confirm':
+ return user_angeltype_confirm_controller();
+ case 'delete':
+ return user_angeltype_delete_controller();
+ case 'update':
+ return user_angeltype_update_controller();
+ case 'add':
+ return user_angeltype_add_controller();
+ default:
+ redirect(page_link_to('angeltypes'));
+ }
+}
diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php
index 26deab7d..3db31eff 100644
--- a/includes/controller/user_driver_licenses_controller.php
+++ b/includes/controller/user_driver_licenses_controller.php
@@ -1,132 +1,148 @@
<?php
/**
- * Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license information provided.
+ * Generates a hint, if user joined angeltypes that require a driving license and the user has no driver license
+ * information provided.
+ *
+ * @return string|null
*/
-function user_driver_license_required_hint() {
- global $user;
-
- $angeltypes = User_angeltypes($user);
- $user_driver_license = UserDriverLicense($user['UID']);
-
- // User has already entered data, no hint needed.
- if ($user_driver_license != null) {
- return null;
- }
-
- foreach ($angeltypes as $angeltype) {
- if ($angeltype['requires_driver_license']) {
- return sprintf(_("You joined an angeltype which requires a driving license. Please edit your driving license information here: %s."), '<a href="' . user_driver_license_edit_link() . '">' . _("driving license information") . '</a>');
+function user_driver_license_required_hint()
+{
+ global $user;
+
+ $angeltypes = User_angeltypes($user);
+ $user_driver_license = UserDriverLicense($user['UID']);
+
+ // User has already entered data, no hint needed.
+ if ($user_driver_license != null) {
+ return null;
}
- }
-
- return null;
+
+ foreach ($angeltypes as $angeltype) {
+ if ($angeltype['requires_driver_license']) {
+ return sprintf(
+ _('You joined an angeltype which requires a driving license. Please edit your driving license information here: %s.'),
+ '<a href="' . user_driver_license_edit_link() . '">' . _('driving license information') . '</a>'
+ );
+ }
+ }
+
+ return null;
}
/**
* Route user driver licenses actions.
+ *
+ * @return array
*/
-function user_driver_licenses_controller() {
- global $user;
-
- if (! isset($user)) {
- redirect(page_link_to(''));
- }
-
- $action = strip_request_item('action', 'edit');
-
- switch ($action) {
- default:
- case 'edit':
- return user_driver_license_edit_controller();
- }
+function user_driver_licenses_controller()
+{
+ global $user;
+
+ if (!isset($user)) {
+ redirect(page_link_to(''));
+ }
+
+ $action = strip_request_item('action', 'edit');
+
+ switch ($action) {
+ default:
+ case 'edit':
+ return user_driver_license_edit_controller();
+ }
}
/**
* Link to user driver license edit page for given user.
*
- * @param User $user
+ * @param array $user
+ * @return string
*/
-function user_driver_license_edit_link($user = null) {
- if ($user == null) {
- return page_link_to('user_driver_licenses');
- }
- return page_link_to('user_driver_licenses') . '&user_id=' . $user['UID'];
+function user_driver_license_edit_link($user = null)
+{
+ if ($user == null) {
+ return page_link_to('user_driver_licenses');
+ }
+ return page_link_to('user_driver_licenses', ['user_id' => $user['UID']]);
}
/**
* Loads the user for the driver license.
+ *
+ * @return array
*/
-function user_driver_license_load_user() {
- global $user;
-
- $user_source = $user;
-
- if (isset($_REQUEST['user_id'])) {
- $user_source = User($_REQUEST['user_id']);
- if ($user_source == null) {
- redirect(user_driver_license_edit_link());
+function user_driver_license_load_user()
+{
+ global $user;
+ $request = request();
+ $user_source = $user;
+
+ if ($request->has('user_id')) {
+ $user_source = User($request->input('user_id'));
+ if ($user_source == null) {
+ redirect(user_driver_license_edit_link());
+ }
}
- }
-
- return $user_source;
+
+ return $user_source;
}
/**
* Edit a users driver license information.
+ *
+ * @return array
*/
-function user_driver_license_edit_controller() {
- global $privileges, $user;
-
- $user_source = user_driver_license_load_user();
-
- // only privilege admin_user can edit other users driver license information
- if ($user['UID'] != $user_source['UID'] && ! in_array('admin_user', $privileges)) {
- redirect(user_driver_license_edit_link());
- }
-
- $user_driver_license = UserDriverLicense($user_source['UID']);
- if ($user_driver_license == null) {
- $wants_to_drive = false;
- $user_driver_license = UserDriverLicense_new();
- } else {
- $wants_to_drive = true;
- }
-
- if (isset($_REQUEST['submit'])) {
- $wants_to_drive = isset($_REQUEST['wants_to_drive']);
- if ($wants_to_drive) {
- $user_driver_license['has_car'] = isset($_REQUEST['has_car']);
- $user_driver_license['has_license_car'] = isset($_REQUEST['has_license_car']);
- $user_driver_license['has_license_3_5t_transporter'] = isset($_REQUEST['has_license_3_5t_transporter']);
- $user_driver_license['has_license_7_5t_truck'] = isset($_REQUEST['has_license_7_5t_truck']);
- $user_driver_license['has_license_12_5t_truck'] = isset($_REQUEST['has_license_12_5t_truck']);
- $user_driver_license['has_license_forklift'] = isset($_REQUEST['has_license_forklift']);
-
- if (UserDriverLicense_valid($user_driver_license)) {
- if ($user_driver_license['user_id'] == null) {
- $user_driver_license = UserDriverLicenses_create($user_driver_license, $user);
- } else {
- UserDriverLicenses_update($user_driver_license);
+function user_driver_license_edit_controller()
+{
+ global $privileges, $user;
+ $request = request();
+ $user_source = user_driver_license_load_user();
+
+ // only privilege admin_user can edit other users driver license information
+ if ($user['UID'] != $user_source['UID'] && !in_array('admin_user', $privileges)) {
+ redirect(user_driver_license_edit_link());
+ }
+
+ $user_driver_license = UserDriverLicense($user_source['UID']);
+ if ($user_driver_license == null) {
+ $wants_to_drive = false;
+ $user_driver_license = UserDriverLicense_new();
+ } else {
+ $wants_to_drive = true;
+ }
+
+ if ($request->has('submit')) {
+ $wants_to_drive = $request->has('wants_to_drive');
+ if ($wants_to_drive) {
+ $user_driver_license['has_car'] = $request->has('has_car');
+ $user_driver_license['has_license_car'] = $request->has('has_license_car');
+ $user_driver_license['has_license_3_5t_transporter'] = $request->has('has_license_3_5t_transporter');
+ $user_driver_license['has_license_7_5t_truck'] = $request->has('has_license_7_5t_truck');
+ $user_driver_license['has_license_12_5t_truck'] = $request->has('has_license_12_5t_truck');
+ $user_driver_license['has_license_forklift'] = $request->has('has_license_forklift');
+
+ if (UserDriverLicense_valid($user_driver_license)) {
+ if ($user_driver_license['user_id'] == null) {
+ $user_driver_license = UserDriverLicenses_create($user_driver_license, $user_source);
+ } else {
+ UserDriverLicenses_update($user_driver_license);
+ }
+ engelsystem_log('Driver license information updated.');
+ success(_('Your driver license information has been saved.'));
+ redirect(user_link($user_source));
+ } else {
+ error(_('Please select at least one driving license.'));
+ }
+ } elseif ($user_driver_license['user_id'] != null) {
+ UserDriverLicenses_delete($user_source['UID']);
+ engelsystem_log('Driver license information removed.');
+ success(_('Your driver license information has been removed.'));
+ redirect(user_link($user_source));
}
- engelsystem_log("Driver license information updated.");
- success(_("Your driver license information has been saved."));
- redirect(user_link($user_source));
- } else {
- error(_("Please select at least one driving license."));
- }
- } elseif ($user_driver_license['id'] != null) {
- UserDriverLicenses_delete($user_source['UID']);
- engelsystem_log("Driver license information removed.");
- success(_("Your driver license information has been removed."));
- redirect(user_link($user_source));
}
- }
-
- return [
- sprintf(_("Edit %s driving license information"), $user_source['Nick']),
- UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
- ];
-}
-?> \ No newline at end of file
+ return [
+ sprintf(_('Edit %s driving license information'), $user_source['Nick']),
+ UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
+ ];
+}
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php
index 3825af7c..b1ef517e 100644
--- a/includes/controller/users_controller.php
+++ b/includes/controller/users_controller.php
@@ -1,371 +1,473 @@
<?php
-use Engelsystem\ShiftsFilter;
+
+use Engelsystem\Database\DB;
use Engelsystem\ShiftCalendarRenderer;
+use Engelsystem\ShiftsFilter;
/**
* Route user actions.
+ *
+ * @return array
*/
-function users_controller() {
- global $user;
-
- if (! isset($user)) {
- redirect(page_link_to(''));
- }
-
- if (! isset($_REQUEST['action'])) {
- $_REQUEST['action'] = 'list';
- }
-
- switch ($_REQUEST['action']) {
- default:
- case 'list':
- return users_list_controller();
- case 'view':
- return user_controller();
- case 'edit':
- return user_edit_controller();
- case 'delete':
- return user_delete_controller();
- case 'edit_vouchers':
- return user_edit_vouchers_controller();
- }
+function users_controller()
+{
+ global $user;
+ $request = request();
+
+ if (!isset($user)) {
+ redirect(page_link_to(''));
+ }
+
+ $action = 'list';
+ if ($request->has('action')) {
+ $action = $request->input('action');
+ }
+
+ switch ($action) {
+ case 'view':
+ return user_controller();
+ case 'delete':
+ return user_delete_controller();
+ case 'edit_vouchers':
+ return user_edit_vouchers_controller();
+ case 'list':
+ default:
+ return users_list_controller();
+ }
}
/**
* Delete a user, requires to enter own password for reasons.
+ *
+ * @return array
*/
-function user_delete_controller() {
- global $privileges, $user;
-
- if (isset($_REQUEST['user_id'])) {
- $user_source = User($_REQUEST['user_id']);
- } else {
- $user_source = $user;
- }
-
- if (! in_array('admin_user', $privileges)) {
- redirect(page_link_to(''));
- }
-
- // You cannot delete yourself
- if ($user['UID'] == $user_source['UID']) {
- error(_("You cannot delete yourself."));
- redirect(user_link($user));
- }
-
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (! (isset($_REQUEST['password']) && verify_password($_REQUEST['password'], $user['Passwort'], $user['UID']))) {
- $valid = false;
- error(_("Your password is incorrect. Please try it again."));
+function user_delete_controller()
+{
+ global $privileges, $user;
+ $request = request();
+
+ if ($request->has('user_id')) {
+ $user_source = User($request->query->get('user_id'));
+ } else {
+ $user_source = $user;
}
-
- if ($valid) {
- $result = User_delete($user_source['UID']);
- if ($result === false) {
- engelsystem_error('Unable to delete user.');
- }
-
- mail_user_delete($user_source);
- success(_("User deleted."));
- engelsystem_log(sprintf("Deleted %s", User_Nick_render($user_source)));
-
- redirect(users_link());
+
+ if (!in_array('admin_user', $privileges)) {
+ redirect(page_link_to(''));
}
- }
-
- return [
- sprintf(_("Delete %s"), $user_source['Nick']),
- User_delete_view($user_source)
- ];
+
+ // You cannot delete yourself
+ if ($user['UID'] == $user_source['UID']) {
+ error(_('You cannot delete yourself.'));
+ redirect(user_link($user));
+ }
+
+ if ($request->has('submit')) {
+ $valid = true;
+
+ if (
+ !(
+ $request->has('password')
+ && verify_password($request->postData('password'), $user['Passwort'], $user['UID'])
+ )
+ ) {
+ $valid = false;
+ error(_('Your password is incorrect. Please try it again.'));
+ }
+
+ if ($valid) {
+ User_delete($user_source['UID']);
+
+ mail_user_delete($user_source);
+ success(_('User deleted.'));
+ engelsystem_log(sprintf('Deleted %s', User_Nick_render($user_source)));
+
+ redirect(users_link());
+ }
+ }
+
+ return [
+ sprintf(_('Delete %s'), $user_source['Nick']),
+ User_delete_view($user_source)
+ ];
}
-function users_link() {
- return page_link_to('users');
+/**
+ * @return string
+ */
+function users_link()
+{
+ return page_link_to('users');
}
-function user_edit_link($user) {
- return page_link_to('admin_user') . '&user_id=' . $user['UID'];
+/**
+ * @param array $user
+ * @return string
+ */
+function user_edit_link($user)
+{
+ return page_link_to('admin_user', ['user_id' => $user['UID']]);
}
-function user_delete_link($user) {
- return page_link_to('users') . '&action=delete&user_id=' . $user['UID'];
+/**
+ * @param array $user
+ * @return string
+ */
+function user_delete_link($user)
+{
+ return page_link_to('users', ['action' => 'delete', 'user_id' => $user['UID']]);
}
-function user_link($user) {
- return page_link_to('users') . '&action=view&user_id=' . $user['UID'];
+/**
+ * @param array $user
+ * @return string
+ */
+function user_link($user)
+{
+ return page_link_to('users', ['action' => 'view', 'user_id' => $user['UID']]);
}
-function user_edit_vouchers_controller() {
- global $privileges, $user;
-
- if (isset($_REQUEST['user_id'])) {
- $user_source = User($_REQUEST['user_id']);
- } else {
- $user_source = $user;
- }
-
- if (! in_array('admin_user', $privileges)) {
- redirect(page_link_to(''));
- }
-
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) {
- $vouchers = trim($_REQUEST['vouchers']);
+/**
+ * @return array
+ */
+function user_edit_vouchers_controller()
+{
+ global $privileges, $user;
+ $request = request();
+
+ if ($request->has('user_id')) {
+ $user_source = User($request->input('user_id'));
} else {
- $valid = false;
- error(_("Please enter a valid number of vouchers."));
+ $user_source = $user;
}
-
- if ($valid) {
- $user_source['got_voucher'] = $vouchers;
-
- $result = User_update($user_source);
- if ($result === false) {
- engelsystem_error('Unable to update user.');
- }
-
- success(_("Saved the number of vouchers."));
- engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf("Got %s vouchers", $user_source['got_voucher']));
-
- redirect(user_link($user_source));
+
+ if (!in_array('admin_user', $privileges)) {
+ redirect(page_link_to(''));
}
- }
-
- return [
- sprintf(_("%s's vouchers"), $user_source['Nick']),
- User_edit_vouchers_view($user_source)
- ];
+
+ if ($request->has('submit')) {
+ $valid = true;
+
+ $vouchers = '';
+ if (
+ $request->has('vouchers')
+ && test_request_int('vouchers')
+ && trim($request->input('vouchers')) >= 0
+ ) {
+ $vouchers = trim($request->input('vouchers'));
+ } else {
+ $valid = false;
+ error(_('Please enter a valid number of vouchers.'));
+ }
+
+ if ($valid) {
+ $user_source['got_voucher'] = $vouchers;
+
+ User_update($user_source);
+
+ success(_('Saved the number of vouchers.'));
+ engelsystem_log(User_Nick_render($user_source) . ': ' . sprintf('Got %s vouchers',
+ $user_source['got_voucher']));
+
+ redirect(user_link($user_source));
+ }
+ }
+
+ return [
+ sprintf(_('%s\'s vouchers'), $user_source['Nick']),
+ User_edit_vouchers_view($user_source)
+ ];
}
-function user_controller() {
- global $privileges, $user;
-
- $user_source = $user;
- if (isset($_REQUEST['user_id'])) {
- $user_source = User($_REQUEST['user_id']);
- if ($user_source == null) {
- error(_("User not found."));
- redirect('?');
+/**
+ * @return array
+ */
+function user_controller()
+{
+ global $privileges, $user;
+ $request = request();
+
+ $user_source = $user;
+ if ($request->has('user_id')) {
+ $user_source = User($request->input('user_id'));
+ if ($user_source == null) {
+ error(_('User not found.'));
+ redirect(page_link_to('/'));
+ }
}
- }
-
- $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`");
- foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
- $needed_angeltype['users'] = sql_select("
- SELECT `ShiftEntry`.`freeloaded`, `User`.*
- FROM `ShiftEntry`
- JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
- WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "'
- AND `ShiftEntry`.`TID`='" . sql_escape($needed_angeltype['id']) . "'");
+
+ $shifts = Shifts_by_user($user_source, in_array('user_shifts_admin', $privileges));
+ foreach ($shifts as &$shift) {
+ // TODO: Move queries to model
+ $shift['needed_angeltypes'] = DB::select('
+ SELECT DISTINCT `AngelTypes`.*
+ FROM `ShiftEntry`
+ JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
+ WHERE `ShiftEntry`.`SID` = ?
+ ORDER BY `AngelTypes`.`name`
+ ',
+ [$shift['SID']]
+ );
+ foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
+ $needed_angeltype['users'] = DB::select('
+ SELECT `ShiftEntry`.`freeloaded`, `User`.*
+ FROM `ShiftEntry`
+ JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
+ WHERE `ShiftEntry`.`SID` = ?
+ AND `ShiftEntry`.`TID` = ?
+ ',
+ [$shift['SID'], $needed_angeltype['id']]
+ );
+ }
}
- }
-
- if ($user_source['api_key'] == "") {
- User_reset_api_key($user_source, false);
- }
-
- return [
- $user_source['Nick'],
- User_view($user_source, in_array('admin_user', $privileges), User_is_freeloader($user_source), User_angeltypes($user_source), User_groups($user_source), $shifts, $user['UID'] == $user_source['UID'])
- ];
+
+ if ($user_source['api_key'] == '') {
+ User_reset_api_key($user_source, false);
+ }
+
+ return [
+ $user_source['Nick'],
+ User_view(
+ $user_source,
+ in_array('admin_user', $privileges),
+ User_is_freeloader($user_source),
+ User_angeltypes($user_source),
+ User_groups($user_source),
+ $shifts,
+ $user['UID'] == $user_source['UID']
+ )
+ ];
}
/**
* List all users.
+ *
+ * @return array
*/
-function users_list_controller() {
- global $privileges;
-
- if (! in_array('admin_user', $privileges)) {
- redirect(page_link_to(''));
- }
-
- $order_by = 'Nick';
- if (isset($_REQUEST['OrderBy']) && in_array($_REQUEST['OrderBy'], User_sortable_columns())) {
- $order_by = $_REQUEST['OrderBy'];
- }
-
- $users = Users($order_by);
- if ($users === false) {
- engelsystem_error('Unable to load users.');
- }
-
- foreach ($users as &$user) {
- $user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
- }
-
- return [
- _('All users'),
- Users_view($users, $order_by, User_arrived_count(), User_active_count(), User_force_active_count(), ShiftEntries_freeleaded_count(), User_tshirts_count(), User_got_voucher_count())
- ];
+function users_list_controller()
+{
+ global $privileges;
+ $request = request();
+
+ if (!in_array('admin_user', $privileges)) {
+ redirect(page_link_to(''));
+ }
+
+ $order_by = 'Nick';
+ if ($request->has('OrderBy') && in_array($request->input('OrderBy'), User_sortable_columns())) {
+ $order_by = $request->input('OrderBy');
+ }
+
+ $users = Users($order_by);
+ foreach ($users as &$user) {
+ $user['freeloads'] = count(ShiftEntries_freeloaded_by_user($user));
+ }
+
+ return [
+ _('All users'),
+ Users_view(
+ $users,
+ $order_by,
+ User_arrived_count(),
+ User_active_count(),
+ User_force_active_count(),
+ ShiftEntries_freeleaded_count(),
+ User_tshirts_count(),
+ User_got_voucher_count()
+ )
+ ];
}
/**
* Second step of password recovery: set a new password using the token link from email
+ *
+ * @return string
*/
-function user_password_recovery_set_new_controller() {
- global $min_password_length;
- $user_source = User_by_password_recovery_token($_REQUEST['token']);
- if ($user_source == null) {
- error(_("Token is not correct."));
- redirect(page_link_to('login'));
- }
-
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= $min_password_length) {
- if ($_REQUEST['password'] != $_REQUEST['password2']) {
- $valid = false;
- error(_("Your passwords don't match."));
- }
- } else {
- $valid = false;
- error(_("Your password is to short (please use at least 6 characters)."));
+function user_password_recovery_set_new_controller()
+{
+ $request = request();
+ $user_source = User_by_password_recovery_token($request->input('token'));
+ if ($user_source == null) {
+ error(_('Token is not correct.'));
+ redirect(page_link_to('login'));
}
-
- if ($valid) {
- set_password($user_source['UID'], $_REQUEST['password']);
- success(_("Password saved."));
- redirect(page_link_to('login'));
+
+ if ($request->has('submit')) {
+ $valid = true;
+
+ if (
+ $request->has('password')
+ && strlen($request->postData('password')) >= config('min_password_length')
+ ) {
+ if ($request->postData('password') != $request->postData('password2')) {
+ $valid = false;
+ error(_('Your passwords don\'t match.'));
+ }
+ } else {
+ $valid = false;
+ error(_('Your password is to short (please use at least 6 characters).'));
+ }
+
+ if ($valid) {
+ set_password($user_source['UID'], $request->postData('password'));
+ success(_('Password saved.'));
+ redirect(page_link_to('login'));
+ }
}
- }
-
- return User_password_set_view();
+
+ return User_password_set_view();
}
/**
* First step of password recovery: display a form that asks for your email and send email with recovery link
+ *
+ * @return string
*/
-function user_password_recovery_start_controller() {
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) {
- $email = strip_request_item('email');
- if (check_email($email)) {
- $user_source = User_by_email($email);
- if ($user_source == null) {
- $valid = false;
- error(_("E-mail address is not correct."));
+function user_password_recovery_start_controller()
+{
+ $request = request();
+ if ($request->has('submit')) {
+ $valid = true;
+
+ if ($request->has('email') && strlen(strip_request_item('email')) > 0) {
+ $email = strip_request_item('email');
+ if (check_email($email)) {
+ $user_source = User_by_email($email);
+ if ($user_source == null) {
+ $valid = false;
+ error(_('E-mail address is not correct.'));
+ }
+ } else {
+ $valid = false;
+ error(_('E-mail address is not correct.'));
+ }
+ } else {
+ $valid = false;
+ error(_('Please enter your e-mail.'));
+ }
+
+ if ($valid) {
+ $token = User_generate_password_recovery_token($user_source);
+ engelsystem_email_to_user(
+ $user_source,
+ _('Password recovery'),
+ sprintf(
+ _('Please visit %s to recover your password.'),
+ page_link_to('user_password_recovery', ['token' => $token])
+ )
+ );
+ success(_('We sent an email containing your password recovery link.'));
+ redirect(page_link_to('login'));
}
- } else {
- $valid = false;
- error(_("E-mail address is not correct."));
- }
- } else {
- $valid = false;
- error(_("Please enter your e-mail."));
- }
-
- if ($valid) {
- $token = User_generate_password_recovery_token($user_source);
- engelsystem_email_to_user($user_source, _("Password recovery"), sprintf(_("Please visit %s to recover your password."), page_link_to_absolute('user_password_recovery') . '&token=' . $token));
- success(_("We sent an email containing your password recovery link."));
- redirect(page_link_to('login'));
}
- }
-
- return User_password_recovery_view();
+
+ return User_password_recovery_view();
}
/**
* User password recovery in 2 steps.
* (By email)
+ *
+ * @return string
*/
-function user_password_recovery_controller() {
- if (isset($_REQUEST['token'])) {
- return user_password_recovery_set_new_controller();
- } else {
+function user_password_recovery_controller()
+{
+ if (request()->has('token')) {
+ return user_password_recovery_set_new_controller();
+ }
+
return user_password_recovery_start_controller();
- }
}
/**
* Menu title for password recovery.
+ *
+ * @return string
*/
-function user_password_recovery_title() {
- return _("Password recovery");
+function user_password_recovery_title()
+{
+ return _('Password recovery');
}
/**
* Loads a user from param user_id.
+ *
+ * return array
*/
-function load_user() {
- if (! isset($_REQUEST['user_id'])) {
- redirect(page_link_to());
- }
-
- $user = User($_REQUEST['user_id']);
- if ($user === false) {
- engelsystem_error("Unable to load user.");
- }
-
- if ($user == null) {
- error(_("User doesn't exist."));
- redirect(page_link_to());
- }
-
- return $user;
+function load_user()
+{
+ $request = request();
+ if (!$request->has('user_id')) {
+ redirect(page_link_to());
+ }
+
+ $user = User($request->input('user_id'));
+
+ if ($user == null) {
+ error(_('User doesn\'t exist.'));
+ redirect(page_link_to());
+ }
+
+ return $user;
}
-function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) {
- $shifts = Shifts_by_ShiftsFilter($shiftsFilter);
- $needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
- $shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
-
- $needed_angeltypes = [];
- $shift_entries = [];
- foreach ($shifts as $shift) {
- $needed_angeltypes[$shift['SID']] = [];
- $shift_entries[$shift['SID']] = [];
- }
- foreach ($shift_entries_source as $shift_entry) {
- if (isset($shift_entries[$shift_entry['SID']])) {
- $shift_entries[$shift_entry['SID']][] = $shift_entry;
+/**
+ * @param ShiftsFilter $shiftsFilter
+ * @return ShiftCalendarRenderer
+ */
+function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
+{
+ $shifts = Shifts_by_ShiftsFilter($shiftsFilter);
+ $needed_angeltypes_source = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
+ $shift_entries_source = ShiftEntries_by_ShiftsFilter($shiftsFilter);
+
+ $needed_angeltypes = [];
+ $shift_entries = [];
+ foreach ($shifts as $shift) {
+ $needed_angeltypes[$shift['SID']] = [];
+ $shift_entries[$shift['SID']] = [];
}
- }
- foreach ($needed_angeltypes_source as $needed_angeltype) {
- if (isset($needed_angeltypes[$needed_angeltype['SID']])) {
- $needed_angeltypes[$needed_angeltype['SID']][] = $needed_angeltype;
+ foreach ($shift_entries_source as $shift_entry) {
+ if (isset($shift_entries[$shift_entry['SID']])) {
+ $shift_entries[$shift_entry['SID']][] = $shift_entry;
+ }
}
- }
- unset($needed_angeltypes_source);
- unset($shift_entries_source);
-
- if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled())) {
- return new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
- }
-
- $filtered_shifts = [];
- foreach ($shifts as $shift) {
- $needed_angels_count = 0;
- foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) {
- $taken = 0;
- foreach ($shift_entries[$shift['SID']] as $shift_entry) {
- if ($needed_angeltype['angel_type_id'] == $shift_entry['TID'] && $shift_entry['freeloaded'] == 0) {
- $taken ++;
+ foreach ($needed_angeltypes_source as $needed_angeltype) {
+ if (isset($needed_angeltypes[$needed_angeltype['SID']])) {
+ $needed_angeltypes[$needed_angeltype['SID']][] = $needed_angeltype;
}
- }
-
- $needed_angels_count += max(0, $needed_angeltype['count'] - $taken);
}
- if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
- $filtered_shifts[] = $shift;
+ unset($needed_angeltypes_source);
+ unset($shift_entries_source);
+
+ if (
+ in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled())
+ && in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled())
+ ) {
+ return new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
}
- if (in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled()) && $taken >= $needed_angels_count) {
- $filtered_shifts[] = $shift;
+
+ $filtered_shifts = [];
+ foreach ($shifts as $shift) {
+ $needed_angels_count = 0;
+ $taken = 0;
+ foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) {
+ $taken = 0;
+ foreach ($shift_entries[$shift['SID']] as $shift_entry) {
+ if ($needed_angeltype['angel_type_id'] == $shift_entry['TID'] && $shift_entry['freeloaded'] == 0) {
+ $taken++;
+ }
+ }
+
+ $needed_angels_count += max(0, $needed_angeltype['count'] - $taken);
+ }
+ if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
+ $filtered_shifts[] = $shift;
+ }
+ if (in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled()) && $taken >= $needed_angels_count) {
+ $filtered_shifts[] = $shift;
+ }
}
- }
-
- return new ShiftCalendarRenderer($filtered_shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
-}
-?>
+ return new ShiftCalendarRenderer($filtered_shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
+}
diff --git a/includes/engelsystem.php b/includes/engelsystem.php
new file mode 100644
index 00000000..07abbb42
--- /dev/null
+++ b/includes/engelsystem.php
@@ -0,0 +1,63 @@
+<?php
+
+use Engelsystem\Application;
+use Engelsystem\Config\Config;
+use Engelsystem\Exceptions\Handler;
+use Engelsystem\Exceptions\Handlers\HandlerInterface;
+
+/**
+ * This file includes all needed functions, connects to the db etc.
+ */
+require_once __DIR__ . '/autoload.php';
+
+
+/**
+ * Include legacy code
+ */
+require __DIR__ . '/includes.php';
+
+
+/**
+ * Initialize and bootstrap the application
+ */
+$app = new Application(realpath(__DIR__ . DIRECTORY_SEPARATOR . '..'));
+$appConfig = $app->make(Config::class);
+$appConfig->set(require config_path('app.php'));
+$app->bootstrap($appConfig);
+
+
+/**
+ * Configure application
+ */
+date_default_timezone_set($app->get('config')->get('timezone'));
+
+if (config('environment') == 'development') {
+ $errorHandler = $app->get('error.handler');
+ $errorHandler->setEnvironment(Handler::ENV_DEVELOPMENT);
+ $app->bind(HandlerInterface::class, 'error.handler.development');
+ ini_set('display_errors', true);
+ error_reporting(E_ALL);
+} else {
+ ini_set('display_errors', false);
+}
+
+
+/**
+ * Check for maintenance
+ */
+if ($app->get('config')->get('maintenance')) {
+ echo file_get_contents(__DIR__ . '/../templates/maintenance.html');
+ die();
+}
+
+
+/**
+ * Init translations
+ */
+gettext_init();
+
+
+/**
+ * Init authorization
+ */
+load_auth();
diff --git a/includes/engelsystem_provider.php b/includes/engelsystem_provider.php
deleted file mode 100644
index 595af9f9..00000000
--- a/includes/engelsystem_provider.php
+++ /dev/null
@@ -1,104 +0,0 @@
-<?php
-/**
- * This file includes all needed functions, connects to the db etc.
- */
-require_once realpath(__DIR__ . '/../includes/mysqli_provider.php');
-
-require_once realpath(__DIR__ . '/../includes/sys_auth.php');
-require_once realpath(__DIR__ . '/../includes/sys_form.php');
-require_once realpath(__DIR__ . '/../includes/sys_log.php');
-require_once realpath(__DIR__ . '/../includes/sys_menu.php');
-require_once realpath(__DIR__ . '/../includes/sys_page.php');
-require_once realpath(__DIR__ . '/../includes/sys_template.php');
-
-require_once realpath(__DIR__ . '/../includes/model/AngelType_model.php');
-require_once realpath(__DIR__ . '/../includes/model/EventConfig_model.php');
-require_once realpath(__DIR__ . '/../includes/model/LogEntries_model.php');
-require_once realpath(__DIR__ . '/../includes/model/Message_model.php');
-require_once realpath(__DIR__ . '/../includes/model/NeededAngelTypes_model.php');
-require_once realpath(__DIR__ . '/../includes/model/Room_model.php');
-require_once realpath(__DIR__ . '/../includes/model/ShiftEntry_model.php');
-require_once realpath(__DIR__ . '/../includes/model/Shifts_model.php');
-require_once realpath(__DIR__ . '/../includes/model/ShiftsFilter.php');
-require_once realpath(__DIR__ . '/../includes/model/ShiftSignupState.php');
-require_once realpath(__DIR__ . '/../includes/model/ShiftTypes_model.php');
-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');
-require_once realpath(__DIR__ . '/../includes/view/Questions_view.php');
-require_once realpath(__DIR__ . '/../includes/view/Rooms_view.php');
-require_once realpath(__DIR__ . '/../includes/view/ShiftCalendarLane.php');
-require_once realpath(__DIR__ . '/../includes/view/ShiftCalendarRenderer.php');
-require_once realpath(__DIR__ . '/../includes/view/ShiftCalendarShiftRenderer.php');
-require_once realpath(__DIR__ . '/../includes/view/ShiftsFilterRenderer.php');
-require_once realpath(__DIR__ . '/../includes/view/Shifts_view.php');
-require_once realpath(__DIR__ . '/../includes/view/ShiftEntry_view.php');
-require_once realpath(__DIR__ . '/../includes/view/ShiftTypes_view.php');
-require_once realpath(__DIR__ . '/../includes/view/UserAngelTypes_view.php');
-require_once realpath(__DIR__ . '/../includes/view/UserDriverLicenses_view.php');
-require_once realpath(__DIR__ . '/../includes/view/UserHintsRenderer.php');
-require_once realpath(__DIR__ . '/../includes/view/User_view.php');
-
-require_once realpath(__DIR__ . '/../includes/controller/angeltypes_controller.php');
-require_once realpath(__DIR__ . '/../includes/controller/event_config_controller.php');
-require_once realpath(__DIR__ . '/../includes/controller/rooms_controller.php');
-require_once realpath(__DIR__ . '/../includes/controller/shift_entries_controller.php');
-require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
-require_once realpath(__DIR__ . '/../includes/controller/shifttypes_controller.php');
-require_once realpath(__DIR__ . '/../includes/controller/users_controller.php');
-require_once realpath(__DIR__ . '/../includes/controller/user_angeltypes_controller.php');
-require_once realpath(__DIR__ . '/../includes/controller/user_driver_licenses_controller.php');
-
-require_once realpath(__DIR__ . '/../includes/helper/graph_helper.php');
-require_once realpath(__DIR__ . '/../includes/helper/internationalization_helper.php');
-require_once realpath(__DIR__ . '/../includes/helper/message_helper.php');
-require_once realpath(__DIR__ . '/../includes/helper/error_helper.php');
-require_once realpath(__DIR__ . '/../includes/helper/email_helper.php');
-
-require_once realpath(__DIR__ . '/../includes/mailer/shifts_mailer.php');
-require_once realpath(__DIR__ . '/../includes/mailer/users_mailer.php');
-
-require_once realpath(__DIR__ . '/../config/config.default.php');
-if (file_exists(realpath(__DIR__ . '/../config/config.php'))) {
- require_once realpath(__DIR__ . '/../config/config.php');
-}
-
-if ($maintenance_mode) {
- echo file_get_contents(__DIR__ . '/../public/maintenance.html');
- die();
-}
-
-require_once realpath(__DIR__ . '/../includes/pages/admin_active.php');
-require_once realpath(__DIR__ . '/../includes/pages/admin_arrive.php');
-require_once realpath(__DIR__ . '/../includes/pages/admin_free.php');
-require_once realpath(__DIR__ . '/../includes/pages/admin_groups.php');
-require_once realpath(__DIR__ . '/../includes/pages/admin_import.php');
-require_once realpath(__DIR__ . '/../includes/pages/admin_log.php');
-require_once realpath(__DIR__ . '/../includes/pages/admin_questions.php');
-require_once realpath(__DIR__ . '/../includes/pages/admin_rooms.php');
-require_once realpath(__DIR__ . '/../includes/pages/admin_shifts.php');
-require_once realpath(__DIR__ . '/../includes/pages/admin_user.php');
-require_once realpath(__DIR__ . '/../includes/pages/guest_login.php');
-require_once realpath(__DIR__ . '/../includes/pages/user_messages.php');
-require_once realpath(__DIR__ . '/../includes/pages/user_myshifts.php');
-require_once realpath(__DIR__ . '/../includes/pages/user_news.php');
-require_once realpath(__DIR__ . '/../includes/pages/user_questions.php');
-require_once realpath(__DIR__ . '/../includes/pages/user_settings.php');
-require_once realpath(__DIR__ . '/../includes/pages/user_shifts.php');
-
-require_once realpath(__DIR__ . '/../vendor/parsedown/Parsedown.php');
-
-session_start();
-
-gettext_init();
-
-sql_connect($config['host'], $config['user'], $config['pw'], $config['db']);
-
-load_auth();
-
-?>
diff --git a/includes/helper/email_helper.php b/includes/helper/email_helper.php
index 462b5641..dad27b39 100644
--- a/includes/helper/email_helper.php
+++ b/includes/helper/email_helper.php
@@ -1,26 +1,50 @@
<?php
-function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false) {
- global $user;
-
- if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
- return true;
- }
-
- gettext_locale($recipient_user['Sprache']);
-
- $message = sprintf(_("Hi %s,"), $recipient_user['Nick']) . "\n\n" . _("here is a message for you from the engelsystem:") . "\n\n" . $message . "\n\n" . _("This email is autogenerated and has not to be signed. You got this email because you are registered in the engelsystem.");
-
- gettext_locale();
- return engelsystem_email($recipient_user['email'], $title, $message);
-}
+/**
+ * @param array $recipient_user
+ * @param string $title
+ * @param string $message
+ * @param bool $not_if_its_me
+ * @return bool
+ */
+function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
+{
+ global $user;
+
+ if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
+ return true;
+ }
+
+ gettext_locale($recipient_user['Sprache']);
+
+ $message = sprintf(_('Hi %s,'), $recipient_user['Nick']) . "\n\n"
+ . _('here is a message for you from the engelsystem:') . "\n\n"
+ . $message . "\n\n"
+ . _('This email is autogenerated and has not to be signed. You got this email because you are registered in the engelsystem.');
-function engelsystem_email($address, $title, $message) {
- global $no_reply_email;
- $result = mail($address, $title, $message, sprintf("Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>", $no_reply_email));
- if ($result === false) {
- engelsystem_error('Unable to send email.');
- }
+ gettext_locale();
+
+ return engelsystem_email($recipient_user['email'], $title, $message);
}
-?>
+/**
+ * @param string $address
+ * @param string $title
+ * @param string $message
+ * @return bool
+ */
+function engelsystem_email($address, $title, $message)
+{
+ $result = mail(
+ $address,
+ $title,
+ $message,
+ sprintf("Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>", config('no_reply_email'))
+ );
+
+ if ($result === false) {
+ engelsystem_error('Unable to send email.');
+ }
+
+ return true;
+}
diff --git a/includes/helper/error_helper.php b/includes/helper/error_helper.php
index 58d0ac86..9314a57a 100644
--- a/includes/helper/error_helper.php
+++ b/includes/helper/error_helper.php
@@ -5,8 +5,7 @@
*
* @param string $message
*/
-function engelsystem_error($message) {
- raw_output($message);
+function engelsystem_error($message)
+{
+ raw_output($message);
}
-
-?> \ No newline at end of file
diff --git a/includes/helper/graph_helper.php b/includes/helper/graph_helper.php
index 42a6c07a..12c7df6c 100644
--- a/includes/helper/graph_helper.php
+++ b/includes/helper/graph_helper.php
@@ -2,40 +2,42 @@
/**
* Renders a bargraph
- * @param string $key keyname of the x-axis
- * @param array $row_names keynames for the data rows
- * @param unknown $colors colors for the data rows
- * @param unknown $data the data
+ *
+ * @param string $dom_id
+ * @param string $key key name of the x-axis
+ * @param array $row_names key names for the data rows
+ * @param array $colors colors for the data rows
+ * @param array $data the data
+ * @return string
*/
-function bargraph($dom_id, $key, $row_names, $colors, $data) {
- $labels = [];
- foreach ($data as $dataset) {
- $labels[] = $dataset[$key];
- }
-
- $datasets = [];
- foreach ($row_names as $row_key => $name) {
- $values = [];
+function bargraph($dom_id, $key, $row_names, $colors, $data)
+{
+ $labels = [];
foreach ($data as $dataset) {
- $values[] = $dataset[$row_key];
+ $labels[] = $dataset[$key];
}
- $datasets[] = [
- 'label' => $name,
- 'fillColor' => $colors[$row_key],
- 'data' => $values
- ];
- }
-
- return '<canvas id="' . $dom_id . '" style="width: 100%; height: 300px;"></canvas>
+
+ $datasets = [];
+ foreach ($row_names as $row_key => $name) {
+ $values = [];
+ foreach ($data as $dataset) {
+ $values[] = $dataset[$row_key];
+ }
+ $datasets[] = [
+ 'label' => $name,
+ 'fillColor' => $colors[$row_key],
+ 'data' => $values
+ ];
+ }
+
+ return '<canvas id="' . $dom_id . '" style="width: 100%; height: 300px;"></canvas>
<script type="text/javascript">
$(function(){
var ctx = $("#' . $dom_id . '").get(0).getContext("2d");
var chart = new Chart(ctx).Bar(' . json_encode([
- 'labels' => $labels,
- 'datasets' => $datasets
- ]) . ');
+ 'labels' => $labels,
+ 'datasets' => $datasets
+ ]) . ');
});
</script>';
}
-
-?> \ No newline at end of file
diff --git a/includes/helper/internationalization_helper.php b/includes/helper/internationalization_helper.php
index a537ef3d..7fa6518b 100644
--- a/includes/helper/internationalization_helper.php
+++ b/includes/helper/internationalization_helper.php
@@ -1,71 +1,83 @@
<?php
-$locales = [
- 'de_DE.UTF-8' => "Deutsch",
- 'en_US.UTF-8' => "English"
-];
-
-$default_locale = 'en_US.UTF-8';
/**
* Return currently active locale
+ *
+ * @return string
*/
-function locale() {
- return $_SESSION['locale'];
+function locale()
+{
+ return session()->get('locale');
}
/**
* Returns two letter language code from currently active locale
+ *
+ * @return string
*/
-function locale_short() {
- return substr(locale(), 0, 2);
+function locale_short()
+{
+ return substr(locale(), 0, 2);
}
/**
* Initializes gettext for internationalization and updates the sessions locale to use for translation.
*/
-function gettext_init() {
- global $locales, $default_locale;
+function gettext_init()
+{
+ $locales = config('locales');
+ $request = request();
+ $session = session();
- if (isset($_REQUEST['set_locale']) && isset($locales[$_REQUEST['set_locale']])) {
- $_SESSION['locale'] = $_REQUEST['set_locale'];
- } elseif (! isset($_SESSION['locale'])) {
- $_SESSION['locale'] = $default_locale;
- }
+ if ($request->has('set_locale') && isset($locales[$request->input('set_locale')])) {
+ $session->set('locale', $request->input('set_locale'));
+ } elseif (!$session->has('locale')) {
+ $session->set('locale', config('default_locale'));
+ }
- gettext_locale();
- bindtextdomain('default', realpath(__DIR__ . '/../../locale'));
- bind_textdomain_codeset('default', 'UTF-8');
- textdomain('default');
+ gettext_locale();
+ bindtextdomain('default', app('path.lang'));
+ bind_textdomain_codeset('default', 'UTF-8');
+ textdomain('default');
}
/**
* Swich gettext locale.
*
- * @param string $locale
+ * @param string $locale
*/
-function gettext_locale($locale = null) {
- if ($locale == null) {
- $locale = $_SESSION['locale'];
- }
-
- putenv('LC_ALL=' . $locale);
- setlocale(LC_ALL, $locale);
+function gettext_locale($locale = null)
+{
+ if ($locale == null) {
+ $locale = session()->get('locale');
+ }
+
+ putenv('LC_ALL=' . $locale);
+ setlocale(LC_ALL, $locale);
}
/**
* Renders language selection.
*
- * @return string
+ * @return array
*/
-function make_langselect() {
- global $locales;
- $URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale=";
-
- $items = [];
- foreach ($locales as $locale => $name) {
- $items[] = toolbar_item_link(htmlspecialchars($URL) . $locale, '', '<img src="pic/flag/' . $locale . '.png" alt="' . $name . '" title="' . $name . '"> ' . $name);
- }
- return $items;
-}
+function make_langselect()
+{
+ $request = app('request');
-?> \ No newline at end of file
+ $items = [];
+ foreach (config('locales') as $locale => $name) {
+ $url = url($request->getPathInfo(), ['set_locale' => $locale]);
+
+ $items[] = toolbar_item_link(
+ htmlspecialchars($url),
+ '',
+ sprintf(
+ '<img src="%s" alt="%s" title="%2$s"> %2$s',
+ url('pic/flag/' . $locale . '.png'),
+ $name
+ )
+ );
+ }
+ return $items;
+}
diff --git a/includes/helper/message_helper.php b/includes/helper/message_helper.php
index 37fc84bb..4fa0efe3 100644
--- a/includes/helper/message_helper.php
+++ b/includes/helper/message_helper.php
@@ -2,52 +2,78 @@
/**
* Gibt zwischengespeicherte Fehlermeldungen zurück und löscht den Zwischenspeicher
+ *
+ * @return string
*/
-function msg() {
- if (! isset($_SESSION['msg'])) {
- return "";
- }
- $msg = $_SESSION['msg'];
- $_SESSION['msg'] = "";
- return $msg;
+function msg()
+{
+ $session = session();
+
+ $message = $session->get('msg', '');
+ $session->set('msg', '');
+
+ return $message;
}
/**
* Rendert eine Information
+ *
+ * @param string $msg
+ * @param bool $immediately
+ * @return string
*/
-function info($msg, $immediatly = false) {
- return alert('info', $msg, $immediatly);
+function info($msg, $immediately = false)
+{
+ return alert('info', $msg, $immediately);
}
/**
* Rendert eine Fehlermeldung
+ *
+ * @param string $msg
+ * @param bool $immediately
+ * @return string
*/
-function error($msg, $immediatly = false) {
- return alert('danger', $msg, $immediatly);
+function error($msg, $immediately = false)
+{
+ return alert('danger', $msg, $immediately);
}
/**
* Rendert eine Erfolgsmeldung
+ *
+ * @param string $msg
+ * @param bool $immediately
+ * @return string
*/
-function success($msg, $immediatly = false) {
- return alert('success', $msg, $immediatly);
+function success($msg, $immediately = false)
+{
+ return alert('success', $msg, $immediately);
}
/**
* Renders an alert with given alert-* class.
+ *
+ * @param string $class
+ * @param string $msg
+ * @param bool $immediately
+ * @return string
*/
-function alert($class, $msg, $immediatly = false) {
- if ($immediatly) {
- if ($msg == "") {
- return "";
+function alert($class, $msg, $immediately = false)
+{
+ $session = session();
+
+ if (empty($msg)) {
+ return '';
}
- return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
- }
-
- if (! isset($_SESSION['msg'])) {
- $_SESSION['msg'] = "";
- }
- $_SESSION['msg'] .= alert($class, $msg, true);
-}
-?> \ No newline at end of file
+ if ($immediately) {
+ return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
+ }
+
+ $message = $session->get('msg', '');
+ $message .= alert($class, $msg, true);
+ $session->set('msg', $message);
+
+ return '';
+}
diff --git a/includes/includes.php b/includes/includes.php
new file mode 100644
index 00000000..a42f960f
--- /dev/null
+++ b/includes/includes.php
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * Include legacy code
+ */
+$includeFiles = [
+ __DIR__ . '/../includes/sys_auth.php',
+ __DIR__ . '/../includes/sys_form.php',
+ __DIR__ . '/../includes/sys_log.php',
+ __DIR__ . '/../includes/sys_menu.php',
+ __DIR__ . '/../includes/sys_page.php',
+ __DIR__ . '/../includes/sys_template.php',
+
+ __DIR__ . '/../includes/model/AngelType_model.php',
+ __DIR__ . '/../includes/model/EventConfig_model.php',
+ __DIR__ . '/../includes/model/LogEntries_model.php',
+ __DIR__ . '/../includes/model/Message_model.php',
+ __DIR__ . '/../includes/model/NeededAngelTypes_model.php',
+ __DIR__ . '/../includes/model/Room_model.php',
+ __DIR__ . '/../includes/model/ShiftEntry_model.php',
+ __DIR__ . '/../includes/model/Shifts_model.php',
+ __DIR__ . '/../includes/model/ShiftsFilter.php',
+ __DIR__ . '/../includes/model/ShiftSignupState.php',
+ __DIR__ . '/../includes/model/ShiftTypes_model.php',
+ __DIR__ . '/../includes/model/UserAngelTypes_model.php',
+ __DIR__ . '/../includes/model/UserDriverLicenses_model.php',
+ __DIR__ . '/../includes/model/UserGroups_model.php',
+ __DIR__ . '/../includes/model/User_model.php',
+ __DIR__ . '/../includes/model/ValidationResult.php',
+
+ __DIR__ . '/../includes/view/AngelTypes_view.php',
+ __DIR__ . '/../includes/view/EventConfig_view.php',
+ __DIR__ . '/../includes/view/Questions_view.php',
+ __DIR__ . '/../includes/view/Rooms_view.php',
+ __DIR__ . '/../includes/view/ShiftCalendarLane.php',
+ __DIR__ . '/../includes/view/ShiftCalendarRenderer.php',
+ __DIR__ . '/../includes/view/ShiftCalendarShiftRenderer.php',
+ __DIR__ . '/../includes/view/ShiftsFilterRenderer.php',
+ __DIR__ . '/../includes/view/Shifts_view.php',
+ __DIR__ . '/../includes/view/ShiftEntry_view.php',
+ __DIR__ . '/../includes/view/ShiftTypes_view.php',
+ __DIR__ . '/../includes/view/UserAngelTypes_view.php',
+ __DIR__ . '/../includes/view/UserDriverLicenses_view.php',
+ __DIR__ . '/../includes/view/UserHintsRenderer.php',
+ __DIR__ . '/../includes/view/User_view.php',
+
+ __DIR__ . '/../includes/controller/angeltypes_controller.php',
+ __DIR__ . '/../includes/controller/event_config_controller.php',
+ __DIR__ . '/../includes/controller/rooms_controller.php',
+ __DIR__ . '/../includes/controller/shift_entries_controller.php',
+ __DIR__ . '/../includes/controller/shifts_controller.php',
+ __DIR__ . '/../includes/controller/shifttypes_controller.php',
+ __DIR__ . '/../includes/controller/users_controller.php',
+ __DIR__ . '/../includes/controller/user_angeltypes_controller.php',
+ __DIR__ . '/../includes/controller/user_driver_licenses_controller.php',
+
+ __DIR__ . '/../includes/helper/graph_helper.php',
+ __DIR__ . '/../includes/helper/internationalization_helper.php',
+ __DIR__ . '/../includes/helper/message_helper.php',
+ __DIR__ . '/../includes/helper/error_helper.php',
+ __DIR__ . '/../includes/helper/email_helper.php',
+
+ __DIR__ . '/../includes/mailer/shifts_mailer.php',
+ __DIR__ . '/../includes/mailer/users_mailer.php',
+
+ __DIR__ . '/../includes/pages/admin_active.php',
+ __DIR__ . '/../includes/pages/admin_arrive.php',
+ __DIR__ . '/../includes/pages/admin_free.php',
+ __DIR__ . '/../includes/pages/admin_groups.php',
+ __DIR__ . '/../includes/pages/admin_import.php',
+ __DIR__ . '/../includes/pages/admin_log.php',
+ __DIR__ . '/../includes/pages/admin_questions.php',
+ __DIR__ . '/../includes/pages/admin_rooms.php',
+ __DIR__ . '/../includes/pages/admin_shifts.php',
+ __DIR__ . '/../includes/pages/admin_user.php',
+ __DIR__ . '/../includes/pages/guest_login.php',
+ __DIR__ . '/../includes/pages/user_messages.php',
+ __DIR__ . '/../includes/pages/user_myshifts.php',
+ __DIR__ . '/../includes/pages/user_news.php',
+ __DIR__ . '/../includes/pages/user_questions.php',
+ __DIR__ . '/../includes/pages/user_settings.php',
+ __DIR__ . '/../includes/pages/user_shifts.php',
+];
+foreach ($includeFiles as $file) {
+ require_once realpath($file);
+}
diff --git a/includes/mailer/shifts_mailer.php b/includes/mailer/shifts_mailer.php
index e1bf422b..5c0e4310 100644
--- a/includes/mailer/shifts_mailer.php
+++ b/includes/mailer/shifts_mailer.php
@@ -1,104 +1,129 @@
<?php
-function mail_shift_change($old_shift, $new_shift) {
- $users = ShiftEntries_by_shift($old_shift["SID"]);
- $old_room = Room($old_shift["RID"]);
- $new_room = Room($new_shift["RID"]);
-
- $noticable_changes = false;
-
- $message = _("A Shift you are registered on has changed:");
- $message .= "\n";
-
- if ($old_shift["name"] != $new_shift["name"]) {
- $message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
- $noticable_changes = true;
- }
-
- if ($old_shift["title"] != $new_shift["title"]) {
- $message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n";
- $noticable_changes = true;
- }
-
- if ($old_shift["start"] != $new_shift["start"]) {
- $message .= sprintf(_("* Shift Start changed from %s to %s"), date("Y-m-d H:i", $old_shift["start"]), date("Y-m-d H:i", $new_shift["start"])) . "\n";
- $noticable_changes = true;
- }
-
- if ($old_shift["end"] != $new_shift["end"]) {
- $message .= sprintf(_("* Shift End changed from %s to %s"), date("Y-m-d H:i", $old_shift["end"]), date("Y-m-d H:i", $new_shift["end"])) . "\n";
- $noticable_changes = true;
- }
-
- if ($old_shift["RID"] != $new_shift["RID"]) {
- $message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
- $noticable_changes = true;
- }
-
- if (! $noticable_changes) {
- // There are no changes worth sending an E-Mail
- return;
- }
-
- $message .= "\n";
- $message .= _("The updated Shift:") . "\n";
-
- $message .= $new_shift["name"] . "\n";
- $message .= $new_shift["title"] . "\n";
- $message .= date("Y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
- $message .= $new_room["Name"] . "\n";
-
- foreach ($users as $user) {
- if ($user["email_shiftinfo"]) {
- engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift has changed"), $message, true);
+/**
+ * @param array $old_shift
+ * @param array $new_shift
+ */
+function mail_shift_change($old_shift, $new_shift)
+{
+ $users = ShiftEntries_by_shift($old_shift['SID']);
+ $old_room = Room($old_shift['RID']);
+ $new_room = Room($new_shift['RID']);
+
+ $noticeable_changes = false;
+
+ $message = _('A Shift you are registered on has changed:');
+ $message .= "\n";
+
+ if ($old_shift['name'] != $new_shift['name']) {
+ $message .= sprintf(_('* Shift type changed from %s to %s'), $old_shift['name'], $new_shift['name']) . "\n";
+ $noticeable_changes = true;
+ }
+
+ if ($old_shift['title'] != $new_shift['title']) {
+ $message .= sprintf(_('* Shift title changed from %s to %s'), $old_shift['title'], $new_shift['title']) . "\n";
+ $noticeable_changes = true;
+ }
+
+ if ($old_shift['start'] != $new_shift['start']) {
+ $message .= sprintf(
+ _('* Shift Start changed from %s to %s'),
+ date('Y-m-d H:i', $old_shift['start']),
+ date('Y-m-d H:i', $new_shift['start'])
+ ) . "\n";
+ $noticeable_changes = true;
}
- }
-}
-function mail_shift_delete($shift) {
- $users = ShiftEntries_by_shift($shift["SID"]);
- $room = Room($shift["RID"]);
-
- $message = _("A Shift you are registered on was deleted:") . "\n";
-
- $message .= $shift["name"] . "\n";
- $message .= $shift["title"] . "\n";
- $message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
- $message .= $room["Name"] . "\n";
-
- foreach ($users as $user) {
- if ($user["email_shiftinfo"]) {
- engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message, true);
+ if ($old_shift['end'] != $new_shift['end']) {
+ $message .= sprintf(
+ _('* Shift End changed from %s to %s'),
+ date('Y-m-d H:i', $old_shift['end']),
+ date('Y-m-d H:i', $new_shift['end'])
+ ) . "\n";
+ $noticeable_changes = true;
+ }
+
+ if ($old_shift['RID'] != $new_shift['RID']) {
+ $message .= sprintf(_('* Shift Location changed from %s to %s'), $old_room['Name'], $new_room['Name']) . "\n";
+ $noticeable_changes = true;
+ }
+
+ if (!$noticeable_changes) {
+ // There are no changes worth sending an E-Mail
+ return;
+ }
+
+ $message .= "\n";
+ $message .= _('The updated Shift:') . "\n";
+
+ $message .= $new_shift['name'] . "\n";
+ $message .= $new_shift['title'] . "\n";
+ $message .= date('Y-m-d H:i', $new_shift['start']) . ' - ' . date('H:i', $new_shift['end']) . "\n";
+ $message .= $new_room['Name'] . "\n";
+
+ foreach ($users as $user) {
+ if ($user['email_shiftinfo']) {
+ engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift has changed'), $message, true);
+ }
}
- }
}
-function mail_shift_assign($user, $shift) {
- if ($user["email_shiftinfo"]) {
- $room = Room($shift["RID"]);
-
- $message = _("You have been assigned to a Shift:") . "\n";
- $message .= $shift["name"] . "\n";
- $message .= $shift["title"] . "\n";
- $message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
- $message .= $room["Name"] . "\n";
-
- engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true);
- }
+/**
+ * @param array $shift
+ */
+function mail_shift_delete($shift)
+{
+ $users = ShiftEntries_by_shift($shift['SID']);
+ $room = Room($shift['RID']);
+
+ $message = _('A Shift you are registered on was deleted:') . "\n";
+
+ $message .= $shift['name'] . "\n";
+ $message .= $shift['title'] . "\n";
+ $message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
+ $message .= $room['Name'] . "\n";
+
+ foreach ($users as $user) {
+ if ($user['email_shiftinfo']) {
+ engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift was deleted'), $message, true);
+ }
+ }
}
-function mail_shift_removed($user, $shift) {
- if ($user["email_shiftinfo"]) {
- $room = Room($shift["RID"]);
-
- $message = _("You have been removed from a Shift:") . "\n";
- $message .= $shift["name"] . "\n";
- $message .= $shift["title"] . "\n";
- $message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
- $message .= $room["Name"] . "\n";
-
- engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
- }
+/**
+ * @param array $user
+ * @param array $shift
+ */
+function mail_shift_assign($user, $shift)
+{
+ if (!$user['email_shiftinfo']) {
+ return;
+ }
+
+ $room = Room($shift['RID']);
+
+ $message = _('You have been assigned to a Shift:') . "\n";
+ $message .= $shift['name'] . "\n";
+ $message .= $shift['title'] . "\n";
+ $message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
+ $message .= $room['Name'] . "\n";
+
+ engelsystem_email_to_user($user, '[engelsystem] ' . _('Assigned to Shift'), $message, true);
}
-?>
+function mail_shift_removed($user, $shift)
+{
+ if (!$user['email_shiftinfo']) {
+ return;
+ }
+
+ $room = Room($shift['RID']);
+
+ $message = _('You have been removed from a Shift:') . "\n";
+ $message .= $shift['name'] . "\n";
+ $message .= $shift['title'] . "\n";
+ $message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n";
+ $message .= $room['Name'] . "\n";
+
+ engelsystem_email_to_user($user, '[engelsystem] ' . _('Removed from Shift'), $message, true);
+}
diff --git a/includes/mailer/users_mailer.php b/includes/mailer/users_mailer.php
index b08af92b..b3f335d7 100644
--- a/includes/mailer/users_mailer.php
+++ b/includes/mailer/users_mailer.php
@@ -1,9 +1,14 @@
<?php
/**
- * @param User $user_source
+ * @param array $user
+ * @return bool
*/
-function mail_user_delete($user) {
- engelsystem_email_to_user($user, '[engelsystem] ' . _("Your account has been deleted"), _("Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven."));
+function mail_user_delete($user)
+{
+ return engelsystem_email_to_user(
+ $user,
+ '[engelsystem] ' . _('Your account has been deleted'),
+ _('Your angelsystem account has been deleted. If you have any questions regarding your account deletion, please contact heaven.')
+ );
}
-?> \ No newline at end of file
diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php
index 8d6a89b3..1f2c8c63 100644
--- a/includes/model/AngelType_model.php
+++ b/includes/model/AngelType_model.php
@@ -1,236 +1,226 @@
<?php
+
+use Engelsystem\Database\DB;
use Engelsystem\ValidationResult;
/**
* Returns an array containing the basic attributes of angeltypes.
* FIXME! This is the big sign for needing entity objects
*/
-function AngelType_new() {
- return [
- 'id' => null,
- 'name' => "",
- 'restricted' => false,
- 'no_self_signup' => false,
- 'description' => '',
- 'requires_driver_license' => false,
- 'contact_user_id' => null,
- 'contact_name' => null,
- 'contact_dect' => null,
- 'contact_email' => null
- ];
-}
-
-/**
- * Validates the contact user
- *
- * @param Angeltype $angeltype
- * The angeltype
- * @return ValidationResult
- */
-function AngelType_validate_contact_user_id($angeltype) {
- if (! isset($angeltype['contact_user_id'])) {
- return new ValidationResult(true, null);
- }
- if (isset($angeltype['contact_name']) || isset($angeltype['contact_dect']) || isset($angeltype['contact_email'])) {
- return new ValidationResult(false, $angeltype['contact_user_id']);
- }
- if (User($angeltype['contact_user_id']) == null) {
- return new ValidationResult(false, $angeltype['contact_user_id']);
- }
- return new ValidationResult(true, $angeltype['contact_user_id']);
+function AngelType_new()
+{
+ return [
+ 'id' => null,
+ 'name' => '',
+ 'restricted' => false,
+ 'no_self_signup' => false,
+ 'description' => '',
+ 'requires_driver_license' => false,
+ 'contact_name' => null,
+ 'contact_dect' => null,
+ 'contact_email' => null
+ ];
}
/**
- * Returns contact data (name, dect, email) for given angeltype or null
- *
+ * Checks if the angeltype has any contact information.
+ *
* @param Angeltype $angeltype
- * The angeltype
+ * @return bool
*/
-function AngelType_contact_info($angeltype) {
- if (isset($angeltype['contact_user_id'])) {
- $contact_user = User($angeltype['contact_user_id']);
- $contact_data = [
- 'contact_name' => $contact_user['Nick'],
- 'contact_dect' => $contact_user['DECT']
- ];
- if ($contact_user['email_by_human_allowed']) {
- $contact_data['contact_email'] = $contact_user['email'];
- }
- return $contact_data;
- }
- if (isset($angeltype['contact_name'])) {
- return [
- 'contact_name' => $angeltype['contact_name'],
- 'contact_dect' => $angeltype['contact_dect'],
- 'contact_email' => $angeltype['contact_email']
- ];
- }
- return null;
+function AngelType_has_contact_info($angeltype) {
+ return !empty($angeltype['contact_name'])
+ || !empty($angeltype['contact_dect'])
+ || !empty($angeltype['contact_email']);
}
/**
* Delete an Angeltype.
*
- * @param Angeltype $angeltype
+ * @param array $angeltype
*/
-function AngelType_delete($angeltype) {
- $result = sql_query("
- DELETE FROM `AngelTypes`
- WHERE `id`='" . sql_escape($angeltype['id']) . "'
- LIMIT 1");
- if ($result === false) {
- engelsystem_error("Unable to delete angeltype.");
- }
- engelsystem_log("Deleted angeltype: " . AngelType_name_render($angeltype));
- return $result;
+function AngelType_delete($angeltype)
+{
+ DB::delete('
+ DELETE FROM `AngelTypes`
+ WHERE `id`=?
+ LIMIT 1
+ ', [$angeltype['id']]);
+ engelsystem_log('Deleted angeltype: ' . AngelType_name_render($angeltype));
}
/**
* Update Angeltype.
*
- * @param Angeltype $angeltype
- * The angeltype
+ * @param array $angeltype The angeltype
*/
-function AngelType_update($angeltype) {
- $result = sql_query("
- UPDATE `AngelTypes` SET
- `name`='" . sql_escape($angeltype['name']) . "',
- `restricted`=" . sql_bool($angeltype['restricted']) . ",
- `description`='" . sql_escape($angeltype['description']) . "',
- `requires_driver_license`=" . sql_bool($angeltype['requires_driver_license']) . ",
- `no_self_signup`=" . sql_bool($angeltype['no_self_signup']) . ",
- `contact_user_id`=" . sql_null($angeltype['contact_user_id']) . ",
- `contact_name`=" . sql_null($angeltype['contact_name']) . ",
- `contact_dect`=" . sql_null($angeltype['contact_dect']) . ",
- `contact_email`=" . sql_null($angeltype['contact_email']) . "
- WHERE `id`='" . sql_escape($angeltype['id']) . "'");
- if ($result === false) {
- engelsystem_error("Unable to update angeltype.");
- }
- engelsystem_log("Updated angeltype: " . $angeltype['name'] . ($angeltype['restricted'] ? ", restricted" : "") . ($angeltype['no_self_signup'] ? ", no_self_signup" : "") . ($angeltype['requires_driver_license'] ? ", requires driver license" : ""));
- return $result;
+function AngelType_update($angeltype)
+{
+ DB::update('
+ UPDATE `AngelTypes` SET
+ `name` = ?,
+ `restricted` = ?,
+ `description` = ?,
+ `requires_driver_license` = ?,
+ `no_self_signup` = ?,
+ `contact_name` = ?,
+ `contact_dect` = ?,
+ `contact_email` = ?
+ WHERE `id` = ?',
+ [
+ $angeltype['name'],
+ (int)$angeltype['restricted'],
+ $angeltype['description'],
+ (int)$angeltype['requires_driver_license'],
+ (int)$angeltype['no_self_signup'],
+ $angeltype['contact_name'],
+ $angeltype['contact_dect'],
+ $angeltype['contact_email'],
+ $angeltype['id'],
+ ]
+ );
+
+ engelsystem_log(
+ 'Updated angeltype: ' . $angeltype['name'] . ($angeltype['restricted'] ? ', restricted' : '')
+ . ($angeltype['no_self_signup'] ? ', no_self_signup' : '')
+ . ($angeltype['requires_driver_license'] ? ', requires driver license' : '') . ', '
+ . $angeltype['contact_name'] . ', '
+ . $angeltype['contact_dect'] . ', '
+ . $angeltype['contact_email']
+ );
}
/**
* Create an Angeltype.
*
- * @param Angeltype $angeltype
- * The angeltype
- * @return the created angeltype
+ * @param array $angeltype The angeltype
+ * @return array the created angeltype
*/
-function AngelType_create($angeltype) {
- $result = sql_query("
- INSERT INTO `AngelTypes` SET
- `name`='" . sql_escape($angeltype['name']) . "',
- `restricted`=" . sql_bool($angeltype['restricted']) . ",
- `description`='" . sql_escape($angeltype['description']) . "',
- `requires_driver_license`=" . sql_bool($angeltype['requires_driver_license']) . ",
- `no_self_signup`=" . sql_bool($angeltype['no_self_signup']) . ",
- `contact_user_id`=" . sql_null($angeltype['contact_user_id']) . ",
- `contact_name`=" . sql_null($angeltype['contact_name']) . ",
- `contact_dect`=" . sql_null($angeltype['contact_dect']) . ",
- `contact_email`=" . sql_null($angeltype['contact_email']));
- if ($result === false) {
- engelsystem_error("Unable to create angeltype.");
- }
- $angeltype['id'] = sql_id();
- engelsystem_log("Created angeltype: " . $angeltype['name'] . ($angeltype['restricted'] ? ", restricted" : "") . ($angeltype['requires_driver_license'] ? ", requires driver license" : ""));
- return $angeltype;
+function AngelType_create($angeltype)
+{
+ DB::insert('
+ INSERT INTO `AngelTypes` (
+ `name`,
+ `restricted`,
+ `description`,
+ `requires_driver_license`,
+ `no_self_signup`,
+ `contact_name`,
+ `contact_dect`,
+ `contact_email`
+ )
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ',
+ [
+ $angeltype['name'],
+ (int)$angeltype['restricted'],
+ $angeltype['description'],
+ (int)$angeltype['requires_driver_license'],
+ (int)$angeltype['no_self_signup'],
+ $angeltype['contact_name'],
+ $angeltype['contact_dect'],
+ $angeltype['contact_email'],
+ ]
+ );
+
+ $angeltype['id'] = DB::getPdo()->lastInsertId();
+ engelsystem_log(
+ 'Created angeltype: ' . $angeltype['name']
+ . ($angeltype['restricted'] ? ', restricted' : '')
+ . ($angeltype['requires_driver_license'] ? ', requires driver license' : '') . ', '
+ . $angeltype['contact_name'] . ', '
+ . $angeltype['contact_dect'] . ', '
+ . $angeltype['contact_email']
+ );
+ return $angeltype;
}
/**
* Validates a name for angeltypes.
* Returns ValidationResult containing validation success and validated name.
*
- * @param string $name
- * Wanted name for the angeltype
- * @param AngelType $angeltype
- * The angeltype the name is for
+ * @param string $name Wanted name for the angeltype
+ * @param array $angeltype The angeltype the name is for
+ *
* @return ValidationResult result and validated name
*/
-function AngelType_validate_name($name, $angeltype) {
- $name = strip_item($name);
- if ($name == "") {
- return new ValidationResult(false, "");
- }
- if ($angeltype != null && isset($angeltype['id'])) {
- $valid = sql_num_query("
- SELECT *
- FROM `AngelTypes`
- WHERE `name`='" . sql_escape($name) . "'
- AND NOT `id`='" . sql_escape($angeltype['id']) . "'
- LIMIT 1") == 0;
+function AngelType_validate_name($name, $angeltype)
+{
+ $name = strip_item($name);
+ if ($name == '') {
+ return new ValidationResult(false, '');
+ }
+ if ($angeltype != null && isset($angeltype['id'])) {
+ $valid = (count(DB::select('
+ SELECT `id`
+ FROM `AngelTypes`
+ WHERE `name`=?
+ AND NOT `id`=?
+ LIMIT 1
+ ', [$name, $angeltype['id']])) == 0);
+ return new ValidationResult($valid, $name);
+ }
+ $valid = (count(DB::select('
+ SELECT `id`
+ FROM `AngelTypes`
+ WHERE `name`=?
+ LIMIT 1', [$name])) == 0);
return new ValidationResult($valid, $name);
- }
- $valid = sql_num_query("
- SELECT `id`
- FROM `AngelTypes`
- WHERE `name`='" . sql_escape($name) . "'
- LIMIT 1") == 0;
- return new ValidationResult($valid, $name);
}
/**
* Returns all angeltypes and subscription state to each of them for given user.
*
- * @param User $user
+ * @param array $user
+ * @return array
*/
-function AngelTypes_with_user($user) {
- $result = sql_select("
- SELECT `AngelTypes`.*,
- `UserAngelTypes`.`id` as `user_angeltype_id`,
+function AngelTypes_with_user($user)
+{
+ return DB::select('
+ SELECT `AngelTypes`.*,
+ `UserAngelTypes`.`id` AS `user_angeltype_id`,
`UserAngelTypes`.`confirm_user_id`,
`UserAngelTypes`.`supporter`
- FROM `AngelTypes`
- LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
- AND `UserAngelTypes`.`user_id`=" . $user['UID'] . "
- ORDER BY `name`");
- if ($result === false) {
- engelsystem_error("Unable to load angeltypes.");
- }
- return $result;
+ FROM `AngelTypes`
+ LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id`
+ AND `UserAngelTypes`.`user_id` = ?
+ ORDER BY `name`', [$user['UID']]);
}
/**
* Returns all angeltypes.
+ *
+ * @return array
*/
-function AngelTypes() {
- $result = sql_select("
- SELECT *
- FROM `AngelTypes`
- ORDER BY `name`");
- if ($result === false) {
- engelsystem_error("Unable to load angeltypes.");
- }
- return $result;
+function AngelTypes()
+{
+ return DB::select('
+ SELECT *
+ FROM `AngelTypes`
+ ORDER BY `name`');
}
/**
* Returns AngelType id array
+ *
+ * @return array
*/
-function AngelType_ids() {
- $result = sql_select("SELECT `id` FROM `AngelTypes`");
- if ($result === false) {
- engelsystem_error("Unable to load angeltypes.");
- }
- return select_array($result, 'id', 'id');
+function AngelType_ids()
+{
+ $result = DB::select('SELECT `id` FROM `AngelTypes`');
+ return select_array($result, 'id', 'id');
}
/**
* Returns angelType by id.
*
- * @param $angeltype_id angelType
- * ID
+ * @param int $angeltype_id angelType ID
+ * @return array|null
*/
-function AngelType($angeltype_id) {
- $angelType_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($angeltype_id) . "'");
- if ($angelType_source === false) {
- engelsystem_error("Unable to load angeltype.");
- }
- if (count($angelType_source) > 0) {
- return $angelType_source[0];
- }
- return null;
+function AngelType($angeltype_id)
+{
+ return DB::selectOne(
+ 'SELECT * FROM `AngelTypes` WHERE `id`=?',
+ [$angeltype_id]
+ );
}
-
-?>
diff --git a/includes/model/EventConfig_model.php b/includes/model/EventConfig_model.php
index de5073d0..646d19c5 100644
--- a/includes/model/EventConfig_model.php
+++ b/includes/model/EventConfig_model.php
@@ -1,46 +1,75 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Get event config.
+ *
+ * @return array|null
*/
-function EventConfig() {
- $event_config = sql_select("SELECT * FROM `EventConfig` LIMIT 1");
- if ($event_config === false) {
- engelsystem_error("Unable to load event config.");
- return false;
- }
- if (count($event_config) > 0) {
- return $event_config[0];
- }
- return null;
+function EventConfig()
+{
+ return DB::selectOne('SELECT * FROM `EventConfig` LIMIT 1');
}
/**
* Update event config.
*
- * @param string $event_name
- * @param int $buildup_start_date
- * @param int $event_start_date
- * @param int $event_end_date
- * @param int $teardown_end_date
- * @param string $event_welcome_msg
+ * @param string $event_name
+ * @param int $buildup_start_date
+ * @param int $event_start_date
+ * @param int $event_end_date
+ * @param int $teardown_end_date
+ * @param string $event_welcome_msg
+ * @return int Rows updated
*/
-function EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg) {
- if (EventConfig() == null) {
- return sql_query("INSERT INTO `EventConfig` SET
- `event_name`=" . sql_null($event_name) . ",
- `buildup_start_date`=" . sql_null($buildup_start_date) . ",
- `event_start_date`=" . sql_null($event_start_date) . ",
- `event_end_date`=" . sql_null($event_end_date) . ",
- `teardown_end_date`=" . sql_null($teardown_end_date) . ",
- `event_welcome_msg`=" . sql_null($event_welcome_msg));
- }
- return sql_query("UPDATE `EventConfig` SET
- `event_name`=" . sql_null($event_name) . ",
- `buildup_start_date`=" . sql_null($buildup_start_date) . ",
- `event_start_date`=" . sql_null($event_start_date) . ",
- `event_end_date`=" . sql_null($event_end_date) . ",
- `teardown_end_date`=" . sql_null($teardown_end_date) . ",
- `event_welcome_msg`=" . sql_null($event_welcome_msg));
+function EventConfig_update(
+ $event_name,
+ $buildup_start_date,
+ $event_start_date,
+ $event_end_date,
+ $teardown_end_date,
+ $event_welcome_msg
+) {
+ if (EventConfig() == null) {
+ return DB::insert('
+ INSERT INTO `EventConfig` (
+ `event_name`,
+ `buildup_start_date`,
+ `event_start_date`,
+ `event_end_date`,
+ `teardown_end_date`,
+ `event_welcome_msg`
+ )
+ VALUES (?, ?, ?, ?, ?, ?)
+ ',
+ [
+ $event_name,
+ $buildup_start_date,
+ $event_start_date,
+ $event_end_date,
+ $teardown_end_date,
+ $event_welcome_msg
+ ]
+ );
+ }
+
+ return DB::update('
+ UPDATE `EventConfig` SET
+ `event_name` = ?,
+ `buildup_start_date` = ?,
+ `event_start_date` = ?,
+ `event_end_date` = ?,
+ `teardown_end_date` = ?,
+ `event_welcome_msg` = ?
+ ',
+ [
+ $event_name,
+ $buildup_start_date,
+ $event_start_date,
+ $event_end_date,
+ $teardown_end_date,
+ $event_welcome_msg,
+ ]
+ );
}
-?>
diff --git a/includes/model/LogEntries_model.php b/includes/model/LogEntries_model.php
index 09bd03dc..f0ee6673 100644
--- a/includes/model/LogEntries_model.php
+++ b/includes/model/LogEntries_model.php
@@ -1,38 +1,62 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Creates a log entry.
*
- * @param $nick Username
- * @param $message Log
- * Message
+ * @param string $logLevel Log level
+ * @param string $message Log Message
+ * @return bool
*/
-function LogEntry_create($nick, $message) {
- return sql_query("INSERT INTO `LogEntries` SET `timestamp`='" . sql_escape(time()) . "', `nick`='" . sql_escape($nick) . "', `message`='" . sql_escape($message) . "'");
+function LogEntry_create($logLevel, $message)
+{
+ return DB::insert('
+ INSERT INTO `LogEntries` (`timestamp`, `level`, `message`)
+ VALUES(?, ?, ?)
+ ', [time(), $logLevel, $message]);
}
/**
* Returns log entries with maximum count of 10000.
+ *
+ * @return array
*/
-function LogEntries() {
- return sql_select("SELECT * FROM `LogEntries` ORDER BY `timestamp` DESC LIMIT 10000");
+function LogEntries()
+{
+ return DB::select('SELECT * FROM `LogEntries` ORDER BY `timestamp` DESC LIMIT 10000');
}
/**
* Returns log entries filtered by a keyword
+ *
+ * @param string $keyword
+ * @return array
*/
-function LogEntries_filter($keyword) {
- if ($keyword == "") {
- return LogEntries();
- }
- return sql_select("SELECT * FROM `LogEntries` WHERE `nick` LIKE '%" . sql_escape($keyword) . "%' OR `message` LIKE '%" . sql_escape($keyword) . "%' ORDER BY `timestamp` DESC");
+function LogEntries_filter($keyword)
+{
+ if ($keyword == '') {
+ return LogEntries();
+ }
+
+ $keyword = '%' . $keyword . '%';
+ return DB::select('
+ SELECT *
+ FROM `LogEntries`
+ WHERE `level` LIKE ?
+ OR `message` LIKE ?
+ ORDER BY `timestamp` DESC
+ ',
+ [$keyword, $keyword]
+ );
}
/**
* Delete all log entries.
+ *
+ * @return bool
*/
-function LogEntries_clear_all() {
- return sql_query("TRUNCATE `LogEntries`");
+function LogEntries_clear_all()
+{
+ return DB::statement('TRUNCATE `LogEntries`');
}
-
-?>
diff --git a/includes/model/Message_model.php b/includes/model/Message_model.php
index 652b60ea..9bb037af 100644
--- a/includes/model/Message_model.php
+++ b/includes/model/Message_model.php
@@ -1,27 +1,26 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Returns Message id array
+ *
+ * @return array
*/
-function Message_ids() {
- return sql_select("SELECT `id` FROM `Messages`");
+function Message_ids()
+{
+ return DB::select('SELECT `id` FROM `Messages`');
}
/**
* Returns message by id.
*
- * @param $message_id message
- * ID
+ * @param int $message_id message ID
+ * @return array|null
*/
-function Message($message_id) {
- $message_source = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
- if ($message_source === false) {
- return false;
- }
- if (count($message_source) > 0) {
- return $message_source[0];
- }
- return null;
+function Message($message_id)
+{
+ return DB::selectOne('SELECT * FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]);
}
/**
@@ -29,23 +28,39 @@ function Message($message_id) {
* TODO: global $user con not be used in model!
* send message
*
- * @param $receiver_user_id User
- * ID of Reciever
- * @param $text Text
- * of Message
+ * @param int $receiver_user_id User ID of Reciever
+ * @param string $text Text of Message
+ * @return bool
*/
-function Message_send($receiver_user_id, $text) {
- global $user;
-
- $text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($text));
- $receiver_user_id = preg_replace("/([^0-9]{1,})/ui", '', strip_tags($receiver_user_id));
-
- if (($text != "" && is_numeric($receiver_user_id)) && (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($receiver_user_id) . "' AND NOT `UID`='" . sql_escape($user['UID']) . "' LIMIT 1") > 0)) {
- sql_query("INSERT INTO `Messages` SET `Datum`='" . sql_escape(time()) . "', `SUID`='" . sql_escape($user['UID']) . "', `RUID`='" . sql_escape($receiver_user_id) . "', `Text`='" . sql_escape($text) . "'");
- return true;
- }
-
- return false;
-}
+function Message_send($receiver_user_id, $text)
+{
+ global $user;
-?> \ No newline at end of file
+ $text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($text));
+ $receiver_user_id = preg_replace('/([^\d]{1,})/ui', '', strip_tags($receiver_user_id));
+
+ if (
+ ($text != '' && is_numeric($receiver_user_id))
+ && count(DB::select('
+ SELECT `UID`
+ FROM `User`
+ WHERE `UID` = ?
+ AND NOT `UID` = ?
+ LIMIT 1
+ ', [$receiver_user_id, $user['UID']])) > 0
+ ) {
+ return DB::insert('
+ INSERT INTO `Messages` (`Datum`, `SUID`, `RUID`, `Text`)
+ VALUES(?, ?, ?, ?)
+ ',
+ [
+ time(),
+ $user['UID'],
+ $receiver_user_id,
+ $text
+ ]
+ );
+ }
+
+ return false;
+}
diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php
index 3bd3660f..d8de5e69 100644
--- a/includes/model/NeededAngelTypes_model.php
+++ b/includes/model/NeededAngelTypes_model.php
@@ -1,5 +1,7 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Entity needed angeltypes describes how many angels of given type are needed for a shift or in a room.
*/
@@ -7,99 +9,96 @@
/**
* Insert a new needed angel type.
*
- * @param int $shift_id
- * The shift. Can be null, but then a room_id must be given.
- * @param int $angeltype_id
- * The angeltype
- * @param int $room_id
- * The room. Can be null, but then a shift_id must be given.
- * @param int $count
- * How many angels are needed?
+ * @param int $shift_id The shift. Can be null, but then a room_id must be given.
+ * @param int $angeltype_id The angeltype
+ * @param int $room_id The room. Can be null, but then a shift_id must be given.
+ * @param int $count How many angels are needed?
+ * @return int|false
*/
-function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count) {
- $result = sql_query("
- INSERT INTO `NeededAngelTypes` SET
- `shift_id`=" . sql_null($shift_id) . ",
- `angel_type_id`='" . sql_escape($angeltype_id) . "',
- `room_id`=" . sql_null($room_id) . ",
- `count`='" . sql_escape($count) . "'");
- if ($result === false) {
- return false;
- }
- return sql_id();
+function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
+{
+ DB::insert('
+ INSERT INTO `NeededAngelTypes` ( `shift_id`, `angel_type_id`, `room_id`, `count`)
+ VALUES (?, ?, ?, ?)
+ ',
+ [
+ $shift_id,
+ $angeltype_id,
+ $room_id,
+ $count,
+ ]);
+
+ return DB::getPdo()->lastInsertId();
}
/**
* Deletes all needed angel types from given shift.
*
- * @param int $shift_id
- * id of the shift
+ * @param int $shift_id id of the shift
*/
-function NeededAngelTypes_delete_by_shift($shift_id) {
- return sql_query("DELETE FROM `NeededAngelTypes` WHERE `shift_id`='" . sql_escape($shift_id) . "'");
+function NeededAngelTypes_delete_by_shift($shift_id)
+{
+ DB::delete('DELETE FROM `NeededAngelTypes` WHERE `shift_id` = ?', [$shift_id]);
}
/**
* Deletes all needed angel types from given room.
*
- * @param int $room_id
- * id of the room
+ * @param int $room_id id of the room
*/
-function NeededAngelTypes_delete_by_room($room_id) {
- return sql_query("DELETE FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
+function NeededAngelTypes_delete_by_room($room_id)
+{
+ DB::delete(
+ 'DELETE FROM `NeededAngelTypes` WHERE `room_id` = ?',
+ [$room_id]
+ );
}
/**
* Returns all needed angeltypes and already taken needs.
*
- * @param int $shiftID
- * id of shift
+ * @param int $shiftId id of shift
+ * @return array
*/
-function NeededAngelTypes_by_shift($shiftId) {
- $needed_angeltypes_source = sql_select("
+function NeededAngelTypes_by_shift($shiftId)
+{
+ $needed_angeltypes_source = DB::select('
SELECT `NeededAngelTypes`.*, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
- WHERE `shift_id`='" . sql_escape($shiftId) . "'
+ WHERE `shift_id` = ?
AND `count` > 0
- ORDER BY `room_id` DESC
- ");
- if ($needed_angeltypes_source === false) {
- engelsystem_error("Unable to load needed angeltypes.");
- }
-
- // Use settings from room
- if (count($needed_angeltypes_source) == 0) {
- $needed_angeltypes_source = sql_select("
+ ORDER BY `room_id` DESC',
+ [$shiftId]
+ );
+
+ // Use settings from room
+ if (count($needed_angeltypes_source) == 0) {
+ $needed_angeltypes_source = DB::select('
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
JOIN `Shifts` ON `Shifts`.`RID` = `NeededAngelTypes`.`room_id`
- WHERE `Shifts`.`SID`='" . sql_escape($shiftId) . "'
+ WHERE `Shifts`.`SID` = ?
AND `count` > 0
ORDER BY `room_id` DESC
- ");
- if ($needed_angeltypes_source === false) {
- engelsystem_error("Unable to load needed angeltypes.");
+ ', [$shiftId]);
}
- }
-
- $shift_entries = ShiftEntries_by_shift($shiftId);
- $needed_angeltypes = [];
- foreach ($needed_angeltypes_source as $angeltype) {
- $angeltype['shift_entries'] = [];
- $angeltype['taken'] = 0;
- foreach ($shift_entries as $shift_entry) {
- if ($shift_entry['TID'] == $angeltype['angel_type_id'] && $shift_entry['freeloaded'] == 0) {
- $angeltype['taken'] ++;
- $angeltype['shift_entries'][] = $shift_entry;
- }
+
+ $shift_entries = ShiftEntries_by_shift($shiftId);
+ $needed_angeltypes = [];
+ foreach ($needed_angeltypes_source as $angeltype) {
+ $angeltype['shift_entries'] = [];
+ $angeltype['taken'] = 0;
+ foreach ($shift_entries as $shift_entry) {
+ if ($shift_entry['TID'] == $angeltype['angel_type_id'] && $shift_entry['freeloaded'] == 0) {
+ $angeltype['taken']++;
+ $angeltype['shift_entries'][] = $shift_entry;
+ }
+ }
+
+ $needed_angeltypes[] = $angeltype;
}
-
- $needed_angeltypes[] = $angeltype;
- }
-
- return $needed_angeltypes;
-}
-?> \ No newline at end of file
+ return $needed_angeltypes;
+}
diff --git a/includes/model/Room_model.php b/includes/model/Room_model.php
index 14935de0..74a08be4 100644
--- a/includes/model/Room_model.php
+++ b/includes/model/Room_model.php
@@ -1,60 +1,79 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* returns a list of rooms.
+ *
* @param boolean $show_all returns also hidden rooms when true
+ * @return array
*/
-function Rooms($show_all = false) {
- return sql_select("SELECT * FROM `Room`" . ($show_all ? "" : " WHERE `show`='Y'") . " ORDER BY `Name`");
+function Rooms($show_all = false)
+{
+ return DB::select('SELECT * FROM `Room`' . ($show_all ? '' : ' WHERE `show`=\'Y\'') . ' ORDER BY `Name`');
+}
+
+/**
+ * Returns Room id array
+ *
+ * @return array
+ */
+function Room_ids()
+{
+ $result = DB::select('SELECT `RID` FROM `Room`');
+ return select_array($result, 'RID', 'RID');
}
/**
* Delete a room
*
- * @param int $room_id
+ * @param int $room_id
*/
-function Room_delete($room_id) {
- return sql_query("DELETE FROM `Room` WHERE `RID`=" . sql_escape($room_id));
+function Room_delete($room_id)
+{
+ DB::delete('DELETE FROM `Room` WHERE `RID` = ?', [$room_id]);
}
/**
* Create a new room
*
- * @param string $name
- * Name of the room
- * @param boolean $from_frab
- * Is this a frab imported room?
- * @param boolean $public
- * Is the room visible for angels?
+ * @param string $name Name of the room
+ * @param boolean $from_frab Is this a frab imported room?
+ * @param boolean $public Is the room visible for angels?
+ * @param int $number Room number
+ * @return false|int
*/
-function Room_create($name, $from_frab, $public) {
- $result = sql_query("
- INSERT INTO `Room` SET
- `Name`='" . sql_escape($name) . "',
- `FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "',
- `show`='" . sql_escape($public ? 'Y' : '') . "',
- `Number`=0");
- if ($result === false) {
- return false;
- }
- return sql_id();
+function Room_create($name, $from_frab, $public, $number = null)
+{
+ DB::insert('
+ INSERT INTO `Room` (`Name`, `FromPentabarf`, `show`, `Number`)
+ VALUES (?, ?, ?, ?)
+ ',
+ [
+ $name,
+ $from_frab ? 'Y' : '',
+ $public ? 'Y' : '',
+ (int)$number,
+ ]
+ );
+
+ return DB::getPdo()->lastInsertId();
}
/**
* Returns room by id.
*
- * @param $room_id RID
+ * @param int $room_id RID
+ * @param bool $onlyVisible
+ * @return array|false
*/
-function Room($room_id) {
- $room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($room_id) . "'");
-
- if ($room_source === false) {
- return false;
- }
- if (count($room_source) > 0) {
- return $room_source[0];
- }
- return null;
+function Room($room_id, $onlyVisible = true)
+{
+ return DB::selectOne('
+ SELECT *
+ FROM `Room`
+ WHERE `RID` = ?
+ ' . ($onlyVisible ? 'AND `show` = \'Y\'' : ''),
+ [$room_id]
+ );
}
-
-?>
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php
index 9f4faf9e..bcc28f05 100644
--- a/includes/model/ShiftEntry_model.php
+++ b/includes/model/ShiftEntry_model.php
@@ -1,152 +1,235 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Returns an array with the attributes of shift entries.
* FIXME! Needs entity object.
+ *
+ * @return array
*/
-function ShiftEntry_new() {
- return [
- 'id' => null,
- 'SID' => null,
- 'TID' => null,
- 'UID' => null,
- 'Comment' => null,
- 'freeloaded_comment' => null,
- 'freeloaded' => false
- ];
+function ShiftEntry_new()
+{
+ return [
+ 'id' => null,
+ 'SID' => null,
+ 'TID' => null,
+ 'UID' => null,
+ 'Comment' => null,
+ 'freeloaded_comment' => null,
+ 'freeloaded' => false
+ ];
}
/**
* Counts all freeloaded shifts.
+ *
+ * @return int
*/
-function ShiftEntries_freeleaded_count() {
- return sql_select_single_cell("SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1");
+function ShiftEntries_freeleaded_count()
+{
+ $result = DB::selectOne('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1');
+
+ if (empty($result)) {
+ return 0;
+ }
+
+ return (int)array_shift($result);
}
/**
* List users subsribed to a given shift.
+ *
+ * @param int $shift_id
+ * @return array
*/
-function ShiftEntries_by_shift($shift_id) {
- return sql_select("
- SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `AngelTypes`.`name` as `angel_type_name`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded`
- FROM `ShiftEntry`
- JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
- JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
- WHERE `ShiftEntry`.`SID`='" . sql_escape($shift_id) . "'");
+function ShiftEntries_by_shift($shift_id)
+{
+ return DB::select('
+ SELECT
+ `User`.`Nick`,
+ `User`.`email`,
+ `User`.`email_shiftinfo`,
+ `User`.`Sprache`,
+ `User`.`Gekommen`,
+ `ShiftEntry`.`UID`,
+ `ShiftEntry`.`TID`,
+ `ShiftEntry`.`SID`,
+ `AngelTypes`.`name` AS `angel_type_name`,
+ `ShiftEntry`.`Comment`,
+ `ShiftEntry`.`freeloaded`
+ FROM `ShiftEntry`
+ JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
+ JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
+ WHERE `ShiftEntry`.`SID` = ?',
+ [$shift_id]
+ );
}
/**
* Create a new shift entry.
*
- * @param ShiftEntry $shift_entry
+ * @param array $shift_entry
+ * @return bool
*/
-function ShiftEntry_create($shift_entry) {
- mail_shift_assign(User($shift_entry['UID']), Shift($shift_entry['SID']));
- return sql_query("INSERT INTO `ShiftEntry` SET
- `SID`='" . sql_escape($shift_entry['SID']) . "',
- `TID`='" . sql_escape($shift_entry['TID']) . "',
- `UID`='" . sql_escape($shift_entry['UID']) . "',
- `Comment`='" . sql_escape($shift_entry['Comment']) . "',
- `freeload_comment`='" . sql_escape($shift_entry['freeload_comment']) . "',
- `freeloaded`=" . sql_bool($shift_entry['freeloaded']));
+function ShiftEntry_create($shift_entry)
+{
+ mail_shift_assign(User($shift_entry['UID']), Shift($shift_entry['SID']));
+ return DB::insert('
+ INSERT INTO `ShiftEntry` (
+ `SID`,
+ `TID`,
+ `UID`,
+ `Comment`,
+ `freeload_comment`,
+ `freeloaded`
+ )
+ VALUES(?, ?, ?, ?, ?, ?)
+ ',
+ [
+ $shift_entry['SID'],
+ $shift_entry['TID'],
+ $shift_entry['UID'],
+ $shift_entry['Comment'],
+ $shift_entry['freeload_comment'],
+ (int)$shift_entry['freeloaded'],
+ ]
+ );
}
/**
* Update a shift entry.
+ *
+ * @param array $shift_entry
*/
-function ShiftEntry_update($shift_entry) {
- return sql_query("UPDATE `ShiftEntry` SET
- `Comment`='" . sql_escape($shift_entry['Comment']) . "',
- `freeload_comment`='" . sql_escape($shift_entry['freeload_comment']) . "',
- `freeloaded`=" . sql_bool($shift_entry['freeloaded']) . "
- WHERE `id`='" . sql_escape($shift_entry['id']) . "'");
+function ShiftEntry_update($shift_entry)
+{
+ DB::update('
+ UPDATE `ShiftEntry`
+ SET
+ `Comment` = ?,
+ `freeload_comment` = ?,
+ `freeloaded` = ?
+ WHERE `id` = ?',
+ [
+ $shift_entry['Comment'],
+ $shift_entry['freeload_comment'],
+ (int)$shift_entry['freeloaded'],
+ $shift_entry['id']
+ ]
+ );
}
/**
* Get a shift entry.
+ *
+ * @param int $shift_entry_id
+ * @return array|null
*/
-function ShiftEntry($shift_entry_id) {
- $shift_entry = sql_select("SELECT * FROM `ShiftEntry` WHERE `id`='" . sql_escape($shift_entry_id) . "'");
- if ($shift_entry === false) {
- return false;
- }
- if (count($shift_entry) == 0) {
- return null;
- }
- return $shift_entry[0];
+function ShiftEntry($shift_entry_id)
+{
+ return DB::selectOne('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
}
/**
* Delete a shift entry.
+ *
+ * @param int $shift_entry_id
*/
-function ShiftEntry_delete($shift_entry_id) {
- $shift_entry = ShiftEntry($shift_entry_id);
- mail_shift_removed(User($shift_entry['UID']), Shift($shift_entry['SID']));
- return sql_query("DELETE FROM `ShiftEntry` WHERE `id`='" . sql_escape($shift_entry_id) . "'");
+function ShiftEntry_delete($shift_entry_id)
+{
+ $shift_entry = ShiftEntry($shift_entry_id);
+ mail_shift_removed(User($shift_entry['UID']), Shift($shift_entry['SID']));
+ DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
}
/**
* Returns next (or current) shifts of given user.
*
- * @param User $user
+ * @param array $user
+ * @return array
*/
-function ShiftEntries_upcoming_for_user($user) {
- return sql_select("
- SELECT *
- FROM `ShiftEntry`
- JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
- JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
- WHERE `ShiftEntry`.`UID`=" . sql_escape($user['UID']) . "
- AND `Shifts`.`end` > " . sql_escape(time()) . "
- ORDER BY `Shifts`.`end`
- ");
+function ShiftEntries_upcoming_for_user($user)
+{
+ return DB::select('
+ SELECT *
+ FROM `ShiftEntry`
+ JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
+ JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
+ WHERE `ShiftEntry`.`UID` = ?
+ AND `Shifts`.`end` > ?
+ ORDER BY `Shifts`.`end`
+ ',
+ [
+ $user['UID'],
+ time(),
+ ]
+ );
}
/**
* Returns shifts completed by the given user.
*
- * @param User $user
+ * @param array $user
+ * @return array
*/
-function ShiftEntries_finished_by_user($user) {
- return sql_select("
- SELECT *
- FROM `ShiftEntry`
- JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
- 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`
- ");
+function ShiftEntries_finished_by_user($user)
+{
+ return DB::select('
+ SELECT *
+ FROM `ShiftEntry`
+ JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
+ JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
+ WHERE `ShiftEntry`.`UID` = ?
+ AND `Shifts`.`end` < ?
+ AND `ShiftEntry`.`freeloaded` = 0
+ ORDER BY `Shifts`.`end`
+ ',
+ [
+ $user['UID'],
+ time(),
+ ]
+ );
}
/**
* Returns all shift entries in given shift for given angeltype.
*
- * @param int $shift_id
- * @param int $angeltype_id
+ * @param int $shift_id
+ * @param int $angeltype_id
+ * @return array
*/
-function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) {
- $result = sql_select("
- SELECT *
- FROM `ShiftEntry`
- WHERE `SID`=" . sql_escape($shift_id) . "
- AND `TID`=" . sql_escape($angeltype_id) . "
- ");
- if ($result === false) {
- engelsystem_error("Unable to load shift entries.");
- }
- return $result;
+function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
+{
+ return DB::select('
+ SELECT *
+ FROM `ShiftEntry`
+ WHERE `SID` = ?
+ AND `TID` = ?
+ ',
+ [
+ $shift_id,
+ $angeltype_id,
+ ]
+ );
}
/**
* Returns all freeloaded shifts for given user.
+ *
+ * @param array $user
+ * @return array
*/
-function ShiftEntries_freeloaded_by_user($user) {
- return sql_select("SELECT *
- FROM `ShiftEntry`
- WHERE `freeloaded` = 1
- AND `UID`=" . sql_escape($user['UID']));
+function ShiftEntries_freeloaded_by_user($user)
+{
+ return DB::select('
+ SELECT *
+ FROM `ShiftEntry`
+ WHERE `freeloaded` = 1
+ AND `UID` = ?
+ ',
+ [
+ $user['UID']
+ ]
+ );
}
-
-?>
diff --git a/includes/model/ShiftSignupState.php b/includes/model/ShiftSignupState.php
index 393023ee..9b3de496 100644
--- a/includes/model/ShiftSignupState.php
+++ b/includes/model/ShiftSignupState.php
@@ -6,112 +6,136 @@ namespace Engelsystem;
* BO to represent if there are free slots on a shift for a given angeltype
* and if signup for a given user is possible (or not, because of collisions, etc.)
*/
-class ShiftSignupState {
-
- /**
- * Shift has free places
- */
- const FREE = 'FREE';
-
- /**
- * Shift collides with users shifts
- */
- const COLLIDES = 'COLLIDES';
-
- /**
- * User cannot join because of a restricted angeltype or user is not in the angeltype
- */
- const ANGELTYPE = 'ANGELTYPE';
-
- /**
- * Shift is full
- */
- const OCCUPIED = 'OCCUPIED';
-
- /**
- * User is admin and can do what he wants.
- */
- const ADMIN = 'ADMIN';
-
- /**
- * Shift has already ended, no signup
- */
- const SHIFT_ENDED = 'SHIFT_ENDED';
-
- /**
- * User is already signed up
- */
- const SIGNED_UP = 'SIGNED_UP';
-
- private $state;
-
- private $freeEntries;
-
- public function __construct($state, $free_entries) {
- $this->state = $state;
- $this->freeEntries = $free_entries;
- }
-
- /**
- * Combine this state with another state from the same shift.
- *
- * @param ShiftSignupState $shiftSignupState
- * The other state to combine
- */
- public function combineWith(ShiftSignupState $shiftSignupState) {
- $this->freeEntries += $shiftSignupState->getFreeEntries();
-
- if ($this->valueForState($shiftSignupState->state) > $this->valueForState($this->state)) {
- $this->state = $shiftSignupState->state;
+class ShiftSignupState
+{
+ /**
+ * Shift has free places
+ */
+ const FREE = 'FREE';
+
+ /**
+ * Shift collides with users shifts
+ */
+ const COLLIDES = 'COLLIDES';
+
+ /**
+ * User cannot join because of a restricted angeltype or user is not in the angeltype
+ */
+ const ANGELTYPE = 'ANGELTYPE';
+
+ /**
+ * Shift is full
+ */
+ const OCCUPIED = 'OCCUPIED';
+
+ /**
+ * User is admin and can do what he wants.
+ */
+ const ADMIN = 'ADMIN';
+
+ /**
+ * Shift has already ended, no signup
+ */
+ const SHIFT_ENDED = 'SHIFT_ENDED';
+
+ /**
+ * User is already signed up
+ */
+ const SIGNED_UP = 'SIGNED_UP';
+
+ /** @var string */
+ private $state;
+
+ /** @var int */
+ private $freeEntries;
+
+ /**
+ * ShiftSignupState constructor.
+ *
+ * @param string $state
+ * @param int $free_entries
+ */
+ public function __construct($state, $free_entries)
+ {
+ $this->state = $state;
+ $this->freeEntries = $free_entries;
}
- }
-
- private function valueForState($state) {
- switch ($state) {
- case ShiftSignupState::SHIFT_ENDED:
- return 100;
-
- case ShiftSignupState::SIGNED_UP:
- return 90;
-
- case ShiftSignupState::FREE:
- return 80;
-
- case ShiftSignupState::ANGELTYPE:
- case ShiftSignupState::COLLIDES:
- return 70;
-
- case ShiftSignupState::OCCUPIED:
- case ShiftSignupState::ADMIN:
- return 60;
+
+ /**
+ * Combine this state with another state from the same shift.
+ *
+ * @param ShiftSignupState $shiftSignupState
+ * The other state to combine
+ */
+ public function combineWith(ShiftSignupState $shiftSignupState)
+ {
+ $this->freeEntries += $shiftSignupState->getFreeEntries();
+
+ if ($this->valueForState($shiftSignupState->state) > $this->valueForState($this->state)) {
+ $this->state = $shiftSignupState->state;
+ }
}
- }
-
- /**
- * Returns true, if signup is allowed
- */
- public function isSignupAllowed() {
- switch ($this->state) {
- case ShiftSignupState::FREE:
- case ShiftSignupState::ADMIN:
- return true;
+
+ /**
+ * @param string $state
+ * @return int
+ */
+ private function valueForState($state)
+ {
+ switch ($state) {
+ case ShiftSignupState::SHIFT_ENDED:
+ return 100;
+
+ case ShiftSignupState::SIGNED_UP:
+ return 90;
+
+ case ShiftSignupState::FREE:
+ return 80;
+
+ case ShiftSignupState::ANGELTYPE:
+ case ShiftSignupState::COLLIDES:
+ return 70;
+
+ case ShiftSignupState::OCCUPIED:
+ case ShiftSignupState::ADMIN:
+ return 60;
+ default:
+ return 0;
+ }
+ }
+
+ /**
+ * Returns true, if signup is allowed
+ *
+ * @return bool
+ */
+ public function isSignupAllowed()
+ {
+ switch ($this->state) {
+ case ShiftSignupState::FREE:
+ case ShiftSignupState::ADMIN:
+ return true;
+ }
+ return false;
}
- return false;
- }
-
- /**
- * Return the shift signup state
- */
- public function getState() {
- return $this->state;
- }
-
- /**
- * How many places are free in this shift for the angeltype?
- */
- public function getFreeEntries() {
- return $this->freeEntries;
- }
-}
-?> \ No newline at end of file
+ /**
+ * Return the shift signup state
+ *
+ * @return string
+ */
+ public function getState()
+ {
+ return $this->state;
+ }
+
+ /**
+ * How many places are free in this shift for the angeltype?
+ *
+ * @return int
+ */
+ public function getFreeEntries()
+ {
+ return $this->freeEntries;
+ }
+}
diff --git a/includes/model/ShiftTypes_model.php b/includes/model/ShiftTypes_model.php
index 89704a65..227df367 100644
--- a/includes/model/ShiftTypes_model.php
+++ b/includes/model/ShiftTypes_model.php
@@ -1,69 +1,84 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Delete a shift type.
+ *
* @param int $shifttype_id
*/
-function ShiftType_delete($shifttype_id) {
- return sql_query("DELETE FROM `ShiftTypes` WHERE `id`='" . sql_escape($shifttype_id) . "'");
+function ShiftType_delete($shifttype_id)
+{
+ DB::delete('DELETE FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
}
/**
* Update a shift type.
*
- * @param int $shifttype_id
- * @param string $name
- * @param int $angeltype_id
- * @param string $description
+ * @param int $shifttype_id
+ * @param string $name
+ * @param int $angeltype_id
+ * @param string $description
*/
-function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) {
- return sql_query("UPDATE `ShiftTypes` SET
- `name`='" . sql_escape($name) . "',
- `angeltype_id`=" . sql_null($angeltype_id) . ",
- `description`='" . sql_escape($description) . "'
- WHERE `id`='" . sql_escape($shifttype_id) . "'");
+function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
+{
+ DB::update('
+ UPDATE `ShiftTypes` SET
+ `name`=?,
+ `angeltype_id`=?,
+ `description`=?
+ WHERE `id`=?
+ ',
+ [
+ $name,
+ $angeltype_id,
+ $description,
+ $shifttype_id,
+ ]
+ );
}
/**
* Create a shift type.
*
- * @param string $name
- * @param int $angeltype_id
- * @param string $description
- * @return new shifttype id
+ * @param string $name
+ * @param int $angeltype_id
+ * @param string $description
+ * @return int|false new shifttype id
*/
-function ShiftType_create($name, $angeltype_id, $description) {
- $result = sql_query("INSERT INTO `ShiftTypes` SET
- `name`='" . sql_escape($name) . "',
- `angeltype_id`=" . sql_null($angeltype_id) . ",
- `description`='" . sql_escape($description) . "'");
- if ($result === false) {
- return false;
- }
- return sql_id();
+function ShiftType_create($name, $angeltype_id, $description)
+{
+ DB::insert('
+ INSERT INTO `ShiftTypes` (`name`, `angeltype_id`, `description`)
+ VALUES(?, ?, ?)
+ ',
+ [
+ $name,
+ $angeltype_id,
+ $description
+ ]
+ );
+
+ return DB::getPdo()->lastInsertId();
}
/**
* Get a shift type by id.
*
- * @param int $shifttype_id
+ * @param int $shifttype_id
+ * @return array|null
*/
-function ShiftType($shifttype_id) {
- $shifttype = sql_select("SELECT * FROM `ShiftTypes` WHERE `id`='" . sql_escape($shifttype_id) . "'");
- if ($shifttype === false) {
- engelsystem_error('Unable to load shift type.');
- }
- if ($shifttype == null) {
- return null;
- }
- return $shifttype[0];
+function ShiftType($shifttype_id)
+{
+ return DB::selectOne('SELECT * FROM `ShiftTypes` WHERE `id`=?', [$shifttype_id]);
}
/**
* Get all shift types.
+ *
+ * @return array
*/
-function ShiftTypes() {
- return sql_select("SELECT * FROM `ShiftTypes` ORDER BY `name`");
+function ShiftTypes()
+{
+ return DB::select('SELECT * FROM `ShiftTypes` ORDER BY `name`');
}
-
-?> \ No newline at end of file
diff --git a/includes/model/ShiftsFilter.php b/includes/model/ShiftsFilter.php
index ff1f5d40..3b691b55 100644
--- a/includes/model/ShiftsFilter.php
+++ b/includes/model/ShiftsFilter.php
@@ -7,115 +7,161 @@ namespace Engelsystem;
*
* @author msquare
*/
-class ShiftsFilter {
-
- /**
- * How long can the time interval be?
- */
- const MAX_DURATION = 86400;
- // one day
-
- /**
- * Shift is completely full.
- */
- const FILLED_FILLED = 1;
-
- /**
- * Shift has some free slots.
- */
- const FILLED_FREE = 0;
-
- /**
- * Has the user "user shifts admin" privilege?
- *
- * @var boolean
- */
- private $userShiftsAdmin;
-
- private $filled = [];
-
- private $rooms = [];
-
- private $types = [];
-
- private $startTime = null;
-
- private $endTime = null;
-
- public function __construct($user_shifts_admin, $rooms, $types) {
- $this->user_shifts_admin = $user_shifts_admin;
- $this->rooms = $rooms;
- $this->types = $types;
-
- $this->filled = [
- ShiftsFilter::FILLED_FREE
- ];
-
- if ($user_shifts_admin) {
- $this->filled[] = ShiftsFilter::FILLED_FILLED;
+class ShiftsFilter
+{
+ /**
+ * Shift is completely full.
+ */
+ const FILLED_FILLED = 1;
+
+ /**
+ * Shift has some free slots.
+ */
+ const FILLED_FREE = 0;
+
+ /**
+ * Has the user "user shifts admin" privilege?
+ *
+ * @var boolean
+ */
+ private $userShiftsAdmin;
+
+ /** @var int[] */
+ private $filled = [];
+
+ /** @var int[] */
+ private $rooms = [];
+
+ /** @var int[] */
+ private $types = [];
+
+ /** @var int unix timestamp */
+ private $startTime = null;
+
+ /** @var int unix timestamp */
+ private $endTime = null;
+
+ /**
+ * ShiftsFilter constructor.
+ *
+ * @param bool $user_shifts_admin
+ * @param int[] $rooms
+ * @param int[] $types
+ */
+ public function __construct($user_shifts_admin, $rooms, $types)
+ {
+ $this->user_shifts_admin = $user_shifts_admin;
+ $this->rooms = $rooms;
+ $this->types = $types;
+
+ $this->filled = [
+ ShiftsFilter::FILLED_FREE
+ ];
+
+ if ($user_shifts_admin) {
+ $this->filled[] = ShiftsFilter::FILLED_FILLED;
+ }
}
- }
- public function getStartTime() {
- return $this->startTime;
- }
+ /**
+ * @return int unix timestamp
+ */
+ public function getStartTime()
+ {
+ return $this->startTime;
+ }
- public function setStartTime($startTime) {
- $this->startTime = $startTime;
- }
+ /**
+ * @param int $startTime unix timestamp
+ */
+ public function setStartTime($startTime)
+ {
+ $this->startTime = $startTime;
+ }
- public function getEndTime() {
- return $this->endTime;
- }
+ /**
+ * @return int unix timestamp
+ */
+ public function getEndTime()
+ {
+ return $this->endTime;
+ }
- public function setEndTime($endTime) {
- if ($endTime - $this->startTime > ShiftsFilter::MAX_DURATION) {
- $endTime = $this->startTime + ShiftsFilter::MAX_DURATION;
+ /**
+ * @param int $endTime unix timestamp
+ */
+ public function setEndTime($endTime)
+ {
+ $this->endTime = $endTime;
}
- $this->endTime = $endTime;
- }
-
- public function getTypes() {
- if (count($this->types) == 0) {
- return [
- 0
- ];
+
+ /**
+ * @return int[]
+ */
+ public function getTypes()
+ {
+ if (count($this->types) == 0) {
+ return [0];
+ }
+ return $this->types;
}
- return $this->types;
- }
-
- public function setTypes($types) {
- $this->types = $types;
- }
-
- public function getRooms() {
- if (count($this->rooms) == 0) {
- return [
- 0
- ];
+
+ /**
+ * @param int[] $types
+ */
+ public function setTypes($types)
+ {
+ $this->types = $types;
}
- return $this->rooms;
- }
- public function setRooms($rooms) {
- $this->rooms = $rooms;
- }
+ /**
+ * @return int[]
+ */
+ public function getRooms()
+ {
+ if (count($this->rooms) == 0) {
+ return [0];
+ }
+ return $this->rooms;
+ }
- public function isUserShiftsAdmin() {
- return $this->userShiftsAdmin;
- }
+ /**
+ * @param int[] $rooms
+ */
+ public function setRooms($rooms)
+ {
+ $this->rooms = $rooms;
+ }
- public function setUserShiftsAdmin($userShiftsAdmin) {
- $this->userShiftsAdmin = $userShiftsAdmin;
- }
+ /**
+ * @return bool
+ */
+ public function isUserShiftsAdmin()
+ {
+ return $this->userShiftsAdmin;
+ }
- public function getFilled() {
- return $this->filled;
- }
+ /**
+ * @param bool $userShiftsAdmin
+ */
+ public function setUserShiftsAdmin($userShiftsAdmin)
+ {
+ $this->userShiftsAdmin = $userShiftsAdmin;
+ }
- public function setFilled($filled) {
- $this->filled = $filled;
- }
-}
+ /**
+ * @return int[]
+ */
+ public function getFilled()
+ {
+ return $this->filled;
+ }
-?> \ No newline at end of file
+ /**
+ * @param int[] $filled
+ */
+ public function setFilled($filled)
+ {
+ $this->filled = $filled;
+ }
+}
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 29156423..8a1b69f9 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -1,432 +1,615 @@
<?php
+
+use Engelsystem\Database\DB;
use Engelsystem\ShiftsFilter;
use Engelsystem\ShiftSignupState;
-function Shifts_by_room($room) {
- $result = sql_select("SELECT * FROM `Shifts` WHERE `RID`=" . sql_escape($room['RID']) . " ORDER BY `start`");
- if ($result === false) {
- engelsystem_error("Unable to load shifts.");
- }
- return $result;
+/**
+ * @param array $angeltype
+ * @return array
+ */
+function Shifts_by_angeltype($angeltype) {
+ return DB::select('
+ SELECT DISTINCT `Shifts`.* FROM `Shifts`
+ JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID`
+ WHERE `NeededAngelTypes`.`angel_type_id` = ?
+ AND `NeededAngelTypes`.`count` > 0
+ AND `Shifts`.`PSID` IS NULL
+
+ UNION
+
+ SELECT DISTINCT `Shifts`.* FROM `Shifts`
+ JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id` = `Shifts`.`RID`
+ WHERE `NeededAngelTypes`.`angel_type_id` = ?
+ AND `NeededAngelTypes`.`count` > 0
+ AND NOT `Shifts`.`PSID` IS NULL
+ ', [$angeltype['id'], $angeltype['id']]);
+}
+
+
+/**
+ * @param array $room
+ * @return array
+ */
+function Shifts_by_room($room)
+{
+ return DB::select('SELECT * FROM `Shifts` WHERE `RID`=? ORDER BY `start`', [$room['RID']]);
}
-function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
- $SQL = "SELECT * FROM (
- SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`
+/**
+ * @param ShiftsFilter $shiftsFilter
+ * @return array[]
+ */
+function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
+{
+ $sql = 'SELECT * FROM (
+ SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
FROM `Shifts`
JOIN `Room` USING (`RID`)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
- JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
- WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
- AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
- AND `NeededAngelTypes`.`angel_type_id` IN (" . implode(',', $shiftsFilter->getTypes()) . ")
+ JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID`
+ WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
+ AND `start` BETWEEN ? AND ?
+ AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND `NeededAngelTypes`.`count` > 0
AND `Shifts`.`PSID` IS NULL
-
+
UNION
-
- SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`
+
+ SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name`
FROM `Shifts`
JOIN `Room` USING (`RID`)
JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
- WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
- AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
- AND `NeededAngelTypes`.`angel_type_id` IN (" . implode(',', $shiftsFilter->getTypes()) . ")
+ WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
+ AND `start` BETWEEN ? AND ?
+ AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ')
AND `NeededAngelTypes`.`count` > 0
- AND NOT `Shifts`.`PSID` IS NULL) as tmp_shifts
-
- ORDER BY `start`";
- $result = sql_select($SQL);
- if ($result === false) {
- engelsystem_error("Unable to load shifts by filter.");
- }
- return $result;
+ AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts
+
+ ORDER BY `start`';
+
+ return DB::select(
+ $sql,
+ [
+ $shiftsFilter->getStartTime(),
+ $shiftsFilter->getEndTime(),
+ $shiftsFilter->getStartTime(),
+ $shiftsFilter->getEndTime(),
+ ]
+ );
}
-function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
- $SQL = "SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
+/**
+ * @param ShiftsFilter $shiftsFilter
+ * @return array[]
+ */
+function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
+{
+ $sql = '
+ SELECT
+ `NeededAngelTypes`.*,
+ `Shifts`.`SID`,
+ `AngelTypes`.`id`,
+ `AngelTypes`.`name`,
+ `AngelTypes`.`restricted`,
+ `AngelTypes`.`no_self_signup`
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
- WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
- AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
+ WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
+ AND `start` BETWEEN ? AND ?
AND `Shifts`.`PSID` IS NULL
UNION
- SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
+ SELECT
+ `NeededAngelTypes`.*,
+ `Shifts`.`SID`,
+ `AngelTypes`.`id`,
+ `AngelTypes`.`name`,
+ `AngelTypes`.`restricted`,
+ `AngelTypes`.`no_self_signup`
FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
- WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
- AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
- AND NOT `Shifts`.`PSID` IS NULL";
- $result = sql_select($SQL);
- if ($result === false) {
- engelsystem_error("Unable to load needed angeltypes by filter.");
- }
- return $result;
+ WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
+ AND `start` BETWEEN ? AND ?
+ AND NOT `Shifts`.`PSID` IS NULL';
+
+ return DB::select(
+ $sql,
+ [
+ $shiftsFilter->getStartTime(),
+ $shiftsFilter->getEndTime(),
+ $shiftsFilter->getStartTime(),
+ $shiftsFilter->getEndTime(),
+ ]
+ );
}
-function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) {
- $result = sql_select("SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
- FROM `Shifts`
- JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
- JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
- WHERE `Shifts`.`SID`=" . sql_escape($shift['SID']) . "
- AND `AngelTypes`.`id`=" . sql_escape($angeltype['id']) . "
- AND `Shifts`.`PSID` IS NULL
-
- UNION
-
- SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
- FROM `Shifts`
- JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
- JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
- WHERE `Shifts`.`SID`=" . sql_escape($shift['SID']) . "
- AND `AngelTypes`.`id`=" . sql_escape($angeltype['id']) . "
- AND NOT `Shifts`.`PSID` IS NULL");
- if ($result === false) {
- engelsystem_error("Unable to load needed angeltypes by filter.");
- }
- if (count($result) == 0) {
- return null;
- }
- return $result[0];
+/**
+ * @param array $shift
+ * @param array $angeltype
+ * @return array|null
+ */
+function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
+{
+ return DB::selectOne('
+ SELECT
+ `NeededAngelTypes`.*,
+ `Shifts`.`SID`,
+ `AngelTypes`.`id`,
+ `AngelTypes`.`name`,
+ `AngelTypes`.`restricted`,
+ `AngelTypes`.`no_self_signup`
+ FROM `Shifts`
+ JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
+ JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
+ WHERE `Shifts`.`SID`=?
+ AND `AngelTypes`.`id`=?
+ AND `Shifts`.`PSID` IS NULL
+
+ UNION
+
+ SELECT
+ `NeededAngelTypes`.*,
+ `Shifts`.`SID`,
+ `AngelTypes`.`id`,
+ `AngelTypes`.`name`,
+ `AngelTypes`.`restricted`,
+ `AngelTypes`.`no_self_signup`
+ FROM `Shifts`
+ JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
+ JOIN `AngelTypes` ON `AngelTypes`.`id`= `NeededAngelTypes`.`angel_type_id`
+ WHERE `Shifts`.`SID`=?
+ AND `AngelTypes`.`id`=?
+ AND NOT `Shifts`.`PSID` IS NULL
+ ',
+ [
+ $shift['SID'],
+ $angeltype['id'],
+ $shift['SID'],
+ $angeltype['id']
+ ]
+ );
}
-function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
- $SQL = "SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded`
+/**
+ * @param ShiftsFilter $shiftsFilter
+ * @return array
+ */
+function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
+{
+ $sql = '
+ SELECT
+ `User`.`Nick`,
+ `User`.`email`,
+ `User`.`email_shiftinfo`,
+ `User`.`Sprache`,
+ `User`.`Gekommen`,
+ `ShiftEntry`.`UID`,
+ `ShiftEntry`.`TID`,
+ `ShiftEntry`.`SID`,
+ `ShiftEntry`.`Comment`,
+ `ShiftEntry`.`freeloaded`
FROM `Shifts`
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID`
- WHERE `Shifts`.`RID` IN (" . implode(',', $shiftsFilter->getRooms()) . ")
- AND `start` BETWEEN " . $shiftsFilter->getStartTime() . " AND " . $shiftsFilter->getEndTime() . "
- ORDER BY `Shifts`.`start`";
- $result = sql_select($SQL);
- if ($result === false) {
- engelsystem_error("Unable to load shift entries by filter.");
- }
- return $result;
+ WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ')
+ AND `start` BETWEEN ? AND ?
+ ORDER BY `Shifts`.`start`';
+ return DB::select(
+ $sql,
+ [
+ $shiftsFilter->getStartTime(),
+ $shiftsFilter->getEndTime(),
+ ]
+ );
}
/**
* Check if a shift collides with other shifts (in time).
*
- * @param Shift $shift
- * @param array<Shift> $shifts
+ * @param array $shift
+ * @param array $shifts
+ * @return bool
*/
-function Shift_collides($shift, $shifts) {
- foreach ($shifts as $other_shift) {
- if ($shift['SID'] != $other_shift['SID']) {
- if (! ($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start'])) {
- return true;
- }
+function Shift_collides($shift, $shifts)
+{
+ foreach ($shifts as $other_shift) {
+ if ($shift['SID'] != $other_shift['SID']) {
+ if (!($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start'])) {
+ return true;
+ }
+ }
}
- }
- return false;
+ return false;
}
/**
* Returns the number of needed angels/free shift entries for an angeltype.
+ *
+ * @param array $needed_angeltype
+ * @param array[] $shift_entries
+ * @return int
*/
-function Shift_free_entries($needed_angeltype, $shift_entries) {
- $taken = 0;
- foreach ($shift_entries as $shift_entry) {
- if ($shift_entry['freeloaded'] == 0) {
- $taken ++;
+function Shift_free_entries($needed_angeltype, $shift_entries)
+{
+ $taken = 0;
+ foreach ($shift_entries as $shift_entry) {
+ if ($shift_entry['freeloaded'] == 0) {
+ $taken++;
+ }
}
- }
- return max(0, $needed_angeltype['count'] - $taken);
+ return max(0, $needed_angeltype['count'] - $taken);
}
/**
* Check if shift signup is allowed from the end users point of view (no admin like privileges)
*
- * @param Shift $shift
- * The shift
- * @param AngelType $angeltype
- * The angeltype to which the user wants to sign up
- * @param array<Shift> $user_shifts
- * List of the users shifts
- * @param boolean $angeltype_supporter
- * True, if the user has angeltype supporter rights for the angeltype, which enables him to sign somebody up for the shift.
+ * @param array $user
+ * @param array $shift The shift
+ * @param array $angeltype The angeltype to which the user wants to sign up
+ * @param array|null $user_angeltype
+ * @param array|null $user_shifts List of the users shifts
+ * @param array $needed_angeltype
+ * @param array[] $shift_entries
+ * @return ShiftSignupState
*/
-function Shift_signup_allowed_angel($user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries) {
- $free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
-
- if ($user['Gekommen'] == 0) {
- return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
- }
-
- if ($user_shifts == null) {
- $user_shifts = Shifts_by_user($user);
- }
-
- $signed_up = false;
- foreach ($user_shifts as $user_shift) {
- if ($user_shift['SID'] == $shift['SID']) {
- $signed_up = true;
- break;
+function Shift_signup_allowed_angel(
+ $user,
+ $shift,
+ $angeltype,
+ $user_angeltype,
+ $user_shifts,
+ $needed_angeltype,
+ $shift_entries
+) {
+ $free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
+
+ if (config('signup_requires_arrival') && !$user['Gekommen']) {
+ return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
+ }
+
+ if ($user_shifts == null) {
+ $user_shifts = Shifts_by_user($user);
+ }
+
+ $signed_up = false;
+ foreach ($user_shifts as $user_shift) {
+ if ($user_shift['SID'] == $shift['SID']) {
+ $signed_up = true;
+ break;
+ }
+ }
+
+ if ($signed_up) {
+ // you cannot join if you already singed up for this shift
+ return new ShiftSignupState(ShiftSignupState::SIGNED_UP, $free_entries);
+ }
+
+ if (time() > $shift['start']) {
+ // you can only join if the shift is in future
+ return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
+ }
+ if ($free_entries == 0) {
+ // you cannot join if shift is full
+ return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
+ }
+
+ if ($user_angeltype == null) {
+ $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
+ }
+
+ if (
+ $user_angeltype == null
+ || ($angeltype['no_self_signup'] == 1 && $user_angeltype != null)
+ || ($angeltype['restricted'] == 1 && $user_angeltype != null && !isset($user_angeltype['confirm_user_id']))
+ ) {
+ // you cannot join if user is not of this angel type
+ // you cannot join if you are not confirmed
+ // you cannot join if angeltype has no self signup
+
+ return new ShiftSignupState(ShiftSignupState::ANGELTYPE, $free_entries);
+ }
+
+ if (Shift_collides($shift, $user_shifts)) {
+ // you cannot join if user alread joined a parallel or this shift
+ return new ShiftSignupState(ShiftSignupState::COLLIDES, $free_entries);
}
- }
-
- if ($signed_up) {
- // you cannot join if you already singed up for this shift
- return new ShiftSignupState(ShiftSignupState::SIGNED_UP, $free_entries);
- }
-
- if (time() > $shift['start']) {
- // you can only join if the shift is in future
- return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries);
- }
- if ($free_entries == 0) {
- // you cannot join if shift is full
- return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
- }
-
- if ($user_angeltype == null) {
- $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- }
-
- if ($user_angeltype == null || ($angeltype['no_self_signup'] == 1 && $user_angeltype != null) || ($angeltype['restricted'] == 1 && $user_angeltype != null && ! isset($user_angeltype['confirm_user_id']))) {
- // you cannot join if user is not of this angel type
- // you cannot join if you are not confirmed
- // you cannot join if angeltype has no self signup
-
- return new ShiftSignupState(ShiftSignupState::ANGELTYPE, $free_entries);
- }
-
- if (Shift_collides($shift, $user_shifts)) {
- // you cannot join if user alread joined a parallel or this shift
- return new ShiftSignupState(ShiftSignupState::COLLIDES, $free_entries);
- }
-
- // Hooray, shift is free for you!
- return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
+
+ // Hooray, shift is free for you!
+ return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
}
/**
* Check if an angeltype supporter can sign up a user to a shift.
+ *
+ * @param array $needed_angeltype
+ * @param array[] $shift_entries
+ * @return ShiftSignupState
*/
-function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries) {
- $free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
- if ($free_entries == 0) {
- return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
- }
-
- return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
+function Shift_signup_allowed_angeltype_supporter($needed_angeltype, $shift_entries)
+{
+ $free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
+ if ($free_entries == 0) {
+ return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
+ }
+
+ return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
}
/**
* Check if an admin can sign up a user to a shift.
*
- * @param Shift $shift
- * The shift
- * @param AngelType $angeltype
- * The angeltype to which the user wants to sign up
+ * @param array $needed_angeltype
+ * @param array[] $shift_entries
+ * @return ShiftSignupState
*/
-function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries) {
- $free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
-
- if ($free_entries == 0) {
- // User shift admins may join anybody in every shift
- return new ShiftSignupState(ShiftSignupState::ADMIN, $free_entries);
- }
-
- return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
+function Shift_signup_allowed_admin($needed_angeltype, $shift_entries)
+{
+ $free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
+
+ if ($free_entries == 0) {
+ // User shift admins may join anybody in every shift
+ return new ShiftSignupState(ShiftSignupState::ADMIN, $free_entries);
+ }
+
+ return new ShiftSignupState(ShiftSignupState::FREE, $free_entries);
}
/**
* Check if an angel can sign up for given shift.
*
- * @param Shift $shift
- * The shift
- * @param AngelType $angeltype
- * The angeltype to which the user wants to sign up
- * @param array<Shift> $user_shifts
- * List of the users shifts
+ * @param array $signup_user
+ * @param array $shift The shift
+ * @param array $angeltype The angeltype to which the user wants to sign up
+ * @param array|null $user_angeltype
+ * @param array|null $user_shifts List of the users shifts
+ * @param array $needed_angeltype
+ * @param array[] $shift_entries
+ * @return ShiftSignupState
*/
-function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype = null, $user_shifts = null, $needed_angeltype, $shift_entries) {
- global $user, $privileges;
-
- if (in_array('user_shifts_admin', $privileges)) {
- return Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries);
- }
-
- if (in_array('shiftentry_edit_angeltype_supporter', $privileges) && User_is_AngelType_supporter($user, $angeltype)) {
- return Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries);
- }
-
- return Shift_signup_allowed_angel($signup_user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries);
+function Shift_signup_allowed(
+ $signup_user,
+ $shift,
+ $angeltype,
+ $user_angeltype,
+ $user_shifts,
+ $needed_angeltype,
+ $shift_entries
+) {
+ global $user, $privileges;
+
+ if (in_array('user_shifts_admin', $privileges)) {
+ return Shift_signup_allowed_admin($needed_angeltype, $shift_entries);
+ }
+
+ if (
+ in_array('shiftentry_edit_angeltype_supporter', $privileges)
+ && User_is_AngelType_supporter($user, $angeltype)
+ ) {
+ return Shift_signup_allowed_angeltype_supporter($needed_angeltype, $shift_entries);
+ }
+
+ return Shift_signup_allowed_angel(
+ $signup_user,
+ $shift,
+ $angeltype,
+ $user_angeltype,
+ $user_shifts,
+ $needed_angeltype,
+ $shift_entries
+ );
}
/**
* Delete a shift by its external id.
+ *
+ * @param int $shift_psid
*/
-function Shift_delete_by_psid($shift_psid) {
- return sql_query("DELETE FROM `Shifts` WHERE `PSID`='" . sql_escape($shift_psid) . "'");
+function Shift_delete_by_psid($shift_psid)
+{
+ DB::delete('DELETE FROM `Shifts` WHERE `PSID`=?', [$shift_psid]);
}
/**
* Delete a shift.
+ *
+ * @param int $shift_id
*/
-function Shift_delete($shift_id) {
- mail_shift_delete(Shift($shift_id));
-
- $result = sql_query("DELETE FROM `Shifts` WHERE `SID`='" . sql_escape($shift_id) . "'");
- if ($result === false) {
- engelsystem_error('Unable to delete shift.');
- }
- return $result;
+function Shift_delete($shift_id)
+{
+ mail_shift_delete(Shift($shift_id));
+
+ DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
}
/**
* Update a shift.
+ *
+ * @param array $shift
+ * @return int Updated row count
*/
-function Shift_update($shift) {
- global $user;
- $shift['name'] = ShiftType($shift['shifttype_id'])['name'];
- mail_shift_change(Shift($shift['SID']), $shift);
-
- return sql_query("UPDATE `Shifts` SET
- `shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
- `start`='" . sql_escape($shift['start']) . "',
- `end`='" . sql_escape($shift['end']) . "',
- `RID`='" . sql_escape($shift['RID']) . "',
- `title`=" . sql_null($shift['title']) . ",
- `URL`=" . sql_null($shift['URL']) . ",
- `PSID`=" . sql_null($shift['PSID']) . ",
- `edited_by_user_id`='" . sql_escape($user['UID']) . "',
- `edited_at_timestamp`=" . time() . "
- WHERE `SID`='" . sql_escape($shift['SID']) . "'");
+function Shift_update($shift)
+{
+ global $user;
+ $shift['name'] = ShiftType($shift['shifttype_id'])['name'];
+ mail_shift_change(Shift($shift['SID']), $shift);
+
+ return DB::update('
+ UPDATE `Shifts` SET
+ `shifttype_id` = ?,
+ `start` = ?,
+ `end` = ?,
+ `RID` = ?,
+ `title` = ?,
+ `URL` = ?,
+ `PSID` = ?,
+ `edited_by_user_id` = ?,
+ `edited_at_timestamp` = ?
+ WHERE `SID` = ?
+ ',
+ [
+ $shift['shifttype_id'],
+ $shift['start'],
+ $shift['end'],
+ $shift['RID'],
+ $shift['title'],
+ $shift['URL'],
+ $shift['PSID'],
+ $user['UID'],
+ time(),
+ $shift['SID']
+ ]
+ );
}
/**
* Update a shift by its external id.
+ *
+ * @param array $shift
+ * @return bool|null
+ * @throws Exception
*/
-function Shift_update_by_psid($shift) {
- $shift_source = sql_select("SELECT `SID` FROM `Shifts` WHERE `PSID`=" . $shift['PSID']);
- if ($shift_source === false) {
- return false;
- }
- if (count($shift_source) == 0) {
- return null;
- }
- $shift['SID'] = $shift_source[0]['SID'];
- return Shift_update($shift);
+function Shift_update_by_psid($shift)
+{
+ $shift_source = DB::selectOne('SELECT `SID` FROM `Shifts` WHERE `PSID`=?', [$shift['PSID']]);
+
+ if (empty($shift_source)) {
+ throw new Exception('Shift not found.');
+ }
+
+ $shift['SID'] = $shift_source['SID'];
+ return Shift_update($shift);
}
/**
* Create a new shift.
*
- * @return new shift id or false
+ * @param array $shift
+ * @return int ID of the new created shift
*/
-function Shift_create($shift) {
- global $user;
- $result = sql_query("INSERT INTO `Shifts` SET
- `shifttype_id`='" . sql_escape($shift['shifttype_id']) . "',
- `start`='" . sql_escape($shift['start']) . "',
- `end`='" . sql_escape($shift['end']) . "',
- `RID`='" . sql_escape($shift['RID']) . "',
- `title`=" . sql_null($shift['title']) . ",
- `URL`=" . sql_null($shift['URL']) . ",
- `PSID`=" . sql_null($shift['PSID']) . ",
- `created_by_user_id`='" . sql_escape($user['UID']) . "',
- `created_at_timestamp`=" . time());
- if ($result === false) {
- return false;
- }
- return sql_id();
+function Shift_create($shift)
+{
+ global $user;
+ DB::insert('
+ INSERT INTO `Shifts` (
+ `shifttype_id`,
+ `start`,
+ `end`,
+ `RID`,
+ `title`,
+ `URL`,
+ `PSID`,
+ `created_by_user_id`,
+ `edited_at_timestamp`,
+ `created_at_timestamp`
+ )
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ',
+ [
+ $shift['shifttype_id'],
+ $shift['start'],
+ $shift['end'],
+ $shift['RID'],
+ $shift['title'],
+ $shift['URL'],
+ $shift['PSID'],
+ $user['UID'],
+ time(),
+ time(),
+ ]
+ );
+
+ return DB::getPdo()->lastInsertId();
}
/**
* Return users shifts.
+ *
+ * @param array $user
+ * @param bool $include_freeload_comments
+ * @return array
*/
-function Shifts_by_user($user, $include_freeload_comments = false) {
- $result = sql_select("
- 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`)
- JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
- WHERE `UID`='" . sql_escape($user['UID']) . "'
- ORDER BY `start`
- ");
- if ($result === false) {
- engelsystem_error('Unable to load users shifts.');
- }
- return $result;
+function Shifts_by_user($user, $include_freeload_comments = false)
+{
+ return DB::select('
+ 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`)
+ JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
+ WHERE `UID` = ?
+ ORDER BY `start`
+ ',
+ [
+ $user['UID']
+ ]
+ );
}
/**
* Returns Shift by id.
*
- * @param $shift_id Shift
- * ID
+ * @param int $shift_id Shift ID
+ * @return array|null
*/
-function Shift($shift_id) {
- $shifts_source = sql_select("
+function Shift($shift_id)
+{
+ $result = DB::selectOne('
SELECT `Shifts`.*, `ShiftTypes`.`name`
- FROM `Shifts`
+ FROM `Shifts`
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
- WHERE `SID`='" . sql_escape($shift_id) . "'");
- $shiftsEntry_source = sql_select("SELECT `id`, `TID` , `UID` , `freeloaded` FROM `ShiftEntry` WHERE `SID`='" . sql_escape($shift_id) . "'");
-
- if ($shifts_source === false) {
- engelsystem_error('Unable to load shift.');
- }
-
- if (empty($shifts_source)) {
- return null;
- }
-
- $result = $shifts_source[0];
-
- $result['ShiftEntry'] = $shiftsEntry_source;
- $result['NeedAngels'] = [];
-
- $temp = NeededAngelTypes_by_shift($shift_id);
- foreach ($temp as $e) {
- $result['NeedAngels'][] = [
- 'TID' => $e['angel_type_id'],
- 'count' => $e['count'],
- 'restricted' => $e['restricted'],
- 'taken' => $e['taken']
- ];
- }
-
- return $result;
+ WHERE `SID`=?', [$shift_id]);
+
+ if (empty($result)) {
+ return null;
+ }
+
+ $shiftsEntry_source = DB::select('
+ SELECT `id`, `TID` , `UID` , `freeloaded`
+ FROM `ShiftEntry`
+ WHERE `SID`=?', [$shift_id]);
+
+ $result['ShiftEntry'] = $shiftsEntry_source;
+ $result['NeedAngels'] = [];
+
+ $angelTypes = NeededAngelTypes_by_shift($shift_id);
+ foreach ($angelTypes as $type) {
+ $result['NeedAngels'][] = [
+ 'TID' => $type['angel_type_id'],
+ 'count' => $type['count'],
+ 'restricted' => $type['restricted'],
+ 'taken' => $type['taken']
+ ];
+ }
+
+ return $result;
}
/**
* Returns all shifts with needed angeltypes and count of subscribed jobs.
+ *
+ * @return array
*/
-function Shifts() {
- $shifts_source = sql_select("
- SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` as `room_name`
- FROM `Shifts`
- JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
- JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
- ");
- if ($shifts_source === false) {
- return false;
- }
-
- foreach ($shifts_source as &$shift) {
- $needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
- if ($needed_angeltypes === false) {
- return false;
+function Shifts()
+{
+ $shifts_source = DB::select('
+ SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name`
+ FROM `Shifts`
+ JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
+ JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
+ ');
+
+ foreach ($shifts_source as &$shift) {
+ $needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
+ $shift['angeltypes'] = $needed_angeltypes;
}
-
- $shift['angeltypes'] = $needed_angeltypes;
- }
-
- return $shifts_source;
-}
-?>
+ return $shifts_source;
+}
diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php
index 11366cdf..3a7508ee 100644
--- a/includes/model/UserAngelTypes_model.php
+++ b/includes/model/UserAngelTypes_model.php
@@ -1,5 +1,7 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* User angeltypes model
*/
@@ -7,223 +9,220 @@
/**
* Checks if a user joined an angeltype.
*
- * @param User $user
- * The user to be checked
- * @param Angeltype $angeltype
- * The angeltype to be checked
+ * @param array $user The user to be checked
+ * @param array $angeltype The angeltype to be checked
* @return boolean
*/
-function UserAngelType_exists($user, $angeltype) {
- return sql_num_query("
- SELECT `id`
+function UserAngelType_exists($user, $angeltype)
+{
+ return count(DB::select('
+ SELECT `id`
FROM `UserAngelTypes`
- WHERE `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "'
- AND `angeltype_id`='" . sql_escape($angeltype['id']) . "'
- ") > 0;
+ WHERE `UserAngelTypes`.`user_id`=?
+ AND `angeltype_id`=?
+ ', [$user['UID'], $angeltype['id']])) > 0;
}
/**
* List users angeltypes.
*
- * @param User $user
+ * @param array $user
+ * @return array
*/
-function User_angeltypes($user) {
- $result = sql_select("
+function User_angeltypes($user)
+{
+ return DB::select('
SELECT `AngelTypes`.*, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`
FROM `UserAngelTypes`
JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`
- WHERE `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "'
- ");
- if ($result === false) {
- engelsystem_error("Unable to load user angeltypes.");
- return false;
- }
- return $result;
+ WHERE `UserAngelTypes`.`user_id`=?
+ ', [$user['UID']]);
}
/**
* Gets unconfirmed user angeltypes for angeltypes of which the given user is a supporter.
*
- * @param User $user
+ * @param array $user
+ * @return array
*/
-function User_unconfirmed_AngelTypes($user) {
- $result = sql_select("
- SELECT
- `UserAngelTypes`.*,
- `AngelTypes`.`name`,
- count(`UnconfirmedMembers`.`user_id`) as `count`
- FROM `UserAngelTypes`
- JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id`
- JOIN `UserAngelTypes` as `UnconfirmedMembers` ON `UserAngelTypes`.`angeltype_id`=`UnconfirmedMembers`.`angeltype_id`
- WHERE `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "'
- AND `UserAngelTypes`.`supporter`=TRUE
- AND `AngelTypes`.`restricted`=TRUE
- AND `UnconfirmedMembers`.`confirm_user_id` IS NULL
- GROUP BY `UserAngelTypes`.`angeltype_id`
- ORDER BY `AngelTypes`.`name`");
- if ($result === false) {
- engelsystem_error("Unable to load user angeltypes.");
- }
- return $result;
+function User_unconfirmed_AngelTypes($user)
+{
+ return DB::select('
+ SELECT
+ `UserAngelTypes`.*,
+ `AngelTypes`.`name`,
+ count(`UnconfirmedMembers`.`user_id`) AS `count`
+ FROM `UserAngelTypes`
+ JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id`
+ JOIN `UserAngelTypes` AS `UnconfirmedMembers` ON `UserAngelTypes`.`angeltype_id`=`UnconfirmedMembers`.`angeltype_id`
+ WHERE `UserAngelTypes`.`user_id`=?
+ AND `UserAngelTypes`.`supporter`=TRUE
+ AND `AngelTypes`.`restricted`=TRUE
+ AND `UnconfirmedMembers`.`confirm_user_id` IS NULL
+ GROUP BY `UserAngelTypes`.`angeltype_id`, `UserAngelTypes`.`id`
+ ORDER BY `AngelTypes`.`name`
+ ', [$user['UID']]);
}
/**
* Returns true if user is angeltype supporter or has privilege admin_user_angeltypes.
*
- * @param User $user
- * @param AngelType $angeltype
+ * @param array $user
+ * @param array $angeltype
+ * @return bool
*/
-function User_is_AngelType_supporter(&$user, $angeltype) {
- if(!isset($user['privileges'])) {
- $user['privileges'] = privileges_for_user($user['UID']);
- }
- return (sql_num_query("
- SELECT `id`
- FROM `UserAngelTypes`
- WHERE `user_id`='" . sql_escape($user['UID']) . "'
- AND `angeltype_id`='" . sql_escape($angeltype['id']) . "'
- AND `supporter`=TRUE
- LIMIT 1") > 0) || in_array('admin_user_angeltypes', $user['privileges']);
+function User_is_AngelType_supporter(&$user, $angeltype)
+{
+ if (!isset($user['privileges'])) {
+ $user['privileges'] = privileges_for_user($user['UID']);
+ }
+ return (count(DB::select('
+ SELECT `id`
+ FROM `UserAngelTypes`
+ WHERE `user_id`=?
+ AND `angeltype_id`=?
+ AND `supporter`=TRUE
+ LIMIT 1
+ ',
+ [
+ $user['UID'],
+ $angeltype['id']
+ ]
+ )) > 0)
+ || in_array('admin_user_angeltypes', $user['privileges']);
}
/**
* Add or remove supporter rights.
*
- * @param int $user_angeltype_id
- * @param bool $supporter
+ * @param int $user_angeltype_id
+ * @param bool $supporter
*/
-function UserAngelType_update($user_angeltype_id, $supporter) {
- $result = sql_query("
+function UserAngelType_update($user_angeltype_id, $supporter)
+{
+ DB::update('
UPDATE `UserAngelTypes`
- SET `supporter`=" . sql_bool($supporter) . "
- WHERE `id`='" . sql_escape($user_angeltype_id) . "'
- LIMIT 1");
- if ($result === false) {
- engelsystem_error("Unable to update supporter rights.");
- }
- return $result;
+ SET `supporter`=?
+ WHERE `id`=?
+ LIMIT 1
+ ', [$supporter, $user_angeltype_id]);
}
/**
* Delete all unconfirmed UserAngelTypes for given Angeltype.
*
- * @param int $angeltype_id
+ * @param int $angeltype_id
*/
-function UserAngelTypes_delete_all($angeltype_id) {
- $result = sql_query("
+function UserAngelTypes_delete_all($angeltype_id)
+{
+ DB::delete('
DELETE FROM `UserAngelTypes`
- WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
- AND `confirm_user_id` IS NULL");
- if ($result === false) {
- engelsystem_error("Unable to delete all unconfirmed users.");
- }
- return $result;
+ WHERE `angeltype_id`=?
+ AND `confirm_user_id` IS NULL
+ ', [$angeltype_id]);
}
/**
* Confirm all unconfirmed UserAngelTypes for given Angeltype.
*
- * @param int $angeltype_id
- * @param User $confirm_user
+ * @param int $angeltype_id
+ * @param array $confirm_user
*/
-function UserAngelTypes_confirm_all($angeltype_id, $confirm_user) {
- $result = sql_query("
+function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
+{
+ DB::update('
UPDATE `UserAngelTypes`
- SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
- WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
- AND `confirm_user_id` IS NULL");
- if ($result === false) {
- engelsystem_error("Unable to confirm all users.");
- }
- return $result;
+ SET `confirm_user_id`=?
+ WHERE `angeltype_id`=?
+ AND `confirm_user_id` IS NULL
+ ', [$confirm_user['UID'], $angeltype_id]);
}
/**
* Confirm an UserAngelType with confirming user.
*
- * @param int $user_angeltype_id
- * @param User $confirm_user
+ * @param int $user_angeltype_id
+ * @param array $confirm_user
+ * @return bool
*/
-function UserAngelType_confirm($user_angeltype_id, $confirm_user) {
- $result = sql_query("
+function UserAngelType_confirm($user_angeltype_id, $confirm_user)
+{
+ DB::update('
UPDATE `UserAngelTypes`
- SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
- WHERE `id`='" . sql_escape($user_angeltype_id) . "'
- LIMIT 1");
- if ($result === false) {
- engelsystem_error("Unable to confirm user angeltype.");
- }
- return $result;
+ SET `confirm_user_id`=?
+ WHERE `id`=?
+ LIMIT 1', [$confirm_user['UID'], $user_angeltype_id]);
}
/**
* Delete an UserAngelType.
*
- * @param UserAngelType $user_angeltype
+ * @param array $user_angeltype
*/
-function UserAngelType_delete($user_angeltype) {
- return sql_query("
- DELETE FROM `UserAngelTypes`
- WHERE `id`='" . sql_escape($user_angeltype['id']) . "'
- LIMIT 1");
+function UserAngelType_delete($user_angeltype)
+{
+ DB::delete('
+ DELETE FROM `UserAngelTypes`
+ WHERE `id`=?
+ LIMIT 1', [$user_angeltype['id']]);
}
/**
* Create an UserAngelType.
*
- * @param User $user
- * @param Angeltype $angeltype
+ * @param array $user
+ * @param array $angeltype
+ * @return int
*/
-function UserAngelType_create($user, $angeltype) {
- $result = sql_query("
- INSERT INTO `UserAngelTypes` SET
- `user_id`='" . sql_escape($user['UID']) . "',
- `angeltype_id`='" . sql_escape($angeltype['id']) . "'");
- if ($result === false) {
- engelsystem_error("Unable to create user angeltype.");
- }
- return sql_id();
+function UserAngelType_create($user, $angeltype)
+{
+ DB::insert('
+ INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`)
+ VALUES (?, ?, FALSE)
+ ',
+ [
+ $user['UID'],
+ $angeltype['id']
+ ]
+ );
+
+ return DB::getPdo()->lastInsertId();
}
/**
* Get an UserAngelType by its id.
*
- * @param int $user_angeltype_id
+ * @param int $user_angeltype_id
+ * @return array|null
*/
-function UserAngelType($user_angeltype_id) {
- $angeltype = sql_select("
+function UserAngelType($user_angeltype_id)
+{
+ return DB::selectOne('
SELECT *
FROM `UserAngelTypes`
- WHERE `id`='" . sql_escape($user_angeltype_id) . "'
- LIMIT 1");
- if ($angeltype === false) {
- engelsystem_error("Unable to load user angeltype.");
- }
- if (count($angeltype) == 0) {
- return null;
- }
- return $angeltype[0];
+ WHERE `id`=?
+ LIMIT 1', [$user_angeltype_id]);
}
/**
* Get an UserAngelType by user and angeltype.
*
- * @param User $user
- * @param Angeltype $angeltype
+ * @param array $user
+ * @param array $angeltype
+ * @return array|null
*/
-function UserAngelType_by_User_and_AngelType($user, $angeltype) {
- $angeltype = sql_select("
- SELECT *
- FROM `UserAngelTypes`
- WHERE `user_id`='" . sql_escape($user['UID']) . "'
- AND `angeltype_id`='" . sql_escape($angeltype['id']) . "'
- LIMIT 1");
- if ($angeltype === false) {
- engelsystem_error("Unable to load user angeltype.");
- }
- if (count($angeltype) == 0) {
- return null;
- }
- return $angeltype[0];
+function UserAngelType_by_User_and_AngelType($user, $angeltype)
+{
+ return DB::selectOne('
+ SELECT *
+ FROM `UserAngelTypes`
+ WHERE `user_id`=?
+ AND `angeltype_id`=?
+ LIMIT 1
+ ',
+ [
+ $user['UID'],
+ $angeltype['id']
+ ]
+ );
}
-?> \ No newline at end of file
diff --git a/includes/model/UserDriverLicenses_model.php b/includes/model/UserDriverLicenses_model.php
index afc44575..dc38368b 100644
--- a/includes/model/UserDriverLicenses_model.php
+++ b/includes/model/UserDriverLicenses_model.php
@@ -1,104 +1,128 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Returns a new empty UserDriverLicense
* FIXME entity object needed
+ *
+ * @return array
*/
-function UserDriverLicense_new() {
- return [
- 'user_id' => null,
- 'has_car' => false,
- 'has_license_car' => false,
- 'has_license_3_5t_transporter' => false,
- 'has_license_7_5t_truck' => false,
- 'has_license_12_5t_truck' => false,
- 'has_license_forklift' => false
- ];
+function UserDriverLicense_new()
+{
+ return [
+ 'user_id' => null,
+ 'has_car' => false,
+ 'has_license_car' => false,
+ 'has_license_3_5t_transporter' => false,
+ 'has_license_7_5t_truck' => false,
+ 'has_license_12_5t_truck' => false,
+ 'has_license_forklift' => false
+ ];
}
/**
* Is it valid?
*
- * @param UserDriverLicense $user_driver_license
- * The UserDriverLicense to check
+ * @param array $user_driver_license The UserDriverLicense to check
* @return boolean
*/
-function UserDriverLicense_valid($user_driver_license) {
- return $user_driver_license['has_license_car'] || $user_driver_license['has_license_3_5t_transporter'] || $user_driver_license['has_license_7_5t_truck'] || $user_driver_license['has_license_12_5t_truck'] || $user_driver_license['has_license_forklift'];
+function UserDriverLicense_valid($user_driver_license)
+{
+ return
+ $user_driver_license['has_license_car']
+ || $user_driver_license['has_license_3_5t_transporter']
+ || $user_driver_license['has_license_7_5t_truck']
+ || $user_driver_license['has_license_12_5t_truck']
+ || $user_driver_license['has_license_forklift'];
}
/**
* Get a users driver license information
*
- * @param int $user_id
- * The users id
+ * @param int $user_id The users id
+ * @return array|null
*/
-function UserDriverLicense($user_id) {
- $user_driver_license = sql_select("SELECT * FROM `UserDriverLicenses` WHERE `user_id`='" . sql_escape($user_id) . "'");
- if ($user_driver_license === false) {
- engelsystem_error('Unable to load user driver license.');
- return false;
- }
- if (count($user_driver_license) > 0) {
- return $user_driver_license[0];
- }
- return null;
+function UserDriverLicense($user_id)
+{
+ return DB::selectOne('
+ SELECT *
+ FROM `UserDriverLicenses`
+ WHERE `user_id`=?', [$user_id]);
}
/**
* Create a user's driver license entry
*
- * @param UserDriverLicense $user_driver_license
- * The UserDriverLicense to create
+ * @param array $user_driver_license The UserDriverLicense to create
+ * @param array $user
+ * @return array
*/
-function UserDriverLicenses_create($user_driver_license, $user) {
- $user_driver_license['user_id'] = $user['UID'];
- $result = sql_query("
- INSERT INTO `UserDriverLicenses` SET
- `user_id`=" . sql_escape($user_driver_license['user_id']) . ",
- `has_car`=" . sql_bool($user_driver_license['has_car']) . ",
- `has_license_car`=" . sql_bool($user_driver_license['has_license_car']) . ",
- `has_license_3_5t_transporter`=" . sql_bool($user_driver_license['has_license_3_5t_transporter']) . ",
- `has_license_7_5t_truck`=" . sql_bool($user_driver_license['has_license_7_5t_truck']) . ",
- `has_license_12_5t_truck`=" . sql_bool($user_driver_license['has_license_12_5t_truck']) . ",
- `has_license_forklift`=" . sql_bool($user_driver_license['has_license_forklift']));
- if ($result === false) {
- engelsystem_error('Unable to create user driver license');
- }
- return $user_driver_license;
+function UserDriverLicenses_create($user_driver_license, $user)
+{
+ $user_driver_license['user_id'] = $user['UID'];
+ DB::insert('
+ INSERT INTO `UserDriverLicenses` (
+ `user_id`,
+ `has_car`,
+ `has_license_car`,
+ `has_license_3_5t_transporter`,
+ `has_license_7_5t_truck`,
+ `has_license_12_5t_truck`,
+ `has_license_forklift`
+ )
+ VALUES (?, ?, ?, ?, ?, ?, ?)
+ ',
+ [
+ $user_driver_license['user_id'],
+ (int)$user_driver_license['has_car'],
+ (int)$user_driver_license['has_license_car'],
+ (int)$user_driver_license['has_license_3_5t_transporter'],
+ (int)$user_driver_license['has_license_7_5t_truck'],
+ (int)$user_driver_license['has_license_12_5t_truck'],
+ (int)$user_driver_license['has_license_forklift'],
+ ]
+ );
+
+ return $user_driver_license;
}
/**
* Update a user's driver license entry
*
- * @param UserDriverLicense $user_driver_license
- * The UserDriverLicense to update
+ * @param array $user_driver_license The UserDriverLicense to update
*/
-function UserDriverLicenses_update($user_driver_license) {
- $result = sql_query("UPDATE `UserDriverLicenses` SET
- `has_car`=" . sql_bool($user_driver_license['has_car']) . ",
- `has_license_car`=" . sql_bool($user_driver_license['has_license_car']) . ",
- `has_license_3_5t_transporter`=" . sql_bool($user_driver_license['has_license_3_5t_transporter']) . ",
- `has_license_7_5t_truck`=" . sql_bool($user_driver_license['has_license_7_5t_truck']) . ",
- `has_license_12_5t_truck`=" . sql_bool($user_driver_license['has_license_12_5t_truck']) . ",
- `has_license_forklift`=" . sql_bool($user_driver_license['has_license_forklift']) . "
- WHERE `user_id`='" . sql_escape($user_driver_license['user_id']) . "'");
- if ($result === false) {
- engelsystem_error("Unable to update user driver license information");
- }
- return $result;
+function UserDriverLicenses_update($user_driver_license)
+{
+ DB::update('
+ UPDATE `UserDriverLicenses`
+ SET
+ `has_car`=?,
+ `has_license_car`=?,
+ `has_license_3_5t_transporter`=?,
+ `has_license_7_5t_truck`=?,
+ `has_license_12_5t_truck`=?,
+ `has_license_forklift`=?
+ WHERE `user_id`=?
+ ',
+ [
+ (int)$user_driver_license['has_car'],
+ (int)$user_driver_license['has_license_car'],
+ (int)$user_driver_license['has_license_3_5t_transporter'],
+ (int)$user_driver_license['has_license_7_5t_truck'],
+ (int)$user_driver_license['has_license_12_5t_truck'],
+ (int)$user_driver_license['has_license_forklift'],
+ $user_driver_license['user_id'],
+ ]
+ );
}
/**
* Delete a user's driver license entry
*
- * @param int $user_id
+ * @param int $user_id
*/
-function UserDriverLicenses_delete($user_id) {
- $result = sql_query("DELETE FROM `UserDriverLicenses` WHERE `user_id`=" . sql_escape($user_id));
- if ($result === false) {
- engelsystem_error("Unable to remove user driver license information");
- }
- return $result;
+function UserDriverLicenses_delete($user_id)
+{
+ DB::delete('DELETE FROM `UserDriverLicenses` WHERE `user_id`=?', [$user_id]);
}
-?> \ No newline at end of file
diff --git a/includes/model/UserGroups_model.php b/includes/model/UserGroups_model.php
index 766f402f..d4baf638 100644
--- a/includes/model/UserGroups_model.php
+++ b/includes/model/UserGroups_model.php
@@ -1,17 +1,22 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Returns users groups
- * @param User $user
+ *
+ * @param array $user
+ * @return array
*/
-function User_groups($user) {
- return sql_select("
- SELECT `Groups`.*
- FROM `UserGroups`
- JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`
- WHERE `UserGroups`.`uid`='" . sql_escape($user['UID']) . "'
- ORDER BY `UserGroups`.`group_id`
- ");
+function User_groups($user)
+{
+ return DB::select('
+ SELECT `Groups`.*
+ FROM `UserGroups`
+ JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`
+ WHERE `UserGroups`.`uid`=?
+ ORDER BY `UserGroups`.`group_id`
+ ',
+ [$user['UID']]
+ );
}
-
-?> \ No newline at end of file
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index 3ebd3bf9..26eb42c4 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -1,4 +1,6 @@
<?php
+
+use Engelsystem\Database\DB;
use Engelsystem\ValidationResult;
/**
@@ -8,164 +10,270 @@ use Engelsystem\ValidationResult;
/**
* Delete a user
*
- * @param int $user_id
+ * @param int $user_id
*/
-function User_delete($user_id) {
- return sql_query("DELETE FROM `User` WHERE `UID`='" . sql_escape($user_id) . "'");
+function User_delete($user_id)
+{
+ DB::delete('DELETE FROM `User` WHERE `UID`=?', [$user_id]);
}
/**
* Update user.
*
- * @param User $user
+ * @param array $user
*/
-function User_update($user) {
- return sql_query("UPDATE `User` SET
- `Nick`='" . sql_escape($user['Nick']) . "',
- `Name`='" . sql_escape($user['Name']) . "',
- `Vorname`='" . sql_escape($user['Vorname']) . "',
- `Alter`='" . sql_escape($user['Alter']) . "',
- `Telefon`='" . sql_escape($user['Telefon']) . "',
- `DECT`='" . sql_escape($user['DECT']) . "',
- `Handy`='" . sql_escape($user['Handy']) . "',
- `email`='" . sql_escape($user['email']) . "',
- `email_shiftinfo`=" . sql_bool($user['email_shiftinfo']) . ",
- `email_by_human_allowed`=" . sql_bool($user['email_by_human_allowed']) . ",
- `jabber`='" . sql_escape($user['jabber']) . "',
- `Size`='" . sql_escape($user['Size']) . "',
- `Gekommen`='" . sql_escape($user['Gekommen']) . "',
- `Aktiv`='" . sql_escape($user['Aktiv']) . "',
- `force_active`=" . sql_bool($user['force_active']) . ",
- `Tshirt`='" . sql_escape($user['Tshirt']) . "',
- `color`='" . sql_escape($user['color']) . "',
- `Sprache`='" . sql_escape($user['Sprache']) . "',
- `Hometown`='" . sql_escape($user['Hometown']) . "',
- `got_voucher`='" . sql_escape($user['got_voucher']) . "',
- `arrival_date`='" . sql_escape($user['arrival_date']) . "',
- `planned_arrival_date`='" . sql_escape($user['planned_arrival_date']) . "',
- `planned_departure_date`=" . sql_null($user['planned_departure_date']) . "
- WHERE `UID`='" . sql_escape($user['UID']) . "'");
+function User_update($user)
+{
+ DB::update('
+ UPDATE `User` SET
+ `Nick`=?,
+ `Name`=?,
+ `Vorname`=?,
+ `Alter`=?,
+ `Telefon`=?,
+ `DECT`=?,
+ `Handy`=?,
+ `email`=?,
+ `email_shiftinfo`=?,
+ `email_by_human_allowed`=?,
+ `jabber`=?,
+ `Size`=?,
+ `Gekommen`=?,
+ `Aktiv`=?,
+ `force_active`=?,
+ `Tshirt`=?,
+ `color`=?,
+ `Sprache`=?,
+ `Hometown`=?,
+ `got_voucher`=?,
+ `arrival_date`=?,
+ `planned_arrival_date`=?,
+ `planned_departure_date`=?
+ WHERE `UID`=?
+ ',
+ [
+ $user['Nick'],
+ $user['Name'],
+ $user['Vorname'],
+ $user['Alter'],
+ $user['Telefon'],
+ $user['DECT'],
+ $user['Handy'],
+ $user['email'],
+ (int)$user['email_shiftinfo'],
+ (int)$user['email_by_human_allowed'],
+ $user['jabber'],
+ $user['Size'],
+ $user['Gekommen'],
+ $user['Aktiv'],
+ (int)$user['force_active'],
+ $user['Tshirt'],
+ $user['color'],
+ $user['Sprache'],
+ $user['Hometown'],
+ $user['got_voucher'],
+ $user['arrival_date'],
+ $user['planned_arrival_date'],
+ $user['planned_departure_date'],
+ $user['UID'],
+ ]
+ );
}
/**
* Counts all forced active users.
+ *
+ * @return int
*/
-function User_force_active_count() {
- return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `force_active` = 1");
+function User_force_active_count()
+{
+ $result = DB::selectOne('SELECT COUNT(*) FROM `User` WHERE `force_active` = 1');
+
+ if (empty($result)) {
+ return 0;
+ }
+
+ return (int)array_shift($result);
}
-function User_active_count() {
- return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1");
+/**
+ * @return int
+ */
+function User_active_count()
+{
+ $result = DB::selectOne('SELECT COUNT(*) FROM `User` WHERE `Aktiv` = 1');
+
+ if (empty($result)) {
+ return 0;
+ }
+
+ return (int)array_shift($result);
}
-function User_got_voucher_count() {
- return sql_select_single_cell("SELECT SUM(`got_voucher`) FROM `User`");
+/**
+ * @return int
+ */
+function User_got_voucher_count()
+{
+ $result = DB::selectOne('SELECT SUM(`got_voucher`) FROM `User`');
+
+ if (empty($result)) {
+ return 0;
+ }
+
+ return (int)array_shift($result);
}
-function User_arrived_count() {
- return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1");
+/**
+ * @return int
+ */
+function User_arrived_count()
+{
+ $result = DB::selectOne('SELECT COUNT(*) FROM `User` WHERE `Gekommen` = 1');
+
+ if (empty($result)) {
+ return 0;
+ }
+
+ return (int)array_shift($result);
}
-function User_tshirts_count() {
- return sql_select_single_cell("SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1");
+/**
+ * @return int
+ */
+function User_tshirts_count()
+{
+ $result = DB::selectOne('SELECT COUNT(*) FROM `User` WHERE `Tshirt` = 1');
+
+ if (empty($result)) {
+ return 0;
+ }
+
+ return (int)array_shift($result);
}
/**
* Returns all column names for sorting in an array.
+ *
+ * @return array
*/
-function User_sortable_columns() {
- return [
- 'Nick',
- 'Name',
- 'Vorname',
- 'Alter',
- 'DECT',
- 'email',
- 'Size',
- 'Gekommen',
- 'Aktiv',
- 'force_active',
- 'Tshirt',
- 'lastLogIn'
- ];
+function User_sortable_columns()
+{
+ return [
+ 'Nick',
+ 'Name',
+ 'Vorname',
+ 'Alter',
+ 'DECT',
+ 'email',
+ 'Size',
+ 'Gekommen',
+ 'Aktiv',
+ 'force_active',
+ 'Tshirt',
+ 'lastLogIn'
+ ];
}
/**
* Get all users, ordered by Nick by default or by given param.
*
- * @param string $order_by
+ * @param string $order_by
+ * @return array
*/
-function Users($order_by = 'Nick') {
- return sql_select("SELECT * FROM `User` ORDER BY `" . sql_escape($order_by) . "` ASC");
+function Users($order_by = 'Nick')
+{
+ return DB::select(sprintf('
+ SELECT *
+ FROM `User`
+ ORDER BY `%s` ASC
+ ',
+ trim(DB::getPdo()->quote($order_by), '\'')
+ ));
}
/**
* Returns true if user is freeloader
*
- * @param User $user
+ * @param array $user
+ * @return bool
*/
-function User_is_freeloader($user) {
- global $max_freeloadable_shifts, $user;
-
- return count(ShiftEntries_freeloaded_by_user($user)) >= $max_freeloadable_shifts;
+function User_is_freeloader($user)
+{
+ global $user;
+
+ return count(ShiftEntries_freeloaded_by_user($user)) >= config('max_freeloadable_shifts');
}
/**
* Returns all users that are not member of given angeltype.
*
- * @param Angeltype $angeltype
+ * @param array $angeltype Angeltype
+ * @return array
*/
-function Users_by_angeltype_inverted($angeltype) {
- $result = sql_select("
- SELECT `User`.*
- FROM `User`
- LEFT JOIN `UserAngelTypes` ON (`User`.`UID`=`UserAngelTypes`.`user_id` AND `angeltype_id`='" . sql_escape($angeltype['id']) . "')
- WHERE `UserAngelTypes`.`id` IS NULL
- ORDER BY `Nick`");
- if ($result === false) {
- engelsystem_error("Unable to load users.");
- }
- return $result;
+function Users_by_angeltype_inverted($angeltype)
+{
+ return DB::select('
+ SELECT `User`.*
+ FROM `User`
+ LEFT JOIN `UserAngelTypes`
+ ON (`User`.`UID`=`UserAngelTypes`.`user_id` AND `angeltype_id`=?)
+ WHERE `UserAngelTypes`.`id` IS NULL
+ ORDER BY `Nick`
+ ',
+ [
+ $angeltype['id']
+ ]
+ );
}
/**
* Returns all members of given angeltype.
*
- * @param Angeltype $angeltype
+ * @param array $angeltype
+ * @return array
*/
-function Users_by_angeltype($angeltype) {
- $result = sql_select("
- SELECT
- `User`.*,
- `UserAngelTypes`.`id` as `user_angeltype_id`,
- `UserAngelTypes`.`confirm_user_id`,
- `UserAngelTypes`.`supporter`,
- `UserDriverLicenses`.*
- FROM `User`
- JOIN `UserAngelTypes` ON `User`.`UID`=`UserAngelTypes`.`user_id`
- LEFT JOIN `UserDriverLicenses` ON `User`.`UID`=`UserDriverLicenses`.`user_id`
- WHERE `UserAngelTypes`.`angeltype_id`='" . sql_escape($angeltype['id']) . "'
- ORDER BY `Nick`");
- if ($result === false) {
- engelsystem_error("Unable to load members.");
- }
- return $result;
+function Users_by_angeltype($angeltype)
+{
+ return DB::select('
+ SELECT
+ `User`.*,
+ `UserAngelTypes`.`id` AS `user_angeltype_id`,
+ `UserAngelTypes`.`confirm_user_id`,
+ `UserAngelTypes`.`supporter`,
+ (`UserDriverLicenses`.`user_id` IS NOT NULL) AS `wants_to_drive`,
+ `UserDriverLicenses`.*
+ FROM `User`
+ JOIN `UserAngelTypes` ON `User`.`UID`=`UserAngelTypes`.`user_id`
+ LEFT JOIN `UserDriverLicenses` ON `User`.`UID`=`UserDriverLicenses`.`user_id`
+ WHERE `UserAngelTypes`.`angeltype_id`=?
+ ORDER BY `Nick`
+ ',
+ [
+ $angeltype['id']
+ ]
+ );
}
/**
* Returns User id array
+ *
+ * @return array
*/
-function User_ids() {
- return sql_select("SELECT `UID` FROM `User`");
+function User_ids()
+{
+ return DB::select('SELECT `UID` FROM `User`');
}
/**
* Strip unwanted characters from a users nick.
*
- * @param string $nick
+ * @param string $nick
+ * @return string
*/
-function User_validate_Nick($nick) {
- return preg_replace("/([^a-z0-9üöäß. _+*-]{1,})/ui", '', $nick);
+function User_validate_Nick($nick)
+{
+ return preg_replace('/([^\wüöäß. +*-]{1,})/ui', '', $nick);
}
/**
@@ -175,9 +283,10 @@ function User_validate_Nick($nick) {
* The email address to validate
* @return ValidationResult
*/
-function User_validate_mail($mail) {
- $mail = strip_item($mail);
- return new ValidationResult(check_email($mail), $mail);
+function User_validate_mail($mail)
+{
+ $mail = strip_item($mail);
+ return new ValidationResult(check_email($mail), $mail);
}
/**
@@ -187,41 +296,42 @@ function User_validate_mail($mail) {
* Jabber-ID to validate
* @return ValidationResult
*/
-function User_validate_jabber($jabber) {
- $jabber = strip_item($jabber);
- if ($jabber == '') {
- // Empty is ok
- return new ValidationResult(true, '');
- }
- return new ValidationResult(check_email($jabber), $jabber);
+function User_validate_jabber($jabber)
+{
+ $jabber = strip_item($jabber);
+ if ($jabber == '') {
+ // Empty is ok
+ return new ValidationResult(true, '');
+ }
+ return new ValidationResult(check_email($jabber), $jabber);
}
/**
* Validate the planned arrival date
*
- * @param int $planned_arrival_date
- * Unix timestamp
+ * @param int $planned_arrival_date Unix timestamp
* @return ValidationResult
*/
-function User_validate_planned_arrival_date($planned_arrival_date) {
- if ($planned_arrival_date == null) {
- // null is not okay
- return new ValidationResult(false, time());
- }
- $event_config = EventConfig();
- if ($event_config == null) {
- // Nothing to validate against
+function User_validate_planned_arrival_date($planned_arrival_date)
+{
+ if ($planned_arrival_date == null) {
+ // null is not okay
+ return new ValidationResult(false, time());
+ }
+ $event_config = EventConfig();
+ if ($event_config == null) {
+ // Nothing to validate against
+ return new ValidationResult(true, $planned_arrival_date);
+ }
+ if (isset($event_config['buildup_start_date']) && $planned_arrival_date < $event_config['buildup_start_date']) {
+ // Planned arrival can not be before buildup start date
+ return new ValidationResult(false, $event_config['buildup_start_date']);
+ }
+ if (isset($event_config['teardown_end_date']) && $planned_arrival_date > $event_config['teardown_end_date']) {
+ // Planned arrival can not be after teardown end date
+ return new ValidationResult(false, $event_config['teardown_end_date']);
+ }
return new ValidationResult(true, $planned_arrival_date);
- }
- if (isset($event_config['buildup_start_date']) && $planned_arrival_date < $event_config['buildup_start_date']) {
- // Planned arrival can not be before buildup start date
- return new ValidationResult(false, $event_config['buildup_start_date']);
- }
- if (isset($event_config['teardown_end_date']) && $planned_arrival_date > $event_config['teardown_end_date']) {
- // Planned arrival can not be after teardown end date
- return new ValidationResult(false, $event_config['teardown_end_date']);
- }
- return new ValidationResult(true, $planned_arrival_date);
}
/**
@@ -233,45 +343,41 @@ function User_validate_planned_arrival_date($planned_arrival_date) {
* Unix timestamp
* @return ValidationResult
*/
-function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date) {
- if ($planned_departure_date == null) {
- // null is okay
- return new ValidationResult(true, null);
- }
- if ($planned_arrival_date > $planned_departure_date) {
- // departure cannot be before arrival
- return new ValidationResult(false, $planned_arrival_date);
- }
- $event_config = EventConfig();
- if ($event_config == null) {
- // Nothing to validate against
+function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date)
+{
+ if ($planned_departure_date == null) {
+ // null is okay
+ return new ValidationResult(true, null);
+ }
+ if ($planned_arrival_date > $planned_departure_date) {
+ // departure cannot be before arrival
+ return new ValidationResult(false, $planned_arrival_date);
+ }
+ $event_config = EventConfig();
+ if ($event_config == null) {
+ // Nothing to validate against
+ return new ValidationResult(true, $planned_departure_date);
+ }
+ if (isset($event_config['buildup_start_date']) && $planned_departure_date < $event_config['buildup_start_date']) {
+ // Planned arrival can not be before buildup start date
+ return new ValidationResult(false, $event_config['buildup_start_date']);
+ }
+ if (isset($event_config['teardown_end_date']) && $planned_departure_date > $event_config['teardown_end_date']) {
+ // Planned arrival can not be after teardown end date
+ return new ValidationResult(false, $event_config['teardown_end_date']);
+ }
return new ValidationResult(true, $planned_departure_date);
- }
- if (isset($event_config['buildup_start_date']) && $planned_departure_date < $event_config['buildup_start_date']) {
- // Planned arrival can not be before buildup start date
- return new ValidationResult(false, $event_config['buildup_start_date']);
- }
- if (isset($event_config['teardown_end_date']) && $planned_departure_date > $event_config['teardown_end_date']) {
- // Planned arrival can not be after teardown end date
- return new ValidationResult(false, $event_config['teardown_end_date']);
- }
- return new ValidationResult(true, $planned_departure_date);
}
/**
* Returns user by id.
*
- * @param $user_id UID
+ * @param int $user_id UID
+ * @return array|null
*/
-function User($user_id) {
- $user_source = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
- if ($user_source === false) {
- engelsystem_error("Unable to load user.");
- }
- if (count($user_source) > 0) {
- return $user_source[0];
- }
- return null;
+function User($user_id)
+{
+ return DB::selectOne('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$user_id]);
}
/**
@@ -279,96 +385,99 @@ function User($user_id) {
*
* @param string $api_key
* User api key
- * @return Matching user, null or false on error
+ * @return array|null Matching user, null if not found
*/
-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) {
- engelsystem_error("Unable to find user by api key.");
- }
- if (count($user) == 0) {
- return null;
- }
- return $user[0];
+function User_by_api_key($api_key)
+{
+ return DB::selectOne('SELECT * FROM `User` WHERE `api_key`=? LIMIT 1', [$api_key]);
}
/**
* Returns User by email.
*
- * @param string $email
- * @return Matching user, null or false on error
+ * @param string $email
+ * @return array|null Matching user, null or false on error
*/
-function User_by_email($email) {
- $user = sql_select("SELECT * FROM `User` WHERE `email`='" . sql_escape($email) . "' LIMIT 1");
- if ($user === false) {
- engelsystem_error("Unable to load user.");
- }
- if (count($user) == 0) {
- return null;
- }
- return $user[0];
+function User_by_email($email)
+{
+ return DB::selectOne('SELECT * FROM `User` WHERE `email`=? LIMIT 1', [$email]);
}
/**
* Returns User by password token.
*
- * @param string $token
- * @return Matching user, null or false on error
+ * @param string $token
+ * @return array|null Matching user, null when not found
*/
-function User_by_password_recovery_token($token) {
- $user = sql_select("SELECT * FROM `User` WHERE `password_recovery_token`='" . sql_escape($token) . "' LIMIT 1");
- if ($user === false) {
- engelsystem_error("Unable to load user.");
- }
- if (count($user) == 0) {
- return null;
- }
- return $user[0];
+function User_by_password_recovery_token($token)
+{
+ return DB::selectOne('SELECT * FROM `User` WHERE `password_recovery_token`=? LIMIT 1', [$token]);
}
/**
* Generates a new api key for given user.
*
- * @param User $user
+ * @param array $user
+ * @param bool $log
*/
-function User_reset_api_key(&$user, $log = true) {
- $user['api_key'] = md5($user['Nick'] . time() . rand());
- $result = sql_query("UPDATE `User` SET `api_key`='" . sql_escape($user['api_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
- if ($result === false) {
- return false;
- }
- if ($log) {
- engelsystem_log(sprintf("API key resetted (%s).", User_Nick_render($user)));
- }
+function User_reset_api_key(&$user, $log = true)
+{
+ $user['api_key'] = md5($user['Nick'] . time() . rand());
+ DB::update('
+ UPDATE `User`
+ SET `api_key`=?
+ WHERE `UID`=?
+ LIMIT 1
+ ',
+ [
+ $user['api_key'],
+ $user['UID']
+ ]
+ );
+
+ if ($log) {
+ engelsystem_log(sprintf('API key resetted (%s).', User_Nick_render($user)));
+ }
}
/**
* Generates a new password recovery token for given user.
*
- * @param User $user
+ * @param array $user
+ * @return string
*/
-function User_generate_password_recovery_token(&$user) {
- $user['password_recovery_token'] = md5($user['Nick'] . time() . rand());
- $result = sql_query("UPDATE `User` SET `password_recovery_token`='" . sql_escape($user['password_recovery_token']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
- if ($result === false) {
- engelsystem_error("Unable to generate password recovery token.");
- }
- engelsystem_log("Password recovery for " . User_Nick_render($user) . " started.");
- return $user['password_recovery_token'];
+function User_generate_password_recovery_token(&$user)
+{
+ $user['password_recovery_token'] = md5($user['Nick'] . time() . rand());
+ DB::update('
+ UPDATE `User`
+ SET `password_recovery_token`=?
+ WHERE `UID`=?
+ LIMIT 1
+ ',
+ [
+ $user['password_recovery_token'],
+ $user['UID'],
+ ]
+ );
+ engelsystem_log('Password recovery for ' . User_Nick_render($user) . ' started.');
+ return $user['password_recovery_token'];
}
-function User_get_eligable_voucher_count(&$user) {
- global $voucher_settings;
-
- $shifts_done = count(ShiftEntries_finished_by_user($user));
-
- $earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers'];
- $elegible_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
- if ($elegible_vouchers < 0) {
- return 0;
- }
-
- return $elegible_vouchers;
-}
+/**
+ * @param array $user
+ * @return float
+ */
+function User_get_eligable_voucher_count(&$user)
+{
+ $voucher_settings = config('voucher_settings');
+ $shifts_done = count(ShiftEntries_finished_by_user($user));
+
+ $earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers'];
+ $elegible_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
+ if ($elegible_vouchers < 0) {
+ return 0;
+ }
-?>
+ return $elegible_vouchers;
+}
diff --git a/includes/model/ValidationResult.php b/includes/model/ValidationResult.php
index 0fc24161..7f88b432 100644
--- a/includes/model/ValidationResult.php
+++ b/includes/model/ValidationResult.php
@@ -6,37 +6,41 @@ 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 {
+class ValidationResult
+{
+ /** @var bool */
+ private $valid;
- private $valid;
+ /** @var mixed */
+ private $value;
- private $value;
+ /**
+ * @param boolean $valid Is the value valid?
+ * @param mixed $value The validated value
+ */
+ public function __construct($valid, $value)
+ {
+ $this->valid = $valid;
+ $this->value = $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?
+ *
+ * @return bool
+ */
+ public function isValid()
+ {
+ return $this->valid;
+ }
- /**
- * Is the value valid?
- */
- public function isValid() {
- return $this->valid;
- }
-
- /**
- * The parsed/validated value.
- */
- public function getValue() {
- return $this->value;
- }
+ /**
+ * The parsed/validated value.
+ *
+ * @return mixed
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
}
-?> \ No newline at end of file
diff --git a/includes/mysqli_provider.php b/includes/mysqli_provider.php
deleted file mode 100644
index c81f157f..00000000
--- a/includes/mysqli_provider.php
+++ /dev/null
@@ -1,216 +0,0 @@
-<?php
-
-/**
- * Close connection.
- */
-function sql_close() {
- global $sql_connection;
-
- return $sql_connection->close();
-}
-
-/**
- * Return NULL if given value is null.
- */
-function sql_null($value = null) {
- return $value == null ? 'NULL' : ("'" . sql_escape($value) . "'");
-}
-
-/**
- * Start new transaction.
- */
-function sql_transaction_start() {
- global $sql_nested_transaction_level;
-
- if ($sql_nested_transaction_level ++ == 0) {
- return sql_query("BEGIN");
- }
-
- return true;
-}
-
-/**
- * Commit transaction.
- */
-function sql_transaction_commit() {
- global $sql_nested_transaction_level;
-
- if (-- $sql_nested_transaction_level == 0) {
- return sql_query("COMMIT");
- }
-
- return true;
-}
-
-/**
- * Stop transaction, revert database.
- */
-function sql_transaction_rollback() {
- global $sql_nested_transaction_level;
-
- if (-- $sql_nested_transaction_level == 0) {
- return sql_query("ROLLBACK");
- }
-
- return true;
-}
-
-/**
- * Logs an sql error.
- *
- * @param string $message
- * @return false
- */
-function sql_error($message) {
- sql_close();
-
- $message = trim($message) . "\n";
- $message .= debug_string_backtrace() . "\n";
-
- error_log('mysql_provider error: ' . $message);
-
- return false;
-}
-
-/**
- * Connect to mysql server.
- *
- * @param string $host
- * Host
- * @param string $user
- * Username
- * @param string $pass
- * Password
- * @param string $db_name
- * DB to select
- * @return mysqli The connection handler
- */
-function sql_connect($host, $user, $pass, $db_name) {
- global $sql_connection;
-
- $sql_connection = new mysqli($host, $user, $pass, $db_name);
- if ($sql_connection->connect_errno) {
- error("Unable to connect to MySQL: " . $sql_connection->connect_error);
- return sql_error("Unable to connect to MySQL: " . $sql_connection->connect_error);
- }
-
- $result = $sql_connection->query("SET CHARACTER SET utf8;");
- if (! $result) {
- return sql_error("Unable to set utf8 character set (" . $sql_connection->errno . ") " . $sql_connection->error);
- }
-
- $result = $sql_connection->set_charset('utf8');
- if (! $result) {
- return sql_error("Unable to set utf8 names (" . $sql_connection->errno . ") " . $sql_connection->error);
- }
-
- return $sql_connection;
-}
-
-/**
- * Change the selected db in current mysql-connection.
- *
- * @param
- * $db_name
- * @return bool true on success, false on error
- */
-function sql_select_db($db_name) {
- global $sql_connection;
- if (! $sql_connection->select_db($db_name)) {
- return sql_error("No database selected.");
- }
- return true;
-}
-
-/**
- * MySQL SELECT query
- *
- * @param string $query
- * @return Result array or false on error
- */
-function sql_select($query) {
- global $sql_connection;
-
-// echo $query . ";\n";
-// echo debug_string_backtrace() . "\n";
-
- $result = $sql_connection->query($query);
- if ($result) {
- $data = [];
- while ($line = $result->fetch_assoc()) {
- array_push($data, $line);
- }
- return $data;
- }
-
- return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
-}
-
-/**
- * MySQL execute a query
- *
- * @param string $query
- * @return mysqli_result boolean resource or false on error
- */
-function sql_query($query) {
- global $sql_connection;
-
- $result = $sql_connection->query($query);
- if ($result) {
- return $result;
- }
-
- return sql_error("MySQL-query error: " . $query . " (" . $sql_connection->errno . ") " . $sql_connection->error);
-}
-
-/**
- * Returns last inserted id.
- *
- * @return int
- */
-function sql_id() {
- global $sql_connection;
- return $sql_connection->insert_id;
-}
-
-/**
- * Escape a string for a sql query.
- *
- * @param string $query
- * @return string
- */
-function sql_escape($query) {
- global $sql_connection;
- return $sql_connection->real_escape_string($query);
-}
-
-/**
- * Convert a boolean for mysql-queries.
- *
- * @param boolean $boolean
- * @return string
- */
-function sql_bool($boolean) {
- return $boolean == true ? 'TRUE' : 'FALSE';
-}
-
-/**
- * Count query result lines.
- *
- * @param string $query
- * @return int Count of result lines
- */
-function sql_num_query($query) {
- return sql_query($query)->num_rows;
-}
-
-function sql_select_single_col($query) {
- $result = sql_select($query);
- return array_map('array_shift', $result);
-}
-
-function sql_select_single_cell($query) {
- return array_shift(array_shift(sql_select($query)));
-}
-
-?>
diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php
index a1e31b11..0612202f 100644
--- a/includes/pages/admin_active.php
+++ b/includes/pages/admin_active.php
@@ -1,202 +1,292 @@
<?php
-function admin_active_title() {
- return _("Active angels");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_active_title()
+{
+ return _('Active angels');
}
-function admin_active() {
- global $tshirt_sizes, $shift_sum_formula;
-
- $msg = "";
- $search = "";
- $forced_count = sql_num_query("SELECT * FROM `User` WHERE `force_active`=1");
- $count = $forced_count;
- $limit = "";
- $set_active = "";
-
- if (isset($_REQUEST['search'])) {
- $search = strip_request_item('search');
- }
-
- $show_all_shifts = isset($_REQUEST['show_all_shifts']);
-
- if (isset($_REQUEST['set_active'])) {
- $valid = true;
-
- if (isset($_REQUEST['count']) && preg_match("/^[0-9]+$/", $_REQUEST['count'])) {
- $count = strip_request_item('count');
- if ($count < $forced_count) {
- error(sprintf(_("At least %s angels are forced to be active. The number has to be greater."), $forced_count));
- redirect(page_link_to('admin_active'));
- }
- } else {
- $valid = false;
- $msg .= error(_("Please enter a number of angels to be marked as active."), true);
- }
-
- if ($valid) {
- $limit = " LIMIT " . $count;
- }
- if (isset($_REQUEST['ack'])) {
- sql_query("UPDATE `User` SET `Aktiv` = 0 WHERE `Tshirt` = 0");
- $users = sql_select("
- SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, $shift_sum_formula as `shift_length`
- FROM `User`
- LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
- LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID`
- WHERE `User`.`Gekommen` = 1 AND `User`.`force_active`=0
- GROUP BY `User`.`UID`
- ORDER BY `force_active` DESC, `shift_length` DESC" . $limit);
- $user_nicks = [];
- foreach ($users as $usr) {
- sql_query("UPDATE `User` SET `Aktiv` = 1 WHERE `UID`='" . sql_escape($usr['UID']) . "'");
- $user_nicks[] = User_Nick_render($usr);
- }
- sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `force_active`=TRUE");
- engelsystem_log("These angels are active now: " . join(", ", $user_nicks));
-
- $limit = "";
- $msg = success(_("Marked angels."), true);
- } else {
- $set_active = '<a href="' . page_link_to('admin_active') . '&amp;serach=' . $search . '">&laquo; ' . _("back") . '</a> | <a href="' . page_link_to('admin_active') . '&amp;search=' . $search . '&amp;count=' . $count . '&amp;set_active&amp;ack">' . _("apply") . '</a>';
- }
- }
-
- if (isset($_REQUEST['active']) && preg_match("/^[0-9]+$/", $_REQUEST['active'])) {
- $user_id = $_REQUEST['active'];
- $user_source = User($user_id);
- if ($user_source != null) {
- sql_query("UPDATE `User` SET `Aktiv`=1 WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
- engelsystem_log("User " . User_Nick_render($user_source) . " is active now.");
- $msg = success(_("Angel has been marked as active."), true);
- } else {
- $msg = error(_("Angel not found."), true);
+/**
+ * @return string
+ */
+function admin_active()
+{
+ $tshirt_sizes = config('tshirt_sizes');
+ $shift_sum_formula = config('shift_sum_formula');
+ $request = request();
+
+ $msg = '';
+ $search = '';
+ $forced_count = count(DB::select('SELECT `UID` FROM `User` WHERE `force_active`=1'));
+ $count = $forced_count;
+ $limit = '';
+ $set_active = '';
+
+ if ($request->has('search')) {
+ $search = strip_request_item('search');
}
- } elseif (isset($_REQUEST['not_active']) && preg_match("/^[0-9]+$/", $_REQUEST['not_active'])) {
- $user_id = $_REQUEST['not_active'];
- $user_source = User($user_id);
- if ($user_source != null) {
- sql_query("UPDATE `User` SET `Aktiv`=0 WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
- engelsystem_log("User " . User_Nick_render($user_source) . " is NOT active now.");
- $msg = success(_("Angel has been marked as not active."), true);
- } else {
- $msg = error(_("Angel not found."), true);
+
+ $show_all_shifts = $request->has('show_all_shifts');
+
+ if ($request->has('set_active')) {
+ $valid = true;
+
+ if ($request->has('count') && preg_match('/^\d+$/', $request->input('count'))) {
+ $count = strip_request_item('count');
+ if ($count < $forced_count) {
+ error(sprintf(
+ _('At least %s angels are forced to be active. The number has to be greater.'),
+ $forced_count
+ ));
+ redirect(page_link_to('admin_active'));
+ }
+ } else {
+ $valid = false;
+ $msg .= error(_('Please enter a number of angels to be marked as active.'), true);
+ }
+
+ if ($valid) {
+ $limit = ' LIMIT ' . $count;
+ }
+ if ($request->has('ack')) {
+ DB::update('UPDATE `User` SET `Aktiv` = 0 WHERE `Tshirt` = 0');
+ $users = DB::select(sprintf('
+ SELECT
+ `User`.*,
+ COUNT(`ShiftEntry`.`id`) AS `shift_count`,
+ %s AS `shift_length`
+ FROM `User`
+ LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
+ LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID`
+ WHERE `User`.`Gekommen` = 1
+ AND `User`.`force_active`=0
+ GROUP BY `User`.`UID`
+ ORDER BY `force_active` DESC, `shift_length` DESC
+ %s
+ ',
+ $shift_sum_formula,
+ $limit
+ ));
+ $user_nicks = [];
+ foreach ($users as $usr) {
+ DB::update('UPDATE `User` SET `Aktiv` = 1 WHERE `UID`=?', [$usr['UID']]);
+ $user_nicks[] = User_Nick_render($usr);
+ }
+ DB::update('UPDATE `User` SET `Aktiv`=1 WHERE `force_active`=TRUE');
+ engelsystem_log('These angels are active now: ' . join(', ', $user_nicks));
+
+ $limit = '';
+ $msg = success(_('Marked angels.'), true);
+ } else {
+ $set_active = '<a href="' . page_link_to('admin_active', ['search' => $search]) . '">&laquo; '
+ . _('back')
+ . '</a> | <a href="'
+ . page_link_to(
+ 'admin_active',
+ ['search' => $search, 'count' => $count, 'set_active' => 1, 'ack' => 1]
+ ) . '">'
+ . _('apply')
+ . '</a>';
+ }
}
- } elseif (isset($_REQUEST['tshirt']) && preg_match("/^[0-9]+$/", $_REQUEST['tshirt'])) {
- $user_id = $_REQUEST['tshirt'];
- $user_source = User($user_id);
- if ($user_source != null) {
- sql_query("UPDATE `User` SET `Tshirt`=1 WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
- engelsystem_log("User " . User_Nick_render($user_source) . " has tshirt now.");
- $msg = success(_("Angel has got a t-shirt."), true);
- } else {
- $msg = error("Angel not found.", true);
+
+ if ($request->has('active') && preg_match('/^\d+$/', $request->input('active'))) {
+ $user_id = $request->input('active');
+ $user_source = User($user_id);
+ if ($user_source != null) {
+ DB::update('UPDATE `User` SET `Aktiv`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
+ engelsystem_log('User ' . User_Nick_render($user_source) . ' is active now.');
+ $msg = success(_('Angel has been marked as active.'), true);
+ } else {
+ $msg = error(_('Angel not found.'), true);
+ }
+ } elseif ($request->has('not_active') && preg_match('/^\d+$/', $request->input('not_active'))) {
+ $user_id = $request->input('not_active');
+ $user_source = User($user_id);
+ if ($user_source != null) {
+ DB::update('UPDATE `User` SET `Aktiv`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
+ engelsystem_log('User ' . User_Nick_render($user_source) . ' is NOT active now.');
+ $msg = success(_('Angel has been marked as not active.'), true);
+ } else {
+ $msg = error(_('Angel not found.'), true);
+ }
+ } elseif ($request->has('tshirt') && preg_match('/^\d+$/', $request->input('tshirt'))) {
+ $user_id = $request->input('tshirt');
+ $user_source = User($user_id);
+ if ($user_source != null) {
+ DB::update('UPDATE `User` SET `Tshirt`=1 WHERE `UID`=? LIMIT 1', [$user_id]);
+ engelsystem_log('User ' . User_Nick_render($user_source) . ' has tshirt now.');
+ $msg = success(_('Angel has got a t-shirt.'), true);
+ } else {
+ $msg = error('Angel not found.', true);
+ }
+ } elseif ($request->has('not_tshirt') && preg_match('/^\d+$/', $request->input('not_tshirt'))) {
+ $user_id = $request->input('not_tshirt');
+ $user_source = User($user_id);
+ if ($user_source != null) {
+ DB::update('UPDATE `User` SET `Tshirt`=0 WHERE `UID`=? LIMIT 1', [$user_id]);
+ engelsystem_log('User ' . User_Nick_render($user_source) . ' has NO tshirt.');
+ $msg = success(_('Angel has got no t-shirt.'), true);
+ } else {
+ $msg = error(_('Angel not found.'), true);
+ }
}
- } elseif (isset($_REQUEST['not_tshirt']) && preg_match("/^[0-9]+$/", $_REQUEST['not_tshirt'])) {
- $user_id = $_REQUEST['not_tshirt'];
- $user_source = User($user_id);
- if ($user_source != null) {
- sql_query("UPDATE `User` SET `Tshirt`=0 WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
- engelsystem_log("User " . User_Nick_render($user_source) . " has NO tshirt.");
- $msg = success(_("Angel has got no t-shirt."), true);
+
+ $users = DB::select(sprintf('
+ SELECT
+ `User`.*,
+ COUNT(`ShiftEntry`.`id`) AS `shift_count`,
+ %s AS `shift_length`
+ FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
+ LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` '
+ . ($show_all_shifts ? '' : 'AND (`Shifts`.`end` < ' . time() . " OR `Shifts`.`end` IS NULL)") . '
+ WHERE `User`.`Gekommen` = 1
+ GROUP BY `User`.`UID`
+ ORDER BY `force_active` DESC, `shift_length` DESC
+ %s
+ ',
+ $shift_sum_formula,
+ $limit
+ ));
+ $matched_users = [];
+ if ($search == '') {
+ $tokens = [];
} else {
- $msg = error(_("Angel not found."), true);
+ $tokens = explode(' ', $search);
}
- }
-
- $users = sql_select("
- SELECT `User`.*, COUNT(`ShiftEntry`.`id`) as `shift_count`, ${shift_sum_formula} as `shift_length`
- FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
- LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` " . ($show_all_shifts ? "" : "AND (`Shifts`.`end` < " . time() . " OR `Shifts`.`end` IS NULL)") . "
- WHERE `User`.`Gekommen` = 1
- GROUP BY `User`.`UID`
- ORDER BY `force_active` DESC, `shift_length` DESC" . $limit);
- $matched_users = [];
- if ($search == "") {
- $tokens = [];
- } else {
- $tokens = explode(" ", $search);
- }
- foreach ($users as &$usr) {
- if (count($tokens) > 0) {
- $match = false;
- foreach ($tokens as $t) {
- if (stristr($usr['Nick'], trim($t))) {
- $match = true;
- break;
+ foreach ($users as &$usr) {
+ if (count($tokens) > 0) {
+ $match = false;
+ foreach ($tokens as $t) {
+ if (stristr($usr['Nick'], trim($t))) {
+ $match = true;
+ break;
+ }
+ }
+ if (!$match) {
+ continue;
+ }
}
- }
- if (! $match) {
- continue;
- }
- }
- $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['active'] = glyph_bool($usr['Aktiv'] == 1);
- $usr['force_active'] = glyph_bool($usr['force_active'] == 1);
- $usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1);
-
- $actions = [];
- if ($usr['Aktiv'] == 0) {
- $actions[] = '<a href="' . page_link_to('admin_active') . '&amp;active=' . $usr['UID'] . ($show_all_shifts ? '&amp;show_all_shifts=' : '') . '&amp;search=' . $search . '">' . _("set active") . '</a>';
- }
- if ($usr['Aktiv'] == 1 && $usr['Tshirt'] == 0) {
- $actions[] = '<a href="' . page_link_to('admin_active') . '&amp;not_active=' . $usr['UID'] . ($show_all_shifts ? '&amp;show_all_shifts=' : '') . '&amp;search=' . $search . '">' . _("remove active") . '</a>';
- $actions[] = '<a href="' . page_link_to('admin_active') . '&amp;tshirt=' . $usr['UID'] . ($show_all_shifts ? '&amp;show_all_shifts=' : '') . '&amp;search=' . $search . '">' . _("got t-shirt") . '</a>';
- }
- if ($usr['Tshirt'] == 1) {
- $actions[] = '<a href="' . page_link_to('admin_active') . '&amp;not_tshirt=' . $usr['UID'] . ($show_all_shifts ? '&amp;show_all_shifts=' : '') . '&amp;search=' . $search . '">' . _("remove t-shirt") . '</a>';
+ $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['active'] = glyph_bool($usr['Aktiv'] == 1);
+ $usr['force_active'] = glyph_bool($usr['force_active'] == 1);
+ $usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1);
+
+ $actions = [];
+ if ($usr['Aktiv'] == 0) {
+ $parameters = [
+ 'active' => $usr['UID'],
+ 'search' => $search,
+ ];
+ if ($show_all_shifts) {
+ $parameters['show_all_shifts'] = 1;
+ }
+ $actions[] = '<a href="' . page_link_to('admin_active', $parameters) . '">'
+ . _('set active')
+ . '</a>';
+ }
+ if ($usr['Aktiv'] == 1 && $usr['Tshirt'] == 0) {
+ $parametersRemove = [
+ 'not_active' => $usr['UID'],
+ 'search' => $search,
+ ];
+ $parametersShirt = [
+ 'tshirt' => $usr['UID'],
+ 'search' => $search,
+ ];
+ if ($show_all_shifts) {
+ $parametersRemove['show_all_shifts'] = 1;
+ $parametersShirt['show_all_shifts'] = 1;
+ }
+ $actions[] = '<a href="' . page_link_to('admin_active', $parametersRemove) . '">'
+ . _('remove active')
+ . '</a>';
+ $actions[] = '<a href="' . page_link_to('admin_active', $parametersShirt) . '">'
+ . _('got t-shirt')
+ . '</a>';
+ }
+ if ($usr['Tshirt'] == 1) {
+ $parameters = [
+ 'not_tshirt' => $usr['UID'],
+ 'search' => $search,
+ ];
+ if ($show_all_shifts) {
+ $parameters['show_all_shifts'] = 1;
+ }
+ $actions[] = '<a href="' . page_link_to('admin_active', $parameters) . '">'
+ . _('remove t-shirt')
+ . '</a>';
+ }
+
+ $usr['actions'] = join(' ', $actions);
+
+ $matched_users[] = $usr;
}
-
- $usr['actions'] = join(' ', $actions);
-
- $matched_users[] = $usr;
- }
-
- $shirt_statistics = [];
- foreach (array_keys($tshirt_sizes) as $size) {
- if ($size != '') {
- $shirt_statistics[] = [
- 'size' => $size,
- 'needed' => sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Size`='" . sql_escape($size) . "' AND `Gekommen`=1"),
- 'given' => sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Size`='" . sql_escape($size) . "' AND `Tshirt`=1")
- ];
+
+ $shirt_statistics = [];
+ foreach (array_keys($tshirt_sizes) as $size) {
+ if (!empty($size)) {
+ $sc = DB::selectOne(
+ 'SELECT count(*) FROM `User` WHERE `Size`=? AND `Gekommen`=1',
+ [$size]
+ );
+ $sc = array_shift($sc);
+
+ $gc = DB::selectOne(
+ 'SELECT count(*) FROM `User` WHERE `Size`=? AND `Tshirt`=1',
+ [$size]
+ );
+ $gc = array_shift($gc);
+
+ $shirt_statistics[] = [
+ 'size' => $size,
+ 'needed' => (int)$sc,
+ 'given' => (int)$gc
+ ];
+ }
}
- }
- $shirt_statistics[] = [
- 'size' => '<b>' . _("Sum") . '</b>',
- 'needed' => '<b>' . User_arrived_count() . '</b>',
- 'given' => '<b>' . sql_select_single_cell("SELECT count(*) FROM `User` WHERE `Tshirt`=1") . '</b>'
- ];
-
- return page_with_title(admin_active_title(), [
- form([
- form_text('search', _("Search angel:"), $search),
- form_checkbox('show_all_shifts', _("Show all shifts"), $show_all_shifts),
- form_submit('submit', _("Search"))
- ], page_link_to('admin_active')),
- $set_active == "" ? form([
- form_text('count', _("How much angels should be active?"), $count),
- form_submit('set_active', _("Preview"))
- ]) : $set_active,
- msg(),
- table([
- 'nick' => _("Nickname"),
- 'shirt_size' => _("Size"),
- 'shift_count' => _("Shifts"),
- 'work_time' => _("Length"),
- 'active' => _("Active?"),
- 'force_active' => _("Forced"),
- 'tshirt' => _("T-shirt?"),
- 'actions' => ""
- ], $matched_users),
- '<h2>' . _("Shirt statistics") . '</h2>',
- table([
- 'size' => _("Size"),
- 'needed' => _("Needed shirts"),
- 'given' => _("Given shirts")
- ], $shirt_statistics)
- ]);
+
+ $shirtCount = DB::selectOne('SELECT count(*) FROM `User` WHERE `Tshirt`=1');
+ $shirtCount = array_shift($shirtCount);
+
+ $shirt_statistics[] = [
+ 'size' => '<b>' . _('Sum') . '</b>',
+ 'needed' => '<b>' . User_arrived_count() . '</b>',
+ 'given' => '<b>' . (int)$shirtCount . '</b>'
+ ];
+
+ return page_with_title(admin_active_title(), [
+ form([
+ form_text('search', _('Search angel:'), $search),
+ form_checkbox('show_all_shifts', _('Show all shifts'), $show_all_shifts),
+ form_submit('submit', _('Search'))
+ ], page_link_to('admin_active')),
+ $set_active == '' ? form([
+ form_text('count', _('How much angels should be active?'), $count),
+ form_submit('set_active', _('Preview'))
+ ]) : $set_active,
+ $msg . msg(),
+ table([
+ 'nick' => _('Nickname'),
+ 'shirt_size' => _('Size'),
+ 'shift_count' => _('Shifts'),
+ 'work_time' => _('Length'),
+ 'active' => _('Active?'),
+ 'force_active' => _('Forced'),
+ 'tshirt' => _('T-shirt?'),
+ 'actions' => ''
+ ], $matched_users),
+ '<h2>' . _('Shirt statistics') . '</h2>',
+ table([
+ 'size' => _('Size'),
+ 'needed' => _('Needed shirts'),
+ 'given' => _('Given shirts')
+ ], $shirt_statistics)
+ ]);
}
-?>
diff --git a/includes/pages/admin_arrive.php b/includes/pages/admin_arrive.php
index 4a1ee8d7..48e2c91f 100644
--- a/includes/pages/admin_arrive.php
+++ b/includes/pages/admin_arrive.php
@@ -1,201 +1,230 @@
<?php
-function admin_arrive_title() {
- return _("Arrived angels");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_arrive_title()
+{
+ return _('Arrived angels');
}
-function admin_arrive() {
- $msg = "";
- $search = "";
- if (isset($_REQUEST['search'])) {
- $search = strip_request_item('search');
- }
-
- if (isset($_REQUEST['reset']) && preg_match("/^[0-9]*$/", $_REQUEST['reset'])) {
- $user_id = $_REQUEST['reset'];
- $user_source = User($user_id);
- if ($user_source != null) {
- sql_query("UPDATE `User` SET `Gekommen`=0, `arrival_date` = NULL WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
- engelsystem_log("User set to not arrived: " . User_Nick_render($user_source));
- success(_("Reset done. Angel has not arrived."));
- redirect(user_link($user_source));
- } else {
- $msg = error(_("Angel not found."), true);
- }
- } elseif (isset($_REQUEST['arrived']) && preg_match("/^[0-9]*$/", $_REQUEST['arrived'])) {
- $user_id = $_REQUEST['arrived'];
- $user_source = User($user_id);
- if ($user_source != null) {
- sql_query("UPDATE `User` SET `Gekommen`=1, `arrival_date`='" . time() . "' WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
- engelsystem_log("User set has arrived: " . User_Nick_render($user_source));
- success(_("Angel has been marked as arrived."));
- redirect(user_link($user_source));
- } else {
- $msg = error(_("Angel not found."), true);
+/**
+ * @return string
+ */
+function admin_arrive()
+{
+ $msg = '';
+ $search = '';
+ $request = request();
+
+ if ($request->has('search')) {
+ $search = strip_request_item('search');
}
- }
-
- $users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
- $arrival_count_at_day = [];
- $planned_arrival_count_at_day = [];
- $planned_departure_count_at_day = [];
- $users_matched = [];
- if ($search == "") {
- $tokens = [];
- } else {
- $tokens = explode(" ", $search);
- }
- foreach ($users as $usr) {
- if (count($tokens) > 0) {
- $match = false;
- $index = join(" ", $usr);
- foreach ($tokens as $t) {
- if (stristr($index, trim($t))) {
- $match = true;
- break;
+
+ if ($request->has('reset') && preg_match('/^\d+$/', $request->input('reset'))) {
+ $user_id = $request->input('reset');
+ $user_source = User($user_id);
+ if ($user_source != null) {
+ DB::update('
+ UPDATE `User`
+ SET `Gekommen`=0, `arrival_date` = NULL
+ WHERE `UID`=?
+ LIMIT 1
+ ', [$user_id]);
+ engelsystem_log('User set to not arrived: ' . User_Nick_render($user_source));
+ success(_('Reset done. Angel has not arrived.'));
+ redirect(user_link($user_source));
+ } else {
+ $msg = error(_('Angel not found.'), true);
+ }
+ } elseif ($request->has('arrived') && preg_match('/^\d+$/', $request->input('arrived'))) {
+ $user_id = $request->input('arrived');
+ $user_source = User($user_id);
+ if ($user_source != null) {
+ DB::update('
+ UPDATE `User`
+ SET `Gekommen`=1, `arrival_date`=?
+ WHERE `UID`=?
+ LIMIT 1
+ ', [time(), $user_id]);
+ engelsystem_log('User set has arrived: ' . User_Nick_render($user_source));
+ success(_('Angel has been marked as arrived.'));
+ redirect(user_link($user_source));
+ } else {
+ $msg = error(_('Angel not found.'), true);
}
- }
- if (! $match) {
- continue;
- }
}
-
- $usr['nick'] = User_Nick_render($usr);
- if ($usr['planned_departure_date'] != null) {
- $usr['rendered_planned_departure_date'] = date('Y-m-d', $usr['planned_departure_date']);
+
+ $users = DB::select('SELECT * FROM `User` ORDER BY `Nick`');
+ $arrival_count_at_day = [];
+ $planned_arrival_count_at_day = [];
+ $planned_departure_count_at_day = [];
+ $users_matched = [];
+ if ($search == '') {
+ $tokens = [];
} else {
- $usr['rendered_planned_departure_date'] = '-';
+ $tokens = explode(' ', $search);
+ }
+ foreach ($users as $usr) {
+ if (count($tokens) > 0) {
+ $match = false;
+ $index = join(' ', $usr);
+ foreach ($tokens as $t) {
+ if (stristr($index, trim($t))) {
+ $match = true;
+ break;
+ }
+ }
+ if (!$match) {
+ continue;
+ }
+ }
+
+ $usr['nick'] = User_Nick_render($usr);
+ if ($usr['planned_departure_date'] != null) {
+ $usr['rendered_planned_departure_date'] = date('Y-m-d', $usr['planned_departure_date']);
+ } else {
+ $usr['rendered_planned_departure_date'] = '-';
+ }
+ $usr['rendered_planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
+ $usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : '-';
+ $usr['arrived'] = $usr['Gekommen'] == 1 ? _('yes') : '';
+ $usr['actions'] = $usr['Gekommen'] == 1
+ ? '<a href="' . page_link_to(
+ 'admin_arrive',
+ ['reset' => $usr['UID'], 'search' => $search]
+ ) . '">' . _('reset') . '</a>'
+ : '<a href="' . page_link_to(
+ 'admin_arrive',
+ ['arrived' => $usr['UID'], 'search' => $search]
+ ) . '">' . _('arrived') . '</a>';
+
+ if ($usr['arrival_date'] > 0) {
+ $day = date('Y-m-d', $usr['arrival_date']);
+ if (!isset($arrival_count_at_day[$day])) {
+ $arrival_count_at_day[$day] = 0;
+ }
+ $arrival_count_at_day[$day]++;
+ }
+
+ if ($usr['planned_arrival_date'] != null) {
+ $day = date('Y-m-d', $usr['planned_arrival_date']);
+ if (!isset($planned_arrival_count_at_day[$day])) {
+ $planned_arrival_count_at_day[$day] = 0;
+ }
+ $planned_arrival_count_at_day[$day]++;
+ }
+
+ if ($usr['planned_departure_date'] != null && $usr['Gekommen'] == 1) {
+ $day = date('Y-m-d', $usr['planned_departure_date']);
+ if (!isset($planned_departure_count_at_day[$day])) {
+ $planned_departure_count_at_day[$day] = 0;
+ }
+ $planned_departure_count_at_day[$day]++;
+ }
+
+ $users_matched[] = $usr;
}
- $usr['rendered_planned_arrival_date'] = date('Y-m-d', $usr['planned_arrival_date']);
- $usr['rendered_arrival_date'] = $usr['arrival_date'] > 0 ? date('Y-m-d', $usr['arrival_date']) : "-";
- $usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
- $usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
-
- if ($usr['arrival_date'] > 0) {
- $day = date('Y-m-d', $usr['arrival_date']);
- if (! isset($arrival_count_at_day[$day])) {
- $arrival_count_at_day[$day] = 0;
- }
- $arrival_count_at_day[$day] ++;
+
+ ksort($arrival_count_at_day);
+ ksort($planned_arrival_count_at_day);
+ ksort($planned_departure_count_at_day);
+
+ $arrival_at_day = [];
+ $arrival_sum = 0;
+ foreach ($arrival_count_at_day as $day => $count) {
+ $arrival_sum += $count;
+ $arrival_at_day[$day] = [
+ 'day' => $day,
+ 'count' => $count,
+ 'sum' => $arrival_sum
+ ];
}
-
- if ($usr['planned_arrival_date'] != null) {
- $day = date('Y-m-d', $usr['planned_arrival_date']);
- if (! isset($planned_arrival_count_at_day[$day])) {
- $planned_arrival_count_at_day[$day] = 0;
- }
- $planned_arrival_count_at_day[$day] ++;
+
+ $planned_arrival_at_day = [];
+ $planned_arrival_sum = 0;
+ foreach ($planned_arrival_count_at_day as $day => $count) {
+ $planned_arrival_sum += $count;
+ $planned_arrival_at_day[$day] = [
+ 'day' => $day,
+ 'count' => $count,
+ 'sum' => $planned_arrival_sum
+ ];
}
-
- if ($usr['planned_departure_date'] != null && $usr['Gekommen'] == 1) {
- $day = date('Y-m-d', $usr['planned_departure_date']);
- if (! isset($planned_departure_count_at_day[$day])) {
- $planned_departure_count_at_day[$day] = 0;
- }
- $planned_departure_count_at_day[$day] ++;
+
+ $planned_departure_at_day = [];
+ $planned_departure_sum = 0;
+ foreach ($planned_departure_count_at_day as $day => $count) {
+ $planned_departure_sum += $count;
+ $planned_departure_at_day[$day] = [
+ 'day' => $day,
+ 'count' => $count,
+ 'sum' => $planned_departure_sum
+ ];
}
-
- $users_matched[] = $usr;
- }
-
- ksort($arrival_count_at_day);
- ksort($planned_arrival_count_at_day);
- ksort($planned_departure_count_at_day);
-
- $arrival_at_day = [];
- $arrival_sum = 0;
- foreach ($arrival_count_at_day as $day => $count) {
- $arrival_sum += $count;
- $arrival_at_day[$day] = [
- 'day' => $day,
- 'count' => $count,
- 'sum' => $arrival_sum
- ];
- }
-
- $planned_arrival_at_day = [];
- $planned_arrival_sum = 0;
- foreach ($planned_arrival_count_at_day as $day => $count) {
- $planned_arrival_sum += $count;
- $planned_arrival_at_day[$day] = [
- 'day' => $day,
- 'count' => $count,
- 'sum' => $planned_arrival_sum
- ];
- }
-
- $planned_departure_at_day = [];
- $planned_departure_sum = 0;
- foreach ($planned_departure_count_at_day as $day => $count) {
- $planned_departure_sum += $count;
- $planned_departure_at_day[$day] = [
- 'day' => $day,
- 'count' => $count,
- 'sum' => $planned_departure_sum
- ];
- }
-
- return page_with_title(admin_arrive_title(), [
- msg(),
- form([
- form_text('search', _("Search"), $search),
- form_submit('submit', _("Search"))
- ]),
- table([
- 'nick' => _("Nickname"),
- 'rendered_planned_arrival_date' => _("Planned arrival"),
- 'arrived' => _("Arrived?"),
- 'rendered_arrival_date' => _("Arrival date"),
- 'rendered_planned_departure_date' => _("Planned departure"),
- 'actions' => ""
- ], $users_matched),
- div('row', [
- div('col-md-4', [
- heading(_("Planned arrival statistics"), 2),
- bargraph('planned_arrives', 'day', [
- 'count' => _("arrived"),
- 'sum' => _("arrived sum")
- ], [
- 'count' => '#090',
- 'sum' => '#888'
- ], $planned_arrival_at_day),
- table([
- 'day' => _("Date"),
- 'count' => _("Count"),
- 'sum' => _("Sum")
- ], $planned_arrival_at_day)
- ]),
- div('col-md-4', [
- heading(_("Arrival statistics"), 2),
- bargraph('arrives', 'day', [
- 'count' => _("arrived"),
- 'sum' => _("arrived sum")
- ], [
- 'count' => '#090',
- 'sum' => '#888'
- ], $arrival_at_day),
- table([
- 'day' => _("Date"),
- 'count' => _("Count"),
- 'sum' => _("Sum")
- ], $arrival_at_day)
- ]),
- div('col-md-4', [
- heading(_("Planned departure statistics"), 2),
- bargraph('planned_departures', 'day', [
- 'count' => _("arrived"),
- 'sum' => _("arrived sum")
- ], [
- 'count' => '#090',
- 'sum' => '#888'
- ], $planned_departure_at_day),
- table([
- 'day' => _("Date"),
- 'count' => _("Count"),
- 'sum' => _("Sum")
- ], $planned_departure_at_day)
- ])
- ])
- ]);
+
+ return page_with_title(admin_arrive_title(), [
+ $msg . msg(),
+ form([
+ form_text('search', _('Search'), $search),
+ form_submit('submit', _('Search'))
+ ]),
+ table([
+ 'nick' => _('Nickname'),
+ 'rendered_planned_arrival_date' => _('Planned arrival'),
+ 'arrived' => _('Arrived?'),
+ 'rendered_arrival_date' => _('Arrival date'),
+ 'rendered_planned_departure_date' => _('Planned departure'),
+ 'actions' => ''
+ ], $users_matched),
+ div('row', [
+ div('col-md-4', [
+ heading(_('Planned arrival statistics'), 2),
+ bargraph('planned_arrives', 'day', [
+ 'count' => _('arrived'),
+ 'sum' => _('arrived sum')
+ ], [
+ 'count' => '#090',
+ 'sum' => '#888'
+ ], $planned_arrival_at_day),
+ table([
+ 'day' => _('Date'),
+ 'count' => _('Count'),
+ 'sum' => _('Sum')
+ ], $planned_arrival_at_day)
+ ]),
+ div('col-md-4', [
+ heading(_('Arrival statistics'), 2),
+ bargraph('arrives', 'day', [
+ 'count' => _('arrived'),
+ 'sum' => _('arrived sum')
+ ], [
+ 'count' => '#090',
+ 'sum' => '#888'
+ ], $arrival_at_day),
+ table([
+ 'day' => _('Date'),
+ 'count' => _('Count'),
+ 'sum' => _('Sum')
+ ], $arrival_at_day)
+ ]),
+ div('col-md-4', [
+ heading(_('Planned departure statistics'), 2),
+ bargraph('planned_departures', 'day', [
+ 'count' => _('arrived'),
+ 'sum' => _('arrived sum')
+ ], [
+ 'count' => '#090',
+ 'sum' => '#888'
+ ], $planned_departure_at_day),
+ table([
+ 'day' => _('Date'),
+ 'count' => _('Count'),
+ 'sum' => _('Sum')
+ ], $planned_departure_at_day)
+ ])
+ ])
+ ]);
}
-?>
diff --git a/includes/pages/admin_free.php b/includes/pages/admin_free.php
index 427de61a..a3c0d17f 100644
--- a/includes/pages/admin_free.php
+++ b/includes/pages/admin_free.php
@@ -1,101 +1,127 @@
<?php
-function admin_free_title() {
- return _("Free angels");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_free_title()
+{
+ return _('Free angels');
}
-function admin_free() {
- global $privileges;
-
- $search = "";
- if (isset($_REQUEST['search'])) {
- $search = strip_request_item('search');
- }
-
- $angeltypesearch = "";
- if (empty($_REQUEST['angeltype'])) {
- $_REQUEST['angeltype'] = '';
- } else {
- $angeltypesearch = " INNER JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id` = '" . sql_escape($_REQUEST['angeltype']) . "' AND `UserAngelTypes`.`user_id` = `User`.`UID`";
- if (isset($_REQUEST['confirmed_only'])) {
- $angeltypesearch .= " AND `UserAngelTypes`.`confirm_user_id`";
+/**
+ * @return string
+ */
+function admin_free()
+{
+ global $privileges;
+ $request = request();
+
+ $search = '';
+ if ($request->has('search')) {
+ $search = strip_request_item('search');
}
- $angeltypesearch .= ") ";
- }
-
- $angel_types_source = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`");
- $angel_types = [
- '' => 'alle Typen'
- ];
- foreach ($angel_types_source as $angel_type) {
- $angel_types[$angel_type['id']] = $angel_type['name'];
- }
-
- $users = sql_select("
- SELECT `User`.*
- FROM `User`
- ${angeltypesearch}
- LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
- LEFT JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID` AND `Shifts`.`start` < '" . sql_escape(time()) . "' AND `Shifts`.`end` > '" . sql_escape(time()) . "')
- WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL
- GROUP BY `User`.`UID`
- ORDER BY `Nick`");
-
- $free_users_table = [];
- if ($search == "") {
- $tokens = [];
- } else {
- $tokens = explode(" ", $search);
- }
- foreach ($users as $usr) {
- if (count($tokens) > 0) {
- $match = false;
- $index = join("", $usr);
- foreach ($tokens as $t) {
- if (stristr($index, trim($t))) {
- $match = true;
- break;
+
+ $angelTypeSearch = '';
+ $angelType = $request->input('angeltype', '');
+ if (!empty($angelType)) {
+ $angelTypeSearch = ' INNER JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id` = '
+ . DB::getPdo()->quote($angelType)
+ . ' AND `UserAngelTypes`.`user_id` = `User`.`UID`';
+ if ($request->has('confirmed_only')) {
+ $angelTypeSearch .= ' AND `UserAngelTypes`.`confirm_user_id`';
}
- }
- if (! $match) {
- continue;
- }
+ $angelTypeSearch .= ') ';
}
-
- $free_users_table[] = [
- 'name' => User_Nick_render($usr),
- 'shift_state' => User_shift_state_render($usr),
- 'dect' => $usr['DECT'],
- 'jabber' => $usr['jabber'],
- 'email' => $usr['email_by_human_allowed'] ? $usr['email'] : glyph('eye-close'),
- 'actions' => in_array('admin_user', $privileges) ? button(page_link_to('admin_user') . '&amp;id=' . $usr['UID'], _("edit"), 'btn-xs') : ''
+
+ $angel_types_source = DB::select('SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`');
+ $angel_types = [
+ '' => 'alle Typen'
];
- }
- return page_with_title(admin_free_title(), [
- form([
- div('row', [
- div('col-md-4', [
- form_text('search', _("Search"), $search)
- ]),
- div('col-md-4', [
- form_select('angeltype', _("Angeltype"), $angel_types, $_REQUEST['angeltype'])
- ]),
- div('col-md-2', [
- form_checkbox('confirmed_only', _("Only confirmed"), isset($_REQUEST['confirmed_only']))
- ]),
- div('col-md-2', [
- form_submit('submit', _("Search"))
- ])
- ])
- ]),
- table([
- 'name' => _("Nick"),
- 'shift_state' => '',
- 'dect' => _("DECT"),
- 'jabber' => _("Jabber"),
- 'email' => _("E-Mail"),
- 'actions' => ''
- ], $free_users_table)
- ]);
+ foreach ($angel_types_source as $angel_type) {
+ $angel_types[$angel_type['id']] = $angel_type['name'];
+ }
+
+ $users = DB::select('
+ SELECT `User`.*
+ FROM `User`
+ ' . $angelTypeSearch . '
+ LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
+ LEFT JOIN `Shifts`
+ ON (
+ `ShiftEntry`.`SID` = `Shifts`.`SID`
+ AND `Shifts`.`start` < ?
+ AND `Shifts`.`end` > ?
+ )
+ WHERE `User`.`Gekommen` = 1
+ AND `Shifts`.`SID` IS NULL
+ GROUP BY `User`.`UID`
+ ORDER BY `Nick`
+ ',
+ [
+ time(),
+ time(),
+ ]
+ );
+
+ $free_users_table = [];
+ if ($search == '') {
+ $tokens = [];
+ } else {
+ $tokens = explode(' ', $search);
+ }
+ foreach ($users as $usr) {
+ if (count($tokens) > 0) {
+ $match = false;
+ $index = join('', $usr);
+ foreach ($tokens as $t) {
+ if (stristr($index, trim($t))) {
+ $match = true;
+ break;
+ }
+ }
+ if (!$match) {
+ continue;
+ }
+ }
+
+ $free_users_table[] = [
+ 'name' => User_Nick_render($usr),
+ 'shift_state' => User_shift_state_render($usr),
+ 'dect' => $usr['DECT'],
+ 'jabber' => $usr['jabber'],
+ 'email' => $usr['email_by_human_allowed'] ? $usr['email'] : glyph('eye-close'),
+ 'actions' =>
+ in_array('admin_user', $privileges)
+ ? button(page_link_to('admin_user', ['id' => $usr['UID']]), _('edit'), 'btn-xs')
+ : ''
+ ];
+ }
+ return page_with_title(admin_free_title(), [
+ form([
+ div('row', [
+ div('col-md-4', [
+ form_text('search', _('Search'), $search)
+ ]),
+ div('col-md-4', [
+ form_select('angeltype', _('Angeltype'), $angel_types, $angelType)
+ ]),
+ div('col-md-2', [
+ form_checkbox('confirmed_only', _('Only confirmed'), $request->has('confirmed_only'))
+ ]),
+ div('col-md-2', [
+ form_submit('submit', _('Search'))
+ ])
+ ])
+ ]),
+ table([
+ 'name' => _('Nick'),
+ 'shift_state' => '',
+ 'dect' => _('DECT'),
+ 'jabber' => _('Jabber'),
+ 'email' => _('E-Mail'),
+ 'actions' => ''
+ ], $free_users_table)
+ ]);
}
-?>
diff --git a/includes/pages/admin_groups.php b/includes/pages/admin_groups.php
index 388e2c68..e0260320 100644
--- a/includes/pages/admin_groups.php
+++ b/includes/pages/admin_groups.php
@@ -1,97 +1,150 @@
<?php
-function admin_groups_title() {
- return _("Grouprights");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_groups_title()
+{
+ return _('Grouprights');
}
-function admin_groups() {
- $html = "";
- $groups = sql_select("SELECT * FROM `Groups` ORDER BY `Name`");
- if (! isset($_REQUEST["action"])) {
- $groups_table = [];
- foreach ($groups as $group) {
- $privileges = sql_select("SELECT * FROM `GroupPrivileges` JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `group_id`='" . sql_escape($group['UID']) . "'");
- $privileges_html = [];
-
- foreach ($privileges as $priv) {
- $privileges_html[] = $priv['name'];
- }
-
- $groups_table[] = [
- 'name' => $group['Name'],
- 'privileges' => join(', ', $privileges_html),
- 'actions' => button(page_link_to('admin_groups') . '&action=edit&id=' . $group['UID'], _("edit"), 'btn-xs')
- ];
- }
-
- return page_with_title(admin_groups_title(), [
- table([
- 'name' => _("Name"),
- 'privileges' => _("Privileges"),
- 'actions' => ''
- ], $groups_table)
- ]);
- } else {
- switch ($_REQUEST["action"]) {
- case 'edit':
- if (isset($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) {
- $group_id = $_REQUEST['id'];
- } else {
- return error("Incomplete call, missing Groups ID.", true);
- }
-
- $group = sql_select("SELECT * FROM `Groups` WHERE `UID`='" . sql_escape($group_id) . "' LIMIT 1");
- if (count($group) > 0) {
- list($group) = $group;
- $privileges = sql_select("SELECT `Privileges`.*, `GroupPrivileges`.`group_id` FROM `Privileges` LEFT OUTER JOIN `GroupPrivileges` ON (`Privileges`.`id` = `GroupPrivileges`.`privilege_id` AND `GroupPrivileges`.`group_id`='" . sql_escape($group_id) . "') ORDER BY `Privileges`.`name`");
- $privileges_html = "";
- $privileges_form = [];
- foreach ($privileges as $priv) {
- $privileges_form[] = form_checkbox('privileges[]', $priv['desc'] . ' (' . $priv['name'] . ')', $priv['group_id'] != "", $priv['id']);
- $privileges_html .= sprintf('<tr><td><input type="checkbox" ' . 'name="privileges[]" value="%s" %s />' . '</td> <td>%s</td> <td>%s</td></tr>', $priv['id'], ($priv['group_id'] != "" ? 'checked="checked"' : ''), $priv['name'], $priv['desc']);
- }
-
- $privileges_form[] = form_submit('submit', _("Save"));
- $html .= page_with_title(_("Edit group"), [
- form($privileges_form, page_link_to('admin_groups') . '&action=save&id=' . $group_id)
- ]);
- } else {
- return error("No Group found.", true);
- }
- break;
-
- case 'save':
- if (isset($_REQUEST['id']) && preg_match("/^-[0-9]{1,11}$/", $_REQUEST['id'])) {
- $group_id = $_REQUEST['id'];
- } else {
- return error("Incomplete call, missing Groups ID.", true);
- }
-
- $group = sql_select("SELECT * FROM `Groups` WHERE `UID`='" . sql_escape($group_id) . "' LIMIT 1");
- if (! is_array($_REQUEST['privileges'])) {
- $_REQUEST['privileges'] = [];
- }
- if (count($group) > 0) {
- list($group) = $group;
- sql_query("DELETE FROM `GroupPrivileges` WHERE `group_id`='" . sql_escape($group_id) . "'");
- $privilege_names = [];
- foreach ($_REQUEST['privileges'] as $priv) {
- if (preg_match("/^[0-9]{1,}$/", $priv)) {
- $group_privileges_source = sql_select("SELECT * FROM `Privileges` WHERE `id`='" . sql_escape($priv) . "' LIMIT 1");
- if (count($group_privileges_source) > 0) {
- sql_query("INSERT INTO `GroupPrivileges` SET `group_id`='" . sql_escape($group_id) . "', `privilege_id`='" . sql_escape($priv) . "'");
- $privilege_names[] = $group_privileges_source[0]['name'];
- }
+/**
+ * @return string
+ */
+function admin_groups()
+{
+ $html = '';
+ $request = request();
+ $groups = DB::select('SELECT * FROM `Groups` ORDER BY `Name`');
+
+ if (!$request->has('action')) {
+ $groups_table = [];
+ foreach ($groups as $group) {
+ $privileges = DB::select('
+ SELECT `name`
+ FROM `GroupPrivileges`
+ JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
+ WHERE `group_id`=?
+ ', [$group['UID']]);
+ $privileges_html = [];
+
+ foreach ($privileges as $privilege) {
+ $privileges_html[] = $privilege['name'];
}
- }
- engelsystem_log("Group privileges of group " . $group['Name'] . " edited: " . join(", ", $privilege_names));
- redirect(page_link_to("admin_groups"));
- } else {
- return error("No Group found.", true);
+
+ $groups_table[] = [
+ 'name' => $group['Name'],
+ 'privileges' => join(', ', $privileges_html),
+ 'actions' => button(
+ page_link_to('admin_groups',
+ ['action' => 'edit', 'id' => $group['UID']]),
+ _('edit'),
+ 'btn-xs'
+ )
+ ];
+ }
+
+ return page_with_title(admin_groups_title(), [
+ table([
+ 'name' => _('Name'),
+ 'privileges' => _('Privileges'),
+ 'actions' => ''
+ ], $groups_table)
+ ]);
+ } else {
+ switch ($request->input('action')) {
+ case 'edit':
+ if ($request->has('id') && preg_match('/^-\d{1,11}$/', $request->input('id'))) {
+ $group_id = $request->input('id');
+ } else {
+ return error('Incomplete call, missing Groups ID.', true);
+ }
+
+ $group = DB::select('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]);
+ if (!empty($group)) {
+ $privileges = DB::select('
+ SELECT `Privileges`.*, `GroupPrivileges`.`group_id`
+ FROM `Privileges`
+ LEFT OUTER JOIN `GroupPrivileges`
+ ON (
+ `Privileges`.`id` = `GroupPrivileges`.`privilege_id`
+ AND `GroupPrivileges`.`group_id`=?
+ )
+ ORDER BY `Privileges`.`name`
+ ', [$group_id]);
+ $privileges_html = '';
+ $privileges_form = [];
+ foreach ($privileges as $privilege) {
+ $privileges_form[] = form_checkbox(
+ 'privileges[]',
+ $privilege['desc'] . ' (' . $privilege['name'] . ')',
+ $privilege['group_id'] != '',
+ $privilege['id'],
+ 'privilege-' . $privilege['name']
+ );
+ $privileges_html .= sprintf(
+ '<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'],
+ $privilege['desc']
+ );
+ }
+
+ $privileges_form[] = form_submit('submit', _('Save'));
+ $html .= page_with_title(_('Edit group'), [
+ form(
+ $privileges_form,
+ page_link_to('admin_groups', ['action' => 'save', 'id' => $group_id])
+ )
+ ]);
+ } else {
+ return error('No Group found.', true);
+ }
+ break;
+
+ case 'save':
+ if ($request->has('id') && preg_match('/^-\d{1,11}$/', $request->input('id'))) {
+ $group_id = $request->input('id');
+ } else {
+ return error('Incomplete call, missing Groups ID.', true);
+ }
+
+ $group = DB::selectOne('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]);
+ $privileges = $request->postData('privileges');
+ if (!is_array($privileges)) {
+ $privileges = [];
+ }
+ if (!empty($group)) {
+ DB::delete('DELETE FROM `GroupPrivileges` WHERE `group_id`=?', [$group_id]);
+ $privilege_names = [];
+ foreach ($privileges as $privilege) {
+ if (preg_match('/^\d{1,}$/', $privilege)) {
+ $group_privileges_source = DB::selectOne(
+ 'SELECT `name` FROM `Privileges` WHERE `id`=? LIMIT 1',
+ [$privilege]
+ );
+ if (!empty($group_privileges_source)) {
+ DB::insert(
+ 'INSERT INTO `GroupPrivileges` (`group_id`, `privilege_id`) VALUES (?, ?)',
+ [$group_id, $privilege]
+ );
+ $privilege_names[] = $group_privileges_source['name'];
+ }
+ }
+ }
+ engelsystem_log(
+ 'Group privileges of group ' . $group['Name']
+ . ' edited: ' . join(', ', $privilege_names)
+ );
+ redirect(page_link_to('admin_groups'));
+ } else {
+ return error('No Group found.', true);
+ }
+ break;
}
- break;
}
- }
- return $html;
+ return $html;
}
-?>
diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php
index 0669029d..e97f95e1 100644
--- a/includes/pages/admin_import.php
+++ b/includes/pages/admin_import.php
@@ -1,392 +1,463 @@
<?php
-function admin_import_title() {
- return _("Frab import");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_import_title()
+{
+ return _('Frab import');
}
-function admin_import() {
- global $rooms_import;
- global $user;
- $html = "";
- $import_dir = __DIR__ . '/../../import';
-
- $step = "input";
- if (isset($_REQUEST['step']) && in_array($step, [
- 'input',
- 'check',
- 'import'
- ])) {
- $step = $_REQUEST['step'];
- }
-
- if ($test_handle = @fopen($import_dir . '/tmp', 'w')) {
- fclose($test_handle);
- @unlink($import_dir . '/tmp');
- } else {
- error(_('Webserver has no write-permission on import directory.'));
- }
-
- $import_file = $import_dir . '/import_' . $user['UID'] . '.xml';
- $shifttype_id = null;
- $add_minutes_start = 15;
- $add_minutes_end = 15;
-
- $shifttypes_source = ShiftTypes();
- if ($shifttypes_source === false) {
- engelsystem_error('Unable to load shifttypes.');
- }
- $shifttypes = [];
- foreach ($shifttypes_source as $shifttype) {
- $shifttypes[$shifttype['id']] = $shifttype['name'];
- }
-
- switch ($step) {
- case 'input':
- $valid = false;
-
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
- $shifttype_id = $_REQUEST['shifttype_id'];
- } else {
- $valid = false;
- error(_('Please select a shift type.'));
- }
-
- if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
- $add_minutes_start = trim($_REQUEST['add_minutes_start']);
- } else {
- $valid = false;
- error(_("Please enter an amount of minutes to add to a talk's begin."));
- }
-
- if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
- $add_minutes_end = trim($_REQUEST['add_minutes_end']);
- } else {
- $valid = false;
- error(_("Please enter an amount of minutes to add to a talk's end."));
- }
-
- if (isset($_FILES['xcal_file']) && ($_FILES['xcal_file']['error'] == 0)) {
- if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) {
- libxml_use_internal_errors(true);
- if (simplexml_load_file($import_file) === false) {
- $valid = false;
- error(_('No valid xml/xcal file provided.'));
- unlink($import_file);
- }
- } else {
+/**
+ * @return string
+ */
+function admin_import()
+{
+ global $rooms_import, $user;
+ $html = '';
+ $import_dir = __DIR__ . '/../../import';
+ $request = request();
+
+ $step = 'input';
+ if (
+ $request->has('step')
+ && in_array($request->input('step'), [
+ 'input',
+ 'check',
+ 'import'
+ ])
+ ) {
+ $step = $request->input('step');
+ }
+
+ if ($test_handle = @fopen($import_dir . '/tmp', 'w')) {
+ fclose($test_handle);
+ @unlink($import_dir . '/tmp');
+ } else {
+ error(_('Webserver has no write-permission on import directory.'));
+ }
+
+ $import_file = $import_dir . '/import_' . $user['UID'] . '.xml';
+ $shifttype_id = null;
+ $add_minutes_start = 15;
+ $add_minutes_end = 15;
+
+ $shifttypes_source = ShiftTypes();
+ $shifttypes = [];
+ foreach ($shifttypes_source as $shifttype) {
+ $shifttypes[$shifttype['id']] = $shifttype['name'];
+ }
+
+ switch ($step) {
+ case 'input':
$valid = false;
- error(_('File upload went wrong.'));
- }
- } else {
- $valid = false;
- error(_('Please provide some data.'));
- }
- }
-
- if ($valid) {
- redirect(page_link_to('admin_import') . "&step=check&shifttype_id=" . $shifttype_id . "&add_minutes_end=" . $add_minutes_end . "&add_minutes_start=" . $add_minutes_start);
- } else {
- $html .= div('well well-sm text-center', [
- _('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([
- form_info('', _("This import will create/update/delete rooms and shifts by given FRAB-export file. The needed file format is xcal.")),
- form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
- form_spinner('add_minutes_start', _("Add minutes to start"), $add_minutes_start),
- form_spinner('add_minutes_end', _("Add minutes to end"), $add_minutes_end),
- form_file('xcal_file', _("xcal-File (.xcal)")),
- form_submit('submit', _("Import"))
- ])
- ])
- ]);
- }
- break;
-
- case 'check':
- if (! file_exists($import_file)) {
- error(_('Missing import file.'));
- redirect(page_link_to('admin_import'));
- }
-
- if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
- $shifttype_id = $_REQUEST['shifttype_id'];
- } else {
- error(_('Please select a shift type.'));
- redirect(page_link_to('admin_import'));
- }
-
- if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
- $add_minutes_start = trim($_REQUEST['add_minutes_start']);
- } else {
- error(_("Please enter an amount of minutes to add to a talk's begin."));
- redirect(page_link_to('admin_import'));
- }
-
- if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
- $add_minutes_end = trim($_REQUEST['add_minutes_end']);
- } else {
- error(_("Please enter an amount of minutes to add to a talk's end."));
- redirect(page_link_to('admin_import'));
- }
-
- list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
- list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id, $add_minutes_start, $add_minutes_end);
-
- $html .= div('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'))
- ]) . form([
- div('row', [
- div('col-sm-6', [
- '<h3>' . _("Rooms to create") . '</h3>',
- table(_("Name"), $rooms_new)
- ]),
- div('col-sm-6', [
- '<h3>' . _("Rooms to delete") . '</h3>',
- table(_("Name"), $rooms_deleted)
- ])
- ]),
- '<h3>' . _("Shifts to create") . '</h3>',
- table([
- 'day' => _("Day"),
- 'start' => _("Start"),
- 'end' => _("End"),
- 'shifttype' => _('Shift type'),
- 'title' => _("Title"),
- 'room' => _("Room")
- ], shifts_printable($events_new, $shifttypes)),
- '<h3>' . _("Shifts to update") . '</h3>',
- table([
- 'day' => _("Day"),
- 'start' => _("Start"),
- 'end' => _("End"),
- 'shifttype' => _('Shift type'),
- 'title' => _("Title"),
- 'room' => _("Room")
- ], shifts_printable($events_updated, $shifttypes)),
- '<h3>' . _("Shifts to delete") . '</h3>',
- table([
- 'day' => _("Day"),
- 'start' => _("Start"),
- 'end' => _("End"),
- 'shifttype' => _('Shift type'),
- 'title' => _("Title"),
- 'room' => _("Room")
- ], shifts_printable($events_deleted, $shifttypes)),
- form_submit('submit', _("Import"))
- ], page_link_to('admin_import') . '&step=import&shifttype_id=' . $shifttype_id . "&add_minutes_end=" . $add_minutes_end . "&add_minutes_start=" . $add_minutes_start);
- break;
-
- case 'import':
- if (! file_exists($import_file)) {
- error(_('Missing import file.'));
- redirect(page_link_to('admin_import'));
- }
-
- if (! file_exists($import_file)) {
- redirect(page_link_to('admin_import'));
- }
-
- if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
- $shifttype_id = $_REQUEST['shifttype_id'];
- } else {
- error(_('Please select a shift type.'));
- redirect(page_link_to('admin_import'));
- }
-
- if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
- $add_minutes_start = trim($_REQUEST['add_minutes_start']);
- } else {
- error(_("Please enter an amount of minutes to add to a talk's begin."));
- redirect(page_link_to('admin_import'));
- }
-
- if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
- $add_minutes_end = trim($_REQUEST['add_minutes_end']);
- } else {
- error(_("Please enter an amount of minutes to add to a talk's end."));
- redirect(page_link_to('admin_import'));
- }
-
- list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
- foreach ($rooms_new as $room) {
- $result = Room_create($room, true, true);
- if ($result === false) {
- engelsystem_error('Unable to create room.');
- }
- $rooms_import[trim($room)] = sql_id();
- }
- foreach ($rooms_deleted as $room) {
- sql_query("DELETE FROM `Room` WHERE `Name`='" . sql_escape($room) . "' LIMIT 1");
- }
-
- list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id, $add_minutes_start, $add_minutes_end);
- foreach ($events_new as $event) {
- $result = Shift_create($event);
- if ($result === false) {
- engelsystem_error('Unable to create shift.');
- }
- }
-
- foreach ($events_updated as $event) {
- $result = Shift_update_by_psid($event);
- if ($result === false) {
- engelsystem_error('Unable to update shift.');
- }
- }
-
- foreach ($events_deleted as $event) {
- $result = Shift_delete_by_psid($event['PSID']);
- if ($result === false) {
- engelsystem_error('Unable to delete shift.');
- }
- }
-
- engelsystem_log("Frab import done");
-
- unlink($import_file);
-
- $html .= div('well well-sm text-center', [
- '<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Validation') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Import') . glyph('ok-circle') . '</span>'
- ]) . success(_("It's done!"), true);
- break;
- default:
- redirect(page_link_to('admin_import'));
- }
-
- return page_with_title(admin_import_title(), [
- msg(),
- $html
- ]);
-}
-function prepare_rooms($file) {
- global $rooms_import;
- $data = read_xml($file);
-
- // Load rooms from db for compare with input
- $rooms = sql_select("SELECT * FROM `Room` WHERE `FromPentabarf`='Y'");
- $rooms_db = [];
- $rooms_import = [];
- foreach ($rooms as $room) {
- $rooms_db[] = (string) $room['Name'];
- $rooms_import[$room['Name']] = $room['RID'];
- }
-
- $events = $data->vcalendar->vevent;
- $rooms_pb = [];
- foreach ($events as $event) {
- $rooms_pb[] = (string) $event->location;
- if (! isset($rooms_import[trim($event->location)])) {
- $rooms_import[trim($event->location)] = trim($event->location);
+ if ($request->has('submit')) {
+ $valid = true;
+
+ if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) {
+ $shifttype_id = $request->input('shifttype_id');
+ } else {
+ $valid = false;
+ 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'));
+ } else {
+ $valid = false;
+ error(_('Please enter an amount of minutes to add to a talk\'s begin.'));
+ }
+
+ if ($request->has('add_minutes_end') && is_numeric(trim($request->input('add_minutes_end')))) {
+ $add_minutes_end = trim($request->input('add_minutes_end'));
+ } else {
+ $valid = false;
+ error(_('Please enter an amount of minutes to add to a talk\'s end.'));
+ }
+
+ if (isset($_FILES['xcal_file']) && ($_FILES['xcal_file']['error'] == 0)) {
+ if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) {
+ libxml_use_internal_errors(true);
+ if (simplexml_load_file($import_file) === false) {
+ $valid = false;
+ error(_('No valid xml/xcal file provided.'));
+ unlink($import_file);
+ }
+ } else {
+ $valid = false;
+ error(_('File upload went wrong.'));
+ }
+ } else {
+ $valid = false;
+ error(_('Please provide some data.'));
+ }
+ }
+
+ if ($valid) {
+ redirect(
+ page_link_to('admin_import', [
+ 'step' => 'check',
+ 'shifttype_id' => $shifttype_id,
+ 'add_minutes_end' => $add_minutes_end,
+ 'add_minutes_start' => $add_minutes_start,
+ ])
+ );
+ } else {
+ $html .= div('well well-sm text-center', [
+ _('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([
+ form_info(
+ '',
+ _('This import will create/update/delete rooms and shifts by given FRAB-export file. The needed file format is xcal.')
+ ),
+ form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
+ form_spinner('add_minutes_start', _('Add minutes to start'), $add_minutes_start),
+ form_spinner('add_minutes_end', _('Add minutes to end'), $add_minutes_end),
+ form_file('xcal_file', _('xcal-File (.xcal)')),
+ form_submit('submit', _('Import'))
+ ])
+ ])
+ ]);
+ }
+ break;
+
+ case 'check':
+ if (!file_exists($import_file)) {
+ error(_('Missing import file.'));
+ redirect(page_link_to('admin_import'));
+ }
+
+ if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) {
+ $shifttype_id = $request->input('shifttype_id');
+ } else {
+ error(_('Please select a shift type.'));
+ redirect(page_link_to('admin_import'));
+ }
+
+ if ($request->has('add_minutes_start') && is_numeric(trim($request->input('add_minutes_start')))) {
+ $add_minutes_start = trim($request->input('add_minutes_start'));
+ } else {
+ error(_('Please enter an amount of minutes to add to a talk\'s begin.'));
+ redirect(page_link_to('admin_import'));
+ }
+
+ if ($request->has('add_minutes_end') && is_numeric(trim($request->input(('add_minutes_end'))))) {
+ $add_minutes_end = trim($request->input('add_minutes_end'));
+ } else {
+ error(_('Please enter an amount of minutes to add to a talk\'s end.'));
+ redirect(page_link_to('admin_import'));
+ }
+
+ list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
+ list($events_new, $events_updated, $events_deleted) = prepare_events(
+ $import_file,
+ $shifttype_id,
+ $add_minutes_start,
+ $add_minutes_end
+ );
+
+ $html .= div(
+ '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'))
+ ]
+ )
+ . form(
+ [
+ div('row', [
+ div('col-sm-6', [
+ '<h3>' . _('Rooms to create') . '</h3>',
+ table(_('Name'), $rooms_new)
+ ]),
+ div('col-sm-6', [
+ '<h3>' . _('Rooms to delete') . '</h3>',
+ table(_('Name'), $rooms_deleted)
+ ])
+ ]),
+ '<h3>' . _('Shifts to create') . '</h3>',
+ table([
+ 'day' => _('Day'),
+ 'start' => _('Start'),
+ 'end' => _('End'),
+ 'shifttype' => _('Shift type'),
+ 'title' => _('Title'),
+ 'room' => _('Room')
+ ], shifts_printable($events_new, $shifttypes)),
+ '<h3>' . _('Shifts to update') . '</h3>',
+ table([
+ 'day' => _('Day'),
+ 'start' => _('Start'),
+ 'end' => _('End'),
+ 'shifttype' => _('Shift type'),
+ 'title' => _('Title'),
+ 'room' => _('Room')
+ ], shifts_printable($events_updated, $shifttypes)),
+ '<h3>' . _('Shifts to delete') . '</h3>',
+ table([
+ 'day' => _('Day'),
+ 'start' => _('Start'),
+ 'end' => _('End'),
+ 'shifttype' => _('Shift type'),
+ 'title' => _('Title'),
+ 'room' => _('Room')
+ ], shifts_printable($events_deleted, $shifttypes)),
+ form_submit('submit', _('Import'))
+ ],
+ page_link_to('admin_import', [
+ 'step' => 'import',
+ 'shifttype_id' => $shifttype_id,
+ 'add_minutes_end' => $add_minutes_end,
+ 'add_minutes_start' => $add_minutes_start,
+ ])
+ );
+ break;
+
+ case 'import':
+ if (!file_exists($import_file)) {
+ error(_('Missing import file.'));
+ redirect(page_link_to('admin_import'));
+ }
+
+ if (!file_exists($import_file)) {
+ redirect(page_link_to('admin_import'));
+ }
+
+ if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) {
+ $shifttype_id = $request->input('shifttype_id');
+ } else {
+ error(_('Please select a shift type.'));
+ redirect(page_link_to('admin_import'));
+ }
+
+ if ($request->has('add_minutes_start') && is_numeric(trim($request->input('add_minutes_start')))) {
+ $add_minutes_start = trim($request->input('add_minutes_start'));
+ } else {
+ error(_('Please enter an amount of minutes to add to a talk\'s begin.'));
+ redirect(page_link_to('admin_import'));
+ }
+
+ if ($request->has('add_minutes_end') && is_numeric(trim($request->input('add_minutes_end')))) {
+ $add_minutes_end = trim($request->input('add_minutes_end'));
+ } else {
+ error(_('Please enter an amount of minutes to add to a talk\'s end.'));
+ redirect(page_link_to('admin_import'));
+ }
+
+ list($rooms_new, $rooms_deleted) = prepare_rooms($import_file);
+ foreach ($rooms_new as $room) {
+ $result = Room_create($room, true, true);
+
+ $rooms_import[trim($room)] = $result;
+ }
+ foreach ($rooms_deleted as $room) {
+ DB::delete('DELETE FROM `Room` WHERE `Name`=? LIMIT 1', [$room]);
+ }
+
+ list($events_new, $events_updated, $events_deleted) = prepare_events(
+ $import_file,
+ $shifttype_id,
+ $add_minutes_start,
+ $add_minutes_end
+ );
+ foreach ($events_new as $event) {
+ Shift_create($event);
+ }
+
+ foreach ($events_updated as $event) {
+ Shift_update_by_psid($event);
+ }
+
+ foreach ($events_deleted as $event) {
+ Shift_delete_by_psid($event['PSID']);
+ }
+
+ engelsystem_log('Frab import done');
+
+ unlink($import_file);
+
+ $html .= div('well well-sm text-center', [
+ '<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>'
+ . mute(glyph('arrow-right'))
+ . '<span class="text-success">' . _('Validation') . glyph('ok-circle') . '</span>'
+ . mute(glyph('arrow-right'))
+ . '<span class="text-success">' . _('Import') . glyph('ok-circle') . '</span>'
+ ]) . success(_('It\'s done!'), true);
+ break;
+ default:
+ redirect(page_link_to('admin_import'));
}
- }
- $rooms_pb = array_unique($rooms_pb);
-
- $rooms_new = array_diff($rooms_pb, $rooms_db);
- $rooms_deleted = array_diff($rooms_db, $rooms_pb);
-
- return [
- $rooms_new,
- $rooms_deleted
- ];
+
+ return page_with_title(admin_import_title(), [
+ msg(),
+ $html
+ ]);
}
-function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_end) {
- global $rooms_import;
- $data = read_xml($file);
-
- $rooms = sql_select("SELECT * FROM `Room`");
- $rooms_db = [];
- foreach ($rooms as $room) {
- $rooms_db[$room['Name']] = $room['RID'];
- }
-
- $events = $data->vcalendar->vevent;
- $shifts_pb = [];
- foreach ($events as $event) {
- $event_pb = $event->children("http://pentabarf.org");
- $event_id = trim($event_pb->{
- 'event-id' });
- $shifts_pb[$event_id] = [
- 'shifttype_id' => $shifttype_id,
- 'start' => parse_date("Ymd\THis", $event->dtstart) - $add_minutes_start * 60,
- 'end' => parse_date("Ymd\THis", $event->dtend) + $add_minutes_end * 60,
- 'RID' => $rooms_import[trim($event->location)],
- 'title' => trim($event->summary),
- 'URL' => trim($event->url),
- 'PSID' => $event_id
+/**
+ * @param string $file
+ * @return array
+ */
+function prepare_rooms($file)
+{
+ global $rooms_import;
+ $data = read_xml($file);
+
+ // Load rooms from db for compare with input
+ $rooms = DB::select('SELECT `Name`, `RID` FROM `Room` WHERE `FromPentabarf`=\'Y\'');
+ $rooms_db = [];
+ $rooms_import = [];
+ foreach ($rooms as $room) {
+ $rooms_db[] = $room['Name'];
+ $rooms_import[$room['Name']] = $room['RID'];
+ }
+
+ $events = $data->vcalendar->vevent;
+ $rooms_pb = [];
+ foreach ($events as $event) {
+ $rooms_pb[] = (string)$event->location;
+ if (!isset($rooms_import[trim($event->location)])) {
+ $rooms_import[trim($event->location)] = trim($event->location);
+ }
+ }
+ $rooms_pb = array_unique($rooms_pb);
+
+ $rooms_new = array_diff($rooms_pb, $rooms_db);
+ $rooms_deleted = array_diff($rooms_db, $rooms_pb);
+
+ return [
+ $rooms_new,
+ $rooms_deleted
];
- }
-
- $shifts = sql_select("SELECT * FROM `Shifts` WHERE `PSID` IS NOT NULL ORDER BY `start`");
- $shifts_db = [];
- foreach ($shifts as $shift) {
- $shifts_db[$shift['PSID']] = $shift;
- }
-
- $shifts_new = [];
- $shifts_updated = [];
- foreach ($shifts_pb as $shift) {
- if (! isset($shifts_db[$shift['PSID']])) {
- $shifts_new[] = $shift;
- } else {
- $tmp = $shifts_db[$shift['PSID']];
- if ($shift['shifttype_id'] != $tmp['shifttype_id'] || $shift['title'] != $tmp['title'] || $shift['start'] != $tmp['start'] || $shift['end'] != $tmp['end'] || $shift['RID'] != $tmp['RID'] || $shift['URL'] != $tmp['URL']) {
- $shifts_updated[] = $shift;
- }
+}
+
+/**
+ * @param string $file
+ * @param int $shifttype_id
+ * @param int $add_minutes_start
+ * @param int $add_minutes_end
+ * @return array
+ */
+function prepare_events($file, $shifttype_id, $add_minutes_start, $add_minutes_end)
+{
+ global $rooms_import;
+ $data = read_xml($file);
+
+ $rooms = Rooms(true);
+ $rooms_db = [];
+ foreach ($rooms as $room) {
+ $rooms_db[$room['Name']] = $room['RID'];
+ }
+
+ $events = $data->vcalendar->vevent;
+ $shifts_pb = [];
+ foreach ($events as $event) {
+ $event_pb = $event->children('http://pentabarf.org');
+ $event_id = trim($event_pb->{'event-id'});
+ $shifts_pb[$event_id] = [
+ 'shifttype_id' => $shifttype_id,
+ 'start' => parse_date("Ymd\THis", $event->dtstart) - $add_minutes_start * 60,
+ 'end' => parse_date("Ymd\THis", $event->dtend) + $add_minutes_end * 60,
+ 'RID' => $rooms_import[trim($event->location)],
+ 'title' => trim($event->summary),
+ 'URL' => trim($event->url),
+ 'PSID' => $event_id
+ ];
}
- }
-
- $shifts_deleted = [];
- foreach ($shifts_db as $shift) {
- if (! isset($shifts_pb[$shift['PSID']])) {
- $shifts_deleted[] = $shift;
+
+ $shifts = DB::select('SELECT * FROM `Shifts` WHERE `PSID` IS NOT NULL ORDER BY `start`');
+ $shifts_db = [];
+ foreach ($shifts as $shift) {
+ $shifts_db[$shift['PSID']] = $shift;
}
- }
-
- return [
- $shifts_new,
- $shifts_updated,
- $shifts_deleted
- ];
+
+ $shifts_new = [];
+ $shifts_updated = [];
+ foreach ($shifts_pb as $shift) {
+ if (!isset($shifts_db[$shift['PSID']])) {
+ $shifts_new[] = $shift;
+ } else {
+ $tmp = $shifts_db[$shift['PSID']];
+ if (
+ $shift['shifttype_id'] != $tmp['shifttype_id']
+ || $shift['title'] != $tmp['title']
+ || $shift['start'] != $tmp['start']
+ || $shift['end'] != $tmp['end']
+ || $shift['RID'] != $tmp['RID']
+ || $shift['URL'] != $tmp['URL']
+ ) {
+ $shifts_updated[] = $shift;
+ }
+ }
+ }
+
+ $shifts_deleted = [];
+ foreach ($shifts_db as $shift) {
+ if (!isset($shifts_pb[$shift['PSID']])) {
+ $shifts_deleted[] = $shift;
+ }
+ }
+
+ return [
+ $shifts_new,
+ $shifts_updated,
+ $shifts_deleted
+ ];
}
-function read_xml($file) {
- global $xml_import;
- if (! isset($xml_import)) {
- $xml_import = simplexml_load_file($file);
- }
- return $xml_import;
+/**
+ * @param string $file
+ * @return SimpleXMLElement
+ */
+function read_xml($file)
+{
+ global $xml_import;
+ if (!isset($xml_import)) {
+ $xml_import = simplexml_load_file($file);
+ }
+ return $xml_import;
}
-function shifts_printable($shifts, $shifttypes) {
- global $rooms_import;
- $rooms = array_flip($rooms_import);
-
- uasort($shifts, 'shift_sort');
-
- $shifts_printable = [];
- foreach ($shifts as $shift) {
- $shifts_printable[] = [
- 'day' => date("l, Y-m-d", $shift['start']),
- 'start' => date("H:i", $shift['start']),
- 'shifttype' => ShiftType_name_render([
- 'id' => $shift['shifttype_id'],
- 'name' => $shifttypes[$shift['shifttype_id']]
- ]),
- 'title' => shorten($shift['title']),
- 'end' => date("H:i", $shift['end']),
- 'room' => $rooms[$shift['RID']]
- ];
- }
- return $shifts_printable;
+/**
+ * @param array $shifts
+ * @param array $shifttypes
+ * @return array
+ */
+function shifts_printable($shifts, $shifttypes)
+{
+ global $rooms_import;
+ $rooms = array_flip($rooms_import);
+
+ uasort($shifts, 'shift_sort');
+
+ $shifts_printable = [];
+ foreach ($shifts as $shift) {
+ $shifts_printable[] = [
+ 'day' => date('l, Y-m-d', $shift['start']),
+ 'start' => date('H:i', $shift['start']),
+ 'shifttype' => ShiftType_name_render([
+ 'id' => $shift['shifttype_id'],
+ 'name' => $shifttypes[$shift['shifttype_id']]
+ ]),
+ 'title' => shorten($shift['title']),
+ 'end' => date('H:i', $shift['end']),
+ 'room' => $rooms[$shift['RID']]
+ ];
+ }
+ return $shifts_printable;
}
-function shift_sort($shift_a, $shift_b) {
- return ($shift_a['start'] < $shift_b['start']) ? - 1 : 1;
+/**
+ * @param array $shift_a
+ * @param array $shift_b
+ * @return int
+ */
+function shift_sort($shift_a, $shift_b)
+{
+ return ($shift_a['start'] < $shift_b['start']) ? -1 : 1;
}
-?>
diff --git a/includes/pages/admin_log.php b/includes/pages/admin_log.php
index 97b81585..694b1d5a 100644
--- a/includes/pages/admin_log.php
+++ b/includes/pages/admin_log.php
@@ -1,33 +1,38 @@
<?php
-function admin_log_title() {
- return _("Log");
+/**
+ * @return string
+ */
+function admin_log_title()
+{
+ return _('Log');
}
-function admin_log() {
- $filter = "";
- if (isset($_REQUEST['keyword'])) {
- $filter = strip_request_item('keyword');
- }
- $log_entries_source = LogEntries_filter($filter);
-
- $log_entries = [];
- foreach ($log_entries_source as $log_entry) {
- $log_entry['date'] = date("d.m.Y H:i", $log_entry['timestamp']);
- $log_entries[] = $log_entry;
- }
-
- return page_with_title(admin_log_title(), [
- msg(),
- form([
- form_text('keyword', _("Search"), $filter),
- form_submit(_("Search"), "Go")
- ]),
- table([
- 'date' => "Time",
- 'nick' => "Angel",
- 'message' => "Log Entry"
- ], $log_entries)
- ]);
+/**
+ * @return string
+ */
+function admin_log()
+{
+ $filter = '';
+ if (request()->has('keyword')) {
+ $filter = strip_request_item('keyword');
+ }
+ $log_entries = LogEntries_filter($filter);
+
+ foreach ($log_entries as &$log_entry) {
+ $log_entry['date'] = date('d.m.Y H:i', $log_entry['timestamp']);
+ }
+
+ return page_with_title(admin_log_title(), [
+ msg(),
+ form([
+ form_text('keyword', _('Search'), $filter),
+ form_submit(_('Search'), 'Go')
+ ]),
+ table([
+ 'date' => 'Time',
+ 'level' => 'Type',
+ 'message' => 'Log Entry'
+ ], $log_entries)
+ ]);
}
-?>
diff --git a/includes/pages/admin_news.php b/includes/pages/admin_news.php
index 789fc728..eb3a250e 100644
--- a/includes/pages/admin_news.php
+++ b/includes/pages/admin_news.php
@@ -1,67 +1,92 @@
<?php
-function admin_news() {
- global $user;
-
- if (! isset($_GET["action"])) {
- redirect(page_link_to("news"));
- }
-
- $html = '<div class="col-md-12"><h1>' . _("Edit news entry") . '</h1>' . msg();
- if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
- $news_id = $_REQUEST['id'];
- } else {
- return error("Incomplete call, missing News ID.", true);
- }
-
- $news = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
- if (empty($news)) {
- return error("No News found.", true);
- }
- switch ($_REQUEST["action"]) {
- default:
- redirect(page_link_to('news'));
- case 'edit':
- list($news) = $news;
-
- $user_source = User($news['UID']);
-
- $html .= form([
- form_info(_("Date"), date("Y-m-d H:i", $news['Datum'])),
- form_info(_("Author"), User_Nick_render($user_source)),
- form_text('eBetreff', _("Subject"), $news['Betreff']),
- form_textarea('eText', _("Message"), $news['Text']),
- form_checkbox('eTreffen', _("Meeting"), $news['Treffen'] == 1, 1),
- form_submit('submit', _("Save"))
- ], page_link_to('admin_news&action=save&id=' . $news_id));
-
- $html .= '<a class="btn btn-danger" href="' . page_link_to('admin_news&action=delete&id=' . $news_id) . '"><span class="glyphicon glyphicon-trash"></span> ' . _("Delete") . '</a>';
- break;
-
- case 'save':
- list($news) = $news;
-
- sql_query("UPDATE `News` SET
- `Datum`='" . sql_escape(time()) . "',
- `Betreff`='" . sql_escape($_POST["eBetreff"]) . "',
- `Text`='" . sql_escape($_POST["eText"]) . "',
- `UID`='" . sql_escape($user['UID']) . "',
- `Treffen`='" . sql_escape($_POST["eTreffen"]) . "'
- WHERE `ID`='" . sql_escape($news_id) . "'");
- engelsystem_log("News updated: " . $_POST["eBetreff"]);
- success(_("News entry updated."));
- redirect(page_link_to("news"));
- break;
-
- case 'delete':
- list($news) = $news;
-
- sql_query("DELETE FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
- engelsystem_log("News deleted: " . $news['Betreff']);
- success(_("News entry deleted."));
- redirect(page_link_to("news"));
- break;
- }
- return $html . '</div>';
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_news()
+{
+ global $user, $privileges;
+ $request = request();
+
+ if (!$request->has('action')) {
+ redirect(page_link_to('news'));
+ }
+
+ $html = '<div class="col-md-12"><h1>' . _('Edit news entry') . '</h1>' . msg();
+ if ($request->has('id') && preg_match('/^\d{1,11}$/', $request->input('id'))) {
+ $news_id = $request->input('id');
+ } else {
+ return error('Incomplete call, missing News ID.', true);
+ }
+
+ $news = DB::selectOne('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
+ if (empty($news)) {
+ return error('No News found.', true);
+ }
+
+ switch ($request->input('action')) {
+ case 'edit':
+ $user_source = User($news['UID']);
+
+ $html .= form(
+ [
+ form_info(_('Date'), date('Y-m-d H:i', $news['Datum'])),
+ form_info(_('Author'), User_Nick_render($user_source)),
+ form_text('eBetreff', _('Subject'), $news['Betreff']),
+ form_textarea('eText', _('Message'), $news['Text']),
+ form_checkbox('eTreffen', _('Meeting'), $news['Treffen'] == 1, 1),
+ form_submit('submit', _('Save'))
+ ],
+ page_link_to('admin_news', ['action' => 'save', 'id' => $news_id])
+ );
+
+ $html .= '<a class="btn btn-danger" href="'
+ . page_link_to('admin_news', ['action' => 'delete', 'id' => $news_id])
+ . '">'
+ . '<span class="glyphicon glyphicon-trash"></span> ' . _('Delete')
+ . '</a>';
+ break;
+
+ case 'save':
+ $text = $request->postData('eText');
+ if (!in_array('admin_news_html', $privileges)) {
+ $text = strip_tags($text);
+ }
+
+ DB::update('
+ UPDATE `News` SET
+ `Datum`=?,
+ `Betreff`=?,
+ `Text`=?,
+ `UID`=?,
+ `Treffen`=?
+ WHERE `ID`=?
+ ',
+ [
+ time(),
+ strip_tags($request->postData('eBetreff')),
+ $text,
+ $user['UID'],
+ $request->has('eTreffen') ? 1 : 0,
+ $news_id
+ ]
+ );
+
+ engelsystem_log('News updated: ' . $request->postData('eBetreff'));
+ success(_('News entry updated.'));
+ redirect(page_link_to('news'));
+ break;
+
+ case 'delete':
+ DB::delete('DELETE FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
+ engelsystem_log('News deleted: ' . $news['Betreff']);
+ success(_('News entry deleted.'));
+ redirect(page_link_to('news'));
+ break;
+ default:
+ redirect(page_link_to('news'));
+ }
+ return $html . '</div>';
}
-?> \ No newline at end of file
diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php
index f53cfab9..5f2e3a2b 100644
--- a/includes/pages/admin_questions.php
+++ b/includes/pages/admin_questions.php
@@ -1,120 +1,164 @@
<?php
-function admin_questions_title() {
- return _("Answer questions");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_questions_title()
+{
+ return _('Answer questions');
}
/**
* Renders a hint for new questions to answer.
+ *
+ * @return string|null
*/
-function admin_new_questions() {
- global $privileges, $page;
-
- if ($page != "admin_questions") {
- if (in_array("admin_questions", $privileges)) {
- $new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID` IS NULL");
-
- if ($new_messages > 0) {
- return '<a href="' . page_link_to("admin_questions") . '">' . _('There are unanswered questions!') . '</a>';
- }
+function admin_new_questions()
+{
+ global $privileges, $page;
+
+ if ($page != 'admin_questions') {
+ if (in_array('admin_questions', $privileges)) {
+ $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 null;
+
+ return null;
}
-function admin_questions() {
- global $user;
-
- if (! isset($_REQUEST['action'])) {
- $unanswered_questions_table = [];
- $questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL");
- foreach ($questions as $question) {
- $user_source = User($question['UID']);
-
- $unanswered_questions_table[] = [
- 'from' => User_Nick_render($user_source),
- 'question' => str_replace("\n", "<br />", $question['Question']),
- 'answer' => form([
- form_textarea('answer', '', ''),
- form_submit('submit', _("Save"))
- ], page_link_to('admin_questions') . '&action=answer&id=' . $question['QID']),
- 'actions' => button(page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'], _("delete"), 'btn-xs')
- ];
- }
-
- $answered_questions_table = [];
- $questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL");
- foreach ($questions as $question) {
- $user_source = User($question['UID']);
- $answer_user_source = User($question['AID']);
- $answered_questions_table[] = [
- 'from' => User_Nick_render($user_source),
- 'question' => str_replace("\n", "<br />", $question['Question']),
- 'answered_by' => User_Nick_render($answer_user_source),
- 'answer' => str_replace("\n", "<br />", $question['Answer']),
- 'actions' => button(page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'], _("delete"), 'btn-xs')
- ];
- }
-
- return page_with_title(admin_questions_title(), [
- '<h2>' . _("Unanswered questions") . '</h2>',
- table([
- 'from' => _("From"),
- 'question' => _("Question"),
- 'answer' => _("Answer"),
- 'actions' => ''
- ], $unanswered_questions_table),
- '<h2>' . _("Answered questions") . '</h2>',
- table([
- 'from' => _("From"),
- 'question' => _("Question"),
- 'answered_by' => _("Answered by"),
- 'answer' => _("Answer"),
- 'actions' => ''
- ], $answered_questions_table)
- ]);
- } else {
- switch ($_REQUEST['action']) {
- case 'answer':
- if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
- $question_id = $_REQUEST['id'];
- } else {
- return error("Incomplete call, missing Question ID.", true);
- }
-
- $question = sql_select("SELECT * FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
- if (count($question) > 0 && $question[0]['AID'] == null) {
- $answer = trim(preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['answer'])));
-
- if ($answer != "") {
- sql_query("UPDATE `Questions` SET `AID`='" . sql_escape($user['UID']) . "', `Answer`='" . sql_escape($answer) . "' WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
- engelsystem_log("Question " . $question[0]['Question'] . " answered: " . $answer);
- redirect(page_link_to("admin_questions"));
- } else {
- return error("Enter an answer!", true);
- }
- } else {
- return error("No question found.", true);
+/**
+ * @return string
+ */
+function admin_questions()
+{
+ global $user;
+ $request = request();
+
+ if (!$request->has('action')) {
+ $unanswered_questions_table = [];
+ $questions = DB::select('SELECT * FROM `Questions` WHERE `AID` IS NULL');
+ foreach ($questions as $question) {
+ $user_source = User($question['UID']);
+
+ $unanswered_questions_table[] = [
+ 'from' => User_Nick_render($user_source),
+ 'question' => str_replace("\n", '<br />', $question['Question']),
+ 'answer' => form([
+ form_textarea('answer', '', ''),
+ form_submit('submit', _('Save'))
+ ], page_link_to('admin_questions', ['action' => 'answer', 'id' => $question['QID']])),
+ 'actions' => button(
+ page_link_to('admin_questions', ['action' => 'delete', 'id' => $question['QID']]),
+ _('delete'),
+ 'btn-xs'
+ )
+ ];
}
- break;
- case 'delete':
- if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
- $question_id = $_REQUEST['id'];
- } else {
- return error("Incomplete call, missing Question ID.", true);
+
+ $answered_questions_table = [];
+ $questions = DB::select('SELECT * FROM `Questions` WHERE NOT `AID` IS NULL');
+ foreach ($questions as $question) {
+ $user_source = User($question['UID']);
+ $answer_user_source = User($question['AID']);
+ $answered_questions_table[] = [
+ 'from' => User_Nick_render($user_source),
+ 'question' => str_replace("\n", '<br />', $question['Question']),
+ 'answered_by' => User_Nick_render($answer_user_source),
+ 'answer' => str_replace("\n", '<br />', $question['Answer']),
+ 'actions' => button(
+ page_link_to('admin_questions', ['action' => 'delete', 'id' => $question['QID']]),
+ _('delete'),
+ 'btn-xs'
+ )
+ ];
}
-
- $question = sql_select("SELECT * FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
- if (count($question) > 0) {
- sql_query("DELETE FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
- engelsystem_log("Question deleted: " . $question[0]['Question']);
- redirect(page_link_to("admin_questions"));
- } else {
- return error("No question found.", true);
+
+ return page_with_title(admin_questions_title(), [
+ '<h2>' . _('Unanswered questions') . '</h2>',
+ table([
+ 'from' => _('From'),
+ 'question' => _('Question'),
+ 'answer' => _('Answer'),
+ 'actions' => ''
+ ], $unanswered_questions_table),
+ '<h2>' . _('Answered questions') . '</h2>',
+ table([
+ 'from' => _('From'),
+ 'question' => _('Question'),
+ 'answered_by' => _('Answered by'),
+ 'answer' => _('Answer'),
+ 'actions' => ''
+ ], $answered_questions_table)
+ ]);
+ } else {
+ switch ($request->input('action')) {
+ case 'answer':
+ if ($request->has('id') && preg_match('/^\d{1,11}$/', $request->input('id'))) {
+ $question_id = $request->input('id');
+ } else {
+ return error('Incomplete call, missing Question ID.', true);
+ }
+
+ $question = DB::selectOne(
+ 'SELECT * FROM `Questions` WHERE `QID`=? LIMIT 1',
+ [$question_id]
+ );
+ if (!empty($question) && $question['AID'] == null) {
+ $answer = trim(
+ preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui",
+ '',
+ strip_tags($request->input('answer'))
+ ));
+
+ if ($answer != '') {
+ DB::update('
+ UPDATE `Questions`
+ SET `AID`=?, `Answer`=?
+ WHERE `QID`=?
+ LIMIT 1
+ ',
+ [
+ $user['UID'],
+ $answer,
+ $question_id,
+ ]
+ );
+ engelsystem_log('Question ' . $question['Question'] . ' answered: ' . $answer);
+ redirect(page_link_to('admin_questions'));
+ } else {
+ return error('Enter an answer!', true);
+ }
+ } else {
+ return error('No question found.', true);
+ }
+ break;
+ case 'delete':
+ if ($request->has('id') && preg_match('/^\d{1,11}$/', $request->input('id'))) {
+ $question_id = $request->input('id');
+ } else {
+ return error('Incomplete call, missing Question ID.', true);
+ }
+
+ $question = DB::selectOne(
+ 'SELECT * FROM `Questions` WHERE `QID`=? LIMIT 1',
+ [$question_id]
+ );
+ if (!empty($question)) {
+ DB::delete('DELETE FROM `Questions` WHERE `QID`=? LIMIT 1', [$question_id]);
+ engelsystem_log('Question deleted: ' . $question['Question']);
+ redirect(page_link_to('admin_questions'));
+ } else {
+ return error('No question found.', true);
+ }
+ break;
}
- break;
}
- }
+
+ return '';
}
-?>
diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php
index 129ed423..9e153bf1 100644
--- a/includes/pages/admin_rooms.php
+++ b/includes/pages/admin_rooms.php
@@ -1,196 +1,247 @@
<?php
-function admin_rooms_title() {
- return _("Rooms");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_rooms_title()
+{
+ return _('Rooms');
}
-function admin_rooms() {
- $rooms_source = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
- $rooms = [];
- foreach ($rooms_source as $room) {
- $rooms[] = [
- 'name' => Room_name_render($room),
- 'from_pentabarf' => $room['FromPentabarf'] == 'Y' ? '&#10003;' : '',
- 'public' => $room['show'] == 'Y' ? '&#10003;' : '',
- '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;
-
- if (isset($_REQUEST['show'])) {
- $msg = "";
- $name = "";
- $from_pentabarf = "";
- $public = 'Y';
- $number = "";
-
- $angeltypes_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
- $angeltypes = [];
- $angeltypes_count = [];
- foreach ($angeltypes_source as $angeltype) {
- $angeltypes[$angeltype['id']] = $angeltype['name'];
- $angeltypes_count[$angeltype['id']] = 0;
- }
-
- if (test_request_int('id')) {
- $room = Room($_REQUEST['id']);
- if ($room === false) {
- engelsystem_error("Unable to load room.");
- }
- if ($room == null) {
- redirect(page_link_to('admin_rooms'));
- }
-
- $room_id = $_REQUEST['id'];
- $name = $room['Name'];
- $from_pentabarf = $room['FromPentabarf'];
- $public = $room['show'];
- $number = $room['Number'];
-
- $needed_angeltypes = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($room_id) . "'");
- foreach ($needed_angeltypes as $needed_angeltype) {
- $angeltypes_count[$needed_angeltype['angel_type_id']] = $needed_angeltype['count'];
- }
+/**
+ * @return string
+ */
+function admin_rooms()
+{
+ $rooms_source = DB::select('SELECT * FROM `Room` ORDER BY `Name`');
+ $rooms = [];
+ $request = request();
+
+ foreach ($rooms_source as $room) {
+ $rooms[] = [
+ 'name' => Room_name_render($room),
+ 'from_pentabarf' => glyph_bool($room['FromPentabarf'] == 'Y'),
+ 'public' => glyph_bool($room['show'] == 'Y'),
+ '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')
+ ])
+ ];
}
-
- if ($_REQUEST['show'] == 'edit') {
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (isset($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) {
- $name = strip_request_item('name');
- if (isset($room) && sql_num_query("SELECT * FROM `Room` WHERE `Name`='" . sql_escape($name) . "' AND NOT `RID`=" . sql_escape($room_id)) > 0) {
- $valid = false;
- $msg .= error(_("This name is already in use."), true);
- }
- } else {
- $valid = false;
- $msg .= error(_("Please enter a name."), true);
- }
-
- if (isset($_REQUEST['from_pentabarf'])) {
- $from_pentabarf = 'Y';
- } else {
- $from_pentabarf = '';
- }
-
- if (isset($_REQUEST['public'])) {
- $public = 'Y';
- } else {
- $public = '';
- }
-
- if (isset($_REQUEST['number'])) {
- $number = strip_request_item('number');
- } else {
- $valid = false;
- }
-
- foreach ($angeltypes as $angeltype_id => $angeltype) {
- if (isset($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}$/", $_REQUEST['angeltype_count_' . $angeltype_id])) {
- $angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
- } else {
- $valid = false;
- $msg .= error(sprintf(_("Please enter needed angels for type %s.", $angeltype)), true);
- }
+ $room = null;
+
+ if ($request->has('show')) {
+ $msg = '';
+ $name = '';
+ $from_pentabarf = '';
+ $public = 'Y';
+ $number = '';
+ $room_id = 0;
+
+ $angeltypes_source = DB::select('SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name`');
+ $angeltypes = [];
+ $angeltypes_count = [];
+ foreach ($angeltypes_source as $angeltype) {
+ $angeltypes[$angeltype['id']] = $angeltype['name'];
+ $angeltypes_count[$angeltype['id']] = 0;
}
-
- if ($valid) {
- if (isset($room_id)) {
- sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`='" . sql_escape($room_id) . "' LIMIT 1");
- engelsystem_log("Room updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
- } else {
- $room_id = Room_create($name, $from_pentabarf, $public, $number);
- if ($room_id === false) {
- engelsystem_error("Unable to create room.");
+
+ if (test_request_int('id')) {
+ $room = Room($request->input('id'), false);
+ if ($room == null) {
+ redirect(page_link_to('admin_rooms'));
}
- engelsystem_log("Room created: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);
- }
-
- NeededAngelTypes_delete_by_room($room_id);
- $needed_angeltype_info = [];
- foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
- $angeltype = AngelType($angeltype_id);
- if ($angeltype != null) {
- NeededAngelType_add(null, $angeltype_id, $room_id, $angeltype_count);
- $needed_angeltype_info[] = $angeltype['name'] . ": " . $angeltype_count;
+
+ $room_id = $request->input('id');
+ $name = $room['Name'];
+ $from_pentabarf = $room['FromPentabarf'];
+ $public = $room['show'];
+ $number = $room['Number'];
+
+ $needed_angeltypes = DB::select(
+ 'SELECT `angel_type_id`, `count` FROM `NeededAngelTypes` WHERE `room_id`=?',
+ [$room_id]
+ );
+ foreach ($needed_angeltypes as $needed_angeltype) {
+ $angeltypes_count[$needed_angeltype['angel_type_id']] = $needed_angeltype['count'];
}
- }
-
- engelsystem_log("Set needed angeltypes of room " . $name . " to: " . join(", ", $needed_angeltype_info));
- success(_("Room saved."));
- redirect(page_link_to("admin_rooms"));
}
- }
- $angeltypes_count_form = [];
- foreach ($angeltypes as $angeltype_id => $angeltype) {
- $angeltypes_count_form[] = div('col-lg-4 col-md-6 col-xs-6', [
- form_spinner('angeltype_count_' . $angeltype_id, $angeltype, $angeltypes_count[$angeltype_id])
- ]);
- }
-
- return page_with_title(admin_rooms_title(), [
- buttons([
- button(page_link_to('admin_rooms'), _("back"), 'back')
- ]),
- $msg,
- form([
- div('row', [
- div('col-md-6', [
- form_text('name', _("Name"), $name),
- form_checkbox('from_pentabarf', _("Frab import"), $from_pentabarf),
- form_checkbox('public', _("Public"), $public),
- form_text('number', _("Room number"), $number)
- ]),
- div('col-md-6', [
- div('row', [
- div('col-md-12', [
- form_info(_("Needed angels:"))
- ]),
- join($angeltypes_count_form)
- ])
- ])
- ]),
- form_submit('submit', _("Save"))
- ])
- ]);
- } elseif ($_REQUEST['show'] == 'delete') {
- if (isset($_REQUEST['ack'])) {
- if (! Room_delete($room_id)) {
- engelsystem_error("Unable to delete room.");
+
+ if ($request->input('show') == 'edit') {
+ if ($request->has('submit')) {
+ $valid = true;
+
+ if ($request->has('name') && strlen(strip_request_item('name')) > 0) {
+ $name = strip_request_item('name');
+ if (
+ isset($room)
+ && count(DB::select(
+ 'SELECT RID FROM `Room` WHERE `Name`=? AND NOT `RID`=?',
+ [$name, $room_id]
+ )) > 0
+ ) {
+ $valid = false;
+ $msg .= error(_('This name is already in use.'), true);
+ }
+ } else {
+ $valid = false;
+ $msg .= error(_('Please enter a name.'), true);
+ }
+
+ $from_pentabarf = '';
+ if ($request->has('from_pentabarf')) {
+ $from_pentabarf = 'Y';
+ }
+
+ $public = '';
+ if ($request->has('public')) {
+ $public = 'Y';
+ }
+
+ if ($request->has('number')) {
+ $number = strip_request_item('number');
+ } else {
+ $valid = false;
+ }
+
+ foreach ($angeltypes as $angeltype_id => $angeltype) {
+ $angeltypes_count[$angeltype_id] = 0;
+ $queryKey = 'angeltype_count_' . $angeltype_id;
+ if (!$request->has($queryKey)) {
+ continue;
+ }
+
+ if (preg_match('/^\d{1,4}$/', $request->input($queryKey))) {
+ $angeltypes_count[$angeltype_id] = $request->input($queryKey);
+ } else {
+ $valid = false;
+ $msg .= error(sprintf(_('Please enter needed angels for type %s.'), $angeltype), true);
+ }
+ }
+
+ if ($valid) {
+ if (!empty($room_id)) {
+ DB::update('
+ UPDATE `Room`
+ SET
+ `Name`=?,
+ `FromPentabarf`=?,
+ `show`=?,
+ `Number`=?
+ WHERE `RID`=?
+ LIMIT 1
+ ', [
+ $name,
+ $from_pentabarf,
+ $public,
+ $number,
+ $room_id,
+ ]);
+ engelsystem_log(
+ 'Room updated: ' . $name
+ . ', pentabarf import: ' . $from_pentabarf
+ . ', public: ' . $public
+ . ', number: ' . $number
+ );
+ } else {
+ $room_id = Room_create($name, $from_pentabarf, $public, $number);
+
+ engelsystem_log(
+ 'Room created: ' . $name
+ . ', pentabarf import: '
+ . $from_pentabarf
+ . ', public: ' . $public
+ . ', number: ' . $number
+ );
+ }
+
+ NeededAngelTypes_delete_by_room($room_id);
+ $needed_angeltype_info = [];
+ foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
+ $angeltype = AngelType($angeltype_id);
+ if ($angeltype != null) {
+ NeededAngelType_add(null, $angeltype_id, $room_id, $angeltype_count);
+ $needed_angeltype_info[] = $angeltype['name'] . ': ' . $angeltype_count;
+ }
+ }
+
+ engelsystem_log(
+ 'Set needed angeltypes of room ' . $name
+ . ' to: ' . join(', ', $needed_angeltype_info)
+ );
+ success(_('Room saved.'));
+ redirect(page_link_to('admin_rooms'));
+ }
+ }
+ $angeltypes_count_form = [];
+ foreach ($angeltypes as $angeltype_id => $angeltype) {
+ $angeltypes_count_form[] = div('col-lg-4 col-md-6 col-xs-6', [
+ form_spinner('angeltype_count_' . $angeltype_id, $angeltype, $angeltypes_count[$angeltype_id])
+ ]);
+ }
+
+ return page_with_title(admin_rooms_title(), [
+ buttons([
+ button(page_link_to('admin_rooms'), _('back'), 'back')
+ ]),
+ $msg,
+ form([
+ div('row', [
+ div('col-md-6', [
+ form_text('name', _('Name'), $name),
+ form_checkbox('from_pentabarf', _('Frab import'), $from_pentabarf),
+ form_checkbox('public', _('Public'), $public),
+ form_text('number', _('Room number'), $number)
+ ]),
+ div('col-md-6', [
+ div('row', [
+ div('col-md-12', [
+ form_info(_('Needed angels:'))
+ ]),
+ join($angeltypes_count_form)
+ ])
+ ])
+ ]),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
+ } elseif ($request->input('show') == 'delete') {
+ if ($request->has('ack')) {
+ Room_delete($room_id);
+
+ engelsystem_log('Room deleted: ' . $name);
+ success(sprintf(_('Room %s deleted.'), $name));
+ redirect(page_link_to('admin_rooms'));
+ }
+
+ return page_with_title(admin_rooms_title(), [
+ buttons([
+ button(page_link_to('admin_rooms'), _('back'), 'back')
+ ]),
+ sprintf(_('Do you want to delete room %s?'), $name),
+ buttons([
+ button(
+ page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room_id, 'ack' => 1]),
+ _('Delete'),
+ 'delete btn-danger'
+ )
+ ])
+ ]);
}
-
- engelsystem_log("Room deleted: " . $name);
- success(sprintf(_("Room %s deleted."), $name));
- redirect(page_link_to('admin_rooms'));
- }
-
- return page_with_title(admin_rooms_title(), [
- buttons([
- button(page_link_to('admin_rooms'), _("back"), 'back')
- ]),
- sprintf(_("Do you want to delete room %s?"), $name),
- buttons([
- button(page_link_to('admin_rooms') . '&show=delete&id=' . $room_id . '&ack', _("Delete"), 'delete')
- ])
- ]);
}
- }
-
- return page_with_title(admin_rooms_title(), [
- buttons([
- button(page_link_to('admin_rooms') . '&show=edit', _("add"))
- ]),
- msg(),
- table([
- 'name' => _("Name"),
- 'from_pentabarf' => _("Frab import"),
- 'public' => _("Public"),
- 'actions' => ""
- ], $rooms)
- ]);
+
+ return page_with_title(admin_rooms_title(), [
+ buttons([
+ button(page_link_to('admin_rooms', ['show' => 'edit']), _('add'))
+ ]),
+ msg(),
+ table([
+ 'name' => _('Name'),
+ 'from_pentabarf' => _('Frab import'),
+ 'public' => _('Public'),
+ 'actions' => ''
+ ], $rooms)
+ ]);
}
-?>
diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php
index 42a8c682..721d0f4f 100644
--- a/includes/pages/admin_shifts.php
+++ b/includes/pages/admin_shifts.php
@@ -1,346 +1,411 @@
<?php
-function admin_shifts_title() {
- return _("Create shifts");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_shifts_title()
+{
+ return _('Create shifts');
}
-// Assistent zum Anlegen mehrerer neuer Schichten
-function admin_shifts() {
- $valid = true;
-
- $rid = 0;
- $start = parse_date("Y-m-d H:i", date("Y-m-d") . " 00:00");
- $end = $start;
- $mode = 'single';
- $angelmode = 'manually';
- $length = '';
- $change_hours = [];
- $title = "";
- $shifttype_id = null;
-
- // Locations laden (auch unsichtbare - fuer Erzengel ist das ok)
- $rooms = sql_select("SELECT * FROM `Room` ORDER BY `Name`");
- $room_array = [];
- foreach ($rooms as $room) {
- $room_array[$room['RID']] = $room['Name'];
- }
-
- // Engeltypen laden
- $types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
- $needed_angel_types = [];
- foreach ($types as $type) {
- $needed_angel_types[$type['id']] = 0;
- }
-
- // Load shift types
- $shifttypes_source = ShiftTypes();
- if ($shifttypes_source === false) {
- engelsystem_error('Unable to load shift types.');
- }
- $shifttypes = [];
- foreach ($shifttypes_source as $shifttype) {
- $shifttypes[$shifttype['id']] = $shifttype['name'];
- }
-
- if (isset($_REQUEST['preview']) || isset($_REQUEST['back'])) {
- if (isset($_REQUEST['shifttype_id'])) {
- $shifttype = ShiftType($_REQUEST['shifttype_id']);
- if ($shifttype === false) {
- engelsystem_error('Unable to load shift type.');
- }
- if ($shifttype == null) {
- $valid = false;
- error(_('Please select a shift type.'));
- } else {
- $shifttype_id = $_REQUEST['shifttype_id'];
- }
- } else {
- $valid = false;
- error(_('Please select a shift type.'));
- }
-
- // Name/Bezeichnung der Schicht, darf leer sein
- $title = strip_request_item('title');
-
- // Auswahl der sichtbaren Locations für die Schichten
- if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room_array[$_REQUEST['rid']])) {
- $rid = $_REQUEST['rid'];
- } else {
- $valid = false;
- $rid = $rooms[0]['RID'];
- error(_('Please select a location.'));
- }
-
- if (isset($_REQUEST['start']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['start'])) {
- $start = $tmp;
- } else {
- $valid = false;
- error(_('Please select a start time.'));
+/**
+ * Assistent zum Anlegen mehrerer neuer Schichten
+ *
+ * @return string
+ */
+function admin_shifts()
+{
+ $valid = true;
+ $request = request();
+ $session = session();
+ $start = parse_date('Y-m-d H:i', date('Y-m-d') . ' 00:00');
+ $end = $start;
+ $mode = 'single';
+ $angelmode = 'manually';
+ $length = '';
+ $change_hours = [];
+ $title = '';
+ $shifttype_id = null;
+
+ // Locations laden (auch unsichtbare - fuer Erzengel ist das ok)
+ $rooms = DB::select('SELECT `RID`, `Name` FROM `Room` ORDER BY `Name`');
+ $room_array = [];
+ foreach ($rooms as $room) {
+ $room_array[$room['RID']] = $room['Name'];
}
-
- if (isset($_REQUEST['end']) && $tmp = parse_date("Y-m-d H:i", $_REQUEST['end'])) {
- $end = $tmp;
- } else {
- $valid = false;
- error(_('Please select an end time.'));
+
+ // Engeltypen laden
+ $types = DB::select('SELECT * FROM `AngelTypes` ORDER BY `name`');
+ $needed_angel_types = [];
+ foreach ($types as $type) {
+ $needed_angel_types[$type['id']] = 0;
}
-
- if ($start >= $end) {
- $valid = false;
- error(_('The shifts end has to be after its start.'));
+
+ // Load shift types
+ $shifttypes_source = ShiftTypes();
+ $shifttypes = [];
+ foreach ($shifttypes_source as $shifttype) {
+ $shifttypes[$shifttype['id']] = $shifttype['name'];
}
-
- if (isset($_REQUEST['mode'])) {
- if ($_REQUEST['mode'] == 'single') {
- $mode = 'single';
- } elseif ($_REQUEST['mode'] == 'multi') {
- if (isset($_REQUEST['length']) && preg_match("/^[0-9]+$/", trim($_REQUEST['length']))) {
- $mode = 'multi';
- $length = trim($_REQUEST['length']);
+
+ if ($request->has('preview') || $request->has('back')) {
+ if ($request->has('shifttype_id')) {
+ $shifttype = ShiftType($request->input('shifttype_id'));
+ if ($shifttype == null) {
+ $valid = false;
+ error(_('Please select a shift type.'));
+ } else {
+ $shifttype_id = $request->input('shifttype_id');
+ }
} else {
- $valid = false;
- error(_('Please enter a shift duration in minutes.'));
+ $valid = false;
+ error(_('Please select a shift type.'));
}
- } elseif ($_REQUEST['mode'] == 'variable') {
- if (isset($_REQUEST['change_hours']) && preg_match("/^([0-9]{2}(,|$))/", trim(str_replace(" ", "", $_REQUEST['change_hours'])))) {
- $mode = 'variable';
- $change_hours = array_map('trim', explode(",", $_REQUEST['change_hours']));
+
+ // Name/Bezeichnung der Schicht, darf leer sein
+ $title = strip_request_item('title');
+
+ // Auswahl der sichtbaren Locations für die Schichten
+ if (
+ $request->has('rid')
+ && preg_match('/^\d+$/', $request->input('rid'))
+ && isset($room_array[$request->input('rid')])
+ ) {
+ $rid = $request->input('rid');
} else {
- $valid = false;
- error(_('Please split the shift-change hours by colons.'));
+ $valid = false;
+ $rid = $rooms[0]['RID'];
+ error(_('Please select a location.'));
}
- }
- } else {
- $valid = false;
- error(_('Please select a mode.'));
- }
-
- if (isset($_REQUEST['angelmode'])) {
- if ($_REQUEST['angelmode'] == 'location') {
- $angelmode = 'location';
- } elseif ($_REQUEST['angelmode'] == 'manually') {
- $angelmode = 'manually';
- foreach ($types as $type) {
- if (isset($_REQUEST['type_' . $type['id']]) && preg_match("/^[0-9]+$/", trim($_REQUEST['type_' . $type['id']]))) {
- $needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]);
- } else {
+
+ if ($request->has('start') && $tmp = parse_date('Y-m-d H:i', $request->input('start'))) {
+ $start = $tmp;
+ } else {
$valid = false;
- error(sprintf(_('Please check the needed angels for team %s.'), $type['name']));
- }
+ error(_('Please select a start time.'));
}
- if (array_sum($needed_angel_types) == 0) {
- $valid = false;
- error(_('There are 0 angels needed. Please enter the amounts of needed angels.'));
+
+ if ($request->has('end') && $tmp = parse_date('Y-m-d H:i', $request->input('end'))) {
+ $end = $tmp;
+ } else {
+ $valid = false;
+ error(_('Please select an end time.'));
}
- } else {
- $valid = false;
- error(_('Please select a mode for needed angels.'));
- }
- } else {
- $valid = false;
- error(_('Please select needed angels.'));
- }
-
- // Beim Zurück-Knopf das Formular zeigen
- if (isset($_REQUEST['back'])) {
- $valid = false;
- }
-
- // Alle Eingaben in Ordnung
- if ($valid) {
- if ($angelmode == 'location') {
- $needed_angel_types = [];
- $needed_angel_types_location = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($rid) . "'");
- foreach ($needed_angel_types_location as $type) {
- $needed_angel_types[$type['angel_type_id']] = $type['count'];
+
+ if ($start >= $end) {
+ $valid = false;
+ error(_('The shifts end has to be after its start.'));
}
- }
- $shifts = [];
- if ($mode == 'single') {
- $shifts[] = [
- 'start' => $start,
- 'end' => $end,
- 'RID' => $rid,
- 'title' => $title,
- 'shifttype_id' => $shifttype_id
- ];
- } elseif ($mode == 'multi') {
- $shift_start = $start;
- do {
- $shift_end = $shift_start + $length * 60;
-
- if ($shift_end > $end) {
- $shift_end = $end;
- }
- if ($shift_start >= $shift_end) {
- break;
- }
-
- $shifts[] = [
- 'start' => $shift_start,
- 'end' => $shift_end,
- 'RID' => $rid,
- 'title' => $title,
- 'shifttype_id' => $shifttype_id
- ];
-
- $shift_start = $shift_end;
- } while ($shift_end < $end);
- } elseif ($mode == 'variable') {
- rsort($change_hours);
- $day = parse_date("Y-m-d H:i", date("Y-m-d", $start) . " 00:00");
- $change_index = 0;
- // Ersten/nächsten passenden Schichtwechsel suchen
- foreach ($change_hours as $i => $change_hour) {
- if ($start < $day + $change_hour * 60 * 60) {
- $change_index = $i;
- } elseif ($start == $day + $change_hour * 60 * 60) {
- // Start trifft Schichtwechsel
- $change_index = ($i + count($change_hours) - 1) % count($change_hours);
- break;
- } else {
- break;
- }
+
+ if ($request->has('mode')) {
+ if ($request->input('mode') == 'single') {
+ $mode = 'single';
+ } elseif ($request->input('mode') == 'multi') {
+ if ($request->has('length') && preg_match('/^\d+$/', trim($request->input('length')))) {
+ $mode = 'multi';
+ $length = trim($request->input('length'));
+ } else {
+ $valid = false;
+ error(_('Please enter a shift duration in minutes.'));
+ }
+ } elseif ($request->input('mode') == 'variable') {
+ if (
+ $request->has('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')));
+ } else {
+ $valid = false;
+ error(_('Please split the shift-change hours by colons.'));
+ }
+ }
+ } else {
+ $valid = false;
+ error(_('Please select a mode.'));
}
-
- $shift_start = $start;
- do {
- $day = parse_date("Y-m-d H:i", date("Y-m-d", $shift_start) . " 00:00");
- $shift_end = $day + $change_hours[$change_index] * 60 * 60;
-
- if ($shift_end > $end) {
- $shift_end = $end;
- }
- if ($shift_start >= $shift_end) {
- $shift_end += 24 * 60 * 60;
- }
-
- $shifts[] = [
- 'start' => $shift_start,
- 'end' => $shift_end,
- 'RID' => $rid,
- 'title' => $title,
- 'shifttype_id' => $shifttype_id
- ];
-
- $shift_start = $shift_end;
- $change_index = ($change_index + count($change_hours) - 1) % count($change_hours);
- } while ($shift_end < $end);
- }
-
- $shifts_table = [];
- foreach ($shifts as $shift) {
- $shifts_table_entry = [
- 'timeslot' => '<span class="glyphicon glyphicon-time"></span> ' . date("Y-m-d H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . '<br />' . Room_name_render(Room($shift['RID'])),
- 'title' => ShiftType_name_render(ShiftType($shifttype_id)) . ($shift['title'] ? '<br />' . $shift['title'] : ''),
- 'needed_angels' => ''
- ];
- 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 />';
- }
+
+ if ($request->has('angelmode')) {
+ if ($request->input('angelmode') == 'location') {
+ $angelmode = 'location';
+ } elseif ($request->input('angelmode') == 'manually') {
+ $angelmode = 'manually';
+ foreach ($types as $type) {
+ if (preg_match('/^\d+$/', trim($request->input('type_' . $type['id'], 0)))) {
+ $needed_angel_types[$type['id']] = trim($request->input('type_' . $type['id'], 0));
+ } else {
+ $valid = false;
+ error(sprintf(_('Please check the needed angels for team %s.'), $type['name']));
+ }
+ }
+
+ if (array_sum($needed_angel_types) == 0) {
+ $valid = false;
+ error(_('There are 0 angels needed. Please enter the amounts of needed angels.'));
+ }
+ } else {
+ $valid = false;
+ error(_('Please select a mode for needed angels.'));
+ }
+ } else {
+ $valid = false;
+ error(_('Please select needed angels.'));
}
- $shifts_table[] = $shifts_table_entry;
- }
-
- // Fürs Anlegen zwischenspeichern:
- $_SESSION['admin_shifts_shifts'] = $shifts;
- $_SESSION['admin_shifts_types'] = $needed_angel_types;
-
- $hidden_types = "";
- foreach ($needed_angel_types as $type_id => $count) {
- $hidden_types .= form_hidden('type_' . $type_id, $count);
- }
- return page_with_title(_("Preview"), [
- form([
- $hidden_types,
- form_hidden('shifttype_id', $shifttype_id),
- form_hidden('title', $title),
- form_hidden('rid', $rid),
- form_hidden('start', date("Y-m-d H:i", $start)),
- form_hidden('end', date("Y-m-d H:i", $end)),
- form_hidden('mode', $mode),
- form_hidden('length', $length),
- form_hidden('change_hours', implode(', ', $change_hours)),
- form_hidden('angelmode', $angelmode),
- form_submit('back', _("back")),
- table([
- 'timeslot' => _('Time and location'),
- 'title' => _('Type and title'),
- 'needed_angels' => _('Needed angels')
- ], $shifts_table),
- form_submit('submit', _("Save"))
- ])
- ]);
+
+ // Beim Zurück-Knopf das Formular zeigen
+ if ($request->has('back')) {
+ $valid = false;
+ }
+
+ // Alle Eingaben in Ordnung
+ if ($valid) {
+ if ($angelmode == 'location') {
+ $needed_angel_types = [];
+ $needed_angel_types_location = DB::select('
+ SELECT `angel_type_id`, `count`
+ FROM `NeededAngelTypes`
+ WHERE `room_id`=?
+ ',
+ [$rid]
+ );
+ foreach ($needed_angel_types_location as $type) {
+ $needed_angel_types[$type['angel_type_id']] = $type['count'];
+ }
+ }
+ $shifts = [];
+ if ($mode == 'single') {
+ $shifts[] = [
+ 'start' => $start,
+ 'end' => $end,
+ 'RID' => $rid,
+ 'title' => $title,
+ 'shifttype_id' => $shifttype_id
+ ];
+ } elseif ($mode == 'multi') {
+ $shift_start = (int)$start;
+ do {
+ $shift_end = $shift_start + (int)$length * 60;
+
+ if ($shift_end > $end) {
+ $shift_end = $end;
+ }
+ if ($shift_start >= $shift_end) {
+ break;
+ }
+
+ $shifts[] = [
+ 'start' => $shift_start,
+ 'end' => $shift_end,
+ 'RID' => $rid,
+ 'title' => $title,
+ 'shifttype_id' => $shifttype_id
+ ];
+
+ $shift_start = $shift_end;
+ } while ($shift_end < $end);
+ } elseif ($mode == 'variable') {
+ rsort($change_hours);
+ $day = parse_date('Y-m-d H:i', date('Y-m-d', $start) . ' 00:00');
+ $change_index = 0;
+ // Ersten/nächsten passenden Schichtwechsel suchen
+ foreach ($change_hours as $i => $change_hour) {
+ if ($start < $day + $change_hour * 60 * 60) {
+ $change_index = $i;
+ } elseif ($start == $day + $change_hour * 60 * 60) {
+ // Start trifft Schichtwechsel
+ $change_index = ($i + count($change_hours) - 1) % count($change_hours);
+ break;
+ } else {
+ break;
+ }
+ }
+
+ $shift_start = $start;
+ do {
+ $day = parse_date('Y-m-d H:i', date('Y-m-d', $shift_start) . ' 00:00');
+ $shift_end = $day + $change_hours[$change_index] * 60 * 60;
+
+ if ($shift_end > $end) {
+ $shift_end = $end;
+ }
+ if ($shift_start >= $shift_end) {
+ $shift_end += 24 * 60 * 60;
+ }
+
+ $shifts[] = [
+ 'start' => $shift_start,
+ 'end' => $shift_end,
+ 'RID' => $rid,
+ 'title' => $title,
+ 'shifttype_id' => $shifttype_id
+ ];
+
+ $shift_start = $shift_end;
+ $change_index = ($change_index + count($change_hours) - 1) % count($change_hours);
+ } while ($shift_end < $end);
+ }
+
+ $shifts_table = [];
+ foreach ($shifts as $shift) {
+ $shifts_table_entry = [
+ 'timeslot' =>
+ '<span class="glyphicon glyphicon-time"></span> '
+ . date('Y-m-d H:i', $shift['start'])
+ . ' - '
+ . date('H:i', $shift['end'])
+ . '<br />'
+ . Room_name_render(Room($shift['RID'])),
+ 'title' =>
+ ShiftType_name_render(ShiftType($shifttype_id))
+ . ($shift['title'] ? '<br />' . $shift['title'] : ''),
+ 'needed_angels' => ''
+ ];
+ 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[] = $shifts_table_entry;
+ }
+
+ // Fürs Anlegen zwischenspeichern:
+ $session->set('admin_shifts_shifts', $shifts);
+ $session->set('admin_shifts_types', $needed_angel_types);
+
+ $hidden_types = '';
+ foreach ($needed_angel_types as $type_id => $count) {
+ $hidden_types .= form_hidden('type_' . $type_id, $count);
+ }
+ return page_with_title(_('Preview'), [
+ form([
+ $hidden_types,
+ form_hidden('shifttype_id', $shifttype_id),
+ form_hidden('title', $title),
+ form_hidden('rid', $rid),
+ form_hidden('start', date('Y-m-d H:i', $start)),
+ form_hidden('end', date('Y-m-d H:i', $end)),
+ form_hidden('mode', $mode),
+ form_hidden('length', $length),
+ form_hidden('change_hours', implode(', ', $change_hours)),
+ form_hidden('angelmode', $angelmode),
+ form_submit('back', _('back')),
+ table([
+ 'timeslot' => _('Time and location'),
+ 'title' => _('Type and title'),
+ 'needed_angels' => _('Needed angels')
+ ], $shifts_table),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
+ }
+ } elseif ($request->has('submit')) {
+ if (
+ !is_array($session->get('admin_shifts_shifts'))
+ || !is_array($session->get('admin_shifts_types'))
+ ) {
+ redirect(page_link_to('admin_shifts'));
+ }
+
+ foreach ($session->get('admin_shifts_shifts', []) as $shift) {
+ $shift['URL'] = null;
+ $shift['PSID'] = null;
+ $shift_id = Shift_create($shift);
+
+ engelsystem_log(
+ 'Shift created: ' . $shifttypes[$shift['shifttype_id']]
+ . ' with title ' . $shift['title']
+ . ' from ' . date('Y-m-d H:i', $shift['start'])
+ . ' to ' . date('Y-m-d H:i', $shift['end'])
+ );
+
+ $needed_angel_types_info = [];
+ foreach ($session->get('admin_shifts_types', []) as $type_id => $count) {
+ $angel_type_source = DB::selectOne('
+ SELECT *
+ FROM `AngelTypes`
+ WHERE `id` = ?
+ LIMIT 1', [$type_id]);
+ if (!empty($angel_type_source)) {
+ DB::insert('
+ INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`)
+ VALUES (?, ?, ?)
+ ',
+ [
+ $shift_id,
+ $type_id,
+ $count
+ ]
+ );
+ $needed_angel_types_info[] = $angel_type_source['name'] . ': ' . $count;
+ }
+ }
+ engelsystem_log('Shift needs following angel types: ' . join(', ', $needed_angel_types_info));
+ }
+
+ success('Schichten angelegt.');
+ redirect(page_link_to('admin_shifts'));
+ } else {
+ $session->remove('admin_shifts_shifts');
+ $session->remove('admin_shifts_types');
}
- } elseif (isset($_REQUEST['submit'])) {
- if (! is_array($_SESSION['admin_shifts_shifts']) || ! is_array($_SESSION['admin_shifts_types'])) {
- redirect(page_link_to('admin_shifts'));
+
+ $rid = null;
+ if ($request->has('rid')) {
+ $rid = $request->input('rid');
}
-
- foreach ($_SESSION['admin_shifts_shifts'] as $shift) {
- $shift['URL'] = null;
- $shift['PSID'] = null;
- $shift_id = Shift_create($shift);
- if ($shift_id === false) {
- engelsystem_error('Unable to create shift.');
- }
-
- engelsystem_log("Shift created: " . $shifttypes[$shift['shifttype_id']] . " with title " . $shift['title'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']));
- $needed_angel_types_info = [];
- foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) {
- $angel_type_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($type_id) . "' LIMIT 1");
- if (count($angel_type_source) > 0) {
- sql_query("INSERT INTO `NeededAngelTypes` SET `shift_id`='" . sql_escape($shift_id) . "', `angel_type_id`='" . sql_escape($type_id) . "', `count`='" . sql_escape($count) . "'");
- $needed_angel_types_info[] = $angel_type_source[0]['name'] . ": " . $count;
- }
- }
+ $angel_types = '';
+ foreach ($types as $type) {
+ $angel_types .= '<div class="col-md-4">' . form_spinner(
+ 'type_' . $type['id'],
+ $type['name'],
+ $needed_angel_types[$type['id']]
+ )
+ . '</div>';
}
-
- engelsystem_log("Shift needs following angel types: " . join(", ", $needed_angel_types_info));
- success("Schichten angelegt.");
- redirect(page_link_to('admin_shifts'));
- } else {
- unset($_SESSION['admin_shifts_shifts']);
- unset($_SESSION['admin_shifts_types']);
- }
-
- if (! isset($_REQUEST['rid'])) {
- $_REQUEST['rid'] = null;
- }
- $angel_types = "";
- foreach ($types as $type) {
- $angel_types .= '<div class="col-md-4">' . form_spinner('type_' . $type['id'], $type['name'], $needed_angel_types[$type['id']]) . '</div>';
- }
-
- return page_with_title(admin_shifts_title(), [
- msg(),
- form([
- form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
- form_text('title', _("Title"), $title),
- form_select('rid', _("Room"), $room_array, $_REQUEST['rid']),
- div('row', [
- div('col-md-6', [
- form_text('start', _("Start"), date("Y-m-d H:i", $start)),
- form_text('end', _("End"), date("Y-m-d H:i", $end)),
- 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"), ! empty($_REQUEST['length']) ? $_REQUEST['length'] : '120'),
- form_radio('mode', _("Create multiple shifts with variable length"), $mode == 'variable', 'variable'),
- form_text('change_hours', _("Shift change hours"), ! empty($_REQUEST['change_hours']) ? $_REQUEST['change_hours'] : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22')
- ]),
- div('col-md-6', [
- form_info(_("Needed angels"), ''),
- form_radio('angelmode', _("Take needed angels from room settings"), $angelmode == 'location', 'location'),
- form_radio('angelmode', _("The following angels are needed"), $angelmode == 'manually', 'manually'),
- div('row', [
- $angel_types
- ])
- ])
- ]),
- form_submit('preview', _("Preview"))
- ])
- ]);
+
+ return page_with_title(admin_shifts_title(), [
+ msg(),
+ form([
+ form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
+ form_text('title', _('Title'), $title),
+ form_select('rid', _('Room'), $room_array, $rid),
+ div('row', [
+ div('col-md-6', [
+ form_text('start', _('Start'), date('Y-m-d H:i', $start)),
+ form_text('end', _('End'), date('Y-m-d H:i', $end)),
+ 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_radio(
+ 'mode',
+ _('Create multiple shifts with variable length'),
+ $mode == 'variable',
+ 'variable'
+ ),
+ form_text(
+ 'change_hours',
+ _('Shift change hours'),
+ $request->has('change_hours') ? $request->input('input') : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22'
+ )
+ ]),
+ div('col-md-6', [
+ form_info(_('Needed angels'), ''),
+ form_radio(
+ 'angelmode',
+ _('Take needed angels from room settings'),
+ $angelmode == 'location',
+ 'location'
+ ),
+ form_radio('angelmode', _('The following angels are needed'), $angelmode == 'manually', 'manually'),
+ div('row', [
+ $angel_types
+ ])
+ ])
+ ]),
+ form_submit('preview', _('Preview'))
+ ])
+ ]);
}
-?>
diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php
index 737bd91f..0620155b 100644
--- a/includes/pages/admin_user.php
+++ b/includes/pages/admin_user.php
@@ -1,208 +1,316 @@
<?php
-function admin_user_title() {
- return _("All Angels");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function admin_user_title()
+{
+ return _('All Angels');
}
-function admin_user() {
- global $user, $privileges, $tshirt_sizes, $privileges;
-
- $html = '';
-
- if (! isset($_REQUEST['id'])) {
- redirect(users_link());
- }
-
- $user_id = $_REQUEST['id'];
- if (! isset($_REQUEST['action'])) {
- $user_source = User($user_id);
- if ($user_source == null) {
- error(_('This user does not exist.'));
- redirect(users_link());
- }
-
- $html .= "Hallo,<br />" . "hier kannst du den Eintrag &auml;ndern. Unter dem Punkt 'Gekommen' " . "wird der Engel als anwesend markiert, ein Ja bei Aktiv bedeutet, " . "dass der Engel aktiv war und damit ein Anspruch auf ein T-Shirt hat. " . "Wenn T-Shirt ein 'Ja' enth&auml;lt, bedeutet dies, dass der Engel " . "bereits sein T-Shirt erhalten hat.<br /><br />\n";
-
- $html .= "<form action=\"" . page_link_to("admin_user") . "&action=save&id=$user_id\" method=\"post\">\n";
- $html .= "<table border=\"0\">\n";
- $html .= "<input type=\"hidden\" name=\"Type\" value=\"Normal\">\n";
- $html .= "<tr><td>\n";
- $html .= "<table>\n";
- $html .= " <tr><td>Nick</td><td>" . "<input type=\"text\" size=\"40\" name=\"eNick\" value=\"" . $user_source['Nick'] . "\"></td></tr>\n";
- $html .= " <tr><td>lastLogIn</td><td>" . date("Y-m-d H:i", $user_source['lastLogIn']) . "</td></tr>\n";
- $html .= " <tr><td>Name</td><td>" . "<input type=\"text\" size=\"40\" name=\"eName\" value=\"" . $user_source['Name'] . "\"></td></tr>\n";
- $html .= " <tr><td>Vorname</td><td>" . "<input type=\"text\" size=\"40\" name=\"eVorname\" value=\"" . $user_source['Vorname'] . "\"></td></tr>\n";
- $html .= " <tr><td>Alter</td><td>" . "<input type=\"text\" size=\"5\" name=\"eAlter\" value=\"" . $user_source['Alter'] . "\"></td></tr>\n";
- $html .= " <tr><td>Telefon</td><td>" . "<input type=\"text\" size=\"40\" name=\"eTelefon\" value=\"" . $user_source['Telefon'] . "\"></td></tr>\n";
- $html .= " <tr><td>Handy</td><td>" . "<input type=\"text\" size=\"40\" name=\"eHandy\" value=\"" . $user_source['Handy'] . "\"></td></tr>\n";
- $html .= " <tr><td>DECT</td><td>" . "<input type=\"text\" size=\"4\" name=\"eDECT\" value=\"" . $user_source['DECT'] . "\"></td></tr>\n";
- if ($user_source['email_by_human_allowed']) {
- $html .= " <tr><td>email</td><td>" . "<input type=\"text\" size=\"40\" name=\"eemail\" value=\"" . $user_source['email'] . "\"></td></tr>\n";
- }
- $html .= " <tr><td>jabber</td><td>" . "<input type=\"text\" size=\"40\" name=\"ejabber\" value=\"" . $user_source['jabber'] . "\"></td></tr>\n";
- $html .= " <tr><td>Size</td><td>" . html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size']) . "</td></tr>\n";
-
- $options = [
- '1' => _("Yes"),
- '0' => _("No")
- ];
-
- // Gekommen?
- $html .= " <tr><td>Gekommen</td><td>\n";
- $html .= html_options('eGekommen', $options, $user_source['Gekommen']) . "</td></tr>\n";
-
- // Aktiv?
- $html .= " <tr><td>Aktiv</td><td>\n";
- $html .= html_options('eAktiv', $options, $user_source['Aktiv']) . "</td></tr>\n";
-
- // Aktiv erzwingen
- if (in_array('admin_active', $privileges)) {
- $html .= " <tr><td>" . _("Force active") . "</td><td>\n";
- $html .= html_options('force_active', $options, $user_source['force_active']) . "</td></tr>\n";
- }
-
- // T-Shirt bekommen?
- $html .= " <tr><td>T-Shirt</td><td>\n";
- $html .= html_options('eTshirt', $options, $user_source['Tshirt']) . "</td></tr>\n";
-
- $html .= " <tr><td>Hometown</td><td>" . "<input type=\"text\" size=\"40\" name=\"Hometown\" value=\"" . $user_source['Hometown'] . "\"></td></tr>\n";
-
- $html .= "</table>\n</td><td valign=\"top\"></td></tr>";
-
- $html .= "</td></tr>\n";
- $html .= "</table>\n<br />\n";
- $html .= "<input type=\"submit\" value=\"Speichern\">\n";
- $html .= "</form>";
-
- $html .= "<hr />";
-
- $html .= form_info('', _('Please visit the angeltypes page or the users profile to manage users angeltypes.'));
-
- $html .= "Hier kannst Du das Passwort dieses Engels neu setzen:<form action=\"" . page_link_to("admin_user") . "&action=change_pw&id=$user_id\" method=\"post\">\n";
- $html .= "<table>\n";
- $html .= " <tr><td>Passwort</td><td>" . "<input type=\"password\" size=\"40\" name=\"new_pw\" value=\"\"></td></tr>\n";
- $html .= " <tr><td>Wiederholung</td><td>" . "<input type=\"password\" size=\"40\" name=\"new_pw2\" value=\"\"></td></tr>\n";
-
- $html .= "</table>";
- $html .= "<input type=\"submit\" value=\"Speichern\">\n";
- $html .= "</form>";
-
- $html .= "<hr />";
-
- $my_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user['UID']) . "' ORDER BY `group_id` LIMIT 1");
- if (count($my_highest_group) > 0) {
- $my_highest_group = $my_highest_group[0]['group_id'];
- }
-
- $his_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user_id) . "' ORDER BY `group_id` LIMIT 1");
- if (count($his_highest_group) > 0) {
- $his_highest_group = $his_highest_group[0]['group_id'];
+/**
+ * @return string
+ */
+function admin_user()
+{
+ global $user, $privileges;
+ $tshirt_sizes = config('tshirt_sizes');
+ $request = request();
+
+ foreach ($tshirt_sizes as $key => $size) {
+ if (empty($size)) {
+ unset($tshirt_sizes[$key]);
+ }
}
-
- if ($user_id != $user['UID'] && $my_highest_group <= $his_highest_group) {
- $html .= "Hier kannst Du die Benutzergruppen des Engels festlegen:<form action=\"" . page_link_to("admin_user") . "&action=save_groups&id=" . $user_id . "\" method=\"post\">\n";
- $html .= '<table>';
-
- $groups = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($user_id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group) . "' ORDER BY `Groups`.`Name`");
- foreach ($groups as $group) {
- $html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group['UID'] . '"' . ($group['group_id'] != "" ? ' checked="checked"' : '') . ' /></td><td>' . $group['Name'] . '</td></tr>';
- }
-
- $html .= '</table>';
-
- $html .= "<input type=\"submit\" value=\"Speichern\">\n";
- $html .= "</form>";
-
- $html .= "<hr />";
+
+ $html = '';
+
+ if (!$request->has('id')) {
+ redirect(users_link());
}
-
- $html .= buttons([
- button(user_delete_link($user_source), glyph('lock') . _("delete"), 'btn-danger')
- ]);
-
- $html .= "<hr />";
- } else {
- switch ($_REQUEST['action']) {
- case 'save_groups':
- if ($user_id != $user['UID']) {
- $my_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user['UID']) . "' ORDER BY `group_id`");
- $his_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user_id) . "' ORDER BY `group_id`");
-
- if (count($my_highest_group) > 0 && (count($his_highest_group) == 0 || ($my_highest_group[0]['group_id'] <= $his_highest_group[0]['group_id']))) {
- $groups_source = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($user_id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group[0]['group_id']) . "' ORDER BY `Groups`.`Name`");
- $groups = [];
- $grouplist = [];
- foreach ($groups_source as $group) {
- $groups[$group['UID']] = $group;
- $grouplist[] = $group['UID'];
- }
-
- if (! is_array($_REQUEST['groups'])) {
- $_REQUEST['groups'] = [];
- }
-
- sql_query("DELETE FROM `UserGroups` WHERE `uid`='" . sql_escape($user_id) . "'");
- $user_groups_info = [];
- foreach ($_REQUEST['groups'] as $group) {
- if (in_array($group, $grouplist)) {
- sql_query("INSERT INTO `UserGroups` SET `uid`='" . sql_escape($user_id) . "', `group_id`='" . sql_escape($group) . "'");
- $user_groups_info[] = $groups[$group]['Name'];
- }
- }
- $user_source = User($user_id);
- engelsystem_log("Set groups of " . User_Nick_render($user_source) . " to: " . join(", ", $user_groups_info));
- $html .= success("Benutzergruppen gespeichert.", true);
- } else {
- $html .= error("Du kannst keine Engel mit mehr Rechten bearbeiten.", true);
- }
- } else {
- $html .= error("Du kannst Deine eigenen Rechte nicht bearbeiten.", true);
+
+ $user_id = $request->input('id');
+ if (!$request->has('action')) {
+ $user_source = User($user_id);
+ if ($user_source == null) {
+ error(_('This user does not exist.'));
+ redirect(users_link());
+ }
+
+ $html .= 'Hallo,<br />'
+ . 'hier kannst du den Eintrag &auml;ndern. Unter dem Punkt \'Gekommen\' '
+ . 'wird der Engel als anwesend markiert, ein Ja bei Aktiv bedeutet, '
+ . 'dass der Engel aktiv war und damit ein Anspruch auf ein T-Shirt hat. '
+ . 'Wenn T-Shirt ein \'Ja\' enth&auml;lt, bedeutet dies, dass der Engel '
+ . 'bereits sein T-Shirt erhalten hat.<br /><br />' . "\n";
+
+ $html .= '<form action="'
+ . page_link_to('admin_user', ['action' => 'save', 'id' => $user_id])
+ . '" method="post">' . "\n";
+ $html .= '<table border="0">' . "\n";
+ $html .= '<input type="hidden" name="Type" value="Normal">' . "\n";
+ $html .= '<tr><td>' . "\n";
+ $html .= '<table>' . "\n";
+ $html .= ' <tr><td>Nick</td><td>' . '<input size="40" name="eNick" value="' . $user_source['Nick'] . '" class="form-control"></td></tr>' . "\n";
+ $html .= ' <tr><td>Last login</td><td><p class="help-block">'
+ . date('Y-m-d H:i', $user_source['lastLogIn'])
+ . '</p></td></tr>' . "\n";
+ $html .= ' <tr><td>Name</td><td>' . '<input size="40" name="eName" value="' . $user_source['Name'] . '" class="form-control"></td></tr>' . "\n";
+ $html .= ' <tr><td>Vorname</td><td>' . '<input size="40" name="eVorname" value="' . $user_source['Vorname'] . '" class="form-control"></td></tr>' . "\n";
+ $html .= ' <tr><td>Alter</td><td>' . '<input size="5" name="eAlter" value="' . $user_source['Alter'] . '" class="form-control"></td></tr>' . "\n";
+ $html .= ' <tr><td>Telefon</td><td>' . '<input size="40" name="eTelefon" value="' . $user_source['Telefon'] . '" class="form-control"></td></tr>' . "\n";
+ $html .= ' <tr><td>Handy</td><td>' . '<input size="40" name="eHandy" value="' . $user_source['Handy'] . '" class="form-control"></td></tr>' . "\n";
+ $html .= ' <tr><td>DECT</td><td>' . '<input size="4" name="eDECT" value="' . $user_source['DECT'] . '" class="form-control"></td></tr>' . "\n";
+ if ($user_source['email_by_human_allowed']) {
+ $html .= " <tr><td>email</td><td>" . '<input size="40" name="eemail" value="' . $user_source['email'] . '" class="form-control"></td></tr>' . "\n";
}
- break;
-
- case 'save':
- $force_active = $user['force_active'];
+ $html .= " <tr><td>jabber</td><td>" . '<input size="40" name="ejabber" value="' . $user_source['jabber'] . '" class="form-control"></td></tr>' . "\n";
+ $html .= ' <tr><td>Size</td><td>'
+ . html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size']) . '</td></tr>' . "\n";
+
+ $options = [
+ '1' => _('Yes'),
+ '0' => _('No')
+ ];
+
+ // Gekommen?
+ $html .= ' <tr><td>Gekommen</td><td>' . "\n";
+ $html .= html_options('eGekommen', $options, $user_source['Gekommen']) . '</td></tr>' . "\n";
+
+ // Aktiv?
+ $html .= ' <tr><td>Aktiv</td><td>' . "\n";
+ $html .= html_options('eAktiv', $options, $user_source['Aktiv']) . '</td></tr>' . "\n";
+
+ // Aktiv erzwingen
if (in_array('admin_active', $privileges)) {
- $force_active = $_REQUEST['force_active'];
+ $html .= ' <tr><td>' . _('Force active') . '</td><td>' . "\n";
+ $html .= html_options('force_active', $options, $user_source['force_active']) . '</td></tr>' . "\n";
+ }
+
+ // T-Shirt bekommen?
+ $html .= ' <tr><td>T-Shirt</td><td>' . "\n";
+ $html .= html_options('eTshirt', $options, $user_source['Tshirt']) . '</td></tr>' . "\n";
+
+ $html .= ' <tr><td>Hometown</td><td>' . '<input size="40" name="Hometown" value="' . $user_source['Hometown'] . '" class="form-control"></td></tr>' . "\n";
+
+ $html .= '</table>' . "\n" . '</td><td valign="top"></td></tr>';
+
+ $html .= '</td></tr>' . "\n";
+ $html .= '</table>' . "\n" . '<br />' . "\n";
+ $html .= '<input type="submit" value="Speichern" class="btn btn-primary">';
+ $html .= '</form>';
+
+ $html .= '<hr />';
+
+ $html .= form_info('', _('Please visit the angeltypes page or the users profile to manage users angeltypes.'));
+
+ $html .= 'Hier kannst Du das Passwort dieses Engels neu setzen:<form action="'
+ . page_link_to('admin_user', ['action' => 'change_pw', 'id' => $user_id])
+ . '" method="post">' . "\n";
+ $html .= '<table>' . "\n";
+ $html .= ' <tr><td>Passwort</td><td>' . '<input type="password" size="40" name="new_pw" value="" class="form-control"></td></tr>' . "\n";
+ $html .= ' <tr><td>Wiederholung</td><td>' . '<input type="password" size="40" name="new_pw2" value="" class="form-control"></td></tr>' . "\n";
+
+ $html .= '</table>' . "\n" . '<br />' . "\n";
+ $html .= '<input type="submit" value="Speichern" class="btn btn-primary">' . "\n";
+ $html .= '</form>';
+
+ $html .= '<hr />';
+
+ $my_highest_group = DB::selectOne(
+ 'SELECT group_id FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
+ [$user['UID']]
+ );
+ if (!empty($my_highest_group)) {
+ $my_highest_group = $my_highest_group['group_id'];
}
- $SQL = "UPDATE `User` SET
- `Nick` = '" . sql_escape($_POST["eNick"]) . "',
- `Name` = '" . sql_escape($_POST["eName"]) . "',
- `Vorname` = '" . sql_escape($_POST["eVorname"]) . "',
- `Telefon` = '" . sql_escape($_POST["eTelefon"]) . "',
- `Handy` = '" . sql_escape($_POST["eHandy"]) . "',
- `Alter` = '" . sql_escape($_POST["eAlter"]) . "',
- `DECT` = '" . sql_escape($_POST["eDECT"]) . "',
- " . ($user_source['email_by_human_allowed'] ? "`email` = '" . sql_escape($_POST["eemail"]) . "'" : "") . "
- `jabber` = '" . sql_escape($_POST["ejabber"]) . "',
- `Size` = '" . sql_escape($_POST["eSize"]) . "',
- `Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "',
- `Aktiv`= '" . sql_escape($_POST["eAktiv"]) . "',
- `force_active`= " . sql_escape($force_active) . ",
- `Tshirt` = '" . sql_escape($_POST["eTshirt"]) . "',
- `Hometown` = '" . sql_escape($_POST["Hometown"]) . "'
- WHERE `UID` = '" . sql_escape($user_id) . "'
- LIMIT 1";
- sql_query($SQL);
- engelsystem_log("Updated user: " . $_POST["eNick"] . ", " . $_POST["eSize"] . ", arrived: " . $_POST["eGekommen"] . ", active: " . $_POST["eAktiv"] . ", tshirt: " . $_POST["eTshirt"]);
- $html .= success("Änderung wurde gespeichert...\n", true);
- break;
-
- case 'change_pw':
- if ($_REQUEST['new_pw'] != "" && $_REQUEST['new_pw'] == $_REQUEST['new_pw2']) {
- set_password($user_id, $_REQUEST['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);
+
+ $his_highest_group = DB::selectOne(
+ 'SELECT `group_id` FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
+ [$user_id]
+ );
+ if (!empty($his_highest_group)) {
+ $his_highest_group = $his_highest_group['group_id'];
+ }
+
+ if ($user_id != $user['UID'] && $my_highest_group <= $his_highest_group) {
+ $html .= 'Hier kannst Du die Benutzergruppen des Engels festlegen:<form action="'
+ . page_link_to('admin_user', ['action' => 'save_groups', 'id' => $user_id])
+ . '" method="post">' . "\n";
+ $html .= '<table>';
+
+ $groups = DB::select('
+ SELECT *
+ FROM `Groups`
+ LEFT OUTER JOIN `UserGroups` ON (
+ `UserGroups`.`group_id` = `Groups`.`UID`
+ AND `UserGroups`.`uid` = ?
+ )
+ WHERE `Groups`.`UID` >= ?
+ ORDER BY `Groups`.`Name`
+ ',
+ [
+ $user_id,
+ $my_highest_group,
+ ]
+ );
+ foreach ($groups as $group) {
+ $html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group['UID'] . '" '
+ . ($group['group_id'] != '' ? ' checked="checked"' : '')
+ . ' /></td><td>' . $group['Name'] . '</td></tr>';
+ }
+
+ $html .= '</table><br>';
+
+ $html .= '<input type="submit" value="Speichern" class="btn btn-primary">' . "\n";
+ $html .= '</form>';
+
+ $html .= '<hr />';
+ }
+
+ $html .= buttons([
+ button(user_delete_link($user_source), glyph('lock') . _('delete'), 'btn-danger')
+ ]);
+
+ $html .= "<hr />";
+ } else {
+ switch ($request->input('action')) {
+ case 'save_groups':
+ if ($user_id != $user['UID']) {
+ $my_highest_group = DB::selectOne(
+ 'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
+ [$user['UID']]
+ );
+ $his_highest_group = DB::selectOne(
+ 'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
+ [$user_id]
+ );
+
+ if (
+ count($my_highest_group) > 0
+ && (
+ count($his_highest_group) == 0
+ || ($my_highest_group['group_id'] <= $his_highest_group['group_id'])
+ )
+ ) {
+ $groups_source = DB::select('
+ SELECT *
+ FROM `Groups`
+ LEFT OUTER JOIN `UserGroups` ON (
+ `UserGroups`.`group_id` = `Groups`.`UID`
+ AND `UserGroups`.`uid` = ?
+ )
+ WHERE `Groups`.`UID` >= ?
+ ORDER BY `Groups`.`Name`
+ ',
+ [
+ $user_id,
+ $my_highest_group['group_id'],
+ ]
+ );
+ $groups = [];
+ $grouplist = [];
+ foreach ($groups_source as $group) {
+ $groups[$group['UID']] = $group;
+ $grouplist[] = $group['UID'];
+ }
+
+ $groupsRequest = $request->input('groups');
+ if (!is_array($groupsRequest)) {
+ $groupsRequest = [];
+ }
+
+ DB::delete('DELETE FROM `UserGroups` WHERE `uid`=?', [$user_id]);
+ $user_groups_info = [];
+ foreach ($groupsRequest as $group) {
+ if (in_array($group, $grouplist)) {
+ DB::insert(
+ 'INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, ?)',
+ [$user_id, $group]
+ );
+ $user_groups_info[] = $groups[$group]['Name'];
+ }
+ }
+ $user_source = User($user_id);
+ engelsystem_log(
+ 'Set groups of ' . User_Nick_render($user_source) . ' to: ' . join(', ', $user_groups_info)
+ );
+ $html .= success('Benutzergruppen gespeichert.', true);
+ } else {
+ $html .= error('Du kannst keine Engel mit mehr Rechten bearbeiten.', true);
+ }
+ } else {
+ $html .= error('Du kannst Deine eigenen Rechte nicht bearbeiten.', true);
+ }
+ break;
+
+ case 'save':
+ $force_active = $user['force_active'];
+ $user_source = User($user_id);
+ if (in_array('admin_active', $privileges)) {
+ $force_active = $request->input('force_active');
+ }
+ $sql = '
+ UPDATE `User` SET
+ `Nick` = ?,
+ `Name` = ?,
+ `Vorname` = ?,
+ `Telefon` = ?,
+ `Handy` = ?,
+ `Alter` =?,
+ `DECT` = ?,
+ ' . ($user_source['email_by_human_allowed'] ? '`email` = ' . DB::getPdo()->quote($request->postData('eemail')) . ',' : '') . '
+ `jabber` = ?,
+ `Size` = ?,
+ `Gekommen`= ?,
+ `Aktiv`= ?,
+ `force_active`= ?,
+ `Tshirt` = ?,
+ `Hometown` = ?
+ WHERE `UID` = ?
+ LIMIT 1';
+ DB::update($sql, [
+ User_validate_Nick($request->postData('eNick')),
+ $request->postData('eName'),
+ $request->postData('eVorname'),
+ $request->postData('eTelefon'),
+ $request->postData('eHandy'),
+ $request->postData('eAlter'),
+ $request->postData('eDECT'),
+ $request->postData('ejabber'),
+ $request->postData('eSize'),
+ $request->postData('eGekommen'),
+ $request->postData('eAktiv'),
+ $force_active,
+ $request->postData('eTshirt'),
+ $request->postData('Hometown'),
+ $user_id,
+ ]);
+ engelsystem_log(
+ 'Updated user: ' . $request->postData('eNick') . ', ' . $request->postData('eSize')
+ . ', arrived: ' . $request->postData('eVorname')
+ . ', active: ' . $request->postData('eAktiv')
+ . ', tshirt: ' . $request->postData('eTshirt')
+ );
+ $html .= success('Änderung wurde gespeichert...' . "\n", true);
+ break;
+
+ case 'change_pw':
+ 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);
+ }
+ break;
}
- break;
}
- }
-
- return page_with_title(_("Edit user"), [
- $html
- ]);
+
+ return page_with_title(_('Edit user'), [
+ $html
+ ]);
}
-?>
diff --git a/includes/pages/guest_credits.php b/includes/pages/guest_credits.php
index cbdc3133..db86132d 100644
--- a/includes/pages/guest_credits.php
+++ b/includes/pages/guest_credits.php
@@ -1,9 +1,17 @@
<?php
-function credits_title() {
- return _("Credits");
+
+/**
+ * @return string
+ */
+function credits_title()
+{
+ return _('Credits');
}
-function guest_credits() {
- return template_render(__DIR__ . '/../../templates/guest_credits.html', []);
+/**
+ * @return string
+ */
+function guest_credits()
+{
+ return view(__DIR__ . '/../../templates/guest_credits.html');
}
-?> \ No newline at end of file
diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php
index 54abe5ca..76c944c5 100644
--- a/includes/pages/guest_login.php
+++ b/includes/pages/guest_login.php
@@ -1,400 +1,529 @@
<?php
-function login_title() {
- return _("Login");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function login_title()
+{
+ return _('Login');
}
-function register_title() {
- return _("Register");
+/**
+ * @return string
+ */
+function register_title()
+{
+ return _('Register');
}
-function logout_title() {
- return _("Logout");
+/**
+ * @return string
+ */
+function logout_title()
+{
+ return _('Logout');
}
-// Engel registrieren
-function guest_register() {
- global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user, $min_password_length;
-
- $event_config = EventConfig();
-
- $msg = "";
- $nick = "";
- $lastname = "";
- $prename = "";
- $age = "";
- $tel = "";
- $dect = "";
- $mobile = "";
- $mail = "";
- $email_shiftinfo = false;
- $email_by_human_allowed = false;
- $jabber = "";
- $hometown = "";
- $comment = "";
- $tshirt_size = '';
- $password_hash = "";
- $selected_angel_types = [];
- $planned_arrival_date = null;
-
- $angel_types_source = AngelTypes();
- $angel_types = [];
- foreach ($angel_types_source as $angel_type) {
- $angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : "");
- if (! $angel_type['restricted']) {
- $selected_angel_types[] = $angel_type['id'];
- }
- }
-
- if (isset($_REQUEST['submit'])) {
- $valid = true;
-
- if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 1) {
- $nick = User_validate_Nick($_REQUEST['nick']);
- if (sql_num_query("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "' LIMIT 1") > 0) {
- $valid = false;
- $msg .= error(sprintf(_("Your nick &quot;%s&quot; already exists."), $nick), true);
- }
- } else {
- $valid = false;
- $msg .= error(sprintf(_("Your nick &quot;%s&quot; is too short (min. 2 characters)."), User_validate_Nick($_REQUEST['nick'])), true);
- }
-
- if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) {
- $mail = strip_request_item('mail');
- if (! check_email($mail)) {
- $valid = false;
- $msg .= error(_("E-mail address is not correct."), true);
- }
- } else {
- $valid = false;
- $msg .= error(_("Please enter your e-mail."), true);
- }
-
- if (isset($_REQUEST['email_shiftinfo'])) {
- $email_shiftinfo = true;
- }
-
- if (isset($_REQUEST['email_by_human_allowed'])) {
- $email_by_human_allowed = true;
- }
-
- if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
- $jabber = strip_request_item('jabber');
- if (! check_email($jabber)) {
- $valid = false;
- $msg .= error(_("Please check your jabber account information."), true);
- }
- }
-
- if ($enable_tshirt_size) {
- if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']]) && $_REQUEST['tshirt_size'] != '') {
- $tshirt_size = $_REQUEST['tshirt_size'];
- } else {
- $valid = false;
- $msg .= error(_("Please select your shirt size."), true);
- }
- }
-
- if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= $min_password_length) {
- if ($_REQUEST['password'] != $_REQUEST['password2']) {
- $valid = false;
- $msg .= error(_("Your passwords don't match."), true);
- }
- } else {
- $valid = false;
- $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 H:i", $_REQUEST['planned_arrival_date'] . " 00:00");
- $result = User_validate_planned_arrival_date($tmp);
- $planned_arrival_date = $result->getValue();
- if (! $result->isValid()) {
- $valid = false;
- error(_("Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date."));
- }
- }
-
+/**
+ * Engel registrieren
+ *
+ * @return string
+ */
+function guest_register()
+{
+ global $user, $privileges;
+ $tshirt_sizes = config('tshirt_sizes');
+ $enable_tshirt_size = config('enable_tshirt_size');
+ $min_password_length = config('min_password_length');
+ $event_config = EventConfig();
+ $request = request();
+ $session = session();
+
+ $msg = '';
+ $nick = '';
+ $lastName = '';
+ $preName = '';
+ $age = 0;
+ $tel = '';
+ $dect = '';
+ $mobile = '';
+ $mail = '';
+ $email_shiftinfo = false;
+ $email_by_human_allowed = false;
+ $jabber = '';
+ $hometown = '';
+ $comment = '';
+ $tshirt_size = '';
+ $password_hash = '';
$selected_angel_types = [];
- foreach (array_keys($angel_types) as $angel_type_id) {
- if (isset($_REQUEST['angel_types_' . $angel_type_id])) {
- $selected_angel_types[] = $angel_type_id;
- }
- }
-
- // Trivia
- if (isset($_REQUEST['lastname'])) {
- $lastname = strip_request_item('lastname');
- }
- if (isset($_REQUEST['prename'])) {
- $prename = strip_request_item('prename');
- }
- if (isset($_REQUEST['age']) && preg_match("/^[0-9]{0,4}$/", $_REQUEST['age'])) {
- $age = strip_request_item('age');
- }
- if (isset($_REQUEST['tel'])) {
- $tel = strip_request_item('tel');
- }
- if (isset($_REQUEST['dect'])) {
- $dect = strip_request_item('dect');
- }
- if (isset($_REQUEST['mobile'])) {
- $mobile = strip_request_item('mobile');
- }
- if (isset($_REQUEST['hometown'])) {
- $hometown = strip_request_item('hometown');
+ $planned_arrival_date = null;
+
+ $angel_types_source = AngelTypes();
+ $angel_types = [];
+ foreach ($angel_types_source as $angel_type) {
+ $angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? ' (restricted)' : '');
+ if (!$angel_type['restricted']) {
+ $selected_angel_types[] = $angel_type['id'];
+ }
}
- if (isset($_REQUEST['comment'])) {
- $comment = strip_request_item_nl('comment');
+
+ foreach ($tshirt_sizes as $key => $size) {
+ if (empty($size)) {
+ unset($tshirt_sizes[$key]);
+ }
}
-
- if ($valid) {
- sql_query("
- INSERT INTO `User` SET
- `color`='" . sql_escape($default_theme) . "',
- `Nick`='" . sql_escape($nick) . "',
- `Vorname`='" . sql_escape($prename) . "',
- `Name`='" . sql_escape($lastname) . "',
- `Alter`='" . sql_escape($age) . "',
- `Telefon`='" . sql_escape($tel) . "',
- `DECT`='" . sql_escape($dect) . "',
- `Handy`='" . sql_escape($mobile) . "',
- `email`='" . sql_escape($mail) . "',
- `email_shiftinfo`=" . sql_bool($email_shiftinfo) . ",
- `email_by_human_allowed`=" . sql_bool($email_by_human_allowed) . ",
- `jabber`='" . sql_escape($jabber) . "',
- `Size`='" . sql_escape($tshirt_size) . "',
- `Passwort`='" . sql_escape($password_hash) . "',
- `kommentar`='" . sql_escape($comment) . "',
- `Hometown`='" . sql_escape($hometown) . "',
- `CreateDate`=NOW(),
- `Sprache`='" . sql_escape($_SESSION["locale"]) . "',
- `arrival_date`=NULL,
- `planned_arrival_date`='" . sql_escape($planned_arrival_date) . "'");
-
- // Assign user-group and set password
- $user_id = sql_id();
- sql_query("INSERT INTO `UserGroups` SET `uid`='" . sql_escape($user_id) . "', `group_id`=-2");
- set_password($user_id, $_REQUEST['password']);
-
- // Assign angel-types
- $user_angel_types_info = [];
- foreach ($selected_angel_types as $selected_angel_type_id) {
- sql_query("INSERT INTO `UserAngelTypes` SET `user_id`='" . sql_escape($user_id) . "', `angeltype_id`='" . sql_escape($selected_angel_type_id) . "'");
- $user_angel_types_info[] = $angel_types[$selected_angel_type_id];
- }
-
- engelsystem_log("User " . User_Nick_render(User($user_id)) . " signed up as: " . join(", ", $user_angel_types_info));
- success(_("Angel registration successful!"));
-
- // User is already logged in - that means a supporter has registered an angel. Return to register page.
- if (isset($user)) {
- redirect(page_link_to('register'));
- }
-
- // If a welcome message is present, display registration success page.
- if ($event_config != null && $event_config['event_welcome_msg'] != null) {
- return User_registration_success_view($event_config['event_welcome_msg']);
- }
-
- redirect('?');
+
+ if (!in_array('register', $privileges) || (!isset($user) && !config('registration_enabled'))) {
+ error(_('Registration is disabled.'));
+
+ return page_with_title(register_title(), [
+ msg(),
+ ]);
}
- }
-
- $buildup_start_date = time();
- $teardown_end_date = null;
- if ($event_config != null) {
- if (isset($event_config['buildup_start_date'])) {
- $buildup_start_date = $event_config['buildup_start_date'];
+
+ if ($request->has('submit')) {
+ $valid = true;
+
+ if ($request->has('nick') && strlen(User_validate_Nick($request->input('nick'))) > 1) {
+ $nick = User_validate_Nick($request->input('nick'));
+ if (count(DB::select('SELECT `UID` FROM `User` WHERE `Nick`=? LIMIT 1', [$nick])) > 0) {
+ $valid = false;
+ $msg .= error(sprintf(_('Your nick &quot;%s&quot; already exists.'), $nick), true);
+ }
+ } else {
+ $valid = false;
+ $msg .= error(sprintf(
+ _('Your nick &quot;%s&quot; is too short (min. 2 characters).'),
+ User_validate_Nick($request->input('nick'))
+ ), true);
+ }
+
+ if ($request->has('mail') && strlen(strip_request_item('mail')) > 0) {
+ $mail = strip_request_item('mail');
+ if (!check_email($mail)) {
+ $valid = false;
+ $msg .= error(_('E-mail address is not correct.'), true);
+ }
+ } else {
+ $valid = false;
+ $msg .= error(_('Please enter your e-mail.'), true);
+ }
+
+ if ($request->has('email_shiftinfo')) {
+ $email_shiftinfo = true;
+ }
+
+ if ($request->has('email_by_human_allowed')) {
+ $email_by_human_allowed = true;
+ }
+
+ if ($request->has('jabber') && strlen(strip_request_item('jabber')) > 0) {
+ $jabber = strip_request_item('jabber');
+ if (!check_email($jabber)) {
+ $valid = false;
+ $msg .= error(_('Please check your jabber account information.'), true);
+ }
+ }
+
+ if ($enable_tshirt_size) {
+ if ($request->has('tshirt_size') && isset($tshirt_sizes[$request->input('tshirt_size')])) {
+ $tshirt_size = $request->input('tshirt_size');
+ } else {
+ $valid = false;
+ $msg .= error(_('Please select your shirt size.'), true);
+ }
+ }
+
+ if ($request->has('password') && strlen($request->postData('password')) >= $min_password_length) {
+ if ($request->postData('password') != $request->postData('password2')) {
+ $valid = false;
+ $msg .= error(_('Your passwords don\'t match.'), true);
+ }
+ } else {
+ $valid = false;
+ $msg .= error(sprintf(
+ _('Your password is too short (please use at least %s characters).'),
+ $min_password_length
+ ), true);
+ }
+
+ if ($request->has('planned_arrival_date')) {
+ $tmp = parse_date('Y-m-d H:i', $request->input('planned_arrival_date') . ' 00:00');
+ $result = User_validate_planned_arrival_date($tmp);
+ $planned_arrival_date = $result->getValue();
+ if (!$result->isValid()) {
+ $valid = false;
+ error(_('Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date.'));
+ }
+ } else {
+ $valid = false;
+ error(_('Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date.'));
+ }
+
+ $selected_angel_types = [];
+ foreach (array_keys($angel_types) as $angel_type_id) {
+ if ($request->has('angel_types_' . $angel_type_id)) {
+ $selected_angel_types[] = $angel_type_id;
+ }
+ }
+
+ // Trivia
+ if ($request->has('lastname')) {
+ $lastName = strip_request_item('lastname');
+ }
+ if ($request->has('prename')) {
+ $preName = strip_request_item('prename');
+ }
+ if ($request->has('age') && preg_match('/^\d{0,4}$/', $request->input('age'))) {
+ $age = strip_request_item('age');
+ }
+ if ($request->has('tel')) {
+ $tel = strip_request_item('tel');
+ }
+ if ($request->has('dect')) {
+ if(strlen(strip_request_item('dect')) <= 5) {
+ $dect = strip_request_item('dect');
+ } else {
+ $valid = false;
+ error(_('For dect numbers are only 5 digits allowed.'));
+ }
+ }
+ if ($request->has('mobile')) {
+ $mobile = strip_request_item('mobile');
+ }
+ if ($request->has('hometown')) {
+ $hometown = strip_request_item('hometown');
+ }
+ if ($request->has('comment')) {
+ $comment = strip_request_item_nl('comment');
+ }
+
+ if ($valid) {
+ DB::insert('
+ INSERT INTO `User` (
+ `color`,
+ `Nick`,
+ `Vorname`,
+ `Name`,
+ `Alter`,
+ `Telefon`,
+ `DECT`,
+ `Handy`,
+ `email`,
+ `email_shiftinfo`,
+ `email_by_human_allowed`,
+ `jabber`,
+ `Size`,
+ `Passwort`,
+ `kommentar`,
+ `Hometown`,
+ `CreateDate`,
+ `Sprache`,
+ `arrival_date`,
+ `planned_arrival_date`,
+ `force_active`,
+ `lastLogIn`,
+ `api_key`,
+ `got_voucher`
+ )
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?, NULL, ?, FALSE, 0, "", 0)
+ ',
+ [
+ config('theme'),
+ $nick,
+ $preName,
+ $lastName,
+ $age,
+ $tel,
+ $dect,
+ $mobile,
+ $mail,
+ (int)$email_shiftinfo,
+ (int)$email_by_human_allowed,
+ $jabber,
+ $tshirt_size,
+ $password_hash,
+ $comment,
+ $hometown,
+ $session->get('locale'),
+ $planned_arrival_date,
+ ]
+ );
+
+ // Assign user-group and set password
+ $user_id = DB::getPdo()->lastInsertId();
+ DB::insert('INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, -20)', [$user_id]);
+ set_password($user_id, $request->postData('password'));
+
+ // Assign angel-types
+ $user_angel_types_info = [];
+ foreach ($selected_angel_types as $selected_angel_type_id) {
+ DB::insert(
+ 'INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`) VALUES (?, ?, FALSE)',
+ [$user_id, $selected_angel_type_id]
+ );
+ $user_angel_types_info[] = $angel_types[$selected_angel_type_id];
+ }
+
+ engelsystem_log(
+ 'User ' . User_Nick_render(User($user_id))
+ . ' signed up as: ' . join(', ', $user_angel_types_info)
+ );
+ success(_('Angel registration successful!'));
+
+ // User is already logged in - that means a supporter has registered an angel. Return to register page.
+ if (isset($user)) {
+ redirect(page_link_to('register'));
+ }
+
+ // If a welcome message is present, display registration success page.
+ if ($event_config != null && $event_config['event_welcome_msg'] != null) {
+ return User_registration_success_view($event_config['event_welcome_msg']);
+ }
+
+ redirect(page_link_to('/'));
+ }
}
- if(isset($event_config['teardown_end_date'])) {
- $teardown_end_date = $event_config['teardown_end_date'];
+
+ $buildup_start_date = time();
+ $teardown_end_date = null;
+ if ($event_config != null) {
+ if (isset($event_config['buildup_start_date'])) {
+ $buildup_start_date = $event_config['buildup_start_date'];
+ }
+ if (isset($event_config['teardown_end_date'])) {
+ $teardown_end_date = $event_config['teardown_end_date'];
+ }
}
- }
-
- return page_with_title(register_title(), [
- _("By completing this form you're registering as a Chaos-Angel. This script will create you an account in the angel task scheduler."),
- $msg,
- msg(),
- form([
- div('row', [
- div('col-md-6', [
- div('row', [
- div('col-sm-4', [
- form_text('nick', _("Nick") . ' ' . entry_required(), $nick)
- ]),
- 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_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $email_by_human_allowed)
- ])
- ]),
- div('row', [
- div('col-sm-6', [
- form_date('planned_arrival_date', _("Planned date of arrival") . ' ' . entry_required(), $planned_arrival_date, $buildup_start_date, $teardown_end_date)
- ]),
- div('col-sm-6', [
- $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size") . ' ' . entry_required(), $tshirt_sizes, $tshirt_size) : ''
- ])
- ]),
- div('row', [
- div('col-sm-6', [
- form_password('password', _("Password") . ' ' . entry_required())
- ]),
- div('col-sm-6', [
- form_password('password2', _("Confirm password") . ' ' . entry_required())
- ])
- ]),
- 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 a supporter. You can change your selection in the options section."))
- ]),
- div('col-md-6', [
- div('row', [
- div('col-sm-4', [
- form_text('dect', _("DECT"), $dect)
- ]),
- div('col-sm-4', [
- form_text('mobile', _("Mobile"), $mobile)
- ]),
- div('col-sm-4', [
- form_text('tel', _("Phone"), $tel)
- ])
- ]),
- form_text('jabber', _("Jabber"), $jabber),
- div('row', [
- div('col-sm-6', [
- form_text('prename', _("First name"), $prename)
- ]),
- div('col-sm-6', [
- form_text('lastname', _("Last name"), $lastname)
- ])
- ]),
- div('row', [
- div('col-sm-3', [
- form_text('age', _("Age"), $age)
- ]),
- div('col-sm-9', [
- form_text('hometown', _("Hometown"), $hometown)
- ])
- ]),
- 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"))
- ])
- ]);
+
+ return page_with_title(register_title(), [
+ _('By completing this form you\'re registering as a Chaos-Angel. This script will create you an account in the angel task scheduler.'),
+ $msg,
+ msg(),
+ form([
+ div('row', [
+ div('col-md-6', [
+ div('row', [
+ div('col-sm-4', [
+ form_text('nick', _('Nick') . ' ' . entry_required(), $nick)
+ ]),
+ 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_by_human_allowed',
+ _('Humans are allowed to send me an email (e.g. for ticket vouchers)'),
+ $email_by_human_allowed
+ )
+ ])
+ ]),
+ div('row', [
+ div('col-sm-6', [
+ form_date(
+ 'planned_arrival_date',
+ _('Planned date of arrival') . ' ' . entry_required(),
+ $planned_arrival_date, $buildup_start_date, $teardown_end_date
+ )
+ ]),
+ div('col-sm-6', [
+ $enable_tshirt_size ? form_select('tshirt_size',
+ _('Shirt size') . ' ' . entry_required(),
+ $tshirt_sizes, $tshirt_size) : ''
+ ])
+ ]),
+ div('row', [
+ div('col-sm-6', [
+ form_password('password', _('Password') . ' ' . entry_required())
+ ]),
+ div('col-sm-6', [
+ form_password('password2', _('Confirm password') . ' ' . entry_required())
+ ])
+ ]),
+ 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 a supporter. You can change your selection in the options section.')
+ )
+ ]),
+ div('col-md-6', [
+ div('row', [
+ div('col-sm-4', [
+ form_text('dect', _('DECT'), $dect)
+ ]),
+ div('col-sm-4', [
+ form_text('mobile', _('Mobile'), $mobile)
+ ]),
+ div('col-sm-4', [
+ form_text('tel', _('Phone'), $tel)
+ ])
+ ]),
+ form_text('jabber', _('Jabber'), $jabber),
+ div('row', [
+ div('col-sm-6', [
+ form_text('prename', _('First name'), $preName)
+ ]),
+ div('col-sm-6', [
+ form_text('lastname', _('Last name'), $lastName)
+ ])
+ ]),
+ div('row', [
+ div('col-sm-3', [
+ form_text('age', _('Age'), $age)
+ ]),
+ div('col-sm-9', [
+ form_text('hometown', _('Hometown'), $hometown)
+ ])
+ ]),
+ 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'))
+ ])
+ ]);
}
-function entry_required() {
- return '<span class="text-info glyphicon glyphicon-warning-sign"></span>';
+/**
+ * @return string
+ */
+function entry_required()
+{
+ return '<span class="text-info glyphicon glyphicon-warning-sign"></span>';
}
-function guest_logout() {
- session_destroy();
- redirect(page_link_to("start"));
+/**
+ * @return bool
+ */
+function guest_logout()
+{
+ session()->invalidate();
+ redirect(page_link_to('start'));
+ return true;
}
-function guest_login() {
- $nick = "";
-
- unset($_SESSION['uid']);
- $valid = true;
-
- if (isset($_REQUEST['submit'])) {
-
- if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) {
- $nick = User_validate_Nick($_REQUEST['nick']);
- $login_user = sql_select("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "'");
- if (count($login_user) > 0) {
- $login_user = $login_user[0];
- if (isset($_REQUEST['password'])) {
- if (! verify_password($_REQUEST['password'], $login_user['Passwort'], $login_user['UID'])) {
- $valid = false;
- error(_("Your password is incorrect. Please try it again."));
- }
+/**
+ * @return string
+ */
+function guest_login()
+{
+ $nick = '';
+ $request = request();
+ $session = session();
+ $valid = true;
+
+ $session->remove('uid');
+
+ if ($request->has('submit')) {
+ if ($request->has('nick') && strlen(User_validate_Nick($request->input('nick'))) > 0) {
+ $nick = User_validate_Nick($request->input('nick'));
+ $login_user = DB::selectOne('SELECT * FROM `User` WHERE `Nick`=?', [$nick]);
+ if (!empty($login_user)) {
+ if ($request->has('password')) {
+ if (!verify_password($request->postData('password'), $login_user['Passwort'], $login_user['UID'])) {
+ $valid = false;
+ error(_('Your password is incorrect. Please try it again.'));
+ }
+ } else {
+ $valid = false;
+ error(_('Please enter a password.'));
+ }
+ } else {
+ $valid = false;
+ error(_('No user was found with that Nickname. Please try again. If you are still having problems, ask a Dispatcher.'));
+ }
} else {
- $valid = false;
- error(_("Please enter a password."));
+ $valid = false;
+ error(_('Please enter a nickname.'));
+ }
+
+ if ($valid && !empty($login_user)) {
+ $session->set('uid', $login_user['UID']);
+ $session->set('locale', $login_user['Sprache']);
+
+ redirect(page_link_to('news'));
}
- } else {
- $valid = false;
- error(_("No user was found with that Nickname. Please try again. If you are still having problems, ask a Dispatcher."));
- }
- } else {
- $valid = false;
- error(_("Please enter a nickname."));
- }
-
- if ($valid) {
- $_SESSION['uid'] = $login_user['UID'];
- $_SESSION['locale'] = $login_user['Sprache'];
-
- redirect(page_link_to('news'));
}
- }
-
- $event_config = EventConfig();
-
- return page([
- div('col-md-12', [
- div('row', [
- 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"))
- ]) : ''
- ])
- ]),
- div('panel-footer', [
- glyph('info-sign') . _("Please note: You have to activate cookies!")
- ])
- ])
- ])
- ]),
- div('row', [
- div('col-sm-6 text-center', [
- heading(register_title(), 2),
- 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([
- button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' &raquo;')
- ])
- ])
- ])
- ])
- ]);
-}
-function get_register_hint() {
- global $privileges;
-
- if (in_array('register', $privileges)) {
- return join('', [
- '<p>' . _("Please sign up, if you want to help us!") . '</p>',
- buttons([
- button(page_link_to('register'), register_title() . ' &raquo;')
- ])
+ $event_config = EventConfig();
+
+ return page([
+ div('col-md-12', [
+ div('row', [
+ 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'))
+ ]) : ''
+ ])
+ ]),
+ div('panel-footer', [
+ glyph('info-sign') . _('Please note: You have to activate cookies!')
+ ])
+ ])
+ ])
+ ]),
+ div('row', [
+ div('col-sm-6 text-center', [
+ heading(register_title(), 2),
+ 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([
+ button(
+ page_link_to('angeltypes', ['action' => 'about']),
+ _('Teams/Job description') . ' &raquo;'
+ )
+ ])
+ ])
+ ])
+ ])
]);
- }
-
- //FIXME: return error(_("Registration is disabled."), true);
- return error("Registration is <a href='https://engelsystem.de/33c3/overwhelmed.html'>disabled</a>.", true);
}
-?>
+
+/**
+ * @return string
+ */
+function get_register_hint()
+{
+ global $privileges;
+
+ if (in_array('register', $privileges) && config('registration_enabled')) {
+ return join('', [
+ '<p>' . _('Please sign up, if you want to help us!') . '</p>',
+ buttons([
+ button(page_link_to('register'), register_title() . ' &raquo;')
+ ])
+ ]);
+ }
+
+ return error(_('Registration is disabled.'), true);
+}
diff --git a/includes/pages/guest_start.php b/includes/pages/guest_start.php
index 8f008a8d..4cd2fa42 100644
--- a/includes/pages/guest_start.php
+++ b/includes/pages/guest_start.php
@@ -1,5 +1,6 @@
<?php
-function guest_start() {
- redirect(page_link_to('login'));
+function guest_start()
+{
+ redirect(page_link_to('login'));
+ return true;
}
-?> \ No newline at end of file
diff --git a/includes/pages/guest_stats.php b/includes/pages/guest_stats.php
index 71fde137..bf1814a3 100644
--- a/includes/pages/guest_stats.php
+++ b/includes/pages/guest_stats.php
@@ -1,35 +1,48 @@
<?php
-function guest_stats() {
- global $api_key;
-
- if (isset($_REQUEST['api_key'])) {
- if ($_REQUEST['api_key'] == $api_key) {
- $stats = [];
-
- list($user_count) = sql_select("SELECT count(*) as `user_count` FROM `User`");
- $stats['user_count'] = $user_count['user_count'];
-
- list($arrived_user_count) = sql_select("SELECT count(*) as `user_count` FROM `User` WHERE `Gekommen`=1");
- $stats['arrived_user_count'] = $arrived_user_count['user_count'];
-
- $done_shifts_seconds = sql_select_single_cell("SELECT SUM(`Shifts`.`end` - `Shifts`.`start`) FROM `ShiftEntry` JOIN `Shifts` USING (`SID`) WHERE `Shifts`.`end` < UNIX_TIMESTAMP()");
- $stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0);
-
- $users_in_action = sql_select("SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` WHERE UNIX_TIMESTAMP() BETWEEN `Shifts`.`start` AND `Shifts`.`end`");
- $stats['users_in_action'] = count($users_in_action);
-
- header("Content-Type: application/json");
- raw_output(json_encode($stats));
- return;
+use Engelsystem\Database\DB;
+
+function guest_stats()
+{
+ $apiKey = config('api_key');
+ $request = request();
+
+ if ($request->has('api_key')) {
+ if (!empty($apiKey) && $request->input('api_key') == $apiKey) {
+ $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');
+ $stats['arrived_user_count'] = $arrived_user_count['user_count'];
+
+ $done_shifts_seconds = DB::selectOne('
+ SELECT SUM(`Shifts`.`end` - `Shifts`.`start`)
+ FROM `ShiftEntry`
+ JOIN `Shifts` USING (`SID`)
+ WHERE `Shifts`.`end` < UNIX_TIMESTAMP()
+ ');
+ $done_shifts_seconds = (int)array_shift($done_shifts_seconds);
+ $stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0);
+
+ $users_in_action = DB::select('
+ SELECT `Shifts`.`start`, `Shifts`.`end`
+ FROM `ShiftEntry`
+ JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID`
+ WHERE UNIX_TIMESTAMP() BETWEEN `Shifts`.`start` AND `Shifts`.`end`
+ ');
+ $stats['users_in_action'] = count($users_in_action);
+
+ header('Content-Type: application/json');
+ raw_output(json_encode($stats));
+ return;
+ }
+ raw_output(json_encode([
+ 'error' => 'Wrong api_key.'
+ ]));
}
raw_output(json_encode([
- 'error' => "Wrong api_key."
+ 'error' => 'Missing parameter api_key.'
]));
- }
- raw_output(json_encode([
- 'error' => "Missing parameter api_key."
- ]));
}
-
-?>
diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php
index 9a765634..c9d9398e 100644
--- a/includes/pages/user_atom.php
+++ b/includes/pages/user_atom.php
@@ -1,51 +1,76 @@
<?php
-// publically available page to feed the news to feedreaders
-function user_atom() {
- global $user, $DISPLAY_NEWS;
-
- if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
- engelsystem_error("Missing key.");
- }
- $key = $_REQUEST['key'];
-
- $user = User_by_api_key($key);
- if ($user == null) {
- engelsystem_error("Key invalid.");
- }
- if (! in_array('atom', privileges_for_user($user['UID']))) {
- engelsystem_error("No privilege for atom.");
- }
-
- $news = sql_select("SELECT * FROM `News` " . (empty($_REQUEST['meetings']) ? '' : 'WHERE `Treffen` = 1 ') . "ORDER BY `ID` DESC LIMIT " . sql_escape($DISPLAY_NEWS));
-
- $output = make_atom_entries_from_news($news);
-
- header('Content-Type: application/atom+xml; charset=utf-8');
- header("Content-Length: " . strlen($output));
- raw_output($output);
+use Engelsystem\Database\DB;
+
+/**
+ * Publically available page to feed the news to feed readers
+ */
+function user_atom()
+{
+ global $user;
+ $request = request();
+
+ if (!$request->has('key') || !preg_match('/^[\da-f]{32}$/', $request->input('key'))) {
+ engelsystem_error('Missing key.');
+ }
+ $key = $request->input('key');
+
+ $user = User_by_api_key($key);
+ if ($user == null) {
+ engelsystem_error('Key invalid.');
+ }
+ if (!in_array('atom', privileges_for_user($user['UID']))) {
+ engelsystem_error('No privilege for atom.');
+ }
+
+ $news = DB::select('
+ SELECT *
+ FROM `News`
+ ' . (!$request->has('meetings') ? '' : 'WHERE `Treffen` = 1 ') . '
+ ORDER BY `ID`
+ DESC LIMIT ' . (int)config('display_news')
+ );
+
+ $output = make_atom_entries_from_news($news);
+
+ header('Content-Type: application/atom+xml; charset=utf-8');
+ header('Content-Length: ' . strlen($output));
+ raw_output($output);
}
-function make_atom_entries_from_news($news_entries) {
- $html = '<?xml version="1.0" encoding="utf-8"?>
+/**
+ * @param array[] $news_entries
+ * @return string
+ */
+function make_atom_entries_from_news($news_entries)
+{
+ $request = app('request');
+ $html = '<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Engelsystem</title>
- <id>' . $_SERVER['HTTP_HOST'] . htmlspecialchars(preg_replace('#[&?]key=[a-f0-9]{32}#', '', $_SERVER['REQUEST_URI'])) . '</id>
- <updated>' . date('Y-m-d\TH:i:sP', $news_entries[0]['Datum']) . "</updated>\n";
- foreach ($news_entries as $news_entry) {
- $html .= make_atom_entry_from_news($news_entry);
- }
- $html .= "</feed>";
- return $html;
+ <id>' . $request->getHttpHost()
+ . htmlspecialchars(preg_replace(
+ '#[&?]key=[a-f\d]{32}#',
+ '',
+ $request->getRequestUri()
+ ))
+ . '</id>
+ <updated>' . date('Y-m-d\TH:i:sP', $news_entries[0]['Datum']) . '</updated>' . "\n";
+ foreach ($news_entries as $news_entry) {
+ $html .= make_atom_entry_from_news($news_entry);
+ }
+ $html .= '</feed>';
+ return $html;
}
-function make_atom_entry_from_news($news_entry) {
- return " <entry>
- <title>" . htmlspecialchars($news_entry['Betreff']) . "</title>
- <link href=\"" . page_link_to_absolute("news_comments&amp;nid=") . "${news_entry['ID']}\"/>
- <id>" . preg_replace('#^https?://#', '', page_link_to_absolute("news")) . "-${news_entry['ID']}</id>
- <updated>" . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . "</updated>
- <summary type=\"html\">" . htmlspecialchars($news_entry['Text']) . "</summary>
- </entry>\n";
+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>
+ <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 34860b70..8d22c4eb 100644
--- a/includes/pages/user_ical.php
+++ b/includes/pages/user_ical.php
@@ -3,61 +3,67 @@
/**
* Controller for ical output of users own shifts or any user_shifts filter.
*/
-function user_ical() {
- global $user;
-
- if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
- engelsystem_error("Missing key.");
- }
- $key = $_REQUEST['key'];
-
- $user = User_by_api_key($key);
- if ($user == null) {
- engelsystem_error("Key invalid.");
- }
-
- if (! in_array('ical', privileges_for_user($user['UID']))) {
- engelsystem_error("No privilege for ical.");
- }
-
- $ical_shifts = load_ical_shifts();
-
- send_ical_from_shifts($ical_shifts);
+function user_ical()
+{
+ global $user;
+ $request = request();
+
+ if (!$request->has('key') || !preg_match('/^[\da-f]{32}$/', $request->input('key'))) {
+ engelsystem_error('Missing key.');
+ }
+ $key = $request->input('key');
+
+ $user = User_by_api_key($key);
+ if ($user == null) {
+ engelsystem_error('Key invalid.');
+ }
+
+ if (!in_array('ical', privileges_for_user($user['UID']))) {
+ engelsystem_error('No privilege for ical.');
+ }
+
+ $ical_shifts = load_ical_shifts();
+
+ send_ical_from_shifts($ical_shifts);
}
/**
* Renders an ical calender from given shifts array.
*
- * @param array<Shift> $shifts
+ * @param array <Shift> $shifts
*/
-function send_ical_from_shifts($shifts) {
- header("Content-Type: text/calendar; charset=utf-8");
- $output = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//-//Engelsystem//DE\r\nCALSCALE:GREGORIAN\r\n";
- foreach ($shifts as $shift) {
- $output .= make_ical_entry_from_shift($shift);
- }
- $output .= "END:VCALENDAR\r\n";
- $output = trim($output, "\x0A");
- header("Content-Length: " . strlen($output));
- raw_output($output);
+function send_ical_from_shifts($shifts)
+{
+ header('Content-Type: text/calendar; charset=utf-8');
+ header('Content-Disposition: attachment; filename=shifts.ics');
+ $output = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//-//Engelsystem//DE\r\nCALSCALE:GREGORIAN\r\n";
+ foreach ($shifts as $shift) {
+ $output .= make_ical_entry_from_shift($shift);
+ }
+ $output .= "END:VCALENDAR\r\n";
+ $output = trim($output, "\x0A");
+ header('Content-Length: ' . strlen($output));
+ raw_output($output);
}
/**
* Renders an ical vevent from given shift.
*
- * @param Shift $shift
+ * @param array $shift
+ * @return string
*/
-function make_ical_entry_from_shift($shift) {
- $output = "BEGIN:VEVENT\r\n";
- $output .= "UID:" . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n";
- $output .= "SUMMARY:" . str_replace("\n", "\\n", $shift['name']) . " (" . str_replace("\n", "\\n", $shift['title']) . ")\r\n";
- if (isset($shift['Comment'])) {
- $output .= "DESCRIPTION:" . str_replace("\n", "\\n", $shift['Comment']) . "\r\n";
- }
- $output .= "DTSTART;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['start']) . "\r\n";
- $output .= "DTEND;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['end']) . "\r\n";
- $output .= "LOCATION:" . $shift['Name'] . "\r\n";
- $output .= "END:VEVENT\r\n";
- return $output;
+function make_ical_entry_from_shift($shift)
+{
+ $output = "BEGIN:VEVENT\r\n";
+ $output .= 'UID:' . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n";
+ $output .= 'SUMMARY:' . str_replace("\n", "\\n", $shift['name'])
+ . ' (' . str_replace("\n", "\\n", $shift['title']) . ")\r\n";
+ if (isset($shift['Comment'])) {
+ $output .= 'DESCRIPTION:' . str_replace("\n", "\\n", $shift['Comment']) . "\r\n";
+ }
+ $output .= 'DTSTART;TZID=Europe/Berlin:' . date("Ymd\THis", $shift['start']) . "\r\n";
+ $output .= 'DTEND;TZID=Europe/Berlin:' . date("Ymd\THis", $shift['end']) . "\r\n";
+ $output .= 'LOCATION:' . $shift['Name'] . "\r\n";
+ $output .= "END:VEVENT\r\n";
+ return $output;
}
-?>
diff --git a/includes/pages/user_messages.php b/includes/pages/user_messages.php
index eb07deea..06ae7e75 100644
--- a/includes/pages/user_messages.php
+++ b/includes/pages/user_messages.php
@@ -1,131 +1,182 @@
<?php
-function messages_title() {
- return _("Messages");
-}
+use Engelsystem\Database\DB;
-function user_unread_messages() {
- global $user;
-
- if (isset($user)) {
- $new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`='" . sql_escape($user['UID']) . "'");
- if ($new_messages > 0) {
- return ' <span class="badge danger">' . $new_messages . '</span>';
- }
- }
- return '';
+/**
+ * @return string
+ */
+function messages_title()
+{
+ return _('Messages');
}
-function user_messages() {
- global $user;
-
- if (! isset($_REQUEST['action'])) {
- $users = sql_select("SELECT * FROM `User` WHERE NOT `UID`='" . sql_escape($user['UID']) . "' ORDER BY `Nick`");
-
- $to_select_data = [
- "" => _("Select recipient...")
- ];
-
- foreach ($users as $u) {
- $to_select_data[$u['UID']] = $u['Nick'];
- }
-
- $to_select = html_select_key('to', 'to', $to_select_data, '');
-
- $messages = sql_select("SELECT * FROM `Messages` WHERE `SUID`='" . sql_escape($user['UID']) . "' OR `RUID`='" . sql_escape($user['UID']) . "' ORDER BY `isRead`,`Datum` DESC");
-
- $messages_table = [
- [
- 'news' => '',
- 'timestamp' => date("Y-m-d H:i"),
- 'from' => User_Nick_render($user),
- 'to' => $to_select,
- 'text' => form_textarea('text', '', ''),
- 'actions' => form_submit('submit', _("Save"))
- ]
- ];
-
- foreach ($messages as $message) {
- $sender_user_source = User($message['SUID']);
- $receiver_user_source = User($message['RUID']);
-
- $messages_table_entry = [
- 'new' => $message['isRead'] == 'N' ? '<span class="glyphicon glyphicon-envelope"></span>' : '',
- 'timestamp' => date("Y-m-d H:i", $message['Datum']),
- 'from' => User_Nick_render($sender_user_source),
- 'to' => User_Nick_render($receiver_user_source),
- 'text' => str_replace("\n", '<br />', $message['Text'])
- ];
-
- if ($message['RUID'] == $user['UID']) {
- if ($message['isRead'] == 'N') {
- $messages_table_entry['actions'] = button(page_link_to("user_messages") . '&action=read&id=' . $message['id'], _("mark as read"), 'btn-xs');
+/**
+ * @return string
+ */
+function user_unread_messages()
+{
+ global $user;
+
+ if (isset($user)) {
+ $new_messages = count(DB::select(
+ 'SELECT `id` FROM `Messages` WHERE isRead=\'N\' AND `RUID`=?',
+ [$user['UID']]
+ ));
+ if ($new_messages > 0) {
+ return ' <span class="badge danger">' . $new_messages . '</span>';
}
- } else {
- $messages_table_entry['actions'] = button(page_link_to("user_messages") . '&action=delete&id=' . $message['id'], _("delete message"), 'btn-xs');
- }
- $messages_table[] = $messages_table_entry;
}
-
- return page_with_title(messages_title(), [
- msg(),
- sprintf(_("Hello %s, here can you leave messages for other angels"), User_Nick_render($user)),
- form([
- table([
- 'new' => _("New"),
- 'timestamp' => _("Date"),
- 'from' => _("Transmitted"),
- 'to' => _("Recipient"),
- 'text' => _("Message"),
- 'actions' => ''
- ], $messages_table)
- ], page_link_to('user_messages') . '&action=send')
- ]);
- } else {
- switch ($_REQUEST['action']) {
- case "read":
- if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
- $message_id = $_REQUEST['id'];
- } else {
- return error(_("Incomplete call, missing Message ID."), true);
- }
-
- $message = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
- if (count($message) > 0 && $message[0]['RUID'] == $user['UID']) {
- sql_query("UPDATE `Messages` SET `isRead`='Y' WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
- redirect(page_link_to("user_messages"));
- } else {
- return error(_("No Message found."), true);
- }
- break;
-
- case "delete":
- if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
- $message_id = $_REQUEST['id'];
- } else {
- return error(_("Incomplete call, missing Message ID."), true);
+ return '';
+}
+
+/**
+ * @return string
+ */
+function user_messages()
+{
+ global $user;
+ $request = request();
+
+ if (!$request->has('action')) {
+ $users = DB::select(
+ 'SELECT `UID`, `Nick` FROM `User` WHERE NOT `UID`=? ORDER BY `Nick`',
+ [$user['UID']]
+ );
+
+ $to_select_data = [
+ '' => _('Select recipient...')
+ ];
+
+ foreach ($users as $u) {
+ $to_select_data[$u['UID']] = $u['Nick'];
}
-
- $message = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
- if (count($message) > 0 && $message[0]['SUID'] == $user['UID']) {
- sql_query("DELETE FROM `Messages` WHERE `id`='" . sql_escape($message_id) . "' LIMIT 1");
- redirect(page_link_to("user_messages"));
- } else {
- return error(_("No Message found."), true);
+
+ $to_select = html_select_key('to', 'to', $to_select_data, '');
+
+ $messages = DB::select('
+ SELECT *
+ FROM `Messages`
+ WHERE `SUID`=?
+ OR `RUID`=?
+ ORDER BY `isRead`,`Datum` DESC
+ ',
+ [
+ $user['UID'],
+ $user['UID'],
+ ]
+ );
+
+ $messages_table = [
+ [
+ 'news' => '',
+ 'timestamp' => date('Y-m-d H:i'),
+ 'from' => User_Nick_render($user),
+ 'to' => $to_select,
+ 'text' => form_textarea('text', '', ''),
+ 'actions' => form_submit('submit', _('Save'))
+ ]
+ ];
+
+ foreach ($messages as $message) {
+ $sender_user_source = User($message['SUID']);
+ $receiver_user_source = User($message['RUID']);
+
+ $messages_table_entry = [
+ 'new' => $message['isRead'] == 'N' ? '<span class="glyphicon glyphicon-envelope"></span>' : '',
+ 'timestamp' => date('Y-m-d H:i', $message['Datum']),
+ 'from' => User_Nick_render($sender_user_source),
+ 'to' => User_Nick_render($receiver_user_source),
+ 'text' => str_replace("\n", '<br />', $message['Text'])
+ ];
+
+ if ($message['RUID'] == $user['UID']) {
+ if ($message['isRead'] == 'N') {
+ $messages_table_entry['actions'] = button(
+ page_link_to('user_messages', ['action' => 'read', 'id' => $message['id']]),
+ _('mark as read'),
+ 'btn-xs'
+ );
+ }
+ } else {
+ $messages_table_entry['actions'] = button(
+ page_link_to('user_messages', ['action' => 'delete', 'id' => $message['id']]),
+ _('delete message'),
+ 'btn-xs'
+ );
+ }
+ $messages_table[] = $messages_table_entry;
}
- break;
-
- case "send":
- if (Message_send($_REQUEST['to'], $_REQUEST['text']) === true) {
- redirect(page_link_to("user_messages"));
- } else {
- return error(_("Transmitting was terminated with an Error."), true);
+
+ return page_with_title(messages_title(), [
+ msg(),
+ sprintf(_('Hello %s, here can you leave messages for other angels'), User_Nick_render($user)),
+ form([
+ table([
+ 'new' => _('New'),
+ 'timestamp' => _('Date'),
+ 'from' => _('Transmitted'),
+ 'to' => _('Recipient'),
+ 'text' => _('Message'),
+ 'actions' => ''
+ ], $messages_table)
+ ], page_link_to('user_messages', ['action' => 'send']))
+ ]);
+ } else {
+ switch ($request->input('action')) {
+ case 'read':
+ if ($request->has('id') && preg_match('/^\d{1,11}$/', $request->input('id'))) {
+ $message_id = $request->input('id');
+ } else {
+ return error(_('Incomplete call, missing Message ID.'), true);
+ }
+
+ $message = DB::selectOne(
+ 'SELECT `RUID` FROM `Messages` WHERE `id`=? LIMIT 1',
+ [$message_id]
+ );
+ if (!empty($message) && $message['RUID'] == $user['UID']) {
+ DB::update(
+ 'UPDATE `Messages` SET `isRead`=\'Y\' WHERE `id`=? LIMIT 1',
+ [$message_id]
+ );
+ redirect(page_link_to('user_messages'));
+ } else {
+ return error(_('No Message found.'), true);
+ }
+ break;
+
+ case 'delete':
+ if ($request->has('id') && preg_match('/^\d{1,11}$/', $request->input('id'))) {
+ $message_id = $request->input('id');
+ } else {
+ return error(_('Incomplete call, missing Message ID.'), true);
+ }
+
+ $message = DB::selectOne(
+ 'SELECT `SUID` FROM `Messages` WHERE `id`=? LIMIT 1',
+ [$message_id]
+ );
+ if (!empty($message) && $message['SUID'] == $user['UID']) {
+ DB::delete('DELETE FROM `Messages` WHERE `id`=? LIMIT 1', [$message_id]);
+ redirect(page_link_to('user_messages'));
+ } else {
+ return error(_('No Message found.'), true);
+ }
+ break;
+
+ case 'send':
+ // @TODO: Validation?
+ if (Message_send($request->input('to'), $request->input('text'))) {
+ redirect(page_link_to('user_messages'));
+ } else {
+ return error(_('Transmitting was terminated with an Error.'), true);
+ }
+ break;
+
+ default:
+ return error(_('Wrong action.'), true);
}
- break;
-
- default:
- return error(_("Wrong action."), true);
}
- }
+
+ return '';
}
-?>
diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php
index 3cf0c571..836bd566 100644
--- a/includes/pages/user_myshifts.php
+++ b/includes/pages/user_myshifts.php
@@ -1,118 +1,169 @@
<?php
-function myshifts_title() {
- return _("My shifts");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function myshifts_title()
+{
+ return _('My shifts');
}
-// Zeigt die Schichten an, die ein Benutzer belegt
-function user_myshifts() {
- global $LETZTES_AUSTRAGEN;
- global $user, $privileges;
-
- if (isset($_REQUEST['id']) && in_array("user_shifts_admin", $privileges) && preg_match("/^[0-9]{1,}$/", $_REQUEST['id']) && sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($_REQUEST['id']) . "'") > 0) {
- $user_id = $_REQUEST['id'];
- } else {
- $user_id = $user['UID'];
- }
-
- list($shifts_user) = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
-
- if (isset($_REQUEST['reset'])) {
- if ($_REQUEST['reset'] == "ack") {
- User_reset_api_key($user);
- success(_("Key changed."));
- redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
+/**
+ * Zeigt die Schichten an, die ein Benutzer belegt
+ *
+ * @return string
+ */
+function user_myshifts()
+{
+ global $user, $privileges;
+ $request = request();
+
+ if (
+ $request->has('id')
+ && in_array('user_shifts_admin', $privileges)
+ && preg_match('/^\d{1,}$/', $request->input('id'))
+ && count(DB::select('SELECT `UID` FROM `User` WHERE `UID`=?', [$request->input('id')])) > 0
+ ) {
+ $user_id = $request->input('id');
+ } else {
+ $user_id = $user['UID'];
}
- return page_with_title(_("Reset API key"), [
- error(_("If you reset the key, the url to your iCal- and JSON-export and your atom feed changes! You have to update it in every application using one of these exports."), true),
- button(page_link_to('user_myshifts') . '&reset=ack', _("Continue"), 'btn-danger')
- ]);
- } elseif (isset($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) {
- $user_id = $_REQUEST['edit'];
- $shift = sql_select("SELECT
- `ShiftEntry`.`freeloaded`,
- `ShiftEntry`.`freeload_comment`,
- `ShiftEntry`.`Comment`,
- `ShiftEntry`.`UID`,
- `ShiftTypes`.`name`,
- `Shifts`.*,
- `Room`.`Name`,
- `AngelTypes`.`name` as `angel_type`
- FROM `ShiftEntry`
- JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`)
- JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
- JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
- JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
- WHERE `ShiftEntry`.`id`='" . sql_escape($user_id) . "'
- AND `UID`='" . sql_escape($shifts_user['UID']) . "' LIMIT 1");
- if (count($shift) > 0) {
- $shift = $shift[0];
- $freeloaded = $shift['freeloaded'];
- $freeload_comment = $shift['freeload_comment'];
-
- if (isset($_REQUEST['submit'])) {
- $valid = true;
- if (in_array("user_shifts_admin", $privileges)) {
- $freeloaded = isset($_REQUEST['freeloaded']);
- $freeload_comment = strip_request_item_nl('freeload_comment');
- if ($freeloaded && $freeload_comment == '') {
- $valid = false;
- error(_("Please enter a freeload comment!"));
- }
+
+ $shifts_user = DB::selectOne('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$user_id]);
+
+ if ($request->has('reset')) {
+ if ($request->input('reset') == 'ack') {
+ User_reset_api_key($user);
+ success(_('Key changed.'));
+ redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user['UID']]));
}
-
- $comment = strip_request_item_nl('comment');
- $user_source = User($shift['UID']);
-
- if ($valid) {
- $result = ShiftEntry_update([
- 'id' => $user_id,
- 'Comment' => $comment,
- 'freeloaded' => $freeloaded,
- 'freeload_comment' => $freeload_comment
- ]);
- if ($result === false) {
- engelsystem_error('Unable to update shift entry.');
- }
-
- engelsystem_log("Updated " . User_Nick_render($user_source) . "'s shift " . $shift['name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']) . " with comment " . $comment . ". Freeloaded: " . ($freeloaded ? "YES Comment: " . $freeload_comment : "NO"));
- success(_("Shift saved."));
- redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
+ return page_with_title(_('Reset API key'), [
+ error(
+ _('If you reset the key, the url to your iCal- and JSON-export and your atom feed changes! You have to update it in every application using one of these exports.'),
+ true
+ ),
+ button(page_link_to('user_myshifts', ['reset' => 'ack']), _('Continue'), 'btn-danger')
+ ]);
+ } elseif ($request->has('edit') && preg_match('/^\d+$/', $request->input('edit'))) {
+ $user_id = $request->input('edit');
+ $shift = DB::selectOne('
+ SELECT
+ `ShiftEntry`.`freeloaded`,
+ `ShiftEntry`.`freeload_comment`,
+ `ShiftEntry`.`Comment`,
+ `ShiftEntry`.`UID`,
+ `ShiftTypes`.`name`,
+ `Shifts`.*,
+ `Room`.`Name`,
+ `AngelTypes`.`name` AS `angel_type`
+ FROM `ShiftEntry`
+ JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`)
+ JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
+ JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
+ JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`)
+ WHERE `ShiftEntry`.`id`=?
+ AND `UID`=?
+ LIMIT 1
+ ',
+ [
+ $user_id,
+ $shifts_user['UID'],
+ ]
+ );
+ if (count($shift) > 0) {
+ $freeloaded = $shift['freeloaded'];
+ $freeload_comment = $shift['freeload_comment'];
+
+ if ($request->has('submit')) {
+ $valid = true;
+ if (in_array('user_shifts_admin', $privileges)) {
+ $freeloaded = $request->has('freeloaded');
+ $freeload_comment = strip_request_item_nl('freeload_comment');
+ if ($freeloaded && $freeload_comment == '') {
+ $valid = false;
+ error(_('Please enter a freeload comment!'));
+ }
+ }
+
+ $comment = strip_request_item_nl('comment');
+ $user_source = User($shift['UID']);
+
+ if ($valid) {
+ ShiftEntry_update([
+ 'id' => $user_id,
+ 'Comment' => $comment,
+ 'freeloaded' => $freeloaded,
+ 'freeload_comment' => $freeload_comment
+ ]);
+
+ engelsystem_log(
+ 'Updated ' . User_Nick_render($user_source) . '\'s shift ' . $shift['name']
+ . ' from ' . date('Y-m-d H:i', $shift['start'])
+ . ' to ' . date('Y-m-d H:i', $shift['end'])
+ . ' with comment ' . $comment
+ . '. Freeloaded: ' . ($freeloaded ? 'YES Comment: ' . $freeload_comment : 'NO')
+ );
+ success(_('Shift saved.'));
+ redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user['UID']]));
+ }
+ }
+
+ return ShiftEntry_edit_view(
+ User_Nick_render($shifts_user),
+ date('Y-m-d H:i', $shift['start']) . ', ' . shift_length($shift),
+ $shift['Name'],
+ $shift['name'],
+ $shift['angel_type'],
+ $shift['Comment'],
+ $shift['freeloaded'],
+ $shift['freeload_comment'],
+ in_array('user_shifts_admin', $privileges)
+ );
+ } else {
+ redirect(page_link_to('user_myshifts'));
}
- }
-
- return ShiftEntry_edit_view(User_Nick_render($shifts_user), date("Y-m-d H:i", $shift['start']) . ', ' . shift_length($shift), $shift['Name'], $shift['name'], $shift['angel_type'], $shift['Comment'], $shift['freeloaded'], $shift['freeload_comment'], in_array("user_shifts_admin", $privileges));
- } else {
- redirect(page_link_to('user_myshifts'));
- }
- } elseif (isset($_REQUEST['cancel']) && preg_match("/^[0-9]*$/", $_REQUEST['cancel'])) {
- $user_id = $_REQUEST['cancel'];
- $shift = sql_select("
- SELECT *
- FROM `Shifts`
- INNER JOIN `ShiftEntry` USING (`SID`)
- WHERE `ShiftEntry`.`id`='" . sql_escape($user_id) . "' AND `UID`='" . sql_escape($shifts_user['UID']) . "'");
- if (count($shift) > 0) {
- $shift = $shift[0];
- if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) {
- $result = ShiftEntry_delete($user_id);
- if ($result === false) {
- engelsystem_error('Unable to delete shift entry.');
+ } elseif ($request->has('cancel') && preg_match('/^\d+$/', $request->input('cancel'))) {
+ $user_id = $request->input('cancel');
+ $shift = DB::selectOne('
+ SELECT *
+ FROM `Shifts`
+ INNER JOIN `ShiftEntry` USING (`SID`)
+ WHERE `ShiftEntry`.`id`=? AND `UID`=?
+ ',
+ [
+ $user_id,
+ $shifts_user['UID'],
+ ]
+ );
+ if (count($shift) > 0) {
+ if (
+ ($shift['start'] > time() + config('last_unsubscribe') * 3600)
+ || in_array('user_shifts_admin', $privileges)
+ ) {
+ ShiftEntry_delete($user_id);
+
+ $room = Room($shift['RID']);
+ $angeltype = AngelType($shift['TID']);
+ $shifttype = ShiftType($shift['shifttype_id']);
+
+ engelsystem_log(
+ 'Deleted own shift: ' . $shifttype['name']
+ . ' at ' . $room['Name']
+ . ' from ' . date('Y-m-d H:i', $shift['start'])
+ . ' to ' . date('Y-m-d H:i', $shift['end'])
+ . ' as ' . $angeltype['name']
+ );
+ success(_('Shift canceled.'));
+ } else {
+ error(_('It\'s too late to sign yourself off the shift. If neccessary, ask the dispatcher to do so.'));
+ }
+ } else {
+ redirect(user_link($shifts_user));
}
- $room = Room($shift['RID']);
- $angeltype = AngelType($shift['TID']);
- $shifttype = ShiftType($shift['shifttype_id']);
-
- engelsystem_log("Deleted own shift: " . $shifttype['name'] . " at " . $room['Name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end']) . " as " . $angeltype['name']);
- success(_("Shift canceled."));
- } else {
- error(_("It's too late to sign yourself off the shift. If neccessary, ask the dispatcher to do so."));
- }
- } else {
- redirect(user_link($shifts_user));
}
- }
-
- redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
+
+ redirect(page_link_to('users', ['action' => 'view', 'user_id' => $shifts_user['UID']]));
+ return '';
}
-?>
diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php
index 97f7ec83..b51b0a4c 100644
--- a/includes/pages/user_news.php
+++ b/includes/pages/user_news.php
@@ -1,169 +1,261 @@
<?php
-function user_news_comments_title() {
- return _("News comments");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function user_news_comments_title()
+{
+ return _('News comments');
}
-function news_title() {
- return _("News");
+/**
+ * @return string
+ */
+function news_title()
+{
+ return _('News');
}
-function meetings_title() {
- return _("Meetings");
+/**
+ * @return string
+ */
+function meetings_title()
+{
+ return _('Meetings');
}
-function user_meetings() {
- global $DISPLAY_NEWS;
-
- $html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg();
-
- if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) {
- $page = $_REQUEST['page'];
- } else {
- $page = 0;
- }
-
- $news = sql_select("SELECT * FROM `News` WHERE `Treffen`=1 ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS));
- foreach ($news as $entry) {
- $html .= display_news($entry);
- }
-
- $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS);
- $html .= '<div class="text-center">' . '<ul class="pagination">';
- for ($i = 0; $i < $dis_rows; $i ++) {
- if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) {
- $html .= '<li class="active">';
- } elseif (! isset($_REQUEST['page']) && $i == 0) {
- $html .= '<li class="active">';
+/**
+ * @return string
+ */
+function user_meetings()
+{
+ $display_news = config('display_news');
+ $html = '<div class="col-md-12"><h1>' . meetings_title() . '</h1>' . msg();
+ $request = request();
+
+ if (preg_match('/^\d{1,}$/', $request->input('page', 0))) {
+ $page = $request->input('page', 0);
} else {
- $html .= '<li>';
+ $page = 0;
+ }
+
+ $news = DB::select(sprintf('
+ SELECT *
+ FROM `News`
+ WHERE `Treffen`=1
+ ORDER BY `Datum`DESC
+ LIMIT %u, %u',
+ $page * $display_news,
+ $display_news
+ ));
+ foreach ($news as $entry) {
+ $html .= display_news($entry);
}
- $html .= '<a href="' . page_link_to("user_meetings") . '&page=' . $i . '">' . ($i + 1) . '</a></li>';
- }
- $html .= '</ul></div></div>';
-
- return $html;
-}
-function display_news($news) {
- global $privileges, $page;
-
- $html = '';
- $html .= '<div class="panel' . ($news['Treffen'] == 1 ? ' panel-info' : ' panel-default') . '">';
- $html .= '<div class="panel-heading">';
- $html .= '<h3 class="panel-title">' . ($news['Treffen'] == 1 ? '[Meeting] ' : '') . ReplaceSmilies($news['Betreff']) . '</h3>';
- $html .= '</div>';
- $html .= '<div class="panel-body">' . ReplaceSmilies(nl2br($news['Text'])) . '</div>';
-
- $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') . '</div>';
- }
- $html .= '<span class="glyphicon glyphicon-time"></span> ' . date("Y-m-d H:i", $news['Datum']) . '&emsp;';
-
- $user_source = User($news['UID']);
-
- $html .= User_Nick_render($user_source);
- if ($page != "news_comments") {
- $html .= '&emsp;<a href="' . page_link_to("news_comments") . '&nid=' . $news['ID'] . '"><span class="glyphicon glyphicon-comment"></span> ' . _("Comments") . ' &raquo;</a> <span class="badge">' . sql_num_query("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($news['ID']) . "'") . '</span>';
- }
- $html .= '</div>';
- $html .= '</div>';
- return $html;
+ $dis_rows = ceil(count(DB::select('SELECT `ID` FROM `News`')) / $display_news);
+ $html .= '<div class="text-center">' . '<ul class="pagination">';
+ for ($i = 0; $i < $dis_rows; $i++) {
+ if ($request->has('page') && $i == $request->input('page', 0)) {
+ $html .= '<li class="active">';
+ } elseif (!$request->has('page') && $i == 0) {
+ $html .= '<li class="active">';
+ } else {
+ $html .= '<li>';
+ }
+ $html .= '<a href="' . page_link_to('user_meetings', ['page' => $i]) . '">' . ($i + 1) . '</a></li>';
+ }
+ $html .= '</ul></div></div>';
+
+ return $html;
}
-function user_news_comments() {
- global $user;
-
- $html = '<div class="col-md-12"><h1>' . user_news_comments_title() . '</h1>';
- if (isset($_REQUEST["nid"]) && preg_match("/^[0-9]{1,}$/", $_REQUEST['nid']) && sql_num_query("SELECT * FROM `News` WHERE `ID`='" . sql_escape($_REQUEST['nid']) . "' LIMIT 1") > 0) {
- $nid = $_REQUEST["nid"];
- list($news) = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($nid) . "' LIMIT 1");
- if (isset($_REQUEST["text"])) {
- $text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['text']));
- sql_query("INSERT INTO `NewsComments` (`Refid`, `Datum`, `Text`, `UID`) VALUES ('" . sql_escape($nid) . "', '" . date("Y-m-d H:i:s") . "', '" . sql_escape($text) . "', '" . sql_escape($user["UID"]) . "')");
- engelsystem_log("Created news_comment: " . $text);
- $html .= success(_("Entry saved."), true);
+/**
+ * @param array $news
+ * @return string
+ */
+function display_news($news)
+{
+ global $privileges, $page;
+
+ $html = '';
+ $html .= '<div class="panel' . ($news['Treffen'] == 1 ? ' panel-info' : ' panel-default') . '">';
+ $html .= '<div class="panel-heading">';
+ $html .= '<h3 class="panel-title">' . ($news['Treffen'] == 1 ? '[Meeting] ' : '') . ReplaceSmilies($news['Betreff']) . '</h3>';
+ $html .= '</div>';
+ $html .= '<div class="panel-body">' . ReplaceSmilies(nl2br($news['Text'])) . '</div>';
+
+ $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')
+ . '</div>';
}
-
- $html .= display_news($news);
-
- $comments = sql_select("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($nid) . "' ORDER BY 'ID'");
- foreach ($comments as $comment) {
- $user_source = User($comment['UID']);
-
- $html .= '<div class="panel panel-default">';
- $html .= '<div class="panel-body">' . nl2br($comment['Text']) . '</div>';
- $html .= '<div class="panel-footer text-muted">';
- $html .= '<span class="glyphicon glyphicon-time"></span> ' . $comment['Datum'] . '&emsp;';
- $html .= User_Nick_render($user_source);
- $html .= '</div>';
- $html .= '</div>';
+ $html .= '<span class="glyphicon glyphicon-time"></span> ' . date('Y-m-d H:i', $news['Datum']) . '&emsp;';
+
+ $user_source = User($news['UID']);
+
+ $html .= User_Nick_render($user_source);
+ if ($page != 'news_comments') {
+ $html .= '&emsp;<a href="' . page_link_to('news_comments', ['nid' => $news['ID']]) . '">'
+ . '<span class="glyphicon glyphicon-comment"></span> '
+ . _('Comments') . ' &raquo;</a> '
+ . '<span class="badge">'
+ . count(DB::select('SELECT `ID` FROM `NewsComments` WHERE `Refid`=?', [$news['ID']]))
+ . '</span>';
+ }
+ $html .= '</div>';
+ $html .= '</div>';
+ return $html;
+}
+
+/**
+ * @return string
+ */
+function user_news_comments()
+{
+ global $user;
+
+ $request = request();
+
+ $html = '<div class="col-md-12"><h1>' . user_news_comments_title() . '</h1>';
+ if (
+ $request->has('nid')
+ && preg_match('/^\d{1,}$/', $request->input('nid'))
+ && count(DB::select('SELECT `ID` FROM `News` WHERE `ID`=? LIMIT 1', [$request->input('nid')])) > 0
+ ) {
+ $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')));
+ DB::insert('
+ INSERT INTO `NewsComments` (`Refid`, `Datum`, `Text`, `UID`)
+ VALUES (?, ?, ?, ?)
+ ',
+ [
+ $nid,
+ date('Y-m-d H:i:s'),
+ $text,
+ $user["UID"],
+ ]
+ );
+ engelsystem_log('Created news_comment: ' . $text);
+ $html .= success(_('Entry saved.'), true);
+ }
+
+ $html .= display_news($news);
+
+ $comments = DB::select(
+ 'SELECT * FROM `NewsComments` WHERE `Refid`=? ORDER BY \'ID\'',
+ [$nid]
+ );
+ foreach ($comments as $comment) {
+ $user_source = User($comment['UID']);
+
+ $html .= '<div class="panel panel-default">';
+ $html .= '<div class="panel-body">' . nl2br(htmlspecialchars($comment['Text'])) . '</div>';
+ $html .= '<div class="panel-footer text-muted">';
+ $html .= '<span class="glyphicon glyphicon-time"></span> ' . $comment['Datum'] . '&emsp;';
+ $html .= User_Nick_render($user_source);
+ $html .= '</div>';
+ $html .= '</div>';
+ }
+
+ $html .= '<hr /><h2>' . _('New Comment:') . '</h2>';
+ $html .= form([
+ form_textarea('text', _('Message'), ''),
+ form_submit('submit', _('Save'))
+ ], page_link_to('news_comments', ['nid' => $news['ID']]));
+ } else {
+ $html .= _('Invalid request.');
}
-
- $html .= '<hr /><h2>' . _("New Comment:") . '</h2>';
- $html .= form([
- form_textarea('text', _("Message"), ''),
- form_submit('submit', _("Save"))
- ], page_link_to('news_comments') . '&nid=' . $news['ID']);
- } else {
- $html .= _("Invalid request.");
- }
-
- return $html . '</div>';
+
+ return $html . '</div>';
}
-function user_news() {
- global $DISPLAY_NEWS, $privileges, $user;
-
- $html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg();
-
- if (isset($_POST["text"]) && isset($_POST["betreff"]) && in_array("admin_news", $privileges)) {
- if (! isset($_POST["treffen"]) || ! in_array("admin_news", $privileges)) {
- $_POST["treffen"] = 0;
+/**
+ * @return string
+ */
+function user_news()
+{
+ global $privileges, $user;
+ $display_news = config('display_news');
+ $request = request();
+
+ $html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg();
+
+ $isMeeting = $request->postData('treffen');
+ if ($request->has('text') && $request->has('betreff') && in_array('admin_news', $privileges)) {
+ if (!$request->has('treffen')) {
+ $isMeeting = 0;
+ }
+
+ $text = $request->postData('text');
+ if (!in_array('admin_news_html', $privileges)) {
+ $text = strip_tags($text);
+ }
+
+ DB::insert('
+ INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`)
+ VALUES (?, ?, ?, ?, ?)
+ ',
+ [
+ time(),
+ strip_tags($request->postData('betreff')),
+ $text,
+ $user['UID'],
+ $isMeeting,
+ ]
+ );
+ engelsystem_log('Created news: ' . $request->postData('betreff') . ', treffen: ' . $isMeeting);
+ success(_('Entry saved.'));
+ redirect(page_link_to('news'));
}
- sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . "', '" . sql_escape($_POST["treffen"]) . "');");
- engelsystem_log("Created news: " . $_POST["betreff"] . ", treffen: " . $_POST["treffen"]);
- success(_("Entry saved."));
- redirect(page_link_to('news'));
- }
-
- if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) {
- $page = $_REQUEST['page'];
- } else {
- $page = 0;
- }
-
- $news = sql_select("SELECT * FROM `News` ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS));
- foreach ($news as $entry) {
- $html .= display_news($entry);
- }
-
- $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS);
- $html .= '<div class="text-center">' . '<ul class="pagination">';
- for ($i = 0; $i < $dis_rows; $i ++) {
- if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) {
- $html .= '<li class="active">';
- } elseif (! isset($_REQUEST['page']) && $i == 0) {
- $html .= '<li class="active">';
+
+ if (preg_match('/^\d{1,}$/', $request->input('page', 0))) {
+ $page = $request->input('page', 0);
} else {
- $html .= '<li>';
+ $page = 0;
+ }
+
+ $news = DB::select(sprintf('
+ SELECT *
+ FROM `News`
+ ORDER BY `Datum`
+ DESC LIMIT %u, %u
+ ',
+ $page * $display_news,
+ $display_news
+ ));
+ foreach ($news as $entry) {
+ $html .= display_news($entry);
+ }
+
+ $dis_rows = ceil(count(DB::select('SELECT `ID` FROM `News`')) / $display_news);
+ $html .= '<div class="text-center">' . '<ul class="pagination">';
+ for ($i = 0; $i < $dis_rows; $i++) {
+ if ($request->has('page') && $i == $request->input('page', 0)) {
+ $html .= '<li class="active">';
+ } elseif (!$request->has('page') && $i == 0) {
+ $html .= '<li class="active">';
+ } else {
+ $html .= '<li>';
+ }
+ $html .= '<a href="' . page_link_to('news', ['page' => $i]) . '">' . ($i + 1) . '</a></li>';
+ }
+ $html .= '</ul></div>';
+
+ if (in_array('admin_news', $privileges)) {
+ $html .= '<hr />';
+ $html .= '<h2>' . _('Create news:') . '</h2>';
+
+ $html .= form([
+ form_text('betreff', _('Subject'), ''),
+ form_textarea('text', _('Message'), ''),
+ form_checkbox('treffen', _('Meeting'), false, 1),
+ form_submit('submit', _('Save'))
+ ]);
}
- $html .= '<a href="' . page_link_to("news") . '&page=' . $i . '">' . ($i + 1) . '</a></li>';
- }
- $html .= '</ul></div>';
-
- if (in_array("admin_news", $privileges)) {
- $html .= '<hr />';
- $html .= '<h2>' . _("Create news:") . '</h2>';
-
- $html .= form([
- form_text('betreff', _("Subject"), ''),
- form_textarea('text', _("Message"), ''),
- form_checkbox('treffen', _("Meeting"), false, 1),
- form_submit('submit', _("Save"))
- ]);
- }
- return $html . '</div>';
+ return $html . '</div>';
}
-?>
diff --git a/includes/pages/user_questions.php b/includes/pages/user_questions.php
index 4abceb92..41fbe64d 100644
--- a/includes/pages/user_questions.php
+++ b/includes/pages/user_questions.php
@@ -1,57 +1,88 @@
<?php
-function questions_title() {
- return _("Ask the Heaven");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function questions_title()
+{
+ return _('Ask the Heaven');
}
-function user_questions() {
- global $user;
-
- if (! isset($_REQUEST['action'])) {
- $open_questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`='" . sql_escape($user['UID']) . "'");
-
- $answered_questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL AND `UID`='" . sql_escape($user['UID']) . "'");
- foreach ($answered_questions as &$question) {
- $answer_user_source = User($question['AID']);
- $question['answer_user'] = User_Nick_render($answer_user_source);
- }
-
- return Questions_view($open_questions, $answered_questions, page_link_to("user_questions") . '&action=ask');
- } else {
- switch ($_REQUEST['action']) {
- case 'ask':
- $question = strip_request_item_nl('question');
- if ($question != "") {
- $result = sql_query("INSERT INTO `Questions` SET `UID`='" . sql_escape($user['UID']) . "', `Question`='" . sql_escape($question) . "'");
- if ($result === false) {
- engelsystem_error(_("Unable to save question."));
- }
- success(_("You question was saved."));
- redirect(page_link_to("user_questions"));
- } else {
- return page_with_title(questions_title(), [
- error(_("Please enter a question!"), true)
- ]);
- }
- break;
- case 'delete':
- if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
- $question_id = $_REQUEST['id'];
- } else {
- return error(_("Incomplete call, missing Question ID."), true);
+/**
+ * @return string
+ */
+function user_questions()
+{
+ global $user;
+ $request = request();
+
+ if (!$request->has('action')) {
+ $open_questions = DB::select(
+ 'SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`=?',
+ [$user['UID']]
+ );
+
+ $answered_questions = DB::select(
+ 'SELECT * FROM `Questions` WHERE NOT `AID` IS NULL AND `UID`=?',
+ [$user['UID']]
+ );
+ foreach ($answered_questions as &$question) {
+ $answer_user_source = User($question['AID']);
+ $question['answer_user'] = User_Nick_render($answer_user_source);
}
-
- $question = sql_select("SELECT * FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
- if (count($question) > 0 && $question[0]['UID'] == $user['UID']) {
- sql_query("DELETE FROM `Questions` WHERE `QID`='" . sql_escape($question_id) . "' LIMIT 1");
- redirect(page_link_to("user_questions"));
- } else {
- return page_with_title(questions_title(), [
- error(_("No question found."), true)
- ]);
+
+ return Questions_view(
+ $open_questions,
+ $answered_questions,
+ page_link_to('user_questions', ['action' => 'ask'])
+ );
+ } else {
+ switch ($request->input('action')) {
+ case 'ask':
+ $question = strip_request_item_nl('question');
+ if ($question != '') {
+ DB::insert('
+ INSERT INTO `Questions` (`UID`, `Question`)
+ VALUES (?, ?)
+ ',
+ [$user['UID'], $question]
+ );
+
+ success(_('You question was saved.'));
+ redirect(page_link_to('user_questions'));
+ } else {
+ return page_with_title(questions_title(), [
+ error(_('Please enter a question!'), true)
+ ]);
+ }
+ break;
+ case 'delete':
+ if ($request->has('id') && preg_match('/^\d{1,11}$/', $request->input('id'))) {
+ $question_id = $request->input('id');
+ } else {
+ return error(_('Incomplete call, missing Question ID.'), true);
+ }
+
+ $question = DB::selectOne(
+ 'SELECT `UID` FROM `Questions` WHERE `QID`=? LIMIT 1',
+ [$question_id]
+ );
+ if (!empty($question) && $question['UID'] == $user['UID']) {
+ DB::delete(
+ 'DELETE FROM `Questions` WHERE `QID`=? LIMIT 1',
+ [$question_id]
+ );
+ redirect(page_link_to('user_questions'));
+ } else {
+ return page_with_title(questions_title(), [
+ error(_('No question found.'), true)
+ ]);
+ }
+ break;
}
- break;
}
- }
+
+ return '';
}
-?> \ No newline at end of file
diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php
index e776320f..83d593ad 100644
--- a/includes/pages/user_settings.php
+++ b/includes/pages/user_settings.php
@@ -1,194 +1,254 @@
<?php
-function settings_title() {
- return _("Settings");
+use Engelsystem\Database\DB;
+
+/**
+ * @return string
+ */
+function settings_title()
+{
+ return _('Settings');
}
/**
* Change user main attributes (name, dates, etc.)
*
- * @param User $user_source
- * The user
+ * @param array $user_source The user
+ * @param bool $enable_tshirt_size
+ * @param array $tshirt_sizes
+ * @return array
*/
-function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) {
- $valid = true;
-
- if (isset($_REQUEST['mail'])) {
- $result = User_validate_mail($_REQUEST['mail']);
- $user_source['email'] = $result->getValue();
- if (! $result->isValid()) {
- $valid = false;
- error(_("E-mail address is not correct."));
+function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
+{
+ $valid = true;
+ $request = request();
+
+ if ($request->has('mail')) {
+ $result = User_validate_mail($request->input('mail'));
+ $user_source['email'] = $result->getValue();
+ if (!$result->isValid()) {
+ $valid = false;
+ error(_('E-mail address is not correct.'));
+ }
+ } else {
+ $valid = false;
+ error(_('Please enter your e-mail.'));
}
- } else {
- $valid = false;
- error(_("Please enter your e-mail."));
- }
-
- $user_source['email_shiftinfo'] = isset($_REQUEST['email_shiftinfo']);
- $user_source['email_by_human_allowed'] = isset($_REQUEST['email_by_human_allowed']);
-
- if (isset($_REQUEST['jabber'])) {
- $result = User_validate_jabber($_REQUEST['jabber']);
- $user_source['jabber'] = $result->getValue();
- if (! $result->isValid()) {
- $valid = false;
- error(_("Please check your jabber account information."));
+
+ $user_source['email_shiftinfo'] = $request->has('email_shiftinfo');
+ $user_source['email_by_human_allowed'] = $request->has('email_by_human_allowed');
+
+ if ($request->has('jabber')) {
+ $result = User_validate_jabber($request->input('jabber'));
+ $user_source['jabber'] = $result->getValue();
+ if (!$result->isValid()) {
+ $valid = false;
+ error(_('Please check your jabber account information.'));
+ }
}
- }
-
- if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']])) {
- $user_source['Size'] = $_REQUEST['tshirt_size'];
- } elseif ($enable_tshirt_size) {
- $valid = false;
- }
-
- if (isset($_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()) {
- $valid = false;
- error(_("Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date."));
+
+ if ($request->has('tshirt_size') && isset($tshirt_sizes[$request->input('tshirt_size')])) {
+ $user_source['Size'] = $request->input('tshirt_size');
+ } elseif ($enable_tshirt_size) {
+ $valid = false;
}
- }
-
- if (isset($_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()) {
- $valid = false;
- error(_("Please enter your planned date of departure. It should be after your planned arrival date and after buildup start date and before teardown end date."));
+
+ if ($request->has('planned_arrival_date')) {
+ $tmp = parse_date('Y-m-d H:i', $request->input('planned_arrival_date') . ' 00:00');
+ $result = User_validate_planned_arrival_date($tmp);
+ $user_source['planned_arrival_date'] = $result->getValue();
+ if (!$result->isValid()) {
+ $valid = false;
+ error(_('Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date.'));
+ }
}
- }
-
- // Trivia
- $user_source['Name'] = strip_request_item('lastname', $user_source['Name']);
- $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']);
- $user_source['DECT'] = strip_request_item('dect', $user_source['DECT']);
- $user_source['Handy'] = strip_request_item('mobile', $user_source['Handy']);
- $user_source['Hometown'] = strip_request_item('hometown', $user_source['Hometown']);
-
- if ($valid) {
- User_update($user_source);
- success(_("Settings saved."));
- redirect(page_link_to('user_settings'));
- }
-
- return $user_source;
+
+ if ($request->has('planned_departure_date')) {
+ $tmp = parse_date('Y-m-d H:i', $request->input('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()) {
+ $valid = false;
+ error(_('Please enter your planned date of departure. It should be after your planned arrival date and after buildup start date and before teardown end date.'));
+ }
+ }
+
+ // Trivia
+ $user_source['Name'] = strip_request_item('lastname', $user_source['Name']);
+ $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) {
+ $user_source['DECT'] = strip_request_item('dect', $user_source['DECT']);
+ } else {
+ $valid = false;
+ error(_('For dect numbers are only 5 digits allowed.'));
+ }
+ $user_source['Handy'] = strip_request_item('mobile', $user_source['Handy']);
+ $user_source['Hometown'] = strip_request_item('hometown', $user_source['Hometown']);
+
+ if ($valid) {
+ User_update($user_source);
+
+ success(_('Settings saved.'));
+ redirect(page_link_to('user_settings'));
+ }
+
+ return $user_source;
}
/**
* Change user password.
*
- * @param User $user_source
- * The user
+ * @param array $user_source The user
*/
-function user_settings_password($user_source) {
- global $min_password_length;
- if (! isset($_REQUEST['password']) || ! verify_password($_REQUEST['password'], $user_source['Passwort'], $user_source['UID'])) {
- error(_("-> not OK. Please try again."));
- } elseif (strlen($_REQUEST['new_password']) < $min_password_length) {
- error(_("Your password is to short (please use at least 6 characters)."));
- } elseif ($_REQUEST['new_password'] != $_REQUEST['new_password2']) {
- error(_("Your passwords don't match."));
- } elseif (set_password($user_source['UID'], $_REQUEST['new_password'])) {
- success(_("Password saved."));
- } else {
- error(_("Failed setting password."));
- }
- redirect(page_link_to('user_settings'));
+function user_settings_password($user_source)
+{
+ $request = request();
+ if (
+ !$request->has('password')
+ || !verify_password($request->postData('password'), $user_source['Passwort'], $user_source['UID'])
+ ) {
+ error(_('-> not OK. Please try again.'));
+ } elseif (strlen($request->postData('new_password')) < config('min_password_length')) {
+ error(_('Your password is to short (please use at least 6 characters).'));
+ } elseif ($request->postData('new_password') != $request->postData('new_password2')) {
+ error(_('Your passwords don\'t match.'));
+ } else {
+ set_password($user_source['UID'], $request->postData('new_password'));
+ success(_('Password saved.'));
+ }
+ redirect(page_link_to('user_settings'));
}
/**
* Change user theme
*
- * @param User $user_sources
- * The user
- * @param array<String> $themes
- * List of available themes
+ * @param array $user_source The user
+ * @param array $themes List of available themes
+ * @return mixed
*/
-function user_settings_theme($user_source, $themes) {
- $valid = true;
-
- if (isset($_REQUEST['theme']) && isset($themes[$_REQUEST['theme']])) {
- $user_source['color'] = $_REQUEST['theme'];
- } else {
- $valid = false;
- }
-
- if ($valid) {
- sql_query("UPDATE `User` SET `color`='" . sql_escape($user_source['color']) . "' WHERE `UID`='" . sql_escape($user_source['UID']) . "'");
-
- success(_("Theme changed."));
- redirect(page_link_to('user_settings'));
- }
-
- return $user_source;
+function user_settings_theme($user_source, $themes)
+{
+ $valid = true;
+ $request = request();
+
+ if ($request->has('theme') && isset($themes[$request->input('theme')])) {
+ $user_source['color'] = $request->input('theme');
+ } else {
+ $valid = false;
+ }
+
+ if ($valid) {
+ DB::update('
+ UPDATE `User`
+ SET `color`=?
+ WHERE `UID`=?
+ ',
+ [
+ $user_source['color'],
+ $user_source['UID'],
+ ]
+ );
+
+ success(_('Theme changed.'));
+ redirect(page_link_to('user_settings'));
+ }
+
+ return $user_source;
}
/**
* Change use locale
*
- * @param User $user_source
- * The user
- * @param array<String> $locales
- * List of available locales
+ * @param array $user_source The user
+ * @param array $locales List of available locales
+ * @return array
*/
-function user_settings_locale($user_source, $locales) {
- $valid = true;
-
- if (isset($_REQUEST['language']) && isset($locales[$_REQUEST['language']])) {
- $user_source['Sprache'] = $_REQUEST['language'];
- } else {
- $valid = false;
- }
-
- if ($valid) {
- sql_query("UPDATE `User` SET `Sprache`='" . sql_escape($user_source['Sprache']) . "' WHERE `UID`='" . sql_escape($user_source['UID']) . "'");
- $_SESSION['locale'] = $user_source['Sprache'];
-
- success("Language changed.");
- redirect(page_link_to('user_settings'));
- }
-
- return $user_source;
+function user_settings_locale($user_source, $locales)
+{
+ $valid = true;
+ $request = request();
+ $session = session();
+
+ if ($request->has('language') && isset($locales[$request->input('language')])) {
+ $user_source['Sprache'] = $request->input('language');
+ } else {
+ $valid = false;
+ }
+
+ if ($valid) {
+ DB::update('
+ UPDATE `User`
+ SET `Sprache`=?
+ WHERE `UID`=?
+ ',
+ [
+ $user_source['Sprache'],
+ $user_source['UID'],
+ ]
+ );
+ $session->set('locale', $user_source['Sprache']);
+
+ success('Language changed.');
+ redirect(page_link_to('user_settings'));
+ }
+
+ return $user_source;
}
/**
* Main user settings page/controller
+ *
+ * @return string
*/
-function user_settings() {
- global $enable_tshirt_size, $tshirt_sizes, $themes, $locales;
- global $user;
-
- $buildup_start_date = null;
- $teardown_end_date = null;
- $event_config = EventConfig();
- if ($event_config != null) {
- if (isset($event_config['buildup_start_date'])) {
- $buildup_start_date = $event_config['buildup_start_date'];
+function user_settings()
+{
+ global $user;
+ $request = request();
+ $themes = config('available_themes');
+
+ $enable_tshirt_size = config('enable_tshirt_size');
+ $tshirt_sizes = config('tshirt_sizes');
+ $locales = config('locales');
+
+ $buildup_start_date = null;
+ $teardown_end_date = null;
+ $event_config = EventConfig();
+ if ($event_config != null) {
+ if (isset($event_config['buildup_start_date'])) {
+ $buildup_start_date = $event_config['buildup_start_date'];
+ }
+ if (isset($event_config['teardown_end_date'])) {
+ $teardown_end_date = $event_config['teardown_end_date'];
+ }
}
- if (isset($event_config['teardown_end_date'])) {
- $teardown_end_date = $event_config['teardown_end_date'];
+
+ foreach ($tshirt_sizes as $key => $size) {
+ if (empty($size)) {
+ unset($tshirt_sizes[$key]);
+ }
}
- }
-
- $user_source = $user;
-
- if (isset($_REQUEST['submit'])) {
- $user_source = user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes);
- } elseif (isset($_REQUEST['submit_password'])) {
- user_settings_password($user_source);
- } elseif (isset($_REQUEST['submit_theme'])) {
- $user_source = user_settings_theme($user_source, $themes);
- } elseif (isset($_REQUEST['submit_language'])) {
- $user_source = user_settings_locale($user_source, $locales);
- }
-
- return User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes);
+
+ $user_source = $user;
+
+ if ($request->has('submit')) {
+ $user_source = user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes);
+ } elseif ($request->has('submit_password')) {
+ user_settings_password($user_source);
+ } elseif ($request->has('submit_theme')) {
+ $user_source = user_settings_theme($user_source, $themes);
+ } elseif ($request->has('submit_language')) {
+ $user_source = user_settings_locale($user_source, $locales);
+ }
+
+ return User_settings_view(
+ $user_source,
+ $locales,
+ $themes,
+ $buildup_start_date,
+ $teardown_end_date,
+ $enable_tshirt_size,
+ $tshirt_sizes
+ );
}
-?>
diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php
index c990ee4a..f8cf71cd 100644
--- a/includes/pages/user_shifts.php
+++ b/includes/pages/user_shifts.php
@@ -1,8 +1,14 @@
<?php
+
+use Engelsystem\Database\DB;
use Engelsystem\ShiftsFilter;
-function shifts_title() {
- return _("Shifts");
+/**
+ * @return string
+ */
+function shifts_title()
+{
+ return _('Shifts');
}
/**
@@ -11,187 +17,267 @@ function shifts_title() {
* Transform into shift controller and shift entry controller.
* Split actions into shift edit, shift delete, shift entry edit, shift entry delete
* Introduce simpler and beautiful actions for shift entry join/leave for users
+ *
+ * @return string
*/
-function user_shifts() {
- global $user;
-
- if (User_is_freeloader($user)) {
- redirect(page_link_to('user_myshifts'));
- }
-
- // Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
- if (isset($_REQUEST['entry_id'])) {
- return shift_entry_delete_controller();
- } elseif (isset($_REQUEST['edit_shift'])) {
- return shift_edit_controller();
- } elseif (isset($_REQUEST['delete_shift'])) {
- return shift_delete_controller();
- } elseif (isset($_REQUEST['shift_id'])) {
- return shift_entry_add_controller();
- }
- return view_user_shifts();
+function user_shifts()
+{
+ global $user;
+ $request = request();
+
+ if (User_is_freeloader($user)) {
+ redirect(page_link_to('user_myshifts'));
+ }
+
+ // Löschen einzelner Schicht-Einträge (Also Belegung einer Schicht von Engeln) durch Admins
+ if ($request->has('entry_id')) {
+ shift_entry_delete_controller();
+ return '';
+ } elseif ($request->has('edit_shift')) {
+ return shift_edit_controller();
+ } elseif ($request->has('delete_shift')) {
+ return shift_delete_controller();
+ } elseif ($request->has('shift_id')) {
+ return shift_entry_add_controller();
+ }
+ return view_user_shifts();
}
/**
* Helper function that updates the start and end time from request data.
* Use update_ShiftsFilter().
*
- * @param ShiftsFilter $shiftsFilter
- * The shiftfilter to update.
+ * @param ShiftsFilter $shiftsFilter The shiftfilter to update.
+ * @param string[] $days
*/
-function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days) {
- $start_time = $shiftsFilter->getStartTime();
- if ($start_time == null) {
- $start_time = time();
- }
-
- $end_time = $shiftsFilter->getEndTime();
- if ($end_time == null) {
- $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));
-
- if ($shiftsFilter->getStartTime() > $shiftsFilter->getEndTime()) {
- $shiftsFilter->setEndTime($shiftsFilter->getStartTime() + 24 * 60 * 60);
- }
+function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days)
+{
+ $start_time = $shiftsFilter->getStartTime();
+ if ($start_time == null) {
+ $start_time = time();
+ }
+
+ $end_time = $shiftsFilter->getEndTime();
+ if ($end_time == null) {
+ $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));
+
+ if ($shiftsFilter->getStartTime() > $shiftsFilter->getEndTime()) {
+ $shiftsFilter->setEndTime($shiftsFilter->getStartTime() + 24 * 60 * 60);
+ }
}
/**
* Update given ShiftsFilter with filter params from user input
*
- * @param ShiftsFilter $shiftsFilter
- * The shifts filter to update from request data
- * @param boolean $user_shifts_admin
- * Has the user user_shift_admin privilege?
- * @param string[] $days
- * An array of available filter days
+ * @param ShiftsFilter $shiftsFilter The shifts filter to update from request data
+ * @param boolean $user_shifts_admin Has the user user_shift_admin privilege?
+ * @param string[] $days An array of available filter days
*/
-function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $days) {
- $shiftsFilter->setUserShiftsAdmin($user_shifts_admin);
- $shiftsFilter->setFilled(check_request_int_array('filled', $shiftsFilter->getFilled()));
- $shiftsFilter->setRooms(check_request_int_array('rooms', $shiftsFilter->getRooms()));
- $shiftsFilter->setTypes(check_request_int_array('types', $shiftsFilter->getTypes()));
- update_ShiftsFilter_timerange($shiftsFilter, $days);
+function update_ShiftsFilter(ShiftsFilter $shiftsFilter, $user_shifts_admin, $days)
+{
+ $shiftsFilter->setUserShiftsAdmin($user_shifts_admin);
+ $shiftsFilter->setFilled(check_request_int_array('filled', $shiftsFilter->getFilled()));
+ $shiftsFilter->setRooms(check_request_int_array('rooms', $shiftsFilter->getRooms()));
+ $shiftsFilter->setTypes(check_request_int_array('types', $shiftsFilter->getTypes()));
+ update_ShiftsFilter_timerange($shiftsFilter, $days);
}
-function load_rooms() {
- $rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
- if (count($rooms) == 0) {
- error(_("The administration has not configured any rooms yet."));
- redirect('?');
- }
- return $rooms;
+/**
+ * @return array
+ */
+function load_rooms()
+{
+ $rooms = DB::select(
+ 'SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`=\'Y\' ORDER BY `Name`'
+ );
+ if (empty($rooms)) {
+ error(_('The administration has not configured any rooms yet.'));
+ redirect(page_link_to('/'));
+ }
+ return $rooms;
}
-function load_days() {
- $days = sql_select_single_col("
+/**
+ * @return array
+ */
+function load_days()
+{
+ $days = DB::select('
SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name`
FROM `Shifts`
- ORDER BY `start`");
- if (count($days) == 0) {
- error(_("The administration has not configured any shifts yet."));
- redirect('?');
- }
- return $days;
+ ORDER BY `id`, `name`
+ ');
+ $days = array_map('array_shift', $days);
+
+ if (empty($days)) {
+ error(_('The administration has not configured any shifts yet.'));
+ redirect(page_link_to('/'));
+ }
+ return $days;
}
-function load_types() {
- global $user;
-
- if (sql_num_query("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0") == 0) {
- error(_("The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype."));
- redirect('?');
- }
- $types = sql_select("SELECT `AngelTypes`.`id`, `AngelTypes`.`name`, (`AngelTypes`.`restricted`=0 OR (NOT `UserAngelTypes`.`confirm_user_id` IS NULL OR `UserAngelTypes`.`id` IS NULL)) as `enabled` FROM `AngelTypes` LEFT JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` AND `UserAngelTypes`.`user_id`='" . sql_escape($user['UID']) . "') ORDER BY `AngelTypes`.`name`");
- if (empty($types)) {
- return sql_select("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0");
- }
- return $types;
+/**
+ * @return array|false
+ */
+function load_types()
+{
+ global $user;
+
+ if (!count(DB::select('SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0'))) {
+ error(_('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.'));
+ redirect(page_link_to('/'));
+ }
+ $types = DB::select('
+ SELECT
+ `AngelTypes`.`id`,
+ `AngelTypes`.`name`,
+ (
+ `AngelTypes`.`restricted`=0
+ OR (
+ NOT `UserAngelTypes`.`confirm_user_id` IS NULL
+ OR `UserAngelTypes`.`id` IS NULL
+ )
+ ) AS `enabled`
+ FROM `AngelTypes`
+ LEFT JOIN `UserAngelTypes`
+ ON (
+ `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id`
+ AND `UserAngelTypes`.`user_id`=?
+ )
+ ORDER BY `AngelTypes`.`name`
+ ',
+ [
+ $user['UID'],
+ ]
+ );
+ if (empty($types)) {
+ return DB::select('SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0');
+ }
+ return $types;
}
-function view_user_shifts() {
- global $user, $privileges;
- global $ical_shifts;
-
- $ical_shifts = [];
- $days = load_days();
- $rooms = load_rooms();
- $types = load_types();
-
- if (! isset($_SESSION['ShiftsFilter'])) {
- $room_ids = [
- $rooms[0]['id']
+/**
+ * @return string
+ */
+function view_user_shifts()
+{
+ global $user, $privileges, $ical_shifts;
+
+ $session = session();
+ $ical_shifts = [];
+ $days = load_days();
+ $rooms = load_rooms();
+ $types = load_types();
+
+ if (!$session->has('ShiftsFilter')) {
+ $room_ids = [
+ $rooms[0]['id']
+ ];
+ $type_ids = array_map('get_ids_from_array', $types);
+ $shiftsFilter = new ShiftsFilter(in_array('user_shifts_admin', $privileges), $room_ids, $type_ids);
+ $session->set('ShiftsFilter', $shiftsFilter);
+ }
+
+ $shiftsFilter = $session->get('ShiftsFilter');
+ update_ShiftsFilter($shiftsFilter, in_array('user_shifts_admin', $privileges), $days);
+
+ $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
+
+ if ($user['api_key'] == '') {
+ User_reset_api_key($user, false);
+ }
+
+ $filled = [
+ [
+ 'id' => '1',
+ 'name' => _('occupied')
+ ],
+ [
+ 'id' => '0',
+ 'name' => _('free')
+ ]
];
- $type_ids = array_map('get_ids_from_array', $types);
- $_SESSION['ShiftsFilter'] = new ShiftsFilter(in_array('user_shifts_admin', $privileges), $room_ids, $type_ids);
- }
- update_ShiftsFilter($_SESSION['ShiftsFilter'], in_array('user_shifts_admin', $privileges), $days);
- $shiftsFilter = $_SESSION['ShiftsFilter'];
-
- $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
-
- if ($user['api_key'] == "") {
- User_reset_api_key($user, false);
- }
-
- $filled = [
- [
- 'id' => '1',
- 'name' => _("occupied")
- ],
- [
- 'id' => '0',
- 'name' => _("free")
- ]
- ];
- $start_day = date("Y-m-d", $shiftsFilter->getStartTime());
- $start_time = date("H:i", $shiftsFilter->getStartTime());
- $end_day = date("Y-m-d", $shiftsFilter->getEndTime());
- $end_time = date("H:i", $shiftsFilter->getEndTime());
-
- return page([
- div('col-md-12', [
- msg(),
- template_render(__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_time' => $start_time,
- 'end_select' => html_select_key("end_day", "end_day", array_combine($days, $days), $end_day),
- 'end_time' => $end_time,
- 'type_select' => make_select($types, $shiftsFilter->getTypes(), "types", _("Angeltypes") . '<sup>1</sup>'),
- 'filled_select' => make_select($filled, $shiftsFilter->getFilled(), "filled", _("Occupancy")),
- 'task_notice' => '<sup>1</sup>' . _("The tasks shown here are influenced by the angeltypes you joined already!") . " <a href=\"" . page_link_to('angeltypes') . '&action=about' . "\">" . _("Description of the jobs.") . "</a>",
- 'shifts_table' => msg() . $shiftCalendarRenderer->render(),
- 'ical_text' => '<h2>' . _("iCal export") . '</h2><p>' . sprintf(_("Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%s\">reset the api key</a>)."), page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to('user_myshifts') . '&reset') . '</p>',
- 'filter' => _("Filter")
- ])
- ])
- ]);
+ $start_day = date('Y-m-d', $shiftsFilter->getStartTime());
+ $start_time = date('H:i', $shiftsFilter->getStartTime());
+ $end_day = date('Y-m-d', $shiftsFilter->getEndTime());
+ $end_time = date('H:i', $shiftsFilter->getEndTime());
+
+ $assignNotice = '';
+ if (config('signup_requires_arrival') && !$user['Gekommen']) {
+ $assignNotice = info(render_user_arrived_hint(), true);
+ }
+
+ return page([
+ div('col-md-12', [
+ msg(),
+ 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_time' => $start_time,
+ 'end_select' => html_select_key('end_day', 'end_day', array_combine($days, $days), $end_day),
+ 'end_time' => $end_time,
+ 'type_select' => make_select(
+ $types,
+ $shiftsFilter->getTypes(),
+ 'types',
+ _('Angeltypes') . '<sup>1</sup>'
+ ),
+ 'filled_select' => make_select($filled, $shiftsFilter->getFilled(), 'filled', _('Occupancy')),
+ 'task_notice' =>
+ '<sup>1</sup>'
+ . _('The tasks shown here are influenced by the angeltypes you joined already!')
+ . ' <a href="' . page_link_to('angeltypes', ['action' => 'about']) . '">'
+ . _('Description of the jobs.')
+ . '</a>',
+ 'assign_notice' => $assignNotice,
+ 'shifts_table' => msg() . $shiftCalendarRenderer->render(),
+ 'ical_text' => '<h2>' . _('iCal export') . '</h2><p>' . sprintf(
+ _('Export of shown shifts. <a href="%s">iCal format</a> or <a href="%s">JSON format</a> available (please keep secret, otherwise <a href="%s">reset the api key</a>).'),
+ page_link_to('ical', ['key' => $user['api_key']]),
+ page_link_to('shifts_json_export', ['key' => $user['api_key']]),
+ page_link_to('user_myshifts', ['reset' => 1])
+ ) . '</p>',
+ 'filter' => _('Filter')
+ ])
+ ])
+ ]);
}
-function get_ids_from_array($array) {
- return $array["id"];
+/**
+ * @param array $array
+ * @return array
+ */
+function get_ids_from_array($array)
+{
+ return $array['id'];
}
-function make_select($items, $selected, $name, $title = null) {
- $html_items = [];
- if (isset($title)) {
- $html_items[] = '<h4>' . $title . '</h4>' . "\n";
- }
-
- foreach ($items as $i) {
- $html_items[] = '<div class="checkbox"><label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"' . (in_array($i['id'], $selected) ? ' checked="checked"' : '') . '> ' . $i['name'] . '</label>' . (! isset($i['enabled']) || $i['enabled'] ? '' : glyph("lock")) . '</div><br />';
- }
- $html = '<div id="selection_' . $name . '" class="selection ' . $name . '">' . "\n";
- $html .= implode("\n", $html_items);
- $html .= buttons([
- button("javascript: checkAll('selection_" . $name . "', true)", _("All"), ""),
- button("javascript: checkAll('selection_" . $name . "', false)", _("None"), "")
- ]);
- $html .= '</div>' . "\n";
- return $html;
+function make_select($items, $selected, $name, $title = null)
+{
+ $html_items = [];
+ if (isset($title)) {
+ $html_items[] = '<h4>' . $title . '</h4>' . "\n";
+ }
+
+ foreach ($items as $i) {
+ $html_items[] = '<div class="checkbox">'
+ . '<label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '" '
+ . (in_array($i['id'], $selected) ? ' checked="checked"' : '')
+ . ' > ' . $i['name'] . '</label>'
+ . (!isset($i['enabled']) || $i['enabled'] ? '' : glyph('lock'))
+ . '</div><br />';
+ }
+ $html = '<div id="selection_' . $name . '" class="selection ' . $name . '">' . "\n";
+ $html .= implode("\n", $html_items);
+ $html .= buttons([
+ button('javascript: checkAll(\'selection_' . $name . '\', true)', _('All'), ''),
+ button('javascript: checkAll(\'selection_' . $name . '\', false)', _('None'), '')
+ ]);
+ $html .= '</div>' . "\n";
+ return $html;
}
-?>
diff --git a/includes/sys_auth.php b/includes/sys_auth.php
index 7a1dd4b7..4242261b 100644
--- a/includes/sys_auth.php
+++ b/includes/sys_auth.php
@@ -1,91 +1,157 @@
<?php
+use Engelsystem\Database\DB;
+
/**
* Testet ob ein User eingeloggt ist und lädt die entsprechenden Privilegien
*/
-function load_auth() {
- global $user, $privileges;
-
- $user = null;
- if (isset($_SESSION['uid'])) {
- $user = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($_SESSION['uid']) . "' LIMIT 1");
- if (count($user) > 0) {
- // User ist eingeloggt, Datensatz zur Verfügung stellen und Timestamp updaten
- list($user) = $user;
- sql_query("UPDATE `User` SET " . "`lastLogIn` = '" . time() . "'" . " WHERE `UID` = '" . sql_escape($_SESSION['uid']) . "' LIMIT 1;");
- $privileges = privileges_for_user($user['UID']);
- return;
+function load_auth()
+{
+ global $user, $privileges;
+
+ $user = null;
+ $session = session();
+
+ if ($session->has('uid')) {
+ $user = DB::selectOne('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$session->get('uid')]);
+ if (!empty($user)) {
+ // User ist eingeloggt, Datensatz zur Verfügung stellen und Timestamp updaten
+ DB::update('
+ UPDATE `User`
+ SET `lastLogIn` = ?
+ WHERE `UID` = ?
+ LIMIT 1
+ ', [
+ time(),
+ $session->get('uid'),
+ ]);
+ $privileges = privileges_for_user($user['UID']);
+ return;
+ }
+
+ $session->remove('uid');
}
- unset($_SESSION['uid']);
- }
-
- // guest privileges
- $privileges = privileges_for_group(- 1);
+
+ // guest privileges
+ $privileges = privileges_for_group(-10);
}
/**
* generate a salt (random string) of arbitrary length suitable for the use with crypt()
+ *
+ * @param int $length
+ * @return string
*/
-function generate_salt($length = 16) {
- $alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- $salt = "";
- for ($i = 0; $i < $length; $i ++) {
- $salt .= $alphabet[rand(0, strlen($alphabet) - 1)];
- }
- return $salt;
+function generate_salt($length = 16)
+{
+ $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ $salt = '';
+ for ($i = 0; $i < $length; $i++) {
+ $salt .= $alphabet[rand(0, strlen($alphabet) - 1)];
+ }
+ return $salt;
}
/**
* set the password of a user
+ *
+ * @param int $uid
+ * @param string $password
*/
-function set_password($uid, $password) {
- global $crypt_alg;
- $result = sql_query("UPDATE `User` SET `Passwort` = '" . sql_escape(crypt($password, $crypt_alg . '$' . generate_salt(16) . '$')) . "', `password_recovery_token`=NULL WHERE `UID` = " . intval($uid) . " LIMIT 1");
- if ($result === false) {
- engelsystem_error('Unable to update password.');
- }
- return $result;
+function set_password($uid, $password)
+{
+ DB::update('
+ UPDATE `User`
+ SET `Passwort` = ?,
+ `password_recovery_token`=NULL
+ WHERE `UID` = ?
+ LIMIT 1
+ ',
+ [
+ crypt($password, config('crypt_alg') . '$' . generate_salt(16) . '$'),
+ $uid
+ ]
+ );
}
/**
* verify a password given a precomputed salt.
* if $uid is given and $salt is an old-style salt (plain md5), we convert it automatically
+ *
+ * @param string $password
+ * @param string $salt
+ * @param int $uid
+ * @return bool
*/
-function verify_password($password, $salt, $uid = false) {
- global $crypt_alg;
- $correct = false;
- if (substr($salt, 0, 1) == '$') { // new-style crypt()
- $correct = crypt($password, $salt) == $salt;
- } elseif (substr($salt, 0, 7) == '{crypt}') { // old-style crypt() with DES and static salt - not used anymore
- $correct = crypt($password, '77') == $salt;
- } elseif (strlen($salt) == 32) { // old-style md5 without salt - not used anymore
- $correct = md5($password) == $salt;
- }
+function verify_password($password, $salt, $uid = null)
+{
+ $crypt_alg = config('crypt_alg');
+ $correct = false;
+ if (substr($salt, 0, 1) == '$') { // new-style crypt()
+ $correct = crypt($password, $salt) == $salt;
+ } elseif (substr($salt, 0, 7) == '{crypt}') { // old-style crypt() with DES and static salt - not used anymore
+ $correct = crypt($password, '77') == $salt;
+ } elseif (strlen($salt) == 32) { // old-style md5 without salt - not used anymore
+ $correct = md5($password) == $salt;
+ }
- if ($correct && substr($salt, 0, strlen($crypt_alg)) != $crypt_alg && $uid) {
- // this password is stored in another format than we want it to be.
- // let's update it!
- // we duplicate the query from the above set_password() function to have the extra safety of checking the old hash
- sql_query("UPDATE `User` SET `Passwort` = '" . sql_escape(crypt($password, $crypt_alg . '$' . generate_salt() . '$')) . "' WHERE `UID` = " . intval($uid) . " AND `Passwort` = '" . sql_escape($salt) . "' LIMIT 1");
- }
- return $correct;
+ if ($correct && substr($salt, 0, strlen($crypt_alg)) != $crypt_alg && intval($uid)) {
+ // this password is stored in another format than we want it to be.
+ // let's update it!
+ // we duplicate the query from the above set_password() function to have the extra safety of checking the old hash
+ DB::update('
+ UPDATE `User`
+ SET `Passwort` = ?
+ WHERE `UID` = ?
+ AND `Passwort` = ?
+ LIMIT 1
+ ',
+ [
+ crypt($password, $crypt_alg . '$' . generate_salt() . '$'),
+ $uid,
+ $salt,
+ ]
+ );
+ }
+ return $correct;
}
-function privileges_for_user($user_id) {
- $privileges = [];
- $user_privs = sql_select("SELECT `Privileges`.`name` FROM `User` JOIN `UserGroups` ON (`User`.`UID` = `UserGroups`.`uid`) JOIN `GroupPrivileges` ON (`UserGroups`.`group_id` = `GroupPrivileges`.`group_id`) JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `User`.`UID`='" . sql_escape($user_id) . "'");
- foreach ($user_privs as $user_priv) {
- $privileges[] = $user_priv['name'];
- }
- return $privileges;
+/**
+ * @param int $user_id
+ * @return array
+ */
+function privileges_for_user($user_id)
+{
+ $privileges = [];
+ $user_privileges = DB::select('
+ SELECT `Privileges`.`name`
+ FROM `User`
+ JOIN `UserGroups` ON (`User`.`UID` = `UserGroups`.`uid`)
+ JOIN `GroupPrivileges` ON (`UserGroups`.`group_id` = `GroupPrivileges`.`group_id`)
+ JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
+ WHERE `User`.`UID`=?
+ ', [$user_id]);
+ foreach ($user_privileges as $user_privilege) {
+ $privileges[] = $user_privilege['name'];
+ }
+ return $privileges;
}
-function privileges_for_group($group_id) {
- $privileges = [];
- $groups_privs = sql_select("SELECT * FROM `GroupPrivileges` JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`) WHERE `group_id`='" . sql_escape($group_id) . "'");
- foreach ($groups_privs as $guest_priv) {
- $privileges[] = $guest_priv['name'];
- }
- return $privileges;
+/**
+ * @param int $group_id
+ * @return array
+ */
+function privileges_for_group($group_id)
+{
+ $privileges = [];
+ $groups_privileges = DB::select('
+ SELECT `name`
+ FROM `GroupPrivileges`
+ JOIN `Privileges` ON (`GroupPrivileges`.`privilege_id` = `Privileges`.`id`)
+ WHERE `group_id`=?
+ ', [$group_id]);
+ foreach ($groups_privileges as $guest_privilege) {
+ $privileges[] = $guest_privilege['name'];
+ }
+ return $privileges;
}
-?>
diff --git a/includes/sys_form.php b/includes/sys_form.php
index 98ef2134..7fa0682d 100644
--- a/includes/sys_form.php
+++ b/includes/sys_form.php
@@ -4,23 +4,28 @@
/**
* Renders a hidden input
*
- * @param string $name
- * Name of the input
- * @param string $value
- * The value
+ * @param string $name Name of the input
+ * @param string $value The value
* @return string rendered html
*/
-function form_hidden($name, $value) {
- return '<input type="hidden" name="' . $name . '" value="' . $value . '" />';
+function form_hidden($name, $value)
+{
+ return '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
}
/**
* Rendert ein Zahlenfeld mit Buttons zum verstellen
+ *
+ * @param string $name
+ * @param string $label
+ * @param string $value
+ * @return string
*/
-function form_spinner($name, $label, $value) {
- return form_element($label, '
+function form_spinner($name, $label, $value)
+{
+ return form_element($label, '
<div class="input-group">
- <input id="spinner-' . $name . '" class="form-control" type="text" name="' . $name . '" value="' . $value . '" />
+ <input id="spinner-' . $name . '" class="form-control" name="' . $name . '" value="' . htmlspecialchars($value) . '" />
<div class="input-group-btn">
<button id="spinner-' . $name . '-down" class="btn btn-default" type="button">
<span class="glyphicon glyphicon-minus"></span>
@@ -31,11 +36,13 @@ function form_spinner($name, $label, $value) {
</div>
</div>
<script type="text/javascript">
- $("#spinner-' . $name . '-down").click(function(e) {
- $("#spinner-' . $name . '").val(parseInt($("#spinner-' . $name . '").val()) - 1);
+ $("#spinner-' . $name . '-down").click(function() {
+ var spinner = $("#spinner-' . $name . '");
+ spinner.val(parseInt(spinner.val()) - 1);
});
- $("#spinner-' . $name . '-up").click(function(e) {
- $("#spinner-' . $name . '").val(parseInt($("#spinner-' . $name . '").val()) + 1);
+ $("#spinner-' . $name . '-up").click(function() {
+ var spinner = $("#spinner-' . $name . '");
+ spinner.val(parseInt(spinner.val()) + 1);
});
</script>
');
@@ -44,24 +51,23 @@ function form_spinner($name, $label, $value) {
/**
* Render a bootstrap datepicker
*
- * @param string $name
- * Name of the parameter
- * @param string $label
- * Label
- * @param int $value
- * Unix Timestamp
- * @param int $min_date
- * Earliest possible date
- * @return HTML
+ * @param string $name Name of the parameter
+ * @param string $label Label
+ * @param int $value Unix Timestamp
+ * @param string $start_date Earliest possible date
+ * @param string $end_date
+ * @return string HTML
*/
-function form_date($name, $label, $value, $start_date = '', $end_date = '') {
- $dom_id = $name . '-date';
- $value = is_numeric($value) ? date('Y-m-d', $value) : '';
- $start_date = is_numeric($start_date) ? date('Y-m-d', $start_date) : '';
- $end_date = is_numeric($end_date) ? date('Y-m-d', $end_date) : '';
- return form_element($label, '
+function form_date($name, $label, $value, $start_date = '', $end_date = '')
+{
+ $dom_id = $name . '-date';
+ $value = is_numeric($value) ? date('Y-m-d', $value) : '';
+ $start_date = is_numeric($start_date) ? date('Y-m-d', $start_date) : '';
+ $end_date = is_numeric($end_date) ? date('Y-m-d', $end_date) : '';
+ return form_element($label, '
<div class="input-group date" id="' . $dom_id . '">
- <input type="text" name="' . $name . '" class="form-control" value="' . $value . '"><span class="input-group-addon">' . glyph('th') . '</span>
+ <input name="' . $name . '" class="form-control" value="' . htmlspecialchars($value) . '">'
+ . '<span class="input-group-addon">' . glyph('th') . '</span>
</div>
<script type="text/javascript">
$(function(){
@@ -80,202 +86,337 @@ function form_date($name, $label, $value, $start_date = '', $end_date = '') {
/**
* Rendert eine Liste von Checkboxen für ein Formular
*
- * @param
- * name Die Namen der Checkboxen werden aus name_key gebildet
- * @param
- * label Die Beschriftung der Liste
- * @param
- * items Array mit den einzelnen Checkboxen
- * @param
- * selected Array mit den Keys, die ausgewählt sind
+ * @param string $name Die Namen der Checkboxen werden aus name_key gebildet
+ * @param string $label Die Beschriftung der Liste
+ * @param array $items Array mit den einzelnen Checkboxen
+ * @param array $selected Array mit den Keys, die ausgewählt sind
+ * @return string
*/
-function form_checkboxes($name, $label, $items, $selected) {
- $html = form_element($label, '');
- foreach ($items as $key => $item) {
- $html .= form_checkbox($name . '_' . $key, $item, array_search($key, $selected) !== false);
- }
- return $html;
+function form_checkboxes($name, $label, $items, $selected)
+{
+ $html = form_element($label, '');
+ foreach ($items as $key => $item) {
+ $html .= form_checkbox($name . '_' . $key, $item, array_search($key, $selected) !== false);
+ }
+ return $html;
}
/**
* Rendert eine Tabelle von Checkboxen für ein Formular
*
- * @param
- * names Assoziatives Array mit Namen der Checkboxen als Keys und Überschriften als Values
- * @param
- * label Die Beschriftung der gesamten Tabelle
- * @param
- * items Array mit den Beschriftungen der Zeilen
- * @param
- * selected Mehrdimensionales Array, wobei $selected[foo] ein Array der in der Datenreihe foo markierten Checkboxen ist
- * @param
- * disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
+ * @param string[] $names Assoziatives Array mit Namen der Checkboxen als Keys und Überschriften als Values
+ * @param string $label Die Beschriftung der gesamten Tabelle
+ * @param string[] $items Array mit den Beschriftungen der Zeilen
+ * @param array[] $selected Mehrdimensionales Array, wobei $selected[foo] ein Array der in der Datenreihe foo
+ * markierten Checkboxen ist
+ * @param array $disabled Wie selected, nur dass die entsprechenden Checkboxen deaktiviert statt markiert sind
+ * @return string
*/
-function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []) {
- $html = "<table><thead><tr>";
- foreach ($names as $title) {
- $html .= "<th>$title</th>";
- }
- $html .= "</tr></thead><tbody>";
- foreach ($items as $key => $item) {
- $html .= "<tr>";
- foreach ($names as $name => $title) {
- $dom_id = $name . '_' . $key;
- $sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : "";
- if (! empty($disabled) && ! empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) {
- $sel .= ' disabled="disabled"';
- }
- $html .= '<td style="text-align: center;"><input type="checkbox" id="' . $dom_id . '" name="' . $name . '[]" value="' . $key . '"' . $sel . ' /></td>';
+function form_multi_checkboxes($names, $label, $items, $selected, $disabled = [])
+{
+ $html = '<table><thead><tr>';
+ foreach ($names as $title) {
+ $html .= '<th>' . $title . '</th>';
+ }
+ $html .= '</tr></thead><tbody>';
+ foreach ($items as $key => $item) {
+ $html .= '<tr>';
+ $dom_id = '';
+ foreach ($names as $name => $title) {
+ $dom_id = $name . '_' . $key;
+ $sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : '';
+ if (!empty($disabled) && !empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) {
+ $sel .= ' disabled="disabled"';
+ }
+ $html .= '<td style="text-align: center;">'
+ . '<input type="checkbox" id="' . $dom_id . '" name="' . $name . '[]" value="' . $key . '" ' . $sel . ' />'
+ . '</td>';
+ }
+ $html .= '<td><label for="' . $dom_id . '">' . $item . '</label></td></tr>';
}
- $html .= '<td><label for="' . $dom_id . '">' . $item . '</label></td></tr>';
- }
- $html .= "</tbody></table>";
- return form_element($label, $html);
+ $html .= '</tbody></table>';
+ return form_element($label, $html);
}
/**
* Rendert eine Checkbox
+ *
+ * @param string $name
+ * @param string $label
+ * @param string $selected
+ * @param string $value
+ * @param string $id
+ * @return string
*/
-function form_checkbox($name, $label, $selected, $value = 'checked') {
- return '<div class="checkbox"><label><input type="checkbox" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
+function form_checkbox($name, $label, $selected, $value = 'checked', $id = null)
+{
+ if (is_null($id)) {
+ $id = $name;
+ }
+
+ return '<div class="checkbox"><label>'
+ . '<input type="checkbox" id="' . $id . '" name="' . $name . '" value="' . htmlspecialchars($value) . '" '
+ . ($selected ? ' checked="checked"' : '') . ' /> '
+ . $label
+ . '</label></div>';
}
/**
* Rendert einen Radio
+ *
+ * @param string $name
+ * @param string $label
+ * @param string $selected
+ * @param string $value
+ * @return string
*/
-function form_radio($name, $label, $selected, $value) {
- return '<div class="radio"><label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . $value . '"' . ($selected ? ' checked="checked"' : '') . ' /> ' . $label . '</label></div>';
+function form_radio($name, $label, $selected, $value)
+{
+ return '<div class="radio">'
+ . '<label><input type="radio" id="' . $name . '" name="' . $name . '" value="' . htmlspecialchars($value) . '" '
+ . ($selected ? ' checked="checked"' : '') . ' /> '
+ . $label
+ . '</label></div>';
}
/**
* Rendert einen Infotext in das Formular
+ *
+ * @param string $label
+ * @param string $text
+ * @return string
*/
-function form_info($label, $text = "") {
- if ($label == "") {
- return '<span class="help-block">' . glyph('info-sign') . $text . '</span>';
- }
- if ($text == "") {
- return '<h4>' . $label . '</h4>';
- }
- return form_element($label, '<p class="form-control-static">' . $text . '</p>', '');
+function form_info($label, $text = '')
+{
+ if ($label == '') {
+ return '<span class="help-block">' . glyph('info-sign') . $text . '</span>';
+ }
+ if ($text == '') {
+ return '<h4>' . $label . '</h4>';
+ }
+ return form_element($label, '<p class="form-control-static">' . $text . '</p>', '');
}
/**
* Rendert den Absenden-Button eines Formulars
+ *
+ * @param string $name
+ * @param string $label
+ * @return string
*/
-function form_submit($name, $label) {
- return form_element('<input class="btn btn-primary" type="submit" name="' . $name . '" value="' . $label . '" />', "");
+function form_submit($name, $label)
+{
+ return form_element(
+ '<input class="btn btn-primary" type="submit" name="' . $name . '" value="' . $label . '" />',
+ ''
+ );
}
/**
* Rendert ein Formular-Textfeld
+ *
+ * @param string $name
+ * @param string $label
+ * @param string $value
+ * @param bool $disabled
+ * @return string
*/
-function form_text($name, $label, $value, $disabled = false) {
- $disabled = $disabled ? ' disabled="disabled"' : '';
- return form_element($label, '<input class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
+function form_text($name, $label, $value, $disabled = false)
+{
+ $disabled = $disabled ? ' disabled="disabled"' : '';
+ 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?
+ * @param String $name Input name
+ * @param String $placeholder Placeholder
+ * @param String $value The value
+ * @param Boolean $disabled Is the field enabled?
+ * @return string
*/
-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 . '/>');
+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
+ *
+ * @param string $name
+ * @param string $label
+ * @param string $value
+ * @param bool $disabled
+ * @return string
*/
-function form_email($name, $label, $value, $disabled = false) {
- $disabled = $disabled ? ' disabled="disabled"' : '';
- return form_element($label, '<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="' . htmlspecialchars($value) . '" ' . $disabled . '/>', 'form_' . $name);
+function form_email($name, $label, $value, $disabled = false)
+{
+ $disabled = $disabled ? ' disabled="disabled"' : '';
+ return form_element(
+ $label,
+ '<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="'
+ . htmlspecialchars($value) . '" ' . $disabled . '/>',
+ 'form_' . $name
+ );
}
/**
* Rendert ein Formular-Dateifeld
+ *
+ * @param string $name
+ * @param string $label
+ * @return string
*/
-function form_file($name, $label) {
- return form_element($label, '<input id="form_' . $name . '" type="file" name="' . $name . '" />', 'form_' . $name);
+function form_file($name, $label)
+{
+ return form_element($label, '<input id="form_' . $name . '" type="file" name="' . $name . '" />', 'form_' . $name);
}
/**
* Rendert ein Formular-Passwortfeld
+ *
+ * @param string $name
+ * @param string $label
+ * @param bool $disabled
+ * @return string
*/
-function form_password($name, $label, $disabled = false) {
- $disabled = $disabled ? ' disabled="disabled"' : '';
- return form_element($label, '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>', 'form_' . $name);
+function form_password($name, $label, $disabled = false)
+{
+ $disabled = $disabled ? ' disabled="disabled"' : '';
+ 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.
+ *
+ * @param string $name
+ * @param string $placeholder
+ * @param bool $disabled
+ * @return string
*/
-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);
+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
+ *
+ * @param string $name
+ * @param string $label
+ * @param string $value
+ * @param bool $disabled
+ * @return string
*/
-function form_textarea($name, $label, $value, $disabled = false) {
- $disabled = $disabled ? ' disabled="disabled"' : '';
- return form_element($label, '<textarea rows="5" class="form-control" id="form_' . $name . '" type="text" name="' . $name . '" ' . $disabled . '>' . $value . '</textarea>', 'form_' . $name);
+function form_textarea($name, $label, $value, $disabled = false)
+{
+ $disabled = $disabled ? ' disabled="disabled"' : '';
+ return form_element(
+ $label,
+ '<textarea rows="5" class="form-control" id="form_' . $name . '" name="'
+ . $name . '" ' . $disabled . '>' . htmlspecialchars($value) . '</textarea>',
+ 'form_' . $name
+ );
}
/**
* Rendert ein Formular-Auswahlfeld
+ *
+ * @param string $name
+ * @param string $label
+ * @param string[] $values
+ * @param string $selected
+ * @return string
*/
-function form_select($name, $label, $values, $selected) {
- return form_element($label, html_select_key('form_' . $name, $name, $values, $selected), 'form_' . $name);
+function form_select($name, $label, $values, $selected)
+{
+ return form_element($label, html_select_key('form_' . $name, $name, $values, $selected), 'form_' . $name);
}
/**
* Rendert ein Formular-Element
+ *
+ * @param string $label
+ * @param string $input
+ * @param string $for
+ * @return string
*/
-function form_element($label, $input, $for = "") {
- if ($label == '') {
- return '<div class="form-group">' . $input . '</div>';
- }
-
- return '<div class="form-group">' . '<label for="' . $for . '">' . $label . '</label>' . $input . '</div>';
+function form_element($label, $input, $for = '')
+{
+ if ($label == '') {
+ return '<div class="form-group">' . $input . '</div>';
+ }
+
+ return '<div class="form-group">' . '<label for="' . $for . '">' . $label . '</label>' . $input . '</div>';
}
/**
* Rendert ein Formular
+ *
+ * @param string[] $elements
+ * @param string $action
+ * @return string
*/
-function form($elements, $action = "") {
- return '<form role="form" action="' . $action . '" enctype="multipart/form-data" method="post">' . join($elements) . '</form>';
+function form($elements, $action = '')
+{
+ return '<form action="' . $action . '" enctype="multipart/form-data" method="post">' . join($elements) . '</form>';
}
-function html_options($name, $options, $selected = "") {
- $html = "";
- foreach ($options as $value => $label) {
- $html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="' . $name . '" value="' . $value . '"> ' . $label;
- }
-
- return $html;
+/**
+ * @param string $name
+ * @param String[] $options
+ * @param string $selected
+ * @return string
+ */
+function html_options($name, $options, $selected = '')
+{
+ $html = '';
+ foreach ($options as $value => $label) {
+ $html .= '<input type="radio"' . ($value == $selected ? ' checked="checked"' : '') . ' name="'
+ . $name . '" value="' . $value . '"> ' . $label;
+ }
+
+ return $html;
}
-function html_select_key($dom_id, $name, $rows, $selected) {
- $html = '<select class="form-control" id="' . $dom_id . '" name="' . $name . '">';
- foreach ($rows as $key => $row) {
- if (($key == $selected) || ($row == $selected)) {
- $html .= '<option value="' . $key . '" selected="selected">' . $row . '</option>';
- } else {
- $html .= '<option value="' . $key . '">' . $row . '</option>';
+/**
+ * @param string $dom_id
+ * @param string $name
+ * @param string[] $rows
+ * @param string $selected
+ * @return string
+ */
+function html_select_key($dom_id, $name, $rows, $selected)
+{
+ $html = '<select class="form-control" id="' . $dom_id . '" name="' . $name . '">';
+ foreach ($rows as $key => $row) {
+ if (($key == $selected) || ($row === $selected)) {
+ $html .= '<option value="' . $key . '" selected="selected">' . $row . '</option>';
+ } else {
+ $html .= '<option value="' . $key . '">' . $row . '</option>';
+ }
}
- }
- $html .= '</select>';
- return $html;
+ $html .= '</select>';
+ return $html;
}
-
-?> \ No newline at end of file
diff --git a/includes/sys_log.php b/includes/sys_log.php
index 66c323c1..513586e6 100644
--- a/includes/sys_log.php
+++ b/includes/sys_log.php
@@ -4,36 +4,17 @@
* Write a log entry.
* This should be used to log user's activity.
*
- * @param
- * $message
+ * @param string $message
*/
-function engelsystem_log($message) {
- global $user;
-
- $nick = "Guest";
- if (isset($user)) {
- $nick = User_Nick_render($user);
- }
- LogEntry_create($nick, $message);
-}
+function engelsystem_log($message)
+{
+ global $user;
+ $nick = "Guest";
+ $logger = app('logger');
-/**
- * Generates a PHP Stacktrace.
- */
-function debug_string_backtrace() {
- ob_start();
- debug_print_backtrace();
- $trace = ob_get_contents();
- ob_end_clean();
-
- // Remove first item from backtrace as it's this function which
- // is redundant.
- $trace = preg_replace('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);
-
- // Renumber backtrace items.
- // $trace = preg_replace('/^#(\d+)/me', '\'#\' . ($1 - 1)', $trace);
-
- return $trace;
-}
+ if (isset($user)) {
+ $nick = User_Nick_render($user);
+ }
-?> \ No newline at end of file
+ $logger->info('{nick}: {message}', ['nick' => $nick, 'message' => $message]);
+}
diff --git a/includes/sys_menu.php b/includes/sys_menu.php
index cb90fb7b..385a6948 100644
--- a/includes/sys_menu.php
+++ b/includes/sys_menu.php
@@ -1,185 +1,221 @@
<?php
-use Engelsystem\UserHintsRenderer;
-function page_link_to($page = "") {
- if ($page == "") {
- return '?';
- }
- return '?p=' . $page;
-}
+use Engelsystem\UserHintsRenderer;
-function page_link_to_absolute($page) {
- return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . preg_replace("/\?.*$/", '', $_SERVER['REQUEST_URI']) . page_link_to($page);
+/**
+ * @param string $page
+ * @param array $parameters get parameters
+ * @return string
+ */
+function page_link_to($page = '', $parameters = [])
+{
+ $page = str_replace('_', '-', $page);
+ return url($page, $parameters);
}
/**
* Render the user hints
+ *
+ * @return string
*/
-function header_render_hints() {
- global $user;
-
- $hints_renderer = new UserHintsRenderer();
-
- if (isset($user)) {
- $hints_renderer->addHint(admin_new_questions());
- $hints_renderer->addHint(user_angeltypes_unconfirmed_hint());
- $hints_renderer->addHint(render_user_departure_date_hint());
- $hints_renderer->addHint(user_driver_license_required_hint());
-
- // Important hints:
- $hints_renderer->addHint(render_user_freeloader_hint(), true);
- $hints_renderer->addHint(render_user_arrived_hint(), true);
- $hints_renderer->addHint(render_user_tshirt_hint(), true);
- $hints_renderer->addHint(render_user_dect_hint(), true);
- }
-
- return $hints_renderer->render();
+function header_render_hints()
+{
+ global $user;
+
+ $hints_renderer = new UserHintsRenderer();
+
+ if (isset($user)) {
+ $hints_renderer->addHint(admin_new_questions());
+ $hints_renderer->addHint(user_angeltypes_unconfirmed_hint());
+ $hints_renderer->addHint(render_user_departure_date_hint());
+ $hints_renderer->addHint(user_driver_license_required_hint());
+
+ // Important hints:
+ $hints_renderer->addHint(render_user_freeloader_hint(), true);
+ $hints_renderer->addHint(render_user_arrived_hint(), true);
+ $hints_renderer->addHint(render_user_tshirt_hint(), true);
+ $hints_renderer->addHint(render_user_dect_hint(), true);
+ }
+
+ return $hints_renderer->render();
}
/**
* Renders the header toolbar containing search, login/logout, user and settings links.
+ *
+ * @return string
*/
-function header_toolbar() {
- global $page, $privileges, $user;
-
- $toolbar_items = [];
-
- if (isset($user)) {
- $toolbar_items[] = toolbar_item_link(page_link_to('shifts') . '&amp;action=next', 'time', User_shift_state_render($user));
- }
-
- if (! isset($user) && in_array('register', $privileges)) {
- $toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $page == 'register');
- }
-
- if (in_array('login', $privileges)) {
- $toolbar_items[] = toolbar_item_link(page_link_to('login'), 'log-in', login_title(), $page == 'login');
- }
-
- if (isset($user) && in_array('user_messages', $privileges)) {
- $toolbar_items[] = toolbar_item_link(page_link_to('user_messages'), 'envelope', user_unread_messages());
- }
-
- $toolbar_items[] = header_render_hints();
- if (in_array('user_myshifts', $privileges)) {
- $toolbar_items[] = toolbar_item_link(page_link_to('users') . '&amp;action=view', ' icon-icon_angel', $user['Nick'], $page == 'users');
- }
-
- $user_submenu = make_user_submenu();
- if (count($user_submenu) > 0) {
- $toolbar_items[] = toolbar_dropdown('', '', $user_submenu);
- }
-
- return toolbar($toolbar_items, true);
+function header_toolbar()
+{
+ global $page, $privileges, $user;
+
+ $toolbar_items = [];
+
+ if (isset($user)) {
+ $toolbar_items[] = toolbar_item_link(
+ page_link_to('shifts', ['action' => 'next']),
+ 'time',
+ User_shift_state_render($user)
+ );
+ }
+
+ if (!isset($user) && in_array('register', $privileges) && config('registration_enabled')) {
+ $toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $page == 'register');
+ }
+
+ if (in_array('login', $privileges)) {
+ $toolbar_items[] = toolbar_item_link(page_link_to('login'), 'log-in', login_title(), $page == 'login');
+ }
+
+ if (isset($user) && in_array('user_messages', $privileges)) {
+ $toolbar_items[] = toolbar_item_link(page_link_to('user_messages'), 'envelope', user_unread_messages());
+ }
+
+ $toolbar_items[] = header_render_hints();
+ if (in_array('user_myshifts', $privileges)) {
+ $toolbar_items[] = toolbar_item_link(
+ page_link_to('users', ['action' => 'view']),
+ ' icon-icon_angel',
+ $user['Nick'],
+ $page == 'users'
+ );
+ }
+
+ $user_submenu = make_user_submenu();
+ if (count($user_submenu) > 0) {
+ $toolbar_items[] = toolbar_dropdown('', '', $user_submenu);
+ }
+
+ return toolbar($toolbar_items, true);
}
-function make_user_submenu() {
- global $privileges, $page;
-
- $user_submenu = make_langselect();
-
- if (in_array('user_settings', $privileges) || in_array('logout', $privileges)) {
- $user_submenu[] = toolbar_item_divider();
- }
-
- if (in_array('user_settings', $privileges)) {
- $user_submenu[] = toolbar_item_link(page_link_to('user_settings'), 'list-alt', settings_title(), $page == 'user_settings');
- }
-
- if (in_array('logout', $privileges)) {
- $user_submenu[] = toolbar_item_link(page_link_to('logout'), 'log-out', logout_title(), $page == 'logout');
- }
-
- return $user_submenu;
+/**
+ * @return array
+ */
+function make_user_submenu()
+{
+ global $privileges, $page;
+
+ $user_submenu = make_langselect();
+
+ if (in_array('user_settings', $privileges) || in_array('logout', $privileges)) {
+ $user_submenu[] = toolbar_item_divider();
+ }
+
+ if (in_array('user_settings', $privileges)) {
+ $user_submenu[] = toolbar_item_link(
+ page_link_to('user_settings'),
+ 'list-alt',
+ settings_title(),
+ $page == 'user_settings'
+ );
+ }
+
+ if (in_array('logout', $privileges)) {
+ $user_submenu[] = toolbar_item_link(page_link_to('logout'), 'log-out', logout_title(), $page == 'logout');
+ }
+
+ return $user_submenu;
}
-function make_navigation() {
- global $page, $privileges;
-
- $menu = [];
- $pages = [
- "news" => news_title(),
- "user_meetings" => meetings_title(),
- "user_shifts" => shifts_title(),
- "angeltypes" => angeltypes_title(),
- "user_questions" => questions_title()
- ];
-
- foreach ($pages as $menu_page => $title) {
- if (in_array($menu_page, $privileges)) {
- $menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
- }
- }
-
- $menu = make_room_navigation($menu);
-
- $admin_menu = [];
- $admin_pages = [
- "admin_arrive" => admin_arrive_title(),
- "admin_active" => admin_active_title(),
- "admin_user" => admin_user_title(),
- "admin_free" => admin_free_title(),
- "admin_questions" => admin_questions_title(),
- "shifttypes" => shifttypes_title(),
- "admin_shifts" => admin_shifts_title(),
- "admin_rooms" => admin_rooms_title(),
- "admin_groups" => admin_groups_title(),
- "admin_import" => admin_import_title(),
- "admin_log" => admin_log_title(),
- "admin_event_config" => event_config_title()
- ];
-
- foreach ($admin_pages as $menu_page => $title) {
- if (in_array($menu_page, $privileges)) {
- $admin_menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
- }
- }
-
- if (count($admin_menu) > 0) {
- $menu[] = toolbar_dropdown('', _("Admin"), $admin_menu);
- }
-
- return toolbar($menu);
+/**
+ * @return string
+ */
+function make_navigation()
+{
+ global $page, $privileges;
+
+ $menu = [];
+ $pages = [
+ 'news' => news_title(),
+ 'user_meetings' => meetings_title(),
+ 'user_shifts' => shifts_title(),
+ 'angeltypes' => angeltypes_title(),
+ 'user_questions' => questions_title()
+ ];
+
+ foreach ($pages as $menu_page => $title) {
+ if (in_array($menu_page, $privileges)) {
+ $menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
+ }
+ }
+
+ $menu = make_room_navigation($menu);
+
+ $admin_menu = [];
+ $admin_pages = [
+ 'admin_arrive' => admin_arrive_title(),
+ 'admin_active' => admin_active_title(),
+ 'admin_user' => admin_user_title(),
+ 'admin_free' => admin_free_title(),
+ 'admin_questions' => admin_questions_title(),
+ 'shifttypes' => shifttypes_title(),
+ 'admin_shifts' => admin_shifts_title(),
+ 'admin_rooms' => admin_rooms_title(),
+ 'admin_groups' => admin_groups_title(),
+ 'admin_import' => admin_import_title(),
+ 'admin_log' => admin_log_title(),
+ 'admin_event_config' => event_config_title()
+ ];
+
+ foreach ($admin_pages as $menu_page => $title) {
+ if (in_array($menu_page, $privileges)) {
+ $admin_menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
+ }
+ }
+
+ if (count($admin_menu) > 0) {
+ $menu[] = toolbar_dropdown('', _('Admin'), $admin_menu);
+ }
+
+ return toolbar($menu);
}
/**
* Adds room navigation to the given menu.
*
- * @param string[] $menu
- * Rendered menu
+ * @param string[] $menu Rendered menu
+ * @return string[]
*/
-function make_room_navigation($menu) {
- global $privileges;
-
- if (! in_array('view_rooms', $privileges)) {
+function make_room_navigation($menu)
+{
+ global $privileges;
+
+ if (!in_array('view_rooms', $privileges)) {
+ return $menu;
+ }
+
+ // Get a list of all rooms
+ $rooms = Rooms(true);
+ $room_menu = [];
+ if (in_array('admin_rooms', $privileges)) {
+ $room_menu[] = toolbar_item_link(page_link_to('admin_rooms'), 'list', _('Manage rooms'));
+ }
+ if (count($room_menu) > 0) {
+ $room_menu[] = toolbar_item_divider();
+ }
+ foreach ($rooms as $room) {
+ if (
+ $room['show'] == 'Y' // room is public
+ || (
+ // room is not public, but user can admin_rooms
+ $room['show'] != 'Y'
+ && in_array('admin_rooms', $privileges)
+ )
+ ) {
+ $room_menu[] = toolbar_item_link(room_link($room), 'map-marker', $room['Name']);
+ }
+ }
+ if (count($room_menu) > 0) {
+ $menu[] = toolbar_dropdown('map-marker', _('Rooms'), $room_menu);
+ }
return $menu;
- }
-
- //get a list of all rooms
- $rooms = Rooms(true);
-
- $room_menu = [];
- if (in_array('admin_rooms', $privileges)) {
- $room_menu[] = toolbar_item_link(page_link_to('admin_rooms'), 'list', _("Manage rooms"));
- }
- if (count($room_menu) > 0) {
- $room_menu[] = toolbar_item_divider();
- }
- foreach ($rooms as $room) {
- if($room['show'] == 'Y' || // room is public
- ($room['show'] != 'Y' && in_array('admin_rooms', $privileges)) // room is not public, but user can admin_rooms
- ) {
- $room_menu[] = toolbar_item_link(room_link($room), 'map-marker', $room['Name']);
- }
- }
- if (count($room_menu > 0)) {
- $menu[] = toolbar_dropdown('map-marker', _("Rooms"), $room_menu);
- }
- return $menu;
}
-function make_menu() {
- return make_navigation();
+/**
+ * @return string
+ */
+function make_menu()
+{
+ return make_navigation();
}
-
-?>
diff --git a/includes/sys_page.php b/includes/sys_page.php
index 82ce9896..33ec18b9 100644
--- a/includes/sys_page.php
+++ b/includes/sys_page.php
@@ -1,4 +1,5 @@
<?php
+
use Engelsystem\ValidationResult;
/**
@@ -8,184 +9,212 @@ use Engelsystem\ValidationResult;
/**
* Parse a date from da day and a time textfield.
*
- * @param string $date_name
- * Name of the textfield containing the day (format Y-m-d)
- * @param string $time_name
- * Name of the textfield containing the time (format H:i)
- * @param string[] $allowed_days
- * List of allowed days in format Y-m-d
- * @param int $default_value
- * Default value unix timestamp
+ * @param string $date_name Name of the textfield containing the day (format Y-m-d)
+ * @param string $time_name Name of the textfield containing the time (format H:i)
+ * @param string[] $allowed_days List of allowed days in format Y-m-d
+ * @param int $default_value Default value unix timestamp
+ * @return int|null
*/
-function check_request_datetime($date_name, $time_name, $allowed_days, $default_value) {
- $time = date("H:i", $default_value);
- $day = date("Y-m-d", $default_value);
-
- if (isset($_REQUEST[$time_name]) && preg_match('#^\d{1,2}:\d\d$#', trim($_REQUEST[$time_name]))) {
- $time = trim($_REQUEST[$time_name]);
- }
- if (isset($_REQUEST[$date_name]) && in_array($_REQUEST[$date_name], $allowed_days)) {
- $day = $_REQUEST[$date_name];
- }
-
- return parse_date("Y-m-d H:i", $day . " " . $time);
+function check_request_datetime($date_name, $time_name, $allowed_days, $default_value)
+{
+ $time = date('H:i', $default_value);
+ $day = date('Y-m-d', $default_value);
+ $request = request();
+
+ if ($request->has($time_name) && preg_match('#^\d{1,2}:\d\d$#', trim($request->input($time_name)))) {
+ $time = trim($request->input($time_name));
+ }
+
+ if ($request->has($date_name) && in_array($request->input($date_name), $allowed_days)) {
+ $day = $request->input($date_name);
+ }
+
+ return parse_date('Y-m-d H:i', $day . ' ' . $time);
}
/**
* Parse a date into unix timestamp
*
- * @param string $pattern
- * The date pattern (i.e. Y-m-d H:i)
- * @param string $value
- * The string to parse
- * @return The parsed unix timestamp
+ * @param string $pattern The date pattern (i.e. Y-m-d H:i)
+ * @param string $value The string to parse
+ * @return int|null The parsed unix timestamp
*/
-function parse_date($pattern, $value) {
- $datetime = DateTime::createFromFormat($pattern, trim($value));
- if ($datetime == null) {
- return null;
- }
- return $datetime->getTimestamp();
+function parse_date($pattern, $value)
+{
+ $datetime = DateTime::createFromFormat($pattern, trim($value));
+ if ($datetime == null) {
+ return null;
+ }
+ return $datetime->getTimestamp();
}
/**
* Leitet den Browser an die übergebene URL weiter und hält das Script an.
+ *
+ * @param string $url
*/
-function redirect($url) {
- header("Location: " . $url, true, 302);
- raw_output("");
+function redirect($url)
+{
+ header('Location: ' . $url, true, 302);
+ raw_output('');
}
/**
* Echoes given output and dies.
*
- * @param String $output
- * String to display
+ * @param String $output String to display
*/
-function raw_output($output) {
- echo $output;
- die();
+function raw_output($output = '')
+{
+ echo $output;
+ die();
}
/**
* Helper function for transforming list of entities into array for select boxes.
*
- * @param array $data
- * The data array
- * @param string $key_name
- * name of the column to use as id/key
- * @param string $value_name
- * name of the column to use as displayed value
+ * @param array $data The data array
+ * @param string $key_name name of the column to use as id/key
+ * @param string $value_name name of the column to use as displayed value
+ *
+ * @return array
*/
-function select_array($data, $key_name, $value_name) {
- $ret = [];
- foreach ($data as $value) {
- $ret[$value[$key_name]] = $value[$value_name];
- }
- return $ret;
+function select_array($data, $key_name, $value_name)
+{
+ $return = [];
+ foreach ($data as $value) {
+ $return[$value[$key_name]] = $value[$value_name];
+ }
+ return $return;
}
/**
* Returns an int[] from given request param name.
*
- * @param String $name
- * Name of the request param
- * @param array<int> $default
- * Default return value, if param is not set
+ * @param string $name Name of the request param
+ * @param array $default Default return value, if param is not set
+ * @return array
*/
-function check_request_int_array($name, $default = []) {
- if (isset($_REQUEST[$name]) && is_array($_REQUEST[$name])) {
- return array_filter($_REQUEST[$name], 'is_numeric');
- }
- return $default;
+function check_request_int_array($name, $default = [])
+{
+ $request = request();
+ if ($request->has($name) && is_array($request->input($name))) {
+ return array_filter($request->input($name), 'is_numeric');
+ }
+ return $default;
}
/**
* Checks if given request item (name) can be parsed to a date.
* If not parsable, given error message is put into msg() and null is returned.
*
- * @param string $input
- * String to be parsed into a date.
- * @param string $error_message
- * the error message displayed if $input is not parsable
- * @param boolean $null_allowed
- * is a null value allowed?
+ * @param string $name to be parsed into a date.
+ * @param string $error_message the error message displayed if $input is not parsable
+ * @param boolean $null_allowed is a null value allowed?
* @return ValidationResult containing the parsed date
*/
-function check_request_date($name, $error_message = null, $null_allowed = false) {
- if (! isset($_REQUEST[$name])) {
- return new ValidationResult($null_allowed, null);
- }
- return check_date($_REQUEST[$name], $error_message, $null_allowed);
+function check_request_date($name, $error_message = null, $null_allowed = false)
+{
+ $request = request();
+ if (!$request->has($name)) {
+ return new ValidationResult($null_allowed, null);
+ }
+ return check_date($request->input($name), $error_message, $null_allowed);
}
/**
* Checks if given string can be parsed to a date.
* If not parsable, given error message is put into msg() and null is returned.
*
- * @param string $input
- * String to be parsed into a date.
- * @param string $error_message
- * the error message displayed if $input is not parsable
- * @param boolean $null_allowed
- * is a null value allowed?
+ * @param string $input String to be parsed into a date.
+ * @param string $error_message the error message displayed if $input is not parsable
+ * @param boolean $null_allowed is a null value allowed?
* @return ValidationResult containing the parsed date
*/
-function check_date($input, $error_message = null, $null_allowed = false) {
- if ($tmp = parse_date("Y-m-d H:i", trim($input) . " 00:00")) {
- return new ValidationResult(true, $tmp);
- }
- if ($null_allowed) {
- return new ValidationResult(true, null);
- }
-
- error($error_message);
- return new ValidationResult(false, null);
+function check_date($input, $error_message = null, $null_allowed = false)
+{
+ if ($tmp = parse_date('Y-m-d H:i', trim($input) . ' 00:00')) {
+ return new ValidationResult(true, $tmp);
+ }
+ if ($null_allowed) {
+ return new ValidationResult(true, null);
+ }
+
+ error($error_message);
+ return new ValidationResult(false, null);
}
/**
* Returns REQUEST value filtered or default value (null) if not set.
+ *
+ * @param string $name
+ * @param string $default_value
+ * @return mixed|null
*/
-function strip_request_item($name, $default_value = null) {
- if (isset($_REQUEST[$name])) {
- return strip_item($_REQUEST[$name]);
- }
- return $default_value;
+function strip_request_item($name, $default_value = null)
+{
+ $request = request();
+ if ($request->has($name)) {
+ return strip_item($request->input($name));
+ }
+ return $default_value;
}
/**
* Testet, ob der angegebene REQUEST Wert ein Integer ist, bzw.
* eine ID sein könnte.
+ *
+ * @param string $name
+ * @return int|false
*/
-function test_request_int($name) {
- if (isset($_REQUEST[$name])) {
- return preg_match("/^[0-9]*$/", $_REQUEST[$name]);
- }
- return false;
+function test_request_int($name)
+{
+ $input = request()->input($name);
+ if (is_null($input)) {
+ return false;
+ }
+
+ return preg_match('/^\d+$/', $input);
}
/**
* Gibt den gefilterten REQUEST Wert mit Zeilenumbrüchen zurück
+ *
+ * @param string $name
+ * @param mixed $default_value
+ * @return mixed
*/
-function strip_request_item_nl($name, $default_value = null) {
- if (isset($_REQUEST[$name])) {
- return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+\n]{1,})/ui", '', strip_tags($_REQUEST[$name]));
- }
- return $default_value;
+function strip_request_item_nl($name, $default_value = null)
+{
+ $request = request();
+ if ($request->has($name)) {
+ return preg_replace(
+ "/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+\n]{1,})/ui",
+ '',
+ strip_tags($request->input($name))
+ );
+ }
+ return $default_value;
}
/**
* Entfernt unerwünschte Zeichen
+ *
+ * @param string $item
+ * @return string
*/
-function strip_item($item) {
- return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+]{1,})/ui", '', strip_tags($item));
+function strip_item($item)
+{
+ return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+]{1,})/ui", '', strip_tags($item));
}
/**
* Überprüft eine E-Mail-Adresse.
+ *
+ * @param string $email
+ * @return bool
*/
-function check_email($email) {
- return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
+function check_email($email)
+{
+ return (bool)filter_var($email, FILTER_VALIDATE_EMAIL);
}
-
-?>
diff --git a/includes/sys_template.php b/includes/sys_template.php
index 3679328b..819b7d1c 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -1,119 +1,211 @@
<?php
/**
- * Liste der verfügbaren Themes
+ * Renders tabs from the array. Array key is tab name, array value is tab content.
+ *
+ * @param array $tabs
+ * @param int $selected The selected tab, default 0
+ * @return string HTML
*/
-$themes = [
- '4' => "Engelsystem 33c3 (2016)",
- '3' => "Engelsystem 32c3 (2015)",
- "2" => "Engelsystem cccamp15",
- "0" => "Engelsystem light",
- "1" => "Engelsystem dark"
-];
+function tabs($tabs, $selected = 0)
+{
+ $tab_header = [];
+ $tab_content = [];
+ foreach($tabs as $header => $content) {
+ $class = '';
+ if(count($tab_header) == $selected) {
+ $class = 'active';
+ }
+ $tab_header[] = '<li role="presentation" class="' . $class . '">
+ <a href="#' . $header . '" aria-controls="' . $header . '" role="tab" data-toggle="tab">'
+ . $header . '</a></li>';
+ $tab_content[] = '<div role="tabpanel" class="tab-pane ' . $class . '" id="' . $header . '">' . $content . '</div>';
+ }
+ return div('', [
+ '<ul class="nav nav-tabs" role="tablist">' . join($tab_header) . '</ul>',
+ '<div class="tab-content">' . join($tab_content) . '</div>'
+ ]);
+}
/**
* Display muted (grey) text.
*
- * @param string $text
+ * @param string $text
+ * @return string
*/
-function mute($text) {
- return '<span class="text-muted">' . $text . '</span>';
+function mute($text)
+{
+ return '<span class="text-muted">' . $text . '</span>';
}
/**
* Renders a bootstrap label with given content and class.
*
- * @param string $content
- * The text
- * @param string $class
- * default, primary, info, success, warning, danger
+ * @param string $content The text
+ * @param string $class default, primary, info, success, warning, danger
+ * @return string
*/
-function label($content, $class = 'default') {
- return '<span class="label label-' . $class . '">' . $content . '</span>';
+function label($content, $class = 'default')
+{
+ return '<span class="label label-' . $class . '">' . $content . '</span>';
}
-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: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%">' . $content . '</div></div>';
+/**
+ * @param int $valuemin
+ * @param int $valuemax
+ * @param int $valuenow
+ * @param string $class
+ * @param string $content
+ * @return string
+ */
+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: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%"'
+ . '>'
+ . $content . ''
+ . '</div>'
+ . '</div>';
}
/**
* Render glyphicon
*
- * @param string $glyph_name
+ * @param string $glyph_name
+ * @return string
*/
-function glyph($glyph_name) {
- return ' <span class="glyphicon glyphicon-' . $glyph_name . '"></span> ';
+function glyph($glyph_name)
+{
+ return ' <span class="glyphicon glyphicon-' . $glyph_name . '"></span> ';
}
/**
* Renders a tick or a cross by given boolean
*
- * @param boolean $boolean
+ * @param boolean $boolean
+ * @return string
*/
-function glyph_bool($boolean) {
- return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
+function glyph_bool($boolean)
+{
+ return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
}
-function div($class, $content = [], $dom_id = "") {
- if (is_array($content)) {
- $content = join("\n", $content);
- }
- $dom_id = $dom_id != '' ? ' id="' . $dom_id . '"' : '';
- return '<div' . $dom_id . ' class="' . $class . '">' . $content . '</div>';
+/**
+ * @param string $class
+ * @param array $content
+ * @param string $dom_id
+ * @return string
+ */
+function div($class, $content = [], $dom_id = '')
+{
+ if (is_array($content)) {
+ $content = join("\n", $content);
+ }
+ $dom_id = $dom_id != '' ? ' id="' . $dom_id . '"' : '';
+ return '<div' . $dom_id . ' class="' . $class . '">' . $content . '</div>';
}
-function heading($content, $number = 1) {
- return "<h" . $number . ">" . $content . "</h" . $number . ">";
+/**
+ * @param string $content
+ * @param int $number
+ * @return string
+ */
+function heading($content, $number = 1)
+{
+ return '<h' . $number . '>' . $content . '</h' . $number . '>';
}
/**
* Render a toolbar.
*
- * @param array $items
+ * @param array $items
+ * @param bool $right
* @return string
*/
-function toolbar($items = [], $right = false) {
- return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>';
+function toolbar($items = [], $right = false)
+{
+ return '<ul class="nav navbar-nav' . ($right ? ' navbar-right' : '') . '">' . join("\n", $items) . '</ul>';
}
-function toolbar_pills($items) {
- return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>';
+/**
+ * @param string[] $items
+ * @return string
+ */
+function toolbar_pills($items)
+{
+ return '<ul class="nav nav-pills">' . join("\n", $items) . '</ul>';
}
/**
* Render a link for a toolbar.
*
- * @param string $href
- * @param string $glyphicon
- * @param string $label
- * @param bool $selected
+ * @param string $href
+ * @param string $glyphicon
+ * @param string $label
+ * @param bool $selected
* @return string
*/
-function toolbar_item_link($href, $glyphicon, $label, $selected = false) {
- return '<li class="' . ($selected ? 'active' : '') . '"><a href="' . $href . '">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . '</a></li>';
+function toolbar_item_link($href, $glyphicon, $label, $selected = false)
+{
+ return '<li class="' . ($selected ? 'active' : '') . '">'
+ . '<a href="' . $href . '">'
+ . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '')
+ . $label
+ . '</a>'
+ . '</li>';
}
-function toolbar_item_divider() {
- return '<li class="divider"></li>';
+/**
+ * @return string
+ */
+function toolbar_item_divider()
+{
+ return '<li class="divider"></li>';
}
-function toolbar_dropdown($glyphicon, $label, $submenu, $class = '') {
- return '<li class="dropdown ' . $class . '">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a>
- <ul class="dropdown-menu" role="menu">' . join("\n", $submenu) . '</ul></li>';
+/**
+ * @param string $glyphicon
+ * @param string $label
+ * @param array $submenu
+ * @param string $class
+ * @return string
+ */
+function toolbar_dropdown($glyphicon, $label, $submenu, $class = '')
+{
+ return '<li class="dropdown ' . $class . '">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">'
+ . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '')
+ . $label
+ . ' <span class="caret"></span></a>
+ <ul class="dropdown-menu" role="menu">'
+ . join("\n", $submenu)
+ . '</ul></li>';
}
-function toolbar_popover($glyphicon, $label, $content, $class = '') {
- $dom_id = md5(microtime() . $glyphicon . $label);
- return '<li class="dropdown messages ' . $class . '">
- <a id="' . $dom_id . '" href="#" tabindex="0">' . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '') . $label . ' <span class="caret"></span></a>
+/**
+ * @param string $glyphicon
+ * @param string $label
+ * @param string[] $content
+ * @param string $class
+ * @return string
+ */
+function toolbar_popover($glyphicon, $label, $content, $class = '')
+{
+ $dom_id = md5(microtime() . $glyphicon . $label);
+ return '<li class="dropdown messages ' . $class . '">
+ <a id="' . $dom_id . '" href="#" tabindex="0">'
+ . ($glyphicon != '' ? '<span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' : '')
+ . $label
+ . ' <span class="caret"></span></a>
<script type="text/javascript">
$(function(){
$("#' . $dom_id . '").popover({
- trigger: "focus",
- html: true,
- content: "' . addslashes(join('', $content)) . '",
- placement: "bottom",
+ trigger: "focus",
+ html: true,
+ content: "' . addslashes(join('', $content)) . '",
+ placement: "bottom",
container: "#navbar-collapse-1"
})
});
@@ -124,155 +216,214 @@ function toolbar_popover($glyphicon, $label, $content, $class = '') {
/**
* Generiert HTML Code für eine "Seite".
* Fügt dazu die übergebenen Elemente zusammen.
+ *
+ * @param string[] $elements
+ * @return string
*/
-function page($elements) {
- return join($elements);
+function page($elements)
+{
+ return join($elements);
}
/**
* Generiert HTML Code für eine "Seite" mit zentraler Überschrift
* Fügt dazu die übergebenen Elemente zusammen.
+ *
+ * @param string $title
+ * @param string[] $elements
+ * @return string
+ */
+function page_with_title($title, $elements)
+{
+ return '<div class="col-md-12"><h1>' . $title . '</h1>' . join($elements) . '</div>';
+}
+
+/**
+ * Renders a description based on the data arrays key and values as label an description.
+ * @param array $data
*/
-function page_with_title($title, $elements) {
- return '<div class="col-md-12"><h1>' . $title . '</h1>' . join($elements) . '</div>';
+function description($data) {
+ $elements = [];
+ foreach($data as $label => $description) {
+ if(!empty($label) && !empty($description)) {
+ $elements[] = '<dt>' . $label . '</dt><dd>' . $description . '</dd>';
+ }
+ }
+ return '<dl class="dl-horizontal">' . join($elements) . '</dl>';
}
/**
* Rendert eine Datentabelle
+ *
+ * @param array|string $columns
+ * @param array[] $rows_raw
+ * @param bool $data
+ * @return string
*/
-function table($columns, $rows_raw, $data = true) {
- // If only one column is given
- if (! is_array($columns)) {
- $rows = [];
- foreach ($rows_raw as $row) {
- $rows[] = [
- 'col' => $row
- ];
+function table($columns, $rows_raw, $data = true)
+{
+ // If only one column is given
+ if (!is_array($columns)) {
+ $rows = [];
+ foreach ($rows_raw as $row) {
+ $rows[] = [
+ 'col' => $row
+ ];
+ }
+ return render_table([
+ 'col' => $columns
+ ], $rows, $data);
}
- return render_table([
- 'col' => $columns
- ], $rows, $data);
- }
-
- return render_table($columns, $rows_raw, $data);
+
+ return render_table($columns, $rows_raw, $data);
}
/**
* Helper for rendering a html-table.
* use table()
+ *
+ * @param string[] $columns
+ * @param array[] $rows
+ * @param bool $data
+ * @return string
*/
-function render_table($columns, $rows, $data = true) {
- if (count($rows) == 0) {
- return info(_("No data found."), true);
- }
-
- $html = '<table class="table table-striped' . ($data ? ' data' : '') . '">';
- $html .= '<thead><tr>';
- foreach ($columns as $key => $column) {
- $html .= '<th class="column_' . $key . '">' . $column . '</th>';
- }
- $html .= '</tr></thead>';
- $html .= '<tbody>';
- foreach ($rows as $row) {
- $html .= '<tr>';
+function render_table($columns, $rows, $data = true)
+{
+ if (count($rows) == 0) {
+ return info(_('No data found.'), true);
+ }
+
+ $html = '<table class="table table-striped' . ($data ? ' data' : '') . '">';
+ $html .= '<thead><tr>';
foreach ($columns as $key => $column) {
- $value = "&nbsp;";
- if (isset($row[$key])) {
- $value = $row[$key];
- }
- $html .= '<td class="column_' . $key . '">' . $value . '</td>';
+ $html .= '<th class="column_' . $key . '">' . $column . '</th>';
+ }
+ $html .= '</tr></thead>';
+ $html .= '<tbody>';
+ foreach ($rows as $row) {
+ $html .= '<tr>';
+ foreach ($columns as $key => $column) {
+ $value = "&nbsp;";
+ if (isset($row[$key])) {
+ $value = $row[$key];
+ }
+ $html .= '<td class="column_' . $key . '">' . $value . '</td>';
+ }
+ $html .= '</tr>';
}
- $html .= '</tr>';
- }
- $html .= '</tbody>';
- $html .= '</table>';
- return $html;
+ $html .= '</tbody>';
+ $html .= '</table>';
+ return $html;
}
/**
* Rendert einen Knopf
+ *
+ * @param string $href
+ * @param string $label
+ * @param string $class
+ * @return string
*/
-function button($href, $label, $class = "") {
- return '<a href="' . $href . '" class="btn btn-default ' . $class . '">' . $label . '</a>';
+function button($href, $label, $class = '')
+{
+ return '<a href="' . $href . '" class="btn btn-default ' . $class . '">' . $label . '</a>';
}
/**
* Rendert einen Knopf mit Glyph
+ *
+ * @param string $href
+ * @param string $glyph
+ * @param string $class
+ * @return string
*/
-function button_glyph($href, $glyph, $class = "") {
- return button($href, glyph($glyph), $class);
+function button_glyph($href, $glyph, $class = '')
+{
+ return button($href, glyph($glyph), $class);
}
/**
* Rendert eine Toolbar mit Knöpfen
+ *
+ * @param array $buttons
+ * @return string
*/
-function buttons($buttons = []) {
- return '<div class="form-group">' . table_buttons($buttons) . '</div>';
+function buttons($buttons = [])
+{
+ return '<div class="form-group">' . table_buttons($buttons) . '</div>';
}
-function table_buttons($buttons = []) {
- return '<div class="btn-group">' . join(' ', $buttons) . '</div>';
+/**
+ * @param array $buttons
+ * @return string
+ */
+function table_buttons($buttons = [])
+{
+ return '<div class="btn-group">' . join(' ', $buttons) . '</div>';
}
-// Load and render template
-function template_render($file, $data) {
- if (file_exists($file)) {
- $template = file_get_contents($file);
- if (is_array($data)) {
- foreach ($data as $name => $content) {
- $template = str_replace("%" . $name . "%", $content, $template);
- }
+/**
+ * @param string $str
+ * @param int $length
+ * @return string
+ */
+function shorten($str, $length = 50)
+{
+ if (strlen($str) < $length) {
+ return $str;
}
- return $template;
- }
- engelsystem_error("Cannot find template file &laquo;" . $file . "&raquo;.");
-}
-
-function shorten($str, $length = 50) {
- if (strlen($str) < $length) {
- return $str;
- }
- return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">' . substr($str, 0, $length - 3) . '...</span>';
+ return '<span title="' . htmlentities($str, ENT_COMPAT, 'UTF-8') . '">'
+ . substr($str, 0, $length - 3)
+ . '...</span>';
}
-function table_body($array) {
- $html = "";
- foreach ($array as $line) {
- $html .= "<tr>";
- if (is_array($line)) {
- foreach ($line as $td) {
- $html .= "<td>" . $td . "</td>";
- }
- } else {
- $html .= "<td>" . $line . "</td>";
+/**
+ * @param array[] $array
+ * @return string
+ */
+function table_body($array)
+{
+ $html = '';
+ foreach ($array as $line) {
+ $html .= '<tr>';
+ if (is_array($line)) {
+ foreach ($line as $td) {
+ $html .= '<td>' . $td . '</td>';
+ }
+ } else {
+ $html .= '<td>' . $line . '</td>';
+ }
+ $html .= '</tr>';
}
- $html .= "</tr>";
- }
- return $html;
+ return $html;
}
-function ReplaceSmilies($neueckig) {
- $neueckig = str_replace(";o))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig);
- $neueckig = str_replace(":-))", "<img src=\"pic/smiles/icon_redface.gif\">", $neueckig);
- $neueckig = str_replace(";o)", "<img src=\"pic/smiles/icon_wind.gif\">", $neueckig);
- $neueckig = str_replace(":)", "<img src=\"pic/smiles/icon_smile.gif\">", $neueckig);
- $neueckig = str_replace(":-)", "<img src=\"pic/smiles/icon_smile.gif\">", $neueckig);
- $neueckig = str_replace(":(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig);
- $neueckig = str_replace(":-(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig);
- $neueckig = str_replace(":o(", "<img src=\"pic/smiles/icon_sad.gif\">", $neueckig);
- $neueckig = str_replace(":o)", "<img src=\"pic/smiles/icon_lol.gif\">", $neueckig);
- $neueckig = str_replace(";o(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig);
- $neueckig = str_replace(";(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig);
- $neueckig = str_replace(";-(", "<img src=\"pic/smiles/icon_cry.gif\">", $neueckig);
- $neueckig = str_replace("8)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $neueckig);
- $neueckig = str_replace("8o)", "<img src=\"pic/smiles/icon_rolleyes.gif\">", $neueckig);
- $neueckig = str_replace(":P", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig);
- $neueckig = str_replace(":-P", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig);
- $neueckig = str_replace(":oP", "<img src=\"pic/smiles/icon_evil.gif\">", $neueckig);
- $neueckig = str_replace(";P", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
- $neueckig = str_replace(";oP", "<img src=\"pic/smiles/icon_mad.gif\">", $neueckig);
- $neueckig = str_replace("?)", "<img src=\"pic/smiles/icon_question.gif\">", $neueckig);
-
- return $neueckig;
+/**
+ * @param string $msg
+ * @return mixed
+ */
+function ReplaceSmilies($msg)
+{
+ $msg = str_replace(';o))', '<img src="pic/smiles/icon_redface.gif">', $msg);
+ $msg = str_replace(':-))', '<img src="pic/smiles/icon_redface.gif">', $msg);
+ $msg = str_replace(';o)', '<img src="pic/smiles/icon_wind.gif">', $msg);
+ $msg = str_replace(':)', '<img src="pic/smiles/icon_smile.gif">', $msg);
+ $msg = str_replace(':-)', '<img src="pic/smiles/icon_smile.gif">', $msg);
+ $msg = str_replace(':(', '<img src="pic/smiles/icon_sad.gif">', $msg);
+ $msg = str_replace(':-(', '<img src="pic/smiles/icon_sad.gif">', $msg);
+ $msg = str_replace(':o(', '<img src="pic/smiles/icon_sad.gif">', $msg);
+ $msg = str_replace(':o)', '<img src="pic/smiles/icon_lol.gif">', $msg);
+ $msg = str_replace(';o(', '<img src="pic/smiles/icon_cry.gif">', $msg);
+ $msg = str_replace(';(', '<img src="pic/smiles/icon_cry.gif">', $msg);
+ $msg = str_replace(';-(', '<img src="pic/smiles/icon_cry.gif">', $msg);
+ $msg = str_replace('8)', '<img src="pic/smiles/icon_rolleyes.gif">', $msg);
+ $msg = str_replace('8o)', '<img src="pic/smiles/icon_rolleyes.gif">', $msg);
+ $msg = str_replace(':P', '<img src="pic/smiles/icon_evil.gif">', $msg);
+ $msg = str_replace(':-P', '<img src="pic/smiles/icon_evil.gif">', $msg);
+ $msg = str_replace(':oP', '<img src="pic/smiles/icon_evil.gif">', $msg);
+ $msg = str_replace(';P', '<img src="pic/smiles/icon_mad.gif">', $msg);
+ $msg = str_replace(';oP', '<img src="pic/smiles/icon_mad.gif">', $msg);
+ $msg = str_replace('?)', '<img src="pic/smiles/icon_question.gif">', $msg);
+
+ return $msg;
}
-?>
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index 592f8d6b..122241a0 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -1,5 +1,7 @@
<?php
+use Engelsystem\ShiftsFilterRenderer;
+use Engelsystem\ShiftCalendarRenderer;
/**
* AngelTypes
*/
@@ -7,323 +9,583 @@
/**
* Renders the angeltypes name as link.
*
- * @param AngelType $angeltype
+ * @param array $angeltype
+ * @return string
*/
-function AngelType_name_render($angeltype) {
- return '<a href="' . angeltype_link($angeltype['id']) . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
+function AngelType_name_render($angeltype)
+{
+ return '<a href="' . angeltype_link($angeltype['id']) . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
}
/**
* Render angeltype membership state
*
- * @param UserAngelType $user_angeltype
- * UserAngelType and AngelType
+ * @param array $user_angeltype UserAngelType and AngelType
* @return string
*/
-function AngelType_render_membership($user_angeltype) {
- if ($user_angeltype['user_angeltype_id'] != null) {
- if ($user_angeltype['restricted']) {
- if ($user_angeltype['confirm_user_id'] == null) {
- return glyph('lock') . _("Unconfirmed");
- } elseif ($user_angeltype['supporter']) {
- return glyph_bool(true) . _("supporter");
- }
- return glyph_bool(true) . _("Member");
- } elseif ($user_angeltype['supporter']) {
- return glyph_bool(true) . _("supporter");
+function AngelType_render_membership($user_angeltype)
+{
+ if ($user_angeltype['user_angeltype_id'] != null) {
+ if ($user_angeltype['restricted']) {
+ if ($user_angeltype['confirm_user_id'] == null) {
+ return glyph('lock') . _('Unconfirmed');
+ } elseif ($user_angeltype['supporter']) {
+ return glyph_bool(true) . _('supporter');
+ }
+ return glyph_bool(true) . _('Member');
+ } elseif ($user_angeltype['supporter']) {
+ return glyph_bool(true) . _('supporter');
+ }
+ return glyph_bool(true) . _('Member');
}
- return glyph_bool(true) . _("Member");
- }
- return glyph_bool(false);
+ return glyph_bool(false);
}
-function AngelType_delete_view($angeltype) {
- return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), [
- info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
- buttons([
- button(page_link_to('angeltypes'), _("cancel"), 'cancel'),
- button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok')
- ])
- ]);
+/**
+ * @param array $angeltype
+ * @return string
+ */
+function AngelType_delete_view($angeltype)
+{
+ return page_with_title(sprintf(_('Delete angeltype %s'), $angeltype['name']), [
+ info(sprintf(_('Do you want to delete angeltype %s?'), $angeltype['name']), true),
+ buttons([
+ button(page_link_to('angeltypes'), _('cancel'), 'cancel'),
+ button(
+ page_link_to(
+ 'angeltypes',
+ ['action' => 'delete', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]
+ ),
+ _('delete'),
+ 'ok'
+ )
+ ])
+ ]);
}
/**
* Render angeltype edit form.
*
- * @param Angeltype $angeltype
- * The angeltype to edit
- * @param boolean $supporter_mode
- * Is the user a supporter of this angeltype?
+ * @param array $angeltype The angeltype to edit
+ * @param boolean $supporter_mode Is the user a supporter of this angeltype?
+ * @return string
*/
-function AngelType_edit_view($angeltype, $supporter_mode) {
- $contact_info = AngelType_contact_info($angeltype);
- return page_with_title(sprintf(_("Edit %s"), $angeltype['name']), [
- buttons([
- button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
- ]),
- msg(),
- form([
- $supporter_mode ? form_info(_("Name"), $angeltype['name']) : form_text('name', _("Name"), $angeltype['name']),
- $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_text('contact_name', _("Name"), $angeltype['contact_name']),
- //form_text('contact_dect', _("DECT"), $angeltype['contact_dect']),
- //form_text('contact_email', _("E-Mail"), $angeltype['contact_email']),
- 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"))
- ])
- ]);
+function AngelType_edit_view($angeltype, $supporter_mode)
+{
+ return page_with_title(sprintf(_('Edit %s'), $angeltype['name']), [
+ buttons([
+ button(page_link_to('angeltypes'), _('Angeltypes'), 'back')
+ ]),
+ msg(),
+ form([
+ $supporter_mode
+ ? form_info(_('Name'), $angeltype['name'])
+ : form_text('name', _('Name'), $angeltype['name']),
+ $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 a supporter (double opt-in).')
+ ),
+ form_textarea('description', _('Description'), $angeltype['description']),
+ form_info('', _('Please use markdown for the description.')),
+ heading(_('Contact'), 3),
+ form_info(
+ '',
+ _('Primary contact person/desk for user questions.')
+ ),
+ form_text('contact_name', _('Name'), $angeltype['contact_name']),
+ form_text('contact_dect', _('DECT'), $angeltype['contact_dect']),
+ form_text('contact_email', _('E-Mail'), $angeltype['contact_email']),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
}
/**
* Renders the buttons for the angeltype view.
+ *
+ * @param array $angeltype
+ * @param array|null $user_angeltype
+ * @param bool $admin_angeltypes
+ * @param bool $supporter
+ * @param array|null $user_driver_license
+ * @param array|null $user
+ * @return string
*/
-function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user) {
- $buttons = [
- button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
- ];
-
- if ($angeltype['requires_driver_license']) {
- $buttons[] = button(user_driver_license_edit_link($user), glyph("road") . _("my driving license"));
- }
-
- if ($user_angeltype == null) {
- $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) {
- error(_("This angeltype requires a driver license. Please enter your driver license information!"));
+function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user)
+{
+ $buttons = [
+ button(page_link_to('angeltypes'), _('Angeltypes'), 'back')
+ ];
+
+ if ($angeltype['requires_driver_license']) {
+ $buttons[] = button(user_driver_license_edit_link($user), glyph('road') . _('my driving license'));
}
-
- if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) {
- error(sprintf(_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), $angeltype['name']));
+
+ if ($user_angeltype == null) {
+ $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) {
+ error(_('This angeltype requires a driver license. Please enter your driver license information!'));
+ }
+
+ if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) {
+ error(sprintf(
+ _('You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed.'),
+ $angeltype['name']
+ ));
+ }
+ $buttons[] = button(
+ page_link_to('user_angeltypes', ['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id']]),
+ _('leave'), 'cancel'
+ );
+ }
+
+ if ($admin_angeltypes || $supporter) {
+ $buttons[] = button(
+ page_link_to('angeltypes', ['action' => 'edit', 'angeltype_id' => $angeltype['id']]),
+ _('edit'),
+ 'edit'
+ );
}
- $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel');
- }
-
- if ($admin_angeltypes || $supporter) {
- $buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit');
- }
- if ($admin_angeltypes) {
- $buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
- }
-
- return buttons($buttons);
+ if ($admin_angeltypes) {
+ $buttons[] = button(
+ page_link_to('angeltypes', ['action' => 'delete', 'angeltype_id' => $angeltype['id']]),
+ _('delete'),
+ 'delete'
+ );
+ }
+
+ return buttons($buttons);
}
/**
* Renders and sorts the members of an angeltype into supporters, members and unconfirmed members.
*
- * @return [supporters, members, unconfirmed members]
+ * @param array $angeltype
+ * @param array $members
+ * @param bool $admin_user_angeltypes
+ * @param bool $admin_angeltypes
+ * @return array [supporters, members, unconfirmed members]
*/
-function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes) {
- $supporters = [];
- $members_confirmed = [];
- $members_unconfirmed = [];
- foreach ($members as $member) {
- $member['Nick'] = User_Nick_render($member);
+function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes)
+{
+ $supporters = [];
+ $members_confirmed = [];
+ $members_unconfirmed = [];
+ foreach ($members as $member) {
+ $member['Nick'] = User_Nick_render($member);
+ if ($angeltype['requires_driver_license']) {
+ $member['wants_to_drive'] = glyph_bool($member['wants_to_drive']);
+ $member['has_car'] = glyph_bool($member['has_car']);
+ $member['has_license_car'] = glyph_bool($member['has_license_car']);
+ $member['has_license_3_5t_transporter'] = glyph_bool($member['has_license_3_5t_transporter']);
+ $member['has_license_7_5t_truck'] = glyph_bool($member['has_license_7_5t_truck']);
+ $member['has_license_12_5t_truck'] = glyph_bool($member['has_license_12_5t_truck']);
+ $member['has_license_forklift'] = glyph_bool($member['has_license_forklift']);
+ }
- if ($angeltype['requires_driver_license']) {
- $member['wants_to_drive'] = glyph_bool($member['wants_to_drive']);
- $member['has_car'] = glyph_bool($member['has_car']);
- $member['has_license_car'] = glyph_bool($member['has_license_car']);
- $member['has_license_3_5t_transporter'] = glyph_bool($member['has_license_3_5t_transporter']);
- $member['has_license_7_5t_truck'] = glyph_bool($member['has_license_7_5t_truck']);
- $member['has_license_12_5t_truck'] = glyph_bool($member['has_license_12_5t_truck']);
- $member['has_license_forklift'] = glyph_bool($member['has_license_forklift']);
+ if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
+ $member['actions'] = table_buttons([
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'confirm', 'user_angeltype_id' => $member['user_angeltype_id']]
+ ),
+ _('confirm'),
+ 'btn-xs'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'delete', 'user_angeltype_id' => $member['user_angeltype_id']]
+ ),
+ _('deny'),
+ 'btn-xs'
+ )
+ ]);
+ $members_unconfirmed[] = $member;
+ } elseif ($member['supporter']) {
+ if ($admin_angeltypes) {
+ $member['actions'] = table_buttons([
+ button(
+ page_link_to('user_angeltypes', [
+ 'action' => 'update',
+ 'user_angeltype_id' => $member['user_angeltype_id'],
+ 'supporter' => 0
+ ]),
+ _('Remove supporter rights'),
+ 'btn-xs'
+ )
+ ]);
+ } else {
+ $member['actions'] = '';
+ }
+ $supporters[] = $member;
+ } else {
+ if ($admin_user_angeltypes) {
+ $member['actions'] = table_buttons([
+ $admin_angeltypes
+ ? button(page_link_to('user_angeltypes', [
+ 'action' => 'update',
+ 'user_angeltype_id' => $member['user_angeltype_id'],
+ 'supporter' => 1
+ ]),
+ _('Add supporter rights'), 'btn-xs')
+ : '',
+ button(
+ page_link_to('user_angeltypes', [
+ 'action' => 'delete',
+ 'user_angeltype_id' => $member['user_angeltype_id']
+ ]),
+ _('remove'),
+ 'btn-xs'
+ )
+ ]);
+ }
+ $members_confirmed[] = $member;
+ }
}
-
- if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
- $member['actions'] = table_buttons([
- button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'], _("confirm"), 'btn-xs'),
- button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("deny"), 'btn-xs')
- ]);
- $members_unconfirmed[] = $member;
- } elseif ($member['supporter']) {
- if ($admin_angeltypes) {
- $member['actions'] = table_buttons([
- button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=0', _("Remove supporter rights"), 'btn-xs')
- ]);
- } else {
- $member['actions'] = '';
- }
- $supporters[] = $member;
- } else {
- if ($admin_user_angeltypes) {
- $member['actions'] = table_buttons([
- $admin_angeltypes ? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&supporter=1', _("Add supporter rights"), 'btn-xs') : '',
- button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("remove"), 'btn-xs')
- ]);
- }
- $members_confirmed[] = $member;
- }
- }
-
- return [
- $supporters,
- $members_confirmed,
- $members_unconfirmed
- ];
+
+ return [
+ $supporters,
+ $members_confirmed,
+ $members_unconfirmed
+ ];
}
/**
* Creates the needed member table headers according to given rights and settings from the angeltype.
+ *
+ * @param array $angeltype
+ * @param bool $supporter
+ * @param bool $admin_angeltypes
+ * @return array
*/
-function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes) {
- if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
+function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
+{
+ if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
+ return [
+ 'Nick' => _('Nick'),
+ 'DECT' => _('DECT'),
+ 'wants_to_drive' => _('Driver'),
+ 'has_car' => _('Has car'),
+ 'has_license_car' => _('Car'),
+ 'has_license_3_5t_transporter' => _('3,5t Transporter'),
+ 'has_license_7_5t_truck' => _('7,5t Truck'),
+ 'has_license_12_5t_truck' => _('12,5t Truck'),
+ 'has_license_forklift' => _('Forklift'),
+ 'actions' => ''
+ ];
+ }
return [
- 'Nick' => _("Nick"),
- 'DECT' => _("DECT"),
- 'wants_to_drive' => _("Driver"),
- 'has_car' => _("Has car"),
- 'has_license_car' => _("Car"),
- 'has_license_3_5t_transporter' => _("3,5t Transporter"),
- 'has_license_7_5t_truck' => _("7,5t Truck"),
- 'has_license_12_5t_truck' => _("12,5t Truck"),
- 'has_license_forklift' => _("Forklift"),
- 'actions' => ''
+ 'Nick' => _('Nick'),
+ 'DECT' => _('DECT'),
+ 'actions' => ''
];
- }
- return [
- 'Nick' => _("Nick"),
- 'DECT' => _("DECT"),
- 'actions' => ''
- ];
}
/**
* Render an angeltype page containing the member lists.
+ *
+ * @param array $angeltype
+ * @param array[] $members
+ * @param array $user_angeltype
+ * @param bool $admin_user_angeltypes
+ * @param bool $admin_angeltypes
+ * @param bool $supporter
+ * @param array $user_driver_license
+ * @param array $user
+ * @param ShiftsFilterRenderer $shiftsFilterRenderer
+ * @param ShiftCalendarRenderer $shiftCalendarRenderer
+ * @param int $tab The selected tab
+ * @return string
*/
-function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $supporter, $user_driver_license, $user) {
- $page = [
- AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
- msg()
- ];
-
- $page[] = '<h3>' . _("Description") . '</h3>';
- $parsedown = new Parsedown();
- if ($angeltype['description'] != "") {
- $page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
- }
-
- list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes);
- $table_headers = AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes);
-
- if (count($supporters) > 0) {
- $page[] = '<h3>' . _("supporters") . '</h3>';
- $page[] = table($table_headers, $supporters);
- }
-
- if (count($members_confirmed) > 0) {
- $members_confirmed[] = [
- 'Nick' => _('Sum'),
- 'DECT' => count($members_confirmed),
- 'actions' => ''
- ];
- }
-
- if (count($members_unconfirmed) > 0) {
- $members_unconfirmed[] = [
- 'Nick' => _('Sum'),
- 'DECT' => count($members_unconfirmed),
- 'actions' => ''
- ];
- }
-
- $page[] = '<h3>' . _("Members") . '</h3>';
- if ($admin_user_angeltypes) {
- $page[] = buttons([
- button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add')
+function AngelType_view(
+ $angeltype,
+ $members,
+ $user_angeltype,
+ $admin_user_angeltypes,
+ $admin_angeltypes,
+ $supporter,
+ $user_driver_license,
+ $user,
+ ShiftsFilterRenderer $shiftsFilterRenderer,
+ ShiftCalendarRenderer $shiftCalendarRenderer,
+ $tab
+) {
+ return page_with_title(sprintf(_('Team %s'), $angeltype['name']), [
+ AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
+ msg(),
+ tabs([
+ _('Info') => AngelType_view_info(
+ $angeltype,
+ $members,
+ $admin_user_angeltypes,
+ $admin_angeltypes,
+ $supporter
+ ),
+ _('Shifts') => AngelType_view_shifts(
+ $angeltype,
+ $shiftsFilterRenderer,
+ $shiftCalendarRenderer
+ )
+ ], $tab)
]);
- }
- $page[] = table($table_headers, $members_confirmed);
-
- if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
- $page[] = '<h3>' . _("Unconfirmed") . '</h3>';
- $page[] = buttons([
- button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'], _("confirm all"), 'ok'),
- button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'], _("deny all"), 'cancel')
+}
+
+/**
+ * @param Angeltype $angeltype
+ * @param ShiftsFilterRenderer $shiftsFilterRenderer
+ * @param ShiftCalendarRenderer $shiftCalendarRenderer
+ * @return string HTML
+ */
+function AngelType_view_shifts($angeltype, $shiftsFilterRenderer, $shiftCalendarRenderer)
+{
+ $shifts = $shiftsFilterRenderer->render(page_link_to('angeltypes', [
+ 'action' => 'view',
+ 'angeltype_id' => $angeltype['id']
+ ]));
+ $shifts .= $shiftCalendarRenderer->render();
+
+ return div('first', $shifts);
+}
+
+/**
+ * @param Angeltype $angeltype
+ * @param array $members
+ * @param bool $admin_user_angeltypes
+ * @param bool $admin_angeltypes
+ * @param bool $supporter
+ * @return string HTML
+ */
+function AngelType_view_info(
+ $angeltype,
+ $members,
+ $admin_user_angeltypes,
+ $admin_angeltypes,
+ $supporter
+) {
+ $info = [];
+ if(AngelType_has_contact_info($angeltype)) {
+ $info[] = AngelTypes_render_contact_info($angeltype);
+ }
+
+ $info[] = '<h3>' . _('Description') . '</h3>';
+ $parsedown = new Parsedown();
+ if ($angeltype['description'] != '') {
+ $info[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
+ }
+
+ list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members(
+ $angeltype,
+ $members,
+ $admin_user_angeltypes,
+ $admin_angeltypes
+ );
+ $table_headers = AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes);
+
+ if (count($supporters) > 0) {
+ $info[] = '<h3>' . _('supporters') . '</h3>';
+ $info[] = table($table_headers, $supporters);
+ }
+
+ if (count($members_confirmed) > 0) {
+ $members_confirmed[] = [
+ 'Nick' => _('Sum'),
+ 'DECT' => count($members_confirmed),
+ 'actions' => ''
+ ];
+ }
+
+ if (count($members_unconfirmed) > 0) {
+ $members_unconfirmed[] = [
+ 'Nick' => _('Sum'),
+ 'DECT' => count($members_unconfirmed),
+ 'actions' => ''
+ ];
+ }
+
+ $info[] = '<h3>' . _('Members') . '</h3>';
+ if ($admin_user_angeltypes) {
+ $info[] = buttons([
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'add', 'angeltype_id' => $angeltype['id']]
+ ),
+ _('Add'),
+ 'add'
+ )
+ ]);
+ }
+ $info[] = table($table_headers, $members_confirmed);
+
+ if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
+ $info[] = '<h3>' . _('Unconfirmed') . '</h3>';
+ $info[] = buttons([
+ button(
+ page_link_to('user_angeltypes', ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id']]),
+ _('confirm all'),
+ 'ok'
+ ),
+ button(
+ page_link_to('user_angeltypes', ['action' => 'delete_all', 'angeltype_id' => $angeltype['id']]),
+ _('deny all'),
+ 'cancel'
+ )
+ ]);
+ $info[] = table($table_headers, $members_unconfirmed);
+ }
+
+ return join($info);
+}
+
+/**
+ * Renders the contact info
+ *
+ * @param Anteltype $angeltype
+ * @return string HTML
+ */
+function AngelTypes_render_contact_info($angeltype)
+{
+ return heading(_('Contact'), 3) . description([
+ _('Name') => $angeltype['contact_name'],
+ _('DECT') => $angeltype['contact_dect'],
+ _('E-Mail') => $angeltype['contact_email']
]);
- $page[] = table($table_headers, $members_unconfirmed);
- }
-
- return page_with_title(sprintf(_("Team %s"), $angeltype['name']), $page);
}
/**
* Display the list of angeltypes.
*
- * @param array $angeltypes
+ * @param array $angeltypes
+ * @param bool $admin_angeltypes
+ * @return string
*/
-function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
- return page_with_title(angeltypes_title(), [
- msg(),
- buttons([
- $admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '',
- button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description"))
- ]),
- table([
- 'name' => _("Name"),
- 'restricted' => glyph('lock') . _("Restricted"),
- 'no_self_signup' => glyph('share') . _("Self Sign Up Allowed"),
- 'membership' => _("Membership"),
- 'actions' => ""
- ], $angeltypes)
- ]);
+function AngelTypes_list_view($angeltypes, $admin_angeltypes)
+{
+ return page_with_title(angeltypes_title(), [
+ msg(),
+ buttons([
+ $admin_angeltypes
+ ? button(page_link_to('angeltypes', ['action' => 'edit']), _('New angeltype'), 'add')
+ : '',
+ button(page_link_to('angeltypes', ['action' => 'about']), _('Teams/Job description'))
+ ]),
+ table([
+ 'name' => _('Name'),
+ 'restricted' => glyph('lock') . _('Restricted'),
+ 'no_self_signup' => glyph('share') . _('Self Sign Up Allowed'),
+ 'membership' => _('Membership'),
+ 'actions' => ''
+ ], $angeltypes)
+ ]);
}
/**
* Renders the about info for an angeltype.
+ *
+ * @param array $angeltype
+ * @return string
*/
-function AngelTypes_about_view_angeltype($angeltype) {
- $parsedown = new Parsedown();
-
- $html = '<h2>' . $angeltype['name'] . '</h2>';
-
- if (isset($angeltype['user_angeltype_id'])) {
- $buttons = [];
- if ($angeltype['user_angeltype_id'] != null) {
- $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel');
- } else {
- $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
+function AngelTypes_about_view_angeltype($angeltype)
+{
+ $parsedown = new Parsedown();
+
+ $html = '<h2>' . $angeltype['name'] . '</h2>';
+
+ if(AngelType_has_contact_info($angeltype)) {
+ $html .= AngelTypes_render_contact_info($angeltype);
+ }
+
+ if (isset($angeltype['user_angeltype_id'])) {
+ $buttons = [];
+ if ($angeltype['user_angeltype_id'] != null) {
+ $buttons[] = button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']]
+ ),
+ _('leave'),
+ 'cancel'
+ );
+ } else {
+ $buttons[] = button(
+ page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
+ _('join'),
+ 'add'
+ );
+ }
+ $html .= buttons($buttons);
+ }
+
+ 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['description'] != '') {
+ $html .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
}
- $html .= buttons($buttons);
- }
-
- 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['description'] != "") {
- $html .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
- }
- $html .= '<hr />';
-
- return $html;
+ $html .= '<hr />';
+
+ return $html;
}
/**
* Renders a site that contains every angeltype and its description, basically as an overview of the needed help types.
+ *
+ * @param array[] $angeltypes
+ * @param bool $user_logged_in
+ * @return string
*/
-function AngelTypes_about_view($angeltypes, $user_logged_in) {
- global $faq_url;
-
- $content = [
- buttons([
- ! $user_logged_in ? button(page_link_to('register'), register_title()) : '',
- ! $user_logged_in ? button(page_link_to('login'), login_title()) : '',
- $user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '',
- button($faq_url, _("FAQ"), "btn-primary")
- ]),
- '<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>',
- '<hr />'
- ];
- foreach ($angeltypes as $angeltype) {
- $content[] = AngelTypes_about_view_angeltype($angeltype);
- }
-
- return page_with_title(_("Teams/Job description"), $content);
-}
+function AngelTypes_about_view($angeltypes, $user_logged_in)
+{
+ global $privileges;
-?>
+ $buttons = [];
+
+ if ($user_logged_in) {
+ $buttons[] = button(page_link_to('angeltypes'), angeltypes_title(), 'back');
+ } else {
+ if (in_array('register', $privileges) && config('registration_enabled')) {
+ $buttons[] = button(page_link_to('register'), register_title());
+ }
+
+ $buttons[] = button(page_link_to('login'), login_title());
+ }
+
+ $faqUrl = config('faq_url');
+ if (!empty($faqUrl)) {
+ $buttons[] = button($faqUrl, _('FAQ'), 'btn-primary');
+ }
+
+ $content = [
+ buttons($buttons),
+ '<p>' . _('Here is the list of teams and their tasks. If you have questions, read the FAQ.') . '</p>',
+ '<hr />'
+ ];
+ foreach ($angeltypes as $angeltype) {
+ $content[] = AngelTypes_about_view_angeltype($angeltype);
+ }
+
+ return page_with_title(_('Teams/Job description'), $content);
+}
diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php
index 37a19839..2b092962 100644
--- a/includes/view/EventConfig_view.php
+++ b/includes/view/EventConfig_view.php
@@ -2,128 +2,154 @@
/**
* Shows basic event infos and countdowns.
- * @param EventConfig $event_config The event configuration
+ *
+ * @param array $event_config The event configuration
+ * @return string
*/
-function EventConfig_countdown_page($event_config) {
- if ($event_config == null) {
- 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[] = 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[] = 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[] = 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']) {
- $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']) {
- $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);
+function EventConfig_countdown_page($event_config)
+{
+ if ($event_config == null) {
+ 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[] = 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[] = 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[] = 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']) {
+ $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']) {
+ $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);
}
/**
* Converts event name and start+end date into a line of text.
+ *
+ * @param array $event_config
+ * @return string
*/
-function EventConfig_info($event_config) {
- if ($event_config == null) {
- 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) {
- return sprintf(_("%s, from %s to %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date']));
- }
-
- // Event name, start date are set
- if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) {
- return sprintf(_("%s, starting %s"), $event_config['event_name'], date(_("Y-m-d"), $event_config['event_start_date']));
- }
-
- // Event start+end date are set
- if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
- return sprintf(_("Event from %s to %s"), date(_("Y-m-d"), $event_config['event_start_date']), date(_("Y-m-d"), $event_config['event_end_date']));
- }
-
- // Only event name is set
- if ($event_config['event_name'] != null) {
- return sprintf($event_config['event_name']);
- }
-
- return "";
+function EventConfig_info($event_config)
+{
+ if ($event_config == null) {
+ 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) {
+ return sprintf(
+ _('%s, from %s to %s'),
+ $event_config['event_name'],
+ date(_('Y-m-d'), $event_config['event_start_date']),
+ date(_('Y-m-d'), $event_config['event_end_date'])
+ );
+ }
+
+ // Event name, start date are set
+ if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) {
+ return sprintf(
+ _('%s, starting %s'), $event_config['event_name'],
+ date(_('Y-m-d'), $event_config['event_start_date'])
+ );
+ }
+
+ // Event start+end date are set
+ if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
+ return sprintf(
+ _('Event from %s to %s'),
+ date(_('Y-m-d'), $event_config['event_start_date']),
+ date(_('Y-m-d'), $event_config['event_end_date'])
+ );
+ }
+
+ // Only event name is set
+ if ($event_config['event_name'] != null) {
+ return sprintf($event_config['event_name']);
+ }
+
+ return '';
}
/**
* Render edit page for event config.
*
- * @param string $event_name
- * The event name
- * @param string $event_welcome_msg
- * The welcome message
- * @param date $buildup_start_date
- * @param date $event_start_date
- * @param date $event_end_date
- * @param date $teardown_end_date
+ * @param string $event_name The event name
+ * @param string $event_welcome_msg The welcome message
+ * @param int $buildup_start_date unix time stamp
+ * @param int $event_start_date unix time stamp
+ * @param int $event_end_date unix time stamp
+ * @param int $teardown_end_date unix time stamp
+ * @return string
*/
-function EventConfig_edit_view($event_name, $event_welcome_msg, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date) {
- return page_with_title(event_config_title(), [
- msg(),
- form([
- div('row', [
- div('col-md-6', [
- form_text('event_name', _("Event Name"), $event_name),
- form_info('', _("Event Name is shown on the start page.")),
- form_textarea('event_welcome_msg', _("Event Welcome Message"), $event_welcome_msg),
- form_info('', _("Welcome message is shown after successful registration. You can use markdown."))
- ]),
- div('col-md-3 col-xs-6', [
- form_date('buildup_start_date', _("Buildup date"), $buildup_start_date),
- form_date('event_start_date', _("Event start date"), $event_start_date)
- ]),
- div('col-md-3 col-xs-6', [
- form_date('teardown_end_date', _("Teardown end date"), $teardown_end_date),
- form_date('event_end_date', _("Event end date"), $event_end_date)
- ])
- ]),
- div('row', [
- div('col-md-6', [
- form_submit('submit', _("Save"))
- ])
- ])
- ])
- ]);
+function EventConfig_edit_view(
+ $event_name,
+ $event_welcome_msg,
+ $buildup_start_date,
+ $event_start_date,
+ $event_end_date,
+ $teardown_end_date
+) {
+ return page_with_title(event_config_title(), [
+ msg(),
+ form([
+ div('row', [
+ div('col-md-6', [
+ form_text('event_name', _('Event Name'), $event_name),
+ form_info('', _('Event Name is shown on the start page.')),
+ form_textarea('event_welcome_msg', _('Event Welcome Message'), $event_welcome_msg),
+ form_info('', _('Welcome message is shown after successful registration. You can use markdown.'))
+ ]),
+ div('col-md-3 col-xs-6', [
+ form_date('buildup_start_date', _('Buildup date'), $buildup_start_date),
+ form_date('event_start_date', _('Event start date'), $event_start_date)
+ ]),
+ div('col-md-3 col-xs-6', [
+ form_date('teardown_end_date', _('Teardown end date'), $teardown_end_date),
+ form_date('event_end_date', _('Event end date'), $event_end_date)
+ ])
+ ]),
+ div('row', [
+ div('col-md-6', [
+ form_submit('submit', _('Save'))
+ ])
+ ])
+ ])
+ ]);
}
-
-?> \ No newline at end of file
diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php
index a44a29d1..a44a099d 100644
--- a/includes/view/Questions_view.php
+++ b/includes/view/Questions_view.php
@@ -1,37 +1,50 @@
<?php
-function Questions_view($open_questions, $answered_questions, $ask_action) {
- foreach ($open_questions as &$question) {
- $question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
- $question['Question'] = str_replace("\n", '<br />', $question['Question']);
- }
-
- foreach ($answered_questions as &$question) {
- $question['Question'] = str_replace("\n", '<br />', $question['Question']);
- $question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
- $question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
- }
-
- return page_with_title(questions_title(), [
- msg(),
- heading(_("Open questions"), 2),
- table([
- 'Question' => _("Question"),
- 'actions' => ""
- ], $open_questions),
- heading(_("Answered questions"), 2),
- table([
- 'Question' => _("Question"),
- 'answer_user' => _("Answered by"),
- 'Answer' => _("Answer"),
- 'actions' => ""
- ], $answered_questions),
- heading(_("Ask the Heaven"), 2),
- form([
- form_textarea('question', _("Your Question:"), ""),
- form_submit('submit', _("Save"))
- ], $ask_action)
- ]);
-}
+/**
+ * @param array[] $open_questions
+ * @param array[] $answered_questions
+ * @param string $ask_action
+ * @return string
+ */
+function Questions_view($open_questions, $answered_questions, $ask_action)
+{
+ foreach ($open_questions as &$question) {
+ $question['actions'] = '<a href="'
+ . page_link_to('user_questions', ['action' => 'delete', 'id' => $question['QID']])
+ . '">'
+ . _('delete')
+ . '</a>';
+ $question['Question'] = str_replace("\n", '<br />', $question['Question']);
+ }
+
+ foreach ($answered_questions as &$question) {
+ $question['Question'] = str_replace("\n", '<br />', $question['Question']);
+ $question['Answer'] = str_replace("\n", '<br />', $question['Answer']);
+ $question['actions'] = '<a href="'
+ . page_link_to('user_questions', ['action' => 'delete', 'id' => $question['QID']])
+ . '">'
+ . _('delete')
+ . '</a>';
+ }
-?> \ No newline at end of file
+ return page_with_title(questions_title(), [
+ msg(),
+ heading(_('Open questions'), 2),
+ table([
+ 'Question' => _('Question'),
+ 'actions' => ''
+ ], $open_questions),
+ heading(_('Answered questions'), 2),
+ table([
+ 'Question' => _('Question'),
+ 'answer_user' => _('Answered by'),
+ 'Answer' => _('Answer'),
+ 'actions' => ''
+ ], $answered_questions),
+ heading(_('Ask the Heaven'), 2),
+ form([
+ form_textarea('question', _('Your Question:'), ''),
+ form_submit('submit', _('Save'))
+ ], $ask_action)
+ ]);
+}
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index 7afdc67b..bd6138e1 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -1,20 +1,42 @@
<?php
-use Engelsystem\ShiftsFilterRenderer;
+
use Engelsystem\ShiftCalendarRenderer;
+use Engelsystem\ShiftsFilterRenderer;
-function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer) {
- return page_with_title(glyph('map-marker') . $room['Name'], [
- $shiftsFilterRenderer->render(room_link($room)) ,
- $shiftCalendarRenderer->render()
- ]);
-}
+/**
+ * @param array $room
+ * @param ShiftsFilterRenderer $shiftsFilterRenderer
+ * @param ShiftCalendarRenderer $shiftCalendarRenderer
+ * @return string
+ */
+function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
+{
+ global $user;
+
+ $assignNotice = '';
+ if (config('signup_requires_arrival') && !$user['Gekommen']) {
+ $assignNotice = info(render_user_arrived_hint(), true);
+ }
-function Room_name_render($room) {
- global $privileges;
- if (in_array('view_rooms', $privileges)) {
- return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
- }
- return glyph('map-marker') . $room['Name'];
+ return page_with_title(glyph('map-marker') . $room['Name'], [
+ $shiftsFilterRenderer->render(page_link_to('rooms', [
+ 'action' => 'view',
+ 'room_id' => $room['RID']
+ ])),
+ $assignNotice,
+ $shiftCalendarRenderer->render()
+ ]);
}
-?> \ No newline at end of file
+/**
+ * @param array $room
+ * @return string
+ */
+function Room_name_render($room)
+{
+ global $privileges;
+ if (in_array('view_rooms', $privileges)) {
+ return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
+ }
+ return glyph('map-marker') . $room['Name'];
+}
diff --git a/includes/view/ShiftCalendarLane.php b/includes/view/ShiftCalendarLane.php
index 33fccec3..fd4c6f06 100644
--- a/includes/view/ShiftCalendarLane.php
+++ b/includes/view/ShiftCalendarLane.php
@@ -2,62 +2,85 @@
namespace Engelsystem;
+use Exception;
+
/**
* Represents a single lane in a shifts calendar.
*/
-class ShiftCalendarLane {
-
- private $firstBlockStartTime;
-
- private $blockCount;
-
- private $header;
-
- private $shifts = [];
-
- public function __construct($header, $firstBlockStartTime, $blockCount) {
- $this->header = $header;
- $this->firstBlockStartTime = $firstBlockStartTime;
- $this->blockCount = $blockCount;
- }
-
- /**
- * Adds a shift to the lane, but only if it fits.
- * Returns true on success.
- *
- * @param Shift $shift
- * The shift to add
- * @return boolean true on success
- */
- public function addShift($shift) {
- if ($this->shiftFits($shift)) {
- $this->shifts[] = $shift;
- return true;
+class ShiftCalendarLane
+{
+ /** @var int */
+ private $firstBlockStartTime;
+
+ /** @var int */
+ private $blockCount;
+
+ /** @var string */
+ private $header;
+
+ /** @var array[] */
+ private $shifts = [];
+
+ /**
+ * ShiftCalendarLane constructor.
+ *
+ * @param string $header
+ * @param int $firstBlockStartTime Unix timestamp
+ * @param int $blockCount
+ */
+ public function __construct($header, $firstBlockStartTime, $blockCount)
+ {
+ $this->header = $header;
+ $this->firstBlockStartTime = $firstBlockStartTime;
+ $this->blockCount = $blockCount;
}
- return false;
- }
-
- /**
- * Returns true if given shift fits into this lane.
- *
- * @param Shift $shift
- * The shift to fit into this lane
- */
- public function shiftFits($newShift) {
- foreach ($this->shifts as $laneShift) {
- if (! ($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) {
- return false;
- }
+
+ /**
+ * Adds a shift to the lane, but only if it fits.
+ * Returns true on success.
+ *
+ * @param array $shift The shift to add
+ * @throws Exception if the shift doesn't fit into the lane.
+ */
+ public function addShift($shift)
+ {
+ if ($this->shiftFits($shift)) {
+ $this->shifts[] = $shift;
+ return;
+ }
+ throw new Exception('Unable to add shift to shift calendar lane.');
}
- return true;
- }
- public function getHeader() {
- return $this->header;
- }
+ /**
+ * Returns true if given shift fits into this lane.
+ *
+ * @param array $newShift
+ * @return bool
+ * @internal param array $shift The shift to fit into this lane
+ */
+ public function shiftFits($newShift)
+ {
+ foreach ($this->shifts as $laneShift) {
+ if (!($newShift['start'] >= $laneShift['end'] || $newShift['end'] <= $laneShift['start'])) {
+ return false;
+ }
+ }
+ return true;
+ }
- public function getShifts() {
- return $this->shifts;
- }
+ /**
+ * @return string
+ */
+ public function getHeader()
+ {
+ return $this->header;
+ }
+
+ /**
+ * @return array[]
+ */
+ public function getShifts()
+ {
+ return $this->shifts;
+ }
}
-?> \ No newline at end of file
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index 8c8e72a4..354d0336 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -2,256 +2,310 @@
namespace Engelsystem;
-class ShiftCalendarRenderer {
-
- /**
- * 15m * 60s/m = 900s
- */
- const SECONDS_PER_ROW = 900;
-
- /**
- * Height of a block in pixel.
- * Do not change - corresponds with theme/css
- */
- const BLOCK_HEIGHT = 30;
-
- /**
- * Distance between two shifts in pixels
- */
- const MARGIN = 5;
-
- /**
- * Seconds added to the start and end time
- */
- const TIME_MARGIN = 1800;
-
- private $lanes;
-
- private $shiftsFilter;
-
- private $firstBlockStartTime = null;
-
- private $lastBlockEndTime = null;
-
- private $blocksPerSlot = null;
-
- private $needed_angeltypes = null;
-
- private $shift_entries = null;
-
- public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter) {
- $this->shiftsFilter = $shiftsFilter;
- $this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
- $this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
- $this->lanes = $this->assignShiftsToLanes($shifts);
- $this->needed_angeltypes = $needed_angeltypes;
- $this->shift_entries = $shift_entries;
- }
-
- /**
- * Assigns the shifts to different lanes per room if they collide
- *
- * @param Shift[] $shifts
- * The shifts to assign
- *
- * @return Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
- */
- private function assignShiftsToLanes($shifts) {
- // array that assigns a room id to a list of lanes (per room)
- $lanes = [];
-
- foreach ($shifts as $shift) {
- $room_id = $shift['RID'];
- $header = Room_name_render([
- 'RID' => $room_id,
- 'Name' => $shift['room_name']
- ]);
- if (! isset($lanes[$room_id])) {
- // initialize room with one lane
- $lanes[$room_id] = [
- new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
- ];
- }
- // Try to add the shift to the existing lanes for this room
- $shift_added = false;
- foreach ($lanes[$room_id] as $lane) {
- $shift_added = $lane->addShift($shift);
- if ($shift_added == true) {
- break;
- }
- }
- // If all lanes for this room are busy, create a new lane and add shift to it
- if ($shift_added == false) {
- $newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
- if (! $newLane->addShift($shift)) {
- engelsystem_error("Unable to add shift to new lane.");
+class ShiftCalendarRenderer
+{
+ /**
+ * 15m * 60s/m = 900s
+ */
+ const SECONDS_PER_ROW = 900;
+
+ /**
+ * Height of a block in pixel.
+ * Do not change - corresponds with theme/css
+ */
+ const BLOCK_HEIGHT = 30;
+
+ /**
+ * Distance between two shifts in pixels
+ */
+ const MARGIN = 5;
+
+ /**
+ * Seconds added to the start and end time
+ */
+ const TIME_MARGIN = 1800;
+
+ /** @var array */
+ private $lanes;
+
+ /** @var ShiftsFilter */
+ private $shiftsFilter;
+
+ /** @var int */
+ private $firstBlockStartTime = 0;
+
+ /** @var int */
+ private $lastBlockEndTime = 0;
+
+ /** @var int */
+ private $blocksPerSlot = null;
+
+ /** @var array[] */
+ private $needed_angeltypes = [];
+
+ /** @var array[] */
+ private $shift_entries = [];
+
+ /**
+ * ShiftCalendarRenderer constructor.
+ *
+ * @param array[] $shifts
+ * @param array[] $needed_angeltypes
+ * @param array[] $shift_entries
+ * @param ShiftsFilter $shiftsFilter
+ */
+ public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter)
+ {
+ $this->shiftsFilter = $shiftsFilter;
+ $this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
+ $this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
+ $this->lanes = $this->assignShiftsToLanes($shifts);
+ $this->needed_angeltypes = $needed_angeltypes;
+ $this->shift_entries = $shift_entries;
+ }
+
+ /**
+ * Assigns the shifts to different lanes per room if they collide
+ *
+ * @param array[] $shifts The shifts to assign
+ * @return array Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts
+ */
+ private function assignShiftsToLanes($shifts)
+ {
+ // array that assigns a room id to a list of lanes (per room)
+ $lanes = [];
+
+ foreach ($shifts as $shift) {
+ $room_id = $shift['RID'];
+ $header = Room_name_render([
+ 'RID' => $room_id,
+ 'Name' => $shift['room_name']
+ ]);
+ if (!isset($lanes[$room_id])) {
+ // initialize room with one lane
+ $lanes[$room_id] = [
+ new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot())
+ ];
+ }
+ // Try to add the shift to the existing lanes for this room
+ $shift_added = false;
+ foreach ($lanes[$room_id] as $lane) {
+ /** @var ShiftCalendarLane $lane */
+ if ($lane->shiftFits($shift)) {
+ $lane->addShift($shift);
+ $shift_added = true;
+ break;
+ }
+ }
+ // If all lanes for this room are busy, create a new lane and add shift to it
+ if ($shift_added == false) {
+ $newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
+ $newLane->addShift($shift);
+ $lanes[$room_id][] = $newLane;
+ }
}
- $lanes[$room_id][] = $newLane;
- }
+
+ return $lanes;
}
-
- return $lanes;
- }
- public function getFirstBlockStartTime() {
- return $this->firstBlockStartTime;
- }
+ /**
+ * @return int
+ */
+ public function getFirstBlockStartTime()
+ {
+ return $this->firstBlockStartTime;
+ }
- public function getLastBlockEndTime() {
- return $this->lastBlockEndTime;
- }
+ /**
+ * @return int
+ */
+ public function getLastBlockEndTime()
+ {
+ return $this->lastBlockEndTime;
+ }
- public function getBlocksPerSlot() {
- if ($this->blocksPerSlot == null) {
- $this->blocksPerSlot = $this->calcBlocksPerSlot();
+ /**
+ * @return float
+ */
+ public function getBlocksPerSlot()
+ {
+ if ($this->blocksPerSlot == null) {
+ $this->blocksPerSlot = $this->calcBlocksPerSlot();
+ }
+ return $this->blocksPerSlot;
+ }
+
+ /**
+ * Renders the whole calendar
+ *
+ * @return string the generated html
+ */
+ public function render()
+ {
+ if (count($this->lanes) == 0) {
+ return info(_('No shifts found.'), true);
+ }
+ return div('shift-calendar', [
+ $this->renderTimeLane(),
+ $this->renderShiftLanes()
+ ]) . $this->renderLegend();
}
- return $this->blocksPerSlot;
- }
-
- /**
- * Renders the whole calendar
- *
- * @return the generated html
- */
- public function render() {
- if (count($this->lanes) == 0) {
- return '';
+
+ /**
+ * Renders the lanes containing the shifts
+ *
+ * @return string
+ */
+ private function renderShiftLanes()
+ {
+ $html = '';
+ foreach ($this->lanes as $room_lanes) {
+ foreach ($room_lanes as $lane) {
+ $html .= $this->renderLane($lane);
+ }
+ }
+
+ return $html;
}
- return div('shift-calendar', [
- $this->renderTimeLane(),
- $this->renderShiftLanes()
- ]) . $this->renderLegend();
- }
-
- /**
- * Renders the lanes containing the shifts
- */
- private function renderShiftLanes() {
- $html = "";
- foreach ($this->lanes as $room_lanes) {
- foreach ($room_lanes as $lane) {
- $html .= $this->renderLane($lane);
- }
+
+ /**
+ * Renders a single lane
+ *
+ * @param ShiftCalendarLane $lane The lane to render
+ * @return string
+ */
+ private function renderLane(ShiftCalendarLane $lane)
+ {
+ global $user;
+
+ $shift_renderer = new ShiftCalendarShiftRenderer();
+ $html = '';
+ $rendered_until = $this->getFirstBlockStartTime();
+
+ foreach ($lane->getShifts() as $shift) {
+ while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) {
+ $html .= $this->renderTick($rendered_until);
+ $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
+ }
+
+ list ($shift_height, $shift_html) = $shift_renderer->render(
+ $shift,
+ $this->needed_angeltypes[$shift['SID']],
+ $this->shift_entries[$shift['SID']],
+ $user
+ );
+ $html .= $shift_html;
+ $rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
+ }
+
+ while ($rendered_until < $this->getLastBlockEndTime()) {
+ $html .= $this->renderTick($rendered_until);
+ $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
+ }
+
+ return div('lane', [
+ div('header', $lane->getHeader()),
+ $html
+ ]);
}
-
- return $html;
- }
-
- /**
- * Renders a single lane
- *
- * @param ShiftCalendarLane $lane
- * The lane to render
- */
- private function renderLane(ShiftCalendarLane $lane) {
- global $user;
-
- $shift_renderer = new ShiftCalendarShiftRenderer();
- $html = "";
- $rendered_until = $this->getFirstBlockStartTime();
-
- foreach ($lane->getShifts() as $shift) {
- while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) {
- $html .= $this->renderTick($rendered_until);
- $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
- }
-
- list($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']], $this->shift_entries[$shift['SID']], $user);
- $html .= $shift_html;
- $rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
+
+ /**
+ * Renders a tick/block for given time
+ *
+ * @param int $time unix timestamp
+ * @param boolean $label Should time labels be generated?
+ * @return string rendered tick html
+ */
+ private function renderTick($time, $label = false)
+ {
+ if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
+ if (!$label) {
+ return div('tick day');
+ }
+ return div('tick day', [
+ date('m-d<b\r />H:i', $time)
+ ]);
+ } elseif ($time % (60 * 60) == 0) {
+ if (!$label) {
+ return div('tick hour');
+ }
+ return div('tick hour', [
+ date('m-d<b\r />H:i', $time)
+ ]);
+ }
+ return div('tick');
}
-
- while ($rendered_until < $this->getLastBlockEndTime()) {
- $html .= $this->renderTick($rendered_until);
- $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
+
+ /**
+ * Renders the left time lane including hour/day ticks
+ *
+ * @return string
+ */
+ private function renderTimeLane()
+ {
+ $time_slot = [
+ div('header', [
+ _('Time')
+ ])
+ ];
+ for ($block = 0; $block < $this->getBlocksPerSlot(); $block++) {
+ $thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
+ $time_slot[] = $this->renderTick($thistime, true);
+ }
+ return div('lane time', $time_slot);
}
-
- return div('lane', [
- div('header', $lane->getHeader()),
- $html
- ]);
- }
-
- /**
- * Renders a tick/block for given time
- *
- * @param int $time
- * unix timestamp
- * @param boolean $label
- * Should time labels be generated?
- * @return rendered tick html
- */
- private function renderTick($time, $label = false) {
- if ($time % (24 * 60 * 60) == 23 * 60 * 60) {
- if (! $label) {
- return div('tick day');
- }
- return div('tick day', [
- date('m-d<b\r />H:i', $time)
- ]);
- } elseif ($time % (60 * 60) == 0) {
- if (! $label) {
- return div('tick hour');
- }
- return div('tick hour', [
- date('m-d<b\r />H:i', $time)
- ]);
+
+ /**
+ * @param array[] $shifts
+ * @return int
+ */
+ private function calcFirstBlockStartTime($shifts)
+ {
+ $start_time = $this->shiftsFilter->getEndTime();
+ foreach ($shifts as $shift) {
+ if ($shift['start'] < $start_time) {
+ $start_time = $shift['start'];
+ }
+ }
+ return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
}
- return div('tick');
- }
-
- /**
- * Renders the left time lane including hour/day ticks
- */
- private function renderTimeLane() {
- $time_slot = [
- div('header', [
- _("Time")
- ])
- ];
- for ($block = 0; $block < $this->getBlocksPerSlot(); $block ++) {
- $thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW);
- $time_slot[] = $this->renderTick($thistime, true);
+
+ /**
+ * @param array[] $shifts
+ * @return int
+ */
+ private function calcLastBlockEndTime($shifts)
+ {
+ $end_time = $this->shiftsFilter->getStartTime();
+ foreach ($shifts as $shift) {
+ if ($shift['end'] > $end_time) {
+ $end_time = $shift['end'];
+ }
+ }
+ return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
}
- return div('lane time', $time_slot);
- }
-
- private function calcFirstBlockStartTime($shifts) {
- $start_time = $this->shiftsFilter->getEndTime();
- foreach ($shifts as $shift) {
- if ($shift['start'] < $start_time) {
- $start_time = $shift['start'];
- }
+
+ /**
+ * @return int
+ */
+ private function calcBlocksPerSlot()
+ {
+ return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
}
- return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
- }
-
- private function calcLastBlockEndTime($shifts) {
- $end_time = $this->shiftsFilter->getStartTime();
- foreach ($shifts as $shift) {
- if ($shift['end'] > $end_time) {
- $end_time = $shift['end'];
- }
+
+ /**
+ * Renders a legend explaining the shift coloring
+ *
+ * @return string
+ */
+ private function renderLegend()
+ {
+ return div('legend', [
+ label(_('Your shift'), 'primary'),
+ label(_('Help needed'), 'danger'),
+ label(_('Other angeltype needed / collides with my shifts'), 'warning'),
+ label(_('Shift is full'), 'success'),
+ label(_('Shift running/ended'), 'default')
+ ]);
}
- return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
- }
-
- private function calcBlocksPerSlot() {
- return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
- }
-
- /**
- * Renders a legend explaining the shift coloring
- */
- private function renderLegend() {
- return div('legend', [
- label(_('Your shift'), 'primary'),
- label(_('Help needed'), 'danger'),
- label(_('Other angeltype needed / collides with my shifts'), 'warning'),
- label(_('Shift is full'), 'success'),
- label(_('Shift running/ended'), 'default')
- ]);
- }
}
-
-?> \ No newline at end of file
diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php
index fdfefcc2..3e59d61a 100644
--- a/includes/view/ShiftCalendarShiftRenderer.php
+++ b/includes/view/ShiftCalendarShiftRenderer.php
@@ -5,191 +5,247 @@ namespace Engelsystem;
/**
* Renders a single shift for the shift calendar
*/
-class ShiftCalendarShiftRenderer {
-
- /**
- * Renders a shift
- *
- * @param Shift $shift
- * The shift to render
- * @param User $user
- * The user who is viewing the shift calendar
- */
- public function render($shift, $needed_angeltypes, $shift_entries, $user) {
- $info_text = "";
- if ($shift['title'] != '') {
- $info_text = glyph('info-sign') . $shift['title'] . '<br>';
- }
- list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user);
-
- $class = $this->classForSignupState($shift_signup_state);
-
- $blocks = ceil(($shift["end"] - $shift["start"]) / ShiftCalendarRenderer::SECONDS_PER_ROW);
- $blocks = max(1, $blocks);
- return [
- $blocks,
- div('shift panel panel-' . $class . '" style="height: ' . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) . 'px"', [
- $this->renderShiftHead($shift),
- div('panel-body', [
- $info_text,
- Room_name_render([
- 'RID' => $shift['RID'],
- 'Name' => $shift['room_name']
- ])
- ]),
- $shifts_row,
- div('shift-spacer')
- ])
- ];
- }
-
- private function classForSignupState(ShiftSignupState $shiftSignupState) {
- switch ($shiftSignupState->getState()) {
- case ShiftSignupState::ADMIN:
- case ShiftSignupState::OCCUPIED:
- return 'success';
-
- case ShiftSignupState::SIGNED_UP:
- return 'primary';
-
- case ShiftSignupState::SHIFT_ENDED:
- return 'default';
-
- case ShiftSignupState::ANGELTYPE:
- case ShiftSignupState::COLLIDES:
- return 'warning';
-
- case ShiftSignupState::FREE:
- return 'danger';
- }
- }
-
- private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user) {
- global $privileges;
-
- $shift_entries_filtered = [];
- foreach ($needed_angeltypes as $needed_angeltype) {
- $shift_entries_filtered[$needed_angeltype['id']] = [];
+class ShiftCalendarShiftRenderer
+{
+ /**
+ * Renders a shift
+ *
+ * @param array $shift The shift to render
+ * @param array $needed_angeltypes
+ * @param array $shift_entries
+ * @param array $user The user who is viewing the shift calendar
+ * @return array
+ */
+ public function render($shift, $needed_angeltypes, $shift_entries, $user)
+ {
+ $info_text = '';
+ if ($shift['title'] != '') {
+ $info_text = glyph('info-sign') . $shift['title'] . '<br>';
+ }
+ list($shift_signup_state, $shifts_row) = $this->renderShiftNeededAngeltypes(
+ $shift,
+ $needed_angeltypes,
+ $shift_entries,
+ $user
+ );
+
+ $class = $this->classForSignupState($shift_signup_state);
+
+ $blocks = ceil(($shift['end'] - $shift['start']) / ShiftCalendarRenderer::SECONDS_PER_ROW);
+ $blocks = max(1, $blocks);
+ return [
+ $blocks,
+ div(
+ 'shift panel panel-' . $class . '" style="height: ' . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) . 'px"',
+ [
+ $this->renderShiftHead($shift),
+ div('panel-body', [
+ $info_text,
+ Room_name_render([
+ 'RID' => $shift['RID'],
+ 'Name' => $shift['room_name']
+ ])
+ ]),
+ $shifts_row,
+ div('shift-spacer')
+ ]
+ )
+ ];
}
- foreach ($shift_entries as $shift_entry) {
- $shift_entries_filtered[$shift_entry['TID']][] = $shift_entry;
+
+ /**
+ * @param ShiftSignupState $shiftSignupState
+ * @return string
+ */
+ private function classForSignupState(ShiftSignupState $shiftSignupState)
+ {
+ switch ($shiftSignupState->getState()) {
+ case ShiftSignupState::ADMIN:
+ case ShiftSignupState::OCCUPIED:
+ return 'success';
+
+ case ShiftSignupState::SIGNED_UP:
+ return 'primary';
+
+ case ShiftSignupState::SHIFT_ENDED:
+ return 'default';
+
+ case ShiftSignupState::ANGELTYPE:
+ case ShiftSignupState::COLLIDES:
+ return 'warning';
+
+ case ShiftSignupState::FREE:
+ return 'danger';
+ default:
+ return '';
+ }
}
-
- $html = "";
- $shift_signup_state = null;
- foreach ($needed_angeltypes as $angeltype) {
- if ($angeltype['count'] > 0 || count($shift_entries_filtered[$angeltype['id']]) > 0) {
- list($angeltype_signup_state, $angeltype_html) = $this->renderShiftNeededAngeltype($shift, $shift_entries_filtered[$angeltype['id']], $angeltype, $user);
+
+ /**
+ * @param array $shift
+ * @param array[] $needed_angeltypes
+ * @param array[] $shift_entries
+ * @param array $user
+ * @return array
+ */
+ private function renderShiftNeededAngeltypes($shift, $needed_angeltypes, $shift_entries, $user)
+ {
+ global $privileges;
+
+ $shift_entries_filtered = [];
+ foreach ($needed_angeltypes as $needed_angeltype) {
+ $shift_entries_filtered[$needed_angeltype['id']] = [];
+ }
+ foreach ($shift_entries as $shift_entry) {
+ $shift_entries_filtered[$shift_entry['TID']][] = $shift_entry;
+ }
+
+ $html = '';
+ /** @var ShiftSignupState $shift_signup_state */
+ $shift_signup_state = null;
+ foreach ($needed_angeltypes as $angeltype) {
+ if ($angeltype['count'] > 0 || count($shift_entries_filtered[$angeltype['id']]) > 0) {
+ list($angeltype_signup_state, $angeltype_html) = $this->renderShiftNeededAngeltype(
+ $shift,
+ $shift_entries_filtered[$angeltype['id']],
+ $angeltype,
+ $user
+ );
+ if ($shift_signup_state == null) {
+ $shift_signup_state = $angeltype_signup_state;
+ } else {
+ $shift_signup_state->combineWith($angeltype_signup_state);
+ }
+ $html .= $angeltype_html;
+ }
+ }
if ($shift_signup_state == null) {
- $shift_signup_state = $angeltype_signup_state;
- } else {
- $shift_signup_state->combineWith($angeltype_signup_state);
+ $shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
}
- $html .= $angeltype_html;
- }
- }
- if ($shift_signup_state == null) {
- $shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0);
- }
-
- if (in_array('user_shifts_admin', $privileges)) {
- $html .= '<li class="list-group-item">' . button(page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'], _("Add more angels"), 'btn-xs') . '</li>';
- }
- if ($html != '') {
- return [
- $shift_signup_state,
- '<ul class="list-group">' . $html . '</ul>'
- ];
- }
- return [
- $shift_signup_state,
- ""
- ];
- }
-
- /**
- * Renders a list entry containing the needed angels for an angeltype
- *
- * @param Shift $shift
- * The shift which is rendered
- * @param Angeltype $angeltype
- * The angeltype, containing informations about needed angeltypes and already signed up angels
- * @param User $user
- * The user who is viewing the shift calendar
- */
- private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user) {
- $entry_list = [];
- foreach ($shift_entries as $entry) {
- $style = $entry['freeloaded'] ? " text-decoration: line-through;" : '';
- $entry_list[] = "<span style=\"$style\">" . User_Nick_render($entry) . "</span>";
+
+ if (in_array('user_shifts_admin', $privileges)) {
+ $html .= '<li class="list-group-item">';
+ $html .= button(
+ page_link_to('user_shifts', ['shift_id' => $shift['SID']]),
+ glyph('plus') . _('Add more angels'),
+ 'btn-xs'
+ );
+ $html .= '</li>';
+ }
+ if ($html != '') {
+ return [
+ $shift_signup_state,
+ '<ul class="list-group">' . $html . '</ul>'
+ ];
+ }
+ return [
+ $shift_signup_state,
+ ''
+ ];
}
- $shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, null, $angeltype, $shift_entries);
- $inner_text = sprintf(ngettext("%d helper needed", "%d helpers needed", $shift_signup_state->getFreeEntries()), $shift_signup_state->getFreeEntries());
- switch ($shift_signup_state->getState()) {
- case ShiftSignupState::ADMIN:
- case ShiftSignupState::FREE:
- // When admin or free display a link + button for sign up
- $entry_list[] = '<a href="' . page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'] . '&amp;type_id=' . $angeltype['id'] . '">' . $inner_text . '</a> ' . button(page_link_to('user_shifts') . '&amp;shift_id=' . $shift['SID'] . '&amp;type_id=' . $angeltype['id'], _('Sign up'), 'btn-xs btn-primary');
- break;
-
- case ShiftSignupState::SHIFT_ENDED:
- // No link and add a text hint, when the shift ended
- $entry_list[] = $inner_text . ' (' . _('ended') . ')';
- break;
-
- case ShiftSignupState::ANGELTYPE:
- if ($angeltype['restricted'] == 1) {
- // User has to be confirmed on the angeltype first
- $entry_list[] = $inner_text . glyph('lock');
- } else {
- // Add link to join the angeltype first
- $entry_list[] = $inner_text . '<br />' . button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']), 'btn-xs');
+
+ /**
+ * Renders a list entry containing the needed angels for an angeltype
+ *
+ * @param array $shift The shift which is rendered
+ * @param array[] $shift_entries
+ * @param array[] $angeltype The angeltype, containing informations about needed angeltypes
+ * and already signed up angels
+ * @param array $user The user who is viewing the shift calendar
+ * @return array
+ */
+ private function renderShiftNeededAngeltype($shift, $shift_entries, $angeltype, $user)
+ {
+ $entry_list = [];
+ foreach ($shift_entries as $entry) {
+ $style = $entry['freeloaded'] ? ' text-decoration: line-through;' : '';
+ $entry_list[] = '<span style="' . $style . '">' . User_Nick_render($entry) . '</span>';
+ }
+ $shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, null, $angeltype, $shift_entries);
+ $inner_text = sprintf(
+ ngettext('%d helper needed', '%d helpers needed', $shift_signup_state->getFreeEntries()),
+ $shift_signup_state->getFreeEntries()
+ );
+
+ switch ($shift_signup_state->getState()) {
+ case ShiftSignupState::ADMIN:
+ case ShiftSignupState::FREE:
+ // When admin or free display a link + button for sign up
+ $entry_list[] = '<a href="'
+ . page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']])
+ . '">'
+ . $inner_text
+ . '</a> '
+ . button(
+ page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]),
+ _('Sign up'), 'btn-xs btn-primary'
+ );
+ break;
+
+ case ShiftSignupState::SHIFT_ENDED:
+ // No link and add a text hint, when the shift ended
+ $entry_list[] = $inner_text . ' (' . _('ended') . ')';
+ break;
+
+ case ShiftSignupState::ANGELTYPE:
+ if ($angeltype['restricted'] == 1) {
+ // User has to be confirmed on the angeltype first
+ $entry_list[] = $inner_text . glyph('lock');
+ } else {
+ // Add link to join the angeltype first
+ $entry_list[] = $inner_text . '<br />'
+ . button(
+ page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
+ sprintf(_('Become %s'), $angeltype['name']),
+ 'btn-xs'
+ );
+ }
+ break;
+
+ case ShiftSignupState::COLLIDES:
+ case ShiftSignupState::SIGNED_UP:
+ // Shift collides or user is already signed up: No signup allowed
+ $entry_list[] = $inner_text;
+ break;
+
+ case ShiftSignupState::OCCUPIED:
+ // Shift is full
+ break;
}
- break;
-
- case ShiftSignupState::COLLIDES:
- case ShiftSignupState::SIGNED_UP:
- // Shift collides or user is already signed up: No signup allowed
- $entry_list[] = $inner_text;
- break;
-
- case ShiftSignupState::OCCUPIED:
- // Shift is full
- break;
+
+ $shifts_row = '<li class="list-group-item">';
+ $shifts_row .= '<strong>' . AngelType_name_render($angeltype) . ':</strong> ';
+ $shifts_row .= join(', ', $entry_list);
+ $shifts_row .= '</li>';
+ return [
+ $shift_signup_state,
+ $shifts_row
+ ];
}
-
- $shifts_row = '<li class="list-group-item">';
- $shifts_row .= '<strong>' . AngelType_name_render($angeltype) . ':</strong> ';
- $shifts_row .= join(", ", $entry_list);
- $shifts_row .= '</li>';
- return [
- $shift_signup_state,
- $shifts_row
- ];
- }
-
- /**
- * Renders the shift header
- *
- * @param Shift $shift
- * The shift
- */
- private function renderShiftHead($shift) {
- global $privileges;
-
- $header_buttons = "";
- if (in_array('admin_shifts', $privileges)) {
- $header_buttons = '<div class="pull-right">' . table_buttons([
- button(page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'], glyph('edit'), 'btn-xs'),
- button(page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'], glyph('trash'), 'btn-xs')
- ]) . '</div>';
+
+ /**
+ * Renders the shift header
+ *
+ * @param array $shift The shift
+ * @return string
+ */
+ private function renderShiftHead($shift)
+ {
+ global $privileges;
+
+ $header_buttons = '';
+ if (in_array('admin_shifts', $privileges)) {
+ $header_buttons = '<div class="pull-right">' . table_buttons([
+ button(page_link_to('user_shifts', ['edit_shift' => $shift['SID']]), glyph('edit'), 'btn-xs'),
+ button(page_link_to('user_shifts', ['delete_shift' => $shift['SID']]), glyph('trash'), 'btn-xs')
+ ]) . '</div>';
+ }
+ $shift_heading = date('H:i', $shift['start']) . ' &dash; '
+ . date('H:i', $shift['end']) . ' &mdash; '
+ . $shift['name'];
+ return div('panel-heading', [
+ '<a href="' . shift_link($shift) . '">' . $shift_heading . '</a>',
+ $header_buttons
+ ]);
}
- $shift_heading = date('H:i', $shift['start']) . ' &dash; ' . date('H:i', $shift['end']) . ' &mdash; ' . $shift['name'];
- return div('panel-heading', [
- '<a href="' . shift_link($shift) . '">' . $shift_heading . '</a>',
- $header_buttons
- ]);
- }
}
-
-?> \ No newline at end of file
diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php
index 5bf10a91..2e638df6 100644
--- a/includes/view/ShiftEntry_view.php
+++ b/includes/view/ShiftEntry_view.php
@@ -2,36 +2,47 @@
/**
* Display form for adding/editing a shift entry.
+ *
* @param string $angel
* @param string $date
* @param string $location
* @param string $title
* @param string $type
* @param string $comment
- *
+ * @param bool $freeloaded
+ * @param string $freeload_comment
+ * @param bool $user_admin_shifts
* @return string
*/
-function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false) {
- $freeload_form = [];
- if ($user_admin_shifts) {
- $freeload_form = [
- form_checkbox('freeloaded', _("Freeloaded"), $freeloaded),
- form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment)
- ];
- }
- return page_with_title(_("Edit shift entry"), [
- msg(),
- form([
- form_info(_("Angel:"), $angel),
- form_info(_("Date, Duration:"), $date),
- form_info(_("Location:"), $location),
- form_info(_("Title:"), $title),
- form_info(_("Type:"), $type),
- form_textarea('comment', _("Comment (for your eyes only):"), $comment),
- join("", $freeload_form),
- form_submit('submit', _("Save"))
- ])
- ]);
+function ShiftEntry_edit_view(
+ $angel,
+ $date,
+ $location,
+ $title,
+ $type,
+ $comment,
+ $freeloaded,
+ $freeload_comment,
+ $user_admin_shifts = false
+) {
+ $freeload_form = [];
+ if ($user_admin_shifts) {
+ $freeload_form = [
+ form_checkbox('freeloaded', _('Freeloaded'), $freeloaded),
+ form_textarea('freeload_comment', _('Freeload comment (Only for shift coordination):'), $freeload_comment)
+ ];
+ }
+ return page_with_title(_('Edit shift entry'), [
+ msg(),
+ form([
+ form_info(_('Angel:'), $angel),
+ form_info(_('Date, Duration:'), $date),
+ form_info(_('Location:'), $location),
+ form_info(_('Title:'), $title),
+ form_info(_('Type:'), $type),
+ form_textarea('comment', _('Comment (for your eyes only):'), $comment),
+ join('', $freeload_form),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
}
-
-?> \ No newline at end of file
diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php
index 3e4cccc6..74e0d7c0 100644
--- a/includes/view/ShiftTypes_view.php
+++ b/includes/view/ShiftTypes_view.php
@@ -1,84 +1,145 @@
<?php
-function ShiftType_name_render($shifttype) {
- global $privileges;
- if (in_array('shifttypes', $privileges)) {
- return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
- }
- return $shifttype['name'];
+/**
+ * @param array $shifttype
+ * @return string
+ */
+function ShiftType_name_render($shifttype)
+{
+ global $privileges;
+ if (in_array('shifttypes', $privileges)) {
+ return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
+ }
+ return $shifttype['name'];
}
-function ShiftType_delete_view($shifttype) {
- return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
- info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
- buttons([
- button(page_link_to('shifttypes'), _("cancel"), 'cancel'),
- button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', _("delete"), 'ok')
- ])
- ]);
+/**
+ * @param array $shifttype
+ * @return string
+ */
+function ShiftType_delete_view($shifttype)
+{
+ return page_with_title(sprintf(_('Delete shifttype %s'), $shifttype['name']), [
+ info(sprintf(_('Do you want to delete shifttype %s?'), $shifttype['name']), true),
+ buttons([
+ button(page_link_to('shifttypes'), _('cancel'), 'cancel'),
+ button(
+ page_link_to(
+ 'shifttypes',
+ ['action' => 'delete', 'shifttype_id' => $shifttype['id'], 'confirmed' => 1]
+ ),
+ _('delete'),
+ 'ok btn-danger'
+ )
+ ])
+ ]);
}
-function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id) {
- $angeltypes_select = [
- '' => _('All')
- ];
- foreach ($angeltypes as $angeltype) {
- $angeltypes_select[$angeltype['id']] = $angeltype['name'];
- }
-
- return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
- msg(),
- buttons([
- button(page_link_to('shifttypes'), shifttypes_title(), 'back')
- ]),
- form([
- form_text('name', _('Name'), $name),
- form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id),
- form_textarea('description', _('Description'), $description),
- form_info('', _('Please use markdown for the description.')),
- form_submit('submit', _('Save'))
- ])
- ]);
-}
+/**
+ * @param string $name
+ * @param int $angeltype_id
+ * @param array[] $angeltypes
+ * @param string $description
+ * @param int|bool $shifttype_id
+ * @return string
+ */
+function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id)
+{
+ $angeltypes_select = [
+ '' => _('All')
+ ];
+ foreach ($angeltypes as $angeltype) {
+ $angeltypes_select[$angeltype['id']] = $angeltype['name'];
+ }
-function ShiftType_view($shifttype, $angeltype) {
- $parsedown = new Parsedown();
- $title = $shifttype['name'];
- if ($angeltype) {
- $title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
- }
- return page_with_title($title, [
- msg(),
- buttons([
- button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
- $angeltype ? button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], $angeltype['name']) : '',
- 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'])
- ]);
+ return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
+ msg(),
+ buttons([
+ button(page_link_to('shifttypes'), shifttypes_title(), 'back')
+ ]),
+ form([
+ form_text('name', _('Name'), $name),
+ form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id),
+ form_textarea('description', _('Description'), $description),
+ form_info('', _('Please use markdown for the description.')),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
}
-function ShiftTypes_list_view($shifttypes) {
- foreach ($shifttypes as &$shifttype) {
- $shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
- $shifttype['actions'] = table_buttons([
- button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'btn-xs'),
- button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'btn-xs')
+/**
+ * @param array $shifttype
+ * @param array $angeltype
+ * @return string
+ */
+function ShiftType_view($shifttype, $angeltype)
+{
+ $parsedown = new Parsedown();
+ $title = $shifttype['name'];
+ if ($angeltype) {
+ $title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
+ }
+ return page_with_title($title, [
+ msg(),
+ buttons([
+ button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
+ $angeltype ? button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ $angeltype['name']
+ ) : '',
+ 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'])
]);
- }
-
- return page_with_title(shifttypes_title(), [
- msg(),
- buttons([
- button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add')
- ]),
- table([
- 'name' => _('Name'),
- 'actions' => ''
- ], $shifttypes)
- ]);
}
-?> \ No newline at end of file
+/**
+ * @param array[] $shifttypes
+ * @return string
+ */
+function ShiftTypes_list_view($shifttypes)
+{
+ foreach ($shifttypes as &$shifttype) {
+ $shifttype['name'] = '<a href="'
+ . page_link_to('shifttypes', ['action' => 'view', 'shifttype_id' => $shifttype['id']])
+ . '">'
+ . $shifttype['name']
+ . '</a>';
+ $shifttype['actions'] = table_buttons([
+ button(
+ page_link_to(
+ 'shifttypes',
+ ['action' => 'edit', 'shifttype_id' => $shifttype['id']]
+ ),
+ _('edit'),
+ 'btn-xs'
+ ),
+ button(
+ page_link_to('shifttypes', ['action' => 'delete', 'shifttype_id' => $shifttype['id']]),
+ _('delete'),
+ 'btn-xs'
+ )
+ ]);
+ }
+
+ return page_with_title(shifttypes_title(), [
+ msg(),
+ buttons([
+ button(page_link_to('shifttypes', ['action' => 'edit']), _('New shifttype'), 'add')
+ ]),
+ table([
+ 'name' => _('Name'),
+ 'actions' => ''
+ ], $shifttypes)
+ ]);
+}
diff --git a/includes/view/ShiftsFilterRenderer.php b/includes/view/ShiftsFilterRenderer.php
index 301f31a2..27c6240a 100644
--- a/includes/view/ShiftsFilterRenderer.php
+++ b/includes/view/ShiftsFilterRenderer.php
@@ -2,68 +2,81 @@
namespace Engelsystem;
-class ShiftsFilterRenderer {
+class ShiftsFilterRenderer
+{
+ /**
+ * The shiftFilter to render.
+ *
+ * @var ShiftsFilter
+ */
+ private $shiftsFilter;
- /**
- * The shiftFilter to render.
- *
- * @var ShiftsFilter
- */
- private $shiftsFilter;
+ /**
+ * Should the filter display a day selection.
+ *
+ * @var boolean
+ */
+ private $daySelectionEnabled = false;
- /**
- * Should the filter display a day selection.
- *
- * @var boolean
- */
- private $daySelectionEnabled = false;
+ /**
+ * Days that can be selected.
+ * Format Y-m-d
+ *
+ * @var string[]
+ */
+ private $days = [];
- /**
- * Days that can be selected.
- * Format Y-m-d
- *
- * @var string[]
- */
- private $days = [];
-
- public function __construct(ShiftsFilter $shiftsFilter) {
- $this->shiftsFilter = $shiftsFilter;
- }
+ /**
+ * ShiftsFilterRenderer constructor.
+ *
+ * @param ShiftsFilter $shiftsFilter
+ */
+ public function __construct(ShiftsFilter $shiftsFilter)
+ {
+ $this->shiftsFilter = $shiftsFilter;
+ }
- /**
- * Renders the filter.
- *
- * @return Generated HTML
- */
- public function render($link_base) {
- $toolbar = [];
- if ($this->daySelectionEnabled && ! empty($this->days)) {
- $selected_day = date("Y-m-d", $this->shiftsFilter->getStartTime());
- $day_dropdown_items = [];
- foreach ($this->days as $day) {
- $day_dropdown_items[] = toolbar_item_link($link_base . '&shifts_filter_day=' . $day, '', $day);
- }
- $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
+ /**
+ * Renders the filter.
+ *
+ * @param string $page_link Link pointing to the actual page.
+ * @return string Generated HTML
+ */
+ public function render($page_link)
+ {
+ $toolbar = [];
+ if ($this->daySelectionEnabled && !empty($this->days)) {
+ $selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime());
+ $day_dropdown_items = [];
+ foreach ($this->days as $day) {
+ $link = $page_link . '&shifts_filter_day=' . $day;
+ $day_dropdown_items[] = toolbar_item_link($link, '', $day);
+ }
+ $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
+ }
+ return div('form-group', [
+ toolbar_pills($toolbar)
+ ]);
}
- return div('form-group', [
- toolbar_pills($toolbar)
- ]);
- }
- /**
- * Should the filter display a day selection.
- */
- public function enableDaySelection($days) {
- $this->daySelectionEnabled = true;
- $this->days = $days;
- }
+ /**
+ * Should the filter display a day selection.
+ *
+ * @param string[] $days
+ */
+ public function enableDaySelection($days)
+ {
+ $this->daySelectionEnabled = true;
+ $this->days = $days;
+ }
- /**
- * Should the filter display a day selection.
- */
- public function isDaySelectionEnabled() {
- return $this->daySelectionEnabled;
- }
+ /**
+ * Should the filter display a day selection.
+ *
+ * @return bool
+ */
+ public function isDaySelectionEnabled()
+ {
+ return $this->daySelectionEnabled;
+ }
}
-
-?> \ No newline at end of file
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 765a6f3b..bc905f39 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -1,163 +1,233 @@
<?php
+
use Engelsystem\ShiftSignupState;
-function Shift_editor_info_render($shift) {
- $info = [];
- if ($shift['created_by_user_id'] != null) {
- $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) {
- $info[] = sprintf(glyph('pencil') . _("edited at %s by %s"), date('Y-m-d H:i', $shift['edited_at_timestamp']), User_Nick_render(User($shift['edited_by_user_id'])));
- }
- return join('<br />', $info);
+/**
+ * @param array $shift
+ * @return string
+ */
+function Shift_editor_info_render($shift)
+{
+ $info = [];
+ if ($shift['created_by_user_id'] != null) {
+ $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) {
+ $info[] = sprintf(
+ glyph('pencil') . _('edited at %s by %s'),
+ date('Y-m-d H:i', $shift['edited_at_timestamp']),
+ User_Nick_render(User($shift['edited_by_user_id']))
+ );
+ }
+ return join('<br />', $info);
}
-function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) {
- global $user;
-
- if ($user_angeltype == null) {
- $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- }
-
- if ($angeltype['shift_signup_state']->isSignupAllowed()) {
- return button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up'));
- } elseif ($user_angeltype == null) {
- return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']));
- }
- return '';
+/**
+ * @param array $shift
+ * @param array $angeltype
+ * @param array $user_angeltype
+ * @return string
+ */
+function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
+{
+ global $user;
+
+ if ($user_angeltype == null) {
+ $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
+ }
+
+ if ($angeltype['shift_signup_state']->isSignupAllowed()) {
+ return button(
+ page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]),
+ _('Sign up')
+ );
+ } elseif ($user_angeltype == null) {
+ return button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ sprintf(_('Become %s'),
+ $angeltype['name'])
+ );
+ }
+ return '';
}
-function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state) {
- global $privileges;
-
- $shift_admin = in_array('admin_shifts', $privileges);
- $user_shift_admin = in_array('user_shifts_admin', $privileges);
- $admin_rooms = in_array('admin_rooms', $privileges);
- $admin_shifttypes = in_array('shifttypes', $privileges);
-
- $parsedown = new Parsedown();
-
- $angeltypes = [];
- foreach ($angeltypes_source as $angeltype) {
- $angeltypes[$angeltype['id']] = $angeltype;
- }
-
- $needed_angels = '';
- foreach ($shift['NeedAngels'] as $needed_angeltype) {
- $needed_angels .= Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin);
- }
-
- return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
- msg(),
- $shift_signup_state->getState() == ShiftSignupState::COLLIDES ? info(_('This shift collides with one of your shifts.'), true) : '',
- $shift_signup_state->getState() == ShiftSignupState::SIGNED_UP ? info(_('You are signed up for this shift.'), true) : '',
- ($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([
- $shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '',
- $shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '',
- $admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '',
- $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : ''
- ]) : '',
- div('row', [
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('Title') . '</h4>',
- '<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>'
- ]),
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('Start') . '</h4>',
- '<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
- glyph('calendar') . date(_('Y-m-d'), $shift['start']),
- '<br />',
- glyph('time') . date('H:i', $shift['start']),
- '</p>'
- ]),
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('End') . '</h4>',
- '<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
- glyph('calendar') . date(_('Y-m-d'), $shift['end']),
- '<br />',
- glyph('time') . date('H:i', $shift['end']),
- '</p>'
- ]),
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('Location') . '</h4>',
- '<p class="lead">' . Room_name_render($room) . '</p>'
- ])
- ]),
- div('row', [
- div('col-sm-6', [
- '<h2>' . _('Needed angels') . '</h2>',
- '<div class="list-group">' . $needed_angels . '</div>'
- ]),
- div('col-sm-6', [
- '<h2>' . _('Description') . '</h2>',
- $parsedown->parse($shifttype['description'])
- ])
- ]),
- $shift_admin ? Shift_editor_info_render($shift) : ''
- ]);
+/**
+ * @param array $shift
+ * @param array $shifttype
+ * @param array $room
+ * @param array[] $angeltypes_source
+ * @param ShiftSignupState $shift_signup_state
+ * @return string
+ */
+function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
+{
+ global $privileges;
+
+ $shift_admin = in_array('admin_shifts', $privileges);
+ $user_shift_admin = in_array('user_shifts_admin', $privileges);
+ $admin_rooms = in_array('admin_rooms', $privileges);
+ $admin_shifttypes = in_array('shifttypes', $privileges);
+
+ $parsedown = new Parsedown();
+
+ $angeltypes = [];
+ foreach ($angeltypes_source as $angeltype) {
+ $angeltypes[$angeltype['id']] = $angeltype;
+ }
+
+ $needed_angels = '';
+ foreach ($shift['NeedAngels'] as $needed_angeltype) {
+ $needed_angels .= Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin);
+ }
+
+ return page_with_title(
+ $shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
+ [
+ msg(),
+ $shift_signup_state->getState() == ShiftSignupState::COLLIDES
+ ? info(_('This shift collides with one of your shifts.'), true)
+ : '',
+ $shift_signup_state->getState() == ShiftSignupState::SIGNED_UP
+ ? info(_('You are signed up for this shift.'), true)
+ : '',
+ ($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([
+ $shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '',
+ $shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '',
+ $admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '',
+ $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : ''
+ ]) : '',
+ div('row', [
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('Title') . '</h4>',
+ '<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>'
+ ]),
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('Start') . '</h4>',
+ '<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
+ glyph('calendar') . date(_('Y-m-d'), $shift['start']),
+ '<br />',
+ glyph('time') . date('H:i', $shift['start']),
+ '</p>'
+ ]),
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('End') . '</h4>',
+ '<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
+ glyph('calendar') . date(_('Y-m-d'), $shift['end']),
+ '<br />',
+ glyph('time') . date('H:i', $shift['end']),
+ '</p>'
+ ]),
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('Location') . '</h4>',
+ '<p class="lead">' . Room_name_render($room) . '</p>'
+ ])
+ ]),
+ div('row', [
+ div('col-sm-6', [
+ '<h2>' . _('Needed angels') . '</h2>',
+ '<div class="list-group">' . $needed_angels . '</div>'
+ ]),
+ div('col-sm-6', [
+ '<h2>' . _('Description') . '</h2>',
+ $parsedown->parse($shifttype['description'])
+ ])
+ ]),
+ $shift_admin ? Shift_editor_info_render($shift) : ''
+ ]
+ );
}
-function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin) {
- global $user;
-
- $angeltype = $angeltypes[$needed_angeltype['TID']];
- $angeltype_supporter = User_is_AngelType_supporter($user, $angeltype);
-
- $needed_angels = '';
-
- $class = 'progress-bar-warning';
- if ($needed_angeltype['taken'] == 0) {
- $class = 'progress-bar-danger';
- }
- if ($needed_angeltype['taken'] >= $needed_angeltype['count']) {
- $class = 'progress-bar-success';
- }
- $needed_angels .= '<div class="list-group-item">';
-
- $needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltype) . '</div>';
-
- $needed_angels .= '<h3>' . AngelType_name_render($angeltype) . '</h3>';
- $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) {
- if ($shift_entry['TID'] == $needed_angeltype['TID']) {
- $angels[] = Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter);
+/**
+ * @param array $needed_angeltype
+ * @param array $angeltypes
+ * @param array[] $shift
+ * @param bool $user_shift_admin
+ * @return string
+ */
+function Shift_view_render_needed_angeltype($needed_angeltype, $angeltypes, $shift, $user_shift_admin)
+{
+ global $user;
+
+ $angeltype = $angeltypes[$needed_angeltype['TID']];
+ $angeltype_supporter = User_is_AngelType_supporter($user, $angeltype);
+
+ $needed_angels = '';
+
+ $class = 'progress-bar-warning';
+ if ($needed_angeltype['taken'] == 0) {
+ $class = 'progress-bar-danger';
}
- }
-
- $needed_angels .= join(', ', $angels);
- $needed_angels .= '</div>';
-
- return $needed_angels;
+ if ($needed_angeltype['taken'] >= $needed_angeltype['count']) {
+ $class = 'progress-bar-success';
+ }
+ $needed_angels .= '<div class="list-group-item">';
+
+ $needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltype) . '</div>';
+
+ $needed_angels .= '<h3>' . AngelType_name_render($angeltype) . '</h3>';
+ $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) {
+ if ($shift_entry['TID'] == $needed_angeltype['TID']) {
+ $angels[] = Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter);
+ }
+ }
+
+ $needed_angels .= join(', ', $angels);
+ $needed_angels .= '</div>';
+
+ return $needed_angels;
}
-function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter) {
- $entry = User_Nick_render(User($shift_entry['UID']));
- if ($shift_entry['freeloaded']) {
- $entry = '<strike>' . $entry . '</strike>';
- }
- if ($user_shift_admin || $angeltype_supporter) {
- $entry .= ' <div class="btn-group">';
- if ($user_shift_admin) {
- $entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs');
+/**
+ * @param array $shift_entry
+ * @param bool $user_shift_admin
+ * @param bool $angeltype_supporter
+ * @return string
+ */
+function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angeltype_supporter)
+{
+ $entry = User_Nick_render(User($shift_entry['UID']));
+ if ($shift_entry['freeloaded']) {
+ $entry = '<del>' . $entry . '</del>';
+ }
+ if ($user_shift_admin || $angeltype_supporter) {
+ $entry .= ' <div class="btn-group">';
+ if ($user_shift_admin) {
+ $entry .= button_glyph(
+ page_link_to('user_myshifts', ['edit' => $shift_entry['id'], 'id' => $shift_entry['UID']]),
+ 'pencil',
+ 'btn-xs'
+ );
+ }
+ $entry .= button_glyph(page_link_to('user_shifts', ['entry_id' => $shift_entry['id']]), 'trash', 'btn-xs');
+ $entry .= '</div>';
}
- $entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs');
- $entry .= '</div>';
- }
- return $entry;
+ return $entry;
}
/**
* Calc shift length in format 12:23h.
*
- * @param Shift $shift
+ * @param array $shift
+ * @return string
*/
-function shift_length($shift) {
- $length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ":";
- $length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, "0", STR_PAD_LEFT) . "h";
- return $length;
+function shift_length($shift)
+{
+ $length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ':';
+ $length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, '0', STR_PAD_LEFT) . 'h';
+ return $length;
}
-?>
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
index da4a2352..98f6c3e9 100644
--- a/includes/view/UserAngelTypes_view.php
+++ b/includes/view/UserAngelTypes_view.php
@@ -1,88 +1,205 @@
<?php
-function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter) {
- return page_with_title($supporter ? _("Add supporter rights") : _("Remove supporter rights"), [
- msg(),
- info(sprintf($supporter ? _("Do you really want to add supporter rights for %s to %s?") : _("Do you really want to remove supporter rights for %s from %s?"), $angeltype['name'], User_Nick_render($user)), true),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $user_angeltype['id'] . '&supporter=' . ($supporter ? '1' : '0') . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $user_angeltype
+ * @param array $user
+ * @param array $angeltype
+ * @param bool $supporter
+ * @return string
+ */
+function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporter)
+{
+ return page_with_title($supporter ? _('Add supporter rights') : _('Remove supporter rights'), [
+ msg(),
+ info(sprintf(
+ $supporter
+ ? _('Do you really want to add supporter rights for %s to %s?')
+ : _('Do you really want to remove supporter rights for %s from %s?'),
+ $angeltype['name'],
+ User_Nick_render($user)
+ ), true),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to('user_angeltypes', [
+ 'action' => 'update',
+ 'user_angeltype_id' => $user_angeltype['id'],
+ 'supporter' => ($supporter ? '1' : '0'),
+ 'confirmed' => 1,
+ ]),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-function UserAngelTypes_delete_all_view($angeltype) {
- return page_with_title(_("Deny all users"), [
- msg(),
- info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $angeltype
+ * @return string
+ */
+function UserAngelTypes_delete_all_view($angeltype)
+{
+ return page_with_title(_('Deny all users'), [
+ msg(),
+ info(sprintf(_('Do you really want to deny all users for %s?'), $angeltype['name']), true),
+ buttons([
+ button(
+ page_link_to(
+ 'angeltypes',
+ ['action' => 'view', 'angeltype_id' => $angeltype['id']]
+ ),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'delete_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]
+ ),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-function UserAngelTypes_confirm_all_view($angeltype) {
- return page_with_title(_("Confirm all users"), [
- msg(),
- info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $angeltype
+ * @return string
+ */
+function UserAngelTypes_confirm_all_view($angeltype)
+{
+ return page_with_title(_('Confirm all users'), [
+ msg(),
+ info(sprintf(_('Do you really want to confirm all users for %s?'), $angeltype['name']), true),
+ buttons([
+ button(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), _('cancel'),
+ 'cancel'),
+ button(
+ page_link_to('user_angeltypes',
+ ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) {
- return page_with_title(_("Confirm angeltype for user"), [
- msg(),
- info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $user_angeltype
+ * @param array $user
+ * @param array $angeltype
+ * @return string
+ */
+function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
+{
+ return page_with_title(_('Confirm angeltype for user'), [
+ msg(),
+ info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'confirm', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1]
+ ),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-function UserAngelType_delete_view($user_angeltype, $user, $angeltype) {
- return page_with_title(_("Remove angeltype"), [
- msg(),
- info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ])
- ]);
+/**
+ * @param array $user_angeltype
+ * @param array $user
+ * @param array $angeltype
+ * @return string
+ */
+function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
+{
+ return page_with_title(_('Remove angeltype'), [
+ msg(),
+ info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to('user_angeltypes',
+ ['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1]),
+ _('yes'),
+ 'ok'
+ )
+ ])
+ ]);
}
-function UserAngelType_add_view($angeltype, $users_source, $user_id) {
- $users = [];
- foreach ($users_source as $user_source) {
- $users[$user_source['UID']] = User_Nick_render($user_source);
- }
-
- return page_with_title(_("Add user to angeltype"), [
- msg(),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back')
- ]),
- form([
- form_info(_("Angeltype"), $angeltype['name']),
- form_select('user_id', _("User"), $users, $user_id),
- form_submit('submit', _("Add"))
- ])
- ]);
-}
+/**
+ * @param array $angeltype
+ * @param array[] $users_source
+ * @param int $user_id
+ * @return string
+ */
+function UserAngelType_add_view($angeltype, $users_source, $user_id)
+{
+ $users = [];
+ foreach ($users_source as $user_source) {
+ $users[$user_source['UID']] = User_Nick_render($user_source);
+ }
-function UserAngelType_join_view($user, $angeltype) {
- return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [
- msg(),
- info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
- buttons([
- button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
- button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed', _("save"), 'ok')
- ])
- ]);
+ return page_with_title(_('Add user to angeltype'), [
+ msg(),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('back'),
+ 'back'
+ )
+ ]),
+ form([
+ form_info(_('Angeltype'), $angeltype['name']),
+ form_select('user_id', _('User'), $users, $user_id),
+ form_submit('submit', _('Add'))
+ ])
+ ]);
}
-?> \ No newline at end of file
+/**
+ * @param array $user
+ * @param array $angeltype
+ * @return string
+ */
+function UserAngelType_join_view($user, $angeltype)
+{
+ return page_with_title(sprintf(_('Become a %s'), $angeltype['name']), [
+ msg(),
+ info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true),
+ buttons([
+ button(
+ page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
+ _('cancel'),
+ 'cancel'
+ ),
+ button(
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'add', 'angeltype_id' => $angeltype['id'], 'user_id' => $user['UID'], 'confirmed' => 1]
+ ),
+ _('save'),
+ 'ok'
+ )
+ ])
+ ]);
+}
diff --git a/includes/view/UserDriverLicenses_view.php b/includes/view/UserDriverLicenses_view.php
index 3c0eaf8d..5eacf456 100644
--- a/includes/view/UserDriverLicenses_view.php
+++ b/includes/view/UserDriverLicenses_view.php
@@ -3,45 +3,60 @@
/**
* Edit a user's driving license information.
*
- * @param User $user_source
- * The user
- * @param bool $wants_to_drive
- * true, if the user wants to drive
- * @param UserDriverLicense $user_driver_license
- * The user driver license
+ * @param array $user_source The user
+ * @param bool $wants_to_drive true, if the user wants to drive
+ * @param array $user_driver_license The user driver license
* @return string
*/
-function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license) {
- return page_with_title(sprintf(_("Edit %s driving license information"), User_Nick_render($user_source)), [
- buttons([
- button(user_link($user_source), _("Back to profile"), 'back')
- ]),
- msg(),
- form([
- form_info(_("Privacy"), _("Your driving license information is only visible for supporters and admins.")),
- form_checkbox('wants_to_drive', _("I am willing to drive a car for the event"), $wants_to_drive),
- div('panel panel-default', [
- div('panel-body', [
- form_checkbox('has_car', _("I have my own car with me and am willing to use it for the event (You'll get reimbursed for fuel)"), $user_driver_license['has_car']),
- heading(_("Driver license"), 3),
- form_checkbox('has_license_car', _("Car"), $user_driver_license['has_license_car']),
- form_checkbox('has_license_3_5t_transporter', _("Transporter 3,5t"), $user_driver_license['has_license_3_5t_transporter']),
- form_checkbox('has_license_7_5t_truck', _("Truck 7,5t"), $user_driver_license['has_license_7_5t_truck']),
- form_checkbox('has_license_12_5t_truck', _("Truck 12,5t"), $user_driver_license['has_license_12_5t_truck']),
- form_checkbox('has_license_forklift', _("Forklift"), $user_driver_license['has_license_forklift'])
- ])
- ], 'driving_license'),
- form_submit('submit', _("Save"))
- ]),
- '<script type="text/javascript">
+function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
+{
+ return page_with_title(sprintf(_('Edit %s driving license information'), User_Nick_render($user_source)), [
+ buttons([
+ button(user_link($user_source), _('Back to profile'), 'back')
+ ]),
+ msg(),
+ form([
+ form_info(_('Privacy'), _('Your driving license information is only visible for supporters and admins.')),
+ form_checkbox('wants_to_drive', _('I am willing to drive a car for the event'), $wants_to_drive),
+ div('panel panel-default', [
+ div('panel-body', [
+ form_checkbox(
+ 'has_car',
+ _('I have my own car with me and am willing to use it for the event (You\'ll get reimbursed for fuel)'),
+ $user_driver_license['has_car']
+ ),
+ heading(_('Driver license'), 3),
+ form_checkbox('has_license_car', _('Car'), $user_driver_license['has_license_car']),
+ form_checkbox(
+ 'has_license_3_5t_transporter',
+ _('Transporter 3,5t'),
+ $user_driver_license['has_license_3_5t_transporter']
+ ),
+ form_checkbox(
+ 'has_license_7_5t_truck',
+ _('Truck 7,5t'),
+ $user_driver_license['has_license_7_5t_truck']
+ ),
+ form_checkbox(
+ 'has_license_12_5t_truck',
+ _('Truck 12,5t'),
+ $user_driver_license['has_license_12_5t_truck']
+ ),
+ form_checkbox('has_license_forklift', _('Forklift'), $user_driver_license['has_license_forklift'])
+ ])
+ ], 'driving_license'),
+ form_submit('submit', _('Save'))
+ ]),
+ '<script type="text/javascript">
$(function() {
- if($("#wants_to_drive").is(":checked"))
+ var checkbox = $("#wants_to_drive");
+ if(checkbox.is(":checked"))
$("#driving_license").show();
else
$("#driving_license").hide();
-
- $("#wants_to_drive").click(
- function(e) {
+
+ checkbox.click(
+ function() {
if($("#wants_to_drive").is(":checked"))
$("#driving_license").show();
else
@@ -49,8 +64,6 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver
}
);
});
- </script>'
- ]);
+ </script>'
+ ]);
}
-
-?> \ No newline at end of file
diff --git a/includes/view/UserHintsRenderer.php b/includes/view/UserHintsRenderer.php
index cf4b1414..aac8ecfd 100644
--- a/includes/view/UserHintsRenderer.php
+++ b/includes/view/UserHintsRenderer.php
@@ -2,58 +2,65 @@
namespace Engelsystem;
-class UserHintsRenderer {
+class UserHintsRenderer
+{
+ /** @var string[] */
+ private $hints = [];
- private $hints = [];
+ private $important = false;
- private $important = false;
+ /**
+ * Render the added hints to a popover for the toolbar.
+ *
+ * @return string
+ */
+ public function render()
+ {
+ if (count($this->hints) > 0) {
+ $hint_class = $this->important ? 'danger' : 'info';
+ $glyphicon = $this->important ? 'warning-sign' : 'info-sign';
- /**
- * Render the added hints to a popover for the toolbar.
- */
- public function render() {
- if (count($this->hints) > 0) {
- $hint_class = $this->important ? 'danger' : 'info';
- $glyphicon = $this->important ? 'warning-sign' : 'info-sign';
-
- return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class);
+ return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class);
+ }
+
+ return '';
}
-
- return '';
- }
-
- /**
- * Add a hint to the list, if its not null and a not empty string.
- *
- * @param string $hint
- * The hint
- * @param boolean $important
- * Is the hint important?
- */
- public function addHint($hint, $important = false) {
- if ($hint != null && $hint != '') {
- if ($important) {
- $this->important = true;
- $this->hints[] = error($hint, true);
- } else {
- $this->hints[] = info($hint, true);
- }
+
+ /**
+ * Add a hint to the list, if its not null and a not empty string.
+ *
+ * @param string $hint The hint
+ * @param boolean $important Is the hint important?
+ */
+ public function addHint($hint, $important = false)
+ {
+ if ($hint != null && $hint != '') {
+ if ($important) {
+ $this->important = true;
+ $this->hints[] = error($hint, true);
+ } else {
+ $this->hints[] = info($hint, true);
+ }
+ }
}
- }
-
- /**
- * Get all hints.
- */
- public function getHints() {
- return $this->hints;
- }
-
- /**
- * Are there important hints? This leads to a more intensive icon.
- */
- public function isImportant() {
- return $this->important;
- }
-}
-?> \ No newline at end of file
+ /**
+ * Get all hints.
+ *
+ * @return string[]
+ */
+ public function getHints()
+ {
+ return $this->hints;
+ }
+
+ /**
+ * Are there important hints? This leads to a more intensive icon.
+ *
+ * @return bool
+ */
+ public function isImportant()
+ {
+ return $this->important;
+ }
+}
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 65cb36b3..cb2af7c0 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -1,494 +1,727 @@
<?php
/**
- * Available T-Shirt sizes
- */
-$tshirt_sizes = [
- '' => _("Please select..."),
- 'S' => "S",
- 'M' => "M",
- 'L' => "L",
- 'XL' => "XL",
- '2XL' => "2XL",
- '3XL' => "3XL",
- '4XL' => "4XL",
- '5XL' => "5XL",
- 'S-G' => "S Girl",
- 'M-G' => "M Girl",
- 'L-G' => "L Girl",
- 'XL-G' => "XL Girl"
-];
-
-/**
* Renders user settings page
*
- * @param User $user_source
- * The user
- * @param array<String> $locales
- * Available languages
- * @param array<String> $themes
- * Available themes
+ * @param array $user_source The user
+ * @param array $locales Available languages
+ * @param array $themes Available themes
+ * @param int $buildup_start_date Unix timestamp
+ * @param int $teardown_end_date Unix timestamp
+ * @param bool $enable_tshirt_size
+ * @param array $tshirt_sizes
+ * @return string
*/
-function User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes) {
- return page_with_title(settings_title(), [
- msg(),
- div('row', [
- div('col-md-6', [
- form([
- form_info('', _("Here you can change your user details.")),
- form_info(entry_required() . ' = ' . _("Entry required!")),
- form_text('nick', _("Nick"), $user_source['Nick'], true),
- form_text('lastname', _("Last name"), $user_source['Name']),
- form_text('prename', _("First name"), $user_source['Vorname']),
- form_date('planned_arrival_date', _("Planned date of arrival") . ' ' . entry_required(), $user_source['planned_arrival_date'], $buildup_start_date, $teardown_end_date),
- form_date('planned_departure_date', _("Planned date of departure"), $user_source['planned_departure_date'], $buildup_start_date, $teardown_end_date),
- form_text('age', _("Age"), $user_source['Alter']),
- form_text('tel', _("Phone"), $user_source['Telefon']),
- form_text('dect', _("DECT"), $user_source['DECT']),
- form_text('mobile', _("Mobile"), $user_source['Handy']),
- form_text('mail', _("E-Mail") . ' ' . entry_required(), $user_source['email']),
- form_checkbox('email_shiftinfo', _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), $user_source['email_shiftinfo']),
- form_checkbox('email_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $user_source['email_by_human_allowed']),
- form_text('jabber', _("Jabber"), $user_source['jabber']),
- form_text('hometown', _("Hometown"), $user_source['Hometown']),
- $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $user_source['Size']) : '',
- form_info('', _('Please visit the angeltypes page to manage your angeltypes.')),
- form_submit('submit', _("Save"))
- ])
- ]),
- div('col-md-6', [
- form([
- form_info(_("Here you can change your password.")),
- form_password('password', _("Old password:")),
- form_password('new_password', _("New password:")),
- form_password('new_password2', _("Password confirmation:")),
- form_submit('submit_password', _("Save"))
- ]),
- form([
- form_info(_("Here you can choose your color settings:")),
- form_select('theme', _("Color settings:"), $themes, $user_source['color']),
- form_submit('submit_theme', _("Save"))
- ]),
- form([
- form_info(_("Here you can choose your language:")),
- form_select('language', _("Language:"), $locales, $user_source['Sprache']),
- form_submit('submit_language', _("Save"))
- ])
- ])
- ])
- ]);
+function User_settings_view(
+ $user_source,
+ $locales,
+ $themes,
+ $buildup_start_date,
+ $teardown_end_date,
+ $enable_tshirt_size,
+ $tshirt_sizes
+) {
+ return page_with_title(settings_title(), [
+ msg(),
+ div('row', [
+ div('col-md-6', [
+ form([
+ form_info('', _('Here you can change your user details.')),
+ form_info(entry_required() . ' = ' . _('Entry required!')),
+ form_text('nick', _('Nick'), $user_source['Nick'], true),
+ form_text('lastname', _('Last name'), $user_source['Name']),
+ form_text('prename', _('First name'), $user_source['Vorname']),
+ form_date(
+ 'planned_arrival_date',
+ _('Planned date of arrival') . ' ' . entry_required(),
+ $user_source['planned_arrival_date'],
+ $buildup_start_date,
+ $teardown_end_date
+ ),
+ form_date(
+ 'planned_departure_date',
+ _('Planned date of departure'),
+ $user_source['planned_departure_date'],
+ $buildup_start_date,
+ $teardown_end_date
+ ),
+ form_text('age', _('Age'), $user_source['Alter']),
+ form_text('tel', _('Phone'), $user_source['Telefon']),
+ form_text('dect', _('DECT'), $user_source['DECT']),
+ form_text('mobile', _('Mobile'), $user_source['Handy']),
+ form_text('mail', _('E-Mail') . ' ' . entry_required(), $user_source['email']),
+ form_checkbox(
+ 'email_shiftinfo',
+ _('The engelsystem is allowed to send me an email (e.g. when my shifts change)'),
+ $user_source['email_shiftinfo']
+ ),
+ form_checkbox(
+ 'email_by_human_allowed',
+ _('Humans are allowed to send me an email (e.g. for ticket vouchers)'),
+ $user_source['email_by_human_allowed']
+ ),
+ form_text('jabber', _('Jabber'), $user_source['jabber']),
+ form_text('hometown', _('Hometown'), $user_source['Hometown']),
+ $enable_tshirt_size ? form_select(
+ 'tshirt_size',
+ _('Shirt size'),
+ $tshirt_sizes,
+ $user_source['Size']
+ ) : '',
+ form_info('', _('Please visit the angeltypes page to manage your angeltypes.')),
+ form_submit('submit', _('Save'))
+ ])
+ ]),
+ div('col-md-6', [
+ form([
+ form_info(_('Here you can change your password.')),
+ form_password('password', _('Old password:')),
+ form_password('new_password', _('New password:')),
+ form_password('new_password2', _('Password confirmation:')),
+ form_submit('submit_password', _('Save'))
+ ]),
+ form([
+ form_info(_('Here you can choose your color settings:')),
+ form_select('theme', _('Color settings:'), $themes, $user_source['color']),
+ form_submit('submit_theme', _('Save'))
+ ]),
+ form([
+ form_info(_('Here you can choose your language:')),
+ form_select('language', _('Language:'), $locales, $user_source['Sprache']),
+ form_submit('submit_language', _('Save'))
+ ])
+ ])
+ ])
+ ]);
}
/**
* Displays the welcome message to the user and shows a login form.
+ *
+ * @param string $event_welcome_message
+ * @return string
*/
-function User_registration_success_view($event_welcome_message) {
- $parsedown = new Parsedown();
- $event_welcome_message = $parsedown->text($event_welcome_message);
- return page_with_title(_("Registration successful"), [
- msg(),
- div('row', [
- div('col-md-4', [
- $event_welcome_message
- ]),
- div('col-md-4', [
- '<h2>' . _("Login") . '</h2>',
- form([
- form_text('nick', _("Nick"), ""),
- form_password('password', _("Password")),
- form_submit('submit', _("Login")),
- buttons([
- button(page_link_to('user_password_recovery'), _("I forgot my password"))
- ]),
- info(_("Please note: You have to activate cookies!"), true)
- ], page_link_to('login'))
- ]),
- div('col-md-4', [
- '<h2>' . _("What can I do?") . '</h2>',
- '<p>' . _("Please read about the jobs you can do to help us.") . '</p>',
- buttons([
- button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description") . ' &raquo;')
- ])
- ])
- ])
- ]);
+function User_registration_success_view($event_welcome_message)
+{
+ $parsedown = new Parsedown();
+ $event_welcome_message = $parsedown->text($event_welcome_message);
+ return page_with_title(_('Registration successful'), [
+ msg(),
+ div('row', [
+ div('col-md-4', [
+ $event_welcome_message
+ ]),
+ div('col-md-4', [
+ '<h2>' . _('Login') . '</h2>',
+ form([
+ form_text('nick', _('Nick'), ''),
+ form_password('password', _('Password')),
+ form_submit('submit', _('Login')),
+ buttons([
+ button(page_link_to('user_password_recovery'), _('I forgot my password'))
+ ]),
+ info(_('Please note: You have to activate cookies!'), true)
+ ], page_link_to('login'))
+ ]),
+ div('col-md-4', [
+ '<h2>' . _('What can I do?') . '</h2>',
+ '<p>' . _('Please read about the jobs you can do to help us.') . '</p>',
+ buttons([
+ button(page_link_to('angeltypes', ['action' => 'about']), _('Teams/Job description') . ' &raquo;')
+ ])
+ ])
+ ])
+ ]);
}
/**
* Gui for deleting user with password field.
+ *
+ * @param array $user
+ * @return string
*/
-function User_delete_view($user) {
- return page_with_title(sprintf(_("Delete %s"), User_Nick_render($user)), [
- msg(),
- buttons([
- button(user_edit_link($user), glyph('chevron-left') . _("back"))
- ]),
- error(_("Do you really want to delete the user including all his shifts and every other piece of his data?"), true),
- form([
- form_password('password', _("Your password")),
- form_submit('submit', _("Delete"))
- ])
- ]);
+function User_delete_view($user)
+{
+ return page_with_title(sprintf(_('Delete %s'), User_Nick_render($user)), [
+ msg(),
+ buttons([
+ button(user_edit_link($user), glyph('chevron-left') . _('back'))
+ ]),
+ error(
+ _('Do you really want to delete the user including all his shifts and every other piece of his data?'),
+ true
+ ),
+ form([
+ form_password('password', _('Your password')),
+ form_submit('submit', _('Delete'))
+ ])
+ ]);
}
/**
* View for editing the number of given vouchers
+ *
+ * @param array $user
+ * @return string
*/
-function User_edit_vouchers_view($user) {
- return page_with_title(sprintf(_("%s's vouchers"), User_Nick_render($user)), [
- msg(),
- buttons([
- button(user_link($user), glyph('chevron-left') . _("back"))
- ]),
- info(sprintf(_("Angel should receive at least %d vouchers."), User_get_eligable_voucher_count($user)), true),
- form([
- form_spinner('vouchers', _("Number of vouchers given out"), $user['got_voucher']),
- form_submit('submit', _("Save"))
- ], page_link_to('users') . '&action=edit_vouchers&user_id=' . $user['UID'])
- ]);
+function User_edit_vouchers_view($user)
+{
+ return page_with_title(sprintf(_('%s\'s vouchers'), User_Nick_render($user)), [
+ msg(),
+ buttons([
+ button(user_link($user), glyph('chevron-left') . _('back'))
+ ]),
+ info(sprintf(_('Angel should receive at least %d vouchers.'), User_get_eligable_voucher_count($user)), true),
+ form(
+ [
+ form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']),
+ form_submit('submit', _('Save'))
+ ],
+ page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user['UID']])
+ )
+ ]);
}
-function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) {
- foreach ($users as &$user) {
- $user['Nick'] = User_Nick_render($user);
- $user['Gekommen'] = glyph_bool($user['Gekommen']);
- $user['got_voucher'] = $user['got_voucher'];
- $user['Aktiv'] = glyph_bool($user['Aktiv']);
- $user['force_active'] = glyph_bool($user['force_active']);
- $user['Tshirt'] = glyph_bool($user['Tshirt']);
- $user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']);
- $user['actions'] = table_buttons([
- button_glyph(page_link_to('admin_user') . '&id=' . $user['UID'], 'edit', 'btn-xs')
+/**
+ * @param array[] $users
+ * @param string $order_by
+ * @param int $arrived_count
+ * @param int $active_count
+ * @param int $force_active_count
+ * @param int $freeloads_count
+ * @param int $tshirts_count
+ * @param int $voucher_count
+ * @return string
+ */
+function Users_view(
+ $users,
+ $order_by,
+ $arrived_count,
+ $active_count,
+ $force_active_count,
+ $freeloads_count,
+ $tshirts_count,
+ $voucher_count
+) {
+ foreach ($users as &$user) {
+ $user['Nick'] = User_Nick_render($user);
+ $user['Gekommen'] = glyph_bool($user['Gekommen']);
+ $user['Aktiv'] = glyph_bool($user['Aktiv']);
+ $user['force_active'] = glyph_bool($user['force_active']);
+ $user['Tshirt'] = glyph_bool($user['Tshirt']);
+ $user['lastLogIn'] = date(_('m/d/Y h:i a'), $user['lastLogIn']);
+ $user['actions'] = table_buttons([
+ button_glyph(page_link_to('admin_user', ['id' => $user['UID']]), 'edit', 'btn-xs')
+ ]);
+ }
+ $users[] = [
+ 'Nick' => '<strong>' . _('Sum') . '</strong>',
+ 'Gekommen' => $arrived_count,
+ 'got_voucher' => $voucher_count,
+ 'Aktiv' => $active_count,
+ 'force_active' => $force_active_count,
+ 'freeloads' => $freeloads_count,
+ 'Tshirt' => $tshirts_count,
+ 'actions' => '<strong>' . count($users) . '</strong>'
+ ];
+
+ return page_with_title(_('All users'), [
+ msg(),
+ buttons([
+ button(page_link_to('register'), glyph('plus') . _('New user'))
+ ]),
+ table([
+ 'Nick' => Users_table_header_link('Nick', _('Nick'), $order_by),
+ 'Vorname' => Users_table_header_link('Vorname', _('Prename'), $order_by),
+ 'Name' => Users_table_header_link('Name', _('Name'), $order_by),
+ 'DECT' => Users_table_header_link('DECT', _('DECT'), $order_by),
+ 'Gekommen' => Users_table_header_link('Gekommen', _('Arrived'), $order_by),
+ 'got_voucher' => Users_table_header_link('got_voucher', _('Voucher'), $order_by),
+ 'freeloads' => _('Freeloads'),
+ 'Aktiv' => Users_table_header_link('Aktiv', _('Active'), $order_by),
+ 'force_active' => Users_table_header_link('force_active', _('Forced'), $order_by),
+ 'Tshirt' => Users_table_header_link('Tshirt', _('T-Shirt'), $order_by),
+ 'Size' => Users_table_header_link('Size', _('Size'), $order_by),
+ 'lastLogIn' => Users_table_header_link('lastLogIn', _('Last login'), $order_by),
+ 'actions' => ''
+ ], $users)
]);
- }
- $users[] = [
- 'Nick' => '<strong>' . _('Sum') . '</strong>',
- 'Gekommen' => $arrived_count,
- 'got_voucher' => $voucher_count,
- 'Aktiv' => $active_count,
- 'force_active' => $force_active_count,
- 'freeloads' => $freeloads_count,
- 'Tshirt' => $tshirts_count,
- 'actions' => '<strong>' . count($users) . '</strong>'
- ];
-
- return page_with_title(_("All users"), [
- msg(),
- buttons([
- button(page_link_to('register'), glyph('plus') . _("New user"))
- ]),
- table([
- 'Nick' => Users_table_header_link('Nick', _("Nick"), $order_by),
- 'Vorname' => Users_table_header_link('Vorname', _("Prename"), $order_by),
- 'Name' => Users_table_header_link('Name', _("Name"), $order_by),
- 'DECT' => Users_table_header_link('DECT', _("DECT"), $order_by),
- 'Gekommen' => Users_table_header_link('Gekommen', _("Arrived"), $order_by),
- 'got_voucher' => Users_table_header_link('got_voucher', _("Voucher"), $order_by),
- 'freeloads' => _('Freeloads'),
- 'Aktiv' => Users_table_header_link('Aktiv', _("Active"), $order_by),
- 'force_active' => Users_table_header_link('force_active', _("Forced"), $order_by),
- 'Tshirt' => Users_table_header_link('Tshirt', _("T-Shirt"), $order_by),
- 'Size' => Users_table_header_link('Size', _("Size"), $order_by),
- 'lastLogIn' => Users_table_header_link('lastLogIn', _("Last login"), $order_by),
- 'actions' => ''
- ], $users)
- ]);
}
-function Users_table_header_link($column, $label, $order_by) {
- return '<a href="' . page_link_to('users') . '&OrderBy=' . $column . '">' . $label . ($order_by == $column ? ' <span class="caret"></span>' : '') . '</a>';
+/**
+ * @param string $column
+ * @param string $label
+ * @param string $order_by
+ * @return string
+ */
+function Users_table_header_link($column, $label, $order_by)
+{
+ return '<a href="'
+ . page_link_to('users', ['OrderBy' => $column])
+ . '">'
+ . $label . ($order_by == $column ? ' <span class="caret"></span>' : '')
+ . '</a>';
}
-function User_shift_state_render($user) {
- $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
- if ($upcoming_shifts === false) {
- return false;
- }
-
- if (count($upcoming_shifts) == 0) {
- return '<span class="text-success">' . _("Free") . '</span>';
- }
-
- if ($upcoming_shifts[0]['start'] > time()) {
- if ($upcoming_shifts[0]['start'] - time() > 3600) {
- return '<span class="text-success moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
+/**
+ * @param array $user
+ * @return string|false
+ */
+function User_shift_state_render($user)
+{
+ $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
+
+ if (empty($upcoming_shifts)) {
+ return '<span class="text-success">' . _('Free') . '</span>';
}
- return '<span class="text-warning moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
- }
- $halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2;
-
- if (time() < $halfway) {
- return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Shift starts %c") . '</span>';
- }
- return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>';
+
+ $nextShift = array_shift($upcoming_shifts);
+
+ if ($nextShift['start'] > time()) {
+ if ($nextShift['start'] - time() > 3600) {
+ return '<span class="text-success moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Next shift %c') . '</span>';
+ }
+ return '<span class="text-warning moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Next shift %c') . '</span>';
+ }
+ $halfway = ($nextShift['start'] + $nextShift['end']) / 2;
+
+ if (time() < $halfway) {
+ return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Shift starts %c') . '</span>';
+ }
+ return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['end'] . '">' . _('Shift ends %c') . '</span>';
}
-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>';
+/**
+ * @param array $needed_angel_type
+ * @return string
+ */
+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 = '<del>' . $member . '</del>';
+ }
+
+ $shift_entries[] = $member;
}
-
- $shift_entries[] = $member;
- }
- $shift_info .= join(", ", $shift_entries);
-
- return $shift_info;
+ $shift_info .= join(', ', $shift_entries);
+
+ return $shift_info;
}
/**
* Helper that renders a shift line for user view
+ *
+ * @param array $shift
+ * @param array $user_source
+ * @param bool $its_me
+ * @return array
*/
-function User_view_myshift($shift, $user_source, $its_me) {
- global $LETZTES_AUSTRAGEN, $privileges;
-
- $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>';
+function User_view_myshift($shift, $user_source, $its_me)
+{
+ global $privileges;
+
+ $shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
+ if ($shift['title']) {
+ $shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
}
- }
-
- $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;
+ 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() + config('last_unsubscribe') * 3600)
+ || in_array('user_shifts_admin', $privileges)
+ ) {
+ $parameters = [
+ 'cancel' => $shift['id'],
+ 'id' => $user_source['UID'],
+ ];
+ if ($its_me) {
+ $parameters['id'] = '';
+ }
+ $myshift['actions'][] = button(
+ page_link_to('user_myshifts', $parameters),
+ glyph('trash') . _('sign off'),
+ 'btn-xs'
+ );
+ }
+ $myshift['actions'] = table_buttons($myshift['actions']);
+
+ return $myshift;
}
/**
* Helper that prepares the shift table for user view
+ *
+ * @param array[] $shifts
+ * @param array $user_source
+ * @param bool $its_me
+ * @return array
*/
-function User_view_myshifts($shifts, $user_source, $its_me) {
- $myshifts_table = [];
- $timesum = 0;
- foreach ($shifts as $shift) {
- $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']);
+function User_view_myshifts($shifts, $user_source, $its_me)
+{
+ $myshifts_table = [];
+ $timesum = 0;
+ foreach ($shifts as $shift) {
+ $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']);
+ }
}
- }
-
- if (count($myshifts_table) > 0) {
- $myshifts_table[] = [
- 'date' => '<b>' . _("Sum:") . '</b>',
- 'time' => "<b>" . round($timesum / 3600, 1) . " h</b>",
- 'room' => "",
- 'shift_info' => "",
- 'comment' => "",
- 'actions' => ""
- ];
- }
- return $myshifts_table;
+
+ if (count($myshifts_table) > 0) {
+ $myshifts_table[] = [
+ 'date' => '<b>' . _('Sum:') . '</b>',
+ 'time' => '<b>' . round($timesum / 3600, 1) . ' h</b>',
+ 'room' => '',
+ 'shift_info' => '',
+ 'comment' => '',
+ 'actions' => ''
+ ];
+ }
+ return $myshifts_table;
}
/**
* Renders view for a single user
+ *
+ * @param array $user_source
+ * @param bool $admin_user_privilege
+ * @param bool $freeloader
+ * @param array[] $user_angeltypes
+ * @param array[] $user_groups
+ * @param array[] $shifts
+ * @param bool $its_me
+ * @return string
*/
-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(),
- div('row space-top', [
- div('col-md-12', [
- buttons([
- $admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '',
- $admin_user_privilege ? button(user_driver_license_edit_link($user_source), glyph("road") . _("driving license")) : '',
- ($admin_user_privilege && ! $user_source['Gekommen']) ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '',
- $admin_user_privilege ? button(page_link_to('users') . '&action=edit_vouchers&user_id=' . $user_source['UID'], glyph('cutlery') . _('Edit vouchers')) : '',
- $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _("Settings")) : '',
- $its_me ? button(page_link_to('ical') . '&key=' . $user_source['api_key'], glyph('calendar') . _("iCal Export")) : '',
- $its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '',
- $its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : ''
- ])
- ])
- ]),
- div('row', [
- div('col-md-3', [
- '<h1>',
- '<span class="glyphicon glyphicon-phone"></span>',
- $user_source['DECT'],
- '</h1>'
- ]),
- div('col-md-3', [
- '<h4>' . _("User state") . '</h4>',
- ($admin_user_privilege && $freeloader) ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />' : '',
- $user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '',
- $admin_user_privilege || $its_me ? ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . sprintf(_("Arrived at %s"), date('Y-m-d', $user_source['arrival_date'])) . '</span>' : '<span class="text-danger">' . sprintf(_("Not arrived (Planned: %s)"), date('Y-m-d', $user_source['planned_arrival_date'])) . '</span>') : ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'),
- $admin_user_privilege ? ($user_source['got_voucher'] > 0 ? '<br /><span class="text-success">' . glyph('cutlery') . sprintf(ngettext("Got %s voucher", "Got %s vouchers", $user_source['got_voucher']), $user_source['got_voucher']) . '</span><br />' : '<br /><span class="text-danger">' . _("Got no vouchers") . '</span><br />') : '',
- ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '',
- ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : ''
- ]),
- div('col-md-3', [
- '<h4>' . _("Angeltypes") . '</h4>',
- User_angeltypes_render($user_angeltypes)
- ]),
- div('col-md-3', [
- '<h4>' . _("Rights") . '</h4>',
- User_groups_render($user_groups)
- ])
- ]),
- ($its_me || $admin_user_privilege) ? '<h2>' . _("Shifts") . '</h2>' : '',
- ($its_me || $admin_user_privilege) ? table([
- 'date' => _("Day"),
- 'time' => _("Time"),
- 'room' => _("Location"),
- 'shift_info' => _("Name &amp; workmates"),
- 'comment' => _("Comment"),
- 'actions' => _("Action")
- ], $myshifts_table) : '',
- $its_me ? info(glyph('info-sign') . _("Your night shifts between 2 and 8 am count twice."), true) : '',
- $its_me && count($shifts) == 0 ? error(sprintf(_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : ''
- ]);
+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(),
+ div('row space-top', [
+ div('col-md-12', [
+ buttons([
+ $admin_user_privilege ? button(
+ page_link_to('admin_user', ['id' => $user_source['UID']]),
+ glyph('edit') . _('edit')
+ ) : '',
+ $admin_user_privilege ? button(
+ user_driver_license_edit_link($user_source),
+ glyph('road') . _('driving license')
+ ) : '',
+ ($admin_user_privilege && !$user_source['Gekommen']) ? button(
+ page_link_to('admin_arrive', ['arrived' => $user_source['UID']]),
+ _('arrived')
+ ) : '',
+ $admin_user_privilege ? button(
+ page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]),
+ glyph('cutlery') . _('Edit vouchers')
+ ) : '',
+ $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _('Settings')) : '',
+ $its_me ? button(
+ page_link_to('ical', ['key' => $user_source['api_key']]),
+ glyph('calendar') . _('iCal Export')
+ ) : '',
+ $its_me ? button(
+ page_link_to('shifts_json_export', ['key' => $user_source['api_key']]),
+ glyph('export') . _('JSON Export')
+ ) : '',
+ $its_me ? button(
+ page_link_to('user_myshifts', ['reset' => 1]),
+ glyph('repeat') . _('Reset API key')
+ ) : ''
+ ])
+ ])
+ ]),
+ div('row', [
+ div('col-md-3', [
+ '<h1>',
+ '<span class="glyphicon glyphicon-phone"></span>',
+ $user_source['DECT'],
+ '</h1>'
+ ]),
+ div('col-md-3', [
+ '<h4>' . _('User state') . '</h4>',
+ ($admin_user_privilege && $freeloader)
+ ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _('Freeloader') . '</span><br />'
+ : '',
+ $user_source['Gekommen']
+ ? User_shift_state_render($user_source) . '<br />'
+ : '',
+ $admin_user_privilege || $its_me
+ ? (
+ $user_source['Gekommen']
+ ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> '
+ . sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date']))
+ . '</span>'
+ : '<span class="text-danger">'
+ . sprintf(_('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date']))
+ . '</span>'
+ )
+ : (
+ $user_source['Gekommen']
+ ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _('Arrived') . '</span>'
+ : '<span class="text-danger">' . _('Not arrived') . '</span>'),
+ $admin_user_privilege
+ ? (
+ $user_source['got_voucher'] > 0
+ ? '<br /><span class="text-success">'
+ . glyph('cutlery')
+ . sprintf(
+ ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']),
+ $user_source['got_voucher']
+ )
+ . '</span><br />'
+ : '<br /><span class="text-danger">' . _('Got no vouchers') . '</span><br />')
+ : '',
+ ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _('Active') . '</span>' : '',
+ ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _('T-Shirt') . '</span>' : ''
+ ]),
+ div('col-md-3', [
+ '<h4>' . _('Angeltypes') . '</h4>',
+ User_angeltypes_render($user_angeltypes)
+ ]),
+ div('col-md-3', [
+ '<h4>' . _('Rights') . '</h4>',
+ User_groups_render($user_groups)
+ ])
+ ]),
+ ($its_me || $admin_user_privilege) ? '<h2>' . _('Shifts') . '</h2>' : '',
+ ($its_me || $admin_user_privilege) ? table([
+ 'date' => _('Day'),
+ 'time' => _('Time'),
+ 'room' => _('Location'),
+ 'shift_info' => _('Name &amp; workmates'),
+ 'comment' => _('Comment'),
+ 'actions' => _('Action')
+ ], $myshifts_table) : '',
+ $its_me ? info(glyph('info-sign') . _('Your night shifts between 2 and 8 am count twice.'), true) : '',
+ $its_me && count($shifts) == 0
+ ? error(sprintf(
+ _('Go to the <a href="%s">shifts table</a> to sign yourself up for some shifts.'),
+ page_link_to('user_shifts')
+ ), true)
+ : ''
+ ]
+ );
}
/**
* View for password recovery step 1: E-Mail
+ *
+ * @return string
*/
-function User_password_recovery_view() {
- return page_with_title(user_password_recovery_title(), [
- msg(),
- _("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."),
- form([
- form_text('email', _("E-Mail"), ""),
- form_submit('submit', _("Recover"))
- ])
- ]);
+function User_password_recovery_view()
+{
+ return page_with_title(user_password_recovery_title(), [
+ msg(),
+ _('We will send you an e-mail with a password recovery link. Please use the email address you used for registration.'),
+ form([
+ form_text('email', _('E-Mail'), ''),
+ form_submit('submit', _('Recover'))
+ ])
+ ]);
}
/**
* View for password recovery step 2: New password
+ *
+ * @return string
*/
-function User_password_set_view() {
- return page_with_title(user_password_recovery_title(), [
- msg(),
- _("Please enter a new password."),
- form([
- form_password('password', _("Password")),
- form_password('password2', _("Confirm password")),
- form_submit('submit', _("Save"))
- ])
- ]);
+function User_password_set_view()
+{
+ return page_with_title(user_password_recovery_title(), [
+ msg(),
+ _('Please enter a new password.'),
+ form([
+ form_password('password', _('Password')),
+ form_password('password2', _('Confirm password')),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
}
-function User_angeltypes_render($user_angeltypes) {
- $output = [];
- foreach ($user_angeltypes as $angeltype) {
- $class = "";
- if ($angeltype['restricted'] == 1) {
- if ($angeltype['confirm_user_id'] != null) {
+/**
+ * @param array[] $user_angeltypes
+ * @return string
+ */
+function User_angeltypes_render($user_angeltypes)
+{
+ $output = [];
+ foreach ($user_angeltypes as $angeltype) {
$class = 'text-success';
- } else {
- $class = 'text-warning';
- }
- } else {
- $class = 'text-success';
+ if ($angeltype['restricted'] == 1 && $angeltype['confirm_user_id'] == null) {
+ $class = 'text-warning';
+ }
+ $output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">'
+ . ($angeltype['supporter'] ? glyph('education') : '') . $angeltype['name']
+ . '</a>';
}
- $output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">' . ($angeltype['supporter'] ? glyph('education') : '') . $angeltype['name'] . '</a>';
- }
- return join('<br />', $output);
+ return join('<br />', $output);
}
-function User_groups_render($user_groups) {
- $output = [];
- foreach ($user_groups as $group) {
- $output[] = substr($group['Name'], 2);
- }
- return join('<br />', $output);
+/**
+ * @param array[] $user_groups
+ * @return string
+ */
+function User_groups_render($user_groups)
+{
+ $output = [];
+ foreach ($user_groups as $group) {
+ $output[] = substr($group['Name'], 2);
+ }
+ return join('<br />', $output);
}
/**
* Render a user nickname.
*
- * @param User $user_source
+ * @param array $user_source
* @return string
*/
-function User_Nick_render($user_source) {
- return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="' . page_link_to('users') . '&amp;action=view&amp;user_id=' . $user_source['UID'] . '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
+function User_Nick_render($user_source)
+{
+ return render_profile_link(
+ '<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>',
+ $user_source['UID'],
+ ($user_source['Gekommen'] ? '' : 'text-muted')
+ );
}
-function render_user_departure_date_hint() {
- global $user;
-
- if (! isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
- return _("Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.");
- }
-
- return null;
+/**
+ * @param string $text
+ * @param int $user_id
+ * @param string $class
+ * @return string
+ */
+function render_profile_link($text, $user_id = null, $class = '')
+{
+ $profile_link = page_link_to('user-settings');
+ if (!is_null($user_id)) {
+ $profile_link = page_link_to('users', ['action' => 'view', 'user_id' => $user_id]);
+ }
+
+ return sprintf(
+ '<a class="%s" href="%s">%s</a>',
+ $class,
+ $profile_link,
+ $text
+ );
}
-function render_user_freeloader_hint() {
- global $user, $max_freeloadable_shifts;
-
- if (User_is_freeloader($user)) {
- return sprintf(_("You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."), $max_freeloadable_shifts);
- }
-
- return null;
+/**
+ * @return string|null
+ */
+function render_user_departure_date_hint()
+{
+ global $user;
+
+ if (!isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
+ $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');
+ }
+
+ return null;
}
-// Hinweis für Engel, die noch nicht angekommen sind
-function render_user_arrived_hint() {
- global $user;
-
- if ($user['Gekommen'] == 0) {
- 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.");
- }
-
- return null;
+/**
+ * @return string|null
+ */
+function render_user_freeloader_hint()
+{
+ global $user;
+
+ if (User_is_freeloader($user)) {
+ return sprintf(
+ _('You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again.'),
+ config('max_freeloadable_shifts')
+ );
+ }
+
+ return null;
}
-function render_user_tshirt_hint() {
- global $enable_tshirt_size, $user;
-
- if ($enable_tshirt_size && $user['Size'] == "") {
- return _("You need to specify a tshirt size in your settings!");
- }
-
- return null;
+/**
+ * Hinweis für Engel, die noch nicht angekommen sind
+ *
+ * @return string|null
+ */
+function render_user_arrived_hint()
+{
+ global $user;
+
+ if ($user['Gekommen'] == 0) {
+ 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.');
+ }
+
+ return null;
}
-function render_user_dect_hint() {
- global $user;
-
- if ($user['DECT'] == "") {
- return _("You need to specify a DECT phone number in your settings! If you don't have a DECT phone, just enter \"-\".");
- }
-
- return null;
+/**
+ * @return string|null
+ */
+function render_user_tshirt_hint()
+{
+ global $user;
+
+ if (config('enable_tshirt_size') && $user['Size'] == '') {
+ $text = _('You need to specify a tshirt size in your settings!');
+ return render_profile_link($text, null, 'alert-link');
+ }
+
+ return null;
}
-?>
+/**
+ * @return string|null
+ */
+function render_user_dect_hint()
+{
+ global $user;
+
+ if ($user['DECT'] == '') {
+ $text = _('You need to specify a DECT phone number in your settings! If you don\'t have a DECT phone, just enter \'-\'.');
+ return render_profile_link($text, null, 'alert-link');
+ }
+
+ return null;
+}
diff --git a/locale/de_DE.UTF-8/LC_MESSAGES/default.mo b/locale/de_DE.UTF-8/LC_MESSAGES/default.mo
index 9d15f46a..bfe3aa42 100644
--- a/locale/de_DE.UTF-8/LC_MESSAGES/default.mo
+++ b/locale/de_DE.UTF-8/LC_MESSAGES/default.mo
Binary files differ
diff --git a/locale/de_DE.UTF-8/LC_MESSAGES/default.po b/locale/de_DE.UTF-8/LC_MESSAGES/default.po
index 28e9d534..c8319882 100644
--- a/locale/de_DE.UTF-8/LC_MESSAGES/default.po
+++ b/locale/de_DE.UTF-8/LC_MESSAGES/default.po
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: Engelsystem 2.0\n"
-"POT-Creation-Date: 2016-12-23 16:23+0100\n"
-"PO-Revision-Date: 2016-12-23 16:24+0100\n"
+"POT-Creation-Date: 2017-11-24 11:59+0100\n"
+"PO-Revision-Date: 2017-11-24 12:00+0100\n"
"Last-Translator: msquare <msquare@notrademark.de>\n"
"Language-Team: \n"
"Language: de_DE\n"
@@ -17,149 +17,146 @@ msgstr ""
"X-Poedit-SearchPath-0: /Users/msquare/workspace/projects/engelsystem\n"
"X-Poedit-SearchPath-1: .\n"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:7
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:177
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:62
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:86
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:356
+#: /Users/msquare/workspace/projects/engelsystem/config/config.default.php:111
+msgid "Please select..."
+msgstr "Bitte auswählen..."
+
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:12
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:228
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:77
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:130
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:520
msgid "Angeltypes"
msgstr "Engeltypen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:53
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:377
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:265
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:326
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:110
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:66
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:503
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:486
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:586
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:130
msgid "Teams/Job description"
msgstr "Team-/Aufgabenbeschreibung"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:72
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:88
#, php-format
msgid "Angeltype %s deleted."
msgstr "Engeltyp %s gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:77
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:41
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:93
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:50
#, php-format
msgid "Delete angeltype %s"
msgstr "Lösche Engeltyp %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:116
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:136
msgid "Please check the name. Maybe it already exists."
msgstr "Bitte überprüfe den Namen. Vielleicht ist er bereits vergeben."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:141
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:60
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:165
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:75
#, php-format
msgid "Edit %s"
msgstr "%s bearbeiten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:162
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:252
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:197
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:329
#, php-format
msgid "Team %s"
msgstr "Team %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:181
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:274
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:279
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:353
msgid "view"
msgstr "ansehen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:185
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:71
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:23
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:16
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:107
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:55
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:67
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:56
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:277
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:328
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:287
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:97
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:43
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:28
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:163
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:92
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:124
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:98
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:358
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:445
msgid "edit"
msgstr "bearbeiten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:186
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:178
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:42
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:56
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:17
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:120
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:45
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:110
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:5
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:12
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:16
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:56
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:68
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:57
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:292
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:239
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:58
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:76
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:174
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:59
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:170
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:15
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:26
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:31
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:97
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:129
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:99
msgid "delete"
msgstr "löschen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:191
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:103
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:288
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:303
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:156
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:522
msgid "leave"
msgstr "verlassen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:193
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:94
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:290
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:309
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:140
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:528
msgid "join"
msgstr "mitmachen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:220
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:29
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:35
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:65
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:71
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:119
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:170
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:235
-msgid "Angeltype doesn't exist."
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/angeltypes_controller.php:346
+msgid "Angeltype doesn't exist . "
msgstr "Engeltyp existiert nicht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:8
msgid "Event config"
msgstr "Event Einstellungen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:48
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:57
msgid "Please enter buildup start date."
msgstr "Bitte gib das Aufbau Start Datum an."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:52
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:61
msgid "Please enter event start date."
msgstr "Bitte gib das Event Start Datum an."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:56
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:65
msgid "Please enter event end date."
msgstr "Bitte gib das Event Ende Datum an."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:60
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:69
msgid "Please enter teardown end date."
msgstr "Bitte gib das Abbau Ende Datum an."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:66
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:75
msgid "The buildup start date has to be before the event start date."
msgstr "Das Aufbau Start Datum muss vor dem Event Start Datum liegen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:71
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:80
msgid "The event start date has to be before the event end date."
msgstr "Das Event Start Datum muss vor dem Event End Datum liegen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:76
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:85
msgid "The event end date has to be before the teardown end date."
msgstr "Das Event Ende Datum muss vor dem Abbau Ende Datum liegen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:81
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:90
msgid "The buildup start date has to be before the teardown end date."
msgstr "Das Aufbau Start Datum muss vor dem Abbau Ende Datum liegen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:92
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:77
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/event_config_controller.php:113
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:93
msgid "Settings saved."
msgstr "Einstellungen gespeichert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:55
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:96
msgid ""
"You are not allowed to sign up for this shift. Maybe shift is full or "
"already running."
@@ -167,153 +164,153 @@ msgstr ""
"Du darfst Dich nicht für diese Schicht eintragen. Vielleicht ist die Schicht "
"voll oder sie läuft bereits."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:102
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:168
msgid "You are subscribed. Thank you!"
msgstr "Du bist eingetragen. Danke!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:102
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:168
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:10
msgid "My shifts"
msgstr "Meine Schichten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:111
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:348
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:187
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:485
msgid "Freeloader"
msgstr "Schwänzer"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:162
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:284
msgid "Shift entry deleted."
msgstr "Schicht-Eintrag gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:164
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shift_entries_controller.php:286
msgid "Entry not found."
msgstr "Eintrag nicht gefunden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:63
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:94
msgid "Please select a room."
msgstr "Bitte einen Raum auswählen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:70
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:101
msgid "Please select a shifttype."
msgstr "Bitte einen Schichttyp wählen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:77
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:108
msgid "Please enter a valid starting time for the shifts."
msgstr "Bitte gib eine korrekte Startzeit für die Schichten ein."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:84
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:115
msgid "Please enter a valid ending time for the shifts."
msgstr "Bitte gib eine korrekte Endzeit für die Schichten ein."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:89
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:120
msgid "The ending time has to be after the starting time."
msgstr "Die Endzeit muss nach der Startzeit liegen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:97
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:133
#, php-format
msgid "Please check your input for needed angels of type %s."
msgstr "Bitte prüfe deine Eingabe für benötigte Engel des Typs %s."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:120
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:161
msgid "Shift updated."
msgstr "Schicht aktualisiert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:135
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:179
msgid "This page is much more comfortable with javascript."
msgstr "Diese Seite ist mit JavaScript viel komfortabler."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:137
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:97
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:319
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:181
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:118
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:371
msgid "Shifttype"
msgstr "Schichttyp"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:138
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:157
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:166
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:175
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:320
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:63
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:182
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:189
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:198
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:207
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:372
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:105
msgid "Title"
msgstr "Titel"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:139
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:183
msgid "Room:"
msgstr "Raum:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:140
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:184
msgid "Start:"
msgstr "Start:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:141
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:185
msgid "End:"
msgstr "Ende:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:142
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:270
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:334
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:89
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:186
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:297
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:395
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:131
msgid "Needed angels"
msgstr "Benötigte Engel"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:144
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:54
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:35
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:40
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:157
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:272
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:44
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:107
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:164
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:76
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:122
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:32
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:32
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:39
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:34
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:56
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:65
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:70
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:75
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:146
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:402
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:188
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:96
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:40
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:54
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:207
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:299
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:76
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:168
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:257
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:111
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:150
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:47
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:45
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:65
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:48
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:72
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:81
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:86
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:91
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:178
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:578
msgid "Save"
msgstr "Speichern"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:172
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:226
msgid "Shift deleted."
msgstr "Schicht gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:177
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:232
#, php-format
msgid "Do you want to delete the shift %s from %s to %s?"
msgstr "Möchtest Du die Schicht %s von %s bis %s löschen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:195
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifts_controller.php:261
msgid "Shift could not be found."
msgstr "Schicht konnte nicht gefunden werden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:31
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:34
#, php-format
msgid "Shifttype %s deleted."
msgstr "Schichttyp %s gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:36
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:12
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:39
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:22
#, php-format
msgid "Delete shifttype %s"
msgstr "Lösche Schichttyp %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:58
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:62
msgid "Shifttype not found."
msgstr "Schichttyp nicht gefunden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:74
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:71
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:78
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:90
msgid "Please enter a name."
msgstr "Gib bitte einen Namen an."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:94
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:96
msgid "Updated shifttype."
msgstr "Schichttyp geändert."
@@ -321,151 +318,161 @@ msgstr "Schichttyp geändert."
msgid "Created shifttype."
msgstr "Schichttyp erstellt."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:155
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/shifttypes_controller.php:160
msgid "Shifttypes"
msgstr "Schichttypen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:19
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:26
#, php-format
msgid "There is %d unconfirmed angeltype."
msgid_plural "There are %d unconfirmed angeltypes."
msgstr[0] "Es gibt %d nicht freigeschalteten Engeltypen!"
msgstr[1] "Es gibt %d nicht freigeschaltete Engeltypen!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:19
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:28
msgid "Angel types which need approvals:"
msgstr "Engeltypen die bestätigt werden müssen:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:40
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:43
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:49
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:83
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:89
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:141
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:201
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:268
+msgid "Angeltype doesn't exist."
+msgstr "Engeltyp existiert nicht."
+
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:54
msgid "You are not allowed to delete all users for this angeltype."
msgstr "Du darfst nicht alle Benutzer von diesem Engeltyp entfernen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:48
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:62
#, php-format
msgid "Denied all users for angeltype %s."
msgstr "Alle Benutzer mit Engeltyp %s abgelehnt."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:53
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:15
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:67
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:47
msgid "Deny all users"
msgstr "Alle Benutzer ablehnen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:77
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:107
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:113
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:158
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:164
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:216
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:229
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:95
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:129
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:135
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:189
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:195
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:249
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:262
msgid "User angeltype doesn't exist."
msgstr "Benutzer-Engeltype existiert nicht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:82
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:100
msgid "You are not allowed to confirm all users for this angeltype."
msgstr "Du darfst nicht alle Benutzer für diesen Engeltyp freischalten."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:90
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:108
#, php-format
msgid "Confirmed all users for angeltype %s."
msgstr "Alle Benutzer für Engeltyp %s freigeschaltet."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:95
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:26
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:113
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:77
msgid "Confirm all users"
msgstr "Alle Benutzer bestätigen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:124
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:146
msgid "You are not allowed to confirm this users angeltype."
msgstr "Du darfst diesen Benutzer nicht für diesen Engeltyp freischalten."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:130
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:176
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:241
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:309
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:152
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:207
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:274
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:407
msgid "User doesn't exist."
msgstr "Benutzer existiert nicht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:141
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:165
#, php-format
msgid "%s confirmed for angeltype %s."
msgstr "%s für Engeltyp %s freigeschaltet."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:146
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:37
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:173
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:101
msgid "Confirm angeltype for user"
msgstr "Engeltyp für Benutzer bestätigen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:181
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:212
msgid "You are not allowed to delete this users angeltype."
msgstr "Du darfst diesen Benutzer nicht von diesem Engeltyp entfernen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:191
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:219
#, php-format
msgid "User %s removed from %s."
msgstr "Benutzer %s von %s entfernt."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:199
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:48
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:227
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:130
msgid "Remove angeltype"
msgstr "Engeltyp löschen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:211
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:244
msgid "You are not allowed to set supporter rights."
msgstr "Du darfst keine Supporterrechte bearbeiten."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:223
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:256
msgid "No supporter update given."
msgstr "Kein Update für Supporterrechte gegeben."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:248
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:282
#, php-format
msgid "Added supporter rights for %s to %s."
msgstr "%s hat %s als Supporter bekommen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:248
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:282
#, php-format
msgid "Removed supporter rights for %s from %s."
msgstr "%s hat jetzt nicht mehr %s als Supporter."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:256
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:156
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:293
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:250
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:12
msgid "Add supporter rights"
msgstr "Supporterrechte geben"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:256
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:147
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:293
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:233
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:12
msgid "Remove supporter rights"
msgstr "Supporterrechte entfernen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:289
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:331
#, php-format
msgid "User %s added to %s."
msgstr "Benutzer %s zu %s hinzugefügt."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:299
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:64
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:348
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:162
msgid "Add user to angeltype"
msgstr "Benutzer zu Engeltyp hinzufügen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:312
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:365
#, php-format
msgid "You are already a %s."
msgstr "Du bist bereits %s."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:319
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:372
#, php-format
msgid "You joined %s."
msgstr "Du bist %s beigetreten."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:332
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:78
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_angeltypes_controller.php:389
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:186
#, php-format
msgid "Become a %s"
msgstr "Werde ein %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:19
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:24
#, php-format
msgid ""
"You joined an angeltype which requires a driving license. Please edit your "
@@ -474,128 +481,128 @@ msgstr ""
"Du bist einem Engeltypen beigetreten, der Führerschein-Infos benötigt. Bitte "
"trage Deine Führerschein-Infos hier ein: %s."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:19
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:25
msgid "driving license information"
msgstr "Führerschein-Infos"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:113
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:131
msgid "Your driver license information has been saved."
msgstr "Deine Führerschein-Infos wurden gespeichert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:116
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:134
msgid "Please select at least one driving license."
msgstr "Bitte wähle mindestens einen Führerschein-Typen aus."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:121
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:139
msgid "Your driver license information has been removed."
msgstr "Deine Führerschein-Infos wurden gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:127
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:15
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/user_driver_licenses_controller.php:145
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:13
#, php-format
msgid "Edit %s driving license information"
msgstr "Bearbeite die Führerschein-Infos von %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:50
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:61
msgid "You cannot delete yourself."
msgstr "Du kannst Dich nicht selber löschen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:59
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:315
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:75
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:439
msgid "Your password is incorrect. Please try it again."
msgstr "Dein Passwort stimmt nicht. Bitte probiere es nochmal."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:69
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:82
msgid "User deleted."
msgstr "Engel gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:77
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:121
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:90
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:145
#, php-format
msgid "Delete %s"
msgstr "%s löschen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:118
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:160
msgid "Please enter a valid number of vouchers."
msgstr "Bitte gib eine korrekte Anzahl von Vouchern ein."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:129
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:168
msgid "Saved the number of vouchers."
msgstr "Anzahl der Voucher gespeichert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:137
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:138
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:177
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:169
#, php-format
msgid "%s's vouchers"
msgstr "Voucher von %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:149
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:194
msgid "User not found."
msgstr "Benutzer nicht gefunden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:203
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:175
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:267
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:228
msgid "All users"
msgstr "Alle Benutzer"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:214
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:291
msgid "Token is not correct."
msgstr "Der Token ist nicht in Ordnung."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:224
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:102
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:96
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:304
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:142
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:116
msgid "Your passwords don't match."
msgstr "Deine Passwörter stimmen nicht überein."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:228
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:94
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:308
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:114
msgid "Your password is to short (please use at least 6 characters)."
msgstr "Dein Passwort ist zu kurz (Bitte mindestens 6 Zeichen nutzen)."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:233
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:98
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:313
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:119
msgid "Password saved."
msgstr "Passwort gespeichert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:254
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:258
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:67
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:21
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:338
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:342
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:107
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:31
msgid "E-mail address is not correct."
msgstr "Die E-Mail Adresse ist nicht in Ordnung."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:262
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:71
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:25
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:346
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:111
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:35
msgid "Please enter your e-mail."
msgstr "Bitte gib Deine E-Mail-Adresse ein."
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:267
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:292
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:353
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:389
msgid "Password recovery"
msgstr "Passwort wiederherstellen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:267
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:355
#, php-format
msgid "Please visit %s to recover your password."
msgstr "Bitte besuche %s, um Dein Passwort zurückzusetzen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:268
+#: /Users/msquare/workspace/projects/engelsystem/includes/controller/users_controller.php:359
msgid "We sent an email containing your password recovery link."
msgstr ""
"Wir haben eine eMail mit einem Link zum Passwort-zurücksetzen geschickt."
-#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:12
+#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:20
#, php-format
msgid "Hi %s,"
msgstr "Hallo %s,"
-#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:12
+#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:21
msgid "here is a message for you from the engelsystem:"
msgstr "hier ist eine Nachricht aus dem Engelsystem für Dich:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:12
+#: /Users/msquare/workspace/projects/engelsystem/includes/helper/email_helper.php:23
msgid ""
"This email is autogenerated and has not to be signed. You got this email "
"because you are registered in the engelsystem."
@@ -604,72 +611,72 @@ msgstr ""
"werden. Du hast diese E-Mail bekommen, weil Du im Engelsystem registriert "
"bist."
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:10
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:15
msgid "A Shift you are registered on has changed:"
msgstr "Eine deiner Schichten hat sich geändert:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:14
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:19
#, php-format
msgid "* Shift type changed from %s to %s"
msgstr "* Schichttyp von %s in %s geändert"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:19
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:24
#, php-format
msgid "* Shift title changed from %s to %s"
msgstr "* Schicht Titel von %s nach %s geändert"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:24
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:30
#, php-format
msgid "* Shift Start changed from %s to %s"
msgstr "* Schicht Beginn von %s nach %s geändert"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:39
#, php-format
msgid "* Shift End changed from %s to %s"
msgstr "* Schicht Ende von %s nach %s geändert"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:34
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:47
#, php-format
msgid "* Shift Location changed from %s to %s"
msgstr "* Schicht Ort von %s to %s geändert"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:44
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:57
msgid "The updated Shift:"
msgstr "Die aktualisierte Schicht:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:53
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:66
msgid "Your Shift has changed"
msgstr "Deine Schicht hat sich geändert"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:62
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:79
msgid "A Shift you are registered on was deleted:"
msgstr "Eine deiner Schichten wurde gelöscht:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:71
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:88
msgid "Your Shift was deleted"
msgstr "Deine Schicht wurde gelöscht"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:80
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:105
msgid "You have been assigned to a Shift:"
msgstr "Du wurdest in eine Schicht eingetragen:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:86
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:111
msgid "Assigned to Shift"
msgstr "In Schicht eingetragen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:94
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:122
msgid "You have been removed from a Shift:"
msgstr "Du wurdest aus einer Schicht ausgetragen:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:100
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/shifts_mailer.php:128
msgid "Removed from Shift"
msgstr "Von Schicht ausgetragen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/users_mailer.php:7
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/users_mailer.php:11
msgid "Your account has been deleted"
msgstr "Dein Konto wurde gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/users_mailer.php:7
+#: /Users/msquare/workspace/projects/engelsystem/includes/mailer/users_mailer.php:12
msgid ""
"Your angelsystem account has been deleted. If you have any questions "
"regarding your account deletion, please contact heaven."
@@ -677,11 +684,11 @@ msgstr ""
"Dein Engelsystem-Konto wurde gelöscht. Wenn Du dazu Fragen hast, kontaktiere "
"bitte den Himmel."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:10
msgid "Active angels"
msgstr "Aktive Engel"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:42
#, php-format
msgid ""
"At least %s angels are forced to be active. The number has to be greater."
@@ -689,374 +696,382 @@ msgstr ""
"Mindestens %s Engel werden als aktiv gekennzeichnet. Die Nummer muss größer "
"sein."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:34
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:49
msgid "Please enter a number of angels to be marked as active."
msgstr ""
"Bitte gib eine Anzahl an Engeln ein, die als Aktiv markiert werden sollen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:59
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:83
msgid "Marked angels."
msgstr "Engel wurden markiert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:61
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:137
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:173
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:266
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:67
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:124
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:141
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:86
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:187
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:221
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:293
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:167
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:148
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:172
msgid "back"
msgstr "zurück"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:61
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:92
msgid "apply"
msgstr "anwenden"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:71
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:103
msgid "Angel has been marked as active."
msgstr "Engel wurde als aktiv markiert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:73
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:83
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:103
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:23
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:34
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:105
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:115
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:135
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:40
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:56
msgid "Angel not found."
msgstr "Engel nicht gefunden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:81
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:113
msgid "Angel has been marked as not active."
msgstr "Engel wurde als nicht aktiv markiert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:91
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:123
msgid "Angel has got a t-shirt."
msgstr "Engel hat ein T-Shirt bekommen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:101
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:133
msgid "Angel has got no t-shirt."
msgstr "Engel hat kein T-Shirt bekommen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:144
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:191
msgid "set active"
msgstr "setze aktiv"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:147
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:208
msgid "remove active"
msgstr "entferne aktiv"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:148
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:211
msgid "got t-shirt"
msgstr "hat t-shirt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:151
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:223
msgid "remove t-shirt"
msgstr "entferne t-shirt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:170
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:165
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:180
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:259
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:195
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:221
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:229
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:165
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:210
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:225
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:407
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:415
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:218
msgid "Sum"
msgstr "Summe"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:177
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:266
msgid "Search angel:"
msgstr "Suche Engel:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:178
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:267
msgid "Show all shifts"
msgstr "Alle Schichten anzeigen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:179
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:141
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:142
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:78
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:87
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_log.php:23
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_log.php:24
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:268
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:171
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:172
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:105
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:114
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_log.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_log.php:30
msgid "Search"
msgstr "Suche"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:182
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:271
msgid "How much angels should be active?"
msgstr "Wie viele Engel sollten aktiv sein?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:183
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:254
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:342
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:272
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:281
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:408
msgid "Preview"
msgstr "Vorschau"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:187
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:145
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:276
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:175
msgid "Nickname"
msgstr "Nick"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:188
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:198
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:191
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:277
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:287
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:244
msgid "Size"
msgstr "Größe"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:189
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:6
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:364
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:278
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:11
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:340
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:528
msgid "Shifts"
msgstr "Schichten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:190
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:329
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:279
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:381
msgid "Length"
msgstr "Länge"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:191
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:280
msgid "Active?"
msgstr "Aktiv?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:192
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:189
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:281
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:242
msgid "Forced"
msgstr "Gezwungen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:193
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:282
msgid "T-shirt?"
msgstr "T-Shirt?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:196
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:285
msgid "Shirt statistics"
msgstr "T-Shirt Statistik"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:199
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:288
msgid "Needed shirts"
msgstr "Benötigte T-Shirts"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:200
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_active.php:289
msgid "Given shirts"
msgstr "Ausgegebene T-Shirts"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:10
msgid "Arrived angels"
msgstr "Angekommene Engel"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:20
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:37
msgid "Reset done. Angel has not arrived."
msgstr "Zurückgesetzt. Engel ist nicht angekommen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:31
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:53
msgid "Angel has been marked as arrived."
msgstr "Engel wurde als angekommen markiert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:71
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:9
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:20
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:31
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:42
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:53
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:93
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:34
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:64
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:86
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:115
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:142
msgid "yes"
msgstr "Ja"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:72
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:98
msgid "reset"
msgstr "zurücksetzen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:72
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:156
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:171
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:102
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:186
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:330
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:201
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:216
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:453
msgid "arrived"
msgstr "angekommen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:146
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:176
msgid "Planned arrival"
msgstr "Geplanter Ankunftstag"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:147
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:177
msgid "Arrived?"
msgstr "Angekommen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:148
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:178
msgid "Arrival date"
msgstr "Ankunftsdatum"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:149
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:179
msgid "Planned departure"
msgstr "Geplante Abreise"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:154
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:184
msgid "Planned arrival statistics"
msgstr "Geplante Ankunfts-Statistik"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:157
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:172
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:187
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:202
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:217
msgid "arrived sum"
msgstr "Summe angekommen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:163
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:178
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:193
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:30
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:76
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:208
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:223
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:35
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:116
msgid "Date"
msgstr "Datum"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:164
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:179
#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:194
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:209
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:224
msgid "Count"
msgstr "Anzahl"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:169
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:199
msgid "Arrival statistics"
msgstr "Ankunfts-Statistik"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:184
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_arrive.php:214
msgid "Planned departure statistics"
msgstr "Geplante Abreise-Statistik"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:10
msgid "Free angels"
msgstr "Freie Engel"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:81
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:36
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:70
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:108
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:62
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:172
msgid "Angeltype"
msgstr "Engeltyp"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:84
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:111
msgid "Only confirmed"
msgstr "Nur bestätigte"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:92
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:225
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:354
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:177
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:190
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:40
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:97
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:181
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:119
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:310
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:478
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:285
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:298
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:31
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:117
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:234
msgid "Nick"
msgstr "Nick"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:94
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:255
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:178
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:191
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:47
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:184
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:121
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:366
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:109
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:286
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:299
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:466
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:50
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:237
msgid "DECT"
msgstr "DECT"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:95
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:264
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:52
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:122
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:375
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:63
msgid "Jabber"
msgstr "Jabber"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:96
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:228
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:49
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:386
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_free.php:123
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:313
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:110
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:467
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:52
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:559
msgid "E-Mail"
msgstr "E-Mail"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:10
msgid "Grouprights"
msgstr "Gruppenrechte"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:29
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:144
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:148
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:143
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:189
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:66
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:268
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:35
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:78
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:183
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:51
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:176
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:180
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:193
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:241
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:82
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:83
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:108
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:465
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:489
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:61
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:141
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:236
msgid "Name"
msgstr "Name"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:30
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:52
msgid "Privileges"
msgstr "Privilegien"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:55
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_groups.php:97
msgid "Edit group"
msgstr "Gruppe bearbeiten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:4
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:144
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:190
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:10
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:194
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:242
msgid "Frab import"
msgstr "Frab Import"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:25
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:39
msgid "Webserver has no write-permission on import directory."
msgstr "Der Webserver hat keine Schreibrechte für das Verzeichnis import."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:53
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:117
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:195
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:53
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:59
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:64
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:138
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:234
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:58
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:64
msgid "Please select a shift type."
msgstr "Bitte einen Schichttyp wählen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:60
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:124
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:202
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:71
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:145
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:241
msgid "Please enter an amount of minutes to add to a talk's begin."
msgstr ""
"Bitte gib eine Anzahl Minuten ein, die vor dem Talk-Beginn hinzugefügt "
"werden sollen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:67
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:131
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:209
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:78
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:152
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:248
msgid "Please enter an amount of minutes to add to a talk's end."
msgstr ""
"Bitte gib eine Anzahl Minuten ein, die nach dem Talk-Ende hinzugefügt werden "
"sollen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:75
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:86
msgid "No valid xml/xcal file provided."
msgstr "Keine valide xml/xcal Datei hochgeladen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:80
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:91
msgid "File upload went wrong."
msgstr "Das Hochladen der Datei ist schiefgegangen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:84
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:95
msgid "Please provide some data."
msgstr "Bitte lade eine Datei hoch."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:92
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:139
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:252
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:110
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:167
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:285
msgid "File Upload"
msgstr "Datei hochladen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:92
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:139
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:252
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:110
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:168
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:287
msgid "Validation"
msgstr "Überprüfen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:92
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:101
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:139
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:178
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:252
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:110
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:122
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:168
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:210
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:289
msgid "Import"
msgstr "Importieren"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:96
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:116
msgid ""
"This import will create/update/delete rooms and shifts by given FRAB-export "
"file. The needed file format is xcal."
@@ -1064,381 +1079,387 @@ msgstr ""
"Dieser Import erzeugt, ändert und löscht Räume und Schichten anhand einer "
"FRAB-Export Datei. Das benötigte Format ist xcal."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:98
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:119
msgid "Add minutes to start"
msgstr "Minuten vor Talk-Beginn hinzufügen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:99
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:120
msgid "Add minutes to end"
msgstr "Minuten nach Talk-Ende hinzufügen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:100
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:121
msgid "xcal-File (.xcal)"
msgstr "xcal-Datei (.xcal)"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:110
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:184
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:131
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:223
msgid "Missing import file."
msgstr "Import-Datei nicht vorhanden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:143
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:175
msgid "Rooms to create"
msgstr "Anzulegende Räume"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:147
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:179
msgid "Rooms to delete"
msgstr "Zu löschende Räume"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:151
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:183
msgid "Shifts to create"
msgstr "Anzulegende Schichten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:153
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:162
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:171
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:366
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:185
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:194
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:203
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:530
msgid "Day"
msgstr "Tag"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:154
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:163
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:172
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:324
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:67
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:186
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:195
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:204
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:376
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:109
msgid "Start"
msgstr "Beginn"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:155
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:164
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:173
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:325
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:75
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:187
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:196
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:205
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:377
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:117
msgid "End"
msgstr "Ende"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:156
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:165
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:174
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:188
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:197
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:206
msgid "Shift type"
msgstr "Schichttyp"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:158
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:167
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:176
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:321
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:190
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:199
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:208
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:373
msgid "Room"
msgstr "Raum"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:160
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:192
msgid "Shifts to update"
msgstr "Zu aktualisierende Schichten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:169
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:201
msgid "Shifts to delete"
msgstr "Zu löschende Schichten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:253
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_import.php:290
msgid "It's done!"
msgstr "Erledigt!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_log.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_log.php:8
msgid "Log"
msgstr "Log"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:10
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:17
msgid "Edit news entry"
msgstr "News-Eintrag bearbeiten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:31
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:36
msgid "Author"
msgstr "Autor"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:32
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:161
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:37
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:254
msgid "Subject"
msgstr "Betreff"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:33
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:79
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:106
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:162
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:38
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:119
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:167
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:255
msgid "Message"
msgstr "Nachricht"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:34
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:163
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:39
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:256
msgid "Meeting"
msgstr "Treffen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:38
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:177
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:129
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:48
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:227
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:156
msgid "Delete"
msgstr "löschen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:52
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:78
msgid "News entry updated."
msgstr "News-Eintrag gespeichert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:61
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_news.php:85
msgid "News entry deleted."
msgstr "News-Eintrag gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:10
msgid "Answer questions"
msgstr "Fragen beantworten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:18
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:27
msgid "There are unanswered questions!"
msgstr "Es gibt unbeantwortete Fragen!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:61
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:83
msgid "Unanswered questions"
msgstr "Unbeantwortete Fragen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:63
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:70
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:85
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:92
msgid "From"
msgstr "Von"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:64
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:71
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:19
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:24
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:86
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:93
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:34
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:39
msgid "Question"
msgstr "Frage"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:65
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:73
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:26
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:87
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:95
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:41
msgid "Answer"
msgstr "Antwort"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:68
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:22
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:90
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:37
msgid "Answered questions"
msgstr "Beantwortete Fragen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:72
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:25
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_questions.php:94
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:40
msgid "Answered by"
msgstr "Antwort von"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:4
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:172
-#: /Users/msquare/workspace/projects/engelsystem/includes/sys_menu.php:170
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:10
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:219
+#: /Users/msquare/workspace/projects/engelsystem/includes/sys_menu.php:210
msgid "Rooms"
msgstr "Räume"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:67
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:86
msgid "This name is already in use."
msgstr "Dieser Name ist bereits vergeben."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:97
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:120
#, php-format
msgid "Please enter needed angels for type %s."
msgstr "Bitte gib die Anzahl der benötigten Engel vom Typ %s an."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:124
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:174
msgid "Room saved."
msgstr "Raum gespeichert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:145
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:191
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:195
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:243
msgid "Public"
msgstr "Öffentlich"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:146
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:196
msgid "Room number"
msgstr "Raumnummer"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:151
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:201
msgid "Needed angels:"
msgstr "Benötigte Engel:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:167
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:215
#, php-format
msgid "Room %s deleted."
msgstr "Raum %s gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:175
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:223
#, php-format
msgid "Do you want to delete room %s?"
msgstr "Möchest Du den Raum %s wirklich löschen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:185
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_rooms.php:237
msgid "add"
msgstr "Neu"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:10
msgid "Create shifts"
msgstr "Schichten erstellen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:71
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:80
msgid "Please select a location."
msgstr "Bitte einen Ort auswählen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:78
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:87
msgid "Please select a start time."
msgstr "Bitte eine Startzeit auswählen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:85
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:94
msgid "Please select an end time."
msgstr "Bitte eine Endzeit auswählen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:90
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:99
msgid "The shifts end has to be after its start."
msgstr "Die Endzeit muss nach der Startzeit liegen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:102
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:111
msgid "Please enter a shift duration in minutes."
msgstr "Gib bitte eine Schichtlänge in Minuten ein."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:110
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:122
msgid "Please split the shift-change hours by colons."
msgstr "Trenne die Schichtwechselstunden mit einem Komma."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:115
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:127
msgid "Please select a mode."
msgstr "Bitte einen Modus auswählen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:128
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:140
#, php-format
msgid "Please check the needed angels for team %s."
msgstr "Bitte gib die Anzahl der benötigten Engel vom Team %s an."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:133
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:146
msgid "There are 0 angels needed. Please enter the amounts of needed angels."
msgstr "Es werden 0 Engel benötigt. Bitte ändere das."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:137
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:150
msgid "Please select a mode for needed angels."
msgstr "Bitte wähle einen Modus für benötigte Engel."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:141
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:154
msgid "Please select needed angels."
msgstr "Bitte wähle benötigte Engel."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:268
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:295
msgid "Time and location"
msgstr "Zeit und Ort"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:269
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:296
msgid "Type and title"
msgstr "Typ und Titel"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:326
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:378
msgid "Mode"
msgstr "Modus"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:327
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:379
msgid "Create one shift"
msgstr "Eine Schicht erstellen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:328
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:380
msgid "Create multiple shifts"
msgstr "Mehrere Schichten erstellen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:330
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:384
msgid "Create multiple shifts with variable length"
msgstr "Erstelle mehrere Schichten mit unterschiedlicher Länge"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:331
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:390
msgid "Shift change hours"
msgstr "Schichtwechsel-Stunden"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:335
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:398
msgid "Take needed angels from room settings"
msgstr "Übernehme benötigte Engel von den Raum-Einstellungen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:336
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_shifts.php:402
msgid "The following angels are needed"
msgstr "Die folgenden Engel werden benötigt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:10
msgid "All Angels"
msgstr "Engelliste"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:20
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:38
msgid "This user does not exist."
msgstr "Benutzer existiert nicht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:46
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:67
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:68
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:69
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:74
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:85
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:88
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:91
msgid "Yes"
msgstr "Ja"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:47
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:67
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:68
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:69
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:75
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:85
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:88
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:91
msgid "No"
msgstr "Nein"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:60
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:88
msgid "Force active"
msgstr "Aktiv erzwingen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:79
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:107
msgid ""
"Please visit the angeltypes page or the users profile to manage users "
"angeltypes."
msgstr ""
"Bitte benutze die Engeltypen-Seite um die Engeltypen des Users zu verwalten."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:204
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/admin_user.php:313
msgid "Edit user"
msgstr "User bearbeiten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_credits.php:3
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_credits.php:8
msgid "Credits"
msgstr "Credits"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:4
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:349
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:356
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:95
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:99
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:10
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:473
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:480
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:115
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:119
msgid "Login"
msgstr "Login"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:8
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:285
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:18
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:396
msgid "Register"
msgstr "Registrieren"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:12
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:26
msgid "Logout"
msgstr "Logout"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:56
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:79
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:528
+msgid "Registration is disabled."
+msgstr "Registrierung ist abgeschaltet."
+
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:93
#, php-format
msgid "Your nick &quot;%s&quot; already exists."
msgstr "Der Nick &quot;%s&quot; existiert schon."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:60
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:98
#, php-format
msgid "Your nick &quot;%s&quot; is too short (min. 2 characters)."
msgstr "Der Nick &quot;%s&quot; ist zu kurz (Mindestens 2 Zeichen)."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:86
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:36
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:126
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:46
msgid "Please check your jabber account information."
msgstr "Bitte überprüfe deine Jabber Account Eingabe."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:95
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:135
msgid "Please select your shirt size."
msgstr "Bitte wähle Deine T-Shirt Größe."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:106
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:147
#, php-format
msgid "Your password is too short (please use at least %s characters)."
msgstr "Dein Passwort ist zu kurz (Bitte mindestens %s Zeichen nutzen)."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:115
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:52
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:158
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:162
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:62
msgid ""
"Please enter your planned date of arrival. It should be after the buildup "
"start date and before teardown end date."
@@ -1446,11 +1467,16 @@ msgstr ""
"Bitte gib Dein geplantes Ankunftsdatum an. Es sollte nach dem Aufbaubeginn "
"und vor dem Abbauende liegen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:189
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:190
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:85
+msgid "For dect numbers are only 5 digits allowed."
+msgstr "Die DECT Nummer darf nur 5 Zeichen lang sein."
+
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:274
msgid "Angel registration successful!"
msgstr "Engel-Registrierung erfolgreich!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:217
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:302
msgid ""
"By completing this form you're registering as a Chaos-Angel. This script "
"will create you an account in the angel task scheduler."
@@ -1458,50 +1484,50 @@ msgstr ""
"Mit diesem Formular registrierst Du Dich als Engel. Du bekommst ein Konto in "
"der Engel-Aufgabenverwaltung."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:229
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:50
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:316
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:55
msgid ""
"The engelsystem is allowed to send me an email (e.g. when my shifts change)"
msgstr ""
"Das Engelsystem darf mir E-Mails senden (z.B. wenn sich meine Schichten "
"ändern)"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:230
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:51
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:321
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:60
msgid "Humans are allowed to send me an email (e.g. for ticket vouchers)"
msgstr "Menschen dürfen mir eine E-Mail senden (z.B. für Ticket Voucher)"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:235
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:43
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:330
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:36
msgid "Planned date of arrival"
msgstr "Geplanter Ankunftstag"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:238
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:54
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:336
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:67
msgid "Shirt size"
msgstr "T-Shirt Größe"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:243
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:355
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:98
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:400
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:342
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:479
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:118
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:576
msgid "Password"
msgstr "Passwort"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:246
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:401
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:345
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:577
msgid "Confirm password"
msgstr "Passwort wiederholen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:249
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:350
msgid "What do you want to do?"
msgstr "Was möchtest Du machen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:249
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:353
msgid "Description of job types"
msgstr "Beschreibung der Aufgaben"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:250
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:360
msgid ""
"Restricted angel types need will be confirmed later by a supporter. You can "
"change your selection in the options section."
@@ -1509,46 +1535,46 @@ msgstr ""
"Beschränkte Engeltypen müssen später von einem Supporter freigeschaltet "
"werden. Du kannst Deine Auswahl später in den Einstellungen ändern."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:258
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:48
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:369
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:51
msgid "Mobile"
msgstr "Handy"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:261
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:46
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:372
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:49
msgid "Phone"
msgstr "Telefon"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:267
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:42
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:378
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:33
msgid "First name"
msgstr "Vorname"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:270
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:41
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:381
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:32
msgid "Last name"
msgstr "Nachname"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:275
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:45
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:386
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:48
msgid "Age"
msgstr "Alter"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:278
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:53
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:389
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:64
msgid "Hometown"
msgstr "Wohnort"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:281
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:39
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:392
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:30
msgid "Entry required!"
msgstr "Pflichtfeld!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:319
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:443
msgid "Please enter a password."
msgstr "Gib bitte ein Passwort ein."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:323
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:447
msgid ""
"No user was found with that Nickname. Please try again. If you are still "
"having problems, ask a Dispatcher."
@@ -1556,100 +1582,96 @@ msgstr ""
"Es wurde kein Engel mit diesem Namen gefunden. Probiere es bitte noch "
"einmal. Wenn das Problem weiterhin besteht, frage einen Dispatcher."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:327
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:451
msgid "Please enter a nickname."
msgstr "Gib bitte einen Nick an."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:358
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:101
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:482
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:121
msgid "I forgot my password"
msgstr "Passwort vergessen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:363
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:103
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:487
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:123
msgid "Please note: You have to activate cookies!"
msgstr "Hinweis: Cookies müssen aktiviert sein!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:374
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:107
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:498
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:127
msgid "What can I do?"
msgstr "Was kann ich machen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:375
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:108
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:499
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:128
msgid "Please read about the jobs you can do to help us."
msgstr ""
"Bitte informiere Dich über die Tätigkeiten bei denen Du uns helfen kannst."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:390
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:521
msgid "Please sign up, if you want to help us!"
msgstr "Bitte registriere Dich, wenn Du helfen möchtest!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/guest_login.php:397
-msgid "Registration is disabled."
-msgstr "Registrierung ist abgeschaltet."
-
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:10
msgid "Messages"
msgstr "Nachrichten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:26
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:47
msgid "Select recipient..."
msgstr "Empfänger auswählen..."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:62
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:96
msgid "mark as read"
msgstr "als gelesen markieren"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:65
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:103
msgid "delete message"
msgstr "Nachricht löschen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:72
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:112
#, php-format
msgid "Hello %s, here can you leave messages for other angels"
msgstr "Hallo %s, hier kannst Du anderen Engeln Nachrichten schreiben."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:75
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:115
msgid "New"
msgstr "Neu"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:77
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:117
msgid "Transmitted"
msgstr "Gesendet"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:78
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:118
msgid "Recipient"
msgstr "Empfänger"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:90
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:106
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:130
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:152
msgid "Incomplete call, missing Message ID."
msgstr "Unvollständiger Aufruf, fehlende Nachrichten ID."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:98
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:114
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:144
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:163
msgid "No Message found."
msgstr "Keine Nachricht gefunden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:122
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:172
msgid "Transmitting was terminated with an Error."
msgstr "Übertragung wurde mit einem Fehler abgebrochen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:127
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_messages.php:177
msgid "Wrong action."
msgstr "Falsche Aktion."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:23
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:39
msgid "Key changed."
msgstr "Key geändert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:26
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:335
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:42
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:470
msgid "Reset API key"
msgstr "API-Key zurücksetzen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:27
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:44
msgid ""
"If you reset the key, the url to your iCal- and JSON-export and your atom "
"feed changes! You have to update it in every application using one of these "
@@ -1658,23 +1680,23 @@ msgstr ""
"Wenn du den API-Key zurücksetzt, ändert sich die URL zu deinem iCal-, JSON-"
"Export und Atom Feed! Du musst diesen überall ändern, wo er in Benutzung ist."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:28
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:47
msgid "Continue"
msgstr "Fortfahren"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:60
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:86
msgid "Please enter a freeload comment!"
msgstr "Gib bitte einen Schwänz-Kommentar ein!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:79
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:108
msgid "Shift saved."
msgstr "Schicht gespeichert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:107
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:158
msgid "Shift canceled."
msgstr "Schichteintrag gelöscht."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:109
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_myshifts.php:160
msgid ""
"It's too late to sign yourself off the shift. If neccessary, ask the "
"dispatcher to do so."
@@ -1682,70 +1704,66 @@ msgstr ""
"Es ist zu spät um Dich aus der Schicht auszutragen. Wenn notwendig, frage "
"einen Dispatcher dafür."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:4
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:10
msgid "News comments"
msgstr "News Kommentare"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:8
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:18
msgid "News"
msgstr "News"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:12
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:26
msgid "Meetings"
msgstr "Treffen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:68
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:103
msgid "Comments"
msgstr "Kommentare"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:86
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:127
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:144
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:212
msgid "Entry saved."
msgstr "Eintrag gespeichert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:104
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:165
msgid "New Comment:"
msgstr "Neuer Kommentar:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:110
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:171
msgid "Invalid request."
msgstr "Ungültige Abfrage."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:158
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_news.php:251
msgid "Create news:"
msgstr "News anlegen:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:4
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:10
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:44
msgid "Ask the Heaven"
msgstr "Frag den Himmel"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:27
-msgid "Unable to save question."
-msgstr "Konnte Frage nicht speichern."
-
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:53
msgid "You question was saved."
msgstr "Frage gespeichert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:33
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:57
msgid "Please enter a question!"
msgstr "Gib eine Frage ein!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:41
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:65
msgid "Incomplete call, missing Question ID."
msgstr "Unvollständiger Aufruf, fehlende Fragen ID."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:50
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_questions.php:80
msgid "No question found."
msgstr "Keine Frage gefunden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:4
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:332
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:10
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:459
msgid "Settings"
msgstr "Einstellungen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:62
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:72
msgid ""
"Please enter your planned date of departure. It should be after your planned "
"arrival date and after buildup start date and before teardown end date."
@@ -1753,27 +1771,23 @@ msgstr ""
"Bitte gibt dein geplantes Abreisedatum an. Es sollte nach Deinem "
"Anreisedatum, nach dem Aufbaubeginn und vor dem Abbauende liegen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:92
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:112
msgid "-> not OK. Please try again."
msgstr "-> Nicht OK. Bitte erneut versuchen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:100
-msgid "Failed setting password."
-msgstr "Konnte Passwort nicht speichern."
-
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:125
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_settings.php:154
msgid "Theme changed."
msgstr "Aussehen geändert."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:83
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:98
msgid "The administration has not configured any rooms yet."
msgstr "Die Administratoren habe noch keine Räume eingerichtet."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:95
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:117
msgid "The administration has not configured any shifts yet."
msgstr "Die Administratoren haben noch keine Schichten angelegt."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:105
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:131
msgid ""
"The administration has not configured any angeltypes yet - or you are not "
"subscribed to any angeltype."
@@ -1781,34 +1795,34 @@ msgstr ""
"Die Administratoren haben noch keine Engeltypen konfiguriert - oder Du hast "
"noch keine Engeltypen ausgewählt."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:154
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:197
msgid "occupied"
msgstr "belegt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:158
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:201
msgid "free"
msgstr "frei"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:178
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:230
msgid "Occupancy"
msgstr "Belegung"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:179
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:233
msgid ""
"The tasks shown here are influenced by the angeltypes you joined already!"
msgstr ""
"Die Schichten, die hier angezeigt werden, sind von Deinen Einstellungen "
"(Engeltypen/Aufgaben) abhängig!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:179
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:235
msgid "Description of the jobs."
msgstr "Beschreibung der Aufgaben."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:181
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:239
msgid "iCal export"
msgstr "iCal Export"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:181
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:240
#, php-format
msgid ""
"Export of shown shifts. <a href=\"%s\">iCal format</a> or <a href=\"%s"
@@ -1819,76 +1833,79 @@ msgstr ""
"\">JSON Format</a> verfügbar (Link bitte geheimhalten, sonst <a href=\"%s"
"\">API-Key zurücksetzen</a>)."
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:182
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:245
msgid "Filter"
msgstr "Filter"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:204
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:23
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:278
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:49
msgid "All"
msgstr "Alle"
-#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:205
+#: /Users/msquare/workspace/projects/engelsystem/includes/pages/user_shifts.php:279
msgid "None"
msgstr "Keine"
-#: /Users/msquare/workspace/projects/engelsystem/includes/sys_menu.php:139
+#: /Users/msquare/workspace/projects/engelsystem/includes/sys_menu.php:168
msgid "Admin"
msgstr "Admin"
-#: /Users/msquare/workspace/projects/engelsystem/includes/sys_menu.php:161
+#: /Users/msquare/workspace/projects/engelsystem/includes/sys_menu.php:192
msgid "Manage rooms"
msgstr "Verwalte Räume"
-#: /Users/msquare/workspace/projects/engelsystem/includes/sys_template.php:166
+#: /Users/msquare/workspace/projects/engelsystem/includes/sys_template.php:292
msgid "No data found."
msgstr "Nichts gefunden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:27
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:244
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:31
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:437
msgid "Unconfirmed"
msgstr "Unbestätigt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:29
#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:33
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:37
msgid "supporter"
msgstr "Supporter"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:31
#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:35
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:39
msgid "Member"
msgstr "Mitglied"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:42
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:51
#, php-format
msgid "Do you want to delete angeltype %s?"
msgstr "Möchtest Du den Engeltypen %s löschen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:44
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:15
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:8
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:19
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:30
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:41
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:52
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:82
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:53
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:25
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:24
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:56
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:81
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:107
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:136
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:192
msgid "cancel"
msgstr "abbrechen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:67
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:269
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:85
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:86
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:490
msgid "Restricted"
msgstr "Beschränkt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:68
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:88
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:89
msgid "No Self Sign Up"
msgstr "Kein Selbst-Eintragen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:69
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:91
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:94
msgid "Requires driver license"
msgstr "Benötigt Führerschein"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:73
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:99
msgid ""
"Restricted angel types can only be used by an angel if enabled by a "
"supporter (double opt-in)."
@@ -1896,24 +1913,33 @@ msgstr ""
"Beschränkte Engeltypen müssen von einem Supporter freigeschaltet werden "
"(double-opt-in)."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:74
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:205
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:37
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:58
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:93
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:101
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:386
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:63
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:101
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:135
msgid "Description"
msgstr "Beschreibung"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:75
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:38
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:102
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:64
msgid "Please use markdown for the description."
msgstr "Bitte benutze Markdown für die Beschreibung."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:90
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:103
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:464
+msgid "Contact"
+msgstr "Kontakt"
+
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:106
+msgid "Primary contact person/desk for user questions."
+msgstr "Ansprechpartner für Fragen."
+
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:134
msgid "my driving license"
msgstr "Meine Führerschein-Infos"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:97
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:145
msgid ""
"This angeltype requires a driver license. Please enter your driver license "
"information!"
@@ -1921,7 +1947,7 @@ msgstr ""
"Dieser Engeltyp benötigt Führerschein-Infos. Bitte trage Deine Führerschein-"
"Infos ein!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:101
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:150
#, php-format
msgid ""
"You are unconfirmed for this angeltype. Please go to the introduction for %s "
@@ -1930,82 +1956,86 @@ msgstr ""
"Du bist noch nicht für diesen Engeltyp bestätigt. Bitte gehe zur Einführung "
"für %s um bestätigt zu werden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:140
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:211
msgid "confirm"
msgstr "bestätigen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:141
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:219
msgid "deny"
msgstr "ablehnen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:157
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:257
msgid "remove"
msgstr "entfernen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:179
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:287
msgid "Driver"
msgstr "Fahrer"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:180
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:288
msgid "Has car"
msgstr "Hat Auto"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:181
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:27
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:289
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:29
msgid "Car"
msgstr "Auto"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:182
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:290
msgid "3,5t Transporter"
msgstr "3,5t Transporter"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:183
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:291
msgid "7,5t Truck"
msgstr "7,5t LKW"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:184
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:292
msgid "12,5t Truck"
msgstr "12,5t LKW"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:185
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:31
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:293
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:45
msgid "Forklift"
msgstr "Gabelstapler"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:215
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:333
+msgid "Info"
+msgstr "Info"
+
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:401
msgid "supporters"
msgstr "Supporter"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:235
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:421
msgid "Members"
msgstr "Mitglieder"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:238
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:72
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:429
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:174
msgid "Add"
msgstr "Hinzufügen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:246
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:441
msgid "confirm all"
msgstr "Alle bestätigen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:247
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:446
msgid "deny all"
msgstr "Alle ablehnen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:264
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:484
msgid "New angeltype"
msgstr "Neuer Engeltyp"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:270
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:491
msgid "Self Sign Up Allowed"
msgstr "Kein Selbst-Eintragen erlaubt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:271
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:492
msgid "Membership"
msgstr "Mitgliedschaft"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:296
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:537
msgid ""
"This angeltype is restricted by double-opt-in by a team supporter. Please "
"show up at the according introduction meetings."
@@ -2013,11 +2043,11 @@ msgstr ""
"Dieser Engeltyp muss zusätzlich von einem Team-Supporter freigeschaltet "
"werden. Bitte komme zu den entsprechenden Einführungstreffen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:317
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:574
msgid "FAQ"
msgstr "FAQ"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:319
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/AngelTypes_view.php:579
msgid ""
"Here is the list of teams and their tasks. If you have questions, read the "
"FAQ."
@@ -2025,289 +2055,295 @@ msgstr ""
"Hier ist die Liste der Teams und ihrer Aufgaben. Wenn Du Fragen hast, schaue "
"im FAQ nach."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:10
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:18
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:13
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:22
#, php-format
msgid "Welcome to the %s!"
msgstr "Willkommen beim %s!"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:24
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:30
msgid "Buildup starts"
msgstr "Aufbau startet"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:26
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:34
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:42
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:50
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:67
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:72
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:77
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:69
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:77
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:32
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:40
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:48
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:56
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:80
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:81
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:89
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:97
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:98
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:111
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:119
msgid "Y-m-d"
msgstr "d.m.Y"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:32
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:38
msgid "Event starts"
msgstr "Event startet"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:40
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:46
msgid "Event ends"
msgstr "Event endet"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:48
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:54
msgid "Teardown ends"
msgstr "Abbau endet"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:67
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:78
#, php-format
msgid "%s, from %s to %s"
msgstr "%s, vom %s bis %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:72
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:88
#, php-format
msgid "%s, starting %s"
msgstr "%s, ab dem %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:77
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:96
#, php-format
msgid "Event from %s to %s"
msgstr "Event von %s bis %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:106
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:134
msgid "Event Name"
msgstr "Event Name"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:107
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:135
msgid "Event Name is shown on the start page."
msgstr "Event Name wird auf der Startseite angezeigt."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:108
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:136
msgid "Event Welcome Message"
msgstr "Event Willkommens-Nachricht"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:109
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:137
msgid ""
"Welcome message is shown after successful registration. You can use markdown."
msgstr ""
"Die Willkommens-Nachricht wird nach einer erfolgreichen Registrierung "
"angezeigt. Du kannst Markdown benutzen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:112
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:140
msgid "Buildup date"
msgstr "Aufbau Datum"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:113
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:141
msgid "Event start date"
msgstr "Event Start Datum"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:116
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:144
msgid "Teardown end date"
msgstr "Abbau Ende Datum"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:117
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/EventConfig_view.php:145
msgid "Event end date"
msgstr "Event Ende Datum"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:17
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:32
msgid "Open questions"
msgstr "Offene Fragen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:31
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Questions_view.php:46
msgid "Your Question:"
msgstr "Deine Frage:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:200
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:367
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:146
+msgid "No shifts found."
+msgstr "Keine Schichten gefunden."
+
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:248
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:531
msgid "Time"
msgstr "Zeit"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:239
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:304
msgid "Your shift"
msgstr "Meine Schicht"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:240
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:305
msgid "Help needed"
msgstr "Hilfe benötigt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:241
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:306
msgid "Other angeltype needed / collides with my shifts"
msgstr "Andere Engeltypen benötigt / kollidiert mit meinen Schichten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:242
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:307
msgid "Shift is full"
msgstr "Schicht ist voll"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:243
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarRenderer.php:308
msgid "Shift running/ended"
msgstr "Schicht läuft/vorbei"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:82
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:130
msgid "Add more angels"
msgstr "Neue Engel hinzufügen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:113
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:166
#, php-format
msgid "%d helper needed"
msgid_plural "%d helpers needed"
msgstr[0] "%d Helfer benötigt"
msgstr[1] "%d Helfer benötigt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:118
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:24
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:181
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:46
msgid "Sign up"
msgstr "Eintragen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:123
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:187
msgid "ended"
msgstr "vorbei"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:132
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:26
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftCalendarShiftRenderer.php:199
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:51
#, php-format
msgid "Become %s"
msgstr "Werde ein %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:18
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:267
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:269
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:31
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:346
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:348
msgid "Freeloaded"
msgstr "Geschwänzt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:19
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:32
msgid "Freeload comment (Only for shift coordination):"
msgstr "Schwänzer Kommentar (Nur für die Schicht-Koordination):"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:22
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:35
msgid "Edit shift entry"
msgstr "Schichteintrag bearbeiten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:25
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:38
msgid "Angel:"
msgstr "Engel:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:26
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:39
msgid "Date, Duration:"
msgstr "Termin, Dauer:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:27
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:40
msgid "Location:"
msgstr "Ort:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:28
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:41
msgid "Title:"
msgstr "Titel:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:42
msgid "Type:"
msgstr "Typ:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:30
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftEntry_view.php:43
msgid "Comment (for your eyes only):"
msgstr "Kommentar (nur für Dich):"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:13
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:23
#, php-format
msgid "Do you want to delete shifttype %s?"
msgstr "Möchtest Du den Schichttypen %s löschen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:55
msgid "Edit shifttype"
msgstr "Schichttyp bearbeiten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:55
msgid "Create shifttype"
msgstr "Schichttyp erstellen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:48
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:80
#, php-format
msgid "for team %s"
msgstr "für Team %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:75
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/ShiftTypes_view.php:138
msgid "New shifttype"
msgstr "Neuer Schichttyp"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:7
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:14
#, php-format
msgid "created at %s by %s"
msgstr "erstellt am %s von %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:10
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:21
#, php-format
msgid "edited at %s by %s"
msgstr "bearbeitet am %s von %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:53
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:92
msgid "This shift collides with one of your shifts."
msgstr "Diese Schicht kollidiert mit deinen Schichten."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:54
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:95
msgid "You are signed up for this shift."
msgstr "Du bist für diese Schicht eingetragen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:83
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:368
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/Shifts_view.php:125
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:532
msgid "Location"
msgstr "Ort"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:6
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:16
#, php-format
msgid "Do you really want to add supporter rights for %s to %s?"
msgstr "Sollen %s %s als neuen Supporter bekommen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:6
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:17
#, php-format
msgid "Do you really want to remove supporter rights for %s from %s?"
msgstr "Möchtest Du wirklich %s von %s als Supporter befreien?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:17
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:49
#, php-format
msgid "Do you really want to deny all users for %s?"
msgstr "Möchtest Du wirklich alle Benutzer als %s ablehnen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:28
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:79
#, php-format
msgid "Do you really want to confirm all users for %s?"
msgstr "Möchtest Du wirklich alle Benutzer als %s bestätigen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:39
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:103
#, php-format
msgid "Do you really want to confirm %s for %s?"
msgstr "Möchtest Du wirklich %s für %s bestätigen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:50
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:132
#, php-format
msgid "Do you really want to delete %s from %s?"
msgstr "Möchtest Du wirklich %s von %s entfernen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:71
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:173
msgid "User"
msgstr "Benutzer"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:80
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:188
#, php-format
msgid "Do you really want to add %s to %s?"
msgstr "Möchtest Du wirklich %s zu %s hinzufügen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:83
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserAngelTypes_view.php:200
msgid "save"
msgstr "Speichern"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:17
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:15
msgid "Back to profile"
msgstr "Zurück zum Profil"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:21
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:19
msgid "Privacy"
msgstr "Privatsphäre"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:21
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:19
msgid ""
"Your driving license information is only visible for supporters and admins."
msgstr "Deine Führerschein-Infos sind nur für Supporter und Admins sichtbar."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:22
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:20
msgid "I am willing to drive a car for the event"
msgstr "Ich möchte für das Event Auto fahren"
@@ -2316,78 +2352,74 @@ msgid ""
"I have my own car with me and am willing to use it for the event (You'll get "
"reimbursed for fuel)"
msgstr ""
-"Ich habe mein eigenes Auto dabei und möchte würde es zum Fahren für das Event "
-"verwenden (Du wirst für Spritkosten entschädigt)"
+"Ich habe mein eigenes Auto dabei und möchte würde es zum Fahren für das "
+"Event verwenden (Du wirst für Spritkosten entschädigt)"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:26
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:28
msgid "Driver license"
msgstr "Führerschein"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:28
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:32
msgid "Transporter 3,5t"
msgstr "3,5t Transporter"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:29
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:37
msgid "Truck 7,5t"
msgstr "7,5t LKW"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:30
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/UserDriverLicenses_view.php:42
msgid "Truck 12,5t"
msgstr "12,5t LKW"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:7
-msgid "Please select..."
-msgstr "Bitte auswählen..."
-
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:38
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:29
msgid "Here you can change your user details."
msgstr "Hier kannst Du Deine Details ändern."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:44
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:43
msgid "Planned date of departure"
msgstr "Geplanter Abreisetag"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:55
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:71
msgid "Please visit the angeltypes page to manage your angeltypes."
msgstr "Bitte benutze die Engeltypen-Seite um deine Engeltypen zu verwalten."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:61
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:77
msgid "Here you can change your password."
msgstr "Hier kannst Du Dein Passwort ändern."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:62
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:78
msgid "Old password:"
msgstr "Altes Passwort:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:63
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:79
msgid "New password:"
msgstr "Neues Passwort:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:64
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:80
msgid "Password confirmation:"
msgstr "Passwort wiederholen:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:68
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:84
msgid "Here you can choose your color settings:"
msgstr "Hier kannst Du das Aussehen auswählen:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:69
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:85
msgid "Color settings:"
msgstr "Aussehen:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:73
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:89
msgid "Here you can choose your language:"
msgstr "Hier kannst Du Deine Sprache auswählen:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:74
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:90
msgid "Language:"
msgstr "Sprache:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:88
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:108
msgid "Registration successful"
msgstr "Registrierung erfolgreich"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:126
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:151
msgid ""
"Do you really want to delete the user including all his shifts and every "
"other piece of his data?"
@@ -2395,152 +2427,152 @@ msgstr ""
"Möchtest Du wirklich den Engel inklusive aller seiner Schichten und allen "
"anderen seiner Daten löschen?"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:128
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:155
msgid "Your password"
msgstr "Dein Passwort"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:143
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:174
#, php-format
msgid "Angel should receive at least %d vouchers."
msgstr "Engel sollte mindestens %d Voucher bekommen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:145
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:177
msgid "Number of vouchers given out"
msgstr "Anzahl Voucher bekommen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:159
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:212
msgid "m/d/Y h:i a"
msgstr "d.m.Y H:i"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:178
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:231
msgid "New user"
msgstr "Neuer User"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:182
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:235
msgid "Prename"
msgstr "Vorname"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:185
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:350
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:238
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:502
msgid "Arrived"
msgstr "Angekommen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:186
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:239
msgid "Voucher"
msgstr "Voucher"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:187
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:240
msgid "Freeloads"
msgstr "Schwänzereien"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:188
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:352
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:241
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:516
msgid "Active"
msgstr "Aktiv"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:190
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:353
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:243
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:517
msgid "T-Shirt"
msgstr "T-Shirt"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:192
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:245
msgid "Last login"
msgstr "Letzter Login"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:209
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:275
msgid "Free"
msgstr "Frei"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:214
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:216
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:282
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:284
#, php-format
msgid "Next shift %c"
msgstr "Nächste Schicht %c"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:221
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:289
#, php-format
msgid "Shift starts %c"
msgstr "Schicht startet %c"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:223
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:291
#, php-format
msgid "Shift ends %c"
msgstr "Schicht endet %c"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:280
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:375
msgid "sign off"
msgstr "abmelden"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:305
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:408
msgid "Sum:"
msgstr "Summe:"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:329
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:449
msgid "driving license"
msgstr "Führerschein"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:331
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:457
msgid "Edit vouchers"
msgstr "Voucher bearbeiten"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:333
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:462
msgid "iCal Export"
msgstr "iCal Export"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:334
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:466
msgid "JSON Export"
msgstr "JSON Export"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:347
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:483
msgid "User state"
msgstr "Engelzustand"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:350
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:494
#, php-format
msgid "Arrived at %s"
msgstr "Angekommen am %s"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:350
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:497
#, php-format
msgid "Not arrived (Planned: %s)"
msgstr "Nicht angekommen (Geplant: %s)"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:350
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:503
msgid "Not arrived"
msgstr "Nicht angekommen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:351
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:510
#, php-format
msgid "Got %s voucher"
msgid_plural "Got %s vouchers"
msgstr[0] "Einen Voucher bekommen"
msgstr[1] "%s Voucher bekommen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:351
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:514
msgid "Got no vouchers"
msgstr "Voucher nicht bekommen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:360
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:524
msgid "Rights"
msgstr "Rechte"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:369
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:533
msgid "Name &amp; workmates"
msgstr "Name &amp; Kollegen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:370
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:534
msgid "Comment"
msgstr "Kommentar"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:371
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:535
msgid "Action"
msgstr "Aktion"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:373
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:537
msgid "Your night shifts between 2 and 8 am count twice."
msgstr "Deine Nachtschichten zwischen 2 und 8 Uhr zählen doppelt."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:374
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:540
#, php-format
msgid ""
"Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some "
@@ -2549,7 +2581,7 @@ msgstr ""
"Gehe zur <a href=\"%s\">Schicht-Tabelle</a>, um Dich für Schichten "
"einzutragen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:384
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:557
msgid ""
"We will send you an e-mail with a password recovery link. Please use the "
"email address you used for registration."
@@ -2558,15 +2590,15 @@ msgstr ""
"zurücksetzen kannst. Bitte benutze die Mailadresse, die du bei der Anmeldung "
"verwendet hast."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:387
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:560
msgid "Recover"
msgstr "Wiederherstellen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:398
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:574
msgid "Please enter a new password."
msgstr "Gib bitte ein neues Passwort ein."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:447
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:659
msgid ""
"Please enter your planned date of departure on your settings page to give us "
"a feeling for teardown capacities."
@@ -2574,7 +2606,7 @@ msgstr ""
"Bitte gib Dein geplantes Abreisedatum an, damit wir ein Gefühl für die Abbau-"
"Planung bekommen."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:457
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:675
#, php-format
msgid ""
"You freeloaded at least %s shifts. Shift signup is locked. Please go to "
@@ -2583,7 +2615,7 @@ msgstr ""
"Du hast mindestens %s Schichten geschwänzt. Schicht-Registrierung ist "
"gesperrt. Bitte gehe zum Himmelsschreibtisch um wieder entsperrt zu werden."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:468
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:693
msgid ""
"You are not marked as arrived. Please go to heaven's desk, get your angel "
"badge and/or tell them that you arrived already."
@@ -2591,30 +2623,36 @@ msgstr ""
"Du bist nicht als angekommen markiert. Bitte gehe zur Himmelsverwaltung, "
"hole Dein Badge ab und/oder erkläre ihnen, dass Du bereits angekommen bist."
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:478
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:707
msgid "You need to specify a tshirt size in your settings!"
msgstr "Bitte eine T-Shirt-Größe auswählen"
-#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:488
+#: /Users/msquare/workspace/projects/engelsystem/includes/view/User_view.php:722
msgid ""
"You need to specify a DECT phone number in your settings! If you don't have "
-"a DECT phone, just enter \"-\"."
+"a DECT phone, just enter '-'."
msgstr ""
"Bitte eine DECT-Telefonnummer in den Einstellungen eingeben. Wenn du noch "
"keine Nummer hast, bitte einfach \"-\" angeben."
-#: /Users/msquare/workspace/projects/engelsystem/public/index.php:155
+#: /Users/msquare/workspace/projects/engelsystem/public/index.php:206
msgid "No Access"
msgstr "Kein Zugriff"
-#: /Users/msquare/workspace/projects/engelsystem/public/index.php:156
+#: /Users/msquare/workspace/projects/engelsystem/public/index.php:207
msgid ""
-"You don't have permission to view this page. You probably have to sign in or "
-"register in order to gain access!"
+"You don't have permission to view this page . You probably have to sign in "
+"or register in order to gain access!"
msgstr ""
"Du hast keinen Zugriff auf diese Seite. Registriere Dich und logge Dich "
"bitte ein, um Zugriff zu erhalten!"
+#~ msgid "Unable to save question."
+#~ msgstr "Konnte Frage nicht speichern."
+
+#~ msgid "Failed setting password."
+#~ msgstr "Konnte Passwort nicht speichern."
+
#~ msgid "Please enter your planned date of arrival."
#~ msgstr "Bitte gib Dein geplantes Ankunftsdatum an."
diff --git a/phpunit.xml b/phpunit.xml
index 5b6d97a1..98e64795 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,24 +1,19 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
- backupGlobals="false"
- bootstrap="./includes/engelsystem_provider.php"
- colors="true"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- processIsolation="false">
- <testsuites>
- <testsuite name="Models">
- <directory>./test/model/</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist>
- <directory>./include/</directory>
- <directory>./public/</directory>
- </whitelist>
- </filter>
- <php>
- <const name="PHPUNIT_TESTSUITE" value="true" />
- </php>
+ bootstrap="./tests/autoload.php"
+ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.3/phpunit.xsd"
+ colors="true"
+>
+ <testsuites>
+ <testsuite name="Feature">
+ <directory>./tests/Feature</directory>
+ </testsuite>
+ <testsuite name="Unit">
+ <directory>./tests/Unit</directory>
+ </testsuite>
+ </testsuites>
+ <filter>
+ <whitelist>
+ <directory>./src/</directory>
+ </whitelist>
+ </filter>
</phpunit>
diff --git a/public/.htaccess b/public/.htaccess
new file mode 100644
index 00000000..2b1d3a7a
--- /dev/null
+++ b/public/.htaccess
@@ -0,0 +1,8 @@
+
+<IfModule mod_rewrite.c>
+ RewriteEngine on
+
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^ index.php [L]
+</IfModule>
diff --git a/public/css/theme0.css b/public/css/theme0.css
index 4c09a094..050f689e 100644
--- a/public/css/theme0.css
+++ b/public/css/theme0.css
@@ -1,6 +1,6 @@
/*!
- * Bootstrap v3.3.6 (http://getbootstrap.com)
- * Copyright 2011-2015 Twitter, Inc.
+ * Bootstrap v3.3.7 (http://getbootstrap.com)
+ * Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
@@ -1095,7 +1095,6 @@ a:focus {
text-decoration: underline;
}
a:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -2524,7 +2523,6 @@ select[size] {
input[type="file"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -3015,7 +3013,6 @@ select[multiple].input-lg {
.btn.focus,
.btn:active.focus,
.btn.active.focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
diff --git a/public/css/theme1.css b/public/css/theme1.css
index 3b5201b6..06ce9907 100644
--- a/public/css/theme1.css
+++ b/public/css/theme1.css
@@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*!
- * Bootstrap v3.3.6 (http://getbootstrap.com)
- * Copyright 2011-2015 Twitter, Inc.
+ * Bootstrap v3.3.7 (http://getbootstrap.com)
+ * Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
@@ -1118,7 +1118,6 @@ a:focus {
text-decoration: underline;
}
a:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -2547,7 +2546,6 @@ select[size] {
input[type="file"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -3038,7 +3036,6 @@ select[multiple].input-lg {
.btn.focus,
.btn:active.focus,
.btn.active.focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
diff --git a/public/css/theme2.css b/public/css/theme2.css
index 07f2ea10..9ca9babb 100644
--- a/public/css/theme2.css
+++ b/public/css/theme2.css
@@ -1,6 +1,6 @@
/*!
- * Bootstrap v3.3.6 (http://getbootstrap.com)
- * Copyright 2011-2015 Twitter, Inc.
+ * Bootstrap v3.3.7 (http://getbootstrap.com)
+ * Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
@@ -1095,7 +1095,6 @@ a:focus {
text-decoration: underline;
}
a:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -2524,7 +2523,6 @@ select[size] {
input[type="file"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -3015,7 +3013,6 @@ select[multiple].input-lg {
.btn.focus,
.btn:active.focus,
.btn.active.focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
diff --git a/public/css/theme3.css b/public/css/theme3.css
index 2b5358be..abb90f23 100644
--- a/public/css/theme3.css
+++ b/public/css/theme3.css
@@ -8,8 +8,8 @@
color: #000;
}
/*!
- * Bootstrap v3.3.6 (http://getbootstrap.com)
- * Copyright 2011-2015 Twitter, Inc.
+ * Bootstrap v3.3.7 (http://getbootstrap.com)
+ * Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
@@ -1104,7 +1104,6 @@ a:focus {
text-decoration: underline;
}
a:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -2533,7 +2532,6 @@ select[size] {
input[type="file"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -3024,7 +3022,6 @@ select[multiple].input-lg {
.btn.focus,
.btn:active.focus,
.btn.active.focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
diff --git a/public/css/theme4.css b/public/css/theme4.css
index 7f80b411..24771afd 100644
--- a/public/css/theme4.css
+++ b/public/css/theme4.css
@@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*!
- * Bootstrap v3.3.6 (http://getbootstrap.com)
- * Copyright 2011-2015 Twitter, Inc.
+ * Bootstrap v3.3.7 (http://getbootstrap.com)
+ * Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
@@ -1118,7 +1118,6 @@ a:focus {
text-decoration: underline;
}
a:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -2547,7 +2546,6 @@ select[size] {
input[type="file"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -3038,7 +3036,6 @@ select[multiple].input-lg {
.btn.focus,
.btn:active.focus,
.btn.active.focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
diff --git a/public/index.php b/public/index.php
index 85e5b4da..69d92127 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,5 +1,8 @@
<?php
-require_once realpath(__DIR__ . '/../includes/engelsystem_provider.php');
+
+use Engelsystem\Http\Request;
+
+require_once realpath(__DIR__ . '/../includes/engelsystem.php');
$free_pages = [
'admin_event_config',
@@ -16,163 +19,222 @@ $free_pages = [
'stats',
'users',
'user_driver_licenses',
- 'user_password_recovery'
+ 'user_password_recovery',
];
// Gewünschte Seite/Funktion
-$page = "";
-if (! isset($_REQUEST['p'])) {
- $_REQUEST['p'] = isset($user) ? "news" : "login";
+$page = '';
+$title = '';
+$content = '';
+
+/** @var Request $request */
+$request = $app->get('request');
+$page = $request->query->get('p');
+if (empty($page)) {
+ $page = $request->path();
+ $page = str_replace('-', '_', $page);
}
+if ($page == '/') {
+ $page = isset($user) ? 'news' : 'login';
+}
+
+if (
+ preg_match('/^\w*$/i', $page)
+ && (
+ in_array($page, $free_pages)
+ || (isset($privileges) && in_array($page, $privileges))
+ )
+) {
+ $title = $page;
-if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (in_array($_REQUEST['p'], $free_pages) || in_array($_REQUEST['p'], $privileges))) {
- $page = $_REQUEST['p'];
-
- $title = $page;
- $content = "";
-
- if ($page == "api") {
- require_once realpath(__DIR__ . '/../includes/controller/api.php');
- error("Api disabled temporily.");
- redirect(page_link_to('login'));
- api_controller();
- } elseif ($page == "ical") {
- require_once realpath(__DIR__ . '/../includes/pages/user_ical.php');
- user_ical();
- } elseif ($page == "atom") {
- require_once realpath(__DIR__ . '/../includes/pages/user_atom.php');
- user_atom();
- } elseif ($page == "shifts_json_export") {
- require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
- shifts_json_export_controller();
- } elseif ($page == "shifts_json_export_all") {
- require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
- shifts_json_export_all_controller();
- } elseif ($page == "stats") {
- require_once realpath(__DIR__ . '/../includes/pages/guest_stats.php');
- guest_stats();
- } elseif ($page == "user_password_recovery") {
- require_once realpath(__DIR__ . '/../includes/controller/users_controller.php');
- $title = user_password_recovery_title();
- $content = user_password_recovery_controller();
- } elseif ($page == "angeltypes") {
- list($title, $content) = angeltypes_controller();
- } elseif ($page == "shifts") {
- list($title, $content) = shifts_controller();
- } elseif ($page == "users") {
- list($title, $content) = users_controller();
- } elseif ($page == "user_angeltypes") {
- list($title, $content) = user_angeltypes_controller();
- } elseif ($page == "user_driver_licenses") {
- list($title, $content) = user_driver_licenses_controller();
- } elseif ($page == "shifttypes") {
- list($title, $content) = shifttypes_controller();
- } elseif ($page == "admin_event_config") {
- list($title, $content) = event_config_edit_controller();
- } elseif ($page == "rooms") {
- list($title, $content) = rooms_controller();
- } elseif ($page == "news") {
- $title = news_title();
- $content = user_news();
- } elseif ($page == "news_comments") {
- require_once realpath(__DIR__ . '/../includes/pages/user_news.php');
- $title = user_news_comments_title();
- $content = user_news_comments();
- } elseif ($page == "user_meetings") {
- $title = meetings_title();
- $content = user_meetings();
- } elseif ($page == "user_myshifts") {
- $title = myshifts_title();
- $content = user_myshifts();
- } elseif ($page == "user_shifts") {
- $title = shifts_title();
- $content = user_shifts();
- } elseif ($page == "user_messages") {
- $title = messages_title();
- $content = user_messages();
- } elseif ($page == "user_questions") {
- $title = questions_title();
- $content = user_questions();
- } elseif ($page == "user_settings") {
- $title = settings_title();
- $content = user_settings();
- } elseif ($page == "login") {
- $title = login_title();
- $content = guest_login();
- } elseif ($page == "register") {
- $title = register_title();
- $content = guest_register();
- } elseif ($page == "logout") {
- $title = logout_title();
- $content = guest_logout();
- } elseif ($page == "admin_questions") {
- $title = admin_questions_title();
- $content = admin_questions();
- } elseif ($page == "admin_user") {
- $title = admin_user_title();
- $content = admin_user();
- } elseif ($page == "admin_arrive") {
- $title = admin_arrive_title();
- $content = admin_arrive();
- } elseif ($page == "admin_active") {
- $title = admin_active_title();
- $content = admin_active();
- } elseif ($page == "admin_free") {
- $title = admin_free_title();
- $content = admin_free();
- } elseif ($page == "admin_news") {
- require_once realpath(__DIR__ . '/../includes/pages/admin_news.php');
- $content = admin_news();
- } elseif ($page == "admin_rooms") {
- $title = admin_rooms_title();
- $content = admin_rooms();
- } elseif ($page == "admin_groups") {
- $title = admin_groups_title();
- $content = admin_groups();
- } elseif ($page == "admin_language") {
- require_once realpath(__DIR__ . '/../includes/pages/admin_language.php');
- $content = admin_language();
- } elseif ($page == "admin_import") {
- $title = admin_import_title();
- $content = admin_import();
- } elseif ($page == "admin_shifts") {
- $title = admin_shifts_title();
- $content = admin_shifts();
- } elseif ($page == "admin_log") {
- $title = admin_log_title();
- $content = admin_log();
- } elseif ($page == "credits") {
- require_once realpath(__DIR__ . '/../includes/pages/guest_credits.php');
- $title = credits_title();
- $content = guest_credits();
- } else {
- require_once realpath(__DIR__ . '/../includes/pages/guest_start.php');
- $content = guest_start();
- }
+ switch ($page) {
+ case 'api':
+ error('Api disabled temporarily.');
+ redirect(page_link_to());
+ break;
+ case 'ical':
+ require_once realpath(__DIR__ . '/../includes/pages/user_ical.php');
+ user_ical();
+ break;
+ case 'atom':
+ require_once realpath(__DIR__ . '/../includes/pages/user_atom.php');
+ user_atom();
+ break;
+ case 'shifts_json_export':
+ require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
+ shifts_json_export_controller();
+ break;
+ case 'shifts_json_export_all':
+ require_once realpath(__DIR__ . '/../includes/controller/shifts_controller.php');
+ shifts_json_export_all_controller();
+ break;
+ case 'stats':
+ require_once realpath(__DIR__ . '/../includes/pages/guest_stats.php');
+ guest_stats();
+ break;
+ case 'user_password_recovery':
+ require_once realpath(__DIR__ . '/../includes/controller/users_controller.php');
+ $title = user_password_recovery_title();
+ $content = user_password_recovery_controller();
+ break;
+ case 'angeltypes':
+ list($title, $content) = angeltypes_controller();
+ break;
+ case 'shifts':
+ list($title, $content) = shifts_controller();
+ break;
+ case 'users':
+ list($title, $content) = users_controller();
+ break;
+ case 'user_angeltypes':
+ list($title, $content) = user_angeltypes_controller();
+ break;
+ case 'user_driver_licenses':
+ list($title, $content) = user_driver_licenses_controller();
+ break;
+ case 'shifttypes':
+ list($title, $content) = shifttypes_controller();
+ break;
+ case 'admin_event_config':
+ list($title, $content) = event_config_edit_controller();
+ break;
+ case 'rooms':
+ list($title, $content) = rooms_controller();
+ break;
+ case 'news':
+ $title = news_title();
+ $content = user_news();
+ break;
+ case 'news_comments':
+ require_once realpath(__DIR__ . '/../includes/pages/user_news.php');
+ $title = user_news_comments_title();
+ $content = user_news_comments();
+ break;
+ case 'user_meetings':
+ $title = meetings_title();
+ $content = user_meetings();
+ break;
+ case 'user_myshifts':
+ $title = myshifts_title();
+ $content = user_myshifts();
+ break;
+ case 'user_shifts':
+ $title = shifts_title();
+ $content = user_shifts();
+ break;
+ case 'user_messages':
+ $title = messages_title();
+ $content = user_messages();
+ break;
+ case 'user_questions':
+ $title = questions_title();
+ $content = user_questions();
+ break;
+ case 'user_settings':
+ $title = settings_title();
+ $content = user_settings();
+ break;
+ case 'login':
+ $title = login_title();
+ $content = guest_login();
+ break;
+ case 'register':
+ $title = register_title();
+ $content = guest_register();
+ break;
+ case 'logout':
+ $title = logout_title();
+ $content = guest_logout();
+ break;
+ case 'admin_questions':
+ $title = admin_questions_title();
+ $content = admin_questions();
+ break;
+ case 'admin_user':
+ $title = admin_user_title();
+ $content = admin_user();
+ break;
+ case 'admin_arrive':
+ $title = admin_arrive_title();
+ $content = admin_arrive();
+ break;
+ case 'admin_active':
+ $title = admin_active_title();
+ $content = admin_active();
+ break;
+ case 'admin_free':
+ $title = admin_free_title();
+ $content = admin_free();
+ break;
+ case 'admin_news':
+ require_once realpath(__DIR__ . '/../includes/pages/admin_news.php');
+ $content = admin_news();
+ break;
+ case 'admin_rooms':
+ $title = admin_rooms_title();
+ $content = admin_rooms();
+ break;
+ case 'admin_groups':
+ $title = admin_groups_title();
+ $content = admin_groups();
+ break;
+ case 'admin_import':
+ $title = admin_import_title();
+ $content = admin_import();
+ break;
+ case 'admin_shifts':
+ $title = admin_shifts_title();
+ $content = admin_shifts();
+ break;
+ case 'admin_log':
+ $title = admin_log_title();
+ $content = admin_log();
+ break;
+ case 'credits':
+ require_once realpath(__DIR__ . '/../includes/pages/guest_credits.php');
+ $title = credits_title();
+ $content = guest_credits();
+ break;
+ default:
+ require_once realpath(__DIR__ . '/../includes/pages/guest_start.php');
+ $content = guest_start();
+ break;
+ }
} else {
- // Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen
- if (isset($user)) {
- $title = _("No Access");
- $content = _("You don't have permission to view this page. You probably have to sign in or register in order to gain access!");
- } else {
- // Sonst zur Loginseite leiten
- redirect(page_link_to("login"));
- }
+ // Wenn schon eingeloggt, keine-Berechtigung-Seite anzeigen
+ if (isset($user)) {
+ $title = _('No Access');
+ $content = _('You don\'t have permission to view this page . You probably have to sign in or register in order to gain access!');
+ } else {
+ // Sonst zur Loginseite leiten
+ redirect(page_link_to('login'));
+ }
}
$event_config = EventConfig();
-echo template_render(__DIR__ . '/../templates/layout.html', [
- 'theme' => isset($user) ? $user['color'] : $default_theme,
- 'title' => $title,
- 'atom_link' => ($page == 'news' || $page == 'user_meetings') ? '<link href="' . page_link_to('atom') . (($page == 'user_meetings') ? '&amp;meetings=1' : '') . '&amp;key=' . $user['api_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '',
- 'menu' => make_menu(),
- 'content' => msg() . $content,
+$parameters = [
+ 'key' => (isset($user) ? $user['api_key'] : ''),
+];
+if ($page == 'user_meetings') {
+ $parameters['meetings'] = 1;
+}
+
+echo view(__DIR__ . '/../templates/layout.html', [
+ 'theme' => isset($user) ? $user['color'] : config('theme'),
+ 'title' => $title,
+ 'atom_link' => ($page == 'news' || $page == 'user_meetings')
+ ? ' <link href="'
+ . page_link_to('atom', $parameters)
+ . '" type = "application/atom+xml" rel = "alternate" title = "Atom Feed">'
+ : '',
+ 'start_page_url' => page_link_to('/'),
+ 'credits_url' => page_link_to('credits'),
+ 'menu' => make_menu(),
+ 'content' => msg() . $content,
'header_toolbar' => header_toolbar(),
- 'faq_url' => $faq_url,
- 'contact_email' => $contact_email,
- 'locale' => locale(),
- 'event_info' => EventConfig_info($event_config) . '<br />'
+ 'faq_url' => config('faq_url'),
+ 'contact_email' => config('contact_email'),
+ 'locale' => locale(),
+ 'event_info' => EventConfig_info($event_config) . ' <br />'
]);
-
-?>
diff --git a/public/js/forms.js b/public/js/forms.js
index f4e2e042..c4eb68df 100644
--- a/public/js/forms.js
+++ b/public/js/forms.js
@@ -1,28 +1,28 @@
/**
* Runs through the DOM under the element with the given id, finds all
* checkboxes and sets them to the wanted state.
- *
+ *
* @param String
* id Id of the element containing all the checkboxes
* @param Boolean
* checked True if the checkboxes should be checked
*/
function checkAll(id, checked) {
- var obj = document.getElementById(id);
- var boxes = obj.getElementsByTagName("input");
- for (var i = 0; i < boxes.length; i++) {
- if (boxes[i].type === "checkbox" && !boxes[i].disabled) {
- boxes[i].checked = checked;
- }
- }
+ var obj = document.getElementById(id);
+ var boxes = obj.getElementsByTagName("input");
+ for (var i = 0; i < boxes.length; i++) {
+ if (boxes[i].type === "checkbox" && !boxes[i].disabled) {
+ boxes[i].checked = checked;
+ }
+ }
}
-$(function() {
- /**
- * Disable every submit button after clicking (to prevent double-clicking)
- */
- $("form").submit(function(ev) {
- $("input[type='submit']").prop("readonly", true).addClass("disabled");
- return true;
- });
+$(function () {
+ /**
+ * Disable every submit button after clicking (to prevent double-clicking)
+ */
+ $("form").submit(function (ev) {
+ $("input[type='submit']").prop("readonly", true).addClass("disabled");
+ return true;
+ });
});
diff --git a/public/js/moment-countdown.js b/public/js/moment-countdown.js
index 9d655038..0cc78210 100644
--- a/public/js/moment-countdown.js
+++ b/public/js/moment-countdown.js
@@ -3,17 +3,17 @@
* class "moment-countdown" and the attribute "data-timestamp" which defines the
* countdown's time goal.
*/
-$(document).ready(function() {
- if (typeof moment !== "undefined") {
- $.each($(".moment-countdown"), function(i, e) {
- var span = $(e);
- var text = span.html();
- /* global moment */
- var timestamp = moment(parseInt(span.attr("data-timestamp") * 1000));
- span.html(text.replace("%c", timestamp.fromNow()));
- setInterval(function() {
- span.html(text.replace("%c", timestamp.fromNow()));
- }, 1000);
- });
- }
-}); \ No newline at end of file
+$(document).ready(function () {
+ if (typeof moment !== "undefined") {
+ $.each($(".moment-countdown"), function (i, e) {
+ var span = $(e);
+ var text = span.html();
+ /* global moment */
+ var timestamp = moment(parseInt(span.attr("data-timestamp") * 1000));
+ span.html(text.replace("%c", timestamp.fromNow()));
+ setInterval(function () {
+ span.html(text.replace("%c", timestamp.fromNow()));
+ }, 1000);
+ });
+ }
+});
diff --git a/public/js/sticky-headers.js b/public/js/sticky-headers.js
index 1d6e9402..6e6a75e2 100644
--- a/public/js/sticky-headers.js
+++ b/public/js/sticky-headers.js
@@ -1,32 +1,31 @@
/**
* Enables the fixed headers and time lane for the shift-calendar and datatables
*/
-$(document).ready(
- function() {
- if ($(".shift-calendar").length) {
+$(document).ready(function () {
+ if ($(".shift-calendar").length) {
var timeLanes = $(".shift-calendar .time");
var headers = $(".shift-calendar .header");
var topReference = $(".container-fluid .row");
- var top = headers.offset().top;
- var left = 15;
timeLanes.css({
- "position" : "relative",
- "z-index" : 999
+ "position": "relative",
+ "z-index": 999
});
headers.css({
- "position" : "relative",
- "z-index" : 900
+ "position": "relative",
+ "z-index": 900
});
$(window).scroll(
- function() {
- timeLanes.css({
- "left" : Math.max(0, $(window).scrollLeft() - left) + "px"
- });
- headers.css({
- "top" : Math.max(0, $(window).scrollTop() - top
- + topReference.offset().top)
+ function () {
+ var top = headers.parent().offset().top;
+ var left = 15;
+ timeLanes.css({
+ "left": Math.max(0, $(window).scrollLeft() - left) + "px"
+ });
+ headers.css({
+ "top": Math.max(0, $(window).scrollTop() - top
+ + topReference.offset().top)
+ "px"
- });
+ });
});
- }
- }); \ No newline at end of file
+ }
+});
diff --git a/public/maintenance.html b/public/maintenance.html
deleted file mode 100644
index bbdee2af..00000000
--- a/public/maintenance.html
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<title>Maintenance - Engelsystem</title>
-<meta charset="UTF-8" />
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<link rel="stylesheet" type="text/css" href="css/theme0.css" />
-<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css" />
-<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css" />
-<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
-<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
-</head>
-<body>
- <div class="navbar navbar-default navbar-fixed-top">
- <div class="container-fluid">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
- <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="?"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
- </div>
- <div class="collapse navbar-collapse" id="navbar-collapse-1">
- <ul class="nav navbar-nav"></ul>
- <ul class="nav navbar-nav navbar-right">
- </ul>
- </div>
- </div>
- </div>
- <div class="container-fluid">
- <div class="row">
- <div class="jumbotron">
- <div class="container text-center">
- <h1>
- <span class="glyphicon glyphicon-scissors"></span> <span class="glyphicon glyphicon-wrench"></span> <span class="glyphicon glyphicon-fire"></span>
- </h1>
- <div class="col-md-6">
- <h2>
- The <span class="icon-icon_angel"></span> <strong>ENGELSYSTEM</strong> is in maintenance mode.
- </h2>
- <p>This may be due to...</p>
- <p>
- ...archangels closing the gates of heaven. <br>...somebody's stolen the power chord and now the battery is empty. <br>...DHCP decided to give me another ip address.
- </p>
- </div>
- <div class="col-md-6">
- <iframe width="560" height="315" src="https://www.youtube.com/embed/0aV_vHcunSQ?rel=0" frameborder="0" allowfullscreen></iframe>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-12">
- <div class="text-center footer">
- <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a> · <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
- </div>
- </div>
- </div>
- </div>
- <script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
- <script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
- <script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
- <script type="text/javascript" src="vendor/Chart.min.js"></script>
- <script type="text/javascript" src="js/forms.js"></script>
- <script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
- <script type="text/javascript">
- $(function() {
- moment.locale("en_US.UTF-8");
- });
- </script>
- <script type="text/javascript" src="js/moment-countdown.js"></script>
-</body>
-</html>
diff --git a/public/overwhelmed.html b/public/overwhelmed.html
deleted file mode 100644
index e38e9dad..00000000
--- a/public/overwhelmed.html
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<title>Engelsystem</title>
-<meta charset="UTF-8" />
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<link rel="stylesheet" type="text/css" href="css/theme0.css" />
-<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css" />
-<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css" />
-<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
-<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
-</head>
-<body>
- <div class="navbar navbar-default navbar-fixed-top">
- <div class="container-fluid">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
- <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="https://engelsystem.de"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
- </div>
- <div class="collapse navbar-collapse" id="navbar-collapse-1">
- <ul class="nav navbar-nav"></ul>
- <ul class="nav navbar-nav navbar-right">
- </ul>
- </div>
- </div>
- </div>
- <div class="container-fluid">
- <div class="row">
- <div class="jumbotron">
- <div class="container text-center">
- <div class="col-md-6 col-md-offset-3">
- <h2>Dear Angels,</h2>
- <p>The great interest in becoming an angel and participating at 33C3 is is something we are grateful for every time. There is a record number of angels and helping volunteers this year.</p>
- <p>We did anticipate a great number but we are overwhelmed by this endless wave of support. We do want to enable each and every one of you to be an angel at the congress, but sadly our resources and capacities at Heaven are limited. The amount of angels at this point is beyond our
- planing and to ensure we can support the angels already checked in. We did make a choice never thought possible on a chaos event:</p>
- <p>We closed the registration in the Engelsystem and at Heaven Desk at 19:00 27. Dec. 2016.</p>
- <p>Everyone of us works for you to support you in being an angel, but the Heaven Desk and the Kitchen among others are limited and so we decided to focus our effort to support those of you already arrived to the best of our abilities.</p>
- <p>
- For the Heaven Team<br /> Agnes, Jen, LLF and Knuth
- </p>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-12">
- <div class="text-center footer">
- <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a> · <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
- </div>
- </div>
- </div>
- </div>
- <script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
-</body>
-</html>
diff --git a/public/vendor/bootstrap b/public/vendor/bootstrap
index 250b0a66..c4f820a9 120000
--- a/public/vendor/bootstrap
+++ b/public/vendor/bootstrap
@@ -1 +1 @@
-../../themes/assets/bootstrap/dist \ No newline at end of file
+../../vendor/twbs/bootstrap/dist \ No newline at end of file
diff --git a/shift_markup.html b/shift_markup.html
deleted file mode 100644
index 7ad5177a..00000000
--- a/shift_markup.html
+++ /dev/null
@@ -1,86 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="UTF-8" />
-<link rel="stylesheet" type="text/css" href="public/css/theme3.css" />
-<style>
-</style>
-</head>
-<body>
- <div class="shift-calendar">
- <div class="lane time">
- <div class="header">Time</div>
- <div class="tick day">2016-12-27 00:00</div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick hour">11:00</div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick hour">12:00</div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick hour">13:00</div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- </div>
- <div class="lane">
- <div class="header">
- <span class="glyphicon glyphicon-map-marker"></span> Bottle Sorting (Hall H)
- </div>
- <div class="tick day"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="shift panel panel-success" style="height: 160px;">
- <div class="panel-heading">
- <a href="?p=shifts&amp;action=view&amp;shift_id=2696">00:00 ‐ 02:00 — Bottle Collection</a>
- <div class="pull-right">
- <div class="btn-group">
- <a href="?p=user_shifts&amp;edit_shift=2696" class="btn btn-default btn-xs"> <span class="glyphicon glyphicon-edit"></span>
- </a> <a href="?p=user_shifts&amp;delete_shift=2696" class="btn btn-default btn-xs"> <span class="glyphicon glyphicon-trash"></span>
- </a>
- </div>
- </div>
- </div>
- <div class="panel-body">
- <span class="glyphicon glyphicon-info-sign"></span> Bottle Collection Quick Response Team<br> <a href="?p=rooms&amp;action=view&amp;room_id=42"> <span class="glyphicon glyphicon-map-marker"></span> Bottle Sorting (Hall H)
- </a>
- </div>
- <ul class="list-group">
- <li class="list-group-item"><strong><a href="?p=angeltypes&amp;action=view&amp;angeltype_id=104575">Angel</a>:</strong> <span style=""><a class="" href="?p=users&amp;action=view&amp;user_id=1755"><span class="icon-icon_angel"></span> Pantomime</a></span>, <span style=""><a
- class="" href="?p=users&amp;action=view&amp;user_id=50"><span class="icon-icon_angel"></span> sandzwerg</a></span></li>
- <li class="list-group-item"><a href="?p=user_shifts&amp;shift_id=2696&amp;type_id=104575" class="btn btn-default btn-xs">Neue Engel hinzufügen</a></li>
- </ul>
- <div class="shift-spacer"></div>
- </div>
- <div class="tick hour"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- </div>
- <div class="lane">
- <div class="header"></div>
- <div class="tick day"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick hour"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick hour"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick hour"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- <div class="tick"></div>
- </div>
- </div>
-</body>
-</html> \ No newline at end of file
diff --git a/src/Application.php b/src/Application.php
new file mode 100644
index 00000000..c9023c7b
--- /dev/null
+++ b/src/Application.php
@@ -0,0 +1,137 @@
+<?php
+
+namespace Engelsystem;
+
+use Engelsystem\Config\Config;
+use Engelsystem\Container\Container;
+use Engelsystem\Container\ServiceProvider;
+use Psr\Container\ContainerInterface;
+
+class Application extends Container
+{
+ /** @var string|null */
+ protected $appPath = null;
+
+ /** @var bool */
+ protected $isBootstrapped = false;
+
+ /**
+ * Registered service providers
+ *
+ * @var array
+ */
+ protected $serviceProviders = [];
+
+ /**
+ * Application constructor.
+ *
+ * @param string $appPath
+ */
+ public function __construct($appPath = null)
+ {
+ if (!is_null($appPath)) {
+ $this->setAppPath($appPath);
+ }
+
+ $this->registerBaseBindings();
+ }
+
+ protected function registerBaseBindings()
+ {
+ static::setInstance($this);
+ Container::setInstance($this);
+ $this->instance('app', $this);
+ $this->instance('container', $this);
+ $this->instance(Container::class, $this);
+ $this->instance(Application::class, $this);
+ $this->bind(ContainerInterface::class, Application::class);
+ }
+
+ /**
+ * @param string|ServiceProvider $provider
+ * @return ServiceProvider
+ */
+ public function register($provider)
+ {
+ if (is_string($provider)) {
+ $provider = $this->make($provider);
+ }
+
+ $this->serviceProviders[] = $provider;
+
+ $provider->register();
+
+ if ($this->isBootstrapped) {
+ $this->call([$provider, 'boot']);
+ }
+
+ return $provider;
+ }
+
+ /**
+ * Boot service providers
+ *
+ * @param Config|null $config
+ */
+ public function bootstrap(Config $config = null)
+ {
+ if ($this->isBootstrapped) {
+ return;
+ }
+
+ if ($config instanceof Config) {
+ foreach ($config->get('providers', []) as $provider) {
+ $this->register($provider);
+ }
+ }
+
+ foreach ($this->serviceProviders as $provider) {
+ $this->call([$provider, 'boot']);
+ }
+
+ $this->isBootstrapped = true;
+ }
+
+ protected function registerPaths()
+ {
+ $appPath = $this->appPath;
+
+ $this->instance('path', $appPath);
+ $this->instance('path.config', $appPath . DIRECTORY_SEPARATOR . 'config');
+ $this->instance('path.lang', $appPath . DIRECTORY_SEPARATOR . 'locale');
+ }
+
+ /**
+ * Set app base path
+ *
+ * @param string $appPath
+ * @return static
+ */
+ public function setAppPath($appPath)
+ {
+ $appPath = realpath($appPath);
+ $appPath = rtrim($appPath, DIRECTORY_SEPARATOR);
+
+ $this->appPath = $appPath;
+
+ $this->registerPaths();
+
+ return $this;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function path()
+ {
+ return $this->appPath;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isBooted()
+ {
+ return $this->isBootstrapped;
+ }
+}
diff --git a/src/Config/Config.php b/src/Config/Config.php
new file mode 100644
index 00000000..34c21a78
--- /dev/null
+++ b/src/Config/Config.php
@@ -0,0 +1,100 @@
+<?php
+
+namespace Engelsystem\Config;
+
+class Config
+{
+ /**
+ * The config values
+ *
+ * @var array
+ */
+ protected $data = [];
+
+ /**
+ * @param string|null $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function get($key, $default = null)
+ {
+ if (is_null($key)) {
+ return $this->data;
+ }
+
+ if ($this->has($key)) {
+ return $this->data[$key];
+ }
+
+ return $default;
+ }
+
+ /**
+ * @param string|array $key
+ * @param mixed $value
+ */
+ public function set($key, $value = null)
+ {
+ if (is_array($key)) {
+ foreach ($key as $configKey => $configValue) {
+ $this->set($configKey, $configValue);
+ }
+
+ return;
+ }
+
+ $this->data[$key] = $value;
+ }
+
+ /**
+ * @param string $key
+ * @return bool
+ */
+ public function has($key)
+ {
+ return isset($this->data[$key]);
+ }
+
+ /**
+ * @param string $key
+ */
+ public function remove($key)
+ {
+ unset($this->data[$key]);
+ }
+
+ /**
+ * @param string $key
+ * @return mixed
+ */
+ public function __get($key)
+ {
+ return $this->get($key);
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ */
+ public function __set($key, $value)
+ {
+ $this->set($key, $value);
+ }
+
+ /**
+ * @param string $key
+ * @return bool
+ */
+ public function __isset($key)
+ {
+ return $this->has($key);
+ }
+
+ /**
+ * @param string $key
+ */
+ public function __unset($key)
+ {
+ $this->remove($key);
+ }
+}
diff --git a/src/Config/ConfigServiceProvider.php b/src/Config/ConfigServiceProvider.php
new file mode 100644
index 00000000..01b648df
--- /dev/null
+++ b/src/Config/ConfigServiceProvider.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Engelsystem\Config;
+
+use Engelsystem\Container\ServiceProvider;
+
+class ConfigServiceProvider extends ServiceProvider
+{
+ public function register()
+ {
+ $defaultConfigFile = config_path('config.default.php');
+ $configFile = config_path('config.php');
+
+ $config = $this->app->make(Config::class);
+ $this->app->instance('config', $config);
+
+ $config->set(require $defaultConfigFile);
+
+ if (file_exists($configFile)) {
+ $config->set(array_replace_recursive(
+ $config->get(null),
+ require $configFile
+ ));
+ }
+ }
+}
diff --git a/src/Container/Container.php b/src/Container/Container.php
new file mode 100644
index 00000000..44c57b6f
--- /dev/null
+++ b/src/Container/Container.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace Engelsystem\Container;
+
+use Illuminate\Container\Container as IlluminateContainer;
+use Psr\Container\ContainerInterface;
+
+class Container extends IlluminateContainer implements ContainerInterface
+{
+}
diff --git a/src/Container/ServiceProvider.php b/src/Container/ServiceProvider.php
new file mode 100644
index 00000000..2a1bbebf
--- /dev/null
+++ b/src/Container/ServiceProvider.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Engelsystem\Container;
+
+use Engelsystem\Application;
+
+abstract class ServiceProvider
+{
+ /** @var Application */
+ protected $app;
+
+ /**
+ * ServiceProvider constructor.
+ *
+ * @param Application $app
+ */
+ public function __construct(Application $app)
+ {
+ $this->app = $app;
+ }
+
+ /**
+ * Register container bindings
+ */
+ public function register() { }
+
+ /**
+ * Called after other services had been registered
+ */
+ public function boot() { }
+}
diff --git a/src/Database/DatabaseServiceProvider.php b/src/Database/DatabaseServiceProvider.php
new file mode 100644
index 00000000..364816cc
--- /dev/null
+++ b/src/Database/DatabaseServiceProvider.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Engelsystem\Database;
+
+use Engelsystem\Container\ServiceProvider;
+use Exception;
+use PDO;
+
+class DatabaseServiceProvider extends ServiceProvider
+{
+ public function register()
+ {
+ $config = $this->app->get('config');
+ Db::connect(
+ 'mysql:host=' . $config->get('database')['host'] . ';dbname=' . $config->get('database')['db'] . ';charset=utf8',
+ $config->get('database')['user'],
+ $config->get('database')['pw']
+ ) || $this->exitOnError();
+
+ Db::getPdo()->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ Db::getPdo()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+ }
+
+ /**
+ * @throws Exception
+ */
+ protected function exitOnError()
+ {
+ throw new Exception('Error: Unable to connect to database');
+ }
+}
diff --git a/src/Database/Db.php b/src/Database/Db.php
new file mode 100644
index 00000000..7042998f
--- /dev/null
+++ b/src/Database/Db.php
@@ -0,0 +1,188 @@
+<?php
+
+namespace Engelsystem\Database;
+
+use PDO;
+use PDOException;
+use PDOStatement;
+
+class Db
+{
+ /** @var PDO */
+ protected static $db;
+
+ /** @var PDOStatement */
+ protected static $stm = null;
+
+ /** @var bool */
+ protected static $lastStatus = true;
+
+ /**
+ * Connect to database
+ *
+ * @param string $dsn
+ * @param string $username
+ * @param string $password
+ * @param array $options
+ * @return bool
+ */
+ public static function connect($dsn, $username = null, $password = null, $options = [])
+ {
+ try {
+ self::$db = new PDO($dsn, $username, $password, $options);
+ } catch (PDOException $e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Run a prepared query
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return PDOStatement
+ */
+ public static function query($query, array $bindings = [])
+ {
+ self::$stm = self::$db->prepare($query);
+ self::$lastStatus = self::$stm->execute($bindings);
+
+ return self::$stm;
+ }
+
+ /**
+ * Run a sql query
+ *
+ * @param string $query
+ * @return bool
+ */
+ public static function unprepared($query)
+ {
+ self::$stm = self::$db->query($query);
+ self::$lastStatus = (self::$stm instanceof PDOStatement);
+
+ return self::$lastStatus;
+ }
+
+ /**
+ * Run a select query
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return array
+ */
+ public static function select($query, array $bindings = [])
+ {
+ self::query($query, $bindings);
+
+ return self::$stm->fetchAll(PDO::FETCH_ASSOC);
+ }
+
+ /**
+ * Run a select query and return only the first result or null if no result is found.
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return array|null
+ */
+ public static function selectOne($query, array $bindings = [])
+ {
+ $result = self::select($query, $bindings);
+
+ if (empty($result)) {
+ return null;
+ }
+
+ return array_shift($result);
+ }
+
+ /**
+ * Run an insert query
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return int Row count
+ */
+ public static function insert($query, array $bindings = [])
+ {
+ self::query($query, $bindings);
+
+ return self::$stm->rowCount();
+ }
+
+ /**
+ * Run an update query
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return int
+ */
+ public static function update($query, array $bindings = [])
+ {
+ self::query($query, $bindings);
+
+ return self::$stm->rowCount();
+ }
+
+ /**
+ * Run a delete query
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return int
+ */
+ public static function delete($query, array $bindings = [])
+ {
+ self::query($query, $bindings);
+
+ return self::$stm->rowCount();
+ }
+
+ /**
+ * Run a single statement
+ *
+ * @param string $query
+ * @param array $bindings
+ * @return bool
+ */
+ public static function statement($query, array $bindings = [])
+ {
+ self::query($query, $bindings);
+
+ return self::$lastStatus;
+ }
+
+ /**
+ * Returns the last error
+ *
+ * @return array
+ */
+ public static function getError()
+ {
+ if (!self::$stm instanceof PDOStatement) {
+ return [-1, null, null];
+ }
+
+ return self::$stm->errorInfo();
+ }
+
+ /**
+ * Get the PDO instance
+ *
+ * @return PDO
+ */
+ public static function getPdo()
+ {
+ return self::$db;
+ }
+
+ /**
+ * @return PDOStatement|false|null
+ */
+ public static function getStm()
+ {
+ return self::$stm;
+ }
+}
diff --git a/src/Exceptions/ExceptionsServiceProvider.php b/src/Exceptions/ExceptionsServiceProvider.php
new file mode 100644
index 00000000..a9bc2b17
--- /dev/null
+++ b/src/Exceptions/ExceptionsServiceProvider.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace Engelsystem\Exceptions;
+
+use Engelsystem\Container\ServiceProvider;
+use Engelsystem\Exceptions\Handlers\HandlerInterface;
+use Engelsystem\Exceptions\Handlers\Legacy;
+use Engelsystem\Exceptions\Handlers\LegacyDevelopment;
+use Engelsystem\Exceptions\Handlers\Whoops;
+use Whoops\Run as WhoopsRunner;
+
+class ExceptionsServiceProvider extends ServiceProvider
+{
+ public function register()
+ {
+ $errorHandler = $this->app->make(Handler::class);
+ $this->addProductionHandler($errorHandler);
+ $this->addDevelopmentHandler($errorHandler);
+ $this->app->instance('error.handler', $errorHandler);
+ $this->app->bind(Handler::class, 'error.handler');
+ $errorHandler->register();
+ }
+
+ public function boot()
+ {
+ /** @var Handler $handler */
+ $handler = $this->app->get('error.handler');
+ $request = $this->app->get('request');
+
+ $handler->setRequest($request);
+ }
+
+ /**
+ * @param Handler $errorHandler
+ */
+ protected function addProductionHandler($errorHandler)
+ {
+ $handler = $this->app->make(Legacy::class);
+ $this->app->instance('error.handler.production', $handler);
+ $errorHandler->setHandler(Handler::ENV_PRODUCTION, $handler);
+ $this->app->bind(HandlerInterface::class, 'error.handler.production');
+ }
+
+ /**
+ * @param Handler $errorHandler
+ */
+ protected function addDevelopmentHandler($errorHandler)
+ {
+ $handler = $this->app->make(LegacyDevelopment::class);
+
+ if (class_exists(WhoopsRunner::class)) {
+ $handler = $this->app->make(Whoops::class);
+ }
+
+ $this->app->instance('error.handler.development', $handler);
+ $errorHandler->setHandler(Handler::ENV_DEVELOPMENT, $handler);
+ }
+}
diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php
new file mode 100644
index 00000000..ee15717a
--- /dev/null
+++ b/src/Exceptions/Handler.php
@@ -0,0 +1,135 @@
+<?php
+
+namespace Engelsystem\Exceptions;
+
+use Engelsystem\Exceptions\Handlers\HandlerInterface;
+use Engelsystem\Http\Request;
+use ErrorException;
+use Throwable;
+
+class Handler
+{
+ /** @var string */
+ protected $environment;
+
+ /** @var HandlerInterface[] */
+ protected $handler = [];
+
+ /** @var Request */
+ protected $request;
+
+ const ENV_PRODUCTION = 'prod';
+ const ENV_DEVELOPMENT = 'dev';
+
+ /**
+ * Handler constructor.
+ *
+ * @param string $environment prod|dev
+ */
+ public function __construct($environment = self::ENV_PRODUCTION)
+ {
+ $this->environment = $environment;
+ }
+
+ /**
+ * Activate the error handler
+ */
+ public function register()
+ {
+ set_error_handler([$this, 'errorHandler']);
+ set_exception_handler([$this, 'exceptionHandler']);
+ }
+
+ /**
+ * @param int $number
+ * @param string $message
+ * @param string $file
+ * @param int $line
+ */
+ public function errorHandler($number, $message, $file, $line)
+ {
+ $exception = new ErrorException($message, 0, $number, $file, $line);
+ $this->exceptionHandler($exception);
+ }
+
+ /**
+ * @param Throwable $e
+ */
+ public function exceptionHandler($e)
+ {
+ if (!$this->request instanceof Request) {
+ $this->request = new Request();
+ }
+
+ $handler = $this->handler[$this->environment];
+ $handler->report($e);
+ $handler->render($this->request, $e);
+ $this->die();
+ }
+
+ /**
+ * Exit the application
+ *
+ * @codeCoverageIgnore
+ * @param string $message
+ */
+ protected function die($message = '')
+ {
+ echo $message;
+ die();
+ }
+
+ /**
+ * @return string
+ */
+ public function getEnvironment()
+ {
+ return $this->environment;
+ }
+
+ /**
+ * @param string $environment
+ */
+ public function setEnvironment($environment)
+ {
+ $this->environment = $environment;
+ }
+
+ /**
+ * @param string $environment
+ * @return HandlerInterface|HandlerInterface[]
+ */
+ public function getHandler($environment = null)
+ {
+ if (!is_null($environment)) {
+ return $this->handler[$environment];
+ }
+
+ return $this->handler;
+ }
+
+ /**
+ * @param string $environment
+ * @param HandlerInterface $handler
+ */
+ public function setHandler($environment, HandlerInterface $handler)
+ {
+ $this->handler[$environment] = $handler;
+ }
+
+ /**
+ * @return Request
+ */
+ public function getRequest()
+ {
+ return $this->request;
+ }
+
+ /**
+ * @param Request $request
+ */
+ public function setRequest(Request $request)
+ {
+ $this->request = $request;
+ }
+}
diff --git a/src/Exceptions/Handlers/HandlerInterface.php b/src/Exceptions/Handlers/HandlerInterface.php
new file mode 100644
index 00000000..9de33e1f
--- /dev/null
+++ b/src/Exceptions/Handlers/HandlerInterface.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Engelsystem\Exceptions\Handlers;
+
+use Engelsystem\Http\Request;
+use Throwable;
+
+interface HandlerInterface
+{
+ /**
+ * @param Request $request
+ * @param Throwable $e
+ */
+ public function render($request, Throwable $e);
+
+ /**
+ * @param Throwable $e
+ * @return
+ */
+ public function report(Throwable $e);
+}
diff --git a/src/Exceptions/Handlers/Legacy.php b/src/Exceptions/Handlers/Legacy.php
new file mode 100644
index 00000000..39683f72
--- /dev/null
+++ b/src/Exceptions/Handlers/Legacy.php
@@ -0,0 +1,42 @@
+<?php
+
+namespace Engelsystem\Exceptions\Handlers;
+
+use Engelsystem\Http\Request;
+use Throwable;
+
+class Legacy implements HandlerInterface
+{
+ /**
+ * @param Request $request
+ * @param Throwable $e
+ */
+ public function render($request, Throwable $e)
+ {
+ echo 'An <del>un</del>expected error occurred, a team of untrained monkeys has been dispatched to deal with it.';
+ }
+
+ /**
+ * @param Throwable $e
+ */
+ public function report(Throwable $e)
+ {
+ error_log(sprintf('Exception: Code: %s, Message: %s, File: %s:%u, Trace: %s',
+ $e->getCode(),
+ $e->getMessage(),
+ $this->stripBasePath($e->getFile()),
+ $e->getLine(),
+ json_encode($e->getTrace())
+ ));
+ }
+
+ /**
+ * @param string $path
+ * @return string
+ */
+ protected function stripBasePath($path)
+ {
+ $basePath = realpath(__DIR__ . '/../../..') . '/';
+ return str_replace($basePath, '', $path);
+ }
+}
diff --git a/src/Exceptions/Handlers/LegacyDevelopment.php b/src/Exceptions/Handlers/LegacyDevelopment.php
new file mode 100644
index 00000000..86f86f4c
--- /dev/null
+++ b/src/Exceptions/Handlers/LegacyDevelopment.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace Engelsystem\Exceptions\Handlers;
+
+use Engelsystem\Http\Request;
+use Throwable;
+
+class LegacyDevelopment extends Legacy
+{
+ /**
+ * @param Request $request
+ * @param Throwable $e
+ */
+ public function render($request, Throwable $e)
+ {
+ $file = $this->stripBasePath($e->getFile());
+
+ echo '<pre style="background-color:#333;color:#ccc;z-index:1000;position:fixed;bottom:1em;padding:1em;width:97%;max-height: 90%;overflow-y:auto;">';
+ echo sprintf('%s: (%s)' . PHP_EOL, get_class($e), $e->getCode());
+ $data = [
+ 'string' => $e->getMessage(),
+ 'file' => $file . ':' . $e->getLine(),
+ 'stacktrace' => $this->formatStackTrace($e->getTrace()),
+ ];
+ var_dump($data);
+ echo '</pre>';
+ }
+
+ /**
+ * @param array $stackTrace
+ * @return array
+ */
+ protected function formatStackTrace($stackTrace)
+ {
+ $return = [];
+ $stackTrace = array_reverse($stackTrace);
+
+ foreach ($stackTrace as $trace) {
+ $path = '';
+ $line = '';
+
+ if (isset($trace['file']) && isset($trace['line'])) {
+ $path = $this->stripBasePath($trace['file']);
+ $line = $trace['line'];
+ }
+
+ $functionName = $trace['function'];
+
+ $return[] = [
+ 'file' => $path . ':' . $line,
+ $functionName => isset($trace['args']) ? $trace['args'] : null,
+ ];
+ }
+
+ return $return;
+ }
+}
diff --git a/src/Exceptions/Handlers/Whoops.php b/src/Exceptions/Handlers/Whoops.php
new file mode 100644
index 00000000..807f5eb0
--- /dev/null
+++ b/src/Exceptions/Handlers/Whoops.php
@@ -0,0 +1,85 @@
+<?php
+
+namespace Engelsystem\Exceptions\Handlers;
+
+use Engelsystem\Application;
+use Engelsystem\Container\Container;
+use Engelsystem\Http\Request;
+use Throwable;
+use Whoops\Handler\JsonResponseHandler;
+use Whoops\Handler\PrettyPageHandler;
+use Whoops\Run as WhoopsRunner;
+
+class Whoops extends Legacy implements HandlerInterface
+{
+ /** @var Application */
+ protected $app;
+
+ public function __construct(Container $app)
+ {
+ $this->app = $app;
+ }
+
+ /**
+ * @param Request $request
+ * @param Throwable $e
+ */
+ public function render($request, Throwable $e)
+ {
+ $whoops = $this->app->make(WhoopsRunner::class);
+ $handler = $this->getPrettyPageHandler($e);
+ $whoops->pushHandler($handler);
+
+ if ($request->isXmlHttpRequest()) {
+ $handler = $this->getJsonResponseHandler();
+ $whoops->pushHandler($handler);
+ }
+
+ echo $whoops->handleException($e);
+ }
+
+ /**
+ * @param Throwable $e
+ * @return PrettyPageHandler
+ */
+ protected function getPrettyPageHandler(Throwable $e)
+ {
+ $handler = $this->app->make(PrettyPageHandler::class);
+
+ $handler->setPageTitle('Just another ' . get_class($e) . ' to fix :(');
+ $handler->setApplicationPaths([realpath(__DIR__ . '/../..')]);
+
+ $data = $this->getData();
+ $handler->addDataTable('Application', $data);
+
+ return $handler;
+ }
+
+ /**
+ * @return JsonResponseHandler
+ */
+ protected function getJsonResponseHandler()
+ {
+ $handler = $this->app->make(JsonResponseHandler::class);
+ $handler->setJsonApi(true);
+ $handler->addTraceToOutput(true);
+
+ return $handler;
+ }
+
+ /**
+ * Aggregate application data
+ *
+ * @return array
+ */
+ protected function getData()
+ {
+ global $user;
+
+ $data = [];
+ $data['user'] = $user;
+ $data['Booted'] = $this->app->isBooted();
+
+ return $data;
+ }
+}
diff --git a/src/Http/Request.php b/src/Http/Request.php
new file mode 100644
index 00000000..c6a9e5ad
--- /dev/null
+++ b/src/Http/Request.php
@@ -0,0 +1,67 @@
+<?php
+
+namespace Engelsystem\Http;
+
+use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
+
+class Request extends SymfonyRequest
+{
+ /**
+ * Get POST input
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function postData($key, $default = null)
+ {
+ return $this->request->get($key, $default);
+ }
+
+ /**
+ * Get input data
+ *
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function input($key, $default = null)
+ {
+ return $this->get($key, $default);
+ }
+
+ /**
+ * Checks if the input exists
+ *
+ * @param string $key
+ * @return bool
+ */
+ public function has($key)
+ {
+ $value = $this->input($key);
+
+ return !is_null($value);
+ }
+
+ /**
+ * Get the requested path
+ *
+ * @return string
+ */
+ public function path()
+ {
+ $pattern = trim($this->getPathInfo(), '/');
+
+ return $pattern == '' ? '/' : $pattern;
+ }
+
+ /**
+ * Return the current URL
+ *
+ * @return string
+ */
+ public function url()
+ {
+ return rtrim(preg_replace('/\?.*/', '', $this->getUri()), '/');
+ }
+}
diff --git a/src/Http/RequestServiceProvider.php b/src/Http/RequestServiceProvider.php
new file mode 100644
index 00000000..077e9ecc
--- /dev/null
+++ b/src/Http/RequestServiceProvider.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace Engelsystem\Http;
+
+use Engelsystem\Container\ServiceProvider;
+
+class RequestServiceProvider extends ServiceProvider
+{
+ public function register()
+ {
+ $request = $this->app->call([Request::class, 'createFromGlobals']);
+ $this->app->instance('request', $request);
+ }
+}
diff --git a/src/Http/SessionServiceProvider.php b/src/Http/SessionServiceProvider.php
new file mode 100644
index 00000000..55e3f48b
--- /dev/null
+++ b/src/Http/SessionServiceProvider.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Engelsystem\Http;
+
+use Engelsystem\Container\ServiceProvider;
+use Symfony\Component\HttpFoundation\Session\Session;
+use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
+use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
+use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
+
+class SessionServiceProvider extends ServiceProvider
+{
+ public function register()
+ {
+ $sessionStorage = $this->getSessionStorage();
+ $this->app->instance('session.storage', $sessionStorage);
+ $this->app->bind(SessionStorageInterface::class, 'session.storage');
+
+ $session = $this->app->make(Session::class);
+ $this->app->instance('session', $session);
+
+ /** @var Request $request */
+ $request = $this->app->get('request');
+ $request->setSession($session);
+
+ $session->start();
+ }
+
+ /**
+ * Returns the session storage
+ *
+ * @return SessionStorageInterface
+ */
+ protected function getSessionStorage()
+ {
+ if ($this->isCli()) {
+ return $this->app->make(MockArraySessionStorage::class);
+ }
+
+ return $this->app->make(NativeSessionStorage::class, ['options' => ['cookie_httponly' => true]]);
+ }
+
+ /**
+ * Test if is called from cli
+ *
+ * @return bool
+ */
+ protected function isCli()
+ {
+ return PHP_SAPI == 'cli';
+ }
+}
diff --git a/src/Logger/EngelsystemLogger.php b/src/Logger/EngelsystemLogger.php
new file mode 100644
index 00000000..1f255b69
--- /dev/null
+++ b/src/Logger/EngelsystemLogger.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Engelsystem\Logger;
+
+use Psr\Log\AbstractLogger;
+use Psr\Log\InvalidArgumentException;
+use Psr\Log\LogLevel;
+
+class EngelsystemLogger extends AbstractLogger
+{
+ protected $allowedLevels = [
+ LogLevel::ALERT,
+ LogLevel::CRITICAL,
+ LogLevel::DEBUG,
+ LogLevel::EMERGENCY,
+ LogLevel::ERROR,
+ LogLevel::INFO,
+ LogLevel::NOTICE,
+ LogLevel::WARNING,
+ ];
+
+ /**
+ * Logs with an arbitrary level.
+ *
+ * @TODO: Implement $context['exception']
+ *
+ * @param mixed $level
+ * @param string $message
+ * @param array $context
+ *
+ * @throws InvalidArgumentException
+ */
+ public function log($level, $message, array $context = [])
+ {
+ if (!$this->checkLevel($level)) {
+ throw new InvalidArgumentException();
+ }
+
+ $message = $this->interpolate($message, $context);
+
+ LogEntry_create($level, $message);
+ }
+
+ /**
+ * Interpolates context values into the message placeholders.
+ *
+ * @param string $message
+ * @param array $context
+ * @return string
+ */
+ protected function interpolate($message, array $context = [])
+ {
+ foreach ($context as $key => $val) {
+ // check that the value can be casted to string
+ if (is_array($val) || (is_object($val) && !method_exists($val, '__toString'))) {
+ continue;
+ }
+
+ // replace the values of the message
+ $message = str_replace('{' . $key . '}', $val, $message);
+ }
+
+ return $message;
+ }
+
+ /**
+ * @param string $level
+ * @return bool
+ */
+ protected function checkLevel($level)
+ {
+ return in_array($level, $this->allowedLevels);
+ }
+}
diff --git a/src/Logger/LoggerServiceProvider.php b/src/Logger/LoggerServiceProvider.php
new file mode 100644
index 00000000..cf22f383
--- /dev/null
+++ b/src/Logger/LoggerServiceProvider.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace Engelsystem\Logger;
+
+use Engelsystem\Container\ServiceProvider;
+use Psr\Log\LoggerInterface;
+
+class LoggerServiceProvider extends ServiceProvider
+{
+ public function register()
+ {
+ $logger = $this->app->make(EngelsystemLogger::class);
+ $this->app->instance('logger', $logger);
+
+ $this->app->bind(LoggerInterface::class, 'logger');
+ $this->app->bind(EngelsystemLogger::class, 'logger');
+ }
+}
diff --git a/src/Renderer/EngineInterface.php b/src/Renderer/EngineInterface.php
new file mode 100644
index 00000000..ca468db5
--- /dev/null
+++ b/src/Renderer/EngineInterface.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Engelsystem\Renderer;
+
+interface EngineInterface
+{
+ /**
+ * Render a template
+ *
+ * @param string $path
+ * @param mixed[] $data
+ * @return string
+ */
+ public function get($path, $data = []);
+
+ /**
+ * @param string $path
+ * @return bool
+ */
+ public function canRender($path);
+}
diff --git a/src/Renderer/HtmlEngine.php b/src/Renderer/HtmlEngine.php
new file mode 100644
index 00000000..75343bbd
--- /dev/null
+++ b/src/Renderer/HtmlEngine.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Engelsystem\Renderer;
+
+class HtmlEngine implements EngineInterface
+{
+ /**
+ * Render a template
+ *
+ * @param string $path
+ * @param mixed[] $data
+ * @return string
+ */
+ public function get($path, $data = [])
+ {
+ $template = file_get_contents($path);
+ if (is_array($data)) {
+ foreach ($data as $name => $content) {
+ $template = str_replace('%' . $name . '%', $content, $template);
+ }
+ }
+
+ return $template;
+ }
+
+ /**
+ * @param string $path
+ * @return bool
+ */
+ public function canRender($path)
+ {
+ return strpos($path, '.htm') && file_exists($path);
+ }
+}
diff --git a/src/Renderer/Renderer.php b/src/Renderer/Renderer.php
new file mode 100644
index 00000000..de31ca74
--- /dev/null
+++ b/src/Renderer/Renderer.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Engelsystem\Renderer;
+
+use Psr\Log\LoggerAwareTrait;
+
+class Renderer
+{
+ use LoggerAwareTrait;
+
+ /** @var EngineInterface[] */
+ protected $renderer = [];
+
+ /**
+ * Render a template
+ *
+ * @param string $template
+ * @param mixed[] $data
+ * @return string
+ */
+ public function render($template, $data = [])
+ {
+ foreach ($this->renderer as $renderer) {
+ if (!$renderer->canRender($template)) {
+ continue;
+ }
+
+ return $renderer->get($template, $data);
+ }
+
+ if ($this->logger) {
+ $this->logger->error('Unable to find a renderer for template file "{file}"', ['file' => $template]);
+ }
+
+ return '';
+ }
+
+ /**
+ * Add a new renderer engine
+ *
+ * @param EngineInterface $renderer
+ */
+ public function addRenderer(EngineInterface $renderer)
+ {
+ $this->renderer[] = $renderer;
+ }
+}
diff --git a/src/Renderer/RendererServiceProvider.php b/src/Renderer/RendererServiceProvider.php
new file mode 100644
index 00000000..3e8d69bc
--- /dev/null
+++ b/src/Renderer/RendererServiceProvider.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Engelsystem\Renderer;
+
+use Engelsystem\Container\ServiceProvider;
+
+class RendererServiceProvider extends ServiceProvider
+{
+ public function register()
+ {
+ $this->registerRenderer();
+ $this->registerHtmlEngine();
+ }
+
+ public function boot()
+ {
+ $renderer = $this->app->get('renderer');
+
+ foreach ($this->app->tagged('renderer.engine') as $engine) {
+ $renderer->addRenderer($engine);
+ }
+ }
+
+ protected function registerRenderer()
+ {
+ $renderer = $this->app->make(Renderer::class);
+ $this->app->instance('renderer', $renderer);
+ }
+
+ protected function registerHtmlEngine()
+ {
+ $htmlEngine = $this->app->make(HtmlEngine::class);
+ $this->app->instance('renderer.htmlEngine', $htmlEngine);
+ $this->app->tag('renderer.htmlEngine', ['renderer.engine']);
+ }
+}
diff --git a/src/Routing/RoutingServiceProvider.php b/src/Routing/RoutingServiceProvider.php
new file mode 100644
index 00000000..b7db1383
--- /dev/null
+++ b/src/Routing/RoutingServiceProvider.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace Engelsystem\Routing;
+
+use Engelsystem\Container\ServiceProvider;
+
+class RoutingServiceProvider extends ServiceProvider
+{
+ public function register()
+ {
+ $urlGenerator = $this->app->make(UrlGenerator::class);
+ $this->app->instance('routing.urlGenerator', $urlGenerator);
+ }
+}
diff --git a/src/Routing/UrlGenerator.php b/src/Routing/UrlGenerator.php
new file mode 100644
index 00000000..6df52425
--- /dev/null
+++ b/src/Routing/UrlGenerator.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Engelsystem\Routing;
+
+class UrlGenerator
+{
+ /**
+ * @param string $path
+ * @param array $parameters
+ * @return string
+ */
+ public function to($path, $parameters = [])
+ {
+ $path = '/' . ltrim($path, '/');
+ $request = app('request');
+ $uri = $request->getUriForPath($path);
+
+ if (!empty($parameters) && is_array($parameters)) {
+ $parameters = http_build_query($parameters);
+ $uri .= '?' . $parameters;
+ }
+
+ return $uri;
+ }
+}
diff --git a/src/helpers.php b/src/helpers.php
new file mode 100644
index 00000000..5a48498a
--- /dev/null
+++ b/src/helpers.php
@@ -0,0 +1,144 @@
+<?php
+// Some useful functions
+
+use Engelsystem\Application;
+use Engelsystem\Config\Config;
+use Engelsystem\Http\Request;
+use Engelsystem\Renderer\Renderer;
+use Engelsystem\Routing\UrlGenerator;
+use Symfony\Component\HttpFoundation\Session\SessionInterface;
+
+/**
+ * Get the global app instance
+ *
+ * @param string $id
+ * @return mixed
+ */
+function app($id = null)
+{
+ if (is_null($id)) {
+ return Application::getInstance();
+ }
+
+ return Application::getInstance()->get($id);
+}
+
+/**
+ * @param string $path
+ * @return string
+ */
+function base_path($path = '')
+{
+ return app('path') . (empty($path) ? '' : DIRECTORY_SEPARATOR . $path);
+}
+
+/**
+ * Get or set config values
+ *
+ * @param string|array $key
+ * @param mixed $default
+ * @return mixed|Config
+ */
+function config($key = null, $default = null)
+{
+ $config = app('config');
+
+ if (empty($key)) {
+ return $config;
+ }
+
+ if (is_array($key)) {
+ $config->set($key);
+ return true;
+ }
+
+ return $config->get($key, $default);
+}
+
+/**
+ * @param string $path
+ * @return string
+ */
+function config_path($path = '')
+{
+ return app('path.config') . (empty($path) ? '' : DIRECTORY_SEPARATOR . $path);
+}
+
+/**
+ * @param string $key
+ * @param mixed $default
+ * @return mixed
+ */
+function env($key, $default = null)
+{
+ $value = getenv($key);
+ if ($value === false) {
+ return $default;
+ }
+
+ return $value;
+}
+
+/**
+ * @param string $key
+ * @param mixed $default
+ * @return Request|mixed
+ */
+function request($key = null, $default = null)
+{
+ $request = app('request');
+
+ if (is_null($key)) {
+ return $request;
+ }
+
+ return $request->input($key, $default);
+}
+
+/**
+ * @param string $key
+ * @param mixed $default
+ * @return SessionInterface|mixed
+ */
+function session($key = null, $default = null)
+{
+ $session = app('session');
+
+ if (is_null($key)) {
+ return $session;
+ }
+
+ return $session->get($key, $default);
+}
+
+/**
+ * @param string $path
+ * @param array $parameters
+ * @return UrlGenerator|string
+ */
+function url($path = null, $parameters = [])
+{
+ $urlGenerator = app('routing.urlGenerator');
+
+ if (is_null($path)) {
+ return $urlGenerator;
+ }
+
+ return $urlGenerator->to($path, $parameters);
+}
+
+/**
+ * @param string $template
+ * @param mixed[] $data
+ * @return Renderer|string
+ */
+function view($template = null, $data = null)
+{
+ $renderer = app('renderer');
+
+ if (is_null($template)) {
+ return $renderer;
+ }
+
+ return $renderer->render($template, $data);
+}
diff --git a/templates/guest_credits.html b/templates/guest_credits.html
index 472676db..db7fac57 100644
--- a/templates/guest_credits.html
+++ b/templates/guest_credits.html
@@ -1,27 +1,36 @@
<div class="container">
-<h1>Credits</h1>
- <div class="row">
- <div class="col-md-4">
- <h2>Source code</h2>
- <p>
- The original system was written by <a href="https://github.com/cookieBerlin/engelsystem">cookie</a>. It was then completely rewritten and greatly enhanced by <a href="http://notrademark.de/">msquare</a> and <a href="http://mortzu.de/">mortzu</a> of <a href="http://planetcyborg.de">planet
- cyborg</a>, <a href="http://jplitza.de/">jplitza</a> and gnomus.
- </p>
- <p>
- Please look at the <a href="https://github.com/engelsystem/engelsystem/graphs/contributors">contributor list on github</a> for a more complete version.
- </p>
+ <h1>Credits</h1>
+ <div class="row">
+ <div class="col-md-4">
+ <h2>Source code</h2>
+ <p>
+ The original system was written by <a href="https://github.com/cookieBerlin/engelsystem">cookie</a>.
+ It was then completely rewritten and enhanced by
+ <a href="http://notrademark.de/">msquare</a> (maintainer),
+ <a href="http://myigel.name/">MyIgel</a>,
+ <a href="http://mortzu.de/">mortzu</a>,
+ <a href="http://jplitza.de/">jplitza</a> and
+ gnomus.
+ </p>
+ <p>
+ Please look at the <a href="https://github.com/engelsystem/engelsystem/graphs/contributors">contributor
+ list on github</a> for a more complete version.
+ </p>
+ </div>
+ <div class="col-md-4">
+ <h2>Hosting</h2>
+ <p>
+ Webspace, development platform and domain on <a href="https://engelsystem.de">engelsystem.de</a>
+ is currently provided by <a href="https://www.wybt.net/">would you buy this?</a> (ichdasich)
+ and adminstrated by <a href="http://mortzu.de/">mortzu</a>,
+ <a href="http://derf.homelinux.org/">derf</a> and ichdasich.
+ </p>
+ </div>
+ <div class="col-md-4">
+ <h2>Translation</h2>
+ <p>
+ Many thanks for the german translation: <a href="http://e7p.de">e7p</a>
+ </p>
+ </div>
</div>
- <div class="col-md-4">
- <h2>Hosting</h2>
- <p>
- Webspace, development platform and domain is currently provided by <a href="https://www.wybt.net/">would you buy this?</a> (ichdasich)<br /> and adminstrated by <a href="http://mortzu.de/">mortzu</a>, <a href="http://derf.homelinux.org/">derf</a> and ichdasich.
- </p>
- </div>
- <div class="col-md-4">
- <h2>Translation</h2>
- <p>
- Many thanks for the german translation: <a href="http://e7p.de">e7p</a>
- </p>
- </div>
- </div>
-</div> \ No newline at end of file
+</div>
diff --git a/templates/layout.html b/templates/layout.html
index 6a1ddb5d..4b9aa06e 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -1,53 +1,62 @@
<!DOCTYPE html>
<html>
<head>
-<title>%title% - Engelsystem</title>
-<meta charset="UTF-8" />
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<link rel="stylesheet" type="text/css" href="css/theme%theme%.css" />
-<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css" />
-<link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css" />
-<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
-<script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
-%atom_link%
+ <title>%title% - Engelsystem</title>
+ <meta charset="UTF-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" type="text/css" href="css/theme%theme%.css"/>
+ <link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css"/>
+ <link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css"/>
+ <script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
+ <script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
+ %atom_link%
</head>
<body>
- <div class="navbar navbar-default navbar-fixed-top">
+<div class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1">
- <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
- </button>
- <a class="navbar-brand" href="?"><span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong></a>
- </div>
- <div class="collapse navbar-collapse" id="navbar-collapse-1">%menu% %header_toolbar%</div>
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed"
+ data-toggle="collapse" data-target="#navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="%start_page_url%">
+ <span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong>
+ </a>
+ </div>
+ <div class="collapse navbar-collapse" id="navbar-collapse-1">%menu% %header_toolbar%</div>
</div>
- </div>
- <div class="container-fluid">
+</div>
+<div class="container-fluid">
<div class="row">%content%</div>
<div class="row">
- <div class="col-md-12">
- <hr />
- <div class="text-center footer" style="margin-bottom: 10px;">
- %event_info%
- <a href="%faq_url%">FAQ</a> · <a href="%contact_email%"><span class="glyphicon glyphicon-envelope"></span> Contact</a> · <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a> · <a href="https://github.com/engelsystem/engelsystem/">Development
- Platform</a> · <a href="?p=credits">Credits</a>
+ <div class="col-md-12">
+ <hr/>
+ <div class="text-center footer" style="margin-bottom: 10px;">
+ %event_info%
+ <a href="%faq_url%">FAQ</a>
+ · <a href="%contact_email%"><span class="glyphicon glyphicon-envelope"></span> Contact</a>
+ · <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a>
+ · <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
+ · <a href="%credits_url%">Credits</a>
+ </div>
</div>
- </div>
</div>
- </div>
- <script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
- <script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
- <script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
- <script type="text/javascript" src="vendor/Chart.min.js"></script>
- <script type="text/javascript" src="js/forms.js"></script>
- <script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
- <script type="text/javascript">
- $(function() {
- moment.locale("%locale%");
- });
- </script>
- <script type="text/javascript" src="js/moment-countdown.js"></script>
- <script type="text/javascript" src="js/sticky-headers.js"></script>
+</div>
+<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
+<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
+<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
+<script type="text/javascript" src="vendor/Chart.min.js"></script>
+<script type="text/javascript" src="js/forms.js"></script>
+<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
+<script type="text/javascript">
+ $(function () {
+ moment.locale("%locale%");
+ });
+</script>
+<script type="text/javascript" src="js/moment-countdown.js"></script>
+<script type="text/javascript" src="js/sticky-headers.js"></script>
</body>
</html>
diff --git a/templates/maintenance.html b/templates/maintenance.html
new file mode 100644
index 00000000..bd73bd74
--- /dev/null
+++ b/templates/maintenance.html
@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Maintenance - Engelsystem</title>
+ <meta charset="UTF-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" type="text/css" href="css/theme0.css"/>
+ <link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css"/>
+ <link rel="stylesheet" type="text/css" href="vendor/bootstrap-datepicker-1.4.0/css/bootstrap-datepicker3.min.css"/>
+ <script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
+ <script type="text/javascript" src="vendor/jquery-ui.min.js"></script>
+</head>
+<body>
+<div class="navbar navbar-default navbar-fixed-top">
+ <div class="container-fluid">
+ <div class="navbar-header">
+ <button type="button" class="navbar-toggle collapsed"
+ data-toggle="collapse" data-target="#navbar-collapse-1">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a class="navbar-brand" href="#">
+ <span class="icon-icon_angel"></span> <strong class="visible-lg-inline">ENGELSYSTEM</strong>
+ </a>
+ </div>
+ <div class="collapse navbar-collapse" id="navbar-collapse-1">
+ <ul class="nav navbar-nav"></ul>
+ <ul class="nav navbar-nav navbar-right">
+ </ul>
+ </div>
+ </div>
+</div>
+<div class="container-fluid">
+ <div class="row">
+ <div class="jumbotron">
+ <div class="container text-center">
+ <h1>
+ <span class="glyphicon glyphicon-scissors"></span>
+ <span class="glyphicon glyphicon-wrench"></span>
+ <span class="glyphicon glyphicon-fire"></span>
+ </h1>
+ <div class="col-md-6">
+ <h2>
+ The <span class="icon-icon_angel"></span> <strong>ENGELSYSTEM</strong> is in maintenance mode.
+ </h2>
+ <p>This may be due to...</p>
+ <p>
+ ...archangels closing the gates of heaven. <br>
+ ...somebody's stolen the power chord and now the battery is empty. <br>
+ ...DHCP decided to give me another ip address.
+ </p>
+ </div>
+ <div class="col-md-6">
+ <iframe width="560" height="315"
+ src="https://www.youtube.com/embed/0aV_vHcunSQ?rel=0"
+ frameborder="0" allowfullscreen>
+ </iframe>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-12">
+ <div class="text-center footer">
+ <a href="https://github.com/engelsystem/engelsystem/issues">Bugs / Features</a>
+ · <a href="https://github.com/engelsystem/engelsystem/">Development Platform</a>
+ </div>
+ </div>
+ </div>
+</div>
+<script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>
+<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/js/bootstrap-datepicker.min.js"></script>
+<script type="text/javascript" src="vendor/bootstrap-datepicker-1.4.0/locales/bootstrap-datepicker.de.min.js"></script>
+<script type="text/javascript" src="vendor/Chart.min.js"></script>
+<script type="text/javascript" src="js/forms.js"></script>
+<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
+<script type="text/javascript">
+ $(function () {
+ moment.locale("en_US.UTF-8");
+ });
+</script>
+<script type="text/javascript" src="js/moment-countdown.js"></script>
+</body>
+</html>
diff --git a/templates/user_shifts.html b/templates/user_shifts.html
index e4aba6ce..c3fb7718 100644
--- a/templates/user_shifts.html
+++ b/templates/user_shifts.html
@@ -1,52 +1,59 @@
<script type="text/javascript">
- function set_to_now(id) {
- document.getElementById(id + '_time').value = moment().format('HH:mm');
- var days = document.getElementById(id + '_day').getElementsByTagName(
- 'option');
- for ( var i = 0; i < days.length; i++) {
- if (days[i].value == moment().format('YYYY-MM-DD'))
- days[i].selected = true;
- }
- }
+ function set_to_now(id) {
+ document.getElementById(id + '_time').value = moment().format('HH:mm');
+ var days = document.getElementById(id + '_day').getElementsByTagName(
+ 'option');
+ for (var i = 0; i < days.length; i++) {
+ if (days[i].value === moment().format('YYYY-MM-DD')) {
+ days[i].selected = true;
+ }
+ }
+ }
</script>
-<form class="form-inline" action="" method="get">
- <input type="hidden" name="p" value="user_shifts">
- <div class="row">
- <div class="col-md-6">
- <h1>%title%</h1>
- <div class="form-group">%start_select%</div>
- <div class="form-group">
- <div class="input-group">
- <input class="form-control" type="text" id="start_time" name="start_time" size="5" pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%start_time%">
- <div class="input-group-btn">
- <button class="btn btn-default" title="Now" type="button" onclick="set_to_now('start');">
- <span class="glyphicon glyphicon-time"></span>
- </button>
- </div>
+
+<form class="form-inline" action="">
+ <input type="hidden" name="p" value="user_shifts">
+ <div class="row">
+ <div class="col-md-6">
+ <h1>%title%</h1>
+ <div class="form-group">%start_select%</div>
+ <div class="form-group">
+ <div class="input-group">
+ <input class="form-control" id="start_time" name="start_time" size="5"
+ pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%start_time%">
+ <div class="input-group-btn">
+ <button class="btn btn-default" title="Now" type="button" onclick="set_to_now('start');">
+ <span class="glyphicon glyphicon-time"></span>
+ </button>
+ </div>
+ </div>
+ </div>
+ &#8211;
+ <div class="form-group">%end_select%</div>
+ <div class="form-group">
+ <div class="input-group">
+ <input class="form-control" id="end_time" name="end_time" size="5"
+ pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%end_time%">
+ <div class="input-group-btn">
+ <button class="btn btn-default" title="Now" type="button" onclick="set_to_now('end');">
+ <span class="glyphicon glyphicon-time"></span>
+ </button>
+ </div>
+ </div>
+ </div>
</div>
- </div>
- &#8211;
- <div class="form-group">%end_select%</div>
- <div class="form-group">
- <div class="input-group">
- <input class="form-control" type="text" id="end_time" name="end_time" size="5" pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%end_time%">
- <div class="input-group-btn">
- <button class="btn btn-default" title="Now" type="button" onclick="set_to_now('end');">
- <span class="glyphicon glyphicon-time"></span>
- </button>
- </div>
+ <div class="col-md-2">%room_select%</div>
+ <div class="col-md-2">%type_select%</div>
+ <div class="col-md-2">%filled_select%</div>
+ </div>
+ <div class="row">
+ <div class="col-md-6">
+ <div>%assign_notice%</div>
+ </div>
+ <div class="col-md-6">
+ <div><p>%task_notice%</p></div>
+ <input class="btn btn-primary" type="submit" style="width:75%; margin-bottom: 20px" value="%filter%">
</div>
- </div>
</div>
- <div class="col-md-2">%room_select%</div>
- <div class="col-md-2">%type_select%</div>
- <div class="col-md-2">%filled_select%</div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div>%task_notice%</div>
- <input class="btn btn-primary" type="submit" style="width: 75%; margin-bottom: 20px" value="%filter%">
- </div>
- </div>
</form>
%shifts_table% %ical_text%
diff --git a/test/model/LogEntriesModelTest.php b/test/model/LogEntriesModelTest.php
deleted file mode 100644
index 552650b2..00000000
--- a/test/model/LogEntriesModelTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-namespace Engelsystem\Test;
-
-class LogEntriesModelTest extends \PHPUnit_Framework_TestCase {
-
- public function create_LogEntry() {
- LogEntry_create('test', 'test');
- }
-
- public function test_LogEntry_create() {
- $count = count(LogEntries());
- $this->assertNotFalse(LogEntry_create('test', 'test_LogEntry_create'));
-
- // There should be one more log entry now
- $this->assertEquals(count(LogEntries()), $count + 1);
- }
-
- public function test_LogEntries_clear_all() {
- $this->create_LogEntry();
- $this->assertTrue(count(LogEntries()) > 0);
- $this->assertNotFalse(LogEntries_clear_all());
- $this->assertEquals(count(LogEntries()), 0);
- }
-
- /**
- * @after
- */
- public function teardown() {
- LogEntries_clear_all();
- }
-}
-
-?>
diff --git a/test/model/RoomModelTest.php b/test/model/RoomModelTest.php
deleted file mode 100644
index 52daf6c8..00000000
--- a/test/model/RoomModelTest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-namespace Engelsystem\Test;
-
-class RoomModelTest extends \PHPUnit_Framework_TestCase {
-
- private $room_id = null;
-
- public function create_Room() {
- $this->room_id = Room_create('test', false, true, '');
- }
-
- public function test_Room() {
- $this->create_Room();
-
- $room = Room($this->room_id);
-
- $this->assertNotFalse($room);
- $this->assertNotNull($room);
- $this->assertEquals($room['Name'], 'test');
-
- $this->assertNull(Room(- 1));
- }
-
- /**
- * @after
- */
- public function teardown() {
- if ($this->room_id != null) {
- Room_delete($this->room_id);
- }
- }
-}
-
-?>
diff --git a/tests/Feature/Database/DatabaseServiceProviderTest.php b/tests/Feature/Database/DatabaseServiceProviderTest.php
new file mode 100644
index 00000000..d5fdd108
--- /dev/null
+++ b/tests/Feature/Database/DatabaseServiceProviderTest.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Engelsystem\Test\Feature\Database;
+
+use Engelsystem\Application;
+use Engelsystem\Config\Config;
+use Engelsystem\Database\DatabaseServiceProvider;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+
+class DatabaseServiceProviderTest extends DatabaseTest
+{
+ /**
+ * @covers \Engelsystem\Database\DatabaseServiceProvider::register()
+ */
+ public function testRegister()
+ {
+ /** @var MockObject|Config $config */
+ $config = $this->getMockBuilder(Config::class)
+ ->getMock();
+
+ /** @var MockObject|Application $app */
+ $app = $this->getMockBuilder(Application::class)
+ ->setMethods(['get'])
+ ->getMock();
+ Application::setInstance($app);
+
+ $app->expects($this->once())
+ ->method('get')
+ ->with('config')
+ ->willReturn($config);
+
+ $config->expects($this->atLeastOnce())
+ ->method('get')
+ ->with('database')
+ ->willReturn($this->getDbConfig());
+
+ $serviceProvider = new DatabaseServiceProvider($app);
+ $serviceProvider->register();
+ }
+}
diff --git a/tests/Feature/Database/DatabaseTest.php b/tests/Feature/Database/DatabaseTest.php
new file mode 100644
index 00000000..11df6779
--- /dev/null
+++ b/tests/Feature/Database/DatabaseTest.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Engelsystem\Test\Feature\Database;
+
+use PHPUnit\Framework\TestCase;
+
+abstract class DatabaseTest extends TestCase
+{
+ /**
+ * Returns the database config
+ *
+ * @return string[]
+ */
+ protected function getDbConfig()
+ {
+ $configValues = require __DIR__ . '/../../../config/config.default.php';
+ $configFile = __DIR__ . '/../../../config/config.php';
+
+ if (file_exists($configFile)) {
+ $configValues = array_replace_recursive($configValues, require $configFile);
+ }
+
+ return $configValues['database'];
+ }
+}
diff --git a/tests/Feature/Logger/EngelsystemLoggerTest.php b/tests/Feature/Logger/EngelsystemLoggerTest.php
new file mode 100644
index 00000000..8886d4ba
--- /dev/null
+++ b/tests/Feature/Logger/EngelsystemLoggerTest.php
@@ -0,0 +1,150 @@
+<?php
+
+namespace Engelsystem\Test\Feature\Logger;
+
+use Engelsystem\Logger\EngelsystemLogger;
+use PHPUnit\Framework\TestCase;
+use Psr\Log\InvalidArgumentException;
+use Psr\Log\LoggerInterface;
+use Psr\Log\LogLevel;
+
+class EngelsystemLoggerTest extends TestCase
+{
+ public static function setUpBeforeClass()
+ {
+ require_once __DIR__ . '/../../../includes/engelsystem.php';
+ }
+
+ /**
+ * @return LoggerInterface
+ */
+ public function getLogger()
+ {
+ return new EngelsystemLogger();
+ }
+
+ public function testImplements()
+ {
+ $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
+ }
+
+ /**
+ * @return string[]
+ */
+ public function provideLogLevels()
+ {
+ return [
+ [LogLevel::ALERT],
+ [LogLevel::CRITICAL],
+ [LogLevel::DEBUG],
+ [LogLevel::EMERGENCY],
+ [LogLevel::ERROR],
+ [LogLevel::INFO],
+ [LogLevel::NOTICE],
+ [LogLevel::WARNING],
+ ];
+ }
+
+ /**
+ * @dataProvider provideLogLevels
+ * @param string $level
+ */
+ public function testAllLevels($level)
+ {
+ $logger = $this->getLogger();
+
+ LogEntries_clear_all();
+
+ $logger->log($level, 'First log message');
+ $logger->{$level}('Second log message');
+
+ $entries = LogEntries();
+ $this->assertCount(2, $entries);
+ }
+
+ public function testContextReplacement()
+ {
+ $logger = $this->getLogger();
+ LogEntries_clear_all();
+
+ $logger->log(LogLevel::INFO, 'My username is {username}', ['username' => 'Foo']);
+
+ $entry = $this->getLastEntry();
+ $this->assertEquals('My username is Foo', $entry['message']);
+ $this->assertEquals(LogLevel::INFO, $entry['level']);
+ }
+
+ /**
+ * @return string[]
+ */
+ public function provideContextReplaceValues()
+ {
+ return [
+ ['Data and {context}', [], 'Data and {context}'],
+ ['Data and {context}', ['context' => null], 'Data and '],
+ ['Data and {context}', ['context' => new \stdClass()], 'Data and {context}'],
+ ['Some user asked: {question}', ['question' => 'Foo?'], 'Some user asked: Foo?'],
+ ];
+ }
+
+ /**
+ * @dataProvider provideContextReplaceValues
+ *
+ * @param string $message
+ * @param string[] $context
+ * @param string $expected
+ */
+ public function testContextReplaceValues($message, $context, $expected)
+ {
+ $logger = $this->getLogger();
+ $logger->log(LogLevel::INFO, $message, $context);
+
+ $entry = $this->getLastEntry();
+ $this->assertEquals($expected, $entry['message']);
+ }
+
+ public function testContextToString()
+ {
+ $logger = $this->getLogger();
+ LogEntries_clear_all();
+
+ $mock = $this->getMockBuilder('someDataProvider')
+ ->setMethods(['__toString'])
+ ->getMock();
+
+ $mock->expects($this->atLeastOnce())
+ ->method('__toString')
+ ->will($this->returnValue('FooBar'));
+
+ $logger->log(LogLevel::INFO, 'Some data and {context}', ['context' => $mock]);
+
+ $entry = $this->getLastEntry();
+ $this->assertEquals('Some data and FooBar', $entry['message']);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testThrowExceptionOnInvalidLevel()
+ {
+ $logger = $this->getLogger();
+
+ $logger->log('This log level should never be defined', 'Some message');
+ }
+
+ /**
+ * @return array
+ */
+ public function getLastEntry()
+ {
+ $entries = LogEntries();
+ $entry = array_pop($entries);
+
+ return $entry;
+ }
+
+ public function tearDown()
+ {
+ LogEntries_clear_all();
+ }
+}
diff --git a/tests/Feature/Model/LogEntriesModelTest.php b/tests/Feature/Model/LogEntriesModelTest.php
new file mode 100644
index 00000000..036f5692
--- /dev/null
+++ b/tests/Feature/Model/LogEntriesModelTest.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Engelsystem\Test\Feature\Model;
+
+use PHPUnit\Framework\TestCase;
+use Psr\Log\LogLevel;
+
+class LogEntriesModelTest extends TestCase
+{
+ public static function setUpBeforeClass()
+ {
+ require_once __DIR__ . '/../../../includes/engelsystem.php';
+ }
+
+ public function testCreateLogEntry()
+ {
+ LogEntries_clear_all();
+ $count = count(LogEntries());
+ $this->assertNotFalse(LogEntry_create(LogLevel::WARNING, 'test_LogEntry_create'));
+
+ // There should be one more log entry now
+ $this->assertEquals(count(LogEntries()), $count + 1);
+ }
+
+ public function testClearAllLogEntries()
+ {
+ LogEntry_create(LogLevel::WARNING, 'test');
+ $this->assertTrue(count(LogEntries()) > 0);
+
+ $this->assertNotFalse(LogEntries_clear_all());
+ $this->assertCount(0, LogEntries());
+ }
+
+ public function tearDown()
+ {
+ LogEntries_clear_all();
+ }
+}
diff --git a/tests/Feature/Model/RoomModelTest.php b/tests/Feature/Model/RoomModelTest.php
new file mode 100644
index 00000000..adf0218e
--- /dev/null
+++ b/tests/Feature/Model/RoomModelTest.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Engelsystem\Test\Feature\Model;
+
+use PHPUnit\Framework\TestCase;
+
+class RoomModelTest extends TestCase
+{
+ private $room_id = null;
+
+ public static function setUpBeforeClass()
+ {
+ require_once __DIR__ . '/../../../includes/engelsystem.php';
+ }
+
+ public function createRoom()
+ {
+ $this->room_id = Room_create('test', false, true, '');
+ }
+
+ public function testRoom()
+ {
+ $this->createRoom();
+
+ $room = Room($this->room_id);
+
+ $this->assertNotFalse($room);
+ $this->assertNotNull($room);
+ $this->assertEquals($room['Name'], 'test');
+
+ $this->assertNull(Room(-1));
+ }
+
+ public function tearDown()
+ {
+ if ($this->room_id != null) {
+ Room_delete($this->room_id);
+ }
+ }
+}
diff --git a/tests/Unit/ApplicationTest.php b/tests/Unit/ApplicationTest.php
new file mode 100644
index 00000000..f58483ea
--- /dev/null
+++ b/tests/Unit/ApplicationTest.php
@@ -0,0 +1,171 @@
+<?php
+
+namespace Engelsystem\Test\Unit;
+
+use Engelsystem\Application;
+use Engelsystem\Config\Config;
+use Engelsystem\Container\Container;
+use Engelsystem\Container\ServiceProvider;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject;
+use Psr\Container\ContainerInterface;
+use ReflectionClass;
+
+class ApplicationTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Application::__construct
+ * @covers \Engelsystem\Application::registerBaseBindings
+ */
+ public function testConstructor()
+ {
+ $app = new Application('.');
+
+ $this->assertInstanceOf(Container::class, $app);
+ $this->assertInstanceOf(ContainerInterface::class, $app);
+ $this->assertSame($app, $app->get('app'));
+ $this->assertSame($app, $app->get('container'));
+ $this->assertSame($app, $app->get(Container::class));
+ $this->assertSame($app, $app->get(Application::class));
+ $this->assertSame($app, $app->get(ContainerInterface::class));
+ $this->assertSame($app, Application::getInstance());
+ $this->assertSame($app, Container::getInstance());
+ }
+
+ /**
+ * @covers \Engelsystem\Application::setAppPath
+ * @covers \Engelsystem\Application::registerPaths
+ * @covers \Engelsystem\Application::path
+ */
+ public function testAppPath()
+ {
+ $app = new Application();
+
+ $this->assertFalse($app->has('path'));
+
+ $app->setAppPath('.');
+ $this->assertTrue($app->has('path'));
+ $this->assertTrue($app->has('path.config'));
+ $this->assertTrue($app->has('path.lang'));
+
+ $this->assertEquals(realpath('.'), $app->path());
+ $this->assertEquals(realpath('.') . '/config', $app->get('path.config'));
+
+ $app->setAppPath('./../');
+ $this->assertEquals(realpath('../') . '/config', $app->get('path.config'));
+ }
+
+ /**
+ * @covers \Engelsystem\Application::register
+ */
+ public function testRegister()
+ {
+ $app = new Application();
+
+ $serviceProvider = $this->mockServiceProvider($app, ['register']);
+ $serviceProvider->expects($this->once())
+ ->method('register');
+
+ $app->register($serviceProvider);
+
+ $anotherServiceProvider = $this->mockServiceProvider($app, ['register', 'boot']);
+ $anotherServiceProvider->expects($this->once())
+ ->method('register');
+ $anotherServiceProvider->expects($this->once())
+ ->method('boot');
+
+ $app->bootstrap();
+ $app->register($anotherServiceProvider);
+ }
+
+ /**
+ * @covers \Engelsystem\Application::register
+ */
+ public function testRegisterBoot()
+ {
+ $app = new Application();
+ $app->bootstrap();
+
+ $serviceProvider = $this->mockServiceProvider($app, ['register', 'boot']);
+ $serviceProvider->expects($this->once())
+ ->method('register');
+ $serviceProvider->expects($this->once())
+ ->method('boot');
+
+ $app->register($serviceProvider);
+ }
+
+ /**
+ * @covers \Engelsystem\Application::register
+ */
+ public function testRegisterClassName()
+ {
+ $app = new Application();
+
+ $mockClassName = $this->getMockClass(ServiceProvider::class);
+ $serviceProvider = $this->getMockBuilder($mockClassName)
+ ->setConstructorArgs([$app])
+ ->setMethods(['register'])
+ ->getMock();
+
+ $serviceProvider->expects($this->once())
+ ->method('register');
+
+ $app->instance($mockClassName, $serviceProvider);
+ $app->register($mockClassName);
+ }
+
+ /**
+ * @covers \Engelsystem\Application::bootstrap
+ * @covers \Engelsystem\Application::isBooted
+ */
+ public function testBootstrap()
+ {
+ /** @var PHPUnit_Framework_MockObject_MockObject|Application $app */
+ $app = $this->getMockBuilder(Application::class)
+ ->setMethods(['register'])
+ ->getMock();
+
+ $serviceProvider = $this->mockServiceProvider($app, ['boot']);
+ $serviceProvider->expects($this->once())
+ ->method('boot');
+
+ $app->expects($this->once())
+ ->method('register')
+ ->with($serviceProvider);
+
+ $config = $this->getMockBuilder(Config::class)
+ ->getMock();
+
+ $config->expects($this->once())
+ ->method('get')
+ ->with('providers')
+ ->willReturn([$serviceProvider]);
+
+ $property = (new ReflectionClass($app))->getProperty('serviceProviders');
+ $property->setAccessible(true);
+ $property->setValue($app, [$serviceProvider]);
+
+ $app->bootstrap($config);
+
+ $this->assertTrue($app->isBooted());
+
+ // Run bootstrap another time to ensure that providers are registered only once
+ $app->bootstrap($config);
+ }
+
+ /**
+ * @param Application $app
+ * @param array $methods
+ * @return PHPUnit_Framework_MockObject_MockObject|ServiceProvider
+ */
+ protected function mockServiceProvider(Application $app, $methods = [])
+ {
+ $serviceProvider = $this->getMockBuilder(ServiceProvider::class)
+ ->setConstructorArgs([$app])
+ ->setMethods($methods)
+ ->getMockForAbstractClass();
+
+ return $serviceProvider;
+ }
+}
diff --git a/tests/Unit/Config/ConfigServiceProviderTest.php b/tests/Unit/Config/ConfigServiceProviderTest.php
new file mode 100644
index 00000000..c8be4b7d
--- /dev/null
+++ b/tests/Unit/Config/ConfigServiceProviderTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Config;
+
+use Engelsystem\Application;
+use Engelsystem\Config\Config;
+use Engelsystem\Config\ConfigServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject;
+
+class ConfigServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Config\ConfigServiceProvider::register()
+ */
+ public function testRegister()
+ {
+ /** @var PHPUnit_Framework_MockObject_MockObject|Config $config */
+ $config = $this->getMockBuilder(Config::class)
+ ->getMock();
+
+ $app = $this->getApp(['make', 'instance', 'get']);
+ Application::setInstance($app);
+
+ $this->setExpects($app, 'make', [Config::class], $config);
+ $this->setExpects($app, 'instance', ['config', $config]);
+ $this->setExpects($app, 'get', ['path.config'], __DIR__ . '/../../../config', $this->atLeastOnce());
+
+ $this->setExpects($config, 'set', null, null, $this->exactly(2));
+ $this->setExpects($config, 'get', [null], []);
+
+ $configFile = __DIR__ . '/../../../config/config.php';
+ $configExists = file_exists($configFile);
+ if (!$configExists) {
+ file_put_contents($configFile, '<?php return [];');
+ }
+
+ $serviceProvider = new ConfigServiceProvider($app);
+ $serviceProvider->register();
+
+ if (!$configExists) {
+ unlink($configFile);
+ }
+ }
+}
diff --git a/tests/Unit/Config/ConfigTest.php b/tests/Unit/Config/ConfigTest.php
new file mode 100644
index 00000000..043599fd
--- /dev/null
+++ b/tests/Unit/Config/ConfigTest.php
@@ -0,0 +1,115 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Config;
+
+use Engelsystem\Config\Config;
+use PHPUnit\Framework\TestCase;
+
+class ConfigTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Config\Config::get
+ */
+ public function testGet()
+ {
+ $config = new Config();
+
+ $config->set('test', 'FooBar');
+ $this->assertEquals(['test' => 'FooBar'], $config->get(null));
+ $this->assertEquals('FooBar', $config->get('test'));
+
+ $this->assertEquals('defaultValue', $config->get('notExisting', 'defaultValue'));
+
+ $this->assertNull($config->get('notExisting'));
+ }
+
+ /**
+ * @covers \Engelsystem\Config\Config::set
+ */
+ public function testSet()
+ {
+ $config = new Config();
+
+ $config->set('test', 'FooBar');
+ $this->assertEquals('FooBar', $config->get('test'));
+
+ $config->set([
+ 'name' => 'Engelsystem',
+ 'mail' => ['user' => 'test'],
+ ]);
+ $this->assertEquals('Engelsystem', $config->get('name'));
+ $this->assertEquals(['user' => 'test'], $config->get('mail'));
+ }
+
+ /**
+ * @covers \Engelsystem\Config\Config::has
+ */
+ public function testHas()
+ {
+ $config = new Config();
+
+ $this->assertFalse($config->has('test'));
+
+ $config->set('test', 'FooBar');
+ $this->assertTrue($config->has('test'));
+ }
+
+ /**
+ * @covers \Engelsystem\Config\Config::remove
+ */
+ public function testRemove()
+ {
+ $config = new Config();
+ $config->set(['foo' => 'bar', 'test' => '123']);
+
+ $config->remove('foo');
+ $this->assertEquals(['test' => '123'], $config->get(null));
+ }
+
+ /**
+ * @covers \Engelsystem\Config\Config::__get
+ */
+ public function testMagicGet()
+ {
+ $config = new Config();
+
+ $config->set('test', 'FooBar');
+ $this->assertEquals('FooBar', $config->test);
+ }
+
+ /**
+ * @covers \Engelsystem\Config\Config::__set
+ */
+ public function testMagicSet()
+ {
+ $config = new Config();
+
+ $config->test = 'FooBar';
+ $this->assertEquals('FooBar', $config->get('test'));
+ }
+
+ /**
+ * @covers \Engelsystem\Config\Config::__isset
+ */
+ public function testMagicIsset()
+ {
+ $config = new Config();
+
+ $this->assertFalse(isset($config->test));
+
+ $config->set('test', 'FooBar');
+ $this->assertTrue(isset($config->test));
+ }
+
+ /**
+ * @covers \Engelsystem\Config\Config::__unset
+ */
+ public function testMagicUnset()
+ {
+ $config = new Config();
+ $config->set(['foo' => 'bar', 'test' => '123']);
+
+ unset($config->foo);
+ $this->assertEquals(['test' => '123'], $config->get(null));
+ }
+}
diff --git a/tests/Unit/Container/ServiceProviderTest.php b/tests/Unit/Container/ServiceProviderTest.php
new file mode 100644
index 00000000..8a9cb76e
--- /dev/null
+++ b/tests/Unit/Container/ServiceProviderTest.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Container;
+
+use Engelsystem\Container\ServiceProvider;
+use Engelsystem\Test\Unit\Container\Stub\ServiceProviderImplementation;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+
+class ConfigServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Container\ServiceProvider::__construct
+ */
+ public function testRegister()
+ {
+ $app = $this->getApp();
+
+ $serviceProvider = new ServiceProviderImplementation($app);
+
+ $this->assertInstanceOf(ServiceProvider::class, $serviceProvider);
+ }
+}
diff --git a/tests/Unit/Container/Stub/ServiceProviderImplementation.php b/tests/Unit/Container/Stub/ServiceProviderImplementation.php
new file mode 100644
index 00000000..36ae2c38
--- /dev/null
+++ b/tests/Unit/Container/Stub/ServiceProviderImplementation.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Container\Stub;
+
+use Engelsystem\Container\ServiceProvider;
+
+class ServiceProviderImplementation extends ServiceProvider
+{
+
+}
diff --git a/tests/Unit/Database/DatabaseServiceProviderTest.php b/tests/Unit/Database/DatabaseServiceProviderTest.php
new file mode 100644
index 00000000..61848c35
--- /dev/null
+++ b/tests/Unit/Database/DatabaseServiceProviderTest.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Database;
+
+use Engelsystem\Config\Config;
+use Engelsystem\Database\DatabaseServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use Exception;
+use PHPUnit_Framework_MockObject_MockObject;
+
+class DatabaseServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Database\DatabaseServiceProvider::register()
+ * @covers \Engelsystem\Database\DatabaseServiceProvider::exitOnError()
+ */
+ public function testRegister()
+ {
+ /** @var PHPUnit_Framework_MockObject_MockObject|Config $config */
+ $config = $this->getMockBuilder(Config::class)
+ ->getMock();
+
+ $app = $this->getApp(['get']);
+
+ $this->setExpects($app, 'get', ['config'], $config);
+ $this->setExpects($config, 'get', ['database'], [
+ 'host' => 'localhost',
+ 'db' => 'database',
+ 'user' => 'user',
+ 'pw' => 'password',
+ ], $this->atLeastOnce());
+ $this->expectException(Exception::class);
+
+ $serviceProvider = new DatabaseServiceProvider($app);
+ $serviceProvider->register();
+ }
+}
diff --git a/tests/Unit/Database/DbTest.php b/tests/Unit/Database/DbTest.php
new file mode 100644
index 00000000..63607cad
--- /dev/null
+++ b/tests/Unit/Database/DbTest.php
@@ -0,0 +1,192 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Database;
+
+use Engelsystem\Database\Db;
+use PDO;
+use PDOStatement;
+use PHPUnit\Framework\TestCase;
+use ReflectionObject;
+use Throwable;
+
+class DbTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Database\Db::connect()
+ */
+ public function testConnect()
+ {
+ $result = Db::connect('mysql:host=localhost;dbname=someTestDatabaseThatDoesNotExist;charset=utf8');
+ $this->assertFalse($result);
+
+ $result = Db::connect('sqlite::memory:');
+ $this->assertTrue($result);
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::query()
+ */
+ public function testQuery()
+ {
+ $stm = Db::query('SELECT * FROM test_data');
+ $this->assertEquals('00000', $stm->errorCode());
+
+ $stm = Db::query('SELECT * FROM test_data WHERE id = ?', [4]);
+ $this->assertEquals('00000', $stm->errorCode());
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::unprepared()
+ */
+ public function testUnprepared()
+ {
+ $return = Db::unprepared('SELECT * FROM test_data WHERE id = 3');
+ $this->assertTrue($return);
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::select()
+ */
+ public function testSelect()
+ {
+ $return = Db::select('SELECT * FROM test_data');
+ $this->assertTrue(count($return) > 3);
+
+ $return = Db::select('SELECT * FROM test_data WHERE id = ?', [2]);
+ $this->assertCount(1, $return);
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::selectOne()
+ */
+ public function testSelectOne()
+ {
+ $return = Db::selectOne('SELECT * FROM test_data');
+ $this->assertEquals('Foo', $return['data']);
+
+ $return = Db::selectOne('SELECT * FROM test_data WHERE id = -1');
+ $this->assertEmpty($return);
+
+ $return = Db::selectOne('SELECT * FROM test_data WHERE id = ?', [3]);
+ $return = array_pop($return);
+ $this->assertTrue(!is_array($return));
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::insert()
+ */
+ public function testInsert()
+ {
+ $count = Db::insert("INSERT INTO test_data (id, data) VALUES (5, 'Some random text'), (6, 'another text')");
+ $this->assertEquals(2, $count);
+
+ $count = Db::insert('INSERT INTO test_data(id, data) VALUES (:id, :alias)', ['id' => 7, 'alias' => 'Blafoo']);
+ $this->assertEquals(1, $count);
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::update()
+ */
+ public function testUpdate()
+ {
+ $count = Db::update("UPDATE test_data SET data='NOPE' WHERE data LIKE '%Replaceme%'");
+ $this->assertEquals(3, $count);
+
+ $count = Db::update("UPDATE test_data SET data=? WHERE data LIKE '%NOPE%'", ['Some random text!']);
+ $this->assertEquals(3, $count);
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::delete()
+ */
+ public function testDelete()
+ {
+ $count = Db::delete('DELETE FROM test_data WHERE id=1');
+ $this->assertEquals(1, $count);
+
+ $count = Db::delete('DELETE FROM test_data WHERE data LIKE ?', ['%Replaceme%']);
+ $this->assertEquals(3, $count);
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::statement()
+ */
+ public function testStatement()
+ {
+ $return = Db::statement('SELECT * FROM test_data WHERE id = 3');
+ $this->assertTrue($return);
+
+ $return = Db::statement('SELECT * FROM test_data WHERE id = ?', [2]);
+ $this->assertTrue($return);
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::getError()
+ */
+ public function testGetError()
+ {
+ try {
+ Db::statement('foo');
+ } catch (Throwable $e) {
+ }
+
+ $error = Db::getError();
+ $this->assertTrue(is_array($error));
+ $this->assertEquals('near "foo": syntax error', $error[2]);
+
+ $db = new Db();
+ $refObject = new ReflectionObject($db);
+ $refProperty = $refObject->getProperty('stm');
+ $refProperty->setAccessible(true);
+ $refProperty->setValue(null, null);
+
+ $error = Db::getError();
+ $this->assertEquals([-1, null, null], $error);
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::getPdo()
+ */
+ public function testGetPdo()
+ {
+ $pdo = Db::getPdo();
+ $this->assertInstanceOf(PDO::class, $pdo);
+ }
+
+ /**
+ * @covers \Engelsystem\Database\Db::getStm()
+ */
+ public function testGetStm()
+ {
+ $stm = Db::getStm();
+ $this->assertInstanceOf(PDOStatement::class, $stm);
+ }
+
+ /**
+ * Setup in memory database
+ */
+ protected function setUp()
+ {
+ Db::connect('sqlite::memory:');
+ Db::getPdo()->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ Db::query(
+ '
+ CREATE TABLE test_data(
+ id INT PRIMARY KEY NOT NULL,
+ data TEXT NOT NULL
+ );
+ ');
+ Db::query('CREATE UNIQUE INDEX test_data_id_uindex ON test_data (id);');
+ Db::insert("
+ INSERT INTO test_data (id, data)
+ VALUES
+ (1, 'Foo'),
+ (2, 'Bar'),
+ (3, 'Batz'),
+ (4, 'Lorem ipsum dolor sit'),
+ (10, 'Replaceme ipsum dolor sit amet'),
+ (11, 'Lorem Replaceme dolor sit amet'),
+ (12, 'Lorem ipsum Replaceme sit amet')
+ ;");
+ }
+}
diff --git a/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php b/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php
new file mode 100644
index 00000000..4f2ae654
--- /dev/null
+++ b/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php
@@ -0,0 +1,109 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Exceptions;
+
+use Engelsystem\Exceptions\ExceptionsServiceProvider;
+use Engelsystem\Exceptions\Handler;
+use Engelsystem\Exceptions\Handlers\HandlerInterface;
+use Engelsystem\Exceptions\Handlers\Legacy;
+use Engelsystem\Exceptions\Handlers\LegacyDevelopment;
+use Engelsystem\Exceptions\Handlers\Whoops;
+use Engelsystem\Http\Request;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+
+class ExceptionsServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Exceptions\ExceptionsServiceProvider::register()
+ * @covers \Engelsystem\Exceptions\ExceptionsServiceProvider::addProductionHandler()
+ * @covers \Engelsystem\Exceptions\ExceptionsServiceProvider::addDevelopmentHandler()
+ */
+ public function testRegister()
+ {
+ $app = $this->getApp(['make', 'instance', 'bind']);
+
+ /** @var MockObject|Handler $handler */
+ $handler = $this->createMock(Handler::class);
+ $this->setExpects($handler, 'register');
+ /** @var Legacy|MockObject $legacyHandler */
+ $legacyHandler = $this->createMock(Legacy::class);
+ /** @var LegacyDevelopment|MockObject $developmentHandler */
+ $developmentHandler = $this->createMock(LegacyDevelopment::class);
+
+ $whoopsHandler = $this->getMockBuilder(Whoops::class)
+ ->setConstructorArgs([$app])
+ ->getMock();
+
+ $app->expects($this->exactly(3))
+ ->method('instance')
+ ->withConsecutive(
+ ['error.handler.production', $legacyHandler],
+ ['error.handler.development', $whoopsHandler],
+ ['error.handler', $handler]
+ );
+
+ $app->expects($this->exactly(4))
+ ->method('make')
+ ->withConsecutive(
+ [Handler::class],
+ [Legacy::class],
+ [LegacyDevelopment::class],
+ [Whoops::class]
+ )
+ ->willReturnOnConsecutiveCalls(
+ $handler,
+ $legacyHandler,
+ $developmentHandler,
+ $whoopsHandler
+ );
+
+ $app->expects($this->exactly(2))
+ ->method('bind')
+ ->withConsecutive(
+ [HandlerInterface::class, 'error.handler.production'],
+ [Handler::class, 'error.handler']
+ );
+
+ $handler->expects($this->exactly(2))
+ ->method('setHandler')
+ ->withConsecutive(
+ [Handler::ENV_PRODUCTION, $legacyHandler],
+ [Handler::ENV_DEVELOPMENT, $whoopsHandler]
+ );
+
+ $serviceProvider = new ExceptionsServiceProvider($app);
+ $serviceProvider->register();
+ }
+
+ /**
+ * @covers \Engelsystem\Exceptions\ExceptionsServiceProvider::boot()
+ */
+ public function testBoot()
+ {
+ /** @var MockObject|Handler $handler */
+ $handler = $this->createMock(Handler::class);
+
+ /** @var MockObject|Request $request */
+ $request = $this->createMock(Request::class);
+
+ $handler->expects($this->once())
+ ->method('setRequest')
+ ->with($request);
+
+ $app = $this->getApp(['get']);
+ $app->expects($this->exactly(2))
+ ->method('get')
+ ->withConsecutive(
+ ['error.handler'],
+ ['request']
+ )
+ ->willReturnOnConsecutiveCalls(
+ $handler,
+ $request
+ );
+
+ $provider = new ExceptionsServiceProvider($app);
+ $provider->boot();
+ }
+}
diff --git a/tests/Unit/Exceptions/HandlerTest.php b/tests/Unit/Exceptions/HandlerTest.php
new file mode 100644
index 00000000..40202be8
--- /dev/null
+++ b/tests/Unit/Exceptions/HandlerTest.php
@@ -0,0 +1,140 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Exceptions;
+
+use Engelsystem\Exceptions\Handler;
+use Engelsystem\Exceptions\Handlers\HandlerInterface;
+use Engelsystem\Http\Request;
+use ErrorException;
+use Exception;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as Mock;
+
+class HandlerTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Exceptions\Handler::__construct()
+ */
+ public function testCreate()
+ {
+ /** @var Handler|Mock $handler */
+ $handler = new Handler();
+ $this->assertInstanceOf(Handler::class, $handler);
+ $this->assertEquals(Handler::ENV_PRODUCTION, $handler->getEnvironment());
+
+ $anotherHandler = new Handler(Handler::ENV_DEVELOPMENT);
+ $this->assertEquals(Handler::ENV_DEVELOPMENT, $anotherHandler->getEnvironment());
+ }
+
+ /**
+ * @covers \Engelsystem\Exceptions\Handler::errorHandler()
+ */
+ public function testErrorHandler()
+ {
+ /** @var Handler|Mock $handler */
+ $handler = $this->getMockBuilder(Handler::class)
+ ->setMethods(['exceptionHandler'])
+ ->getMock();
+
+ $handler->expects($this->once())
+ ->method('exceptionHandler')
+ ->with($this->isInstanceOf(ErrorException::class));
+
+ $handler->errorHandler(1, 'Foo and bar!', '/lo/rem.php', 123);
+ }
+
+ /**
+ * @covers \Engelsystem\Exceptions\Handler::exceptionHandler()
+ */
+ public function testExceptionHandler()
+ {
+ $exception = new Exception();
+
+ /** @var HandlerInterface|Mock $handlerMock */
+ $handlerMock = $this->getMockForAbstractClass(HandlerInterface::class);
+ $handlerMock->expects($this->once())
+ ->method('report')
+ ->with($exception);
+ $handlerMock->expects($this->once())
+ ->method('render')
+ ->with($this->isInstanceOf(Request::class), $exception);
+
+ /** @var Handler|Mock $handler */
+ $handler = $this->getMockBuilder(Handler::class)
+ ->setMethods(['die'])
+ ->getMock();
+ $handler->expects($this->once())
+ ->method('die');
+
+ $handler->setHandler(Handler::ENV_PRODUCTION, $handlerMock);
+
+ $handler->exceptionHandler($exception);
+ }
+
+ /**
+ * @covers \Engelsystem\Exceptions\Handler::register()
+ */
+ public function testRegister()
+ {
+ /** @var Handler|Mock $handler */
+ $handler = $this->getMockForAbstractClass(Handler::class);
+ $handler->register();
+
+ set_error_handler($errorHandler = set_error_handler('var_dump'));
+ $this->assertEquals($handler, array_shift($errorHandler));
+
+ set_exception_handler($exceptionHandler = set_error_handler('var_dump'));
+ $this->assertEquals($handler, array_shift($exceptionHandler));
+
+ restore_error_handler();
+ restore_exception_handler();
+ }
+
+ /**
+ * @covers \Engelsystem\Exceptions\Handler::setEnvironment()
+ * @covers \Engelsystem\Exceptions\Handler::getEnvironment()
+ */
+ public function testEnvironment()
+ {
+ $handler = new Handler();
+
+ $handler->setEnvironment(Handler::ENV_DEVELOPMENT);
+ $this->assertEquals(Handler::ENV_DEVELOPMENT, $handler->getEnvironment());
+
+ $handler->setEnvironment(Handler::ENV_PRODUCTION);
+ $this->assertEquals(Handler::ENV_PRODUCTION, $handler->getEnvironment());
+ }
+
+ /**
+ * @covers \Engelsystem\Exceptions\Handler::setHandler()
+ * @covers \Engelsystem\Exceptions\Handler::getHandler()
+ */
+ public function testHandler()
+ {
+ $handler = new Handler();
+ /** @var HandlerInterface|Mock $devHandler */
+ $devHandler = $this->getMockForAbstractClass(HandlerInterface::class);
+ /** @var HandlerInterface|Mock $prodHandler */
+ $prodHandler = $this->getMockForAbstractClass(HandlerInterface::class);
+
+ $handler->setHandler(Handler::ENV_DEVELOPMENT, $devHandler);
+ $handler->setHandler(Handler::ENV_PRODUCTION, $prodHandler);
+ $this->assertEquals($devHandler, $handler->getHandler(Handler::ENV_DEVELOPMENT));
+ $this->assertEquals($prodHandler, $handler->getHandler(Handler::ENV_PRODUCTION));
+ $this->assertCount(2, $handler->getHandler());
+ }
+
+ /**
+ * @covers \Engelsystem\Exceptions\Handler::setRequest()
+ * @covers \Engelsystem\Exceptions\Handler::getRequest()
+ */
+ public function testRequest()
+ {
+ $handler = new Handler();
+ /** @var Request|Mock $request */
+ $request = $this->createMock(Request::class);
+
+ $handler->setRequest($request);
+ $this->assertEquals($request, $handler->getRequest());
+ }
+}
diff --git a/tests/Unit/Exceptions/Handlers/LegacyDevelopmentTest.php b/tests/Unit/Exceptions/Handlers/LegacyDevelopmentTest.php
new file mode 100644
index 00000000..d5390c9e
--- /dev/null
+++ b/tests/Unit/Exceptions/Handlers/LegacyDevelopmentTest.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Exceptions\handlers;
+
+
+use Engelsystem\Exceptions\Handlers\LegacyDevelopment;
+use Engelsystem\Http\Request;
+use ErrorException;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as Mock;
+
+class LegacyDevelopmentTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Exceptions\Handlers\LegacyDevelopment::render()
+ * @covers \Engelsystem\Exceptions\Handlers\LegacyDevelopment::formatStackTrace()
+ */
+ public function testRender()
+ {
+ $handler = new LegacyDevelopment();
+ /** @var Request|Mock $request */
+ $request = $this->createMock(Request::class);
+ $exception = new ErrorException('Lorem Ipsum', 4242, 1, 'foo.php', 9999);
+
+ $regex = sprintf(
+ '%%<pre.*>.*ErrorException.*4242.*Lorem Ipsum.*%s.*%s.*%s.*</pre>%%is',
+ 'foo.php',
+ 9999,
+ __FUNCTION__
+ );
+ $this->expectOutputRegex($regex);
+
+ $handler->render($request, $exception);
+ }
+}
diff --git a/tests/Unit/Exceptions/Handlers/LegacyTest.php b/tests/Unit/Exceptions/Handlers/LegacyTest.php
new file mode 100644
index 00000000..04b214f2
--- /dev/null
+++ b/tests/Unit/Exceptions/Handlers/LegacyTest.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Exceptions\handlers;
+
+
+use Engelsystem\Exceptions\Handlers\Legacy;
+use Engelsystem\Http\Request;
+use Exception;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as Mock;
+
+class LegacyTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Exceptions\Handlers\Legacy::render()
+ */
+ public function testRender()
+ {
+ $handler = new Legacy();
+ /** @var Request|Mock $request */
+ $request = $this->createMock(Request::class);
+ /** @var Exception|Mock $exception */
+ $exception = $this->createMock(Exception::class);
+
+ $this->expectOutputRegex('/.*error occurred.*/i');
+
+ $handler->render($request, $exception);
+ }
+
+ /**
+ * @covers \Engelsystem\Exceptions\Handlers\Legacy::report()
+ * @covers \Engelsystem\Exceptions\Handlers\Legacy::stripBasePath()
+ */
+ public function testReport()
+ {
+ $handler = new Legacy();
+ $exception = new Exception('Lorem Ipsum', 4242);
+ $line = __LINE__ - 1;
+
+ $log = tempnam(sys_get_temp_dir(), 'engelsystem-log');
+ $errorLog = ini_get('error_log');
+ ini_set('error_log', $log);
+ $handler->report($exception);
+ ini_set('error_log', $errorLog);
+ $logContent = file_get_contents($log);
+ unset($log);
+
+ $this->assertContains('4242', $logContent);
+ $this->assertContains('Lorem Ipsum', $logContent);
+ $this->assertContains(basename(__FILE__), $logContent);
+ $this->assertContains((string)$line, $logContent);
+ $this->assertContains(__FUNCTION__, $logContent);
+ $this->assertContains(json_encode(__CLASS__), $logContent);
+ }
+}
diff --git a/tests/Unit/Exceptions/Handlers/WhoopsTest.php b/tests/Unit/Exceptions/Handlers/WhoopsTest.php
new file mode 100644
index 00000000..261ee83f
--- /dev/null
+++ b/tests/Unit/Exceptions/Handlers/WhoopsTest.php
@@ -0,0 +1,83 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Exceptions\handlers;
+
+
+use Engelsystem\Application;
+use Engelsystem\Exceptions\Handlers\Whoops;
+use Engelsystem\Http\Request;
+use Exception;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as Mock;
+use Whoops\Handler\JsonResponseHandler;
+use Whoops\Handler\PrettyPageHandler;
+use Whoops\Run as WhoopsRunner;
+use Whoops\RunInterface as WhoopsRunnerInterface;
+
+class WhoopsTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Exceptions\Handlers\Whoops
+ */
+ public function testRender()
+ {
+ /** @var Application|Mock $app */
+ $app = $this->createMock(Application::class);
+ /** @var Request|Mock $request */
+ $request = $this->createMock(Request::class);
+ $request->expects($this->once())
+ ->method('isXmlHttpRequest')
+ ->willReturn(true);
+ /** @var WhoopsRunnerInterface|Mock $whoopsRunner */
+ $whoopsRunner = $this->getMockForAbstractClass(WhoopsRunnerInterface::class);
+ /** @var PrettyPageHandler|Mock $prettyPageHandler */
+ $prettyPageHandler = $this->createMock(PrettyPageHandler::class);
+ $prettyPageHandler
+ ->expects($this->atLeastOnce())
+ ->method('setApplicationPaths');
+ $prettyPageHandler
+ ->expects($this->once())
+ ->method('setApplicationPaths');
+ $prettyPageHandler
+ ->expects($this->once())
+ ->method('addDataTable');
+ /** @var JsonResponseHandler|Mock $jsonResponseHandler */
+ $jsonResponseHandler = $this->createMock(JsonResponseHandler::class);
+ $jsonResponseHandler->expects($this->once())
+ ->method('setJsonApi')
+ ->with(true);
+ $jsonResponseHandler->expects($this->once())
+ ->method('addTraceToOutput')
+ ->with(true);
+ /** @var Exception|Mock $exception */
+ $exception = $this->createMock(Exception::class);
+
+ $app->expects($this->exactly(3))
+ ->method('make')
+ ->withConsecutive(
+ [WhoopsRunner::class],
+ [PrettyPageHandler::class],
+ [JsonResponseHandler::class]
+ )
+ ->willReturnOnConsecutiveCalls(
+ $whoopsRunner,
+ $prettyPageHandler,
+ $jsonResponseHandler
+ );
+
+ $whoopsRunner
+ ->expects($this->exactly(2))
+ ->method('pushHandler')
+ ->withConsecutive(
+ [$prettyPageHandler],
+ [$jsonResponseHandler]
+ );
+ $whoopsRunner
+ ->expects($this->once())
+ ->method('handleException')
+ ->with($exception);
+
+ $handler = new Whoops($app);
+ $handler->render($request, $exception);
+ }
+}
diff --git a/tests/Unit/HelpersTest.php b/tests/Unit/HelpersTest.php
new file mode 100644
index 00000000..43c29c84
--- /dev/null
+++ b/tests/Unit/HelpersTest.php
@@ -0,0 +1,208 @@
+<?php
+
+namespace Engelsystem\Test\Unit;
+
+use Engelsystem\Application;
+use Engelsystem\Config\Config;
+use Engelsystem\Container\Container;
+use Engelsystem\Http\Request;
+use Engelsystem\Renderer\Renderer;
+use Engelsystem\Routing\UrlGenerator;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Symfony\Component\HttpFoundation\Session\Session;
+use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface as StorageInterface;
+
+class HelpersTest extends TestCase
+{
+ /**
+ * @covers \app
+ */
+ public function testApp()
+ {
+ $class = new class
+ {
+ };
+
+ $appMock = $this->getAppMock('some.name', $class);
+
+ $this->assertEquals($appMock, app());
+ $this->assertEquals($class, app('some.name'));
+ }
+
+ /**
+ * @covers \base_path()
+ */
+ public function testBasePath()
+ {
+ /** @var MockObject|Application $app */
+ $app = $this->getMockBuilder(Container::class)
+ ->getMock();
+ Application::setInstance($app);
+
+ $app->expects($this->atLeastOnce())
+ ->method('get')
+ ->with('path')
+ ->willReturn('/foo/bar');
+
+ $this->assertEquals('/foo/bar', base_path());
+ $this->assertEquals('/foo/bar/bla-foo.conf', base_path('bla-foo.conf'));
+ }
+
+ /**
+ * @covers \config
+ */
+ public function testConfig()
+ {
+ $configMock = $this->getMockBuilder(Config::class)
+ ->getMock();
+
+ $this->getAppMock('config', $configMock);
+ $this->assertEquals($configMock, config());
+
+ $configMock->expects($this->once())
+ ->method('set')
+ ->with(['foo' => 'bar']);
+
+ $this->assertTrue(config(['foo' => 'bar']));
+
+ $configMock->expects($this->once())
+ ->method('get')
+ ->with('mail')
+ ->willReturn(['user' => 'FooBar']);
+
+ $this->assertEquals(['user' => 'FooBar'], config('mail'));
+ }
+
+ /**
+ * @covers \config_path()
+ */
+ public function testConfigPath()
+ {
+ /** @var MockObject|Application $app */
+ $app = $this->getMockBuilder(Container::class)
+ ->getMock();
+ Application::setInstance($app);
+
+ $app->expects($this->atLeastOnce())
+ ->method('get')
+ ->with('path.config')
+ ->willReturn('/foo/conf');
+
+ $this->assertEquals('/foo/conf', config_path());
+ $this->assertEquals('/foo/conf/bar.php', config_path('bar.php'));
+ }
+
+ /**
+ * @covers \env
+ */
+ public function testEnv()
+ {
+ putenv('envTestVar=someContent');
+
+ $env = env('envTestVar');
+ $this->assertEquals('someContent', $env);
+
+ $env = env('someRandomEnvVarThatShouldNeverExist', 'someDefaultValue');
+ $this->assertEquals('someDefaultValue', $env);
+ }
+
+ /**
+ * @covers \request
+ */
+ public function testRequest()
+ {
+ $requestMock = $this->getMockBuilder(Request::class)
+ ->getMock();
+
+ $this->getAppMock('request', $requestMock);
+ $this->assertEquals($requestMock, request());
+
+ $requestMock->expects($this->once())
+ ->method('input')
+ ->with('requestKey')
+ ->willReturn('requestValue');
+
+ $this->assertEquals('requestValue', request('requestKey'));
+ }
+
+ /**
+ * @covers \session
+ */
+ public function testSession()
+ {
+ $sessionStorage = $this->getMockForAbstractClass(StorageInterface::class);
+ $sessionMock = $this->getMockBuilder(Session::class)
+ ->setConstructorArgs([$sessionStorage])
+ ->getMock();
+
+ $this->getAppMock('session', $sessionMock);
+ $this->assertEquals($sessionMock, session());
+
+ $sessionMock->expects($this->once())
+ ->method('get')
+ ->with('someKey')
+ ->willReturn('someValue');
+
+ $this->assertEquals('someValue', session('someKey'));
+ }
+
+ /**
+ * @covers \view
+ */
+ public function testView()
+ {
+ $rendererMock = $this->getMockBuilder(Renderer::class)
+ ->getMock();
+
+ $this->getAppMock('renderer', $rendererMock);
+ $this->assertEquals($rendererMock, view());
+
+ $rendererMock->expects($this->once())
+ ->method('render')
+ ->with('template.name', ['template' => 'data'])
+ ->willReturn('rendered template');
+
+ $this->assertEquals('rendered template', view('template.name', ['template' => 'data']));
+ }
+
+ /**
+ * @covers \url
+ */
+ public function testUrl()
+ {
+ $urlGeneratorMock = $this->getMockBuilder(UrlGenerator::class)
+ ->getMock();
+
+ $this->getAppMock('routing.urlGenerator', $urlGeneratorMock);
+ $this->assertEquals($urlGeneratorMock, url());
+
+ $urlGeneratorMock->expects($this->once())
+ ->method('to')
+ ->with('foo/bar', ['param' => 'value'])
+ ->willReturn('http://lorem.ipsum/foo/bar?param=value');
+
+ $this->assertEquals('http://lorem.ipsum/foo/bar?param=value', url('foo/bar', ['param' => 'value']));
+ }
+
+ /**
+ * @param string $alias
+ * @param object $object
+ * @return Application|MockObject
+ */
+ protected function getAppMock($alias, $object)
+ {
+ $appMock = $this->getMockBuilder(Container::class)
+ ->getMock();
+
+ $appMock->expects($this->atLeastOnce())
+ ->method('get')
+ ->with($alias)
+ ->willReturn($object);
+
+ /** @var $appMock Application */
+ Application::setInstance($appMock);
+
+ return $appMock;
+ }
+}
diff --git a/tests/Unit/Http/RequestServiceProviderTest.php b/tests/Unit/Http/RequestServiceProviderTest.php
new file mode 100644
index 00000000..a137b0ac
--- /dev/null
+++ b/tests/Unit/Http/RequestServiceProviderTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Http;
+
+use Engelsystem\Http\Request;
+use Engelsystem\Http\RequestServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+
+class RequestServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Http\RequestServiceProvider::register()
+ */
+ public function testRegister()
+ {
+ /** @var MockObject|Request $request */
+ $request = $this->getMockBuilder(Request::class)
+ ->getMock();
+
+ $app = $this->getApp(['call', 'instance']);
+
+ $this->setExpects($app, 'call', [[Request::class, 'createFromGlobals']], $request);
+ $this->setExpects($app, 'instance', ['request', $request]);
+
+ $serviceProvider = new RequestServiceProvider($app);
+ $serviceProvider->register();
+ }
+}
diff --git a/tests/Unit/Http/RequestTest.php b/tests/Unit/Http/RequestTest.php
new file mode 100644
index 00000000..a68f8b8f
--- /dev/null
+++ b/tests/Unit/Http/RequestTest.php
@@ -0,0 +1,99 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Http;
+
+use Engelsystem\Http\Request;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+
+class RequestTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Http\Request::postData
+ */
+ public function testPostData()
+ {
+ $request = new Request(
+ ['foo' => 'I\'m a test!'],
+ ['foo' => 'bar']
+ );
+
+ $this->assertEquals('bar', $request->postData('foo'));
+ $this->assertEquals('LoremIpsum', $request->postData('test-key', 'LoremIpsum'));
+ }
+
+ /**
+ * @covers \Engelsystem\Http\Request::input
+ */
+ public function testInput()
+ {
+ $request = new Request(
+ ['foo' => 'I\'m a test!'],
+ ['foo' => 'bar']
+ );
+
+ $this->assertEquals('I\'m a test!', $request->input('foo'));
+ $this->assertEquals('LoremIpsum', $request->input('test-key', 'LoremIpsum'));
+ }
+
+ /**
+ * @covers \Engelsystem\Http\Request::has
+ */
+ public function testHas()
+ {
+ $request = new Request([
+ 'foo' => 'I\'m a test!',
+ 'bar' => '',
+ ]);
+
+ $this->assertTrue($request->has('foo'));
+ $this->assertTrue($request->has('bar'));
+ $this->assertFalse($request->has('baz'));
+ }
+
+ /**
+ * @covers \Engelsystem\Http\Request::path
+ */
+ public function testPath()
+ {
+ /** @var MockObject|Request $request */
+ $request = $this
+ ->getMockBuilder(Request::class)
+ ->setMethods(['getPathInfo'])
+ ->getMock();
+
+ $request
+ ->expects($this->atLeastOnce())
+ ->method('getPathInfo')
+ ->willReturnOnConsecutiveCalls(
+ '/foo',
+ '/'
+ );
+
+ $this->assertEquals('foo', $request->path());
+ $this->assertEquals('/', $request->path());
+ }
+
+ /**
+ * @covers \Engelsystem\Http\Request::url
+ */
+ public function testUrl()
+ {
+ /** @var MockObject|Request $request */
+ $request = $this
+ ->getMockBuilder(Request::class)
+ ->setMethods(['getUri'])
+ ->getMock();
+
+ $request
+ ->expects($this->atLeastOnce())
+ ->method('getUri')
+ ->willReturnOnConsecutiveCalls(
+ 'http://foo.bar/bla/foo/',
+ 'https://lorem.ipsum/dolor/sit?amet=consetetur&sadipscing=elitr'
+ );
+
+ $this->assertEquals('http://foo.bar/bla/foo', $request->url());
+ $this->assertEquals('https://lorem.ipsum/dolor/sit', $request->url());
+ }
+}
diff --git a/tests/Unit/Http/SessionServiceProviderTest.php b/tests/Unit/Http/SessionServiceProviderTest.php
new file mode 100644
index 00000000..a78b4f72
--- /dev/null
+++ b/tests/Unit/Http/SessionServiceProviderTest.php
@@ -0,0 +1,128 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Http;
+
+use Engelsystem\Http\Request;
+use Engelsystem\Http\SessionServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Symfony\Component\HttpFoundation\Session\Session;
+use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
+use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
+use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface as StorageInterface;
+
+class SessionServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Http\SessionServiceProvider::register()
+ * @covers \Engelsystem\Http\SessionServiceProvider::getSessionStorage()
+ */
+ public function testRegister()
+ {
+ $app = $this->getApp(['make', 'instance', 'bind', 'get']);
+
+ $sessionStorage = $this->getMockForAbstractClass(StorageInterface::class);
+ $sessionStorage2 = $this->getMockForAbstractClass(StorageInterface::class);
+
+ $session = $this->getSessionMock();
+ $request = $this->getRequestMock();
+
+ /** @var MockObject|SessionServiceProvider $serviceProvider */
+ $serviceProvider = $this->getMockBuilder(SessionServiceProvider::class)
+ ->setConstructorArgs([$app])
+ ->setMethods(['isCli'])
+ ->getMock();
+ $serviceProvider->expects($this->exactly(2))
+ ->method('isCli')
+ ->willReturnOnConsecutiveCalls(true, false);
+
+ $app->expects($this->exactly(4))
+ ->method('make')
+ ->withConsecutive(
+ [MockArraySessionStorage::class],
+ [Session::class],
+ [NativeSessionStorage::class, ['options' => ['cookie_httponly' => true]]],
+ [Session::class]
+ )
+ ->willReturnOnConsecutiveCalls(
+ $sessionStorage,
+ $session,
+ $sessionStorage2,
+ $session
+ );
+ $app->expects($this->atLeastOnce())
+ ->method('instance')
+ ->withConsecutive(
+ ['session.storage', $sessionStorage],
+ ['session', $session]
+ );
+
+ $this->setExpects($app, 'bind', [StorageInterface::class, 'session.storage'], null, $this->atLeastOnce());
+ $this->setExpects($app, 'get', ['request'], $request, $this->atLeastOnce());
+ $this->setExpects($request, 'setSession', [$session], null, $this->atLeastOnce());
+ $this->setExpects($session, 'start', null, null, $this->atLeastOnce());
+
+ $serviceProvider->register();
+ $serviceProvider->register();
+ }
+
+ /**
+ * @covers \Engelsystem\Http\SessionServiceProvider::isCli()
+ */
+ public function testIsCli()
+ {
+ $app = $this->getApp(['make', 'instance', 'bind', 'get']);
+
+ $sessionStorage = $this->getMockForAbstractClass(StorageInterface::class);
+
+ $session = $this->getSessionMock();
+ $request = $this->getRequestMock();
+
+ $app->expects($this->exactly(2))
+ ->method('make')
+ ->withConsecutive(
+ [MockArraySessionStorage::class],
+ [Session::class]
+ )
+ ->willReturnOnConsecutiveCalls(
+ $sessionStorage,
+ $session
+ );
+ $app->expects($this->exactly(2))
+ ->method('instance')
+ ->withConsecutive(
+ ['session.storage', $sessionStorage],
+ ['session', $session]
+ );
+
+ $this->setExpects($app, 'bind', [StorageInterface::class, 'session.storage']);
+ $this->setExpects($app, 'get', ['request'], $request);
+ $this->setExpects($request, 'setSession', [$session]);
+ $this->setExpects($session, 'start');
+
+ $serviceProvider = new SessionServiceProvider($app);
+ $serviceProvider->register();
+ }
+
+ /**
+ * @return MockObject
+ */
+ private function getSessionMock()
+ {
+ $sessionStorage = $this->getMockForAbstractClass(StorageInterface::class);
+ return $this->getMockBuilder(Session::class)
+ ->setConstructorArgs([$sessionStorage])
+ ->setMethods(['start'])
+ ->getMock();
+ }
+
+ /**
+ * @return MockObject
+ */
+ private function getRequestMock()
+ {
+ return $this->getMockBuilder(Request::class)
+ ->setMethods(['setSession'])
+ ->getMock();
+ }
+}
diff --git a/tests/Unit/Logger/LoggerServiceProviderTest.php b/tests/Unit/Logger/LoggerServiceProviderTest.php
new file mode 100644
index 00000000..cef95d5b
--- /dev/null
+++ b/tests/Unit/Logger/LoggerServiceProviderTest.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Logger;
+
+use Engelsystem\Logger\EngelsystemLogger;
+use Engelsystem\Logger\LoggerServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject;
+use Psr\Log\LoggerInterface;
+
+class LoggerServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Logger\LoggerServiceProvider::register()
+ */
+ public function testRegister()
+ {
+ /** @var PHPUnit_Framework_MockObject_MockObject|EngelsystemLogger $logger */
+ $logger = $this->getMockBuilder(EngelsystemLogger::class)
+ ->getMock();
+
+ $app = $this->getApp(['make', 'instance', 'bind']);
+
+ $this->setExpects($app, 'make', [EngelsystemLogger::class], $logger);
+ $this->setExpects($app, 'instance', ['logger', $logger]);
+
+ $app->expects($this->atLeastOnce())
+ ->method('bind')
+ ->withConsecutive(
+ [LoggerInterface::class, 'logger'],
+ [EngelsystemLogger::class, 'logger']
+ );
+
+ $serviceProvider = new LoggerServiceProvider($app);
+ $serviceProvider->register();
+ }
+}
diff --git a/tests/Unit/Renderer/HtmlEngineTest.php b/tests/Unit/Renderer/HtmlEngineTest.php
new file mode 100644
index 00000000..8c262932
--- /dev/null
+++ b/tests/Unit/Renderer/HtmlEngineTest.php
@@ -0,0 +1,67 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Renderer;
+
+use Engelsystem\Renderer\HtmlEngine;
+use PHPUnit\Framework\TestCase;
+
+class HtmlEngineTest extends TestCase
+{
+ /** @var string[] */
+ protected $tmpFileNames = [];
+
+ /**
+ * @covers \Engelsystem\Renderer\HtmlEngine::get
+ */
+ public function testGet()
+ {
+ $engine = new HtmlEngine();
+
+ $file = $this->createTempFile('<div>%main_content%</div>');
+
+ $data = $engine->get($file, ['main_content' => 'Lorem ipsum dolor sit']);
+ $this->assertEquals('<div>Lorem ipsum dolor sit</div>', $data);
+ }
+
+ /**
+ * @covers \Engelsystem\Renderer\HtmlEngine::canRender
+ */
+ public function testCanRender()
+ {
+ $engine = new HtmlEngine();
+
+ $this->assertFalse($engine->canRender('/dev/null'));
+
+ $file = $this->createTempFile();
+ $this->assertTrue($engine->canRender($file));
+
+ $htmFile = $this->createTempFile('', '.htm');
+ $this->assertTrue($engine->canRender($htmFile));
+ }
+
+ /**
+ * @param string $content
+ * @param string $extension
+ * @return string
+ */
+ protected function createTempFile($content = '', $extension = '.html')
+ {
+ $tmpFileName = tempnam(sys_get_temp_dir(), 'EngelsystemUnitTest');
+
+ $fileName = $tmpFileName . $extension;
+ rename($tmpFileName, $fileName);
+
+ file_put_contents($fileName, $content);
+
+ $this->tmpFileNames[] = $fileName;
+
+ return $fileName;
+ }
+
+ public function tearDown()
+ {
+ foreach ($this->tmpFileNames as $fileName) {
+ unlink($fileName);
+ }
+ }
+}
diff --git a/tests/Unit/Renderer/RendererServiceProviderTest.php b/tests/Unit/Renderer/RendererServiceProviderTest.php
new file mode 100644
index 00000000..3826da7e
--- /dev/null
+++ b/tests/Unit/Renderer/RendererServiceProviderTest.php
@@ -0,0 +1,81 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Renderer;
+
+use Engelsystem\Renderer\EngineInterface;
+use Engelsystem\Renderer\HtmlEngine;
+use Engelsystem\Renderer\Renderer;
+use Engelsystem\Renderer\RendererServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject;
+
+class RendererServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Renderer\RendererServiceProvider::register()
+ * @covers \Engelsystem\Renderer\RendererServiceProvider::registerRenderer()
+ * @covers \Engelsystem\Renderer\RendererServiceProvider::registerHtmlEngine()
+ */
+ public function testRegister()
+ {
+ /** @var PHPUnit_Framework_MockObject_MockObject|Renderer $renderer */
+ $renderer = $this->getMockBuilder(Renderer::class)
+ ->getMock();
+ /** @var PHPUnit_Framework_MockObject_MockObject|HtmlEngine $htmlEngine */
+ $htmlEngine = $this->getMockBuilder(HtmlEngine::class)
+ ->getMock();
+
+ $app = $this->getApp(['make', 'instance', 'tag']);
+
+ $app->expects($this->exactly(2))
+ ->method('make')
+ ->withConsecutive(
+ [Renderer::class],
+ [HtmlEngine::class]
+ )->willReturnOnConsecutiveCalls(
+ $renderer,
+ $htmlEngine
+ );
+
+ $app->expects($this->exactly(2))
+ ->method('instance')
+ ->withConsecutive(
+ ['renderer', $renderer],
+ ['renderer.htmlEngine', $htmlEngine]
+ );
+
+ $this->setExpects($app, 'tag', ['renderer.htmlEngine', ['renderer.engine']]);
+
+ $serviceProvider = new RendererServiceProvider($app);
+ $serviceProvider->register();
+ }
+
+ /**
+ * @covers \Engelsystem\Renderer\RendererServiceProvider::boot()
+ */
+ public function testBoot()
+ {
+ /** @var PHPUnit_Framework_MockObject_MockObject|Renderer $renderer */
+ $renderer = $this->getMockBuilder(Renderer::class)
+ ->getMock();
+ /** @var PHPUnit_Framework_MockObject_MockObject|EngineInterface $engine1 */
+ $engine1 = $this->getMockForAbstractClass(EngineInterface::class);
+ /** @var PHPUnit_Framework_MockObject_MockObject|EngineInterface $engine2 */
+ $engine2 = $this->getMockForAbstractClass(EngineInterface::class);
+
+ $app = $this->getApp(['get', 'tagged']);
+
+ $engines = [$engine1, $engine2];
+
+ $this->setExpects($app, 'get', ['renderer'], $renderer);
+ $this->setExpects($app, 'tagged', ['renderer.engine'], $engines);
+
+ $invocation = $renderer
+ ->expects($this->exactly(count($engines)))
+ ->method('addRenderer');
+ call_user_func_array([$invocation, 'withConsecutive'], $engines);
+
+ $serviceProvider = new RendererServiceProvider($app);
+ $serviceProvider->boot();
+ }
+}
diff --git a/tests/Unit/Renderer/RendererTest.php b/tests/Unit/Renderer/RendererTest.php
new file mode 100644
index 00000000..969ced7f
--- /dev/null
+++ b/tests/Unit/Renderer/RendererTest.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Renderer;
+
+use Engelsystem\Renderer\EngineInterface;
+use Engelsystem\Renderer\Renderer;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Psr\Log\LoggerInterface;
+
+class RendererTest extends TestCase
+{
+ public function testGet()
+ {
+ $renderer = new Renderer();
+
+ /** @var MockObject|EngineInterface $nullRenderer */
+ $nullRenderer = $this->getMockForAbstractClass(EngineInterface::class);
+
+ $nullRenderer->expects($this->atLeastOnce())
+ ->method('canRender')
+ ->willReturn(false);
+ $renderer->addRenderer($nullRenderer);
+
+ /** @var MockObject|EngineInterface $mockRenderer */
+ $mockRenderer = $this->getMockForAbstractClass(EngineInterface::class);
+
+ $mockRenderer->expects($this->atLeastOnce())
+ ->method('canRender')
+ ->with('foo.template')
+ ->willReturn(true);
+
+ $mockRenderer->expects($this->atLeastOnce())
+ ->method('get')
+ ->with('foo.template', ['lorem' => 'ipsum'])
+ ->willReturn('Rendered content');
+
+ $renderer->addRenderer($mockRenderer);
+ $data = $renderer->render('foo.template', ['lorem' => 'ipsum']);
+
+ $this->assertEquals('Rendered content', $data);
+ }
+
+ public function testError()
+ {
+ $renderer = new Renderer();
+
+ /** @var MockObject|LoggerInterface $loggerMock */
+ $loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
+ $loggerMock
+ ->expects($this->once())
+ ->method('error');
+
+ $renderer->setLogger($loggerMock);
+
+ $data = $renderer->render('testing.template');
+ $this->assertEquals('', $data);
+ }
+}
diff --git a/tests/Unit/Routing/RoutingServiceProviderTest.php b/tests/Unit/Routing/RoutingServiceProviderTest.php
new file mode 100644
index 00000000..dd9441eb
--- /dev/null
+++ b/tests/Unit/Routing/RoutingServiceProviderTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Routing;
+
+use Engelsystem\Routing\RoutingServiceProvider;
+use Engelsystem\Routing\UrlGenerator;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject;
+
+class RoutingServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Routing\RoutingServiceProvider::register()
+ */
+ public function testRegister()
+ {
+ /** @var PHPUnit_Framework_MockObject_MockObject|UrlGenerator $urlGenerator */
+ $urlGenerator = $this->getMockBuilder(UrlGenerator::class)
+ ->getMock();
+
+ $app = $this->getApp();
+
+ $this->setExpects($app, 'make', [UrlGenerator::class], $urlGenerator);
+ $this->setExpects($app, 'instance', ['routing.urlGenerator', $urlGenerator]);
+
+ $serviceProvider = new RoutingServiceProvider($app);
+ $serviceProvider->register();
+ }
+}
diff --git a/tests/Unit/Routing/UrlGeneratorTest.php b/tests/Unit/Routing/UrlGeneratorTest.php
new file mode 100644
index 00000000..6da59a4f
--- /dev/null
+++ b/tests/Unit/Routing/UrlGeneratorTest.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Routing;
+
+use Engelsystem\Application;
+use Engelsystem\Container\Container;
+use Engelsystem\Http\Request;
+use Engelsystem\Routing\UrlGenerator;
+use PHPUnit\Framework\TestCase;
+
+class UrlGeneratorTest extends TestCase
+{
+ public function provideLinksTo()
+ {
+ return [
+ ['/foo/path', '/foo/path', 'http://foo.bar/foo/path', [], 'http://foo.bar/foo/path'],
+ ['foo', '/foo', 'https://foo.bar/foo', [], 'https://foo.bar/foo'],
+ ['foo', '/foo', 'http://f.b/foo', ['test' => 'abc', 'bla' => 'foo'], 'http://f.b/foo?test=abc&bla=foo'],
+ ];
+ }
+
+ /**
+ * @dataProvider provideLinksTo
+ * @covers \Engelsystem\Routing\UrlGenerator::to
+ *
+ * @param string $path
+ * @param string $willReturn
+ * @param string $urlToPath
+ * @param string[] $arguments
+ * @param string $expectedUrl
+ */
+ public function testTo($urlToPath, $path, $willReturn, $arguments, $expectedUrl)
+ {
+ $app = new Container();
+ $urlGenerator = new UrlGenerator();
+ Application::setInstance($app);
+
+ $request = $this->getMockBuilder(Request::class)
+ ->getMock();
+
+ $request->expects($this->once())
+ ->method('getUriForPath')
+ ->with($path)
+ ->willReturn($willReturn);
+
+ $app->instance('request', $request);
+
+ $url = $urlGenerator->to($urlToPath, $arguments);
+ $this->assertEquals($expectedUrl, $url);
+ }
+}
diff --git a/tests/Unit/ServiceProviderTest.php b/tests/Unit/ServiceProviderTest.php
new file mode 100644
index 00000000..dc58a65e
--- /dev/null
+++ b/tests/Unit/ServiceProviderTest.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Engelsystem\Test\Unit;
+
+use Engelsystem\Application;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_Matcher_InvokedRecorder as InvokedRecorder;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+
+abstract class ServiceProviderTest extends TestCase
+{
+ /**
+ * @param array $methods
+ * @return Application|MockObject
+ */
+ protected function getApp($methods = ['make', 'instance'])
+ {
+ /** @var MockObject|Application $app */
+ return $this->getMockBuilder(Application::class)
+ ->setMethods($methods)
+ ->getMock();
+ }
+
+ /**
+ * @param MockObject $object
+ * @param string $method
+ * @param array $arguments
+ * @param mixed $return
+ * @param InvokedRecorder $times
+ */
+ protected function setExpects($object, $method, $arguments = null, $return = null, $times = null)
+ {
+ if (is_null($times)) {
+ $times = $this->once();
+ }
+
+ $invocation = $object->expects($times)
+ ->method($method);
+
+ if (is_null($arguments)) {
+ $invocation->withAnyParameters();
+ } else {
+ call_user_func_array([$invocation, 'with'], $arguments);
+ }
+
+ if (!is_null($return)) {
+ $invocation->willReturn($return);
+ }
+ }
+}
diff --git a/tests/autoload.php b/tests/autoload.php
new file mode 100644
index 00000000..3168ce3d
--- /dev/null
+++ b/tests/autoload.php
@@ -0,0 +1,8 @@
+<?php
+
+use Composer\Autoload\ClassLoader;
+
+require_once __DIR__ . '/../includes/autoload.php';
+
+/** @var $loader ClassLoader */
+$loader->addPsr4('Engelsystem\\Test\\', __DIR__ . '/');
diff --git a/themes/assets/bootstrap b/themes/assets/bootstrap
deleted file mode 160000
-Subproject ad716b9ea9506456f28e2c1bcdd7b4a81b44c11
diff --git a/themes/base.less b/themes/base.less
index 2bee2187..677f3200 100644
--- a/themes/base.less
+++ b/themes/base.less
@@ -1,4 +1,4 @@
-@import "assets/bootstrap/less/bootstrap";
+@import "../vendor/twbs/bootstrap/less/bootstrap";
@icon-font-path: "../../../../vendor/bootstrap/fonts/";
@@ -11,14 +11,14 @@ body {
}
.first {
- margin-top: 30px;
+ margin-top: 30px;
}
.text-big {
- display: block;
- font-size: 30px;
- line-height: 30px;
- margin: 0px;
+ display: block;
+ font-size: 30px;
+ line-height: 30px;
+ margin: 0px;
}
.panel-primary .panel-heading a {
@@ -51,51 +51,51 @@ body {
flex-wrap: nowrap;
align-itmes: stretch;
width: 100%;
-
- .lane {
- background: @table-bg-accent;
- flex-grow: 1;
- min-width: 280px;
- width: 280px;
- flex-shrink: 1;
-
- .header {
- background: @panel-bg;
- border-bottom: 1px solid @table-border-color;
- height: 30px;
- padding: 5px 5px 5px 16px;
- }
-
- .tick {
- height: 30px;
- border-top: 1px solid darken(@table-bg-accent, 2%);
- }
-
+
+ .lane {
+ background: @table-bg-accent;
+ flex-grow: 1;
+ min-width: 280px;
+ width: 280px;
+ flex-shrink: 1;
+
+ .header {
+ background: @panel-bg;
+ border-bottom: 1px solid @table-border-color;
+ height: 30px;
+ padding: 5px 5px 5px 16px;
+ }
+
+ .tick {
+ height: 30px;
+ border-top: 1px solid darken(@table-bg-accent, 2%);
+ }
+
.tick.hour {
border-top: 2px solid @table-border-color;
font-size: 0.9em;
padding-left: 5px;
}
-
+
.tick.day {
border-top: 2px solid @brand-primary;
font-size: 0.9em;
padding-left: 5px;
}
- }
-
- .lane.time {
- border-right: 1px solid @table-border-color;
- flex-grow: 0;
- min-width: 50px;
- width: 50px;
- flex-shrink: 0;
- }
-
- .shift {
- margin: 0 5px 5px 0;
- overflow: hidden;
- }
+ }
+
+ .lane.time {
+ border-right: 1px solid @table-border-color;
+ flex-grow: 0;
+ min-width: 50px;
+ width: 50px;
+ flex-shrink: 0;
+ }
+
+ .shift {
+ margin: 0 5px 5px 0;
+ overflow: hidden;
+ }
}
.space-top {
@@ -119,22 +119,22 @@ body {
@keyframes pulse {
0% {
- transform: rotate(0deg);
+ transform: rotate(0deg);
}
10% {
- transform: rotate(5deg) translateY(-2px);
+ transform: rotate(5deg) translateY(-2px);
}
20% {
- transform: rotate(-5deg);
+ transform: rotate(-5deg);
}
- 30% {
- transform: rotate(5deg) translateY(-2px);;
+ 30% {
+ transform: rotate(5deg) translateY(-2px);;
}
- 40% {
- transform: rotate(-5deg);
+ 40% {
+ transform: rotate(-5deg);
}
- 50% {
- transform: rotate(0deg) translateY(-2px);
+ 50% {
+ transform: rotate(0deg) translateY(-2px);
}
75% {
transform: rotate(0deg) translateY(0px);
@@ -143,22 +143,22 @@ body {
@-webkit-keyframes pulse {
0% {
- transform: rotate(0deg);
+ transform: rotate(0deg);
}
10% {
- transform: rotate(5deg) translateY(-2px);
+ transform: rotate(5deg) translateY(-2px);
}
20% {
- transform: rotate(-5deg);
+ transform: rotate(-5deg);
}
- 30% {
- transform: rotate(5deg) translateY(-2px);
+ 30% {
+ transform: rotate(5deg) translateY(-2px);
}
- 40% {
- transform: rotate(-5deg);
+ 40% {
+ transform: rotate(-5deg);
}
- 50% {
- transform: rotate(0deg) translateY(-2px);
+ 50% {
+ transform: rotate(0deg) translateY(-2px);
}
75% {
transform: rotate(0deg) translateY(0px);
@@ -167,22 +167,22 @@ body {
@-moz-keyframes pulse {
0% {
- transform: rotate(0deg);
+ transform: rotate(0deg);
}
10% {
- transform: rotate(5deg) translateY(-2px);
+ transform: rotate(5deg) translateY(-2px);
}
20% {
- transform: rotate(-5deg);
+ transform: rotate(-5deg);
}
- 30% {
- transform: rotate(5deg) translateY(-2px);
+ 30% {
+ transform: rotate(5deg) translateY(-2px);
}
- 40% {
- transform: rotate(-5deg);
+ 40% {
+ transform: rotate(-5deg);
}
- 50% {
- transform: rotate(0deg) translateY(-2px);
+ 50% {
+ transform: rotate(0deg) translateY(-2px);
}
75% {
transform: rotate(0deg) translateY(0px);
diff --git a/themes/theme1.less b/themes/theme1.less
index 134e79b7..7a893951 100644
--- a/themes/theme1.less
+++ b/themes/theme1.less
@@ -1,4 +1,4 @@
-@import "assets/bootstrap/less/variables";
+@import "../vendor/twbs/bootstrap/less/variables";
/*
The MIT License (MIT)
diff --git a/themes/theme2.less b/themes/theme2.less
index 344e23c6..c4486444 100644
--- a/themes/theme2.less
+++ b/themes/theme2.less
@@ -1,4 +1,4 @@
-@import "assets/bootstrap/less/variables";
+@import "../vendor/twbs/bootstrap/less/variables";
@brand-primary: #758499;
@brand-success: #7b9c41;
diff --git a/themes/theme3.less b/themes/theme3.less
index 7e7e0f69..e6be3637 100644
--- a/themes/theme3.less
+++ b/themes/theme3.less
@@ -1,4 +1,4 @@
-@import "assets/bootstrap/less/variables";
+@import "../vendor/twbs/bootstrap/less/variables";
@brand-primary: #f19224;
@brand-success: #39AB50;
diff --git a/themes/theme4.less b/themes/theme4.less
index 2ad8593d..4234de9c 100644
--- a/themes/theme4.less
+++ b/themes/theme4.less
@@ -1,4 +1,4 @@
-@import "assets/bootstrap/less/variables";
+@import "../vendor/twbs/bootstrap/less/variables";
/*
The MIT License (MIT)
diff --git a/vendor/parsedown b/vendor/parsedown
deleted file mode 160000
-Subproject 3ebbd730b5c2cf5ce78bc1bf64071407fc6674b