xuanxuan.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Get user actions of password change and login since last two xxd poll.
  4. *
  5. * @param string $action
  6. * @access public
  7. * @return array
  8. */
  9. public function getListSinceLastPoll($action = '')
  10. {
  11. $lastPoll = date(DT_DATETIME1, strtotime($this->config->xxd->lastPoll . ' - ' . 2 * $this->config->xuanxuan->pollingInterval . ' second'));
  12. $actions = array();
  13. if($action === 'changepassword')
  14. {
  15. $actions = $this->dao->select('t1.id, t1.objectID, t1.date')->from(TABLE_ACTION)->alias('t1')
  16. ->leftJoin(TABLE_HISTORY)->alias('t2')->on('t1.id = t2.action')
  17. ->leftJoin(TABLE_USER)->alias('t3')->on('t1.objectID = t3.id')
  18. ->where('t3.clientStatus')->ne('offline')
  19. ->andWhere('t1.objectType')->eq('user')
  20. ->andWhere('t2.field')->eq('password')
  21. ->andWhere('t1.action')->eq('edited')
  22. ->andWhere('t1.date')->gt($lastPoll)
  23. ->orderBy('t1.`date`_desc')
  24. ->fetchAll();
  25. }
  26. elseif($action === 'loginxuanxuan')
  27. {
  28. $actions = $this->dao->select('id, objectID, date')->from(TABLE_ACTION)
  29. ->where('date')->gt($lastPoll)
  30. ->andWhere('action')->eq('loginxuanxuan')
  31. ->orderBy('`date`_desc')
  32. ->fetchAll();
  33. }
  34. $uniqueActions = array();
  35. foreach($actions as $action)
  36. {
  37. $exist = false;
  38. foreach($uniqueActions as $uniqueAction)
  39. {
  40. if($uniqueAction->objectID === $action->objectID)
  41. {
  42. $exist = true;
  43. break;
  44. }
  45. }
  46. if(!$exist) $uniqueActions[] = $action;
  47. }
  48. return $uniqueActions;
  49. }
  50. /**
  51. * Check log level for action.
  52. *
  53. * @param string $module
  54. * @param object $action
  55. * @access public
  56. * @return bool
  57. */
  58. public function checkLogLevel($module, $action)
  59. {
  60. $logLevel = (int)zget($this->config->xuanxuan, 'logLevel', 1);
  61. $actionLevel = zget($this->config->action->logLevel->{$module}, $action, 0);
  62. if($logLevel >= $actionLevel) return true;
  63. return false;
  64. }