Developping a plugin used for user management

Get help from other users here.

Moderators: Contributor, Developer

Developping a plugin used for user management

Postby Beniko_J » Nov 20, 2017 9:52 pm

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
Beniko_J
 
Posts: 2
Joined: Nov 20, 2017 8:59 pm

Re: Developping a plugin used for user management

Postby rkarmann » Dec 12, 2017 3:22 am

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 :)
rkarmann
 
Posts: 22
Joined: Nov 24, 2017 5:00 am
Location: Lille, France

Re: Developping a plugin used for user management

Postby Beniko_J » Dec 13, 2017 3:57 am

Your reply is very helpful. Thank you very much! :D
Beniko_J
 
Posts: 2
Joined: Nov 20, 2017 8:59 pm


Return to Help

Who is online

Users browsing this forum: Bing [Bot] and 26 guests