Userdata plugin

General discussion about MantisBT Plugins

Moderators: Developer, Contributor

Post Reply
cas
Posts: 1641
Joined: 11 Mar 2006, 16:08
Contact:

Userdata plugin

Post by cas »

This plugin allows to extend the user definition with additional fields. You can name them yourselves and they become visible when viewing an issue.
Look forward to have your commets :mrgreen:
Attachments
Userdata201.zip
(128.07 KiB) Downloaded 2887 times
mohamedh
Posts: 15
Joined: 30 Apr 2015, 09:07

Re: Userdata plugin

Post by mohamedh »

Hi

Thanks for sharing this plugin

are the new fields supposed to appear in view_user_page?

Judging by the fact you posted your plugin here https://www.mantisbt.org/bugs/view.php?id=5278

I would assume it allows for custom user fields, but so far what I am seeing is that it is something completely different from Heiko's Plugin.

Heiko's plugin:
- user has more fields under his account settings/profile.
- the user can modify his own custom fields.
- view_user_page.php?id=XX shows the customs fields

have a look at the screenshot posted in OP where you can see "custom field 1"
https://www.mantisbt.org/bugs/file_down ... 9&type=bug

This is what a custom user field means. It means custom fields for the user profile. For example, adding a user's team name, gender, age, address, etc

What your plugin seems to do IIUC from my quick trial is to add custom data per user account on issues.
Do you mind providing some context?
What kind of use case do you have in mind exactly with your plugin? what is it exactly that you are trying to achieve by showing custom user data on the issue page? What is the added benefit of associating them with the reporter? why not simply create new fields in the issue form and allow the user to fill in whatever they want (granted if it is the same value every time, you will be asking the user to refill the fields with the same data every time)? I am assuming this for example to add some client_id? or some internal identifiers that you do not want the user to mess with? Perhaps, if that's the case it will be worth clearing up the confusion and adding more details in the main post especially since you posted it in a reply to issue 5278 while in reality, it is not similar at all to what we're discussing there.


As for the plugin itself, there are a lot of warnings thrown

Code: Select all

#view.php
Deprecated functionality: "db_query_bound()", use "db_query()" instead. (in C:\xampp\htdocs\mantis\plugins\Userdata\Userdata.php line 33)
Deprecated functionality: "db_query_bound()", use "db_query()" instead. (in C:\xampp\htdocs\mantis\plugins\Userdata\pages\showdata.php line 36)
Deprecated functionality: "db_query_bound()", use "db_query()" instead. (in C:\xampp\htdocs\mantis\plugins\Userdata\pages\showdata.php line 44)
Deprecated functionality: "helper_alternate_class", use "CSS" instead. (in C:\xampp\htdocs\mantis\plugins\Userdata\pages\showdata.php line 57)

#/plugin.php?page=Userdata/userdata_definition
Deprecated functionality: "db_query_bound()", use "db_query()" instead. (in C:\xampp\htdocs\mantis\plugins\Userdata\pages\userdata_definition.php line 71)
Deprecated functionality: "helper_alternate_class", use "CSS" instead. (in C:\xampp\htdocs\mantis\plugins\Userdata\pages\userdata_definition.php line 76)

#manage_user_edit_page.php?user_id=2
Deprecated functionality: "db_query_bound()", use "db_query()" instead. (in C:\xampp\htdocs\mantis\plugins\Userdata\pages\editdata.php line 34)
Deprecated functionality: "db_query_bound()", use "db_query()" instead. (in C:\xampp\htdocs\mantis\plugins\Userdata\pages\editdata.php line 42)
Deprecated functionality: "helper_alternate_class", use "CSS" instead. (in C:\xampp\htdocs\mantis\plugins\Userdata\pages\editdata.php line 50)

cas
Posts: 1641
Joined: 11 Mar 2006, 16:08
Contact:

Re: Userdata plugin

Post by cas »

Hi,
I did not had the intention to mimic Heiko's changes (would not call that a plugin even). My point is that with a true plugin, one can achieve most of the time what you are looking for. Same here.
My plugin gives the ability to add, up to 100, fields to the user account which indeed are visible, if you like, as another little form on the issues screen (this you can switch off). But it can be handy is you need a phone number or email address.
In the current setup, I have not yet made it visible under My Account or on the View_user_page but that is simple adjustment. I would even suggest that @ definition time one can define the field to be listed on the My Account page (to be edited by the user in person) or not.
Remember this was the initial version so happy to have the suggestions for improvements.
Looks like I just need to tackle the 3 mentioned items and it is pretty much covering all the differences.
The reported errors have been removed already :D
cas
Posts: 1641
Joined: 11 Mar 2006, 16:08
Contact:

Re: Userdata plugin

Post by cas »

Updated version where the warnings are gone and the remarks from Mohamedh have been taken care of.
In addition data can be maintained under My Account and data is visible on the view_user_page.
Attachments
Userdata202.zip
(125.65 KiB) Downloaded 2978 times
mohamedh
Posts: 15
Joined: 30 Apr 2015, 09:07

Re: Userdata plugin

Post by mohamedh »

It is just that I was mistaken and thought it would achieve a similar behavior because you didn't particularly say how your plugin did things.

> I did not had the intention to mimic Heiko's changes (would not call that a plugin even).

agreed, and you definitely don't have/need to mimic Heiko's changes. I don't think (based on my limited knowledge) that what we see there is achievable anyway without modifying core files view_user_page.php and possibly account_page.php.

Using the event "EVENT_MENU_ACCOUNT", maybe the extra fields can be added to a custom page as an extra tab in the menu to avoid modifying core account_page.php. On the other side, I don't think there is a workaround to modifying view_user_page since I don't see any events related to that page in the manual, if core at least offers an event for that page that takes an HTML array, then what I am looking to achieve can be easily and painlessly done via plugins.

If I end up deploying this in prod in the upcoming weeks, I may happily try to give each user the ability to modify his own customs fields under his own account and I will share the modifications here. (see screenshot, experimented quickly my idea: added new page, and I did `include()` for your form in that page)



Your plugin is indeed not similar in behavior but is a viable replacement and has many use cases and it is probably as good as it gets without modifying core files. I can see cases where it can be useful, as you mentioned for some client-related info that you may need to see on the issue page.

I remember back then I did more changes Heiko's work to allow for what I would call "meta-data" of the account, part of the profile characteristics, (sort of my main use-case) where showing such specific info in the ticket is not exactly relevant but showing them in view_user_page makes more sense in our case.

Anyway, thanks for taking one for the team and spending your time on this. I appreciate the quick response and the modifications!
Attachments
cas.PNG
cas.PNG (10.41 KiB) Viewed 16587 times
cas
Posts: 1641
Joined: 11 Mar 2006, 16:08
Contact:

Re: Userdata plugin

Post by cas »

Hi Mohamedh,
changes to core files, as described in the install.txt, are only adding the event lines where they are missing so that means a minimal change.
I do like your suggestion on using the extra tab via "EVENT_MENU_ACCOUNT" (please share the code you used and I will add it in)
cas
Posts: 1641
Joined: 11 Mar 2006, 16:08
Contact:

Re: Userdata plugin

Post by cas »

Here is version 2.03 which support the account_page without any changes :D
Attachments
Userdata203.zip
(127.35 KiB) Downloaded 2880 times
mohamedh
Posts: 15
Joined: 30 Apr 2015, 09:07

Re: Userdata plugin

Post by mohamedh »

> (please share the code you used and I will add it in)

I am never so sure of what I do due to my lack of experience which is why I didn't share them immediately when I first posted (I am sure your implementation is cleaner). I see you did already add it and released v203! Thanks for the new release

Good job!

Maybe for the next version you may want to consider adding a 3rd line in Userdata/config to ask "allow the user to enter his own custom fields yes|no".
and depending on this you show the extra tab or not. No rush, not an option I am gonna use personally, but just an idea I am suggesting :D

p.s: you may want to put a small ko-fi link or something. I think many people would happily chip in to encourage you :wink:
cas
Posts: 1641
Joined: 11 Mar 2006, 16:08
Contact:

Re: Userdata plugin

Post by cas »

Adding a third line in config, is really simple so added that.
Should the user have control over all fields or should the plugin support also fields for the administrator?

I will have a look @ ko-fi but donations can always be made using pay-pal:mrgreen:
Attachments
Userdata204.zip
(127.45 KiB) Downloaded 3014 times
cas
Posts: 1641
Joined: 11 Mar 2006, 16:08
Contact:

Re: Userdata plugin

Post by cas »

For now final version (2.05), changes compared to 2.04 are:
- 2 additional config options
- for each field it can be defined whether or not the user may maintain it.
Attachments
Userdata205.zip
(179.77 KiB) Downloaded 2887 times
Post Reply