MyBB Community Forums

Full Version: No plugin deactivate or uninstall possibility
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am completely new in making your own plugins, so I started with a very simple one. This plugin removes the forum jump menu at the bottom of the forum display and thread display pages.
It works, the templates are changed and the forum jump menu is disappeared from the pages. However, after installing I get the following screen:

[attachment=33497]

So it seems to be installed (and it is, the templates have been changed), but there is no uninstall (or deactivate) link. Hence, I cannot uninstall the plugin. When I reverse the templates to their original state and I press install, the templates are changed again.
I suppose something went wrong in the first try, when there was still an error, but I can't remember what that was. Is there a way to restore a "normal" situation in which I can activate and deactivate this plugin?
Below the listing:


<?php
/**
 * Disallow direct access to this file for security reasons
 * 
 */
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
/**
 * Standard MyBB info function
 * 
 */
function WMOforum_info()
{
    global $lang;
    return Array(
        'name'          => "WMOforum",
        'description'   => "Wijzigingen van WMO forum ten opzichte van het standaard MyBB 1.8.3 forum",
        'website'       => '',
        'author'        => 'Ad Bakker',
        'authorsite'    => '',
        'version'       => '1.0',
        'guid'          => '',
        'compatibility' => '18*',
    );
}

/**
 * Install function
 * 
 */
function WMOforum_install()
{
//  Deactivate forum jump menu in templates showthread and forumdisplay_threadlist
    require_once(MYBB_ROOT . '/inc/adminfunctions_templates.php');
    find_replace_templatesets('showthread', '#' . preg_quote('{$forumjump}') . '#', '<!--Here was the forumjump menu-->');
    find_replace_templatesets('forumdisplay_threadlist', '#' . preg_quote('{$forumjump}') . '#', '<!--Here was the forumjump menu-->');
//    WMOforum_uninstall();
}

/**
 * Function that checks whether plugin is installed
 * 
 */
function WMOforum_is_installed()
{
    global $db;
    if($db->table_exists("WMOforum"))
    {
        return true;
    }
    return false;
}

/**
 * Uninstall function
 * 
 */
function WMOforum_uninstall()
{
//  Reactivate forum jump menu in templates showthread and forumdisplay_threadlist
    require_once(MYBB_ROOT . '/inc/adminfunctions_templates.php');
    find_replace_templatesets('showthread', '#' . preg_quote('<!--Here was the forumjump menu-->') . '#', '{$forumjump}');
    find_replace_templatesets('forumdisplay_threadlist', '#' . preg_quote('<!--Here was the forumjump menu-->') . '#', '{$forumjump}');
}
?>

Thanks in advance!!
Normally template changes are done in the _activate and _deactivate function. Database changes are done in _install and _uninstall. Add in a function for each of those and the links should show up.
I changed the function names to _activate and _deactivate, changed the templates back to the original form and presses "install & Activate" again. But the resuls is the same, activation is performed but no deactivation and/or uninstall links.
Your install function you aren't actually creating a table so your is_installed function will not return true. I think that is the biggest problem. Since you aren't doing any database changes, I believe you'd have to read the plugin cache. You can then check if it is in that. https://github.com/mybb/mybb/blob/featur...acache.php
Any suggestion what to do with it? Confused
The Hello World plugin has nothing to do with data base operations, and even has no unstall, uninstall, activate or deactivate functions, an yet it shows "Uninstall & Deactivate".

The file class_datacache.php already exists in the inc directury, but what to do with it?
Your plugin code currently makes no sense - you're trying to check a table which is not connected with your plugin at all. As dragonexpert said, you need to:
1. Move the template changes to activate/deactivate functions.
2. Remove the install/uninstall/is_installed functions.
Thanks, this works. I thought that I did the same by returning fulse by the _is_installed function, but that did't make any difference. But commenting the function did!!
I could have known, in Hello World, the _is_installed function is also commented. Blush 

Thanks again!!