Passed
Push — development ( 080d06...0379dc )
by Spuds
01:04 queued 23s
created

template_Emailmoderator_init()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 35
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 35
rs 10
1
<?php
2
3
/**
4
 * @package   ElkArte Forum
5
 * @copyright ElkArte Forum contributors
6
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
7
 *
8
 * This file contains code covered by:
9
 * copyright: 2011 Simple Machines (http://www.simplemachines.org)
10
 *
11
 * @version 2.0 dev
12
 *
13
 */
14
15
/**
16
 * The report sub-template needs some error stuff
17
 */
18
function template_Emailmoderator_init()
19
{
20
	global $context, $txt;
21
22
	 if (empty($context['sub_template'])) {
23
		 return;
24
	 }
25
26
	 if ($context['sub_template'] !== 'report') {
27
		 return;
28
	 }
29
30
	 theme()->addInlineJavascript('
31
		error_txts[\'post_too_long\'] = ' . JavaScriptEscape($txt['error_post_too_long']) . ';
32
33
		function checkReportForm()
34
		{
35
			let checkID = \'report_comment\',
36
				comment = document.getElementById(checkID).value.trim();
37
		
38
			let error = new errorbox_handler({
39
				error_box_id: \'report_error\',
40
				error_code: \'post_too_long\',
41
			});
42
		
43
			error.checkErrors(comment.length > 254);
44
			if (comment.length > 254)
45
			{
46
				document.getElementById(checkID).setAttribute(\'onkeyup\', \'checkReportForm()\');
47
				return false;
48
			}
49
			
50
			return true;
51
		}
52
		', true);
53
}
54
55
/**
56
 * The report sub template gets shown from:
57
 *  '?action=reporttm;topic=##.##;msg=##'
58
 * It should submit to:
59
 *  '?action=reporttm;topic=' . $context['current_topic'] . '.' . $context['start']
60
 *
61
 * It only needs to send the following fields:
62
 *  comment: an additional comment to give the moderator.
63
 *  sessionDI: $context['session_id'].
64
 */
65
function template_report()
66
{
67
	global $context, $txt, $scripturl;
68
69
	echo '
70
	<div id="report_topic">
71
		<form action="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $context['start'], '" method="post" accept-charset="UTF-8">
72
			<h2 class="category_header">', $txt['report_to_mod'], '</h2>
73
			<div class="content">';
74
75
	template_show_error('report_error');
76
77
	echo '
78
				<p class="warningbox">', $txt['report_to_mod_func'], '</p>
79
				<br />
80
				<dl class="settings" id="report_post">';
81
82
	if ($context['user']['is_guest'])
83
	{
84
		echo '
85
					<dt>
86
						<label for="email_address">', $txt['email'], '</label>:
87
					</dt>
88
					<dd>
89
						<input type="text" id="email_address" name="email" value="', $context['email_address'], '" size="25" maxlength="255" />
90
					</dd>';
91
	}
92
93
	echo '
94
					<dt>
95
						<label for="report_comment">', $txt['enter_comment'], '</label>:
96
					</dt>
97
					<dd>
98
						<textarea id="report_comment" name="comment">', $context['comment_body'], '</textarea>
99
					</dd>';
100
101
	if (!empty($context['require_verification']))
102
	{
103
		template_verification_controls($context['visual_verification_id'], '
104
					<dt>
105
						' . $txt['verification'] . ':
106
					</dt>
107
					<dd>
108
						', '
109
					</dd>');
110
	}
111
112
	echo '
113
				</dl>
114
				<div class="submitbutton">
115
					<input type="hidden" name="msg" value="' . $context['message_id'] . '" />
116
					<input type="submit" name="save" value="', $txt['rtm10'], '" onclick="return checkReportForm();" />
117
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
118
				</div>
119
			</div>
120
		</form>
121
	</div>';
122
}
123