commit
599f2fd264
@ -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
|
||||
"
|
@ -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
|
@ -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
|
@ -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/).
|
||||
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
@ -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,
|
||||
],
|
||||
];
|
@ -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;
|
||||
|
@ -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';
|
@ -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();
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function event_config_edit_controller()
|
||||
{
|
||||
global $privileges;
|
||||
|
||||
$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 (!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)
|
||||
];
|
||||
return [
|
||||
event_config_title(),
|
||||
EventConfig_edit_view(
|
||||
$event_name,
|
||||
$event_welcome_msg,
|
||||
$buildup_start_date,
|
||||
$event_start_date,
|
||||
$event_end_date,
|
||||
$teardown_end_date
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
?>
|
@ -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)) {
|
||||
function shift_entry_add_controller()
|
||||
{
|
||||
global $privileges, $user;
|
||||
|
||||
if (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1") == 0) {
|
||||
$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'];
|
||||
}
|
||||
// Locations laden
|
||||
$rooms = Rooms();
|
||||
$room_array = [];
|
||||
foreach ($rooms as $room) {
|
||||
$room_array[$room['RID']] = $room['Name'];
|
||||
}
|
||||
|
||||
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);
|
||||
$shift = Shift($shift_id);
|
||||
if ($shift == null) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$shift['Name'] = $room_array[$shift['RID']];
|
||||
|
||||
$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');
|
||||
$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") . ' »</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') . ' »</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']) . ' – ' . 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'])
|
||||
. ' – '
|
||||
. 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;
|
||||
function shift_entry_delete_controller()
|
||||
{
|
||||
global $privileges, $user;
|
||||
$request = request();
|
||||
|
||||
if (! isset($_REQUEST['entry_id']) || ! test_request_int('entry_id')) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$entry_id = $_REQUEST['entry_id'];
|
||||
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 = sql_select("
|
||||
SELECT `User`.`Nick`, `ShiftEntry`.`Comment`, `ShiftEntry`.`UID`, `ShiftTypes`.`name`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type`, `AngelTypes`.`id` as `angeltype_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];
|
||||
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'));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
$result = ShiftEntry_delete($entry_id);
|
||||
if ($result === false) {
|
||||
engelsystem_error('Unable to delete shift entry.');
|
||||
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));
|
||||
redirect(shift_link($shift_entry_source));
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
function shift_edit_controller()
|
||||
{
|
||||
global $privileges;
|
||||
|
||||
// Schicht bearbeiten
|
||||
$msg = "";
|
||||
$valid = true;
|
||||
// Schicht bearbeiten
|
||||
$msg = '';
|
||||
$valid = true;
|
||||
$request = request();
|
||||
|
||||
if (! in_array('admin_shifts', $privileges)) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
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'];
|
||||
if (!$request->has('edit_shift') || !test_request_int('edit_shift')) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$shift_id = $request->input('edit_shift');
|
||||
|
||||
$shift = Shift($shift_id);
|
||||
$shift = Shift($shift_id);
|
||||
|
||||
$room = select_array(Rooms(), 'RID', 'Name');
|
||||
$angeltypes = select_array(AngelTypes(), 'id', 'name');
|
||||
$shifttypes = select_array(ShiftTypes(), 'id', 'name');
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
$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);
|
||||
$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'));
|
||||
}
|
||||
$shift_id = $request->input('delete_shift');
|
||||
|
||||
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 = 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;
|
||||
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>'
|
||||
]);
|
||||
}
|
||||
|
||||
if (! in_array('user_shifts_admin', $privileges)) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
function shift_controller()
|
||||
{
|
||||
global $user, $privileges;
|
||||
$request = request();
|
||||
|
||||
// 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'];
|
||||
if (!in_array('user_shifts', $privileges)) {
|
||||
redirect(page_link_to('/'));
|
||||
}
|
||||
|
||||
$shift = Shift($shift_id);
|
||||
if ($shift == null) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
if (!$request->has('shift_id')) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
// Schicht löschen bestätigt
|
||||
if (isset($_REQUEST['delete'])) {
|
||||
Shift_delete($shift_id);
|
||||
$shift = Shift($request->input('shift_id'));
|
||||
if ($shift == null) {
|
||||
error(_('Shift could not be found.'));
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
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'));
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
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 [
|
||||
$shift['name'],
|
||||
Shift_view($shift, $shifttype, $room, $angeltypes, $shift_signup_state)
|
||||
];
|
||||
}
|
||||
|
||||
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|false
|
||||
*/
|
||||
function shifts_controller()
|
||||
{
|
||||
$request = request();
|
||||
if (!$request->has('action')) {
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
$angeltype['shift_signup_state'] = $angeltype_signup_state;
|
||||
}
|
||||
|
||||
return [
|
||||
$shift['name'],
|
||||
Shift_view($shift, $shifttype, $room, $angeltypes, $shift_signup_state)
|
||||
];
|
||||
}
|
||||
switch ($request->input('action')) {
|
||||
case 'view':
|
||||
return shift_controller();
|
||||
case 'next':
|
||||
return shift_next_controller();
|
||||
default:
|
||||
redirect(page_link_to('/'));
|
||||
}
|
||||
|
||||
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 false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects the user to his next shift.
|
||||
*/
|
||||
function shift_next_controller() {
|
||||
global $user, $privileges;
|
||||
function shift_next_controller()
|
||||
{
|
||||
global $user, $privileges;
|
||||
|
||||
if (! in_array('user_shifts', $privileges)) {
|
||||
redirect(page_link_to('?'));
|
||||
}
|
||||
if (!in_array('user_shifts', $privileges)) {
|
||||
redirect(page_link_to('/'));
|
||||
}
|
||||
|
||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
||||
if ($upcoming_shifts === false) {
|
||||
return false;
|
||||
}
|
||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
||||
|
||||
if (count($upcoming_shifts) > 0) {
|
||||
redirect(shift_link($upcoming_shifts[0]));
|
||||
}
|
||||
if (!empty($upcoming_shifts)) {
|
||||
redirect(shift_link($upcoming_shifts[0]));
|
||||
}
|
||||
|
||||
redirect(page_link_to('user_shifts'));
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all shifts using api-key.
|
||||
*/
|
||||
function shifts_json_export_all_controller() {
|
||||
global $api_key;
|
||||
function shifts_json_export_all_controller()
|
||||
{
|
||||
$api_key = config('api_key');
|
||||
$request = request();
|
||||
|
||||
if ($api_key == "") {
|
||||
engelsystem_error("Config contains empty apikey.");
|
||||
}
|
||||
if (empty($api_key)) {
|
||||
engelsystem_error('Config contains empty apikey.');
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['api_key'])) {
|
||||
engelsystem_error("Missing parameter api_key.");
|
||||
}
|
||||
if (!$request->has('api_key')) {
|
||||
engelsystem_error('Missing parameter api_key.');
|
||||
}
|
||||
|
||||
if ($_REQUEST['api_key'] != $api_key) {
|
||||
engelsystem_error("Invalid api_key.");
|
||||
}
|
||||
if ($request->input('api_key') != $api_key) {
|
||||
engelsystem_error('Invalid api_key.');
|
||||
}
|
||||
|
||||
$shifts_source = Shifts();
|
||||
if ($shifts_source === false) {
|
||||
engelsystem_error("Unable to load shifts.");
|
||||
}
|
||||
$shifts_source = Shifts();
|
||||
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
raw_output(json_encode($shifts_source));
|
||||
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;
|
||||
function shifts_json_export_controller()
|
||||
{
|
||||
global $user;
|
||||
$request = request();
|
||||
|
||||
if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
|
||||
engelsystem_error("Missing key.");
|
||||
}
|
||||
if (!$request->has('key') || !preg_match('/^[\da-f]{32}$/', $request->input('key'))) {
|
||||
engelsystem_error('Missing key.');
|
||||
}
|
||||
|
||||
$key = $_REQUEST['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.");
|
||||
}
|
||||
$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();
|
||||
$shifts = load_ical_shifts();
|
||||
|
||||
header("Content-Type: application/json; charset=utf-8");
|
||||
raw_output(json_encode($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;
|
||||
function load_ical_shifts()
|
||||
{
|
||||
global $user;
|
||||
|
||||
return Shifts_by_user($user);
|
||||
return Shifts_by_user($user);
|
||||
}
|
||||
|
||||
?>
|
@ -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'));
|
||||
}
|
||||
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)
|
||||
];
|
||||
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.'));
|
||||
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 (isset($_REQUEST['angeltype_id']) && preg_match("/^[0-9]+$/", $_REQUEST['angeltype_id'])) {
|
||||
$angeltype_id = $_REQUEST['angeltype_id'];
|
||||
} else {
|
||||
$angeltype_id = null;
|
||||
}
|
||||
if ($request->has('submit')) {
|
||||
$valid = true;
|
||||
|
||||
if (isset($_REQUEST['description'])) {
|
||||
$description = strip_request_item_nl('description');
|
||||
}
|
||||
if ($request->has('name') && $request->input('name') != '') {
|
||||
$name = strip_request_item('name');
|
||||
} else {
|
||||
$valid = false;
|
||||
error(_('Please enter a name.'));
|
||||
}
|
||||
|
||||
if ($request->has('angeltype_id') && preg_match('/^\d+$/', $request->input('angeltype_id'))) {
|
||||
$angeltype_id = $request->input('angeltype_id');
|
||||
} else {
|
||||
$angeltype_id = null;
|
||||
}
|
||||
|
||||
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('description')) {
|
||||
$description = strip_request_item_nl('description');
|
||||
}
|
||||
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 ($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');
|
||||
}
|
||||
|
||||
?>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
function user_driver_license_required_hint()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$angeltypes = User_angeltypes($user);
|
||||
$user_driver_license = UserDriverLicense($user['UID']);
|
||||
$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;
|
||||
}
|
||||
// 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>');
|
||||
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;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Route user driver licenses actions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function user_driver_licenses_controller() {
|
||||
global $user;
|
||||
function user_driver_licenses_controller()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (! isset($user)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
if (!isset($user)) {
|
||||
redirect(page_link_to(''));
|
||||
}
|
||||
|
||||
$action = strip_request_item('action', 'edit');
|
||||
$action = strip_request_item('action', 'edit');
|
||||
|
||||
switch ($action) {
|
||||
default:
|
||||
case 'edit':
|
||||
return user_driver_license_edit_controller();
|
||||
}
|
||||
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)
|
||||
];
|
||||
return [
|
||||
sprintf(_('Edit %s driving license information'), $user_source['Nick']),
|
||||
UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver_license)
|
||||
];
|
||||
}
|
||||
|
||||
?>
|
@ -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();
|
@ -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();
|
||||
|
||||
?>
|
@ -1,26 +1,50 @@
|
||||
<?php
|
||||
|
||||
function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false) {
|
||||
global $user;
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
if ($not_if_its_me && $user['UID'] == $recipient_user['UID']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
gettext_locale($recipient_user['Sprache']);
|
||||
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.");
|
||||
$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);
|
||||
}
|
||||
gettext_locale();
|
||||
|
||||
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.');
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mail_shift_delete($shift) {
|
||||
$users = ShiftEntries_by_shift($shift["SID"]);
|
||||
$room = Room($shift["RID"]);
|
||||
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;
|
||||
}
|
||||
|
||||
$message = _("A Shift you are registered on was deleted:") . "\n";
|
||||
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;
|
||||
}
|
||||
|
||||
$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";
|
||||
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;
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mail_shift_assign($user, $shift) {
|
||||
if ($user["email_shiftinfo"]) {
|
||||
$room = Room($shift["RID"]);
|
||||
if (!$noticeable_changes) {
|
||||
// There are no changes worth sending an E-Mail
|
||||
return;
|
||||
}
|
||||
|
||||
$message .= "\n";
|
||||
$message .= _('The updated Shift:') . "\n";
|
||||
|
||||
$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";
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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"]);
|
||||
/**
|
||||
* @param array $user
|
||||
* @param array $shift
|
||||
*/
|
||||
function mail_shift_assign($user, $shift)
|
||||
{
|
||||
if (!$user['email_shiftinfo']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$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";
|
||||
$room = Room($shift['RID']);
|
||||
|
||||
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true);
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
@ -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.')
|
||||
);
|
||||
}
|
||||
?>
|
@ -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 int $shifttype_id
|
||||
* @param string $name
|
||||
* @param int $angeltype_id
|
||||
* @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 int $angeltype_id
|
||||
* @param string $description
|
||||
* @return new shifttype id
|
||||
* @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
|
||||
* @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`');
|
||||
}
|
||||
|
||||
?>
|
@ -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']]
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
@ -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)));
|
||||
}
|
||||
|
||||
?>
|
@ -1,67 +1,92 @@
|
||||
<?php
|
||||
|
||||
function admin_news() {
|
||||
global $user;
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
if (! isset($_GET["action"])) {
|
||||
redirect(page_link_to("news"));
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function admin_news()
|
||||
{
|
||||
global $user, $privileges;
|
||||
$request = request();
|
||||
|
||||
$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);
|
||||
}
|
||||
if (!$request->has('action')) {
|
||||
redirect(page_link_to('news'));
|
||||
}
|
||||
|
||||
$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;
|
||||
$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);
|
||||
}
|
||||
|
||||
$user_source = User($news['UID']);
|
||||
$news = DB::selectOne('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$news_id]);
|
||||
if (empty($news)) {
|
||||
return error('No News found.', true);
|
||||
}
|
||||
|
||||
$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));
|
||||
switch ($request->input('action')) {
|
||||
case 'edit':
|
||||
$user_source = User($news['UID']);
|
||||
|
||||
$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;
|
||||
$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])
|
||||
);
|
||||
|
||||
case 'save':
|
||||
list($news) = $news;
|
||||
$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;
|
||||
|
||||
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 'save':
|
||||
$text = $request->postData('eText');
|
||||
if (!in_array('admin_news_html', $privileges)) {
|
||||
$text = strip_tags($text);
|
||||
}
|
||||
|
||||
case 'delete':
|
||||
list($news) = $news;
|
||||
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
|
||||
]
|
||||
);
|
||||
|
||||
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>';
|
||||
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>';
|
||||
}
|
||||
?>
|
@ -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');
|
||||
}
|
||||
?>
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
function guest_start() {
|
||||
redirect(page_link_to('login'));
|
||||
function guest_start()
|
||||
{
|
||||
redirect(page_link_to('login'));
|
||||
return true;
|
||||
}
|
||||
?>
|
@ -1,57 +1,88 @@
|
||||
<?php
|
||||
|
||||
function questions_title() {
|
||||
return _("Ask the Heaven");
|
||||
}
|
||||
use Engelsystem\Database\DB;
|
||||
|
||||
function user_questions() {
|
||||
global $user;
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function questions_title()
|
||||
{
|
||||
return _('Ask the Heaven');
|
||||
}
|
||||
|
||||
if (! isset($_REQUEST['action'])) {
|
||||
$open_questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`='" . sql_escape($user['UID']) . "'");
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function user_questions()
|
||||
{
|
||||
global $user;
|
||||
$request = request();
|
||||
|
||||
$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);
|
||||
}
|
||||
if (!$request->has('action')) {
|
||||
$open_questions = DB::select(
|
||||
'SELECT * FROM `Questions` WHERE `AID` IS NULL AND `UID`=?',
|
||||
[$user['UID']]
|
||||
);
|
||||
|
||||
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);
|
||||
$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 '';
|
||||
}
|
||||
?>
|
@ -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']);
|
||||
}
|
||||
/**
|
||||
* @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>';
|
||||
}
|
||||
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)
|
||||
]);
|
||||
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)
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
@ -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()
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
/**
|
||||
* @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'];
|
||||
}
|
||||
|
@ -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'];
|
||||
}
|
||||
/**
|
||||
* @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'];
|
||||
}
|
||||
|
||||
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'))
|
||||
])
|
||||
]);
|
||||
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 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'])
|
||||
]);
|
||||
/**
|
||||
* @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'])
|
||||
]);
|
||||
}
|
||||
|
||||
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[] $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)
|
||||
]);
|
||||
return page_with_title(shifttypes_title(), [
|
||||
msg(),
|
||||
buttons([
|
||||
button(page_link_to('shifttypes', ['action' => 'edit']), _('New shifttype'), 'add')
|
||||
]),
|
||||
table([
|
||||
'name' => _('Name'),
|
||||
'actions' => ''
|
||||
], $shifttypes)
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
@ -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);
|
||||
}
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
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"))
|
||||
])
|
||||
]);
|
||||
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'))
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
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')
|
||||
])
|
||||
]);
|
||||
/**
|
||||
* @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'
|
||||
)
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -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>
|
||||
|
@ -0,0 +1,8 @@
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue