Skip to:
Content

bbPress.org

Changeset 1198


Ignore:
Timestamp:
03/03/2008 06:16:23 AM (18 years ago)
Author:
sambauers
Message:

Built-in Avatar/Gravatar support using pluggable function.

Clean up layout/CSS for post author display.

Properly clear infobox in topic and stop "strikethrough" effect in IE.

Show email address on profile to 'manage_users' privilege holders. Fixes #792

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/options-general.php

    r1174 r1198  
    6767$selected[bb_get_option('mod_rewrite')] = ' selected="selected"';
    6868?>
    69                 <option value="0"<?php echo $selected[0]; ?>><?php _e('None') ?>&nbsp;&nbsp;&nbsp;.../forums.php?id=1</option>
    70                 <option value="1"<?php echo $selected[1]; ?>><?php _e('Numeric') ?>&nbsp;&nbsp;&nbsp;.../forums/1</option>
    71                 <option value="slugs"<?php echo $selected['slugs']; ?>><?php _e('Name based') ?>&nbsp;&nbsp;&nbsp;.../forums/first-forum</option>
     69                <option value="0"<?php echo $selected[0]; ?>><?php _e('None'); ?>&nbsp;&nbsp;&nbsp;.../forums.php?id=1</option>
     70                <option value="1"<?php echo $selected[1]; ?>><?php _e('Numeric'); ?>&nbsp;&nbsp;&nbsp;.../forums/1</option>
     71                <option value="slugs"<?php echo $selected['slugs']; ?>><?php _e('Name based'); ?>&nbsp;&nbsp;&nbsp;.../forums/first-forum</option>
     72<?php
     73unset($selected);
     74?>
    7275            </select>
    7376        </div>
     
    122125    </fieldset>
    123126    <fieldset>
     127        <legend><?php _e('Avatars'); ?></legend>
     128        <p>
     129            <?php _e('bbPress includes built-in support for <a href="http://gravatar.com/">Gravatars</a>, you can enable this feature here.'); ?>
     130        </p>
     131        <label for="avatars_show">
     132            <?php _e('Show avatars:') ?>
     133        </label>
     134        <div>
     135<?php
     136$checked = array();
     137$checked[bb_get_option('avatars_show')] = ' checked="checked"';
     138?>
     139            <input type="checkbox" class="checkbox" name="avatars_show" id="avatars_show" value="1"<?php echo $checked[1]; ?> />
     140<?php
     141unset($checked);
     142?>
     143        </div>
     144        <label for="avatars_rating">
     145            <?php _e('Gravatar maximum rating:'); ?>
     146        </label>
     147        <div>
     148            <select name="avatars_rating" id="avatars_rating">
     149<?php
     150$selected = array();
     151$selected[bb_get_option('avatars_rating')] = ' selected="selected"';
     152?>
     153                <option value="0"<?php echo $selected[0]; ?>><?php _e('None'); ?></option>
     154                <option value="X"<?php echo $selected['X']; ?>><?php _e('X'); ?></option>
     155                <option value="R"<?php echo $selected['R']; ?>><?php _e('R'); ?></option>
     156                <option value="PG"<?php echo $selected['PG']; ?>><?php _e('PG'); ?></option>
     157                <option value="G"<?php echo $selected['G']; ?>><?php _e('G'); ?></option>
     158<?php
     159unset($selected);
     160?>
     161            </select>
     162            <p>
     163                <img src="http://site.gravatar.com/images/gravatars/ratings/3.gif" alt="Rated X" style="height:30px; width:30px; float:left; margin-right:10px;" />
     164                <?php _e('X rated gravatars may contain hardcore sexual imagery or extremely disturbing violence.'); ?>
     165            </p>
     166            <p>
     167                <img src="http://site.gravatar.com/images/gravatars/ratings/2.gif" alt="Rated R" style="height:30px; width:30px; float:left; margin-right:10px;" />
     168                <?php _e('R rated gravatars may contain such things as harsh profanity, intense violence, nudity, or hard drug use.'); ?>
     169            </p>
     170            <p>
     171                <img src="http://site.gravatar.com/images/gravatars/ratings/1.gif" alt="Rated PG" style="height:30px; width:30px; float:left; margin-right:10px;" />
     172                <?php _e('PG rated gravatars may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.'); ?>
     173            </p>
     174            <p>
     175                <img src="http://site.gravatar.com/images/gravatars/ratings/0.gif" alt="Rated G" style="height:30px; width:30px; float:left; margin-right:10px;" />
     176                <?php _e('A G rated gravatar is suitable for display on all websites with any audience type.'); ?>
     177            </p>
     178        </div>
     179    </fieldset>
     180    <fieldset>
    124181        <?php bb_nonce_field( 'options-general-update' ); ?>
    125182        <input type="hidden" name="action" id="action" value="update" />
  • trunk/bb-includes/pluggable.php

    r1153 r1198  
    428428endif;
    429429
     430if ( !function_exists( 'bb_get_avatar' ) ) :
     431/**
     432 * bb_get_avatar() - Get avatar for a user
     433 *
     434 * Retrieve the avatar for a user provided a user ID or email address
     435 *
     436 * @since 0.8.4
     437 * @param int|string $id_or_email A user ID or email address
     438 * @param int $size Size of the avatar image
     439 * @param string $default URL to a default image to use if no avatar is available
     440 * @return string <img> tag for the user's avatar
     441*/
     442function bb_get_avatar( $id_or_email, $size = '80', $default = '' ) {
     443    if ( !bb_get_option('avatars_show') )
     444        return false;
     445
     446    if ( !$email = bb_get_user_email($id_or_email) )
     447        $email = $id_or_email;
     448
     449    if ( !$email )
     450        $email = '';
     451
     452    if ( empty($default) )
     453        $default = 'http://www.gravatar.com/avatar.php?gravatar_id=ad516503a11cd5ca435acc9bb6523536&size=' . $size;
     454        // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
     455    $default = urlencode( $default );
     456
     457    if ( !empty($email) ) {
     458        $out = 'http://www.gravatar.com/avatar.php?gravatar_id=';
     459        $out .= md5( $email );
     460        $out .= '&amp;size=' . $size;
     461        $out .= '&amp;default=' . $default;
     462
     463        $rating = bb_get_option('avatars_rating');
     464        if ( !empty( $rating ) )
     465            $out .= '&amp;rating=' . $rating;
     466
     467        $avatar = '<img alt="" src="' . $out . '" class="avatar avatar-' . $size . '" height="' . $size . '" width="' . $size . '" />';
     468    } else {
     469        $avatar = '<img alt="" src="' . $default . '" />';
     470    }
     471
     472    return apply_filters('bb_get_avatar', $avatar, $id_or_email, $size, $default);
     473}
     474endif;
    430475?>
  • trunk/bb-includes/template-functions.php

    r1185 r1198  
    44    global $bb, $bbdb, $bb_current_user, $page, $bb_cache,
    55        $posts, $bb_post, $post_id, $topics, $topic, $topic_id,
    6         $forums, $forum, $forum_id, $tags, $tag, $tag_name, $user, $user_id, $view;
     6        $forums, $forum, $forum_id, $tags, $tag, $tag_name, $user, $user_id, $view,
     7        $del_class, $bb_alt;
    78
    89    if ( $globals )
     
    11501151}
    11511152
     1153function post_author_avatar( $size = '48', $default = '', $post_id = 0 ) {
     1154    if ( ! bb_get_option('show_avatars') )
     1155        return false;
     1156   
     1157    $author_id = get_post_author_id( $post_id );
     1158    if ( $link = get_user_link( $author_id ) ) {
     1159        echo '<a href="' . attribute_escape( $link ) . '">' . bb_get_avatar( $author_id, $size, $default ) . '</a>';
     1160    } else {
     1161        echo bb_get_avatar( $author_id, $size, $default );
     1162    }
     1163}
     1164
    11521165function post_text( $post_id = 0 ) {
    11531166    echo apply_filters( 'post_text', get_post_text( $post_id ), get_post_id( $post_id ) );
     
    14231436    if ( is_array( $profile_info_keys ) ) {
    14241437        foreach ( $profile_info_keys as $key => $label ) {
    1425             if ( 'user_email' != $key && isset($user->$key) && '' !== $user->$key && 'http://' != $user->$key ) {
     1438            if (
     1439                ( 'user_email' != $key || ( 'user_email' == $key && bb_current_user_can( 'edit_users' ) ) )
     1440                && isset($user->$key)
     1441                && '' !== $user->$key
     1442                && 'http://' != $user->$key
     1443            ) {
    14261444                echo "\t<dt>{$label[1]}</dt>\n";
    14271445                echo "\t<dd>" . make_clickable($user->$key) . "</dd>\n";
  • trunk/bb-templates/kakumei/post.php

    r678 r1198  
    11        <div class="threadauthor">
    2             <p><strong><?php post_author_link(); ?></strong><br />
    3               <small><?php post_author_title(); ?></small></p>
     2            <?php post_author_avatar(); ?>
     3            <p>
     4                <strong><?php post_author_link(); ?></strong><br />
     5                <small><?php post_author_title(); ?></small>
     6            </p>
    47        </div>
    58       
    6         <div class="threadpost">
     9        <div<?php alt_class('post', 'threadpost ' . $del_class); ?>>
    710            <div class="post"><?php post_text(); ?></div>
    811            <div class="poststuff"><?php printf( __('Posted %s ago'), bb_get_post_time() ); ?> <a href="<?php post_anchor_link(); ?>">#</a> <?php post_ip_link(); ?> <?php post_edit_link(); ?> <?php post_delete_link(); ?></div>
  • trunk/bb-templates/kakumei/profile.php

    r711 r1198  
    22
    33<h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php _e('Profile') ?></h3>
     4<div id="useravatar"><?php echo bb_get_avatar( $user->ID ); ?></div>
    45<h2 id="userlogin"><?php echo get_user_name( $user->ID ); ?></h2>
    56
  • trunk/bb-templates/kakumei/style.css

    r1169 r1198  
    4040
    4141h2 { font-size: 1.5em; }
     42
     43img.avatar { border: 1px solid #ddd; }
    4244
    4345/* Structure
     
    233235
    234236#thread {
    235     background: #eee;
    236237    list-style: none;
    237     margin: 0 0 0 100px;
     238    margin: 0;
    238239    padding: 0;
    239240}
    240241
    241242#thread li {
    242     padding: 1.5em 1.0em;
    243243    line-height: 1.5em;
     244    clear: both;
     245    /* Hack to force padding on .threadauthor on IE */
     246    border-top: 1px solid #fff;
    244247}
    245248
     
    249252
    250253.threadauthor {
    251     margin-left: -110px;
    252     overflow: hidden;
    253     position: absolute;
    254     width: 95px;
    255 }
     254    float: left;
     255    padding: 1em 0 0 1em;
     256    width: 120px;
     257}
     258
     259.threadauthor p { margin: 0; }
    256260
    257261.threadauthor small { font: 11px Verdana, Arial, Helvetica, sans-serif; }
    258262
     263.threadpost {
     264    padding: 1.5em 1em;
     265    margin-left: 140px;
     266    background-color: #eee;
     267    -moz-border-radius: 6px;
     268    -khtml-border-radius: 6px;
     269    -webkit-border-radius: 6px;
     270    border-radius: 6px;
     271}
     272
     273.threadpost.alt {
     274    background-color: transparent;
     275}
    259276
    260277#thread .post blockquote {
     
    387404    position: relative;
    388405    top: -10px;
    389     -moz-border-bottom-left-radius: 6px;
     406    -moz-border-radius-bottomleft: 6px;
    390407    -khtml-border-bottom-left-radius: 6px;
    391408    -webkit-border-bottom-left-radius: 6px;
    392409    border-bottom-left-radius: 6px;
    393     -moz-border-bottom-right-radius: 6px;
     410    -moz-border-radius-bottomright: 6px;
    394411    -khtml-border-bottom-right-radius: 6px;
    395412    -webkit-border-bottom-right-radius: 6px;
     
    405422    background: #e4f3e1;
    406423}
     424
     425#useravatar { margin-bottom: 1em; }
     426
     427#useravatar img { display: block; border-width: 3px; border-style: double; }
    407428
    408429#userinfo { margin-top: 10px; }
  • trunk/bb-templates/kakumei/topic.php

    r968 r1198  
    2222<?php topic_tags(); ?>
    2323
    24 <br clear="all" />
     24<div style="clear:both;"></div>
    2525</div>
    2626<?php do_action('under_title', ''); ?>
     
    3333
    3434<?php foreach ($posts as $bb_post) : $del_class = post_del_class(); ?>
    35     <li id="post-<?php post_id(); ?>"<?php alt_class('post', $del_class); ?>>
     35    <li id="post-<?php post_id(); ?>">
    3636<?php bb_post_template(); ?>
    3737    </li>
Note: See TracChangeset for help on using the changeset viewer.