- Posts: 5
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Mixture of Core modification and plugin
- AshleyBarnett
- Topic Author
- Offline
- New Member
Less
More
6 years 6 months ago #158467
by AshleyBarnett
Mixture of Core modification and plugin was created by AshleyBarnett
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:
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?
Code:
--- 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]');
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?
The topic has been locked.
- LouisGac
- Visitor
6 years 6 months ago #158476
by LouisGac
Replied by LouisGac on 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.
For now, in master, you can submit a PR to make core this event.
The topic has been locked.
- AshleyBarnett
- Topic Author
- Offline
- New Member
Less
More
- Posts: 5
- Thank you received: 0
6 years 6 months ago #158483
by AshleyBarnett
Replied by AshleyBarnett on 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.
Thanks.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13907
- Thank you received: 2546
6 years 6 months ago #158491
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on 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.
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 , plugin development .
I don't answer to private message.
The topic has been locked.