Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 70
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
acp_contact
0.00% covered (danger)
0.00%
0 / 68
0.00% covered (danger)
0.00%
0 / 1
90
0.00% covered (danger)
0.00%
0 / 1
 main
0.00% covered (danger)
0.00%
0 / 68
0.00% covered (danger)
0.00%
0 / 1
90
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14/**
15* @ignore
16*/
17if (!defined('IN_PHPBB'))
18{
19    exit;
20}
21
22/**
23* @package acp
24*/
25class acp_contact
26{
27    public $u_action;
28
29    public function main($id, $mode)
30    {
31        global $user, $request, $template;
32        global $config, $phpbb_root_path, $phpEx, $phpbb_container;
33
34        $user->add_lang(array('acp/board', 'posting'));
35
36        $this->tpl_name = 'acp_contact';
37        $this->page_title = 'ACP_CONTACT_SETTINGS';
38        $form_name = 'acp_contact';
39        add_form_key($form_name);
40        $error = '';
41
42        if (!function_exists('display_custom_bbcodes'))
43        {
44            include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
45        }
46        if (!class_exists('parse_message'))
47        {
48            include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
49        }
50
51        /* @var $config_text \phpbb\config\db_text */
52        $config_text = $phpbb_container->get('config_text');
53
54        $contact_admin_data            = $config_text->get_array(array(
55            'contact_admin_info',
56            'contact_admin_info_uid',
57            'contact_admin_info_bitfield',
58            'contact_admin_info_flags',
59        ));
60
61        $contact_admin_info            = $contact_admin_data['contact_admin_info'];
62        $contact_admin_info_uid        = $contact_admin_data['contact_admin_info_uid'];
63        $contact_admin_info_bitfield= $contact_admin_data['contact_admin_info_bitfield'];
64        $contact_admin_info_flags    = $contact_admin_data['contact_admin_info_flags'];
65
66        if ($request->is_set_post('submit') || $request->is_set_post('preview'))
67        {
68            if (!check_form_key($form_name))
69            {
70                $error = $user->lang('FORM_INVALID');
71            }
72
73            $contact_admin_info = $request->variable('contact_admin_info', '', true);
74
75            generate_text_for_storage(
76                $contact_admin_info,
77                $contact_admin_info_uid,
78                $contact_admin_info_bitfield,
79                $contact_admin_info_flags,
80                !$request->variable('disable_bbcode', false),
81                !$request->variable('disable_magic_url', false),
82                !$request->variable('disable_smilies', false)
83            );
84
85            if (empty($error) && $request->is_set_post('submit'))
86            {
87                $config->set('contact_admin_form_enable', $request->variable('contact_admin_form_enable', false));
88
89                $config_text->set_array(array(
90                    'contact_admin_info'            => $contact_admin_info,
91                    'contact_admin_info_uid'        => $contact_admin_info_uid,
92                    'contact_admin_info_bitfield'    => $contact_admin_info_bitfield,
93                    'contact_admin_info_flags'        => $contact_admin_info_flags,
94                ));
95
96                trigger_error($user->lang['CONTACT_US_INFO_UPDATED'] . adm_back_link($this->u_action));
97            }
98        }
99
100        $contact_admin_info_preview = '';
101        if ($request->is_set_post('preview'))
102        {
103            $contact_admin_info_preview = generate_text_for_display($contact_admin_info, $contact_admin_info_uid, $contact_admin_info_bitfield, $contact_admin_info_flags);
104        }
105
106        $contact_admin_edit = generate_text_for_edit($contact_admin_info, $contact_admin_info_uid, $contact_admin_info_flags);
107
108        /** @var \phpbb\controller\helper $controller_helper */
109        $controller_helper = $phpbb_container->get('controller.helper');
110
111        $template->assign_vars(array(
112            'ERRORS'            => $error,
113            'CONTACT_ENABLED'    => $config['contact_admin_form_enable'],
114
115            'CONTACT_US_INFO'            => $contact_admin_edit['text'],
116            'CONTACT_US_INFO_PREVIEW'    => $contact_admin_info_preview,
117
118            'S_BBCODE_DISABLE_CHECKED'        => !$contact_admin_edit['allow_bbcode'],
119            'S_SMILIES_DISABLE_CHECKED'        => !$contact_admin_edit['allow_smilies'],
120            'S_MAGIC_URL_DISABLE_CHECKED'    => !$contact_admin_edit['allow_urls'],
121
122            'BBCODE_STATUS'            => $user->lang('BBCODE_IS_ON', '<a href="' . $controller_helper->route('phpbb_help_bbcode_controller') . '">', '</a>'),
123            'SMILIES_STATUS'        => $user->lang['SMILIES_ARE_ON'],
124            'IMG_STATUS'            => $user->lang['IMAGES_ARE_ON'],
125            'URL_STATUS'            => $user->lang['URL_IS_ON'],
126
127            'S_BBCODE_ALLOWED'        => true,
128            'S_SMILIES_ALLOWED'        => true,
129            'S_BBCODE_IMG'            => true,
130            'S_LINKS_ALLOWED'        => true,
131        ));
132
133        // Assigning custom bbcodes
134        display_custom_bbcodes();
135    }
136}