Search Results for 'code'
-
AuthorSearch Results
-
July 29, 2007 at 1:33 pm #59537
In reply to: “My Threads” – User Specific Views
howtogeek
MemberI activated this plugin, but when I click on the link for “topics i’ve started”, all I get is a white page… looking at a sql trace, it doesn’t appear to be running the code at all.
Any idea what I could be doing wrong here?
July 29, 2007 at 1:18 pm #59558In reply to: transfering wp and bb to the same db
fel64
MemberNot a problem as long as you have access to the databases.
Open phpMyAdmin through your administration panel of your web hosting account, go to your database, open wp_usermeta and then click the ‘Search’ tab. Put into the “search conditions” field user_id = 1 AND meta_key = 'bb_capabilities'(this should be the user_id of your admin account). Edit the (hopefully) one result that comes up, and change the meta_value toa:1:{s:9:"keymaster";b:1;}. Then you should be keymaster.July 29, 2007 at 12:55 pm #59327In reply to: Strange (?) (404) report i Firebug
Sam Bauers
ParticipantApache processes rewrite directives in the order they are found.
First the main Apache config file is used, then (if they are allowed) the .htaccess files are used in the order they are encountered from the root of the website out through the directories until the final directory that contains the file that is being accessed.
So if you have a page at http://www.example.com/blog/forum, then the order of processing is like:
Apache config
|
+-> /path/to/site/www.example.com/.htaccess
|
+-> /path/to/site/www.example.com/blog/.htaccess
|
+-> /path/to/site/www.example.com/blog/forum/.htaccessSo the “blog” rewrite rules will be assessed first. This means that you may want to place your bbPress rewrite rules in the same .htaccess file as your blog rules, before the blog rules, as they are more specific and should be handled first.
Also, there were some problems with WordPress throwing 404 errors based on what mod_rewrite was doing. This was specifically with version 2.1 I think, so your WordPress may need to be upgraded.
July 29, 2007 at 12:27 pm #49633In reply to: Emoticons For bbPress?
fel64
MemberIt’s Javascript. PHP files are just like HTML files, and anything outside the
<?php ... ?>is treated as HTML. Calling the particular function around that makes it go to that place and then go through and output the HTML (which happens to be JS).July 29, 2007 at 12:12 pm #59534In reply to: “My Threads” – User Specific Views
Sam Bauers
Participant> is there a method way to delete a view
In current trunk…
bb_deregister_view( $view )July 29, 2007 at 11:35 am #59532In reply to: “My Threads” – User Specific Views
_ck_
ParticipantUgh. So that breaks a view things I’ve done.
I’m waiting for an addition to the plugin svn and I’ll just update there at this point. I also missed checking if the user is logged in, now fixed.
I don’t run the newest trunk so I don’t have a way to test. Looks like I’ll have to setup a test account and install it again.
and I just put the finishes on a nice dropdown view box too…

function views_dropdown() {
$views_dropdown='<form name="views_dropdown" id="views_dropdown">
<select size=1 name="views_dropdown_select" onchange="if (this.selectedIndex != 0) {location=this.options[this.selectedIndex].value;}}">
<option value="#">SHOW ME
> </option>';
$views=get_views(); foreach ($views as $view => $title ) {
$views_dropdown.='<option value="'.get_view_link($view).'">'.$views[$view].'</option>';
}
$views_dropdown.='</select></form>'; echo $views_dropdown;
}July 29, 2007 at 11:30 am #59531In reply to: “My Threads” – User Specific Views
Sam Bauers
ParticipantYou should be aware that views are registered differently in the latest versions in trunk. Views are now constructed using the BB_Query class.
See the latest Support Forum plugin for a way to use both the new and old, although it is wrapped in a Class in there so the basic idea is:
if (is_callable('bb_register_view')) { // Build 876+
$query = <SOME ARRAY ACCEPTABLE TO BB_QUERY>;
bb_register_view('myview', __('My view name'), $query);
} else { // Build 214-875
add_filter('bb_views', 'my_addView');
add_action('bb_custom_view', 'my_processView');
}July 29, 2007 at 10:07 am #49632In reply to: Emoticons For bbPress?
mazdakam
Memberhi again i want to know why the function grin(tag) { is out of php code
why it need to be out side?
July 29, 2007 at 9:03 am #59030In reply to: Plugin: Private Forums v4.0
_ck_
ParticipantOh figured out how to fix the moderator’s profile, very easy to do when using my additional function – just attached more “where filters”:
function private_forums_filter_private($where,$prefix=''){
if (function_exists("private_forums_custom_get_options")) {
$private_forums = private_forums_custom_get_options('private_forums');
foreach($private_forums as $forum => $role) {
if(!private_forums_check_user_access_to_forum($role)) {
$where.=" AND ".$prefix."forum_id != ".$forum." ";
}
}
}
return $where;
}
add_filter( 'get_latest_topics_where', 'private_forums_filter_private');
add_filter( 'get_latest_posts_where', 'private_forums_filter_private');
add_filter( 'get_recent_user_replies_where', 'private_forums_filter_private');
add_filter( 'get_recent_user_threads_where', 'private_forums_filter_private');July 29, 2007 at 8:49 am #59530In reply to: “My Threads” – User Specific Views
_ck_
ParticipantWow I was making it too complicated! Try this…
I managed to use internal functions but there’s a catch with get_recent_user_replies in that all topic data is not attached properly so I have to run through get_topic to pull all the cache data out again (the only proper way to do it without peeking in the cache directly)
<?php
/*
Plugin Name: my views
Description: views for a user's topics started and other participated topics
Plugin URI:
Author:
Version: 0.01
*/
function my_views_filter( $views ) {
global $views;
$views['my-topics'] = "Topics I've Started";
$views['my-posts'] = "Topics I've Participated In";
return $views;
}
add_filter('bb_views', 'my_views_filter');
function my_views_action( $view ) {
global $bbdb, $topics, $view_count; $user_id=bb_get_current_user_info( 'id' );
if ($view=='my-topics') {$topics=get_recent_user_threads($user_id); $view_count = count($topics);}
if ($view=='my-posts') {
$posts=get_recent_user_replies($user_id); $topics="";
foreach ($posts as $post) {$topics[]=get_topic($post->topic_id );}
$topics=bb_append_meta( $topics, 'topic' );
$view_count = count($topics);}
}
add_action( 'bb_custom_view', 'my_views_action' );
if (!function_exists(bb_get_view_title)) {
function bb_get_view_title($title) {
if (is_view()) {$title = get_view_name(). ' « ' . bb_get_option( 'name' ); }
return $title;
}
add_filter( 'bb_get_title', 'bb_get_view_title' );
}
?>July 29, 2007 at 7:50 am #59476In reply to: {Request plugin:} auto complete tags
mazdakam
Memberhummm i am listeing to good news
July 29, 2007 at 7:20 am #59528In reply to: “My Threads” – User Specific Views
_ck_
ParticipantI haven’t seen them (doesn’t mean it doesnt exist) but I’ve figured out the framework on how to build and attach a view if you’d like to copy my homework

This is the code I whipped up for “most-views” and “least-views” (which requires the view count plugin to be installed (and inserting the views column in view.php)
function most_views_views( $views ) {
global $views;
$views['most-views'] = 'Topics with the most views';
return $views;
}
add_filter('bb_views', 'most_views_views');
function least_views_views( $views ) {
global $views;
$views['least-views'] = 'Topics with the least views';
return $views;
}
add_filter('bb_views', 'least_views_views');
function most_views( $view ) {
global $bbdb, $topics, $view_count;
if ($view=='most-views') {$sort="DESC";}
if ($view=='least-views') {$sort="ASC";}
if ($view=='least-views' || $view=='most-views') {
$limit = bb_get_option('page_topics');
$where = apply_filters('get_latest_topics_where','');
$most_views = $bbdb->get_results("SELECT topic_id FROM $bbdb->topicmeta WHERE meta_key='views' ORDER BY cast(meta_value as UNSIGNED) $sort LIMIT $limit");
foreach (array_keys($most_views) as $i) {$trans[$most_views[$i]->topic_id] =& $most_views[$i];} $ids = join(',', array_keys($trans));
$topics ="SELECT * FROM $bbdb->topics WHERE topic_status=0 AND topic_id IN ($ids) $where ORDER BY FIELD(topic_id, $ids)";
$topics = $bbdb->get_results($topics);
$view_count = count($topics);
$topics = bb_append_meta( $topics, 'topic' );
}
else {do_action( 'bb_custom_view', $view );}
}
add_action( 'bb_custom_view', 'most_views' );As you can see a new view requires both 1. an action 2. a filter
Easy once you’ve seen it, but try figuring it out from scratch!
This bit adds the title to view pages (missing by default in bbpress)
function bb_get_view_title($title) {
if (is_view()) {$title = get_view_name(). ' « ' . bb_get_option( 'name' ); }
return $title;
}
add_filter( 'bb_get_title', 'bb_get_view_title' );July 29, 2007 at 4:37 am #59243In reply to: Plugin: Plugin browser for bbPress
Sam Bauers
ParticipantMy other option is to make the update check more atomic. Here, your pagination idea could help. So instead of fetching all the plugins, I could just fetch the first page, then the second etc. etc. on request. More complicated to code, but it might be the best long term solution to keep the best of both worlds. I could also add a way to list installed plugins first, or even have a separate view of installed plugins.
I wouldn’t think Trac is faster, it has a few more overheads on the server side I think. I don’t think it will come down to that though.
Neither the Trac site nor the SVN repository use compression on their output, so gzip is useless, but that was a good suggestion. I’m not sure the SVN repository could use gzip anyway as it would potentially get in the way of some SVN clients, I’m not sure SVN even supports compression techniques like that (although it probably should).
July 29, 2007 at 4:23 am #51573In reply to: Full Content of Most Recent Post on Front-Page?
Sam Bauers
ParticipantYou’ll need to order that query by using
ORDER BY post_time DESC. There is no guarantee that the last row of a table is the last row that was added.July 29, 2007 at 3:50 am #59474In reply to: {Request plugin:} auto complete tags
_ck_
ParticipantAuto closing formatting is being worked on by mdawaffe now I believe.
It’s a single boolean bug (true/false) so I should hope it doesn’t take too long
July 29, 2007 at 3:35 am #51572In reply to: Full Content of Most Recent Post on Front-Page?
outchy
Memberok cool, thank you. it’s doing something so that’s good

this is what i’m using:
<?php
$latestpost = $bbdb->get_row("
SELECT *
FROM $bbdb->posts
WHERE post_status = 0
LIMIT 1
");
?>
<?php echo $latestpost->post_text; ?>it’s displaying the first post from forum 3 for some reason, not the most recent post. i’ve posted a few new posts since then in other forums and it never changes on the front page, it still shows that first post from that forum 3. any idea how come?
(thanks for your help on this)
July 29, 2007 at 3:16 am #51571In reply to: Full Content of Most Recent Post on Front-Page?
fel64
MemberSure that’s possible.

You want a query that gives you the last post. Forget anything messing around with the forum or the topic. You want the last post, right?
There’s no API function to do this AFAIK, so you will have to use a query. I think the structure could go something like this:
$latestpost = $bbdb->get_row("
SELECT *
FROM $bbdb->posts
WHERE post_status = 0
LIMIT 1
");And then
$latestposthas$latestpost->post_text, poster_idand so on. But unfortunately not filtered, so you’d need to apply all those. Which is a bit nasty.But this is all unchecked and unresearched, you’ll need to play around with it.
All this is is a bare start.
July 29, 2007 at 2:33 am #51570In reply to: Full Content of Most Recent Post on Front-Page?
outchy
Memberi want to display the most recent post, no matter what forum it happens to be from. is that possible?
i tried doing what you said but maybe i messed it up because i’m getting a mysql syntax error. here is what i have, forgive me if it looks glaringly stupid:
<?php
$forum_id = 1;
$forum_one_topics = $bbdb->get_row("SELECT * FROM $bbdb->topics WHERE forum_id = $forum_id ORDER BY topic_time DESC ") ?>
<?php
$forum_one_topic_posts = get_thread( $forum_one_topics->topic_id); ?>
Re: <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a>
<span class="gray">
<a href="<?php get_user_profile_link( $id = 0, $page = 1 ); ?>">
<?php echo $forum_one_topics->topic_last_poster_name; ?></a> said:</span> <span class="justify"><?php echo $forum_one_topic_posts[0]->post_text;
?></span>sorry, i’m really trying to get it
July 28, 2007 at 9:41 pm #59500In reply to: Working on new theme…
refueled
MemberJuly 28, 2007 at 9:32 pm #51569In reply to: Full Content of Most Recent Post on Front-Page?
fel64
Member$forum_one_topicsis not an array which is why it’s failing (although I’m surprised it’s not).Do you actually want the 1 latest topic from forum 1? Then use
$bbdb->get_row()instead ofget_results()and stop treating it as an array (basically, just take out theforeachpart since you don’t have several, and replace$topicwith$forum_one_topics).If you want all the topics from forum one, then take out the LIMIT 0, 1 bit from the query which as I understand it would give you only one result.
Also, you have some malformed HTML just under
span gray.July 28, 2007 at 9:28 pm #59520In reply to: subforums and markup
fel64
Memberfel64, the string is internal to bbpress, not the template loop.
Fair enough, shoulda checked that. So I went and looked through the code, you know, to find the problem. bb has quite an interesting structure there. Couldn’t find the problem, though, so I looked at the code in the .8.2.1 version and it’s missing a bit.
It’s fixed in trunk. Claire, upgrade to the latest version and it’ll work just fine.
July 28, 2007 at 8:44 pm #51568In reply to: Full Content of Most Recent Post on Front-Page?
outchy
Membersure, here is line 13:
foreach($forum_one_topics as $topic) :and here is the surrounding stuff:
<h2><?php _e('Latest Post'); ?></h2>
<?php
$forum_id = 1;
$forum_one_topics = $bbdb->get_results("SELECT * FROM $bbdb->topics WHERE forum_id = $forum_id ORDER BY topic_time DESC LIMIT 0,1") ?>
<?php
foreach($forum_one_topics as $topic) :
$forum_one_topic_posts = get_thread( $topic->topic_id); ?>
Re: <a>"><?php topic_title(); ?></a>
<span class="gray">
<a>">
<?php echo $topic->topic_last_poster_name; ?></a> said:</span> <span class="justify"><?php echo $forum_one_topic_posts[0]->post_text;
endforeach;
?></span>July 28, 2007 at 6:29 pm #59432In reply to: not getting pagination links on forum pages
_ck_
Participantfel64, the string is internal to bbpress, not the template loop.
Look at forum.php template to remind yourself
<?php while ( bb_forum() ) : ?>
<tr<?php bb_forum_class(); ?>>$forum is being treated as a global and not reset back.
I could remember and reset $forum I guess before and after the while-loop $temp=$forum; loop-here; $forum=$temp; but that’s an ugly hack. It’s got to be fixed in the core and that’s beyond my knowledge of bbpress.
July 28, 2007 at 6:28 pm #59516In reply to: subforums and markup
_ck_
Participantfel64, the string is internal to bbpress, not the template loop.
Look at forum.php template to remind yourself
<?php while ( bb_forum() ) : ?>
<tr<?php bb_forum_class(); ?>>$forum is being treated as a global and not reset back.
I could remember and reset $forum I guess before and after the while-loop $temp=$forum; loop-here; $forum=$temp; but that’s an ugly hack. It’s got to be fixed in the core and that’s beyond my knowledge of bbpress.
July 28, 2007 at 6:10 pm #59513In reply to: subforums and markup
fel64
MemberYup. Just don’t display the forum if
$forum->forum_parentis true. Change the bit in your templates that goes like this:<?php foreach( $forums as $forum ) : ?>
//blaaaaah HTML
<?php endforeach; ?>to this sort of thing:
<?php foreach( $forums as $forum ) :
if( !$forum->forum_parent ) { ?>
//blaaaaaah HTML
<?php }
enforeach; ?>(ugh colon syntax)
[Edit] Beat me to it ck (by the way, blockquote is already allowed and you’re overwriting it. Doesn’t really matter but could add conflict problems if someone wants to allow it to have attributes). Claire, worth mentioning that this method means it will ignore any subforums without you having to tell it it’s a subforum.
Claire, markup is like this:
<anytag>your text here</anytag>so actually HTML tags go between < and >. Actual code, like php code, will be shown as code if you put backticks around it.

You can also use a simplified markup like http://www.loinhead.net/files/felise (just copy that into a plugin file and activate), which means that *this* is bold, _this_ italic and this@someurl turns into
<a href="someurl">this</a>, etc. More on that https://bbpress.org/forums/topic/markdown?replies=10 -
AuthorSearch Results