Alternative Captcha Plugin

We were recently asked whether it was possible to use an alternative 'captcha' plugin instead of the standard Joomla supplied Google ReCaptcha plugin with our Issue Tracker component.

The reason for the request was because the site in question did not have any outside access, so was unable to connect to Google to check the captcha, hence the site need a captcha mechanism that would be totally self-contained. ( In the case of Google ReCaptcha the request is sent to verify.google.com for the captcha verification).

The details in this article are based upon work enabling the Easy Calc Check Plus (henceforth known as ECC+) plugin available upon the JED (Joomla Extensions Directory). This is not to say that other captcha plugins would or do not work, just that we only experimented with this particular plugin. We are assuming that the version of Issue Tracker is 1.6.10 and that the version of ECC+ is 3.1.1. Other versions will probably also work but have not been tested and any specified change line numbers will probably be different.

There were several steps involved in getting the plugin to work successfully with Issue Tracker and these are documented below:

1) Download the version of the ECC+ plugin from the JED and install.

Configure the ECC+ plugin.

Under the 'Additional Information' tab one needs to enable the 'Custom Call' option and set the value to yes.

If the ECC+ plugin is to be used for any other component then this would be a suitable time to also configure the plugin for those as well, which is beyond the scope of this article. IN our tests we only wanted to use the ECC+ plugin fo rIssue Tracker itself so disabled it for login, contact page etc.

Once all changes are made and saved then the plugin can be enabled.

2) Issue Tracker uses the captcha mechanism in the issue submission form when a user is not logged in, for additional checks upon the person submitting the issue. We first need to create a template override for issue form.

Copy the relevant files and we need to edit the copied edit_user_details.php file.

At the end of the file make the following changes:

Comment out the 'div' with the id of recaptcha and add the line:

<?php echo "{easycalccheckplus}" ?>

The resulting code (at the end of the file) will now look like the following:

<?php endforeach;
if ($parameters->get('captcha') == "recaptcha" ) {
JPluginHelper::importPlugin('captcha');
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onInit','recaptcha');
}
?>
<?php echo "{easycalccheckplus}" ?>
<!-- div id="recaptcha"></div -->

3) Ensure that the Issue Tracker component is not configured to use Google Recaptcha, otherwise our usage of ECC+ will not work.

4) We also need to make a small change to the template override edit.php file

In the issue tracker file components/com_issuetracker/views/form/tmpl/edit.php just after line 70 we add the line:

window.location = "yoururl";

where yoururl is a redirection url where you want to redirect your users when they cancel out of the issue creation. i.e.

window.location = "http://yoursite.com?option=com_content&id=1&view=article"

where in this example it is (usually) a home page. Change it to what ever you want for your site.

We choose suitable article ids so that when the user cancels out of the firm submission the redirection will be to a valid site page.

You could also comment out the line 70 itself, but this is not mandatory.
Joomla.submitform(task, document.getElementById('issue-form'));
by adding a double slash at the front.

Thus the final code would look something like this:

<script type="text/javascript">
Joomla.submitbutton = function(task) {
if (task == 'itissues.cancel') {
Joomla.submitform(task, document.getElementById('issue-form'));
window.location = "http://yoursite.com";
} else {

Aside: One could be more adventurous and select a page from the users previous browser history but they is something we will leave to anyone who wishes to try as an exercise.

5) Now we need to modify the ECC+ plugin slightly.

Go to the plugins/system/easycalccheckplus/ directory and edit the file easycalccheckplus.php

After line 593 (approx) which depending upon the specific version of ECC+ will be immediately after the setting of the $request variable at the start of the performChecks method.

[In ECC+ version 3.1.1 this is after line 891.]

We need to add the following few lines:

In the tested version it is immediately after the call to the performChecks routine and the setting of the $request variable.

// echo "<pre>";var_dump($request);echo "</pre>";
if ( array_key_exists('task',$request) && $request['task'] == "itissues.cancel") {
return true;
}
if ( $request['option'] == 'com_content' ) return true;
// die;

We have left the echo and die statements in the above, and commented them out in case one wishes to refine the redirection further. The above is simplistic but it illustrates the method.

There is an assumption that the home page article id is a '1', and you could extend the second test similar to the following if you want to be more specific (and perhaps should be).

if ( $request['option'] == 'com_content' && $request['id'] == 1 && $request['view' == 'article' ) return true;

These are required to prevent the following problems:

a) When the issue form is cancelled the ECC+ plugin is still invoked so the first few lines provide a 'positive' response back to the form submission. We are specifically checking the 'task' variable.

b) The second set of lines ensure that when we next redirect to a specific page on the site that the ECC+ checks also work correctly. We are assuming that the page we are redirecting to is not itself subject to an 'captcha' requirements, which is the usual case for the home page.

6) Now test out the changes. Go to the Issue Tracker create issue form on the site as a guest use and create an issue. Test by entering the issue without completing the captcha. Next test using a valid captcha response. Finally test 'cancelling' out of the issue creation and you should be redirected to the page specified in our settings above.

These tests were repeated against ECC+ version 3.1.1 and Issue Tracker 1.6.10 and worked flawlessly on 17th Feb 2016. Note that this is not something that we specifically recommend but it will work in the situation as described by the raiser of the question. Other captcha plugins are expected to work similarly although specific details will vary as to implementation.

Go To Top

The Macrotone Consulting Web site would like to use cookies to store information on your computer, to improve our website. Cookies used for the essential operation of the site have already been set. To find out more about the cookies we use and how to delete them, see our Privacy Policy.

I accept cookies from this site.