-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the point module type #486
base: dev
Are you sure you want to change the base?
Conversation
Looks good. Since this uses a different structure to other plugin types we'll have to consider the best approach. I'd like to move all the plugins to a more standard format like you've done here, but it may have to wait until the next version when we can use namespaces. I don't want to have a mess of completely different plugin formats, nor have people start creating plugins in one format only to change it in the next version. But I do like the general idea of having an interface for the plugin type, that can certainly save a lot of I've also been wondering if many of the plugin types can be replaced by a more generic Event plugin system. For example instead of filter modules, an event is fired after a question is submitted (but before it's saved in the database), and an event plugin could intercept that event. Or for a CAPTCHA module, an event fires when we're about to create the captcha, allowing a plugin to intercept. |
I might be missing something here but I think there shouldn't be any issue with that. I mean, the only difference between any other module and this one, from a plugin developer perspective, is extending/implementing the abstract class/interface. Extending the abstract class is optional. Implementing the interface can still be avoided as the core will just call a method in an object, no matter what class it is, as long as it has the method the call should succeed. This means that in order to implement this module, developers just need a class with 2 methods defined, which is exactly the same as modules such as the Even if the idea is to change how plugins work in a near future, I don't think this should be an issue at all and the plugin will generate the same impact as if it worked in the old-way. Furthermore, not documenting the abstract class or the interface will allow them to be renamed without any impact at all.
I understand this comment is more related to the core rather than plugin developers and it is a good point but I don't think this is a showstopper either. If you consider it is, then, I think it is just a matter of removing the interface and the abstract class. Then, the documentation will state that both methods are required (the same as the
It is true the interface will save those
This might be a bit unrelated to the PR but here are my thoughts. I think so. They are just hooks. I haven't gone through each method of each module but most likely there are two type of method calls: unidirectional and bidirectional. The former are just methods that get notified and don't interfere in any way with the processing (just like For example, in a However, I'd reconsider rewriting how that would work: having a single entrance for all events doesn't seem to be a good idea and forces each Again, if a similar behaviour can be applied to other module types, I think it would require them to be analyzed one by one. |
Hey @svivian. When you have a chance, can you take a look at this again? Many users in the Q2A forum are looking for point exchanging and having this implemented will considerably ease that or even make it possible. I'm open to adapt the code to whatever style you consider appropriate. If the idea is to eventually add this to Q2A 1.9, I can adapt the code to support PHP 5.3 features. BTW, although I believe this kind of feature should be added to the Would it make sense to release this as a test feature to receive feedback from developers and improve? Then, in that case, no commitments will be made regarding the interface. The rationale for this request is that this feature is not for the end user but rather for developers. So in order to see the result of the feature time will have to pass for developers to update their plugins. The more time it passes, the more time will be needed to adapt the code to support the interface updates that might come in the future. So the more final the interface, the better. Just my 2 cents! |
This should be a simple implementation to a new module type (
point
) that would allow plugins to change user points.The module is a class that knows how to calculate points that should be changed by the plugin. It needs to be able to update points for a single user (usually the logged in user) and for a set of users (in order to be able to recalculate points).
Plugin developers will need to manually call the
qa_db_points_update_ifuser()
function in order for point recalculation to be run (after the plugin performs some action that would require points to change for a user).Location of the abstract classes and interfaces is unclear to me so I added them in the Q2A/Plugin pseudo-namespace.
Note I tried to focus on simplicity for the plugin developer so I decided to abstract them from writing core-related SQL so they just receive known user ids an operate on their own to fetch the points. This ads a little extra work for the core but I think it is simpler this way and also more secure than allowing plugin developers to directly inject SQL inside a dynamic query.
This kind of module should be quite useful for already existing plugins and should open a door for many new kind of plugins. It also should be the answer to a lot of questions in the Q2A forum that request a way to "pay in points" for a given action.