Core.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. if ($audit) {
  10. $info = Dever::db('audit/data')->getIn($id);
  11. if ($info) {
  12. foreach($info as $k => $v) {
  13. $table = Dever::config('base')->type_table[$v['type']];
  14. $source = Dever::db($table)->one($v['data_id']);
  15. if ($source && $source['audit'] != $audit) {
  16. Dever::config('base')->after = false;
  17. Dever::db($table)->update(array('where_id' => $v['data_id'], 'audit' => $audit));
  18. }
  19. }
  20. }
  21. }
  22. }
  23. public function status($id, $name, $data)
  24. {
  25. $status = Dever::param('status', $data);
  26. if ($status) {
  27. $info = Dever::db('audit/data')->getIn($id);
  28. if ($info) {
  29. foreach ($info as $k => $v) {
  30. $table = Dever::config('base')->type_table[$v['type']];
  31. $source = Dever::db($table)->one($v['data_id']);
  32. if ($source && $source['status'] != $status) {
  33. Dever::config('base')->after = false;
  34. Dever::db($table)->update(array('where_id' => $v['data_id'], 'status' => $status));
  35. }
  36. }
  37. }
  38. }
  39. }
  40. public function updatemul($id, $name, $data)
  41. {
  42. //$this->audit($id, $name, $data);
  43. //$this->status($id, $name, $data);
  44. $this->push($id, $name, $data);
  45. }
  46. public function push($id, $name, $data)
  47. {
  48. $push = Dever::param('push', $data);
  49. if ($push) {
  50. $info = Dever::db('audit/data')->getIn($id);
  51. if ($info) {
  52. foreach ($info as $k => $v) {
  53. if ($v['type'] > 2) {
  54. continue;
  55. }
  56. $table = Dever::config('base')->type_table[$v['type']];
  57. $source = Dever::db($table)->one($v['data_id']);
  58. if ($source && $push == 2) {
  59. $content = Dever::load('content/lib/article')->getContent($source);
  60. $send['source_id'] = $v['id'];
  61. $send['name'] = $source['name'];
  62. $send['cate_id'] = $source['cate_id'];
  63. $send['pic_cover'] = Dever::pic($source['share_pic']);
  64. $send['pic_index'] = Dever::pic($source['pic_cover_169']);
  65. $send['pdate'] = $source['pdate'];
  66. $send['desc'] = $source['share_content'] ? $source['share_content'] : $source['share_title'];
  67. $send['template'] = $v['type'];
  68. if (isset($source['video'])) {
  69. $send['video'] = $source['video'];
  70. }
  71. $send['content'] = Dever::json_encode($content['content_array']);
  72. $data = Dever::load('jingpin/lib/article.up', $send);
  73. }
  74. }
  75. }
  76. }
  77. }
  78. public function reorder($id, $name, $data)
  79. {
  80. $reorder = Dever::param('reorder', $data);
  81. $info = Dever::db('audit/data')->one($id);
  82. $table = Dever::config('base')->type_table[$info['type']];
  83. $source = Dever::db($table)->one($info['data_id']);
  84. if ($source && $source['reorder'] != $reorder) {
  85. Dever::config('base')->after = false;
  86. Dever::db($table)->update(array('where_id' => $info['data_id'], 'reorder' => $reorder));
  87. }
  88. }
  89. }