Developping a plugin used for user management

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
Beniko_J
Posts: 2
Joined: 21 Nov 2017, 01:59

Developping a plugin used for user management

Post by Beniko_J »

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. :D
rkarmann
Posts: 66
Joined: 24 Nov 2017, 10:00
Location: Lille, France

Re: Developping a plugin used for user management

Post by rkarmann »

Hi Beniko_J,
Beniko_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).
-> You should have a look on this plugin structure, particullary function schema() in the plugin's core : https://github.com/mantisbt-plugins/Announce
This is the best example I have found searching for plugin's database schema.
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?
-> 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)

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.
Beniko_J
Posts: 2
Joined: 21 Nov 2017, 01:59

Re: Developping a plugin used for user management

Post by Beniko_J »

Your reply is very helpful. Thank you very much! :D
Post Reply