module.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 VoiceModule extends WeModule {
  8. public $tablename = 'voice_reply';
  9. private $replies = '';
  10. public function fieldsFormDisplay($rid = 0) {
  11. global $_W;
  12. load()->func('tpl');
  13. if (!empty($rid)) {
  14. $replies = pdo_fetch("SELECT * FROM ".tablename($this->tablename)." WHERE rid = :rid", array(':rid' => $rid));
  15. $replies = istripslashes($replies);
  16. }
  17. include $this->template('form');
  18. }
  19. public function fieldsFormValidate($rid = 0) {
  20. global $_GPC;
  21. if(empty($_GPC['title'])) {
  22. return '必须填写有效的语音标题.';
  23. }
  24. if (empty($_GPC['mediaid'])) {
  25. return '必须上传有效的语音.';
  26. }
  27. $this->replies['title'] = $_GPC['title'];
  28. $this->replies['mediaid'] = $_GPC['mediaid'];
  29. $this->replies['createtime'] = time();
  30. return '';
  31. }
  32. public function fieldsFormSubmit($rid = 0) {
  33. global $_GPC, $_W;
  34. $sql = 'DELETE FROM '. tablename($this->tablename) . ' WHERE `rid`=:rid';
  35. $pars = array();
  36. $pars[':rid'] = $rid;
  37. pdo_query($sql, $pars);
  38. $this->replies['rid'] = $rid;
  39. pdo_insert($this->tablename, $this->replies);
  40. return true;
  41. }
  42. public function ruleDeleted($rid = 0) {
  43. pdo_delete($this->tablename, array('rid' => $rid));
  44. }
  45. }