module.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. class PaycenterModule extends WeModule {
  8. public $tablename = 'wxcard_reply';
  9. public $replies = array();
  10. public function fieldsFormDisplay($rid = 0) {
  11. if (!empty($rid)) {
  12. $replies = table($this->tablename)->where(array('rid' => $rid))->getall();
  13. }
  14. include $this->template('display');
  15. }
  16. public function fieldsFormValidate($rid = 0) {
  17. global $_GPC;
  18. $this->replies = @json_decode(htmlspecialchars_decode($_GPC['replies']), true);
  19. if (empty($this->replies)) {
  20. return '必须填写有效的回复内容.';
  21. }
  22. foreach ($this->replies as $k => &$row) {
  23. if (empty($row['cid']) || empty($row['card_id'])) {
  24. unset($k);
  25. }
  26. }
  27. if (empty($this->replies)) {
  28. return '必须填写有效的回复内容.';
  29. }
  30. return '';
  31. }
  32. public function fieldsFormSubmit($rid = 0) {
  33. global $_W, $_GPC;
  34. $rid = intval($rid);
  35. $rule_exists = table('rule')->getById($rid, $_W['uniacid']);
  36. if (empty($rule_exists)) {
  37. return false;
  38. }
  39. table($this->tablename)->where(array('rid' => $rid))->delete();
  40. foreach ($this->replies as $reply) {
  41. $data = array(
  42. 'rid' => $rid,
  43. 'title' => $reply['title'],
  44. 'card_id' => $reply['card_id'],
  45. 'cid' => $reply['cid'],
  46. 'brand_name' => $reply['brand_name'],
  47. 'logo_url' => $reply['logo_url'],
  48. 'success' => safe_gpc_string($_GPC['success']),
  49. 'error' => safe_gpc_string($_GPC['error']),
  50. );
  51. table($this->tablename)->fill($data)->save();
  52. }
  53. return true;
  54. }
  55. public function ruleDeleted($rid = 0) {
  56. global $_W;
  57. $rid = intval($rid);
  58. $rule_exists = table('rule')->getById($rid, $_W['uniacid']);
  59. if (empty($rule_exists)) {
  60. return false;
  61. }
  62. table($this->tablename)->where(array('rid' => $rid))->delete();
  63. return true;
  64. }
  65. }