MyBB-Plugins Forums

Full Version: Why Wont This Work? [MAKING OWN PLUGIN]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay, I'm trying to make my own plugin so it adds "My Posts" and "My Threads" into the welcomeblock_member area, so forum owners don't have to manually do it. But I can't get it to work?

i've uploaded it to my plugin directory, but it wont show up in the plugins section in the ACP, but all the other plugins will.

Code:
PHP Code:
<?php
/**
 * MyThreadsMyPosts 1.0
 
 * Copyright 2011 Deliver
 
 ** http://www.xblforums.net
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
**/
 
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
 
$plugins->add_hook("global_start""MyThreadsMyPosts");
 
function 
MyThreadsMyPosts_info()
{
    return array(
        
"name" => "MyThreadsMyPosts",
        
"description" => "Adds View My Threads and View My Posts to the WelcomeBlock area.",
        
"website" => "http://xblforums.net",
        
"author" => "Deliver",
        
"authorsite" => "http://xblforums.net",
        
"version" => "1.0",
        
"compatibility" => "16*",
        
"guid" => "null"
    
);
}
 
function 
MyThreadsMyPosts_activate()
{
    global 
$db;
 
    require_once 
MYBB_ROOT "inc/adminfunctions_templates.php";
 
    
MyThreadsMyPosts_deactivate();
 
    
$settings_group = array(
        
"name" => "MyThreadsMyPosts",
        
"title" => "Adds View My Threads & View My Posts in welcome area.",
        
"description" => "Adds View My Threads and View My Posts to the WelcomeBlock area.",
        
"disporder" => "28",
        
"isdefault" => 0
    
);
    
$db->insert_query("settinggroups"$settings_group);
    
$gid $db->insert_id();
 
    
$settings = array();
    
$settings[] = array(
        
"name" => "MyThreadsMyPosts",
        
"title" => "Adds View My Threads & View My Posts in welcome area.",
        
"description" => "Adds View My Threads and View My Posts to the WelcomeBlock area.",
        
"optionscode" => "onoff",
        
"value" => "1"
    
);
    
$settings[] = array(
        
"name" => "MyThreadsMyPostslevelgroups",
        
"title" => "Groups to show to",
        
"description" => "What usergroups should this show to?? Enter the GIDs and separate with a comma.",
        
"optionscode" => "text",
        
"value" => "2"
    
);
    
$i 1;
    foreach(
$settings as $setting)
    {
        
$insert = array(
            
"name" => $setting['name'],
            
"title" => $setting['title'],
            
"description" => $setting['description'],
            
"optionscode" => $setting['optionscode'],
            
"value" => $setting['value'],
            
"disporder" => $i,
            
"gid" => intval($gid),
        );
        
$db->insert_query("settings"$insert);
        
$i++;
    }
 
    
rebuild_settings();
 
    
$templates = array();
    
$templates[] = array(
        
"title" => "MyThreadsMyPosts",
        
"template" => " — {\$lang->header_welcomeblock_members} <a href=\"{\search.php?action=finduserthreads&uid={$mybb->user['uid']}\">View My Threads</a> | <a href=\"search.php?action=finduser&uid={$mybb->user['uid']}\">View My Posts</a> |\"><strong>{\$MyThreadsMyPosts</strong></a>"
    
); 
    foreach(
$templates as $template)
    {
        
$insert = array(
            
"title" => $template['title'],
            
"template" => $template['template'],
            
"sid" => "-1",
            
"version" => "1600",
            
"dateline" => TIME_NOW
        
);
        
$db->insert_query("templates"$insert);
    }
 
    
find_replace_templatesets("header_welcomeblock_member""#".preg_quote('{$lang->welcome_open_buddy_list}</a>')."#i"'{$lang->welcome_open_buddy_list}</a>{$MyThreadsMyPosts}');
}
 
function 
MyThreadsMyPosts_deactivate()
{
    global 
$db;
 
    require_once 
MYBB_ROOT "inc/adminfunctions_templates.php";
 
    
$db->delete_query("settinggroups""name = 'MyThreadsMyPosts)'");
 
    
$settings = array(
        
"MyThreadsMyPosts",
        
"MyThreadsMyPostsgroups"
    
);
    
$settings "'" implode("','"$settings) . "'";
    
$db->delete_query("settings""name IN ({$settings})");
 
    
rebuild_settings();
 
    
$templates = array(
        
"MyThreadsMyPosts"
    
);
    
$templates "'" implode("','"$templates) . "'";
    
$db->delete_query("templates""title IN ({$templates})");
 
    
find_replace_templatesets("header_welcomeblock_member""#".preg_quote('{$MyThreadsMyPosts}')."#i"''0);
}
 
function 
MyThreadsMyPosts()
{
    
$MyThreadsMyPostsgroups explode(","str_replace(" """$mybb->settings['MyThreadsMyPostsgroups']));
 
    if(
$mybb->settings['MyThreadsMyPosts'] == && in_array($mybb->user['usergroup'], $MyThreadsMyPostsgroups))
    {
            eval(
"\$MyThreadsMyPosts = \"".$templates->get('MyThreadsMyPosts')."\";");
        }
    }
?>
(The code is from "Warning level in header" plugin, I thought it would be good to use as I can't code, there's a lot of un-edited code which I've missed.)
If anyone can help me out that would be great, thanks.

No Permission

Unfortunately you do not have sufficient rights to view replies in this thread.