Recent Topics

1 Sep 10, 2006 21:20    

How can this be done?

I require it for the Avatars and Gallery Plugins, as some users do not actually want to uninstall the database and file structure when they uninstall the plugin, so i would like it so when uninstall is clicked they are asked what they want to do.

Cheers.

2 Sep 10, 2006 22:32

See Plugin::BeforeUninstall(). Return NULL to have Plugin::BeforeUninstallPayload() get called.

3 Sep 10, 2006 22:42

k.

So what i would do is;

in BeforeUninstall, check if the variable that contains what the user wants to do exists, if it doesn't return NULL, if it does then do whatever the user wanted and return false/true depending on success of the action.

And in BeforeUninstallPayload i would output my html and use regenurl with the additional param?

5 Sep 10, 2006 22:57

Ok it's all cool and dandy, except in the payload the following is added;

THIS CANNOT BE UNDONE!
[I am sure!]

Why am i seeing that?

Or should i be using radio buttons instead of text and regenurl ?

Edit: Yeh, i just used radio buttons.

For anyone else wondering, here is what i used:

	function BeforeUninstall()
	{	
		global $Gallery;
	
		require_once(dirname(__FILE__).'/_gallery.php');
		
		if ( isset($_POST['gallery_uninstall']) )
		{
			if ( $_POST['gallery_uninstall'] == 'true' )
			{
				$pass = $Gallery->uninstall( true, true );
		
				if( !$pass || $Gallery->debug )
					$this->msg( 'Gallery Plugin: Uninstall Error<br />'.$Gallery->get_debug_info(), 'error' );
					
				return $pass;
			} else
			{
				return true;
			}
		} else {
			return NULL;
		}
	}
	
	function BeforeUninstallPayload()
	{
		?><br />
		Would you also like to uninstall all the data that was created with the Gallery Project?
		<br />
		<input type="radio" class="radio" name="gallery_uninstall" id="gallery_uninstall_radio_1" value="true" checked="checked" />
		<label class="radiooption" for="gallery_uninstall_radio_1">Yes</label>
		<input type="radio" class="radio" name="gallery_uninstall" id="gallery_uninstall_radio_2" value="false" />
		<label class="radiooption" for="gallery_uninstall_radio_2">No</label>
		<br /><br />
		<?php
	}

7 Sep 11, 2006 00:00

Yeah :)

Although maybe there should be a way so that 'I am sure' is not shown? But it is not needed atm, so until i need it i'm not complaining ;)

8 Sep 11, 2006 00:54

So, you mean that a plugin should be able to have it's own form, especially its own submit and the core actions like dropping Plugin tables, disabling other plugins that depend on the uninstalled one etc should be carried out afterwards?


Form is loading...