ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCaptchaUtil Class Reference

Captcha util. More...

+ Collaboration diagram for ilCaptchaUtil:

Static Public Member Functions

static checkFreetype ()
 Check whether captcha support is active. More...
 
static __callStatic ($name, array $arguments=array())
 

Data Fields

const CONTEXT_FORUM = 'frm'
 
const CONTEXT_LOGIN = 'auth'
 
const CONTEXT_REGISTRATION = 'reg'
 
const CONTEXT_WIKI = 'wiki'
 

Static Protected Attributes

static $context_map
 

Static Private Member Functions

static getSupportedContexts ()
 

Detailed Description

Captcha util.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 11 of file class.ilCaptchaUtil.php.

Member Function Documentation

◆ __callStatic()

static ilCaptchaUtil::__callStatic (   $name,
array  $arguments = array() 
)
static
Parameters
string$name
array$arguments
Returns
bool
Exceptions
BadMethodCallException

Definition at line 44 of file class.ilCaptchaUtil.php.

References $lng.

45  {
46  if(
47  strpos($name, 'isActiveFor') === 0 ||
48  strpos($name, 'setActiveFor') === 0
49  )
50  {
51  $settings = new ilSetting('cptch');
52  $supported_contexts = self::getSupportedContexts();
53  $method_parts = explode('_', strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name)));
54  $requested_context = strtolower($method_parts[count($method_parts) - 1]);
55  if(!isset($requested_context, self::$context_map))
56  {
57  throw new BadMethodCallException('Method ' . $name . ' called for a non existing context.');
58  }
59 
60  if('set' == $method_parts[0])
61  {
62  $settings->set('activate_captcha_anonym_' . $supported_contexts[$requested_context], (int)$arguments[0]);
63  return;
64  }
65  else
66  {
67  return self::checkFreetype() && (bool)$settings->get('activate_captcha_anonym_' . $supported_contexts[$requested_context], false);
68  }
69  }
70  else
71  {
72  throw new BadMethodCallException('Call to an undefined static method ' . $name . ' in class ' . __CLASS__ . '.');
73  }
74  }
ILIAS Setting Class.

◆ checkFreetype()

static ilCaptchaUtil::checkFreetype ( )
static

Check whether captcha support is active.

Returns
bool

Definition at line 27 of file class.ilCaptchaUtil.php.

References ilLoggerFactory\getLogger().

Referenced by ilObjForumAdministrationGUI\getSettingsForm(), ilObjAuthSettingsGUI\initAuthModeDetermination(), ilRegistrationSettingsGUI\initForm(), and ilObjWikiSettingsGUI\initForm().

28  {
29  if(function_exists('imageftbbox'))
30  {
31  ilLoggerFactory::getLogger('auth')->debug('Function imageftbox is available.');
32  return true;
33  }
34  ilLoggerFactory::getLogger('auth')->debug('Function imageftbox is not available.');
35  return false;
36  }
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSupportedContexts()

static ilCaptchaUtil::getSupportedContexts ( )
staticprivate
Returns
array

Definition at line 93 of file class.ilCaptchaUtil.php.

References $r, and array.

94  {
95  if(null !== self::$context_map)
96  {
97  return self::$context_map;
98  }
99 
100  self::$context_map = array();
101 
102  $r = new ReflectionClass(new self());
103  $constants = $r->getConstants();
104  foreach($constants as $name => $value)
105  {
106  if(strpos($name, 'CONTEXT_') === 0)
107  {
108  self::$context_map[strtolower(substr($name, strlen('CONTEXT_')))] = $value;
109  }
110  }
111 
112  return self::$context_map;
113  }
$r
Definition: example_031.php:79
Create styles array
The data for the language used.

Field Documentation

◆ $context_map

ilCaptchaUtil::$context_map
staticprotected

Definition at line 21 of file class.ilCaptchaUtil.php.

◆ CONTEXT_FORUM

const ilCaptchaUtil::CONTEXT_FORUM = 'frm'

Definition at line 13 of file class.ilCaptchaUtil.php.

◆ CONTEXT_LOGIN

const ilCaptchaUtil::CONTEXT_LOGIN = 'auth'

Definition at line 14 of file class.ilCaptchaUtil.php.

◆ CONTEXT_REGISTRATION

const ilCaptchaUtil::CONTEXT_REGISTRATION = 'reg'

Definition at line 15 of file class.ilCaptchaUtil.php.

◆ CONTEXT_WIKI

const ilCaptchaUtil::CONTEXT_WIKI = 'wiki'

Definition at line 16 of file class.ilCaptchaUtil.php.


The documentation for this class was generated from the following file: