AutologoutManagerInterface.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace Drupal\autologout;
  3. /**
  4. * Interface for AutologoutManager.
  5. */
  6. interface AutologoutManagerInterface {
  7. /**
  8. * Get the timer HTML markup.
  9. *
  10. * @return string
  11. * HTML to insert a countdown timer.
  12. */
  13. public function createTimer();
  14. /**
  15. * Get the time remaining before logout.
  16. *
  17. * @return int
  18. * Number of seconds remaining.
  19. */
  20. public function getRemainingTime();
  21. /**
  22. * Go through every role to get timeout value, default is the global timeout.
  23. *
  24. * @return int
  25. * Number of seconds timeout set for the user role.
  26. */
  27. public function getRoleTimeout();
  28. /**
  29. * Get a user's timeout in seconds.
  30. *
  31. * @param int $uid
  32. * (Optional) Provide a user's uid to get the timeout for.
  33. * Default is the logged in user.
  34. *
  35. * @return int
  36. * The number of seconds the user can be idle for before being logged out.
  37. * A value of 0 means no timeout.
  38. */
  39. public function getUserTimeout($uid = NULL);
  40. /**
  41. * Perform Logout.
  42. *
  43. * Helper to perform the actual logout. Destroys the session of the logged
  44. * in user.
  45. */
  46. public function logout();
  47. /**
  48. * Helper to determine if a given user should be autologged out.
  49. */
  50. public function logoutRole($user);
  51. /**
  52. * Display the inactivity message if required when the user is logged out.
  53. */
  54. public function inactivityMessage();
  55. /**
  56. * Determine if autologout should be prevented.
  57. *
  58. * @return bool
  59. * TRUE if there is a reason not to autologout
  60. * the current user on the current page.
  61. */
  62. public function preventJs();
  63. /**
  64. * Determine if connection should be refreshed.
  65. *
  66. * @return bool
  67. * TRUE if something about the current context should keep the connection
  68. * open. FALSE and the standard countdown to autologout applies.
  69. */
  70. public function refreshOnly();
  71. }