public function __construct()
{
$user = User::identify();
if (!$user->loggedin) {
Session::add_to_set('login', $_SERVER['REQUEST_URI'], 'original');
if (URL::get_matched_rule()->action == 'admin_ajax' && isset($_SERVER['HTTP_REFERER'])) {
$ar = new AjaxResponse(408, _t('Your session has ended, please log in and try again.'));
$ar->out();
} else {
$post_raw = $_POST->get_array_copy_raw();
if (!empty($post_raw)) {
Session::add_to_set('last_form_data', $post_raw, 'post');
Session::error(_t('We saved the last form you posted. Log back in to continue its submission.'), 'expired_form_submission');
}
$get_raw = $_GET->get_array_copy_raw();
if (!empty($get_raw)) {
Session::add_to_set('last_form_data', $get_raw, 'get');
Session::error(_t('We saved the last form you posted. Log back in to continue its submission.'), 'expired_form_submission');
}
Utils::redirect(URL::get('auth', array('page' => 'login')));
}
exit;
}
$last_form_data = Session::get_set('last_form_data');
// This was saved in the "if ( !$user )" above, UserHandler transferred it properly.
/* At this point, Controller has not created handler_vars, so we have to modify $_POST/$_GET. */
if (isset($last_form_data['post'])) {
$_POST = $_POST->merge($last_form_data['post']);
$_SERVER['REQUEST_METHOD'] = 'POST';
// This will trigger the proper act_admin switches.
Session::remove_error('expired_form_submission');
}
if (isset($last_form_data['get'])) {
$_GET = $_GET->merge($last_form_data['get']);
Session::remove_error('expired_form_submission');
// No need to change REQUEST_METHOD since GET is the default.
}
$user->remember();
// Create an instance of the active public theme so that its plugin functions are implemented
$this->active_theme = Themes::create();
// on every page load check the plugins currently loaded against the list we last checked for updates and trigger a cron if we need to
Update::check_plugins();
}