admincp_portalpermission.php
8.24 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_portalpermission.php 29236 2012-03-30 05:34:47Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$ops = array('article', 'template', 'block');
$operation = in_array($operation, $ops, true) ? $operation : 'article';
$opdata = array();
foreach($ops as $op) {
$opdata[] = array('portalpermission_'.$op, 'portalpermission&operation='.$op, $op == $operation);
}
$line = '−';
$right = '√';
$adminscript = $mpurl = ADMINSCRIPT.'?action=portalpermission&operation='.$operation;
$permissions = $members = $uids = array();
shownav('portal', 'portalpermission');
showsubmenu('portalpermission', $opdata);
$_GET['ordersc'] = in_array($_GET['ordersc'], array('desc', 'asc'), true) ? $_GET['ordersc'] : 'desc';
$_GET['uid'] = dintval($_GET['uid']);
if(($_GET['uid'] = $_GET['uid'] ? $_GET['uid'] : '')) {
$mpurl .= '&uid='.$_GET['uid'];
} elseif($_GET['username']) {
$uids = array_keys(C::t('common_member')->fetch_all_by_like_username($_GET['username']));
$uids = $uids ? $uids : array(0);
$mpurl .= '&username='.dhtmlspecialchars($_GET['username']);
}
if($_GET['inherited']) {
$inherited = ' checked';
$mpurl .= '&inherited=1';
}
$ordersc = array($_GET['ordersc']=>' selected');
$perpage = in_array($_GET['perpage'], array(10,20,50,100)) ? $_GET['perpage'] : 20;
$start = ($page-1)*$perpage;
$perpages = array($perpage => ' selected');
$searchlang = array();
$keys = array('search', 'resultsort', 'orderdesc', 'orderasc', 'perpage_10', 'perpage_20', 'perpage_50', 'perpage_100', 'likesupport',
'uid', 'username', 'portalpermission_no_inherited');
foreach ($keys as $key) {
$searchlang[$key] = cplang($key);
}
echo <<<SEARCH
<form method="get" autocomplete="off" action="$adminscript" id="tb_search">
<div style="margin-top:8px;">
<table cellspacing="3" cellpadding="3">
<tr>
<th>$searchlang[uid]</th><td><input type="text" class="txt" name="uid" value="$_GET[uid]"></td>
<th>$searchlang[username]*</th><td><input type="text" class="txt" name="username" value="$_GET[username]"> *$searchlang[likesupport]</td>
</tr>
<tr>
<th>$searchlang[resultsort]</th>
<td>
<select name="ordersc">
<option value="desc"$ordersc[desc]>$searchlang[orderdesc]</option>
<option value="asc"$ordersc[asc]>$searchlang[orderasc]</option>
</select>
<select name="perpage">
<option value="10"$perpages[10]>$searchlang[perpage_10]</option>
<option value="20"$perpages[20]>$searchlang[perpage_20]</option>
<option value="50"$perpages[50]>$searchlang[perpage_50]</option>
<option value="100"$perpages[100]>$searchlang[perpage_100]</option>
</select>
</td>
<th><label for="inherited">$searchlang[portalpermission_no_inherited]</label></th>
<td>
<input type="checkbox" value=1 name="inherited" id="inherited" $inherited/>
<input type="hidden" name="action" value="portalpermission">
<input type="hidden" name="operation" value="$operation">
<input type="submit" name="searchsubmit" value="$searchlang[search]" class="btn">
</td>
</tr>
</table>
</div>
</form>
SEARCH;
showformheader('portalpermission&operation='.$operation);
showtableheader('portalpermission');
if($operation == 'article') {
showsubtitle(array('username', 'portalcategory', 'portalcategory_perm_publish', 'portalcategory_perm_manage', 'block_perm_inherited'));
showtagheader('tbody', '', true);
loadcache('portalcategory');
$wherearr = array();
if(($where = $_GET['uid'] ? 'uid='.$_GET['uid'] : ($uids ? 'uid IN('.dimplode($uids).')' : ''))) {
$wherearr[] = $where;
}
if($inherited) {
$wherearr[] = 'inheritedcatid = \'\'';
}
$wheresql = $wherearr ? ' WHERE '.implode(' AND ', $wherearr) : '';
$uids = $_GET['uid'] ? array($_GET['uid']) : $uids;
$count = C::t('portal_category_permission')->count_by_uids($uids, !$inherited);
if($count) {
$permissions = C::t('portal_category_permission')->fetch_all_by_uid($uids, !$inherited, $_GET['ordersc'], $start, $perpage);
foreach($permissions as $value) {
$uids[$value['uid']] = $value['uid'];
}
if(empty($members)) $members = C::t('common_member')->fetch_all($uids);
$multipage = multi($count, $perpage, $page, $mpurl.'&perpage='.$perpage);
foreach($permissions as $value){
showtablerow('', '', array(
$members[$value['uid']]['username'],
'<a href="'.ADMINSCRIPT.'?action=portalcategory&operation=perm&catid='.$value['catid'].'">'.$_G['cache']['portalcategory'][$value['catid']]['catname'].'</a>',
$value['allowpublish'] ? $right : $line,
$value['allowmanage'] ? $right : $line,
$value['inheritedcatid'] ? '<a href="'.ADMINSCRIPT.'?action=portalcategory&operation=perm&catid='.$value['inheritedcatid'].'">'.$_G['cache']['portalcategory'][$value['inheritedcatid']]['catname'].'</a>' : $line,
));
}
echo '<tr><td colspan="6">'.$multipage.'</td></tr>';
}
showtagfooter('tbody');
} elseif ($operation == 'template') {
showsubtitle(array('username', 'diytemplate_name', 'block_perm_manage', 'block_perm_recommend', 'block_perm_needverify', 'block_perm_inherited'));
showtagheader('tbody', '', true);
loadcache('diytemplatename');
$uids = $_GET['uid'] ? array($_GET['uid']) : $uids;
$count = C::t('common_template_permission')->count_by_uids($uids, !$inherited);
if($count) {
$permissions = C::t('common_template_permission')->fetch_all_by_uid($uids, !$inherited, $_GET['ordersc'], $start, $perpage);
foreach($permissions as $value) {
$uids[$value['uid']] = $value['uid'];
}
if(empty($members)) $members = C::t('common_member')->fetch_all($uids);
$multipage = multi($count, $perpage, $page, $mpurl.'&perpage='.$perpage);
foreach($permissions as $value){
$targettplname = $_G['cache']['diytemplatename'][$value['targettplname']];
showtablerow('', '', array(
$members[$value['uid']]['username'],
'<a href="'.ADMINSCRIPT.'?action=diytemplate&operation=perm&targettplname='.$value['targettplname'].'">'.$targettplname.'</a>',
$value['allowmanage'] ? $right : $line,
$value['allowrecommend'] ? $right : $line,
$value['needverify'] ? $right : $line,
$value['inheritedtplname'] ? '<a href="'.ADMINSCRIPT.'?action=diytemplate&operation=perm&targettplname='.$value['inheritedtplname'].'">'.$_G['cache']['diytemplatename'][$value['inheritedtplname']].'</a>' : $line,
));
}
echo '<tr><td colspan="6">'.$multipage.'</td></tr>';
}
showtagfooter('tbody');
} elseif ($operation == 'block') {
showsubtitle(array('username', 'block_name', 'block_perm_manage', 'block_perm_recommend', 'block_perm_needverify', 'block_perm_inherited'));
showtagheader('tbody', '', true);
loadcache('diytemplatename');
$uids = $_GET['uid'] ? array($_GET['uid']) : $uids;
if(($count = C::t('common_block_permission')->count_by_uids($uids, !$inherited))) {
$blocks = $bids = array();
$permissions = C::t('common_block_permission')->fetch_all_by_uid($uids, !$inherited, $_GET['ordersc'], $start, $perpage);
foreach($permissions as $value) {
$uids[$value['uid']] = $value['uid'];
$bids[$value['bid']] = $value['bid'];
}
if($bids) $blocks = C::t('common_block')->fetch_all($bids);
if(empty($members)) $members = C::t('common_member')->fetch_all($uids);
$multipage = multi($count, $perpage, $page, $mpurl.'&perpage='.$perpage);
foreach($permissions as $value){
$blockname = $blocks[$value['bid']]['name'] ? $blocks[$value['bid']]['name'] : $value['bid'];
showtablerow('', '', array(
$members[$value['uid']]['username'],
'<a href="'.ADMINSCRIPT.'?action=block&operation=perm&bid='.$value['bid'].'">'.$blockname.'</a>',
$value['allowmanage'] ? $right : $line,
$value['allowrecommend'] ? $right : $line,
$value['needverify'] ? $right : $line,
$value['inheritedtplname'] ? '<a href="'.ADMINSCRIPT.'?action=diytemplate&operation=perm&targettplname='.$value['inheritedtplname'].'">'.$_G['cache']['diytemplatename'][$value['inheritedtplname']].'</a>' : $line,
));
}
echo '<tr><td colspan="6">'.$multipage.'</td></tr>';
}
showtagfooter('tbody');
}
showtablefooter();
showformfooter();
?>