Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/21/2010 03:47:02 PM (16 years ago)
Author:
apeatling
Message:

Fixes #1598 - broken sitewide notices

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages/bp-messages-templatetags.php

    r2389 r2397  
    162162        global $messages_template;
    163163
    164         return apply_filters( 'bp_get_message_thread_id', $messages_template->thread->thread_id );
     164        /* Notice support */
     165        if ( empty( $messages_template->thread->thread_id ) )
     166            $id = $messages_template->thread->id;
     167        else
     168            $id = $messages_template->thread->thread_id;
     169
     170        return apply_filters( 'bp_get_message_thread_id', $id );
    165171    }
    166172
     
    170176    function bp_get_message_thread_subject() {
    171177        global $messages_template;
    172         return apply_filters( 'bp_get_message_thread_subject', stripslashes_deep( $messages_template->thread->last_message_subject ) );
     178
     179        /* Notice support */
     180        if ( empty( $messages_template->thread->last_message_subject ) )
     181            $subject = $messages_template->thread->subject;
     182        else
     183            $subject = $messages_template->thread->last_message_subject;
     184
     185        return apply_filters( 'bp_get_message_thread_subject', stripslashes_deep( $subject ) );
    173186    }
    174187
     
    178191    function bp_get_message_thread_excerpt() {
    179192        global $messages_template;
    180         return apply_filters( 'bp_get_message_thread_excerpt', strip_tags( bp_create_excerpt($messages_template->thread->last_message_message, 10 ) ) );
     193
     194        /* Notice support */
     195        if ( empty( $messages_template->thread->last_message_message ) )
     196            $message = $messages_template->thread->message;
     197        else
     198            $message = $messages_template->thread->last_message_message;
     199
     200        return apply_filters( 'bp_get_message_thread_excerpt', strip_tags( bp_create_excerpt( $message, 10 ) ) );
    181201    }
    182202
     
    185205}
    186206    function bp_get_message_thread_from() {
    187         global $messages_template;
    188         return apply_filters( 'bp_get_message_thread_from', bp_core_get_userlink($messages_template->thread->last_sender_id) );
     207        global $messages_template, $bp;
     208
     209        /* Notice support */
     210        if ( empty( $messages_template->thread->last_sender_id ) )
     211            $sender = $bp->loggedin_user->id;
     212        else
     213            $sender = $messages_template->thread->last_sender_id;
     214
     215        return apply_filters( 'bp_get_message_thread_from', bp_core_get_userlink($sender) );
    189216    }
    190217
     
    239266    function bp_get_message_thread_last_post_date() {
    240267        global $messages_template;
    241         echo apply_filters( 'bp_get_message_thread_last_post_date', bp_format_time( strtotime($messages_template->thread->last_post_date) ) );
     268
     269        /* Notice support */
     270        if ( empty( $messages_template->thread->last_post_date ) )
     271            $date = $messages_template->thread->date_sent;
     272        else
     273            $date = $messages_template->thread->last_post_date;
     274
     275        echo apply_filters( 'bp_get_message_thread_last_post_date', bp_format_time( strtotime($date) ) );
    242276    }
    243277
     
    246280}
    247281    function bp_get_message_thread_avatar() {
    248         global $messages_template;
    249         echo apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array( 'item_id' => $messages_template->thread->last_sender_id, 'type' => 'thumb' ) ) );
     282        global $messages_template, $bp;
     283
     284        /* Notice support */
     285        if ( empty( $messages_template->thread->last_sender_id ) )
     286            $sender = $bp->loggedin_user->id;
     287        else
     288            $sender = $messages_template->thread->last_sender_id;
     289
     290        echo apply_filters( 'bp_get_message_thread_avatar', bp_core_fetch_avatar( array( 'item_id' => $sender, 'type' => 'thumb' ) ) );
    250291    }
    251292
     
    318359function bp_messages_options() {
    319360    global $bp;
    320 
    321     if ( $bp->current_action != 'sentbox' ) {
    322361?>
    323         <?php _e( 'Select:', 'buddypress' ) ?>
    324         <select name="message-type-select" id="message-type-select">
    325             <option value=""></option>
    326             <option value="read"><?php _e('Read', 'buddypress') ?></option>
    327             <option value="unread"><?php _e('Unread', 'buddypress') ?></option>
    328             <option value="all"><?php _e('All', 'buddypress') ?></option>
    329         </select> &nbsp;
     362    <?php _e( 'Select:', 'buddypress' ) ?>
     363    <select name="message-type-select" id="message-type-select">
     364        <option value=""></option>
     365        <option value="read"><?php _e('Read', 'buddypress') ?></option>
     366        <option value="unread"><?php _e('Unread', 'buddypress') ?></option>
     367        <option value="all"><?php _e('All', 'buddypress') ?></option>
     368    </select> &nbsp;
     369    <?php if ( $bp->current_action != 'sentbox' && $bp->current_action != 'notices' ) : ?>
    330370        <a href="#" id="mark_as_read"><?php _e('Mark as Read', 'buddypress') ?></a> &nbsp;
    331371        <a href="#" id="mark_as_unread"><?php _e('Mark as Unread', 'buddypress') ?></a> &nbsp;
    332     <?php } ?>
     372    <?php endif; ?>
    333373    <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> &nbsp;
    334374<?php
     
    418458
    419459    $notice = BP_Messages_Notice::get_active();
    420     $closed_notices = get_usermeta( $userdata->ID, 'closed_notices');
     460
     461    if ( empty( $notice ) )
     462        return false;
     463
     464    $closed_notices = get_usermeta( $userdata->ID, 'closed_notices' );
    421465
    422466    if ( !$closed_notices )
     
    426470        if ( !in_array( $notice->id, $closed_notices ) && $notice->id ) {
    427471            ?>
    428             <div class="notice" id="<?php echo $notice->id ?>">
    429                 <h5><?php echo stripslashes($notice->subject) ?></h5>
    430                 <?php echo stripslashes($notice->message) ?>
    431                 <a href="#" id="close-notice"><?php _e( 'Close', 'buddypress' ) ?></a>
     472            <div id="message" class="info notice" rel="n-<?php echo $notice->id ?>">
     473                <p>
     474                    <strong><?php echo stripslashes( wp_filter_kses( $notice->subject ) ) ?></strong><br />
     475                    <?php echo stripslashes( wp_filter_kses( $notice->message) ) ?>
     476                    <a href="#" id="close-notice"><?php _e( 'Close', 'buddypress' ) ?></a>
     477                </p>
    432478            </div>
    433479            <?php
Note: See TracChangeset for help on using the changeset viewer.