Skip to content

Commit

Permalink
Adding a stick topic checkbox for admins on post.php and edit.php, pa…
Browse files Browse the repository at this point in the history
…tch by Christian.
  • Loading branch information
reines committed Sep 18, 2010
1 parent 7b8ee54 commit b59e9d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion edit.php
Expand Up @@ -89,6 +89,7 @@
$errors[] = $lang_post['No message'];

$hide_smilies = isset($_POST['hide_smilies']) ? '1' : '0';
$stick_topic = isset($_POST['stick_topic']) && $is_admmod ? '1' : '0';

// Did everything go according to plan?
if (empty($errors) && !isset($_POST['preview']))
Expand All @@ -100,7 +101,7 @@
if ($can_edit_subject)
{
// Update the topic and any redirect topics
$db->query('UPDATE '.$db->prefix.'topics SET subject=\''.$db->escape($subject).'\' WHERE id='.$cur_post['tid'].' OR moved_to='.$cur_post['tid']) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
$db->query('UPDATE '.$db->prefix.'topics SET subject=\''.$db->escape($subject).'\', sticky='.$stick_topic.' WHERE id='.$cur_post['tid'].' OR moved_to='.$cur_post['tid']) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

// We changed the subject, so we need to take that into account when we update the search words
update_search_index('edit', $id, $message, $subject);
Expand Down Expand Up @@ -212,6 +213,14 @@
<?php

$checkboxes = array();
if ($can_edit_subject && $is_admmod)
{
if (isset($_POST['stick_topic']) || $cur_post['sticky'] == '1')
$checkboxes[] = '<label><input type="checkbox" name="stick_topic" value="1" checked="checked" tabindex="'.($cur_index++).'" />'.$lang_common['Stick topic'].'<br /></label>';
else
$checkboxes[] = '<label><input type="checkbox" name="stick_topic" value="1" tabindex="'.($cur_index++).'" />'.$lang_common['Stick topic'].'<br /></label>';
}

if ($pun_config['o_smilies'] == '1')
{
if (isset($_POST['hide_smilies']) || $cur_post['hide_smilies'] == '1')
Expand Down
6 changes: 5 additions & 1 deletion post.php
Expand Up @@ -140,6 +140,7 @@

$hide_smilies = isset($_POST['hide_smilies']) ? '1' : '0';
$subscribe = isset($_POST['subscribe']) ? '1' : '0';
$stick_topic = isset($_POST['stick_topic']) && $is_admmod ? '1' : '0';

$now = time();

Expand Down Expand Up @@ -265,7 +266,7 @@
else if ($fid)
{
// Create the topic
$db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, last_poster, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', '.$now.', \''.$db->escape($username).'\', '.$fid.')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());
$db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, last_poster, sticky, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', '.$now.', \''.$db->escape($username).'\', '.$stick_topic.', '.$fid.')') or error('Unable to create topic', __FILE__, __LINE__, $db->error());
$new_tid = $db->insert_id();

if (!$pun_user['is_guest'])
Expand Down Expand Up @@ -509,6 +510,9 @@
<?php

$checkboxes = array();
if ($is_admmod)
$checkboxes[] = '<label><input type="checkbox" name="stick_topic" value="1" tabindex="'.($cur_index++).'"'.(isset($_POST['stick_topic']) ? ' checked="checked"' : '').' />'.$lang_common['Stick topic'].'<br /></label>';

if (!$pun_user['is_guest'])
{
if ($pun_config['o_smilies'] == '1')
Expand Down

0 comments on commit b59e9d7

Please sign in to comment.