2014-01-08, 02:00 PM
Guys I can't seem to get this plugin to check editpost.php it only checks newthread.php I had included:
but still doesn't work please help me.
$plugins->add_hook('datahandler_post_update_thread', "Leminewthread");
but still doesn't work please help me.
<?php
$plugins->add_hook("datahandler_post_validate_thread", "Leminewthread");
/*
Length Minimum in New Thread
Leminewthread
*/
function Leminewthread_info()
{
return array(
"name" => "Length Minimum in New Thread",
"description" => "This requires a minimum character count for thread titles and message",
"website" => "mailto:[email protected]",
"author" => "Edson Ordaz",
"authorsite" => "mailto:[email protected]",
"version" => "1.0",
"guid" => "54adf5bfb3149e71743ba35160e8411c",
"compatibility" => "16*"
);
}
// This function runs when the plugin is activated.
function Leminewthread_activate()
{
global $mybb, $db;
$Leminewthread = array(
"gid" => "NULL",
"name" => "Leminewthread",
"title" => "Length Minimum in New Thread",
"description" => "This requires a minimum character count for thread titles and message",
"disporder" => "-1",
"isdefault" => "no",
);
$db->insert_query("settinggroups", $Leminewthread);
$gid = $db->insert_id();
$setting_1 = array(
"sid" => "NULL",
"name" => "LengthMinimuminNewThread_subject",
"title" => "Longitud Minima de titulo en temas",
"description" => "Ingresa el numero de caracteres minimos para el titulo de los temas!!",
"optionscode" => "text",
"value" => "10",
"disporder" => "1",
"gid" => $gid
);
$setting_2 = array(
"sid" => "NULL",
"name" => "LengthMinimuminNewThread_subject_error",
"title" => "Mensaje de error en titulo",
"description" => "Ingresa el mensaje de error a mostrar si no tienen los caracteres el titulo del tema
Puedes usar <b>{1}</b> para que se ingrese el numero permitido de caracteres!!",
"optionscode" => "textarea",
"value" => "No puedes crear tema porque el titulo necesita tener {1} caracteres!!",
"disporder" => "2",
"gid" => $gid
);
$setting_3 = array(
"sid" => "NULL",
"name" => "LengthMinimuminNewThread_message",
"title" => "Longitud Minima de Mensaje de temas",
"description" => "Ingresa el numero de caracteres minimos para el mensaje de los temas!!",
"optionscode" => "text",
"value" => "30",
"disporder" => "3",
"gid" => $gid
);
$setting_4 = array(
"sid" => "NULL",
"name" => "LengthMinimuminNewThread_message_error",
"title" => "Mensaje de error en mensaje",
"description" => "Ingresa el mensaje de error a mostrar si no tienen los caracteres el mensaje del tema
Puedes usar <b>{1}</b> para que se ingrese el numero permitido de caracteres!!",
"optionscode" => "textarea",
"value" => "No puedes crear tema porque el mensaje necesita tener {1} caracteres!!",
"disporder" => "4",
"gid" => $gid
);
$db->insert_query("settings", $setting_1);
$db->insert_query("settings", $setting_2);
$db->insert_query("settings", $setting_3);
$db->insert_query("settings", $setting_4);
rebuild_settings();
}
// This function runs when the plugin is deactivated.
function Leminewthread_deactivate()
{
global $mybb, $db;
$db->delete_query("settinggroups","name='Leminewthread'");
$db->delete_query("settings","name='LengthMinimuminNewThread_subject'");
$db->delete_query("settings","name='LengthMinimuminNewThread_subject_error'");
$db->delete_query("settings","name='LengthMinimuminNewThread_message'");
$db->delete_query("settings","name='LengthMinimuminNewThread_message_error'");
rebuild_settings();
}
function Leminewthread(&$this)
{
global $mybb, $db, $posthandler;
$title_error = $mybb->settings['LengthMinimuminNewThread_subject_error'];
$message_error = $mybb->settings['LengthMinimuminNewThread_message_error'];
$title = $mybb->settings['LengthMinimuminNewThread_subject'];
$message = $mybb->settings['LengthMinimuminNewThread_message'];
$title_chars = get_object_vars($this);
$message_chars = get_object_vars($this);
$length_title = my_strlen($title_chars['data']['subject']);
$length_message = my_strlen($message_chars['data']['message']);
if( $length_title < $title){
$title_error = preg_replace("!\{1\}!Us", $title, $title_error);
$posthandler->set_error($title_error);
}
if( $length_message < $message){
$message_error = preg_replace("!\{1\}!Us", $message, $message_error);
$posthandler->set_error($message_error);
}
}
?>