MyBB Community Forums

Full Version: HideUntilPost problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys, need help with this as it's driving me crazy..

I'm using this plugin on my forum: http://mods.mybb.com/view/hideuntilpost

It wasn't working until I made the edits stated by a user in the "Reviews" section and then it seemed to work.

However I keep getting this error:
Fatal error: Call to undefined function hideUntilPost_donewreply() in /home/******/public_html/inc/class_plugins.php on line 139

Not sure how to solve it and I've disabled the plugin for now as it wasn't working properly.. Can anyone assist with this?

Here is the full php file I am using myself:

<?php
/**
* Author: Sergio Montoya
* Copyright: © 2010 Sergio Montoya
* Website:  http://teamlago.com/
**/
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
// Parse messages
$plugins->add_hook("postbit", "hideUntilPost_clear");
$plugins->add_hook("parse_message", "hideUntilPost_code");
// Detect if first reply to post and refresh page
$plugins->add_hook('newreply_do_newreply_end', 'hideUntilPost_donewreply');
// filter quoted messages for tags that user should not see
$plugins->add_hook('newreply_end', 'hideUntilPost_newreply');
// filter fast reply quoted messages
$plugins->add_hook('xmlhttp', 'hideUntilPost_xmlhttp');

function hideUntilPost_info()
{
    return array(
        "name"          => "Links and Attachments lock until post",
        "title"         => "Links and Attachments lock until post",
        "description"   => "Will hide all links on posts and remove the attachment box if user has not replied to the thread.",
        "website"       => "http://www.soportemybb.com",
        "author"        => "Sergio Montoya",
        "authorsite"    => "http://www.teamlago.com/foro",
        "version"       => "1.2",
        "guid"          => "078dd70346382c953996ebfc3e8edcc7",
        "compatibility" => "14*,16*,18*"
    );
}
function hideUntilPost_install()
{
 // Creating plugin settings
 global $db;
 $group = array(
 "name" => "hideUntilPost_settings",
 "title" => "Hides Links and Attachments until Post",
 "description" => "Hides Links and Attachments until Post a Post has been made on the thread.",
 "disporder" => "50",
 "isdefault" => "no",
 );
 $db->insert_query("settinggroups", $group);
 $gid = intval($db->insert_id());
 $settings = array(
 array(
 "name" => "hideUntilPost_link_enabled",
 "title" => "Enable/Disable",
 "description" => "Hide links until post has been made?",
 "optionscode" => "yesno",
 "value" => "no",
 "disporder" => 1,
 "gid" => $gid,
 ), 
    array(
        "name" => "hideUntilPost_lock_enabled",
        "title" => "Enable/Disable",
        "description" => "Enable lock bbcode? (Everything inside [lock]...[/lock] will be hiden until post is made)",
        "optionscode" => "yesno",
        "value" => "no",
        "disporder" => 2,
        "gid" => $gid,
    ),
    array(
        "name" => "hideUntilPost_attach_enabled",
        "title" => "Enable/Disable",
        "description" => "Hide attachments until post has been made?",
        "optionscode" => "yesno",
        "value" => "no",
        "disporder" => 3,
        "gid" => $gid,
    ),
    array(
        "name" => "hideUntilPost_gid_exclude",
        "title" => "Exclude Groups",
        "description" => "Enter the usergroups IDs separated by commas which this plugin should not apply. 0 = No usergroups excluded. (Still won\'t apply for mods and admins)",
        "optionscode" => "text",
        "value" => 0,
        "disporder" => 4,
        "gid" => $gid,
    ),
    array(
        "name" => "hideUntilPost_fid_exclude",
        "title" => "Exclude Forums",
        "description" => "Enter the forum IDs separated by commas which this plugin should not apply. 0 = Applies for all forums.",
        "optionscode" => "text",
        "value" => 0,
        "disporder" => 5,
        "gid" => $gid,
    )
 );
 foreach($settings as $setting)
 $db->insert_query("settings", $setting);
 rebuild_settings();
 // Create template
 $template = array(
 "tid" => NULL,
 "title" => "hideUntilPost_box",
 "template" => "<div style=\"background: #FFF7C0; text-align: left; margin-left: 15px; padding: 13px 20px 13px 45px; border-top: 2px solid #F7D229; border-bottom: 2px solid #F7D229; line-height: 150%; margin-top: 5px; margin-bottom: 5px;\">{\$msg}</div>",
 "sid" => "-1"
 );
 $db->insert_query("templates", $template);
}
function hideUntilPost_is_installed()
{
 global $db;
 $query = $db->simple_select("templates", "tid", "title = 'hideUntilPost_box'");
 if($db->num_rows($query))
 {
 return true;
 }
 return false;
}
function hideUntilPost_uninstall()
{
 global $db;
 $db->delete_query("templates","title = 'hideUntilPost_box'");
 $db->delete_query("settinggroups","name = 'hideUntilPost_settings'");
 $db->delete_query("settings","name LIKE 'hideUntilPost_%'");
    rebuild_settings();
}
function hideUntilPost_count($tid,$uid)
{
 global $db;
 if(!isset($posts))
 {
 // Saves in the cache the amount of posts the current user has on the thread
 static $posts = 0;
 $query = $db->simple_select("posts","COUNT(pid) AS posts","tid='{$tid}' AND uid = '{$uid}'");
 $posts = intval($db->fetch_field($query,"posts"));
 }
 return $posts;
}
function hideUntilPost_validate($fid)
{
 global $mybb;
 // Check first by usergroups.
 if($mybb->user['uid'] != 0 && $mybb->settings['hideUntilPost_gid_exclude'] != 0)
 {
 $groups = explode(",", $mybb->settings['hideUntilPost_gid_exclude']);
 if($mybb->settings['hideUntilPost_gid_exclude'] == 0 || in_array($mybb->user['usergroup'], $groups))
 {
 // Aww man, can't apply the script to the post.
 return false;
 }
 }
 // Usergroup not excluded, so far so good. What about the forum?
 if($mybb->settings['hideUntilPost_fid_exclude'] != 0)
 {
 $fids = explode(",", $mybb->settings['hideUntilPost_fid_exclude']);
 if($mybb->settings['hideUntilPost_fid_exclude'] == 0 || in_array($fid, $fids))
 {
 // Aww man, can't apply the script to the post.
 return false;
 }
 }
 // Too bad... hiding content :)
 return true;
}
function hideUntilPost_filter(&$msg,$fid,$tid)
{
 global $mybb;
 if(!hideUntilPost_count($tid,$mybb->user['uid']) && hideUntilPost_validate($fid))
 {
 if($mybb->settings['hideUntilPost_link_enabled'])
 {
 $msg = preg_replace("#(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)#is",'',$msg);
 }
 if($mybb->settings['hideUntilPost_lock_enabled'])
 {
 $msg = preg_replace("#\[lock\](.*)\[/lock\]#is",'',$msg);
 }
 }
}
function hideUntilPost_code($message)
{
 global $mybb,$lang,$templates,$thread;
 // Will run only if it's being called from newthread.php.
 if((THIS_SCRIPT == "showthread.php" || THIS_SCRIPT == "newreply.php") && ($mybb->settings['hideUntilPost_link_enabled'] || $mybb->settings['hideUntilPost_lock_enabled']) && hideUntilPost_validate($thread['fid']) && !is_moderator($thread['fid']))
 {
 if(!hideUntilPost_count($mybb->input['tid'],$mybb->user['uid']))
 {
 $lang->load("hideUntilPost");
 if($mybb->settings['hideUntilPost_link_enabled'])
 {
 // Hides links
 $msg = $lang->hideUntilPost_link;
 eval("\$box = \"".$templates->get("hideUntilPost_box",1,0)."\";");
 $message = preg_replace("#<a[^>]*(http|www)(.*)</a>#siU",$box,$message);
 }
 if($mybb->settings['hideUntilPost_lock_enabled'])
 {
 // Hides lock bbcode content
 $msg = $lang->hideUntilPost_lock;
 eval("\$box = \"".$templates->get("hideUntilPost_box",1,0)."\";");
 $message = preg_replace("#\[lock\](.*)\[/lock\]#is",$box,$message);
 }
return $msg; 
 $done = true;
 }
 }
 if(!is_moderator())
 {
 // Parse this one more time. Only mods and admins can see the bbcode.
 $message = preg_replace("#\[lock\](.*)\[/lock\]#is",'$1',$message);
 }
}
function hideUntilPost_clear(&$post)
{
 global $mybb,$lang,$attachcache,$templates;
 if($mybb->settings['hideUntilPost_attach_enabled'] && is_array($attachcache[$post['pid']]) && $mybb->user['uid'] != $post['uid'] && !is_moderator($post['fid']) && hideUntilPost_validate($post['fid']))
 {
 if(!hideUntilPost_count($mybb->input['tid'],$mybb->user['uid']))
 {
 $lang->load("hideUntilPost");
 $msg = $lang->hideUntilPost_attach;
 eval("\$post['attachments'] = \"".$templates->get("hideUntilPost_box",1,0)."\";");
return $post; 
 }
 }
}
function hideUntilPost_newreply()
{
 global $message,$mybb;
 hideUntilPost_filter($message,$mybb->input['fid'],$mybb->input['tid']);
}
// After a quick reply, decide to refresh the page or not.
$redirect = true;
{
 global $db,$mybb,$thread;
 $redirect = false;
 // What has to be done to refresh the page automatically... A huge amount of validation :(
 if($mybb->input['ajax'] && !is_moderator($thread['fid']) && hideUntilPost_validate($thread['fid']))
 {
 if(hideUntilPost_count($thread['tid'],$mybb->user['uid']) === 1)
 {
 if($mybb->settings['hideUntilPost_attach_enabled'] && $thread['attachmentcount'] > 0)
 $redirect = true; //Cmon, attach on first post. Obvious redirect.
 else
 {
 // There's no attachment, but what about links and lock bbcode on first post?
 $options = array(
 "orderby" => "dateline",
 "limit" => array(
 "limit" => "1",
 "start" => "0"
 )
 );
 $query = $db->simple_select("posts","message","tid = '{$thread['tid']}'",$options);
 $message = $db->fetch_field($query,"message");
 if($mybb->settings['hideUntilPost_lock_enabled'] && preg_match("#\[lock\](.*)\[/lock\]#is",$msg))
 $redirect = true; // We do have a lock bbcode on the first post. Refresh to enable!
 elseif($mybb->settings['hideUntilPost_link_enabled'] && preg_match("#<a[^>]*(http|www)(.*)</a>#siU",$msg))
 $redirect = true; // We do have a lock bbcode on the first post. Refresh to enable!
 }
 }
 }
 if($redirect)
 redirect(get_thread_link($thread['tid'], 0, "lastpost"));
}
// Filter quotes
function hideUntilPost_xmlhttp()
{
 global $mybb;
 if($mybb->input['action'] != 'get_multiquoted')
 return;
 ob_start();
 function hideUntilPost_shutdown()
 {
 global $message,$multiquoted,$db;
 $query = $db->query("SELECT tid,fid FROM ".TABLE_PREFIX."posts WHERE pid = '{$multiquoted[0]}' LIMIT 1");
 $addinfo = $db->fetch_array($query);
 if(!$message)
 return;
 ob_end_clean();
 ob_start();
 hideUntilPost_filter($message,$addinfo['fid'],$addinfo['tid']);
 echo $message;
 }
 register_shutdown_function('hideUntilPost_shutdown');
}
?>
Anyone can help with this?
That is a 1.6 plugin. Just changing the compatibility does not always work.

Please look on the 1.8 mods site and/or the plugin releases forum. If you cannot find what you need make a plugin request.
(2015-10-30, 06:40 PM)Leefish Wrote: [ -> ]That is a 1.6 plugin. Just changing the compatibility does not always work.

Please look on the 1.8 mods site and/or the plugin releases forum. If you cannot find what you need make a plugin request.

I did and can't seem to find anything relevant sadly Dodgy
so make a plugin request......