clearSectionNavigationPreference() public method

Also optionally resets the section dashboard landing page, which may be desirable if a user no longer has permission to access pages in that section.
public clearSectionNavigationPreference ( string $url = '', string $userID = '', boolean $resetSectionPreference = true )
$url string The url to search the user navigation preferences for, defaults to the request
$userID string The ID of the user to clear the preferences for, defaults to the sessioned user
$resetSectionPreference boolean Whether to reset the dashboard section landing page
コード例 #1
0
ファイル: class.hooks.php プロジェクト: vanilla/vanilla
 /**
  * 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
             }
         }
     }
 }
コード例 #2
0
 /**
  * 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);
     }
 }