Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
form.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\message;
015
016 /**
017 * Abstract class form
018 */
019 abstract class form
020 {
021 /** @var \phpbb\auth\auth */
022 protected $auth;
023 /** @var \phpbb\config\config */
024 protected $config;
025 /** @var \phpbb\db\driver\driver_interface */
026 protected $db;
027 /** @var \phpbb\message\message */
028 protected $message;
029 /** @var \phpbb\user */
030 protected $user;
031
032 /** @var string */
033 protected $phpbb_root_path;
034 /** @var string */
035 protected $phpEx;
036
037 /** @var array */
038 protected $errors = array();
039 /** @var bool */
040 protected $cc_sender;
041 /** @var string */
042 protected $body;
043
044 /**
045 * Construct
046 *
047 * @param \phpbb\auth\auth $auth
048 * @param \phpbb\config\config $config
049 * @param \phpbb\db\driver\driver_interface $db
050 * @param \phpbb\user $user
051 * @param string $phpbb_root_path
052 * @param string $phpEx
053 */
054 public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $phpbb_root_path, $phpEx)
055 {
056 $this->phpbb_root_path = $phpbb_root_path;
057 $this->phpEx = $phpEx;
058 $this->user = $user;
059 $this->auth = $auth;
060 $this->config = $config;
061 $this->db = $db;
062
063 $this->message = new message($config['server_name']);
064 $this->message->set_sender_from_user($this->user);
065 }
066
067 /**
068 * Returns the title for the email form page
069 *
070 * @return string
071 */
072 public function get_page_title()
073 {
074 return $this->user->lang['SEND_EMAIL'];
075 }
076
077 /**
078 * Returns the file name of the form template
079 *
080 * @return string
081 */
082 public function get_template_file()
083 {
084 return 'memberlist_email.html';
085 }
086
087 /**
088 * Checks whether the user is allowed to use the form
089 *
090 * @return false|string Error string if not allowed, false otherwise
091 */
092 public function check_allow()
093 {
094 if (!$this->config['email_enable'])
095 {
096 return 'EMAIL_DISABLED';
097 }
098
099 if (time() - $this->user->data['user_emailtime'] < $this->config['flood_interval'])
100 {
101 return 'FLOOD_EMAIL_LIMIT';
102 }
103
104 return false;
105 }
106
107 /**
108 * Get the return link after the message has been sent
109 *
110 * @return string
111 */
112 public function get_return_message()
113 {
114 return sprintf($this->user->lang['RETURN_INDEX'], '<a href="' . append_sid($this->phpbb_root_path . 'index.' . $this->phpEx) . '">', '</a>');
115 }
116
117 /**
118 * Bind the values of the request to the form
119 *
120 * @param \phpbb\request\request_interface $request
121 * @return null
122 */
123 public function bind(\phpbb\request\request_interface $request)
124 {
125 $this->cc_sender = $request->is_set_post('cc_sender');
126 $this->body = $request->variable('message', '', true);
127 }
128
129 /**
130 * Submit form, generate the email and send it
131 *
132 * @param \messenger $messenger
133 * @return null
134 */
135 public function submit(\messenger $messenger)
136 {
137 if (!check_form_key('memberlist_email'))
138 {
139 $this->errors[] = 'FORM_INVALID';
140 }
141
142 if (!sizeof($this->errors))
143 {
144 $sql = 'UPDATE ' . USERS_TABLE . '
145 SET user_emailtime = ' . time() . '
146 WHERE user_id = ' . $this->user->data['user_id'];
147 $this->db->sql_query($sql);
148
149 if ($this->cc_sender)
150 {
151 $this->message->cc_sender();
152 }
153
154 $this->message->send($messenger, phpbb_get_board_contact($this->config, $this->phpEx));
155
156 meta_refresh(3, append_sid($this->phpbb_root_path . 'index.' . $this->phpEx));
157 trigger_error($this->user->lang['EMAIL_SENT'] . '<br /><br />' . $this->get_return_message());
158 }
159 }
160
161 /**
162 * Render the template of the form
163 *
164 * @param \phpbb\template\template $template
165 * @return null
166 */
167 public function render(\phpbb\template\template $template)
168 {
169 add_form_key('memberlist_email');
170
171 $template->assign_vars(array(
172 'ERROR_MESSAGE' => (sizeof($this->errors)) ? implode('<br />', $this->errors) : '',
173 ));
174 }
175 }
176