- ชื่อ: View Only Boards
- ผู้เขียน: Rudolf
- นำเสนอโดย: อศูรดำ
- ประเภท: Administrative
- รองรับ: SMF 1.1.xx, 2.0.xx
- ปรับปรุงล่าสุด: 21 มกราคม 2552
- ต้นฉบับ: View Only Boards
รายละเอียด เหมาะสำหรับท่านที่ต้องการปิดข้อมูล ต้องการเปิดเผยเพียงบางส่วน หรือสร้างเงื่อนไขการเข้าชมสำหรับสมาชิกบางกลุ่ม
สำหรับ SMF 1.1.xxแก้ไขไฟล์:file $sourcedir/BoardIndex.php
ค้นหา -->>
$this_category[$row_board['ID_BOARD']] = array(
'new' => empty($row_board['isRead']),
เพิ่มไว้หลัง -->>
'protected' => in_array($row_board['ID_BOARD'],$user_info['view_only_boards']), //- View Only Boards MOD-
ค้นหา -->>
$this_category[$row_board['ID_PARENT']]['children'][$row_board['ID_BOARD']] = array(
'id' => $row_board['ID_BOARD'],
เพิ่มไว้หลัง -->>
'protected' => in_array($row_board['ID_BOARD'],$user_info['view_only_boards']), //- View Only Boards MOD-
ค้นหา -->>
$this_last_post = array(
'id' => $row_board['ID_MSG'],
เพิ่มไว้หลัง -->>
'protected' => in_array($row_board['ID_BOARD'],$user_info['view_only_boards']), //- View Only Boards MOD-
ค้นหา -->>
// Set the last post in the parent board.
if (empty($row_board['ID_PARENT']) || ($isChild && !empty($row_board['posterTime']) && $this_category[$row_board['ID_PARENT']]['last_post']['timestamp'] < forum_time(true, $row_board['posterTime'])))
แก้เป็น -->>
// Set the last post in the parent board. //- View Only Boards MOD- modified condition
if (empty($row_board['ID_PARENT']) || ($isChild && !empty($row_board['posterTime']) && (!$this_last_post['protected'] || !empty($modSettings['vob_allowMessageIndexView'])) && $this_category[$row_board['ID_PARENT']]['last_post']['timestamp'] < forum_time(true, $row_board['posterTime'])))
file $sourcesdir/MessageIndex.php
ค้นหา -->>
$context['boards'][$row_board['ID_BOARD']] = array(
'id' => $row_board['ID_BOARD'],
เพิ่มไว้หลัง -->>
'protected' => in_array($row_board['ID_BOARD'],$user_info['view_only_boards']), //- View Only Boards MOD-
ค้นหา -->>
'last_post' => array(
'id' => $row_board['ID_MSG'],
เพิ่มไว้หลัง -->>
'protected' => in_array($row_board['ID_BOARD'],$user_info['view_only_boards']), //- View Only Boards MOD-
ค้นหา -->>
$context['boards'][$row['ID_PARENT']]['children'][$row['ID_BOARD']] = array(
'id' => $row['ID_BOARD'],
เพิ่มไว้หลัง -->>
'protected' => in_array($row['ID_BOARD'],$user_info['view_only_boards']), //- View Only Boards MOD-
ค้นหา -->>
$context['boards'][$row['ID_PARENT']]['last_post'] = array(
'id' => $row['ID_MSG'],
เพิ่มไว้หลัง -->>
'protected' => in_array($row['ID_BOARD'],$user_info['view_only_boards']), //- View Only Boards MOD-
file $sourcesdir/ManageBoards.php
ค้นหา -->>
// Change '1 & 2' to '1 & 2', but not '&' to '&amp;'...
เพิ่มไว้ก่อน -->>
//-View Only Boards MOD- Start - prepare the view information to save
$boardOptions['access_groups_view'] = array();
if (!empty($_POST['groupsView']))
foreach ($_POST['groupsView'] as $group)
$boardOptions['access_groups_view'][] = (int) $group;
//-View Only Boards MOD- End
ค้นหา -->>
'memberGroups' => array(0, -1),
เพิ่มไว้หลัง -->>
'memberGroupsView' => array(), //-View Only Boards MOD-
ค้นหา -->>
'checked' => in_array('-1', $curBoard['memberGroups']),
เพิ่มไว้หลัง -->>
'view' => in_array('-1', $curBoard['memberGroupsView']), //-View Only Boards MOD-
ค้นหา -->>
'checked' => in_array('0', $curBoard['memberGroups']),
เพิ่มไว้หลัง -->>
'view' => in_array('0', $curBoard['memberGroupsView']), //-View Only Boards MOD-
ค้นหา -->>
'checked' => in_array($row['ID_GROUP'], $curBoard['memberGroups']),
เพิ่มไว้หลัง -->>
'view' => in_array($row['ID_GROUP'], $curBoard['memberGroupsView']), //-View Only Boards MOD-
file $sourcesdir/Subs-Boards.php
ค้นหา -->>
// Who's allowed to access this board.
เพิ่มไว้ก่อน -->>
//-View Only Boards MOD- Who's allowed to view this board.
if (isset($boardOptions['access_groups_view']))
$boardUpdates[] = 'memberGroupsView = \'' . implode(',', $boardOptions['access_groups_view']) . '\'';
ค้นหา -->>
b.memberGroups,
เพิ่มไว้หลัง -->>
b.memberGroupsView,
ค้นหา -->>
// Getting all the board and category information you'd ever wanted.
เพิ่มไว้ก่อน -->>
//-View Only Boards MOD- query modified
ค้นหา -->>
'memberGroups' => explode(',', $row['memberGroups']),
เพิ่มไว้หลัง -->>
'memberGroupsView' => explode(',', $row['memberGroupsView']), //-View Only Boards MOD-
file $sourcesdir/Load.php
ค้นหา -->>
b.memberGroups,
เพิ่มไว้หลัง -->>
b.memberGroupsView,
ค้นหา -->>
AND t.ID_TOPIC = $topic"), __FILE__, __LINE__);
เพิ่มไว้หลัง -->>
//-View Only Boards MOD- query modified
ค้นหา -->>
$board_info['groups'] = $row['memberGroups'] == '' ? array() : explode(',', $row['memberGroups']);
เพิ่มไว้หลัง -->>
$board_info['groups_view'] = $row['memberGroupsView'] == '' ? array() : explode(',', $row['memberGroupsView']);//-View Only Boards MOD-
ค้นหา -->>
if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin'])
$board_info['error'] = 'access';
แก้เป็น -->>
//-View Only Boards MOD- Start
if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin'])
if (!empty($topic) || isset($_REQUEST['action']))
$board_info['error'] = 'access';
elseif (count(array_intersect($user_info['groups'], $board_info['groups_view'])) == 0 || empty($modSettings['vob_allowMessageIndexView']))
$board_info['error'] = 'access';
//-View Only Boards MOD- End
ค้นหา -->>
}
// Check for moderators and see if they have access to the board.
เพิ่มไว้ก่อน -->>
//-View Only Boards MOD- Start
$user_info['view_only_boards'] = array();
$result = db_query("
SELECT b.ID_BOARD
FROM {$db_prefix}boards as b
WHERE (FIND_IN_SET(" . implode(', b.memberGroupsView) OR FIND_IN_SET(', $user_info['groups']) . ', b.memberGroupsView)) AND NOT ' . $user_info['query_see_board'],__FILE__,__LINE__);
while ($row = mysql_fetch_row($result))
$user_info['view_only_boards'][] = $row[0];
$query_see_board = $user_info['query_see_board'];
if ($user_info['query_see_board'] != '1' && (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('recent','profile'))))
if (!$user_info['is_guest'])
$user_info['query_see_board'] = substr($query_see_board,0,-1) . ' OR FIND_IN_SET(\'' . implode('\', b.memberGroupsView) OR FIND_IN_SET(\'', $user_info['groups']) . '\', b.memberGroupsView))';
else
$user_info['query_see_board'] = '(' . $query_see_board . ' OR FIND_IN_SET(-1, b.memberGroupsView))';
//-View Only Boards MOD- End
file $sourcesdir/Recent.php
ค้นหา -->>
// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
แก้เป็น -->>
//- View Only Boards MOD- START
// Do not show protected topics
if (empty($modSettings['vob_allowMessageIndexView']) && in_array($row['ID_BOARD'],$user_info['view_only_boards']))
continue;
//- View Only Boards MOD- END
// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'protected' => in_array($row['ID_BOARD'],$user_info['view_only_boards']), //- View Only Boards MOD-
ค้นหา -->>
// And build the array.
$context['topics'][$row['ID_TOPIC']] = array(
เพิ่มไว้ก่อน -->>
//- View Only Boards MOD- START
// Do not show protected topics
if (empty($modSettings['vob_allowMessageIndexView']) && in_array($row['ID_BOARD'],$user_info['view_only_boards']))
continue;
//- View Only Boards MOD- END
ค้นหา -->>
'views' => $row['numViews'],
'board' => array(
'id' => $row['ID_BOARD'],
เพิ่มไว้หลัง -->>
'protected' => in_array($row['ID_BOARD'],$user_info['view_only_boards']), //- View Only Boards MOD-
file $sourcesdir/ModSettings.php
ค้นหา -->>
array('check', 'allow_guestAccess'),
เพิ่มไว้หลัง -->>
array('check', 'vob_allowMessageIndexView'), //-View Only Boards MOD-
file $themesdir/BoardIndex.template.php
ค้นหา -->>
if (!empty($board['last_post']['id']))
echo '
<b>', $txt[22], '</b> ', $txt[525], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
', $txt[30], ' ', $board['last_post']['time'];
แก้เป็น -->>
if (!empty($board['last_post']['id']))
echo '
<b>', $txt[22], '</b> ', $txt[525], ' ', ($board['last_post']['protected'] ? '<span class="vob_protected">' . (empty($modSettings['vob_allowMessageIndexView']) ? $txt['vob_protected'] : $board['last_post']['member']['link']) . '</span>' : $board['last_post']['member']['link']) , '<br />
', $txt['smf88'], ' ', ( $board['last_post']['protected'] ? '<span class="vob_protected">' . (empty($modSettings['vob_allowMessageIndexView']) ? $txt['vob_protected'] : $board['last_post']['link']) . '</span>' : $board['last_post']['link'] ), '<br />
', $txt[30], ' ', $board['last_post']['time'];
ค้นหา -->>
foreach ($category['boards'] as $board)
{
echo '
<tr>
แก้เป็น -->>
foreach ($category['boards'] as $board)
{
echo '
<tr ' , $board['protected'] ? 'style="vob_protected"' : '' , '>
ค้นหา -->>
$children[] = $child['new'] ? '<b>' . $child['link'] . '</b>' : $child['link'];
แก้เป็น -->>
$children[] = $child['new'] ? '<b>' . $child['link'] . '</b>' : $child['protected'] ? '<span class="vob_protected">' . $child['link'] . '</span>' : $child['link'];
ค้นหา -->>
<b><a href="', $scripturl, '?action=recent">', $txt[214], '</a></b>
<div class="smalltext">
แก้เป็น -->>
<b><a href="', $scripturl, '?action=recent">', $txt[214], '</a></b>
<div class="smalltext', $context['latest_post']['protected'] ? ' vob_protected' : '' ,'">
ค้นหา -->>
foreach ($context['latest_posts'] as $post)
echo '
<tr>
แก้เป็น -->>
foreach ($context['latest_posts'] as $post)
echo '
<tr ' , $post['board']['protected'] ? 'class="vob_protected"' : '' , '>
file $themesdir/MessageIndex.template.php
ค้นหา -->>
foreach ($context['boards'] as $board)
{
echo '
<tr>
แก้เป็น -->>
foreach ($context['boards'] as $board)
{
echo '
<tr ' , $board['protected'] ? 'style="vob_protected"' : '' , '>
ค้นหา -->>
if (!empty($board['last_post']['id']))
echo '
<b>', $txt[22], '</b> ', $txt[525], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
', $txt[30], ' ', $board['last_post']['time'];
แก้เป็น -->>
if (!empty($board['last_post']['id']))
echo '
<b>', $txt[22], '</b> ', $txt[525], ' ', ($board['last_post']['protected'] ? '<span class="vob_protected">' . (empty($modSettings['vob_allowMessageIndexView']) ? $txt['vob_protected'] : $board['last_post']['member']['link']) . '</span>' : $board['last_post']['member']['link']) , '<br />
', $txt['smf88'], ' ', ( $board['last_post']['protected'] ? '<span class="vob_protected">' . (empty($modSettings['vob_allowMessageIndexView']) ? $txt['vob_protected'] : $board['last_post']['link']) . '</span>' : $board['last_post']['link'] ), '<br />
', $txt[30], ' ', $board['last_post']['time'];
ค้นหา -->>
$children[] = $child['new'] ? '<b>' . $child['link'] . '</b>' : $child['link'];
แก้เป็น -->>
$children[] = $child['new'] ? '<b>' . $child['link'] . '</b>' : $child['protected'] ? '<span class="vob_protected">' . $child['link'] . '</span>' : $child['link'];
file $themesdir/Recent.template.php
ค้นหา -->>
foreach ($context['topics'] as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));
echo '
<tr>
แก้เป็น -->>
foreach ($context['topics'] as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));
echo '
<tr ', $topic['board']['protected'] ? 'class="vob_protected"' : '' ,'>
file $themesdir/ManageBoards.template.php
ค้นหา -->>
// List all the membergroups so the user can choose who may access this board.
foreach ($context['groups'] as $group)
echo '
<label for="groups_', $group['id'], '"><span', $group['is_post_group'] ? ' style="border-bottom: 1px dotted;" title="' . $txt['mboards_groups_post_group'] . '"' : '', '>', $group['name'], '</span> <input type="checkbox" name="groups[]" value="', $group['id'], '" id="groups_', $group['id'], '"', $group['checked'] ? ' checked="checked"' : '', ' /></label><br />';
echo '
<i>', $txt[737], '</i> <input type="checkbox" onclick="invertAll(this, this.form, \'groups[]\');" /><br />
<br />
</td>
</tr>';
แก้เป็น -->>
//-View Only Boards MOD- echo in foreach modified to show additional checkbox
// List all the membergroups so the user can choose who may access this board.
foreach ($context['groups'] as $group)
echo '
<label for="groups_', $group['id'], '"><span', $group['is_post_group'] ? ' style="border-bottom: 1px dotted;" title="' . $txt['mboards_groups_post_group'] . '"' : '', '>', $group['name'], '</span> <input type="checkbox" name="groups[]" value="', $group['id'], '" id="groups_', $group['id'], '"', $group['checked'] ? ' checked="checked"' : '', ' /></label> <input type="checkbox" name="groupsView[]" value="', $group['id'], '" id="groupsView_', $group['id'], '"', $group['view'] ? ' checked="checked"' : '', ' /><br />';
echo '
<i>', $txt[737], '</i> <input type="checkbox" onclick="invertAll(this, this.form, \'groups[]\');" /> <input type="checkbox" onclick="invertAll(this, this.form, \'groupsView[]\');" /><br />
<br />
</td>
</tr>';
file $themesdir/style.css
ค้นหา -->>
?>
เพิ่มไว้ก่อน -->>
/* //-View Only Boards MOD- START */
/* You can customize here the appearence of the protected areas */
.vob_protected
{
cursor: default;
}
.vob_protected, .vob_protected a:link, .vob_protected a:visited, .vob_protected a:hover
{
color: #666;
color: red;
text-decoration: none;
cursor: default;
}
/* //-View Only Boards MOD- END */
file $languagesdir/Modifications.thai-utf8.php
เพิ่ม -->>
//-View Only Boards MOD- Start
$txt['vob_allowMessageIndexView'] = 'แสดงข้อความปกติแทนข้อความป้องกัน';
$txt['vob_protected'] = 'ป้องกัน';
//-View Only Boards MOD- End
สร้างไฟล์: DB.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/DB.php -->> Enter เสร็จแล้วลบทิ้ง
<?php
/***********************************************************************
View Only Boards MOD - version 1.2
This file makes the necessary changes in the database.
***********************************************************************/
if (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
//create the column and index if not exists
$result = db_query("SHOW COLUMNS FROM {$db_prefix}boards LIKE 'memberGroupsView'",__FILE__,__LINE__);
if (!mysql_num_rows($result))
{
$result = db_query("ALTER IGNORE TABLE {$db_prefix}boards ADD column memberGroupsView TINYTEXT NULL AFTER memberGroups",__FILE__,__LINE__);
$result = db_query("ALTER IGNORE TABLE {$db_prefix}boards ADD INDEX memberGroupsView (memberGroupsView(48))",__FILE__,__LINE__);
}
//Rename a settings variable
db_query("
UPDATE IGNORE {$db_prefix}settings
SET variable='vob_allowMessageIndexView'
WHERE variable='cbv_allowMessageIndexView'
LIMIT 1",__FILE__,__LINE__);
?>
การตั้งค่า: ผู้ดูแล --> แก้ไขบอร์ด --> แก้ไข
ลิงค์หัวข้อ:
http://dexmore.com/topic/1941