session_limit.api.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * @file
  4. * This file contains no working PHP code; it exists to provide additional
  5. * documentation for doxygen as well as to document hooks in the standard
  6. * Drupal manner.
  7. */
  8. /**
  9. * Prevent session limitation checks at page load.
  10. *
  11. * Session limit module checks for active sessions during hook_init. If
  12. * a particular path or page load or context may mean that session
  13. * checks should not occur.
  14. *
  15. * @return bool
  16. * TRUE if the current page request should bypass session limitation
  17. * restrictions.
  18. */
  19. function hook_session_limit_bypass() {
  20. if ((arg(0) == 'session' && arg(1) == 'limit') || arg(0) == 'logout') {
  21. return TRUE;
  22. }
  23. }
  24. /**
  25. * Notify other modules that a session imitation event has occured.
  26. *
  27. * When a session limit is reached, this hook is invoked. There are
  28. * two types of event. Collision events happen when a new session
  29. * causes an old session to close. Disconnect events happen when
  30. * a new session is prevented by an existing session.
  31. *
  32. * @param string $sid
  33. * The session id of the session which caused the event. In a
  34. * collision, this is not the session which was ended.
  35. * @param string $op
  36. * Either 'disconnect' or 'collision'.
  37. */
  38. function hook_session_limit($sid, $op) {
  39. global $user;
  40. rules_invoke_event('session_limit_' . $op, $user, $sid);
  41. }