I am working on my first mantis plugin and managed to get almost everything working.
Where I am struggling is in the (un)install area.
My plugin needs a table an I have not figured out how to do that at install time within plugin management. Clearly at uninstall time, the table ought to beremoved, also there i could use some advice.
Does anyone have a sample or other docs to help me out?
Cas
Plugin development
Moderators: Developer, Contributor
Re: Plugin development
Hi Cas,
What is your version of Mantis ?
Have you seen my post ? ==> http://www.mantisbt.org/forums/viewtopic.php?f=2&t=4809
It can help you.
Arenx
What is your version of Mantis ?
Have you seen my post ? ==> http://www.mantisbt.org/forums/viewtopic.php?f=2&t=4809
It can help you.
Arenx
Re: Plugin development
Hi Arenx,
I did saw your posting and had a look on the deboutv site.
Since I was playing with version 1.2.0 , I started also with the new plugin model.
I found the answer from Vincent on compatibility not very clear and so far did not managed to download anything from his site (but only tried twice).
Since my previous post I made some progress but am far from complete.
How did you continue?
Cas
I did saw your posting and had a look on the deboutv site.
Since I was playing with version 1.2.0 , I started also with the new plugin model.
I found the answer from Vincent on compatibility not very clear and so far did not managed to download anything from his site (but only tried twice).
Since my previous post I made some progress but am far from complete.
How did you continue?
Cas
Last edited by cas on 17 Jun 2008, 08:56, edited 1 time in total.
Re: Plugin development
I made lot of progress too.
Now I have created 2 plugins, in context of project management :
- One to manage action
- Second one to manage risk
Both ones used the plugin model of Mantis 1.2
The plugin about risk management is dependent on the first plugin (because risks can be scourge of actions). So risk and action are linked (even though, action don't need risk to work) and I made plugin for action re-usable. So my second plugin is based on the first one.
Next, with each plugin, I can add, update or consult items. (It means that I add tables in Mantis).
Recently, I also add a functionality to export action and risk to Excel.
Yet, I did not finish the development. I have to enhance what I have done, and I will add other functionalities.
What about your plugin?
Arenx
Now I have created 2 plugins, in context of project management :
- One to manage action
- Second one to manage risk
Both ones used the plugin model of Mantis 1.2
The plugin about risk management is dependent on the first plugin (because risks can be scourge of actions). So risk and action are linked (even though, action don't need risk to work) and I made plugin for action re-usable. So my second plugin is based on the first one.
Next, with each plugin, I can add, update or consult items. (It means that I add tables in Mantis).
Recently, I also add a functionality to export action and risk to Excel.
Yet, I did not finish the development. I have to enhance what I have done, and I will add other functionalities.
What about your plugin?
Arenx
Re: Plugin development
I have published one plugin called FAQ which you can find here:
http://www.mantisbt.org/bugs/view.php?id=9261
In addition i have almost finished a simple plugin that allows copying of an issue into your calendar or tasklist.
Also started work on a plugin to allow sending an issue from one instance to another. So a few to come.
Will you make your plugins general available ? Would be interested in those, certainly on the technical side but also on the functional side.
Did you figure out how to update and/or delete tables using this model?
Cas
http://www.mantisbt.org/bugs/view.php?id=9261
In addition i have almost finished a simple plugin that allows copying of an issue into your calendar or tasklist.
Also started work on a plugin to allow sending an issue from one instance to another. So a few to come.
Will you make your plugins general available ? Would be interested in those, certainly on the technical side but also on the functional side.
Did you figure out how to update and/or delete tables using this model?
Cas
Re: Plugin development
Maybe one day...Will you make your plugins general available ?
First, I need to finish them (I am still in development phase)
Second, I have not translate my plugins in english yet (I am french ; sorry for my english mistakes ).
The only solution i have found, is to "hard code" your SQL request.Did you figure out how to update and/or delete tables using this model?
Example :
Code: Select all
#general import of Mantis core
require_once($t_core_mantis."core.php");
#connexion to database
global $g_db;
#SQL execution
$g_db->Execute($request);
Re: Plugin development
Question is how you can trigger the hard-coded bit, anyway there is room to improve.
Re: Plugin development
Test this little plugin :
Your table will be removed at unistall time.
I hope this code will help you !
Code: Select all
<?php
#filename : Test.php
#it can work without this 2 lines below / there are here only to understand the process
$t_core_mantis =dirname(dirname(dirname( __FILE__ ))).DIRECTORY_SEPARATOR;
require_once($t_core_mantis."core.php");
class TestPlugin extends MantisPlugin {
function register() {
$this->name = 'Test';
$this->version = '1.0';
$this->requires = array('MantisCore' => '1.2.0');
}
#add 1 table for the example
public function schema() {
return array(
array( 'CreateTableSQL',
array( plugin_table( 'test' ), "
id I NOTNULL UNSIGNED AUTOINCREMENT PRIMARY
" )
)
);
}
public function uninstall() {
global $g_db;
#remove the table created before
$request='DROP TABLE '.plugin_table( 'test' );
$g_db->Execute($request);
#IMPORTANT : erase information about the plugin stored in Mantis
#Without this request, you cannot created the table again (if you re-install)
$request="DELETE FROM ". db_get_table('mantis_config_table'). " WHERE config_id = 'plugin_Test_schema'";
$g_db->Execute($request);
}
}
?>
I hope this code will help you !