circle_recycle.model.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /**
  3. * Circle Level
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class circle_recycleModel extends Model {
  11. public function __construct(){
  12. parent::__construct();
  13. }
  14. /**
  15. * Saved to the recycle bin
  16. *
  17. * @param array $param
  18. */
  19. public function saveRecycle($param, $data = array()){
  20. switch($param['type']){
  21. case 'theme':
  22. return $this->saveRecycleTheme($param);
  23. break;
  24. case 'reply':
  25. return $this->saveRecycleReply($param);
  26. break;
  27. case 'admintheme':
  28. return $this->saveRecycleThemeAdmin($param, $data);
  29. break;
  30. case 'adminreply':
  31. return $this->saveRecycleReplyAdmin($param, $data);
  32. break;
  33. default:
  34. return false;
  35. break;
  36. }
  37. }
  38. /**
  39. * Keep the theme to the recycle bin
  40. *
  41. * @param array $param
  42. */
  43. private function saveRecycleTheme($param){
  44. $theme_info = $this->themeInfo($param);
  45. if(empty($theme_info)) return false;
  46. $insert = array();
  47. $insert['member_id'] = $theme_info['member_id'];
  48. $insert['member_name'] = $theme_info['member_name'];
  49. $insert['circle_id'] = $theme_info['circle_id'];
  50. $insert['circle_name'] = $theme_info['circle_name'];
  51. $insert['theme_name'] = $theme_info['theme_name'];
  52. $insert['recycle_content'] = $theme_info['theme_content'];
  53. $insert['recycle_opid'] = $param['op_id'];
  54. $insert['recycle_opname'] = $param['op_name'];
  55. $insert['recycle_type'] = 1;
  56. $insert['recycle_time'] = time();
  57. return $this->add($insert);
  58. }
  59. /**
  60. * Keep the theme to the recycle bin
  61. *
  62. * @param array $param
  63. */
  64. private function saveRecycleThemeAdmin($param, $theme_info){
  65. $insert = array();
  66. $insert['member_id'] = $theme_info['member_id'];
  67. $insert['member_name'] = $theme_info['member_name'];
  68. $insert['circle_id'] = $theme_info['circle_id'];
  69. $insert['circle_name'] = $theme_info['circle_name'];
  70. $insert['theme_name'] = $theme_info['theme_name'];
  71. $insert['recycle_content'] = $theme_info['theme_content'];
  72. $insert['recycle_opid'] = $param['op_id'];
  73. $insert['recycle_opname'] = $param['op_name'];
  74. $insert['recycle_type'] = 1;
  75. $insert['recycle_time'] = time();
  76. return $this->add($insert);
  77. }
  78. /**
  79. * Keep the reply to the recycle bin
  80. *
  81. * @param array $param
  82. */
  83. private function saveRecycleReply($param){
  84. $theme_info = $this->themeInfo($param);
  85. if(empty($theme_info)) return false;
  86. $reply_info = $this->replyInfo($param);
  87. if(empty($reply_info)) return false;
  88. $insert = array();
  89. $insert['member_id'] = $reply_info['member_id'];
  90. $insert['member_name'] = $reply_info['member_name'];
  91. $insert['circle_id'] = $theme_info['circle_id'];
  92. $insert['circle_name'] = $theme_info['circle_name'];
  93. $insert['theme_name'] = $theme_info['theme_name'];
  94. $insert['recycle_content'] = $reply_info['reply_content'];
  95. $insert['recycle_opid'] = $param['op_id'];
  96. $insert['recycle_opname'] = $param['op_name'];
  97. $insert['recycle_type'] = 2;
  98. $insert['recycle_time'] = time();
  99. return $this->add($insert);
  100. }
  101. /**
  102. * Keep the reply to the recycle bin for admin
  103. *
  104. * @param array $param
  105. */
  106. private function saveRecycleReplyAdmin($param, $reply_info){
  107. $theme_info = $this->themeInfo($param);
  108. if(empty($theme_info)) return false;
  109. $insert = array();
  110. $insert['member_id'] = $reply_info['member_id'];
  111. $insert['member_name'] = $reply_info['member_name'];
  112. $insert['circle_id'] = $theme_info['circle_id'];
  113. $insert['circle_name'] = $theme_info['circle_name'];
  114. $insert['theme_name'] = $theme_info['theme_name'];
  115. $insert['recycle_content'] = $reply_info['reply_content'];
  116. $insert['recycle_opid'] = $param['op_id'];
  117. $insert['recycle_opname'] = $param['op_name'];
  118. $insert['recycle_type'] = 2;
  119. $insert['recycle_time'] = time();
  120. return $this->add($insert);
  121. }
  122. /**
  123. * save data
  124. *
  125. * @param array $param
  126. */
  127. private function add($param){
  128. return $this->table('circle_recycle')->insert($param);
  129. }
  130. /**
  131. * theme information
  132. *
  133. * @param array $param
  134. * @return array
  135. */
  136. private function themeInfo($param){
  137. return $this->table('circle_theme')->where(array('theme_id'=>$param['theme_id']))->find();
  138. }
  139. /**
  140. * theme information
  141. *
  142. * @param array $param
  143. * @return array
  144. */
  145. private function replyInfo($param){
  146. return $this->table('circle_threply')->where(array('theme_id'=>$param['theme_id'], 'reply_id'=>$param['reply_id']))->find();
  147. }
  148. }