人人商城

notice.ctrl.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. $dos = array('display', 'change_read_status', 'event_notice', 'all_read', 'setting', 'read');
  8. $do = in_array($do, $dos) ? $do : 'display';
  9. load()->model('message');
  10. $_W['page']['title'] = '系统管理 - 消息提醒 - 消息提醒';
  11. if (in_array($do, array('display', 'all_read'))) {
  12. $type = $types = intval($_GPC['type']);
  13. if ($type == MESSAGE_ACCOUNT_EXPIRE_TYPE) {
  14. $types = array(MESSAGE_ACCOUNT_EXPIRE_TYPE, MESSAGE_WECHAT_EXPIRE_TYPE, MESSAGE_WEBAPP_EXPIRE_TYPE);
  15. }
  16. if (empty($type) && (!user_is_founder($_W['uid']) || user_is_vice_founder())){
  17. $types = array(MESSAGE_ACCOUNT_EXPIRE_TYPE, MESSAGE_WECHAT_EXPIRE_TYPE, MESSAGE_WEBAPP_EXPIRE_TYPE, MESSAGE_USER_EXPIRE_TYPE, MESSAGE_WXAPP_MODULE_UPGRADE);
  18. }
  19. }
  20. if ($do == 'display') {
  21. $message_id = intval($_GPC['message_id']);
  22. message_notice_read($message_id);
  23. $pindex = max(intval($_GPC['page']), 1);
  24. $psize = 10;
  25. $message_table = table('message');
  26. $is_read = !empty($_GPC['is_read']) ? intval($_GPC['is_read']) : '';
  27. if (!empty($is_read)) {
  28. $message_table->searchWithIsRead($is_read);
  29. }
  30. if (!empty($types)) {
  31. $message_table->searchWithType($types);
  32. }
  33. $message_table->searchWithPage($pindex, $psize);
  34. $lists = $message_table->messageList($type);
  35. $lists = message_list_detail($lists);
  36. $total = $message_table->getLastQueryTotal();
  37. $pager = pagination($total, $pindex, $psize);
  38. }
  39. if ($do == 'change_read_status') {
  40. $id = $_GPC['id'];
  41. message_notice_read($id);
  42. iajax(0, '成功');
  43. }
  44. if ($do == 'event_notice') {
  45. if (!pdo_tableexists('message_notice_log')) {
  46. iajax(-1);
  47. }
  48. if (user_is_founder($_W['uid'], true)) {
  49. message_store_notice();
  50. }
  51. $message = message_event_notice_list();
  52. if (!empty($message) && !empty($message['lists'])) {
  53. $setting = message_setting();
  54. $setting_status = array();
  55. if (!empty($setting)) {
  56. foreach ($setting as $property => $property_info) {
  57. foreach ($property_info['types'] as $type => $type_info) {
  58. if ($property_info['status'] == MESSAGE_DISABLE) {
  59. $setting_status[$type]['property'] = MESSAGE_DISABLE;
  60. } else {
  61. $setting_status[$type]['property'] = MESSAGE_ENABLE;
  62. }
  63. if ($type_info['status'] == MESSAGE_DISABLE) {
  64. $setting_status[$type]['type'] = MESSAGE_DISABLE;
  65. } else {
  66. $setting_status[$type]['type'] = MESSAGE_ENABLE;
  67. }
  68. }
  69. }
  70. }
  71. foreach ($message['lists'] as $k => $notice) {
  72. if (empty($setting_status[$notice['type']])) {
  73. continue;
  74. }
  75. if ($setting_status[$notice['type']]['property'] == MESSAGE_ENABLE && $setting_status[$notice['type']]['type'] == MESSAGE_ENABLE) {
  76. continue;
  77. }
  78. unset($message['lists'][$k]);
  79. }
  80. }
  81. sort($message['lists']);
  82. $message['total'] = count($message['lists']);
  83. $cookie_name = $_W['config']['cookie']['pre'] . '__notice';
  84. if (empty($_COOKIE[$cookie_name]) || $_COOKIE[$cookie_name] < TIMESTAMP) {
  85. message_account_expire();
  86. message_notice_worker();
  87. message_sms_expire_notice();
  88. message_user_expire_notice();
  89. message_wxapp_modules_version_upgrade();
  90. }
  91. iajax(0, $message);
  92. }
  93. if ($do == 'read') {
  94. $message_id = pdo_getcolumn('message_notice_log', array('id' => intval($_GPC['id'])), 'id');
  95. if (!empty($message_id)) {
  96. pdo_update('message_notice_log', array('is_read' => MESSAGE_READ), array('id' => $message_id));
  97. }
  98. iajax(0, '已标记已读');
  99. }
  100. if ($do == 'all_read') {
  101. message_notice_all_read($types);
  102. if ($_W['isajax']) {
  103. iajax(0, '全部已读', url('message/notice', array('type' => $type)));
  104. }
  105. itoast('', referer());
  106. }
  107. if ($do == 'setting') {
  108. $setting = message_setting();
  109. if (!empty($_GPC['property']) && !empty($_GPC['type'])) {
  110. $property = trim($_GPC['property']);
  111. $type = '';
  112. if (is_numeric($_GPC['type'])) {
  113. $type = intval($_GPC['type']);
  114. if (empty($setting[$property]['types'][$type]['status']) || $setting[$property]['types'][$type]['status'] == MESSAGE_ENABLE) {
  115. $setting[$property]['types'][$type]['status'] = MESSAGE_DISABLE;
  116. } else {
  117. $setting[$property]['types'][$type]['status'] = MESSAGE_ENABLE;
  118. }
  119. } else {
  120. if (empty($setting[$property]['status']) || $setting[$property]['status'] == MESSAGE_ENABLE) {
  121. $setting[$property]['status'] = MESSAGE_DISABLE;
  122. } else {
  123. $setting[$property]['status'] = MESSAGE_ENABLE;
  124. }
  125. }
  126. setting_save($setting, 'message_notice_setting');
  127. iajax(0, '更新成功', url('message/notice/setting'));
  128. }
  129. }
  130. template('message/notice');