[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
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 namespace phpbb\message; 15 16 /** 17 * Class admin_form 18 * Displays a message to the user and allows him to send an email 19 */ 20 class admin_form extends form 21 { 22 /** @var \phpbb\config\db_text */ 23 protected $config_text; 24 25 /** @var \phpbb\event\dispatcher_interface */ 26 protected $dispatcher; 27 28 /** @var string */ 29 protected $subject; 30 /** @var string */ 31 protected $sender_name; 32 /** @var string */ 33 protected $sender_address; 34 35 /** 36 * Construct 37 * 38 * @param \phpbb\auth\auth $auth 39 * @param \phpbb\config\config $config 40 * @param \phpbb\config\db_text $config_text 41 * @param \phpbb\db\driver\driver_interface $db 42 * @param \phpbb\user $user 43 * @param \phpbb\event\dispatcher_interface $dispatcher 44 * @param string $phpbb_root_path 45 * @param string $phpEx 46 */ 47 public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\event\dispatcher_interface $dispatcher, $phpbb_root_path, $phpEx) 48 { 49 parent::__construct($auth, $config, $db, $user, $phpbb_root_path, $phpEx); 50 $this->config_text = $config_text; 51 $this->dispatcher = $dispatcher; 52 } 53 54 /** 55 * {inheritDoc} 56 */ 57 public function check_allow() 58 { 59 $error = parent::check_allow(); 60 if ($error) 61 { 62 return $error; 63 } 64 65 if (!$this->config['contact_admin_form_enable']) 66 { 67 return 'NO_CONTACT_PAGE'; 68 } 69 70 return false; 71 } 72 73 /** 74 * {inheritDoc} 75 */ 76 public function bind(\phpbb\request\request_interface $request) 77 { 78 parent::bind($request); 79 80 $this->subject = $request->variable('subject', '', true); 81 $this->sender_address = $request->variable('email', ''); 82 $this->sender_name = $request->variable('name', '', true); 83 } 84 85 /** 86 * {inheritDoc} 87 */ 88 public function submit(\messenger $messenger) 89 { 90 if (!$this->subject) 91 { 92 $this->errors[] = $this->user->lang['EMPTY_SUBJECT_EMAIL']; 93 } 94 if (!$this->body) 95 { 96 $this->errors[] = $this->user->lang['EMPTY_MESSAGE_EMAIL']; 97 } 98 99 $subject = $this->subject; 100 $body = $this->body; 101 $errors = $this->errors; 102 103 /** 104 * You can use this event to modify subject and/or body and add new errors. 105 * 106 * @event core.message_admin_form_submit_before 107 * @var string subject Message subject 108 * @var string body Message body 109 * @var array errors Form errors 110 * @since 3.2.6-RC1 111 */ 112 $vars = [ 113 'subject', 114 'body', 115 'errors', 116 ]; 117 extract($this->dispatcher->trigger_event('core.message_admin_form_submit_before', compact($vars))); 118 $this->subject = $subject; 119 $this->body = $body; 120 $this->errors = $errors; 121 122 if ($this->user->data['is_registered']) 123 { 124 $this->message->set_sender_from_user($this->user); 125 $this->sender_name = $this->user->data['username']; 126 $this->sender_address = $this->user->data['user_email']; 127 } 128 else 129 { 130 if (!$this->sender_name) 131 { 132 $this->errors[] = $this->user->lang['EMPTY_SENDER_NAME']; 133 } 134 135 if (!function_exists('validate_data')) 136 { 137 require($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); 138 } 139 140 $validate_array = validate_data( 141 array( 142 'email' => $this->sender_address, 143 ), 144 array( 145 'email' => array( 146 array('string', false, 6, 60), 147 array('email'), 148 ), 149 ) 150 ); 151 152 foreach ($validate_array as $error) 153 { 154 $this->errors[] = $this->user->lang[$error]; 155 } 156 157 $this->message->set_sender($this->user->ip, $this->sender_name, $this->sender_address, $this->user->lang_name); 158 $this->message->set_sender_notify_type(NOTIFY_EMAIL); 159 } 160 161 $this->message->set_template('contact_admin'); 162 $this->message->set_subject($this->subject); 163 $this->message->set_body($this->body); 164 $this->message->add_recipient( 165 $this->user->lang['ADMINISTRATOR'], 166 $this->config['board_contact'], 167 $this->config['default_lang'], 168 NOTIFY_EMAIL 169 ); 170 171 $this->message->set_template_vars(array( 172 'FROM_EMAIL_ADDRESS' => $this->sender_address, 173 'FROM_IP_ADDRESS' => $this->user->ip, 174 'S_IS_REGISTERED' => $this->user->data['is_registered'], 175 176 'U_FROM_PROFILE' => generate_board_url() . '/memberlist.' . $this->phpEx . '?mode=viewprofile&u=' . $this->user->data['user_id'], 177 )); 178 179 parent::submit($messenger); 180 } 181 182 /** 183 * {inheritDoc} 184 */ 185 public function render(\phpbb\template\template $template) 186 { 187 $l_admin_info = $this->config_text->get('contact_admin_info'); 188 if ($l_admin_info) 189 { 190 $contact_admin_data = $this->config_text->get_array(array( 191 'contact_admin_info', 192 'contact_admin_info_uid', 193 'contact_admin_info_bitfield', 194 'contact_admin_info_flags', 195 )); 196 197 $l_admin_info = generate_text_for_display( 198 $contact_admin_data['contact_admin_info'], 199 $contact_admin_data['contact_admin_info_uid'], 200 $contact_admin_data['contact_admin_info_bitfield'], 201 $contact_admin_data['contact_admin_info_flags'] 202 ); 203 } 204 205 $template->assign_vars(array( 206 'S_CONTACT_ADMIN' => true, 207 'S_CONTACT_FORM' => $this->config['contact_admin_form_enable'], 208 'S_IS_REGISTERED' => $this->user->data['is_registered'], 209 'S_POST_ACTION' => append_sid($this->phpbb_root_path . 'memberlist.' . $this->phpEx, 'mode=contactadmin'), 210 211 'CONTACT_INFO' => $l_admin_info, 212 'MESSAGE' => $this->body, 213 'SUBJECT' => $this->subject, 214 'NAME' => $this->sender_name, 215 'EMAIL' => $this->sender_address, 216 )); 217 218 parent::render($template); 219 } 220 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |