|
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_PersonalMessage_Module |
|
20
|
|
|
* |
|
21
|
|
|
* Adds Visual Verification controls to the PM page for those that need it. |
|
22
|
|
|
*/ |
|
23
|
|
|
class Verification_PersonalMessage_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
|
|
|
// Are controls required? |
|
33
|
|
|
if (!$user_info['is_admin'] && !empty($modSettings['pm_posts_verification']) && $user_info['posts'] < $modSettings['pm_posts_verification']) |
|
34
|
|
|
{ |
|
35
|
|
|
require_once(SUBSDIR . '/VerificationControls.class.php'); |
|
36
|
|
|
|
|
37
|
|
|
// Add the events to call for the verification |
|
38
|
|
|
return array( |
|
39
|
|
|
array('prepare_send_context', array('Verification_PersonalMessage_Module', 'prepare_send_context'), array()), |
|
40
|
|
|
array('before_sending', array('Verification_PersonalMessage_Module', 'before_sending'), array('post_errors')), |
|
41
|
|
|
); |
|
42
|
|
|
} |
|
43
|
|
|
else |
|
44
|
|
|
return array(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Prepare $context for the PM page. |
|
49
|
|
|
*/ |
|
50
|
|
|
public function prepare_send_context() |
|
51
|
|
|
{ |
|
52
|
|
|
global $context; |
|
53
|
|
|
|
|
54
|
|
|
// Verification control needed for this PM? |
|
55
|
|
|
$context['require_verification'] = true; |
|
56
|
|
|
|
|
57
|
|
|
$verificationOptions = array( |
|
58
|
|
|
'id' => 'pm', |
|
59
|
|
|
); |
|
60
|
|
|
$context['require_verification'] = create_control_verification($verificationOptions); |
|
61
|
|
|
$context['visual_verification_id'] = $verificationOptions['id']; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Checks the user passed the verifications on the PM page. |
|
66
|
|
|
* |
|
67
|
|
|
* @param \ErrorContext $post_errors |
|
|
|
|
|
|
68
|
|
|
* @throws Elk_Exception |
|
69
|
|
|
*/ |
|
70
|
|
|
public function before_sending($post_errors) |
|
71
|
|
|
{ |
|
72
|
|
|
global $context; |
|
73
|
|
|
|
|
74
|
|
|
if (isset($_REQUEST['xml'])) |
|
75
|
|
|
return; |
|
76
|
|
|
|
|
77
|
|
|
// Wrong verification code? |
|
78
|
|
|
$verificationOptions = array( |
|
79
|
|
|
'id' => 'pm', |
|
80
|
|
|
); |
|
81
|
|
|
$context['require_verification'] = create_control_verification($verificationOptions, true); |
|
82
|
|
|
|
|
83
|
|
|
if (is_array($context['require_verification'])) |
|
84
|
|
|
{ |
|
85
|
|
|
foreach ($context['require_verification'] as $error) |
|
86
|
|
|
$post_errors->addError($error); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths