diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/autoload.php | 2 | ||||
-rw-r--r-- | includes/engelsystem.php | 61 | ||||
-rw-r--r-- | includes/helper/internationalization_helper.php | 2 | ||||
-rw-r--r-- | includes/includes.php (renamed from includes/engelsystem_provider.php) | 124 | ||||
-rw-r--r-- | includes/model/Shifts_model.php | 4 | ||||
-rw-r--r-- | includes/model/UserAngelTypes_model.php | 2 | ||||
-rw-r--r-- | includes/pages/user_shifts.php | 2 |
7 files changed, 68 insertions, 129 deletions
diff --git a/includes/autoload.php b/includes/autoload.php index f51f89e4..0cd9d355 100644 --- a/includes/autoload.php +++ b/includes/autoload.php @@ -6,4 +6,4 @@ if (!is_readable(__DIR__ . '/../vendor/autoload.php')) { } // Include composer autoloader -require_once __DIR__ . '/../vendor/autoload.php'; +$loader = require __DIR__ . '/../vendor/autoload.php'; diff --git a/includes/engelsystem.php b/includes/engelsystem.php new file mode 100644 index 00000000..97076895 --- /dev/null +++ b/includes/engelsystem.php @@ -0,0 +1,61 @@ +<?php + +use Engelsystem\Application; +use Engelsystem\Config\Config; +use Engelsystem\Exceptions\Handler as ExceptionHandler; + +/** + * 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(ExceptionHandler::ENV_DEVELOPMENT); + ini_set('display_errors', true); + error_reporting(E_ALL); +} else { + ini_set('display_errors', false); +} + + +/** + * Check for maintenance + */ +if ($app->get('config')->get('maintenance')) { + echo file_get_contents(__DIR__ . '/../templates/maintenance.html'); + die(); +} + + +/** + * Init translations + */ +gettext_init(); + + +/** + * Init authorization + */ +load_auth(); diff --git a/includes/helper/internationalization_helper.php b/includes/helper/internationalization_helper.php index efbe5db5..7fa6518b 100644 --- a/includes/helper/internationalization_helper.php +++ b/includes/helper/internationalization_helper.php @@ -36,7 +36,7 @@ function gettext_init() } gettext_locale(); - bindtextdomain('default', realpath(__DIR__ . '/../../locale')); + bindtextdomain('default', app('path.lang')); bind_textdomain_codeset('default', 'UTF-8'); textdomain('default'); } diff --git a/includes/engelsystem_provider.php b/includes/includes.php index 0de5e0f5..a42f960f 100644 --- a/includes/engelsystem_provider.php +++ b/includes/includes.php @@ -1,115 +1,5 @@ <?php -use Engelsystem\Application; -use Engelsystem\Config\Config; -use Engelsystem\Database\Db; -use Engelsystem\Exceptions\Handler as ExceptionHandler; -use Engelsystem\Http\Request; -use Engelsystem\Logger\EngelsystemLogger; -use Engelsystem\Renderer\HtmlEngine; -use Engelsystem\Renderer\Renderer; -use Engelsystem\Routing\UrlGenerator; -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; - -/** - * This file includes all needed functions, connects to the db etc. - */ -require_once __DIR__ . '/autoload.php'; - - -/** - * Initialize the application - */ -$app = Application::getInstance(); - - -/** - * Load configuration - */ -$config = new Config(); -$app->instance('config', $config); -$config->set(require __DIR__ . '/../config/config.default.php'); - -if (file_exists(__DIR__ . '/../config/config.php')) { - $config->set(array_replace_recursive( - $config->get(null), - require __DIR__ . '/../config/config.php' - )); -} - -date_default_timezone_set($config->get('timezone')); - - -/** - * Initialize Request - * - * @var Request $request - */ -$request = Request::createFromGlobals(); -$app->instance('request', $request); - - -/** - * Check for maintenance - */ -if ($config->get('maintenance')) { - echo file_get_contents(__DIR__ . '/../templates/maintenance.html'); - die(); -} - - -/** - * Register UrlGenerator - */ -$urlGenerator = new UrlGenerator(); -$app->instance('routing.urlGenerator', $urlGenerator); - - -/** - * Initialize renderer - */ -$renderer = new Renderer(); -$app->instance('renderer', $renderer); -$renderer->addRenderer(new HtmlEngine()); - - -/** - * Register error handler - */ -$errorHandler = new ExceptionHandler(); -$app->instance('error.handler', $errorHandler); -if (config('environment') == 'development') { - $errorHandler->setEnvironment(ExceptionHandler::ENV_DEVELOPMENT); - ini_set('display_errors', true); - error_reporting(E_ALL); -} else { - ini_set('display_errors', false); -} - - -/** - * Connect to database - */ -Db::connect( - 'mysql:host=' . config('database')['host'] . ';dbname=' . config('database')['db'] . ';charset=utf8', - config('database')['user'], - config('database')['pw'] -) || die('Error: Unable to connect to database'); -Db::getPdo()->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -Db::getPdo()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); - -/** - * Init logger - */ -$logger = new EngelsystemLogger(); -$app->instance('logger', $logger); -$app->instance(LoggerInterface::class, $logger); -$app->instance(EngelsystemLogger::class, $logger); - - /** * Include legacy code */ @@ -194,17 +84,3 @@ $includeFiles = [ foreach ($includeFiles as $file) { require_once realpath($file); } - - -/** - * Init application - */ -$sessionStorage = (PHP_SAPI != 'cli' ? new NativeSessionStorage(['cookie_httponly' => true]) : new MockArraySessionStorage()); -$session = new Session($sessionStorage); -$app->instance('session', $session); -$session->start(); -$request->setSession($session); - -gettext_init(); - -load_auth(); diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 03f8341f..ef02aaab 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -481,9 +481,10 @@ function Shift_create($shift) `URL`, `PSID`, `created_by_user_id`, + `edited_at_timestamp`, `created_at_timestamp` ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ', [ $shift['shifttype_id'], @@ -495,6 +496,7 @@ function Shift_create($shift) $shift['PSID'], $user['UID'], time(), + time(), ] ); diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php index 5b0caf98..0c413010 100644 --- a/includes/model/UserAngelTypes_model.php +++ b/includes/model/UserAngelTypes_model.php @@ -59,7 +59,7 @@ function User_unconfirmed_AngelTypes($user) AND `UserAngelTypes`.`supporter`=TRUE AND `AngelTypes`.`restricted`=TRUE AND `UnconfirmedMembers`.`confirm_user_id` IS NULL - GROUP BY `UserAngelTypes`.`angeltype_id` + GROUP BY `UserAngelTypes`.`angeltype_id`, `UserAngelTypes`.`id` ORDER BY `AngelTypes`.`name` ', [$user['UID']]); } diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 2bd7688f..24b9251a 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -109,7 +109,7 @@ function load_days() $days = DB::select(' SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` FROM `Shifts` - ORDER BY `start` + ORDER BY `id`, `name` '); $days = array_map('array_shift', $days); |