LMD (@louisedade)

Forum Replies Created

Viewing 25 replies - 26 through 50 (of 52 total)

  • LMD
    Participant

    @louisedade

    Hmmm, great idea, but it doesn’t cope with complex plugins very well yet.

    For example, Avatar Upload and Private Messaging (which doesn’t even show up in the browser for some reason), where files need to be placed in different locations to the my-plugins folder.

    Still, useful to know when new versions of plugins come out.

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    A new version of Avatar Upload is now available – for changes see the plugin browser thread:

    https://bbpress.org/plugins/topic/46/page/2?replies=34#post-373

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    @Beaver6813:

    The error sounds like it’s trying to call the add_action() function when either the file containing the function (wp-functions.php) isn’t included for some reason, or the plugin is being called before it has been included.

    I do not know why this might occur, although the fact you are using an integrated WordPress/bbPress combo might be a factor. We really need somebody who knows more about the internals of both system to help.

    Anyway, by commenting out the add_action() function all you have done is prevent the plugin from automatically creating an identicon for newly registered users. So, it’s not such a biggie while trying to solve the problem.

    @_ck_

    Feel free to hack the script however you see fit — I realise I have been rather too strict with the filenames, especially as it is really only a first-stage precaution (the file gets renamed n the server anyway). Also, I believe some browsers add the whole path to the uploaded filename (something I neglected to address).

    A solution I am adding to the next version will be to extract the actual filename from the path before checking.

    $img_name = basename($img['name']);

    Then, the number of necessary characters to allow is greatly reduced. I just prefer to approach it from the other end, block everything except what I explicitly allow. But as I said, feel free to hack it to suit your needs.

    I was completely unaware that you could enter a URL into a file input (“browse”) field? You indicate that it forces Windows to download the file, but I am wondering whether it is a browser specific feature and whether it is supposed to work like that? I would not rely on it.

    The mime-type comes from the uploaded file in $_FILES which, you are right should not be trusted. I’m experimenting with checking whether the uploaded file is areally an image doing something like imagecreatefromjpeg() – obviously using the appropriate function for the reported file extension (so if it’s all wrong/missing/forged an error will result). Alternatively, a simple solution might be to use getimagesize() (just the one function for all types), which I already use later in the code.

    In reply to: Avatar Upload Problems

    LMD
    Participant

    @louisedade

    RatherBeBiking: I’ve reponsed to your query in the bbPress forum “Plugin: Avatar Upload” topic.

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    Hello, the specific error you have reported could be a permissions problem – although if you tried settings permission to 666 and it still failed, I’m stumped. Alternatively, it could be some other problem with PHP’s move_uploaded_file() function.

    What might be helpful is what error PHP returns itself (I’ve suppressed PHP errors in the plugin). You need to temporarily show the PHP error for the function in question by removing the @ symbol from in front of it.

    Find the following line in avatar_upload.php (~ #99) and remove the @ symbol before the move_upload_file function.

    if ($img_errs == 0 && !@move_uploaded_file($img_temp, BBPATH .$config->avatar_dir . $user_filename) )

    .

    Then upload the file to the server, chmod the avatars folder to 666 and try uploading an avatar again — please report the full error message you get, including the PHP error.

    Oh and I have to ask this, just in case: are all the configuration settings in my-plugins/bb-avatar-upload.php correct? Is the avatars folder in the root and is the $this->avatar_dir config setting pointing to the correct location? I’m sure they are, but I have to check.

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    Oops, I ought to add the permissions information into the help file – maybe add a permissions check so plugin dies gracefully.

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    Version 0.3 is now available for download from the plugin browser.

    Version 0.3 is not compatible with previous versions, so you will have to go through your templates and make some changes to the template functions (check the Readme file).

    New Features

    * added an ‘Avatar’ tab to the profile menu

    * added a ‘default avatar image’ option (if you don’t want to use fel64’s identicons — see previous posts in this thread).

    * can access just the avatar’s URI for use in other plugins.

    fel – how would you like me to link to the identicon’s plugin? Currently, I’m just linking to your post in this thread.

    Oh and I have hacked together an Über-Avatar plugin which pulls together the various avatar plugins into one ‘api’. It iterates through some logic based on a specified order of preference (set by the admin), checking to see if the user has specified an avatar using each plugin.

    For example:

    Order to check: avatar-upload, bb-avatar. bb-myavatars, identicon

    Has user uploaded an avatar?

    — Yes: Invoke the ‘avatar-upload’ plugin template function and break.

    — No… continue

    Has the user specified an external URL?

    — Yes, invoke ‘bb-myavatar’ template function and break.

    — No… continue

    Has the user got a Gravatar?

    — Yes, invoke ‘bb-myavatars’ template functions and break.

    — No… continue

    Has the user got an identicon?

    — Yes, invoke the same code as ‘avatar-upload’ and break.

    — No. create an identicon and then invoke the ‘avatar-upload’ code.

    It’s not perfect yet though, so no release.

    In reply to: Profile Tabs

    LMD
    Participant

    @louisedade

    Aha! Thank you Sam! As fel has already discovered I abandoned any attempt at having “Upload Avatar” as a profile tab. It’s definitely going into the next version.

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    Yikes, what a lot of mime-types! Thanks, they won’t be hard to include in the next version. Although I’ve not actually seen many of them before, particularly the JPEG ones – I’m guessing those are created by various digital cameras?

    @amethystdragon: It shouldn’t be too hard to hack all four plugins together, while also keeping them as standalone plugins. I’ve downloaded all the avatar plugins to take a look. I have an idea for a “über-avatar” layer – a single script that ties all the others together. Almost an API layer.

    I don’t want to start, though, until I’ve got access to the plugin SVN repositry.

    In reply to: Hooks & Filters Docu

    LMD
    Participant

    @louisedade

    I don’t know if I count as recognised or regular? Does it help if I remove my disguise?

    I’m all for some docs, even if it’s just a bare-bones list of available hooks and filters.

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    A default avatar option will be in the next version of the plugin!

    Also, Smurfdude, Would you also like to show how you included avatars in WordPress, for the benefit of other users?

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    @Trent and ardentfrost: Thank you!

    Trent, feel free to use the upload code for whatever! I stole it from myself anyway… it is adapted from a photo gallery application I wrote.

    My previous message hinted at expanding the number of images that can be uploaded, although I only mean it within the context of multiple avatars. But somebody else is welcome to expand the code to a general image/file uploader.

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    Ok, I’ve now looked at the code and can see how it can be included without needing to branch the plugin too much (and all the maintenance issues involved with that!).

    First of all I removed the identicon functions from the bb-avatar-upload.php file and placed them at the bottom of the identicon.php file, to keep them all together.

    Secondly, I moved the if($_POST['identicon']){...} code from the avatar-upload.php file to the bottom of identicon.php and made it a function called by the ‘bb_head’ hook (I might eventually do this for the main upload functions too). Note: Is there a pre-head hook that fires before any headers are sent?

    function useidenticon()
    {
    global $user;
    //fel identicon
    if( $_POST['identicon'] )
    {
    felapplyidenticon( $user->ID );
    }
    }

    add_action( 'bb_head', 'useidenticon' );

    You then only need to supply and maintain two files for the “branch”.

    - my-plugins/identicon.php
    - my-templates/avatar.php

    The avatar.php template is the least likely file to change (it’s been modified slightly since version 0.1).

    I’ve made the modifications and zipped them up for you to examine:

    Identar Modified (this is minus my files, except the template file)

    You will also need the updated version of Avatar Upload: Avatar Upload (version 0.2)

    By keeping the Identicon and Avatar parts of the code separate, it should be easier to use Subversion to merge in – or simply replace – changes I make to the trunk code.

    Regarding filename storage in the database – there are two reasons for this. The first is that I prefer to store the image dimensions along with the current avatar. The maximum width and height of the avatar is just that, maximums; the actual dimensions could be any size and any aspect ratio within that limit. I then include the height and width attributes in the <img> tag – it’s good practise because the browser makes space for the image when loading the page, instead of shifting everything after the page has loaded.

    The second reason is more exciting – future proofing. A future version of this plugin will allow multiple file uploads, allowing users to upload more than one avatar image and select which one to use.

    Since releasing version 0.1 of the plugin, I have reduced the number of DB calls in the profile pages and in the avatar-upload.php file by making use of the $user object and calling $user->avatar_file when I need to access the avatar info.

    Although, when adding avatars to a user’s posts you still have to do a DB query. If I used your suggested method, it is still going to involve at least one call to the DB, either to get the user_login from the get_post_author_id() (and then grab the avatar file), or to get the avatar itself from the get_post_author_id().

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    @fel64: I’ve downloaded your mod and will take a look at how it works to see about branching my plugin. More thoughts later…

    @smurfdude: That is an excellent idea. I’m not sure about how to integrate with WordPress, but I’m guessing it would require a WordPress plugin that pulls the data from the bbPress database.

    In reply to: like5.com

    LMD
    Participant

    @louisedade

    Aha! I did not realise there was a Random Member plugin. In that case I just need to add instructions for integrating without needing to duplicate the functionality.

    I like it when things turn out to be far simpler than expected!

    In reply to: like5.com

    LMD
    Participant

    @louisedade

    Nice use of my Avatar Upload plugin! I see you’ve modded it a bit too by adding a classname to the image link, which is great.

    I like the “Random Members” on the front page. I wonder if you’d consider sharing code, with full credit of course, so the random image thing can be added to the avatar upload plugin?

    I don’t know how you’ve set-up your random script, but I can see it being made configurable, so users can select the number to display and if they wish to limit it to only people who have uploaded an avatar.

    Let me know what you think.

    In reply to: Plugin: Avatar Upload

    LMD
    Participant

    @louisedade

    If you are using the default template, ‘kakumei’, then yes, you can put ‘avatar.php’ in the default ‘bb-templates/kakumei’ folder.

    If you are using a custom template, then you need to upload it to your custom template folder (which is how I’m using it) – it does not cause problems if the file does not exist in the default template.

    In reply to: Plugin: Latest Replies

    LMD
    Participant

    @louisedade

    I’m not that surpised it didn’t work. Here is a different fix, editing the ‘bbPress Post’ plugin itself. I’m using line numbers to reference the code. I’ve based the line numbers on an UNEDITED version of the ‘bbpress_post.php’ file. So, if you open up a fresh version of the file that hasn’t been touched (i.e. do not use the version you previously added my ‘fix’ to – you no longer need that fix).

    Try these code changes:

    Line # 457 – replace with:

    bbpress_bb_new_post($topic_id, $content, $forum, $author, $now, $title);

    Line #533 – replace with:

    $wpdb->query("UPDATE ". $bb_table_prefix ."posts SET post_text='$content', post_title='$title' WHERE post_id=$bbpost_id LIMIT 1;");

    Line #540 – replace with:

    $otherdb->query("UPDATE ". $bb_table_prefix ."posts SET post_text='$content', post_title='$title' WHERE post_id=$bbpost_id LIMIT 1;");

    Line #585 – replace with:

    function bbpress_bb_new_post( $topic_id, $content, $forum, $author, $now, $title ) { // making new post in bbPress

    Line #587 – replace with:

    $wpdb->query("INSERT INTO ". $bb_table_prefix ."posts VALUES ('', $forum, $topic_id, $author, '$content', '$now', '127.0.0.1', 0, 1, $title);");

    Line #591 – replace with:

    $otherdb->query("INSERT INTO ". $bb_table_prefix ."posts VALUES ('', $forum, $topic_id, $author, '$content', '$now', '127.0.0.1', 0, 1, $title);");

    Note: this is assumes two things:

    1. That in the bbPress ‘posts’ table the ‘post_title’ field was added as the last field.

    2. That you do not have any other plugins that have added fields to the bbPress database.

    Let me know how you get on this time.

    In reply to: Plugin: Latest Replies

    LMD
    Participant

    @louisedade

    Hello again, just finished examining code. There are two issues.

    The first issue is that the blog entries you are posting to bbPress appear as closed topics. This problem is totally unrelated to the “Add Titles to Replies” plugin, which does not touch the ‘topics’ table in the database at all. I suggest you enquire with the ‘bbPress Post’ author about this. Did you update that plugin on your forum at the same time as installing mine? That could be the source of the problem.

    Now, having said all that, the second issue is going to seem to contradict it. What I mean is, are you sure the topics are ‘closed’, or is it just that the content does not appear – that is, is it a phantom topic?

    This can occur when the ‘topics’ table gets updated, but the ‘posts’ table does not for some reason (usually a coding error). When you create a new topic in bbPress, you are actually simultaneously creating the topic and making the first post in that topic – so both tables get updated.

    This is where the problem involves my “Add Titles to Replies” plugin, because we have altered the ‘posts’ table, which may be causing an error in the ‘bbPress Post’ plugin code (that plugin writes to the database in a different way to the bbPress core).

    Still with me? Good…

    Now, I do not have access to an integrated WordPress/bbPress installation, so I have made a stab in the dark at trying to fix this the easy way. I’ve written a very short function (a bit of a hack really) that you can add to the ‘bbPress Post’ plugin.

    In the ‘bbPress Post’ plugin open the file called ‘bbpress_post.php’ and add the following code to the bottom of the page, just before the bottom PHP tag ?>

    /* Ugly 'Add Titles to Replies' Hack by LouiseDade */
    function bbpress_add_reply_title( $post_id, $topic_id ) {
    global $wpdb, $otherdb;
    $bb_table_prefix = bbpress_getoption('bb_prefix');

    if (bbpress_getoption('bb_other_base') === "no") {
    $topic_title=$wpdb->get_var("SELECT topic_title FROM ". $bb_table_prefix ."topics WHERE topic_id=$topic_id LIMIT 1; ");
    $wpdb->query("UPDATE ". $bb_table_prefix ."posts SET post_title='$topic_title' WHERE post_id='$post_id' LIMIT 1");
    } else {
    $topic_title=$otherdb->get_var("SELECT topic_title FROM ". $bb_table_prefix ."topics WHERE topic_id=$topic_id LIMIT 1; ");
    $otherdb->query("UPDATE ". $bb_table_prefix ."posts SET post_title='$topic_title' WHERE post_id='$post_id' LIMIT 1");
    }
    }

    Next, scroll up to the bbpress_new_post() function and at the bottom, before the closing curly brace, add:

    /* Added by LouiseDade - updates post reply title */
    bbpress_add_reply_title( $post_id, $topic_id );

    Then scroll up again to the bbpress_post_update() function and add the same code as above just before the closing curly brace again.

    Re-upload the plugin with the changes made and try posting a WordPress entry.

    If it works I shall jump around for joy, but unfortunately I have grave doubts about it. I think it might need to be done the hard-way, which involves rewriting some of the ‘bbPress Post’ plugin.

    Good luck!

    In reply to: Plugin: Latest Replies

    LMD
    Participant

    @louisedade

    Hi,

    Thank you for letting me know. I suspect the problem is something to do with the fact that an extra database field has been created, and the ‘bbPress Post’ plugin is not updating that field. I have downloaded the plugin and will look at the code to see what’s going on — the fix may have to be in ‘bbPress Post’ rather than my plugins – but it may just be a small code change you can make yourself.

    So, I’ll get back to you in this topic later.


    LMD
    Participant

    @louisedade

    Uh, you don’t need to create separate functions for each tag! You are only extending the contents of an array.

    I use this home-grown plugin for all the extra tags I want to add (edited for readability).

    <?php
    // Allow extra html tags, even depreciated
    function allow_extra_tags( $tags )
    {
    $tags['a'] = array(
    'href' => array(),
    'title' => array(),
    'rel' => array(),
    'target' => array()
    );
    $tags['i'] = array();
    $tags['b'] = array();
    $tags['del'] = array();
    $tags['strike'] = array();
    $tags['img'] = array(
    'src'=> array(),
    'alt' => array(),
    'width' => array(),
    'height' => array()
    );

    return $tags;
    }
    add_filter( 'bb_allowed_tags', 'allow_extra_tags' );
    ?>

    Much simpler and easier to maintain.

    In reply to: Plugin: Latest Replies

    LMD
    Participant

    @louisedade

    Plugin updated!

    Now you can also display an individual user’s latest replies on their profile page.


    LMD
    Participant

    @louisedade

    Add Titles to Replies plugin version 0.2 now available.

    CHANGELOG

    * 2007-03-11 ver. 0.2 enabled the title to be edited in “Edit Post” + template changes.

    * 2007-03-10 ver. 0.1 relased

    Edit: just seen Trent’s post – will see about adding it to repositry.


    LMD
    Participant

    @louisedade

    Oops, I’m a plonker – I forgot to include the ability to edit the title in ‘Edit Post’ . If anybody spotted it, don’t worry, I’ll fix that today.


    LMD
    Participant

    @louisedade

    I’ve managed to create a plugin that adds titles to replies – and documented it. The plugin is available for download from my website:

    http://www.classical-webdesigns.co.uk/articles/36_bbpress-plugin-add-titles-to-replies.html

    Comments and suggestions are welcome.

    One other thing, re:

    “Preview sounds good – but better yet would be an AJAX thing that means you don’t even have to reload the page when you post. :D

    That’s what I meant by using the DOM. In fact there would be no need for AJAX even – by using the javascript DOM you can ‘preview in place’ the post you are currently working on. If users do not have javascript enabled, then graceful degradation would mean that a button to view the preview on a separate page would be visible.

Viewing 25 replies - 26 through 50 (of 52 total)