Mixture of Core modification and plugin

More
3 months 1 week ago #158467 by AshleyBarnett
AshleyBarnett created the topic: Mixture of Core modification and plugin
In my previous question to LimeSurvey, I had inquired if it was possible to limit open survey results to 3 entries per IP per 24 hours . A few days later, I did fix it myself (as seen on my site ), but to do so, I both modified the core to add a PluginEvent and wrote a plugin. When plugin functionality exists, I prefer that to forking, but I didn't see another way, other than hoping for a feature request. Here is my core change from 2.67.3:
--- application/helpers/frontend_helper.php
+++ application/helpers/frontend_helper.php
@@ -1631,7 +1631,13 @@
             if($scenarios['tokenRequired']){
                 doFRender('/survey/frontpage/enterToken', $aEnterTokenData, false);
             } else {
-                App()->getController()->renderPartial('/survey/frontpage/enterCaptcha', $aEnterTokenData);
+                $event = new PluginEvent('beforeCaptcha');
+                $event->set('surveyId', $surveyid);
+                App()->getPluginManager()->dispatchEvent($event);
+
+                if(!$event->get('hideCaptcha')){
+                    App()->getController()->renderPartial('/survey/frontpage/enterCaptcha', $aEnterTokenData);
+                }
             }
 
             echo templatereplace(file_get_contents($sTemplateViewPath."endpage.pstpl"),array(),$redata,'frontend_helper[1645]');
I don't know that this is the best method, to simply hide the captcha rather than terminating the session. The plugin does give pretty error messages, but there seems like there should be some better way.

If you want to see the result, have at it . My site that pulls data from the poll isn't serious, so bogus entries won't cause a problem.

Is there a better way to approach? Should this diff be included for LimeSurvey 3?

Please Log in to join the conversation.

More
3 months 1 week ago #158476 by LouisGac
LouisGac replied the topic: Mixture of Core modification and plugin
In LS3 you'll can change/control the captcha from template files.
For now, in master, you can submit a PR to make core this event.

Please Log in to join the conversation.

More
3 months 1 week ago #158483 by AshleyBarnett
AshleyBarnett replied the topic: Mixture of Core modification and plugin
I'll need to pull LimeSurvey 3 and see how the template control works. The results of that would affect any PR.
Thanks.

Please Log in to join the conversation.

More
3 months 1 week ago #158491 by DenisChenu
DenisChenu replied the topic: Mixture of Core modification and plugin
I think with current version and event : i use directly beforeSurveyPage or beforeRegisterEvent (this one allow easily redirect and show own message).

See framagit.org/SondagePro-LimeSurvey-plugin/registerQuick and framagit.org/SondagePro-LimeSurvey-plugin/maintenanceMode for some example code.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!