Help for a newb mantis plugin writer

General discussion about MantisBT Plugins

Moderators: Developer, Contributor

Post Reply
stigzler
Posts: 10
Joined: 18 Mar 2019, 23:36

Help for a newb mantis plugin writer

Post by stigzler »

Hi all. I'm looking to write a plugin for mantis to sync it with phpbb. I'm looking to log in through phpbb and when go to mantisbt, mantis detects this and doesn't ask for a login - using phpbb's auth rather than it's own (although I'm guessing there needs to be some catch for 'new' users to mantisbt to create a new account). I've sought some advice from the writer of a phpbb plugin writer, and he advised:
I took a quick look at the MantisBT documentation, and they have a sample plugin that does authorization. Such a plugin can be modified to read the phpBB cookies and validate the user with a couple simple queries to the phpBB database. That would seem to be the best way to proceed since it eliminates the need to write both a WP plugin and phpBB extension, and there would be no need to deal with passwords/registration in MantisBT.

Since I know nothing about MantisBT, you would be on your own with writing a MantisBT plugin. The phpBB code in the session_begin() and session_create() functions in the phpbb/session.php file contains most of what you will need.
I normally code in .net - although I have done a bit of php coding (and know how to interface with mysql through php). A couple of questions:
  • Does anyone know where this example Authorisation plugin is?
  • Any tips for a newb(ish) php/mantis plugin writer on how to achieve the above?
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Help for a newb mantis plugin writer

Post by atrol »

stigzler wrote: 13 Jun 2020, 09:49Does anyone know where this example Authorisation plugin is?
https://github.com/mantisbt-plugins/SampleAuth
Please use Search before posting and read the Manual
stigzler
Posts: 10
Joined: 18 Mar 2019, 23:36

Re: Help for a newb mantis plugin writer

Post by stigzler »

Thanks atrol. I did have a look at this, but couldn't figure a way to get phpbb registrations registering in Mantis + also how to glean the phpbb logged in user for the auth plugin. This is all a little beyond my capabilities, sadly. Thanks for the reply though.
Starbuck
Posts: 219
Joined: 14 Feb 2006, 02:53
Location: USA
Contact:

Re: Help for a newb mantis plugin writer

Post by Starbuck »

Hey @stigzler, I just wanted to comment that you're not alone. I haven't looked specifically at a phpBB interface but I've had it in my mind to do others like it. While I'm competent to work on existing PHP code, I don't have same confidence as I do when working with C#, Java, or other languages.

Working with Mantis, or any FOSS like this, just takes time and patience. I think the best way to approach projects like this is to break everything down into very small functions, and control it all from higher-level functions. Then you can pull in sample code and ask for help on very small pieces rather than feeling stuck on huge concepts. For example, rather than this

Code: Select all

success = doSomethingReallyBig(p1,p2,p3,p4,p5,p6);
try this

Code: Select all

p1 = p1get();
if (!p1IsOK(p1)) return;
p2 = p2get(p1);
if (!p2IsOK(p2)) return;
p3 = "foo";
...
workingResult = new WorkingResult() ; // class instance with project-level scope that gets built in pieces
if(!finalCheck(p1,p2,p3,p4,p5,p6)) return;
success = doSomethingSimple1(p1,p2);
if(!success) return;
success = doSomethingSimple2(p2,p3);
if(!success) return;
success = putSomePiecesTogether1(p3,p4,p5);
if(!success) return;
success = finalTouches(workingResult);
if(!success) return;
// Hey, we have a workingResult! Success!
return;
...
Keep everything small and modular. Then questions don't need to be "how do I change the world" but more like "how do I get this one data element".
The above code is really sloppy. Minimize global variables. Use OOP as normal. PHP is very similar to other languages in terms of OOP these days. Use try/catch. Create small focused classes to manage state rather than dealing with a lot of little vars like p1, p2, etc.

Give yourself a lot of space in your code to do things verbosely - don't try to be concise. As you know, that comes later. Comment the hell out of your code, including adding the sources of your various insights. Then FOSS what you're doing in GitHub so that others can benefit and contribute. You'll get a lot more feedback on specific code challenges if you have code that you can point to - abstract requests like we frequently see in forums like this often receive equally abstract responses that don't help much - the quality of responses is usually commensurate with the quality of the questions. Track your problems and detailed resolutions in Issues. You and others will look back at the tickets later to understand why things are done the way they are.

I wish I could participate in projects like this. I have a LOT of things that I want to do with Mantis plugins but I lack the time. I've only thought about how I would approach it and I'm sharing that here. HTH
If you want Mantis to work differently, use or create a plugin. Visit the Plugins forums.
Ask developers to create a plugin that you need - and motivate them to help you!
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Help for a newb mantis plugin writer

Post by cas »

This plugin is using the internal userid from Mantis for verification ( so not the username). For your purpose this is not a true fit.
Not a big issue, the plugin can be adjusted to work based on the username only. All it takes is in the function auth_user_flags to retrieve the user-id from the DB and take it from there.
This is a fairly small change :mrgreen:
Post Reply