Core.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Audit\Lib;
  3. use Dever;
  4. class Core
  5. {
  6. public function audit($id, $name, $data)
  7. {
  8. $audit = Dever::param('audit', $data);
  9. $info = Dever::db('audit/data')->one($id);
  10. $table = Dever::config('base')->type_table[$info['type']];
  11. $source = Dever::db($table)->one($info['data_id']);
  12. if ($source && $source['audit'] != $audit) {
  13. Dever::config('base')->after = false;
  14. Dever::db($table)->update(array('where_id' => $info['data_id'], 'audit' => $audit));
  15. }
  16. }
  17. public function status($id, $name, $data)
  18. {
  19. $status = Dever::param('status', $data);
  20. $info = Dever::db('audit/data')->one($id);
  21. $table = Dever::config('base')->type_table[$info['type']];
  22. $source = Dever::db($table)->one($info['data_id']);
  23. if ($source && $source['status'] != $status) {
  24. Dever::config('base')->after = false;
  25. Dever::db($table)->update(array('where_id' => $info['data_id'], 'status' => $status));
  26. }
  27. }
  28. public function reorder($id, $name, $data)
  29. {
  30. $reorder = Dever::param('reorder', $data);
  31. $info = Dever::db('audit/data')->one($id);
  32. $table = Dever::config('base')->type_table[$info['type']];
  33. $source = Dever::db($table)->one($info['data_id']);
  34. if ($source && $source['reorder'] != $reorder) {
  35. Dever::config('base')->after = false;
  36. Dever::db($table)->update(array('where_id' => $info['data_id'], 'reorder' => $reorder));
  37. }
  38. }
  39. }