MyBB Central

Full Version: Lex...can you look into this?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Add this function to your plugins/myps.php

PHP Code:
function myps_delete_reply2()
{
    global 
$db$mybb$pid$post,$theme$templates$lang;

  if (
$mybb->settings['myps_status'] != "off")
  {
    
$myps_allow myps_allow();
    if(
$myps_allow == "yes")
    {

    
$query2 $db->query("SELECT uid FROM `".TABLE_PREFIX."posts` WHERE pid='".$pid."'");
    
$puid $db->fetch_field($query2"uid");

echo 
$pid "-pid test<br />";
echo 
$puid "-puid test<br />";


    }
  }


I know it looks weird...make sure it's on a test site only. Also turn on friendly redirect because on the redirect page you will get the echos.

Now change the hook on the top of the file from...

$plugins->add_hook('delete_post', 'myps_delete_reply');

to

$plugins->add_hook('delete_post', 'myps_delete_reply2');


The problem is that I have the $pid...but I can't get ANY db query to get me a result from it. I have tried DOZENS of things...nothing seems to work. The problem is actually only in one place...when you use the "inline moderation" tool to delete posts. It's fine to delete with the "Moderation Options:" with the regular function... but the "Inline Post Moderation:" where it uses some Javascript (though that shouldn't effect this) is the problem.

It's weird because I get $pid and $tid just fine...but queries for some reason won't go...I have tried arrays too. EVERYTHING...

Your help is much appreciated on this one. It's pretty much the last bug I want to fix before releasing 1.10.
OK, it freaks me out too =P If you try this, with a filled in number ex.

Code:
$query = $db->query("SELECT * FROM `".TABLE_PREFIX."posts` WHERE pid='70'");

You can get a result of it, but not with the $pid var filled in, even if the $pid contains the correct number.
Yeah I am like WTF...$pid does echo though.
$plugins->run_hooks("delete_post", $post['pid']);

find

PHP Code:
function myps_delete_reply2()
{
    global 
$db$mybb$pid$post,$theme$templates$lang

replace with

PHP Code:
function myps_delete_reply2($pid)
{
    global 
$db$mybb$post$theme$templates$lang

Any plugin hook that's called with a second argument means you call it in the functions arguments.

This is done because the function delete_post in inc/class_moderation.php doesn't globalize $pid. You need to globalize a variable in both functions if you wish to use a function within another function (which is basically how plugins work). And since it isn't globalized in function delete_post we pass it by reference as a argument to the plugin hook.
I've tried it with the $post var, but that didn't work ^^.


Edit ::

Doesn't seem to work either =/
Great news....The Most Excellent and Honorable Tikitiki helped me out and fixed the problem. When I release 1.10 you can check out what the problem was. Kind of sucked really as I approached it the wrong way. The PID was good but the post row was already deleted so there wasn't any UID to query! BAH! ...we had to hook into another area to get it to work. You will see the code.
lol =P Sounds like the problem with the editpost =P The record is already deleted before the plugin can do his job =P Will take a look at the code when it is released, there's always a place to learn more ^^ =D
Reference URL's