Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 30,276 through 30,300 (of 32,467 total)
  • Author
    Search Results
  • #57348
    fel64
    Member

    Sure. Paste this in your HTML code somewhere:

    <?php if( bb_current_user_can('administrate) {
    $wp_admin = 'http://link.to.your/wordpress/wp-admin/';
    echo '<a href="'.$wpadmin.'">Wordpress Admin</a>'; } ?>

    #57329
    wmarcy
    Member

    Any chance you could show us the code for your admin stuff?

    #56258
    wittmania
    Member

    The reason that happened is that the user roles are stored in a separate table. If it is an integrated site, they are in wp_usermeta (or bb_usermeta if not integrated) where the meta_key is bb_capabilites and the meta_value is the capabilities assigned to them. I have no idea what the syntax for these capabilities is. However, if you wanted you could go into the database and search for the user ID that you are changing, and just change it there. Otherwise, reassigning the role might be just as easy, though it will still leave the record in the usermeta DB for that ID number, which might cause some problems. Unfortunately, there just isn’t an easy way to do this. :(

    #57337

    In reply to: Include code in posts

    wittmania
    Member

    Trent uses if (bb_current_user_can('administrate')) in his YouTube plugin. Couldn’t you mod the allow_images plugin to also allow <script> tags, but only if the user is an administrator? That would still allow the scripts to do their thing, but only in posts authored by an administrator.

    Unfortunately, if you’re looking for a way to place ads in posts by any ol’ user, there’s not a safe way to do that b/c they could put ANY script in and have it execute.

    Best bet? bb-Ads. Situations just like this are what I wrote it for. You can see it in action at blog.wittmania.com/bbpress

    #57336

    In reply to: Include code in posts

    fel64
    Member

    Yeah, and that’s where it’s annoying because you can’t easily check if a given user has permissions. Might be worth a trac ticket request.

    Possibly easiest would be to attach a filter for the post being submitted, because then you can use the bb_current_user_can() function.

    #57335

    In reply to: Include code in posts

    Null
    Member

    Well this doesn’t adress ads only, the question is more that the admin have more rights (like javascript/html entries) then ‘normal’ users.

    Can be done let me think…………….

    – You’ll have to enter some new tags in the plugin (allowed tags)

    – Then in the template files containing post fields, you could add the tags and make them visible for the admin only with something like: if user can edit;

    Now you can use javascript and other tags that you’ve entered and only the admin can see these links/buttons, but every1 can use them though :(

    So some filter should be added in view.php? like euuhh…

    If post is by admin, allow tags x,y,z else print as code...

    This way if a user tries to put in some javascript code it will be displayed as code and if the user is admin it will execute/display it.

    In theory :D

    #57334

    In reply to: Include code in posts

    fel64
    Member

    If you can’t edit the template and have something against the excellent bb-Ads plugin: I can’t help you, because AFAIK there’s no straightforward API function to check what a non-current user can do.

    #57340
    fel64
    Member

    Thanks!

    You can include ASCIIMathML.js in the header via plugin by this sort of code:

    `function incMathJs() {

    $url = bb_path_to_url( dirname(__FILE__) . ‘/ASCIIMathML.js’)

    echo ‘<script type=”text/javascript” src=”‘ . $url . ‘”>’;

    }

    add_action( ‘bb_head’, ‘incMathJs’ );

    Not sure when or how the JS kicks in, but perhaps that’s not necessary? Anyway, you could head over to trac and request that code_trick be made pluggable (so a plugin could overwrite it).

    #57333

    In reply to: Include code in posts

    dprice
    Member

    There is a plugin to allow the img tag, but you’d need to edit it and add a statement in saying “if admin then allowed_tags = …, else allowed_tags = …”. I’m not sure how easy that would be – anyone else have any clues?

    I’d suggest editing the template in bb-templates and adding it in manually, if you really, really want a banner ad.

    #1811

    Topic: Plugin: Say My Name

    in forum Plugins
    gh3
    Member

    Hi, this is my first post on bbPress, and it will deal with my new plugin.

    First of all I have to say that it is based on the great work by Thomas Klaiber on Post Notify plugin.

    But now let’s talk about Say My Name ( smn for friends ), this plugin will look at each post that will be posted for your nickname, and if it will find it, it will notify you by mail.

    I made this plugin because many times i saw people calling someone inside a post, and due to the dimension of the forum, the huge amount of post per day, and going on… the people called doesn’t see it.

    I have only to add that, as Thomas plugin, this one is activable by your profile, so if you have too common name like “and” “or” and going on, is better if you keep it off :)

    So that’s all, i have only to add the download link: http://www.ellequadro.net/wp-content/plugins/downloads-manager/download.php?id=6

    I hope that this plugin could be useful.

    #1810
    dprice
    Member

    Being both a web nerd and Physics student, I decided it was time for BBpress to meet up with MathML.

    Here’s the steps I took to get it crankin’:

    1. Made a copy of the default ‘kakumei’ template, then renamed the folder ‘physics’, my new template name. I then put a copy of ASCIImath.js in there. This does all the hard work.
    2. Changed the physics/header.php from:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" <?php bb_language_attributes( '1.1' ); ?>>

      to:

      <?xml version='1.0' encoding='iso-8859-1'?>
      <?xml-stylesheet type="text/xsl" href="http://www.w3.org/Math/XSL/mathml.xsl"?>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >

      <html xmlns="http://www.w3.org/1999/xhtml"
      xml:lang="en"
      xmlns:pref="http://www.w3.org/2002/Math/preference"
      pref:renderer="css">

      It’d probably still work if you didn’t bother with this step, but seeing as BBpress is making XML we may as well.

    3. Added <script type="text/javascript" src="<?php echo bb_path_to_url( dirname(__FILE__) . '/ASCIIMathML.js'); ?>"> to physics/header.php – this loads the ASCIIMathML.js javascript and does a majority of the MathML magic.
    4. Opened bb-includes/formattingfunctions.php and edited this:
      function code_trick( $text ) {
      $text = str_replace(array("rn", "r"), "n", $text);
      // $text = preg_replace("|<code>(.*?)</code>|e", "'<code>' . encodeit('$1') . '</code>'", $text);
      // $text = preg_replace("|n<code>(.*?)</code>|se", "'<pre><code>' . encodeit('$1') . '</code></pre>'", $text);
      return $text;
      }

      To turn off the backtick code replacement – this is what ASCIIMath.js does!

    That was it. I’ll zip it all up then post it up here. Ideally, it’d be better to not comment out any of the bb-include/ files – if anyone has any suggestions, let me know.

    #1809
    medden
    Member

    Is there a simple way for ONLY the administrator of the forum to be able to input embedded javascript into posts?

    She wants to include some banner ads from other companies, and getting these in the right format is turning into a real headache…..

    they are published like this…

    <img src="http://track.webgains.com/link.html?wglinkid=2995&wgcampaignid=23815&js=0" border="0" alt=""/>

    but the image plugin only allows .jpg .gif etc.

    Could that be disabled only if the ADMIN was posting the entry?

    #57328
    andersson
    Participant

    Thanks for the praise and also for the tip on the middle column. Haven’t really thought of it before but you’re probably right about that one.

    Regarding the /profiles/x it is really a simple mod. You could do it in a number of ways really, where I chose the following:

    Add a row in .htaccess steering the call to the logic:

    RewriteRule ^profiles/?$ mods/profiles-by-letter.php?id=$1 [QSA,L]

    Personally I put the logic of all mods in separate files in a mod folder and the presentation in another to keep it clean.

    The rewrite rule of .htaccess makes “x” a GET-parameter to the logic, it’s then very easy to select all members starting with letter given by “x” like so:

    SELECT * FROM bb_users WHERE user_login LIKE '$first_letter' ORDER BY user_login LIMIT $limit

    That’s it. The logic part then calls the presentation which can use the result in an array or whatever format you choose for the result.

    #57188
    fel64
    Member

    Replace D M Y with a date-formatted string of your choice. It’s quite an interesting but simple system. Each letter stands for a different type of date or time. So D is replaced by first three letters of the weekdate, M by first three of the month etc.

    This reference will tell you what letters to use to see what date outputs you get. Roll your own date format. :)

    #57327
    fel64
    Member

    You’ve got a really nice eye for the design of the site. It’s rare to see something so nicely designed and functional. :)

    The main column of games could be a bit more highlighted, though; with the strong coloured backgrounds the left colum distracts a lot. Worth it for the login form, but in my opinion not for stats.

    How did you get the /profiles/X thing to work? Haven’t tried it myself, but it would be interesting to know how much modification it took to have bb accept that – if any?

    #57331
    wittmania
    Member

    Answered my own questions. Thanks to plenty of googling, I learned that I needed to use the cast() function to consider the values as numbers instead of as text strings.

    This is the code I ended up with:

    $most_viewed = (array) $bbdb->get_results("SELECT topic_id, meta_value FROM $bbdb->topicmeta WHERE meta_key='views' ORDER BY cast(meta_value as UNSIGNED) DESC");

    The cast($column as $type) function forces the query to treat the meta_value values as unsigned integers. Nifty, yes?

    #57265
    Trent Adams
    Member

    The plugin system is actually now implemented in the TRAC version of bbPress and will be available in the upcoming 1.0 version (and no, I don’t know when that is for sure! ;)

    Trent

    #1808
    wittmania
    Member

    I am working on adding a “Most Viewed Topics” list to my bb-Topic-Views plugin, and I’m getting hung up on one little thing. This is the code I am using to pull the topic ID and # of views from the topicmeta table:

    $most_viewed = (array) $bbdb->get_results("SELECT topic_id, meta_value FROM $bbdb->topicmeta WHERE meta_key='views' ORDER BY meta_value DESC");

    I then use array_slice to shorten the list to the number of posts the user wants to have listed. The only problem is that the results are sorted out of order.

    For instance, a post with 5 views would come before a post with 40, because 5 is higher than 4. In other words, any post with a single-digit number of views is sorted above posts with a double-digit number of views.

    Has anyone ever had this problem? Any ideas how to fix it?

    #1807
    andersson
    Participant

    PurposeGames is one of my sites. It’s basically a site for anyone that wants to learn something new in the most efficient way possible; by creating a game around that very subject. It allows for anyone to easily create games and play/rate games by other members. I’ve actionscripted a game engine and a game creation module to allow for anyone to create games via their own pictures and drag and drop.

    I use bbpress for the forum section, and actually liked the user handling so much that I kept the authentication engine for all of the site. I’ve extended it in the following manner:

    – Elaborating on the bozo concept to exclude games created by a bozo, ratings doesn’t count for bozo’s and comments to games by bozos gets treated like forum entries by bozos.

    – Added a vast number of statistics to the dashboard to see what member’s are doing, creating, rating, commenting, forum entries, top lists etc.

    – Extending profile pages to show member’s games, comments to the games created by member etc.

    – Keeping the base of the style of the forum, extending it to fit the way I like my site to look.

    Concepts I like most about bbpress include the sanitize methods (very fast, perfectly implemented in my opinion), the user object; extending it is endless and very easy with the meta-concept, the tags concept, and the bozo concept and of course the table-free layout. The Akismet utilization is very nice also.

    Concepts that I’ve excluded or re-written: Db-connection open/close (not optimized for my type of site), the plugin concept (my extensions are therefore “include”-based i.e. I’m not utilizing the various hooks available). I have not cluttered the code of any standard files with my code, other than adding an include statement where needed. I also had to re-route the “include header”-call of the admin panel to be able to add new parent sections to keep child sections. No biggie really but quite strange.

    I rate bbpress as 4 out of 5 as code architecture goes being able to extend it and to use it as authentication foundation. Near superb. As forums goes, it falls into the category of “less is more, but not enough” ;)

    Check my way of using bbpress at http://www.purposegames.com

    Feel free to comment on what you like and don’t like. Thanks.

    David Andersson

    Creator of purposegames.com

    #57302

    In reply to: Plugin: bb-Topic-Views

    Sam Bauers
    Participant

    Change:

    function get_view_count( $topic_id )
    {
    $view_count = $bbdb->get_var("SELECT meta_value FROM $bbdb->topicmeta WHERE topic_id = $topic_id AND meta_key='views'");

    To:

    function get_view_count( $topic_id )
    {
    global $bbdb, $topic;

    $view_count = $bbdb->get_var("SELECT meta_value FROM $bbdb->topicmeta WHERE topic_id = $topic_id AND meta_key='views'");

    ????

    #57300

    In reply to: Plugin: bb-Topic-Views

    fel64
    Member

    All I did was split display_view_count() into two functions, display_view_count() and get_view_count(). If for example you wanted the views in a seperate column, you’d add the column HTML and then add

    <?php $view_count = get_view_count(); echo $view_count; ?>

    This is what I replaced display_view_count( $title ) with, here for Smurf’s convenience. You’re about to get mail.

    Oh, before I forget – hopefully now that plugins need activation in 1.0-alpha, there’s also an activation hook or the like. That would let you do a lot of preparation first, making the code much easier. :)

    Edit: there is! bb_activate_plugin_XXX. Maybe you can use that – if you want to and figure it out, tell us/make an entry on the wiki. :)

    function display_view_count ($title)
    {
    global $bbdb, $topic;
    $topic_id = $topic->topic_id;

    $view_count = get_view_count( $topic_id );

    //Builds the text to be appended to the title
    $count_display = " <em>($view_count views)</em>"; //This sets the view count var to the existing number of views, if greater than 0
    //Makes this plugin play nice with the Page Links plugin by putting the pages (if they exist) on a new line
    if (function_exists('page_links_add_links')) {
    $count_display .= "n";
    }
    $title .= $count_display;

    return $title;
    }

    function get_view_count( $topic_id )
    {
    $view_count = $bbdb->get_var("SELECT meta_value FROM $bbdb->topicmeta WHERE topic_id = $topic_id AND meta_key='views'");

    if ( $view_count <= 0 ) {
    //If the view count hasn't been initialized...
    if ($topic->topic_posts >= 1) {
    /* Sets the new record to the number of posts that have been made in a topic */
    $view_count = $topic->topic_posts; //sets the view_count number
    } else {
    $view_count = 0; //can't think of a time when this would be necessary (phantom topics???)
    }

    //Adds the record to the DB so it isn't zero any longer
    $bbdb->query("INSERT INTO $bbdb->topicmeta ( meta_id, topic_id, meta_key, meta_value) VALUES ( NULL , $topic_id, 'views', $view_count )");
    }

    return $view_count;
    }

    #57299

    In reply to: Plugin: bb-Topic-Views

    wittmania
    Member

    @fel, Hack away… I’d be interested in seeing the code so I could incorporate it in the next version of the plugin. If you’re willing, please e-mail it to me at mike at wittmania dot com.

    Thanks!

    #57298

    In reply to: Plugin: bb-Topic-Views

    fel64
    Member

    Wittmania, it’s a really easy hack – in fact, if you simply take the code that gets the pageviews and seperate it into a different function, you could call that both from the current function you have to automatically append it and use it as a template tag. If you don’t fancy doing it, is it alright if I quickly hack it for Smurf?

    #57297

    In reply to: Plugin: bb-Topic-Views

    wittmania
    Member

    @Sam, I use your excellent Page Links plugin, and I wrote mine specifically to be compatible with yours. In fact, I wouldn’t have known what filter to use if it weren’t for your plugin.

    I set the priority of my filter as 99 (yours is set to 100), so it fires directly before yours. Also, my plugin checks to see if the page_links_add_links function exists, and if it does it automatically drops the page links to a new line below the title in order to make things a little more sightly.

    @smurfdude, I thought about that, too. I initially decided against that route so I could have it function without having to edit any template files. The way it works right now is that it is inserted with a filter that is triggered when (and where) the topic title is fed to the page. If you’re feeling really ambitious, you can go into bb-topic-views.php to see how the mechanics of the plugin work. From there, you could change some things around so you could put the views count in its own column. Eventually I may add that functionality within the plugin, but that’s not a high priority right now.

    Speaking of priorities, the next to-do on my list is to add functionality where a user can add a template tag that will display the top 5 (or 10, or whatever) most viewed posts, either as <li> items so you can use it anywhere, or in a format similar to the way the Latest Discussion area is laid out. Stay tuned…

    #57273

    In reply to: Profile Tabs

    fel64
    Member

    Should really have been more familiar with the code – there’s a check to see if it’s the correct file, otherwise it simply redirects to the front page. Getting rid of that made it work.

    Thanks for all your help, Sam! :D

Viewing 25 results - 30,276 through 30,300 (of 32,467 total)
Skip to toolbar