I want to develop a plugin to automatically manage enabled users in MantisBT database at set intervals. According some rules like whiteList and blackList(they will change sometimes), user's enabled column in mantis_user_table will be set to 0 or remain 1. If it is set to 0, there will be an automatically generated issue assigned to administrator of MantisBT and the monitor of it will be set to the user who are blocked, in order to keep him/her informed.
Now i have some questions as listed below:
1. How to create the database corresponded to the plugin(in order to store whiteList and blackList)? Is there any api function in MantisBT that can help do this?
2. How to get whiteList and blackList from the created plugin database? Is db_query() function in database_api.php enough?
3. After the flow, if enabled column is set to 0, could I just create a BugData instance, then set all the fileds, then call create() function to create an issue? And how to set the monitor of this issue(because there seems to be no filed about monitor in a BugData instance).
4. In the process of setting fields of BugData instance, how to get reporter_id and reporter_name(although it seems that reporter name is not needed in the setting, title of notification email is expected to include the reporter's name)? By querying the database or is there another way to do this?
It is my first time to develop a MantisBT plugin, so there may be some things i haven't considered yet. Could anyone please give me any ideas or advice? Thanks very much.
Developping a plugin used for user management
Moderators: Developer, Contributor
Re: Developping a plugin used for user management
Hi Beniko_J,
This is the best example I have found searching for plugin's database schema.
Hope you'll find this helpfull
-> You should have a look on this plugin structure, particullary function schema() in the plugin's core : https://github.com/mantisbt-plugins/AnnounceBeniko_J wrote: 1. How to create the database corresponded to the plugin(in order to store whiteList and blackList)? Is there any api function in MantisBT that can help do this?
2. How to get whiteList and blackList from the created plugin database? Is db_query() function in database_api.php enough?
3. After the flow, if enabled column is set to 0, could I just create a BugData instance, then set all the fileds, then call create() function to create an issue? And how to set the monitor of this issue(because there seems to be no filed about monitor in a BugData instance).
This is the best example I have found searching for plugin's database schema.
-> Take a look at string_api and helper_api in MantisBT core apis, many functions could help you in retrieving project_id or user_id. Then you will be able to retrieve project_name with such function as get_project_name($t_project_id)Beniko_J wrote:4. In the process of setting fields of BugData instance, how to get reporter_id and reporter_name(although it seems that reporter name is not needed in the setting, title of notification email is expected to include the reporter's name)? By querying the database or is there another way to do this?
Hope you'll find this helpfull
Currently working on a wiki-based plugin for MantisBT 2.X. If you'd like to test it, contact me or see the plugin section.
Re: Developping a plugin used for user management
Your reply is very helpful. Thank you very much!