人人商城

groups.ctrl.php 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. $do = !empty($_GPC['do']) ? $_GPC['do'] : 'display';
  8. if ($do == 'display') {
  9. $_W['page']['title'] = '服务套餐列表 - 服务套餐管理 - 公众号';
  10. if (checksubmit('submit')) {
  11. if (!empty($_GPC['delete'])) {
  12. pdo_query("DELETE FROM ".tablename('uni_group')." WHERE id IN ('".implode("','", $_GPC['delete'])."')");
  13. cache_build_account_modules();
  14. }
  15. message('用户组更新成功!', referer(), 'success');
  16. }
  17. $list = pdo_fetchall("SELECT * FROM ".tablename('uni_group') . ' WHERE uniacid = 0');
  18. if (!empty($list)) {
  19. foreach ($list as &$row) {
  20. if (!empty($row['modules'])) {
  21. $modules = iunserializer($row['modules']);
  22. if (is_array($modules)) {
  23. $row['modules'] = pdo_fetchall("SELECT name, title FROM ".tablename('modules')." WHERE `name` IN ('".implode("','", $modules)."')");
  24. }
  25. }
  26. if (!empty($row['templates'])) {
  27. $templates = iunserializer($row['templates']);
  28. if (is_array($templates)) {
  29. $row['templates'] = pdo_fetchall("SELECT name, title FROM ".tablename('site_templates')." WHERE id IN ('".implode("','", $templates)."')");
  30. }
  31. }
  32. }
  33. }
  34. }
  35. if ($do == 'post') {
  36. $id = intval($_GPC['id']);
  37. $_W['page']['title'] = $id ? '编辑服务套餐 - 服务套餐管理 - 公众号' : '添加服务套餐 - 服务套餐管理 - 公众号';
  38. $sql = "SELECT * FROM " . tablename('modules') . ' WHERE 1';
  39. $modules = pdo_fetchall($sql, array(), 'name');
  40. if (!empty($id)) {
  41. $item = pdo_fetch("SELECT * FROM ".tablename('uni_group') . " WHERE id = :id", array(':id' => $id));
  42. $item['modules'] = iunserializer($item['modules']);
  43. $item['templates'] = iunserializer($item['templates']);
  44. }
  45. $templates = pdo_fetchall("SELECT * FROM ".tablename('site_templates'));
  46. if (checksubmit('submit')) {
  47. if (empty($_GPC['name'])) {
  48. message('请输入公众号组名称!');
  49. }
  50. $data = array(
  51. 'name' => $_GPC['name'],
  52. 'modules' => iserializer($_GPC['modules']),
  53. 'templates' => iserializer($_GPC['templates'])
  54. );
  55. if (empty($id)) {
  56. pdo_insert('uni_group', $data);
  57. } else {
  58. pdo_update('uni_group', $data, array('id' => $id));
  59. cache_build_account_modules();
  60. }
  61. load()->model('module');
  62. module_build_privileges();
  63. message('公众号组更新成功!', url('account/groups/display'), 'success');
  64. }
  65. }
  66. template('account/groups');