Skip to:
Content

bbPress.org

Changeset 74


Ignore:
Timestamp:
03/18/2005 07:05:50 PM (21 years ago)
Author:
matt
Message:

Sticky support

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/upgrade-schema.php

    r73 r74  
    3838  topic_open tinyint(1) NOT NULL default '1',
    3939  topic_last_post_id bigint(20) NOT NULL default '1',
     40  topic_sticky tinyint(1) NOT NULL default '0',
    4041  topic_posts bigint(20) NOT NULL default '0',
    4142  PRIMARY KEY  (topic_id),
  • trunk/bb-includes/functions.php

    r73 r74  
    5050        $limit = ($limit * $page) . ", $limit";
    5151    return $bbdb->get_results("SELECT * FROM $bbdb->topics WHERE topic_status = 0 $where ORDER BY topic_time DESC LIMIT $limit");
     52}
     53
     54function get_sticky_topics( $forum = 0, $page = 0 ) {
     55    global $bbdb, $bb;
     56    $where = '';
     57    if ( $forum )
     58        $where = "AND forum_id = $forum";
     59    return $bbdb->get_results("SELECT * FROM $bbdb->topics WHERE topic_status = 0 AND topic_sticky = '1' $where ORDER BY topic_time DESC");
    5260}
    5361
     
    419427}
    420428
     429function bb_stick_topic ( $topic_id ) {
     430    global $bbdb;
     431    bb_do_action('stick_topic', $topic_id);
     432    return $bbdb->query("UPDATE $bbdb->topics SET topic_sticky = '1' WHERE topic_id = $topic_id");
     433}
     434
     435function bb_unstick_topic ( $topic_id ) {
     436    global $bbdb;
     437    bb_do_action('unstick_topic', $topic_id);
     438    return $bbdb->query("UPDATE $bbdb->topics SET topic_sticky = '0' WHERE topic_id = $topic_id");
     439}
     440
    421441function bb_update_post( $post, $post_id ) {
    422442    global $bbdb, $current_user;
     
    507527    $topic = get_topic( $topic_id );
    508528    if ( 1 == $topic->topic_open )
     529        return true;
     530    else
     531        return false;
     532}
     533
     534function topic_is_sticky ( $topic_id ) {
     535    $topic = get_topic( $topic_id );
     536    if ( 1 == $topic->topic_sticky )
    509537        return true;
    510538    else
  • trunk/bb-includes/template-functions.php

    r73 r74  
    369369    }
    370370}
     371
     372function topic_sticky_link() {
     373    global $current_user;
     374    if ( $current_user->user_type > 1 ) {
     375        if ( topic_is_sticky( get_topic_id() ) )
     376            $text = 'Unstick topic';
     377        else
     378            $text = 'Stick topic';
     379        echo "<a href='" . bb_get_option('uri') . 'bb-admin/sticky.php?id=' . get_topic_id() . "'>$text</a>";
     380    }
     381}
     382
    371383
    372384function post_author_id() {
  • trunk/bb-templates/forum.php

    r5 r74  
    1919</tr>
    2020
     21<?php if ( $stickies) : foreach ( $stickies as $topic ) : ?>
     22<tr<?php alt_class('topic'); ?>>
     23    <td>Sticky: <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></td>
     24    <td class="num"><?php topic_posts(); ?></td>
     25    <td class="num"><?php topic_last_poster(); ?></td>
     26    <td class="num"><small><?php topic_time(); ?></small></td>
     27</tr>
     28<?php endforeach; endif; ?>
    2129
    2230<?php foreach ( $topics as $topic ) : ?>
  • trunk/bb-templates/topic.php

    r73 r74  
    55<h3><a href="<?php option('uri'); ?>"><?php option('name'); ?></a> &raquo; <a href="<?php forum_link(); ?>"><?php forum_name(); ?></a></h3>
    66<h2><?php topic_title(); ?></h2>
     7<?php bb_do_action('under_title', ''); ?>
    78<?php if ($posts) : ?>
    89<div class="nav">
     
    4142<?php endif; ?>
    4243<div class="admin">
    43 <?php topic_delete_link(); ?> <?php topic_close_link(); ?>
     44<?php topic_delete_link(); ?> <?php topic_close_link(); ?> <?php topic_sticky_link(); ?>
    4445</div>
    4546<?php get_footer(); ?>
  • trunk/forum.php

    r59 r74  
    1515    die('Forum not found.');
    1616
    17 $topics = get_latest_topics( $forum_id, $page );
     17$topics   = get_latest_topics( $forum_id, $page );
     18$stickies = get_sticky_topics( $forum_id );
    1819
    1920include('bb-templates/forum.php');
Note: See TracChangeset for help on using the changeset viewer.