Fork me on GitHub
Subscribe 3

Ticket #134 (fixed enhancement)

Stick topic option in post.php

  • Created: 2010-09-16 11:05:26
  • Reported by: Christian
  • Assigned to: Reines
  • Milestone: 1.4.3
  • Component: usability
  • Priority: normal

Add stick topic option to post view.

Here is the patch:

post.php add after line 142:

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

replace line 269:

            $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());

add after line 512:

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>';
}

edit.php change line 22:

$result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.first_post_id, t.closed, t.sticky, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

add after line 91:

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

update line 104:

 $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());

add after line 215:

if ($can_edit_subject && $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>';
}

History

Reines 2010-09-16 11:25:12

  • Component set to usability.
  • Milestone set to 1.4.3.

Christian 2010-09-16 12:29:36

  • Description changed. (Diff)

Christian 2010-09-16 12:59:12

  • Description changed. (Diff)

Christian 2010-09-16 13:01:52

  • Description changed. (Diff)

Christian 2010-09-16 13:30:13

  • Description changed. (Diff)

Reines 2010-09-18 11:50:24

  • Owner set to Reines.

Reines 2010-09-18 13:30:45

  • Status changed from open to fixed.

Done, thanks.

M@x 2010-09-21 09:25:46

Hello !

I think there is a problem in this commit.

-> If topic is stick (So $stick_topic = 1)
-> I'm not admin and moderator
-> I answer in this topic

...

$stick_topic = 0

Now topic isn't stick...

I think you must add sticky in query and replace line 92 by :
$stick_topic = isset($_POST['stick_topic']) && $is_admmod ? '1' : $cur_post['sticky'];

Reines 2010-09-21 09:32:32

  • Status changed from fixed to open.

Reines 2010-09-21 15:38:57

  • Status changed from open to fixed.

Thanks, I think this should sort it.

M@x 2010-09-21 15:45:10

Also in post.php wink

Reines 2010-09-21 15:46:39

The sticky status is only set in post.php if it is a new post - if it's a reply it isn't touched, so this shouldn't affect post.php.

M@x 2010-09-21 15:51:00

Oh yes sorry.