Completed
Pull Request — master (#3325)
by Emanuele
11:19
created

Verification_Display_Module   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0
wmc 8
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A topicinfo() 0 11 1
B hooks() 0 12 7
1
<?php
2
3
/**
4
 *
5
 *
6
 * @name      ElkArte Forum
7
 * @copyright ElkArte Forum contributors
8
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
9
 *
10
 * This file contains code covered by:
11
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
12
 * license:  	BSD, See included LICENSE.TXT for terms and conditions.
13
 *
14
 * @version 1.1
15
 *
16
 */
17
18
/**
19
 * Class Verification_Display_Module
20
 *
21
 * Adding Visual Verification event to Quick Reply area (display.controller)
22
 */
23
class Verification_Display_Module extends ElkArte\sources\modules\Abstract_Module
24
{
25
	/**
26
	 * {@inheritdoc }
27
	 */
28
	public static function hooks(\Event_Manager $eventsManager)
29
	{
30
		global $user_info, $modSettings;
31
32
		if (!$user_info['is_admin'] && !$user_info['is_moderator'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)))
33
		{
34
			return array(
35
				array('topicinfo', array('Verification_Display_Module', 'topicinfo'), array()),
36
			);
37
		}
38
		else
39
			return array();
40
	}
41
42
	/**
43
	 * Prepare $context for the quick reply.
44
	 */
45
	public function topicinfo()
46
	{
47
		global $context;
48
49
		// Do we need to show the visual verification image?
50
		require_once(SUBSDIR . '/VerificationControls.class.php');
51
		$verificationOptions = array(
52
			'id' => 'post',
53
		);
54
		$context['require_verification'] = create_control_verification($verificationOptions);
55
		$context['visual_verification_id'] = $verificationOptions['id'];
56
	}
57
}