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