public static function login($user, $keepLoggedIn = true, $dontLog = false) { $_SESSION['dw-user-id'] = $user->getId(); self::getInstance()->user = $user; if (!$dontLog) { Action::logAction($user, 'login'); } // reload plugins since there might be new plugins // becoming available after logins DatawrapperPluginManager::load(); $_SESSION['persistent'] = $keepLoggedIn; $_SESSION['last_action_time'] = time(); // make sure that the charts of the guest now belong to // the logged or newly created user $charts = ChartQuery::create()->findByGuestSession(session_id()); foreach ($charts as $chart) { $chart->setAuthorId($user->getId()); $chart->setGuestSession(''); $chart->save(); } // restore user organization if (empty($_SESSION['dw-user-organization'])) { // let's check the last chart $lastChart = ChartQuery::create()->filterByUser($user)->filterByOrganizationId(null, Criteria::ISNOTNULL)->orderByLastModifiedAt(Criteria::DESC)->findOne(); if (!empty($lastChart)) { $_SESSION['dw-user-organization'] = $lastChart->getOrganization()->getId(); } } }
fwrite($h, microtime(true) . ': ' . $txt . "\n"); fclose($h); } require ROOT_PATH . 'lib/l10n.php'; require ROOT_PATH . 'lib/utils/parse_config.php'; parse_config(); if (!defined('NO_SLIM')) { // Initialize Slim app.. if (ROOT_PATH == '../') { // ..either with TwigView for Datawrapper UI,... require_once ROOT_PATH . 'vendor/Slim-Extras/Views/TwigView.php'; TwigView::$twigDirectory = ROOT_PATH . 'vendor/Twig'; $app = new Slim(array('view' => new TwigView(), 'templates.path' => '../templates', 'session.handler' => null)); } else { // ..or with JSONView for API. require ROOT_PATH . 'lib/api/views/JSONView.php'; $app = new Slim(array('view' => 'JSONView')); } } require ROOT_PATH . 'lib/visualization/DatawrapperVisualization.php'; require ROOT_PATH . 'lib/theme/DatawrapperTheme.php'; require ROOT_PATH . 'lib/plugin/DatawrapperPlugin.php'; require ROOT_PATH . 'lib/hooks/DatawrapperHooks.php'; require ROOT_PATH . 'lib/mail.php'; require ROOT_PATH . 'lib/utils/memcache.php'; require ROOT_PATH . 'lib/utils/vksprintf.php'; require ROOT_PATH . 'lib/utils/copy_recursively.php'; require ROOT_PATH . 'lib/plugin/load_plugins.php'; require_once ROOT_PATH . 'lib/utils/i18n.php'; DatawrapperPluginManager::load();