How to change Captcha style

Permalink 1 user found helpful
Hi,

I found the Captcha style is defined in /concrete/core/models/system/captcha/types/securimage/controller.php.

But no matter how I change the file variables, nothing changes on site. Am I missing something? I used to simply override the 3rd party library a few versions before. But now it all changed and I can't figure out how to change the Captcha style.

If I copy /concrete/core/models/system/captcha/types/securimage/controller.php to MYSITE/models/system/captcha/types/securimage/controller.php and change it there, it gives me an error: "Fatal error: Class 'SecurimageSystemCaptchaTypeController' not found in /srv/www/htdocs/MYSITE/concrete/core/models/system/captcha/library.php on line 129".

Please help. Thank you.

linuxoid
 
shahroq replied on at Permalink Reply
shahroq
You cant override core items. for changing the captcha setting:
1- copy '\concrete\models\system\captcha\types\securimage\controller.php' to '\models\system\captcha\types\securimage\controller.php' [its an empty class]
2- now, copy construct method from '\concrete\core\models\system\captcha\types\securimage' to newly added file, inside the class, then change settings at this new file.
your code at the new file should look like this:
class SecurimageSystemCaptchaTypeController extends Concrete5_Model_SecurimageSystemCaptchaTypeController {
   public function __construct() {
      Loader::library("3rdparty/securimage/securimage");
      $this->securimage = new Securimage();
      $this->securimage->image_width   = 190;
      $this->securimage->image_height  = 60;
      $this->securimage->image_bg_color = new Securimage_Color(227, 218, 237);
      $this->securimage->line_color = new Securimage_Color(51, 51, 51);
      $this->securimage->num_lines = 5;
      $this->securimage->use_multi_text   = true;
      $this->securimage->multi_text_color = array(
         new Securimage_Color(184, 4, 50),
         new Securimage_Color(12, 67, 157),
         new Securimage_Color(244, 49, 11)
         );
linuxoid replied on at Permalink Reply
linuxoid
Thank you very much. It worked! Thanks a lot!

Could you please tell me how this can be done automatically when installing a package? That is, I am writing a package which installs a block. This works fine. But I also need to change the Captcha style when installing the block. How can I copy the Captcha controller into the Models folder during the block installation? Thank you.
shahroq replied on at Permalink Reply
shahroq
I'm not sure about this one, but maybe you can extend the class in your package.