module.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 VideoModule extends WeModule {
  8. public $tablename = 'video_reply';
  9. public function fieldsFormDisplay($rid = 0) {
  10. global $_W;
  11. load()->func('tpl');
  12. if (!empty($rid)) {
  13. $replies = pdo_fetch("SELECT * FROM ".tablename($this->tablename)." WHERE rid = :rid", array(':rid' => $rid));
  14. $replies = istripslashes($replies);
  15. }
  16. include $this->template('form');
  17. }
  18. public function fieldsFormValidate($rid = 0) {
  19. global $_GPC;
  20. if(empty($_GPC['title'])) {
  21. return '必须填写有效的视频标题.';
  22. }
  23. if (empty($_GPC['mediaid'])) {
  24. return '必须上传有效的视频.';
  25. }
  26. $this->replies['title'] = $_GPC['title'];
  27. $this->replies['mediaid'] = $_GPC['mediaid'];
  28. $this->replies['description'] = $_GPC['description'];
  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. global $_W;
  44. $replies = pdo_fetchall("SELECT id FROM ".tablename($this->tablename)." WHERE rid = '$rid'");
  45. $deleteid = array();
  46. if (!empty($replies)) {
  47. foreach ($replies as $index => $row) {
  48. $deleteid[] = $row['id'];
  49. }
  50. }
  51. pdo_delete($this->tablename, "id IN ('".implode("','", $deleteid)."')");
  52. return true;
  53. }
  54. }