1 balupton Sep 10, 2006 21:20
3 balupton 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?
4 blueyed Sep 10, 2006 22:48
yep
5 balupton 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
}
6 blueyed Sep 10, 2006 23:54
So, is all fine?
7 balupton 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 blueyed 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?
9 balupton Sep 11, 2006 00:59
Why not?
See Plugin::BeforeUninstall(). Return NULL to have Plugin::BeforeUninstallPayload() get called.