ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 42 of file class.ilCaptchaUtil.php.

References $lng.

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

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

28  {
29  if(function_exists('imageftbbox'))
30  {
31  return true;
32  }
33  return false;
34  }
+ Here is the caller graph for this function:

◆ getSupportedContexts()

static ilCaptchaUtil::getSupportedContexts ( )
staticprivate
Returns
array

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

References $r.

92  {
93  if(null !== self::$context_map)
94  {
95  return self::$context_map;
96  }
97 
98  self::$context_map = array();
99 
100  $r = new ReflectionClass(new self());
101  $constants = $r->getConstants();
102  foreach($constants as $name => $value)
103  {
104  if(strpos($name, 'CONTEXT_') === 0)
105  {
106  self::$context_map[strtolower(substr($name, strlen('CONTEXT_')))] = $value;
107  }
108  }
109 
110  return self::$context_map;
111  }
$r

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: