人人商城

module.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 BasicModule extends WeModule {
  8. public $tablename = 'basic_reply';
  9. private $replies = '';
  10. public function fieldsFormDisplay($rid = 0) {
  11. if(!empty($rid) && $rid > 0) {
  12. $isexists = pdo_fetch("SELECT id FROM ".tablename('rule')." WHERE id = :id", array(':id' => $rid));
  13. }
  14. if(!empty($isexists)) {
  15. $replies = pdo_fetchall("SELECT * FROM ".tablename($this->tablename)." WHERE rid = :rid ORDER BY `id`", array(':rid' => $rid));
  16. }
  17. include $this->template('display');
  18. }
  19. public function fieldsFormValidate($rid = 0) {
  20. global $_GPC;
  21. $this->replies = @json_decode(htmlspecialchars_decode($_GPC['replies']), true);
  22. if(empty($this->replies)) {
  23. return '必须填写有效的回复内容.';
  24. }
  25. return '';
  26. }
  27. public function fieldsFormSubmit($rid = 0) {
  28. pdo_delete($this->tablename, array('rid' => $rid));
  29. foreach($this->replies as $reply) {
  30. pdo_insert($this->tablename, array('rid' => $rid, 'content' => $reply['content']));
  31. }
  32. return true;
  33. }
  34. public function ruleDeleted($rid = 0) {
  35. pdo_delete($this->tablename, array('rid' => $rid));
  36. }
  37. }