group_my.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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: group_my.php 30630 2012-06-07 07:16:14Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $_G['mnid'] = 'mn_group';
  12. if(!$_G['uid']) {
  13. showmessage('to_login', null, array(), array('showmsg' => true, 'login' => 1));
  14. }
  15. require_once libfile('function/group');
  16. $view = $_GET['view'] && in_array($_GET['view'], array('manager', 'join', 'groupthread', 'mythread')) ? $_GET['view'] : 'groupthread';
  17. $actives = array('manager' => '', 'join' => '', 'groupthread' => '', 'mythread' => '');
  18. $actives[$view] = ' class="a"';
  19. $perpage = 20;
  20. $page = intval($_GET['page']) ? intval($_GET['page']) : 1;
  21. $start = ($page - 1) * $perpage;
  22. if($view == 'groupthread' || $view == 'mythread') {
  23. $typeid = intval($_GET['typeid']);
  24. $attentiongroups = $usergroups = array();
  25. $usergroups = update_usergroups($_G['uid']);
  26. if($view == 'groupthread' && empty($typeid) && !empty($usergroups['grouptype'])) {
  27. $attentiongroup = $_G['member']['attentiongroup'];
  28. if(empty($attentiongroup)) {
  29. $attentiongroups = array_slice(array_keys($usergroups['groups']), 0, 1);
  30. } else {
  31. $attentiongroups = explode(',', $attentiongroup);
  32. }
  33. $attentionthread = $attentiongroup_icon = array();
  34. $attentiongroupfid = '';
  35. $query = C::t('forum_forum')->fetch_all_info_by_fids($attentiongroups);
  36. foreach($query as $row) {
  37. $attentiongroup_icon[$row[fid]] = get_groupimg($row['icon'], 'icon');
  38. }
  39. foreach($attentiongroups as $groupid) {
  40. $attentiongroupfid .= $attentiongroupfid ? ','.$groupid : $groupid;
  41. if($page == 1) {
  42. foreach(C::t('forum_thread')->fetch_all_by_fid_displayorder($groupid, 0, null, null, 0, 5, 'lastpost', 'DESC', '=') as $thread) {
  43. $attentionthread[$groupid][$thread['tid']]['fid'] = $thread['fid'];
  44. $attentionthread[$groupid][$thread['tid']]['subject'] = $thread['subject'];
  45. $attentionthread[$groupid][$thread['tid']]['groupname'] = $usergroups['groups'][$thread['fid']];
  46. $attentionthread[$groupid][$thread['tid']]['views'] = $thread['views'];
  47. $attentionthread[$groupid][$thread['tid']]['replies'] = $thread['replies'];
  48. $attentionthread[$groupid][$thread['tid']]['lastposter'] = $thread['lastposter'];
  49. $attentionthread[$groupid][$thread['tid']]['lastpost'] = dgmdate($thread['lastpost'], 'u');
  50. $attentionthread[$groupid][$thread['tid']]['folder'] = 'common';
  51. if(empty($_G['cookie']['oldtopics']) || strpos($_G['cookie']['oldtopics'], 'D'.$thread['tid'].'D') === FALSE) {
  52. $attentionthread[$groupid][$thread['tid']]['folder'] = 'new';
  53. }
  54. }
  55. }
  56. }
  57. }
  58. $mygrouplist = mygrouplist($_G['uid'], 'lastupdate', array('f.name', 'ff.icon'), 50);
  59. if($mygrouplist) {
  60. $managegroup = $commongroup = $groupthreadlist = array();
  61. foreach($mygrouplist as $fid => $group) {
  62. if($group['level'] == 1 || $group['level'] == 2) {
  63. if(count($managegroup) == 8) {
  64. continue;
  65. }
  66. $managegroup[$fid]['name'] = $group['name'];
  67. $managegroup[$fid]['icon'] = $group['icon'];
  68. } else {
  69. if(count($commongroup) == 8) {
  70. continue;
  71. }
  72. $commongroup[$fid]['name'] = $group['name'];
  73. $commongroup[$fid]['icon'] = $group['icon'];
  74. }
  75. }
  76. $mygroupfid = array_keys($mygrouplist);
  77. if($typeid && !empty($usergroups['grouptype'][$typeid]['groups'])) {
  78. $mygroupfid = explode(',', $usergroups['grouptype'][$typeid]['groups']);
  79. $typeurl = '&typeid='.$typeid;
  80. } else {
  81. $typeid = 0;
  82. }
  83. if(!empty($attentiongroupfid) && !empty($mygroupfid)) {
  84. $mygroupfid = array_diff($mygroupfid, explode(',', $attentiongroupfid));
  85. }
  86. if($mygroupfid) {
  87. $lastpost = 0;
  88. $displayorder = null;
  89. if($view != 'mythread') {
  90. $displayorder = 0;
  91. $lastpost = TIMESTAMP - 86400*30;
  92. }
  93. $authorid = $_G['uid'];
  94. foreach(C::t('forum_thread')->fetch_all_by_fid_authorid_displayorder($mygroupfid, $authorid, $displayorder, $lastpost, $start, $perpage) as $thread) {
  95. $groupthreadlist[$thread['tid']]['fid'] = $thread['fid'];
  96. $groupthreadlist[$thread['tid']]['subject'] = $thread['subject'];
  97. $groupthreadlist[$thread['tid']]['groupname'] = $mygrouplist[$thread['fid']]['name'];
  98. $groupthreadlist[$thread['tid']]['views'] = $thread['views'];
  99. $groupthreadlist[$thread['tid']]['replies'] = $thread['replies'];
  100. $groupthreadlist[$thread['tid']]['lastposter'] = $thread['lastposter'];
  101. $groupthreadlist[$thread['tid']]['lastpost'] = dgmdate($thread['lastpost'], 'u');
  102. $groupthreadlist[$thread['tid']]['folder'] = 'common';
  103. if(empty($_G['cookie']['oldtopics']) || strpos($_G['cookie']['oldtopics'], 'D'.$thread['tid'].'D') === FALSE) {
  104. $groupthreadlist[$thread['tid']]['folder'] = 'new';
  105. }
  106. }
  107. if($view == 'mythread') {
  108. $multipage = simplepage(count($groupthreadlist), $perpage, $page, 'group.php?mod=my&view='.$view.$typeurl);
  109. }
  110. }
  111. }
  112. } elseif($view == 'manager' || $view == 'join') {
  113. $perpage = 40;
  114. $start = ($page - 1) * $perpage;
  115. $ismanager = $view == 'manager' ? 1 : 2;
  116. $num = mygrouplist($_G['uid'], 'lastupdate', array('f.name', 'ff.icon'), 0, 0, $ismanager, 1);
  117. $multipage = multi($num, $perpage, $page, 'group.php?mod=my&view='.$view);
  118. $grouplist = mygrouplist($_G['uid'], 'lastupdate', array('f.name', 'ff.icon'), $perpage, $start, $ismanager);
  119. }
  120. $frienduidarray = $friendgrouplist = $randgroupdata = $randgrouplist = $randgroup = array();
  121. loadcache('groupindex');
  122. $randgroupdata = $_G['cache']['groupindex']['randgroupdata'];
  123. if($randgroupdata) {
  124. foreach($randgroupdata as $groupid => $rgroup) {
  125. if($rgroup['iconstatus']) {
  126. $randgrouplist[$groupid] = $rgroup;
  127. }
  128. }
  129. }
  130. if(count($randgrouplist) > 9) {
  131. foreach(array_rand($randgrouplist, 9) as $fid) {
  132. $randgroup[] = $randgrouplist[$fid];
  133. }
  134. } elseif (count($randgrouplist)) {
  135. $randgroup = $randgrouplist;
  136. }
  137. require_once libfile('function/friend');
  138. $frienduid = friend_list($_G['uid'], 50);
  139. if($frienduid && is_array($frienduid)) {
  140. foreach($frienduid as $friend) {
  141. $frienduidarray[] = $friend['fuid'];
  142. }
  143. $fids = C::t('forum_groupuser')->fetch_all_fid_by_uids($frienduidarray);
  144. $query = C::t('forum_forum')->fetch_all_info_by_fids($fids, 0, 9);
  145. foreach($query as $group) {
  146. $icon = get_groupimg($group['icon'], 'icon');
  147. $friendgrouplist[$group['fid']] = array('fid' => $group['fid'], 'name' => $group['name'], 'icon' => $icon);
  148. }
  149. }
  150. $navtitle = $_G['username'].lang('core', 'title_of').$_G['setting']['navs'][3]['navname'];
  151. include_once template("diy:group/group_my");
  152. ?>