shortcut.ctrl.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. load()->model('module');
  8. $dos = array('display', 'post');
  9. $do = !empty($_GPC['do']) ? $_GPC['do'] : 'display';
  10. $module_name = trim($_GPC['m']);
  11. $modulelist = uni_modules();
  12. $module = $_W['current_module'] = $modulelist[$module_name];
  13. $module_shortcut_talbe = table('uni_account_modules_shortcut');
  14. if(empty($module)) {
  15. itoast('抱歉,你操作的模块不能被访问!');
  16. }
  17. if ($do == 'display') {
  18. $pageindex = max(1, intval($_GPC['page']));
  19. $pagesize = 15;
  20. $list = $module_shortcut_talbe->getShortcutListByUniacidAndModule($_W['uniacid'], $module_name, $pageindex, $pagesize);
  21. $list['pager'] = pagination($list['total'], $pageindex, $pagesize, '', array('ajaxcallback' => true, 'callbackfuncname' => 'changePage'));
  22. if ($_W['ispost'] && $_W['isajax']) {
  23. iajax(0, $list);
  24. }
  25. template('module/shortcut');
  26. }
  27. if ($do == 'post') {
  28. $id = intval($_GPC['id']);
  29. if (!empty($id)) {
  30. $shortcut_info = $module_shortcut_talbe->getShortcutById($id);
  31. }
  32. if ($_W['ispost']) {
  33. $data = array();
  34. $data['title'] = safe_gpc_string($_GPC['title']);
  35. $data['url'] = safe_gpc_url($_GPC['url'], false);
  36. $data['icon'] = safe_gpc_string($_GPC['icon']);
  37. $data['version_id'] = intval($_GPC['version_id']);
  38. if (!empty($shortcut_info) && ($shortcut_info['uniacid'] != $_W['uniacid'] || $shortcut_info['module_name'] != $module_name)) {
  39. itoast('请不要尝试修改非本账号下本模块的数据', referer(), 'error');
  40. }
  41. if (empty($shortcut_info)) {
  42. $data['uniacid'] = $_W['uniacid'];
  43. $data['module_name'] = $module_name;
  44. }
  45. $res = $module_shortcut_talbe->saveShortcut($data, $id);
  46. if ($res) {
  47. itoast('保存成功', url('module/shortcut/display', array('uniacid' => $_W['uniacid'], 'm' => $module_name)));
  48. } else {
  49. itoast('保存失败', referer(), 'error');
  50. }
  51. }
  52. template('module/shortcut-post');
  53. }
  54. if ($do == 'delete') {
  55. $id = intval($_GPC['id']);
  56. if (empty($id)) {
  57. itoast('请求错误,请刷新页面重试!', referer(), 'error');
  58. }
  59. $if_exist = $module_shortcut_talbe->getShortcutById($id);
  60. if (empty($if_exist) || $if_exist['uniacid'] != $_W['uniacid'] || $if_exist['module_name'] != $module_name) {
  61. itoast('本模块无此快捷入口,请刷新重试!', referer(), 'error');
  62. }
  63. $res = $module_shortcut_talbe->deleteShortcutById($id);
  64. if ($res) {
  65. itoast('删除成功', url('module/shortcut/display', array('uniacid' => $_W['uniacid'], 'm' => $module_name)));
  66. } else {
  67. itoast('删除失败', referer(), 'error');
  68. }
  69. }