Chris@76: $topic, Chris@76: ) Chris@76: ); Chris@76: list ($starter, $locked) = $smcFunc['db_fetch_row']($request); Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: // Can you lock topics here, mister? Chris@76: $user_lock = !allowedTo('lock_any'); Chris@76: if ($user_lock && $starter == $user_info['id']) Chris@76: isAllowedTo('lock_own'); Chris@76: else Chris@76: isAllowedTo('lock_any'); Chris@76: Chris@76: // Locking with high privileges. Chris@76: if ($locked == '0' && !$user_lock) Chris@76: $locked = '1'; Chris@76: // Locking with low privileges. Chris@76: elseif ($locked == '0') Chris@76: $locked = '2'; Chris@76: // Unlocking - make sure you don't unlock what you can't. Chris@76: elseif ($locked == '2' || ($locked == '1' && !$user_lock)) Chris@76: $locked = '0'; Chris@76: // You cannot unlock this! Chris@76: else Chris@76: fatal_lang_error('locked_by_admin', 'user'); Chris@76: Chris@76: // Actually lock the topic in the database with the new value. Chris@76: $smcFunc['db_query']('', ' Chris@76: UPDATE {db_prefix}topics Chris@76: SET locked = {int:locked} Chris@76: WHERE id_topic = {int:current_topic}', Chris@76: array( Chris@76: 'current_topic' => $topic, Chris@76: 'locked' => $locked, Chris@76: ) Chris@76: ); Chris@76: Chris@76: // If they are allowed a "moderator" permission, log it in the moderator log. Chris@76: if (!$user_lock) Chris@76: logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); Chris@76: // Notify people that this topic has been locked? Chris@76: sendNotifications($topic, empty($locked) ? 'unlock' : 'lock'); Chris@76: Chris@76: // Back to the topic! Chris@76: redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . (WIRELESS ? ';moderate' : '')); Chris@76: } Chris@76: Chris@76: // Sticky a topic. Can't be done by topic starters - that would be annoying! Chris@76: function Sticky() Chris@76: { Chris@76: global $modSettings, $topic, $board, $sourcedir, $smcFunc; Chris@76: Chris@76: // Make sure the user can sticky it, and they are stickying *something*. Chris@76: isAllowedTo('make_sticky'); Chris@76: Chris@76: // You shouldn't be able to (un)sticky a topic if the setting is disabled. Chris@76: if (empty($modSettings['enableStickyTopics'])) Chris@76: fatal_lang_error('cannot_make_sticky', false); Chris@76: Chris@76: // You can't sticky a board or something! Chris@76: if (empty($topic)) Chris@76: fatal_lang_error('not_a_topic', false); Chris@76: Chris@76: checkSession('get'); Chris@76: Chris@76: // We need Subs-Post.php for the sendNotifications() function. Chris@76: require_once($sourcedir . '/Subs-Post.php'); Chris@76: Chris@76: // Is this topic already stickied, or no? Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT is_sticky Chris@76: FROM {db_prefix}topics Chris@76: WHERE id_topic = {int:current_topic} Chris@76: LIMIT 1', Chris@76: array( Chris@76: 'current_topic' => $topic, Chris@76: ) Chris@76: ); Chris@76: list ($is_sticky) = $smcFunc['db_fetch_row']($request); Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: // Toggle the sticky value.... pretty simple ;). Chris@76: $smcFunc['db_query']('', ' Chris@76: UPDATE {db_prefix}topics Chris@76: SET is_sticky = {int:is_sticky} Chris@76: WHERE id_topic = {int:current_topic}', Chris@76: array( Chris@76: 'current_topic' => $topic, Chris@76: 'is_sticky' => empty($is_sticky) ? 1 : 0, Chris@76: ) Chris@76: ); Chris@76: Chris@76: // Log this sticky action - always a moderator thing. Chris@76: logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board)); Chris@76: // Notify people that this topic has been stickied? Chris@76: if (empty($is_sticky)) Chris@76: sendNotifications($topic, 'sticky'); Chris@76: Chris@76: // Take them back to the now stickied topic. Chris@76: redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . (WIRELESS ? ';moderate' : '')); Chris@76: } Chris@76: Chris@76: ?>