人人商城

module.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 ImagesModule extends WeModule {
  8. public $tablename = 'images_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. }
  15. include $this->template('form');
  16. }
  17. public function fieldsFormValidate($rid = 0) {
  18. global $_GPC;
  19. if(empty($_GPC['title'])) {
  20. return '必须填写有效的图片标题.';
  21. }
  22. if (empty($_GPC['mediaid'])) {
  23. return '必须上传有效的图片.';
  24. }
  25. $this->replies['title'] = $_GPC['title'];
  26. $this->replies['mediaid'] = $_GPC['mediaid'];
  27. $this->replies['description'] = $_GPC['description'];
  28. $this->replies['createtime'] = time();
  29. return '';
  30. }
  31. public function fieldsFormSubmit($rid = 0) {
  32. global $_GPC, $_W;
  33. pdo_delete($this->tablename, array('rid' => $rid));
  34. $this->replies['rid'] = $rid;
  35. pdo_insert($this->tablename, $this->replies);
  36. return true;
  37. }
  38. public function ruleDeleted($rid = 0) {
  39. global $_W;
  40. $replies = pdo_fetchall("SELECT id FROM ".tablename($this->tablename)." WHERE rid = '$rid'");
  41. $deleteid = array();
  42. if (!empty($replies)) {
  43. foreach ($replies as $index => $row) {
  44. $deleteid[] = $row['id'];
  45. }
  46. }
  47. pdo_delete($this->tablename, "id IN ('".implode("','", $deleteid)."')");
  48. return true;
  49. }
  50. }