module.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 = pdo_getall($this->tablename, array('rid' => $rid));
  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 = pdo_get('rule', array('id' => $rid, 'uniacid' => $_W['uniacid']));
  36. if (empty($rule_exists)) {
  37. return false;
  38. }
  39. pdo_delete($this->tablename, array('rid' => $rid));
  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'], 'brand_name' => $reply['brand_name'],
  46. 'logo_url' => $reply['logo_url'],
  47. 'success' => trim($_GPC['success']),
  48. 'error' => trim($_GPC['error'])
  49. );
  50. pdo_insert($this->tablename, $data);
  51. }
  52. return true;
  53. }
  54. public function ruleDeleted($rid = 0) {
  55. global $_W;
  56. $rid = intval($rid);
  57. $rule_exists = pdo_get('rule', array('id' => $rid, 'uniacid' => $_W['uniacid']));
  58. if (empty($rule_exists)) {
  59. return false;
  60. }
  61. pdo_delete($this->tablename, array('rid' => $rid));
  62. return true;
  63. }
  64. }