/** * Clear user navigation preferences if we can't find the explicit method on the controller. * * @param Gdn_Controller $sender * @param array $args Event arguments. We can expect a 'PathArgs' key here. */ public function gdn_dispatcher_methodNotFound_handler($sender, $args) { // If PathArgs is empty, the user hit the root, and we assume they want the index. // If not, they got redirected to the root because their controller method was not // found. We should clear the user prefs in that case. if (!empty($args['PathArgs'])) { if (Gdn::session()->isValid()) { $uri = Gdn::request()->getRequestArguments('server')['REQUEST_URI']; try { $userModel = new UserModel(); $userModel->clearSectionNavigationPreference($uri); } catch (Exception $ex) { // Nothing } } } }
/** * Clears the request uri from the user's navigation preferences. This stops the user from getting locked out of * the dashboard if they saved a preference for a page that no longer exists or that they no longer have * permission to view. */ private function clearNavigationPreferences() { if (Gdn::session()->isValid()) { $uri = Gdn::request()->getRequestArguments('server')['REQUEST_URI']; $userModel = new UserModel(); $userModel->clearSectionNavigationPreference($uri); } }