Skip to:
Content

bbPress.org


Ignore:
Timestamp:
12/27/2004 11:22:22 AM (21 years ago)
Author:
matt
Message:

Login, logout, sanitize everything, be fast.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-includes/template-functions.php

    r3 r5  
    1212
    1313function login_form() {
    14     return;
     14    global $current_user;
     15    if ($current_user) {
     16        echo "Welcome, $current_user->username! <a href='/user/$current_user->user_id'>View your profile &raquo;</a>
     17        <small>(<a href='" . get_option('uri') . "bb-login.php?logout'>Logout</a>)</small>";
     18    } else {
     19        require( ABSPATH . '/bb-templates/login-form.php');
     20    }
     21}
     22
     23function post_form() {
     24    global $current_user;
     25    if ($current_user) {
     26        require( ABSPATH . '/bb-templates/post-form.php');
     27    } else {
     28        echo "<p>You must login to post.";
     29        require( ABSPATH . '/bb-templates/login-form.php');
     30    }
    1531}
    1632
     
    6985    echo apply_filters('forum_name', get_forum_name() );
    7086}
    71 
     87function get_forum_id() {
     88    global $forum;
     89    return $forum->forum_id;
     90}
     91function forum_id() {
     92    echo apply_filters('forum_id', get_forum_id() );
     93}
    7294function get_forum_name() {
    7395    global $forum;
     
    107129
    108130// TOPICS
     131function get_topic_id() {
     132    global $topic;
     133    return $topic->topic_id;
     134}
     135
     136function topic_id() {
     137    echo apply_filters('topic_id', get_topic_id() );
     138}
     139
    109140function topic_link() {
     141    echo apply_filters('topic_link', get_topic_link() );
     142}
     143
     144function get_topic_link() {
    110145    global $topic, $bb;
    111     if ( $bb->mod_rewrite )
    112         $link = $bb->path . $topic->topic_id;
    113     else
    114         $link = $bb->path . "topic.php?id=$topic->topic_id";
    115 
    116     echo apply_filters('topic_link', $link);
     146
     147    if ( get_option('mod_rewrite') )
     148        $link = get_option('path') . $topic->topic_id;
     149    else
     150        $link = get_option('path') . "topic.php?id=$topic->topic_id";
     151
     152    return apply_filters('get_topic_link', $link);
    117153}
    118154
     
    170206
    171207function get_post_author() {
    172     global $post;
    173     return apply_filters('post_author', $post->poster_name);
     208    global $bbdb, $user_cache;
     209    $id = get_post_author_id();
     210    if ( $id ) :
     211        if ( isset( $user_cache[$id] ) ) {
     212            return $user_cache[$id]->username;
     213        } else {
     214            $user_cache[$id] = $bbdb->get_row("SELECT * FROM $bbdb->users WHERE user_id = $id");
     215            return $user_cache[$id]->username;
     216        }
     217    else :
     218        return 'Anonymous';
     219    endif;
    174220}
    175221
Note: See TracChangeset for help on using the changeset viewer.