Not Solved Plugin won't let me deactivate/uninstall after installing
#1
Not Solved
The other week I did my first attempt at making a plugin after reading the help docs, everything worked completely fine. The plugin for now basically just adds settings to the AdminCP.

But now when I install them, they won't uninstall or give me the option to.

[Image: 63da2a67aa5a447dba78fd6bb78004f5.png]

Here is the code
<?php

if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.");
}


function noticemods_info()
{
	return array(
		"name"			=> "noticemods",
		"description"	=> "NoticeMods highlights moderator posts so they can be seen clearly over other posts.",
		"website"		=> "http://virtualfrost.com",
		"author"		=> "VirtualFrost",
		"authorsite"	=> "http://virtualfrost.com",
		"version"		=> "1.0.0",
		"guid" 			=> "",
		"codename"		=> "",
		"compatibility" => "18*"
	);
}

function noticemods_install()
{
  global $db, $mybb;

  $setting_group = array(
      'name' => 'noticemodsgroup',
      'title' => 'NoticeMods Settings',
      'description' => 'NoticeMods Configuration.',
      'disporder' => 5, // The order your setting group will display
      'isdefault' => 0
  );

  $gid = $db->insert_query("settinggroups", $setting_group);

  $setting_array = array(
    // A text setting
    'noticemods_user' => array(
        'title' => 'Moderator Username',
        'description' => 'Enter the username of the user who you wish to have highlighted posts.',
        'optionscode' => 'text',
        'value' => '',
        'disporder' => 1
    ),

		'noticemods_post_bg' => array(
        'title' => 'Background Color',
        'description' => 'Select the background color for the moderator posts',
        'optionscode' => 'text',
        'value' => '',
        'disporder' => 2
    ),
);

foreach($setting_array as $name => $setting)
{
    $setting['name'] = $name;
    $setting['gid'] = $gid;

    $db->insert_query('settings', $setting);
}

// Don't forget this!
rebuild_settings();
}

function noticemods_is_installed()
{

}

function noticemods_uninstall()
{
  global $db;

  $db->delete_query('settings', "name IN ('noticemods_user')");
  $db->delete_query('settinggroups', "name = 'noticemodsgroup'");

  rebuild_settings();
}

function noticemods_activate()
{

}

function noticemods_deactivate()
{

}
?>
Reply
#2
Not Solved
The problem is you aren't doing anything in the is_installed function that tells it whether or not it is installed.

function noticemods_is_installed()
{
global $db;
$query = $db->simple_select("settinggroups", "*", "name='noticemodsgroup'");
if($db->num_rows($query) >= 1)
{
return true;
}
return false;
}
Reply
#3
Not Solved
Perfect! I must have been using a previous version where I didn't save at that point. Thank you for that!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)