space_notice.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: space_notice.php 34047 2013-09-25 04:41:45Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $perpage = 30;
  12. $perpage = mob_perpage($perpage);
  13. $page = empty($_GET['page'])?0:intval($_GET['page']);
  14. if($page<1) $page = 1;
  15. $start = ($page-1)*$perpage;
  16. ckstart($start, $perpage);
  17. $list = array();
  18. $mynotice = $count = 0;
  19. $multi = '';
  20. if(empty($_G['member']['category_num']['manage']) && !in_array($_G['adminid'], array(1,2,3))) {
  21. unset($_G['notice_structure']['manage']);
  22. }
  23. $view = (!empty($_GET['view']) && (isset($_G['notice_structure'][$_GET[view]]) || in_array($_GET['view'], array('userapp'))))?$_GET['view']:'mypost';
  24. $actives = array($view=>' class="a"');
  25. $opactives[$view] = 'class="a"';
  26. $categorynum = $newprompt = array();
  27. if($view == 'userapp') {
  28. space_merge($space, 'status');
  29. if($_GET['op'] == 'del') {
  30. $appid = intval($_GET['appid']);
  31. C::t('common_myinvite')->delete_by_appid_touid($appid, $_G['uid']);
  32. showmessage('do_success', "home.php?mod=space&do=notice&view=userapp&quickforward=1");
  33. }
  34. $filtrate = 0;
  35. $count = 0;
  36. $apparr = array();
  37. $type = intval($_GET['type']);
  38. foreach(C::t('common_myinvite')->fetch_all_by_touid($_G['uid']) as $value) {
  39. $count++;
  40. $key = md5($value['typename'].$value['type']);
  41. $apparr[$key][] = $value;
  42. if($filtrate) {
  43. $filtrate--;
  44. } else {
  45. if($count < $perpage) {
  46. if($type && $value['appid'] == $type) {
  47. $list[$key][] = $value;
  48. } elseif(!$type) {
  49. $list[$key][] = $value;
  50. }
  51. }
  52. }
  53. }
  54. $mynotice = $count;
  55. } else {
  56. if(!empty($_GET['ignore'])) {
  57. C::t('home_notification')->ignore($_G['uid']);
  58. }
  59. foreach (array('wall', 'piccomment', 'blogcomment', 'clickblog', 'clickpic', 'sharecomment', 'doing', 'friend', 'credit', 'bbs', 'system', 'thread', 'task', 'group') as $key) {
  60. $noticetypes[$key] = lang('notification', "type_$key");
  61. }
  62. $isread = in_array($_GET['isread'], array(0, 1)) ? intval($_GET['isread']) : 0;
  63. $category = $type = '';
  64. if(isset($_G['notice_structure'][$view])) {
  65. if(!in_array($view, array('mypost', 'interactive'))) {
  66. $category = $view;
  67. } else {
  68. $deftype = $_G['notice_structure'][$view][0];
  69. if($_G['member']['newprompt_num']) {
  70. foreach($_G['notice_structure'][$view] as $subtype) {
  71. if($_G['member']['newprompt_num'][$subtype]) {
  72. $deftype = $subtype;
  73. break;
  74. }
  75. }
  76. }
  77. $type = in_array($_GET['type'], $_G['notice_structure'][$view]) ? trim($_GET['type']) : $deftype;
  78. }
  79. }
  80. $wherearr = array();
  81. $new = -1;
  82. if(!empty($type)) {
  83. $wherearr[] = "`type`='$type'";
  84. }
  85. $sql = ' AND '.implode(' AND ', $wherearr);
  86. $newnotify = false;
  87. $count = C::t('home_notification')->count_by_uid($_G['uid'], $new, $type, $category);
  88. if($count) {
  89. if($new == 1 && $perpage == 30) {
  90. $perpage = 200;
  91. }
  92. foreach(C::t('home_notification')->fetch_all_by_uid($_G['uid'], $new, $type, $start, $perpage, $category) as $value) {
  93. if($value['new']) {
  94. $newnotify = true;
  95. $value['style'] = 'color:#000;font-weight:bold;';
  96. } else {
  97. $value['style'] = '';
  98. }
  99. $value['rowid'] = '';
  100. if(in_array($value['type'], array('friend', 'poke'))) {
  101. $value['rowid'] = ' id="'.($value['type'] == 'friend' ? 'pendingFriend_' : 'pokeQuery_').$value['authorid'].'" ';
  102. }
  103. if($value['from_num'] > 0) $value['from_num'] = $value['from_num'] - 1;
  104. $list[$value['id']] = $value;
  105. }
  106. $multi = '';
  107. $multi = multi($count, $perpage, $page, "home.php?mod=space&do=$do&isread=1");
  108. }
  109. if($newnotify) {
  110. C::t('home_notification')->ignore($_G['uid'], $type, $category, true, true);
  111. if($_G['setting']['cloud_status']) {
  112. $noticeService = Cloud::loadClass('Service_Client_Notification');
  113. $noticeService->setNoticeFlag($_G['uid'], TIMESTAMP);
  114. }
  115. }
  116. helper_notification::update_newprompt($_G['uid'], ($type ? $type : $category));
  117. if($_G['setting']['my_app_status']) {
  118. $mynotice = C::t('common_myinvite')->count_by_touid($_G['uid']);
  119. }
  120. if($_G['member']['newprompt']) {
  121. $recountprompt = 0;
  122. foreach($_G['member']['category_num'] as $promptnum) {
  123. $recountprompt += $promptnum;
  124. }
  125. $recountprompt += $mynotice;
  126. if($recountprompt == 0) {
  127. C::t('common_member')->update($_G['uid'], array('newprompt' => 0));
  128. }
  129. }
  130. $readtag = array($type => ' class="a"');
  131. }
  132. dsetcookie('promptstate_'.$_G['uid'], $newprompt, 31536000);
  133. include_once template("diy:home/space_notice");
  134. ?>