2012-01-20, 01:10 PM
hi all, i have made a plugin, every thing works fine. the main thing i dont know how to work.
i want to hide edit button from owner. Users can only delete / edit their posts for 15 minutes after initial post.
i tried eval and find replace template but all in vain?
<?php
/**
@ Author: john App Engineer
@ Created: 02/01/12
@ Version: 1.0
@ Contact: [email protected]
*/
if(!defined("IN_MYBB"))
{
die("Hacking Attempt Logged. dhuz is comming to beat you putar.");
}
//$plugins->add_hook("showthread_start", "dhuz_hidelinks");
$plugins->add_hook("postbit", "dhuz_hidelinks");
function dhuz_info()
{
# This function returns info about the plugin, inluding the plugin name, the author, and the current version of the plugin.
return array(
"name" => "<span style='text-decoration: none;color: red;'>dhuz</span>",
"description" => "Hide Edit / Delete opton from post after 15 minutes.",
"website" => "http://www.google.com.pk/search?q=mirza+zeeshant+baig&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official",
"author" => "john App Engineer",
"authorsite" => "http://www.google.com.pk/search?q=mirza+zeeshan+baig&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official",
"version" => "1.0",
"guid" => "",
"compatibility" => "*"
);
}
function check_init_status1(){
global $db, $mybb, $templates, $lang, $plugins , $plugin_cache;
if ($mybb->settings['enabled_dhuz'] == 1){
echo "<center><h1>this Works!</h1><br />Try To Disable The Plugin You'll See This Text Will Hide..";
}
}
function dhuz_install(){
global $db, $mybb, $templates, $lang, $plugins;
}
function dhuz_uninstall()
{
global $db, $mybb, $templates, $lang, $plugins;
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('enabled_dhuz')");
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='dhuz'");
rebuild_settings();
}
function dhuz_hidelinks(&$post){
global $mybb, $post, $lang, $theme, $pid, $fid, $db, $headerinclude, $header, $footer, $thread,$templates,$forum;
$pid = $post['pid'];
$current_user_id = $mybb->user['uid'];
$thread_owner_id = $thread['uid'];
if($current_user_id) {
if($current_user_id == $thread_owner_id){
$d1=$thread['dateline'];
$d2=TIME_NOW;
$hours_diff = floor(($d2-$d1)/3600);
$min_diff = floor(($d2-$d1)/60);
$allowed_minutes = 15;
if(isset($mybb->settings['enabled_dhuz']) && !empty($mybb->settings['enabled_dhuz']) ){
if(isset($mybb->settings['time_dhuz']) && !empty($mybb->settings['time_dhuz']) ){
$allowed_minutes = (int) $mybb->settings['time_dhuz'];
}
}
$str = ' ';
$hours_diff = 0; # hack for testing for now
$min_diff = 10; # hack for testing for now
if($hours_diff<1){
if($min_diff <= $allowed_minutes){
what to do here for hiding the post bit edit { edit and delete button for first post}
}
}
}
// Rebuilding settings
rebuild_settings();
}
}
function dhuz_activate(){
global $db, $mybb, $templates, $lang, $plugins;
$dhuz_group = array(
'gid' => 'NULL',
'name' => 'dhuz',
'title' => 'dhuz',
'description' => 'Settings For hiding links of edit / delete from user after 15 miutes',
'disporder' => "1",
'isdefault' => 'no',
);
$dup_group_title ='';
$errors= '';
$query = $db->simple_select("settinggroups", "title", "name='dhuz'");
if($db->num_rows($query) > 0)
{
$dup_group_title = $db->fetch_field($query, 'title');
// $errors = $lang->sprintf($lang->error_duplicate_group_name, $dup_group_title);
}
if(empty($dup_group_title) || $dup_group_title == null ){
$db->insert_query('settinggroups', $dhuz_group);
$gid = $db->insert_id();
}
$dhuz_setting = array(
'sid' => 'NULL',
'name' => 'enabled_dhuz',
'title' => 'Do you want dhuz Enabled',
'description' => 'If Yes People Can Use dhuz, If No People Cannot Use dhuz.',
'optionscode' => 'yesno',
'value' => '1',
'disporder' => 1,
'gid' => intval($gid),
);
if ($mybb->settings['enabled_dhuz'] != 1){
$db->insert_query('settings', $dhuz_setting);
}
$dhuz_setting = array(
'sid' => 'NULL',
'name' => 'time_dhuz',
'title' => 'Time to dhuz',
'description' => 'After specified minutes (15), post will dhuz.',
'optionscode' => 'text',
'value' => '15',
'disporder' => 2,
'gid' => intval($gid),
);
if (!$mybb->settings['time_dhuz']){
$db->insert_query('settings', $dhuz_setting);
}
rebuild_settings();
}
function dhuz_deactivate(){
# here we are just deactivation. now Un-Installing.
global $db, $mybb, $templates, $lang, $plugins;
$db->delete_query("settings", "name IN ('enabled_dhuz','time_dhuz')");
$db->delete_query("settinggroups", "name='dhuz'");
rebuild_settings();
}
?>
i want to hide edit button from owner. Users can only delete / edit their posts for 15 minutes after initial post.
i tried eval and find replace template but all in vain?
<?php
/**
@ Author: john App Engineer
@ Created: 02/01/12
@ Version: 1.0
@ Contact: [email protected]
*/
if(!defined("IN_MYBB"))
{
die("Hacking Attempt Logged. dhuz is comming to beat you putar.");
}
//$plugins->add_hook("showthread_start", "dhuz_hidelinks");
$plugins->add_hook("postbit", "dhuz_hidelinks");
function dhuz_info()
{
# This function returns info about the plugin, inluding the plugin name, the author, and the current version of the plugin.
return array(
"name" => "<span style='text-decoration: none;color: red;'>dhuz</span>",
"description" => "Hide Edit / Delete opton from post after 15 minutes.",
"website" => "http://www.google.com.pk/search?q=mirza+zeeshant+baig&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official",
"author" => "john App Engineer",
"authorsite" => "http://www.google.com.pk/search?q=mirza+zeeshan+baig&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official",
"version" => "1.0",
"guid" => "",
"compatibility" => "*"
);
}
function check_init_status1(){
global $db, $mybb, $templates, $lang, $plugins , $plugin_cache;
if ($mybb->settings['enabled_dhuz'] == 1){
echo "<center><h1>this Works!</h1><br />Try To Disable The Plugin You'll See This Text Will Hide..";
}
}
function dhuz_install(){
global $db, $mybb, $templates, $lang, $plugins;
}
function dhuz_uninstall()
{
global $db, $mybb, $templates, $lang, $plugins;
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('enabled_dhuz')");
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='dhuz'");
rebuild_settings();
}
function dhuz_hidelinks(&$post){
global $mybb, $post, $lang, $theme, $pid, $fid, $db, $headerinclude, $header, $footer, $thread,$templates,$forum;
$pid = $post['pid'];
$current_user_id = $mybb->user['uid'];
$thread_owner_id = $thread['uid'];
if($current_user_id) {
if($current_user_id == $thread_owner_id){
$d1=$thread['dateline'];
$d2=TIME_NOW;
$hours_diff = floor(($d2-$d1)/3600);
$min_diff = floor(($d2-$d1)/60);
$allowed_minutes = 15;
if(isset($mybb->settings['enabled_dhuz']) && !empty($mybb->settings['enabled_dhuz']) ){
if(isset($mybb->settings['time_dhuz']) && !empty($mybb->settings['time_dhuz']) ){
$allowed_minutes = (int) $mybb->settings['time_dhuz'];
}
}
$str = ' ';
$hours_diff = 0; # hack for testing for now
$min_diff = 10; # hack for testing for now
if($hours_diff<1){
if($min_diff <= $allowed_minutes){
what to do here for hiding the post bit edit { edit and delete button for first post}
}
}
}
// Rebuilding settings
rebuild_settings();
}
}
function dhuz_activate(){
global $db, $mybb, $templates, $lang, $plugins;
$dhuz_group = array(
'gid' => 'NULL',
'name' => 'dhuz',
'title' => 'dhuz',
'description' => 'Settings For hiding links of edit / delete from user after 15 miutes',
'disporder' => "1",
'isdefault' => 'no',
);
$dup_group_title ='';
$errors= '';
$query = $db->simple_select("settinggroups", "title", "name='dhuz'");
if($db->num_rows($query) > 0)
{
$dup_group_title = $db->fetch_field($query, 'title');
// $errors = $lang->sprintf($lang->error_duplicate_group_name, $dup_group_title);
}
if(empty($dup_group_title) || $dup_group_title == null ){
$db->insert_query('settinggroups', $dhuz_group);
$gid = $db->insert_id();
}
$dhuz_setting = array(
'sid' => 'NULL',
'name' => 'enabled_dhuz',
'title' => 'Do you want dhuz Enabled',
'description' => 'If Yes People Can Use dhuz, If No People Cannot Use dhuz.',
'optionscode' => 'yesno',
'value' => '1',
'disporder' => 1,
'gid' => intval($gid),
);
if ($mybb->settings['enabled_dhuz'] != 1){
$db->insert_query('settings', $dhuz_setting);
}
$dhuz_setting = array(
'sid' => 'NULL',
'name' => 'time_dhuz',
'title' => 'Time to dhuz',
'description' => 'After specified minutes (15), post will dhuz.',
'optionscode' => 'text',
'value' => '15',
'disporder' => 2,
'gid' => intval($gid),
);
if (!$mybb->settings['time_dhuz']){
$db->insert_query('settings', $dhuz_setting);
}
rebuild_settings();
}
function dhuz_deactivate(){
# here we are just deactivation. now Un-Installing.
global $db, $mybb, $templates, $lang, $plugins;
$db->delete_query("settings", "name IN ('enabled_dhuz','time_dhuz')");
$db->delete_query("settinggroups", "name='dhuz'");
rebuild_settings();
}
?>