11.cache.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php return '
  2. if (!$UsersOnline = $modx->getService(\'usersonline\', \'UsersOnline\', $modx->getOption(\'usersonline_core_path\', null,
  3. $modx->getOption(\'core_path\') . \'components/usersonline/\') . \'model/usersonline/\', $scriptProperties)
  4. ) {
  5. return \'Could not load UsersOnline class!\';
  6. }
  7. switch ($modx->event->name) {
  8. case \'OnMODXInit\':
  9. $context = $modx->context->key;
  10. if (!$mgr = $modx->getOption(\'usersonline_mgr_check\') and $context == \'mgr\') {
  11. break;
  12. }
  13. if ($user = $modx->getAuthenticatedUser($context)) {
  14. $blocked = 0;
  15. $active = $user->get(\'active\');
  16. if ($profile = $user->getOne(\'Profile\')) {
  17. $blocked = $profile->get(\'blocked\');
  18. }
  19. $id = $user->get(\'id\');
  20. if (!$userOnline = $modx->getObject(\'userOnline\', array(\'user_id\' => $id, \'context_key\' => $context))) {
  21. $userOnline = $modx->newObject(\'userOnline\', array(
  22. \'user_id\' => $id,
  23. \'context_key\' => $context
  24. ));
  25. }
  26. $userOnline->set(\'lastvisit\', time());
  27. $userOnline->save();
  28. if (!$active or $blocked) {
  29. $response = $response = $modx->runProcessor(\'/security/logout\');
  30. $modx->sendRedirect($modx->makeUrl($modx->getOption(\'site_start\')));
  31. }
  32. }
  33. break;
  34. default:
  35. break;
  36. }
  37. return;
  38. ';