123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?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 ($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'] . (WIRELESS ? ';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);
-
- $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'] . (WIRELESS ? ';moderate' : ''));
- }
- ?>
|