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:
<?php
if (!defined('SMF'))
die('No direct access...');
function LockTopic()
{
global $topic, $user_info, $sourcedir, $board, $smcFunc;
if (empty($topic))
fatal_lang_error('not_a_topic', false);
checkSession('get');
require_once($sourcedir . '/Subs-Post.php');
$request = $smcFunc['db_query']('', '
SELECT id_member_started, locked
FROM {db_prefix}topics
WHERE id_topic = {int:current_topic}
LIMIT 1',
array(
'current_topic' => $topic,
)
);
list ($starter, $locked) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$user_lock = !allowedTo('lock_any');
if ($user_lock && $starter == $user_info['id'])
isAllowedTo('lock_own');
else
isAllowedTo('lock_any');
if (isset($_GET['sa']) && $_GET['sa'] == 'unlock' && $locked == '0')
fatal_lang_error('error_topic_locked_already', false);
elseif (isset($_GET['sa']) && $_GET['sa'] == 'lock' && ($locked == '1' || $locked == '2'))
fatal_lang_error('error_topic_unlocked_already', false);
if ($locked == '0' && !$user_lock)
$locked = '1';
elseif ($locked == '0')
$locked = '2';
elseif ($locked == '2' || ($locked == '1' && !$user_lock))
$locked = '0';
else
fatal_lang_error('locked_by_admin', 'user');
$smcFunc['db_query']('', '
UPDATE {db_prefix}topics
SET locked = {int:locked}
WHERE id_topic = {int:current_topic}',
array(
'current_topic' => $topic,
'locked' => $locked,
)
);
if (!$user_lock)
logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board));
sendNotifications($topic, empty($locked) ? 'unlock' : 'lock');
redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate');
}
function Sticky()
{
global $topic, $board, $sourcedir, $smcFunc;
isAllowedTo('make_sticky');
if (empty($topic))
fatal_lang_error('not_a_topic', false);
checkSession('get');
require_once($sourcedir . '/Subs-Post.php');
$request = $smcFunc['db_query']('', '
SELECT is_sticky
FROM {db_prefix}topics
WHERE id_topic = {int:current_topic}
LIMIT 1',
array(
'current_topic' => $topic,
)
);
list ($is_sticky) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
if (isset($_GET['sa']) && $_GET['sa'] == 'nonsticky' && $is_sticky == '0')
fatal_lang_error('error_topic_nonsticky_already', false);
elseif (isset($_GET['sa']) && $_GET['sa'] == 'sticky' && $is_sticky == '1')
fatal_lang_error('error_topic_sticky_already', false);
$smcFunc['db_query']('', '
UPDATE {db_prefix}topics
SET is_sticky = {int:is_sticky}
WHERE id_topic = {int:current_topic}',
array(
'current_topic' => $topic,
'is_sticky' => empty($is_sticky) ? 1 : 0,
)
);
logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board));
if (empty($is_sticky))
sendNotifications($topic, 'sticky');
redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate');
}
?>