' . $this->language->lang('RETURN_INDEX', 'root_path}index.$this->php_ext") . '">', '');
throw new http_exception(503, $message);
}
@@ -314,8 +317,8 @@ private function contact_send_email($email_template, $email_message)
$messenger->headers('X-AntiAbuse: User IP - ' . $this->user->ip);
$messenger->template($email_template, $lang);
+ // No from() call: the messenger sends from the board email address by default
$messenger->to($this->config['board_email']);
- $messenger->from($this->config['server_name']);
$messenger->assign_vars([
'SUBJECT' => $this->language->lang('CONTACT_BOT_SUBJECT'),
@@ -329,38 +332,41 @@ private function contact_send_email($email_template, $email_message)
}
/**
- * contact_make_select
+ * contact_reason_options
*
* @param array $input_ary an array of contact reasons
* @param string $selected the chosen reason
- * @return string Select html
- * for drop down reasons in the contact page
+ * @return array Options for the reasons drop down, empty if there are no reasons
*/
- public function contact_make_select($input_ary, $selected)
+ public function contact_reason_options($input_ary, $selected)
{
// only accept arrays, no empty ones
if (!is_array($input_ary) || !count($input_ary))
{
- return false;
+ return [];
}
// add a default entry asking for user to choose a reason
- $default_reason[] = $this->language->lang('REASON_EXPLAIN');
-
- $input_ary = array_merge($default_reason, $input_ary);
+ $input_ary = array_merge([$this->language->lang('REASON_EXPLAIN')], $input_ary);
- $select = '';
+ $options = [];
foreach ($input_ary as $item)
{
- $item_selected = ($item == $selected) ? ' selected="selected"' : '';
- $select .= '';
+ $options[] = [
+ 'VALUE' => $item,
+ 'S_SELECTED' => ($item == $selected),
+ ];
}
- return $select;
+ return $options;
}
/**
* Create the selection for who gets the message
+ *
+ * @param int $value the selected option
+ * @param string $key config key passed on to h_radio()
+ * @return string Radio buttons html, built by phpBB's h_radio()
*/
public function who_select($value, $key = '')
{
@@ -375,6 +381,10 @@ public function who_select($value, $key = '')
/**
* Create the selection for the contact method
+ *
+ * @param int $value the selected option
+ * @param string $key config key passed on to h_radio()
+ * @return string Radio buttons html, built by phpBB's h_radio()
*/
public function method_select($value, $key = '')
{
@@ -399,6 +409,10 @@ public function method_select($value, $key = '')
/**
* Create the selection for the post method
+ *
+ * @param int $value the selected option
+ * @param string $key config key passed on to h_radio()
+ * @return string Radio buttons html, built by phpBB's h_radio()
*/
public function poster_select($value, $key = '')
{
@@ -412,11 +426,14 @@ public function poster_select($value, $key = '')
}
/**
- * Create the selection for the bot forum
+ * Get the forums for the bot forum drop down
+ *
+ * @param int $value the selected forum id
+ * @return array Forum data keyed by forum id, from make_forum_select()
*/
- public function forum_select($value)
+ public function forum_options($value)
{
- return '';
+ return make_forum_select((int) $value, false, true, true, true, false, true);
}
/**
@@ -480,66 +497,81 @@ public function admin_array()
}
/**
- * bot_user_info used in the ACP when choosing the "bot"
+ * bot_user_info look up the user chosen as the contact "bot"
*
- * @param user_id user id
- * @return array array of user info or error if not found
+ * @param int $user_id user id
+ * @return array user_id, username and user_type, or an 'error' message if not found
* @access public
*/
public function bot_user_info($user_id)
{
- $bot_user_info = [];
-
$sql = 'SELECT user_id, username, user_type
- FROM ' . USERS_TABLE . "
- WHERE user_id = " . (int) $user_id;
+ FROM ' . USERS_TABLE . '
+ WHERE user_id = ' . (int) $user_id;
$result = $this->db->sql_query($sql);
$bot_user_info = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- if (!isset($bot_user_info['username']))
+ if (!$bot_user_info)
{
- $bot_user_info['error'] = $this->language->lang('CONTACT_NO_BOT_USER');
+ $bot_user_info = ['error' => $this->language->lang('CONTACT_NO_BOT_USER')];
}
- if ($this->request->is_ajax())
+ return $bot_user_info;
+ }
+
+ /**
+ * bot_user_info_json AJAX lookup used by the ACP settings when choosing the "bot"
+ *
+ * Only board administrators may use it: it reveals usernames and account types.
+ *
+ * @param int $user_id user id
+ * @return JsonResponse the user's profile link, plus an error key if the user is unsuitable
+ * @throws http_exception 403 for anyone without the a_board permission
+ * @access public
+ */
+ public function bot_user_info_json($user_id)
+ {
+ if (!$this->auth->acl_get('a_board'))
{
- if (!isset($bot_user_info['username']))
- {
- $json = new JsonResponse([
- 'error' => 'CONTACT_NO_BOT_USER',
- 'user_link' => '',
- ]);
- }
- else if ($bot_user_info['user_id'] == ANONYMOUS)
- {
- $json = new JsonResponse([
- 'error' => 'CONTACT_BOT_IS_GUEST',
- 'user_link' => $bot_user_info['username'],
- ]);
- }
- else if ($bot_user_info['user_type'] == USER_IGNORE)
- {
- $json = new JsonResponse([
- 'error' => 'CONTACT_BOT_IS_BOT',
- 'user_link' => $bot_user_info['username'],
- ]);
- }
- else
- {
- $json = new JsonResponse([
- 'error' => false,
- 'user_link' => 'root_path}memberlist.$this->php_ext", 'mode=viewprofile&u=' . $bot_user_info['user_id']) . '" target="_blank">' . $bot_user_info['username'] . '',
- ]);
- }
- return $json;
+ throw new http_exception(403, 'NOT_AUTHORISED');
}
- return $bot_user_info;
+ $bot_user_info = $this->bot_user_info($user_id);
+
+ if (isset($bot_user_info['error']))
+ {
+ return new JsonResponse([
+ 'error' => 'CONTACT_NO_BOT_USER',
+ 'user_link' => '',
+ ]);
+ }
+ else if ($bot_user_info['user_id'] == ANONYMOUS)
+ {
+ return new JsonResponse([
+ 'error' => 'CONTACT_BOT_IS_GUEST',
+ 'user_link' => $bot_user_info['username'],
+ ]);
+ }
+ else if ($bot_user_info['user_type'] == USER_IGNORE)
+ {
+ return new JsonResponse([
+ 'error' => 'CONTACT_BOT_IS_BOT',
+ 'user_link' => $bot_user_info['username'],
+ ]);
+ }
+
+ return new JsonResponse([
+ 'error' => false,
+ 'user_link' => 'root_path}memberlist.$this->php_ext", 'mode=viewprofile&u=' . $bot_user_info['user_id']) . '" target="_blank">' . $bot_user_info['username'] . '',
+ ]);
}
- /*
- * Get an array that represents directory tree
+ /**
+ * Get the names of the sub-directories of a directory
+ *
+ * @param string $directory path of the directory
+ * @return array directory names
*/
public function dir_to_array($directory)
{
diff --git a/event/listener.php b/event/listener.php
index cbf0214..3cf60cf 100644
--- a/event/listener.php
+++ b/event/listener.php
@@ -35,7 +35,7 @@ class listener implements EventSubscriberInterface
/** @var language */
protected $language;
- /* @var template */
+ /** @var template */
protected $template;
/** @var user */
@@ -151,12 +151,9 @@ public function page_header_after($event)
{
if (empty($this->user->data['is_bot']))
{
- $version = phpbb_version_compare($this->config['version'], '3.3', '>=');
-
$this->template->assign_vars([
'U_CONTACT_US' => false,
'U_CONTACTADMIN' => $this->helper->route('phpbbmodders_contactadmin_displayform'),
- 'S_FORUM_VERSION' => $version,
]);
}
}
diff --git a/language/en/acp/info_acp_contact.php b/language/en/acp/info_acp_contact.php
index e59f41e..5e1f826 100644
--- a/language/en/acp/info_acp_contact.php
+++ b/language/en/acp/info_acp_contact.php
@@ -41,7 +41,6 @@
'FORUM_EMAIL_INACTIVE' => 'How do you want users to be able to make contact. No email allowed per forum settings',
'NO_FORUM_ATTACHMENTS' => 'If set attachments will be allowed in posting to the forum and private messages. The extensions allowed are the same as the board configuration. No attachments allowed per forum settings!',
// Log entries
- 'LOG_CONFIG_CONTACT_ADMIN' => 'Altered Contact Admin extension page settings',
'LOG_CONTACT_BOT_INVALID' => 'The Contact Admin extension bot has an invalid user id selected: User ID %1$s',
'LOG_CONTACT_FORUM_INVALID' => 'The Contact Admin extension forum has an invalid forum selected: Forum ID %1$s',
'LOG_CONTACT_EMAIL_INVALID' => 'The Contact Admin extension is allowing emails but the forum is not setup to allow emails. The extension has been disabled.',
diff --git a/language/en/acp_contact.php b/language/en/acp_contact.php
index 060f30a..3abea03 100644
--- a/language/en/acp_contact.php
+++ b/language/en/acp_contact.php
@@ -38,10 +38,8 @@
//
$lang = array_merge($lang, [
- 'ADMINS_NOT_EXIST_FOR_METHOD' => [
- 0 => 'There are no Administrators who allow emails. You must choose a different method of contact.',
- 2 => 'There are no Administrators who allow private messages. You must choose a different method of contact.',
- ],
+ 'ADMINS_NOT_EXIST_EMAIL' => 'There are no Administrators who allow emails. You must choose a different method of contact.',
+ 'ADMINS_NOT_EXIST_PM' => 'There are no Administrators who allow private messages. You must choose a different method of contact.',
'CONTACT_CONFIG_SAVED' => 'Contact Admin configuration has been updated',
'CONTACT_ACP_CONFIRM' => 'Enable visual confirmation',
'CONTACT_ACP_CONFIRM_EXPLAIN' => 'If you enable this option, users will have to enter a visual confirmation to send the message. This is to prevent spam messages. Note that this option is for the contact page only. It does not affect other visual confirmation settings',
diff --git a/language/en/contact.php b/language/en/contact.php
index 663ecd8..6947496 100644
--- a/language/en/contact.php
+++ b/language/en/contact.php
@@ -39,7 +39,7 @@
$lang = array_merge($lang, [
'ACP_CAT_CONTACTADMIN' => 'Contact Admin',
- 'ADD_ATTACHMENT_EXPLAIN' => 'If you wish to attach a file enter the details below.',
+ 'CONTACT_ADD_ATTACHMENT_EXPLAIN' => 'If you wish to attach a file enter the details below.',
'CONTACT_ERROR' => 'You can’t use the contact form at the moment because there is an error in the configuration. An email has been sent to the founder.',
'CONTACT_NONE' => 'The user %1$s tried to use the Contact Admin extension at %2$s to send a %3$s, but there are no Administrators that allow %3$ss by users. Please enter the Contact Admin Configuration in the Admin Extension Panel for the board %4$s and choose a different method for contact',
'CONTACT_BOT_SUBJECT' => 'Contact Admin Extension Error',
@@ -52,7 +52,6 @@
'CONTACT_NO_SUBJ' => 'You didn’t enter a subject',
'CONTACT_REASON' => 'Reason',
'CONTACT_TEMPLATE' => '[b]Name:[/b] %1$s' . "\n" . '[b]Email Address:[/b] %2$s' . "\n" . '[b]IP:[/b] %3$s' . "\n" . '[b]Subject:[/b] %4$s' . "\n" . '[b]Has entered the following message into the contact form:[/b] %5$s',
- 'CONTACT_TITLE' => 'Contact Administration',
'CONTACT_YOUR_NAME' => 'Your name',
'CONTACT_YOUR_NAME_EXPLAIN' => 'Please enter your name, so the message has an identity.',
@@ -63,14 +62,13 @@
'TOO_MANY_CONTACT_TRIES' => 'You have exceeded the maximum number of attempts for this session. Please try again later.',
'CONTACT_NO_NAME' => 'You didn’t enter a name',
- 'FORUM' => 'forum',
+ 'CONTACT_FORUM' => 'forum',
'USER' => 'user',
'CONTACT_REGISTERED' => 'Registered User',
'CONTACT_GUEST' => 'Guest User',
'REASON_EXPLAIN' => 'Please choose a reason',
'REASON_ERROR' => 'Please choose an appropriate reason',
- 'RETURN_CONTACT' => '%sReturn to the contact page%s',
'CONTACT_PRIVACYPOLICY' => 'Privacy policy',
'CONTACT_PRIVACYPOLICY_EXPLAIN' => 'I confirm that the given name, e-mail address, message text and my IP address will be processed and stored by the owner of the board according to the Privacy Policy',
'CONTACT_PRIVACYPOLICY_ERROR' => 'Please check the privacy policy box. Without your confirmation you won’t able to send us a message.',
diff --git a/license.txt b/license.txt
index 3912109..b8b347f 100644
--- a/license.txt
+++ b/license.txt
@@ -1,12 +1,12 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
- Preamble
+ Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
+the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
-
- GNU GENERAL PUBLIC LICENSE
+
+ GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
-
+
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
-
+
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
-
+
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
- NO WARRANTY
+ NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@@ -277,64 +277,5 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- , 1 April 1989
- Ty Coon, President of Vice
+ END OF TERMS AND CONDITIONS
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/styles/prosilver/template/contactadmin_body.html b/styles/prosilver/template/contactadmin_body.html
index 2b05ffc..7ca80f5 100644
--- a/styles/prosilver/template/contactadmin_body.html
+++ b/styles/prosilver/template/contactadmin_body.html
@@ -1,4 +1,5 @@
-{% INCLUDE 'overall_header.html' %}
+{% INCLUDECSS '@phpbbmodders_contactadmin/contactadmin.css' %}
+{% include 'overall_header.html' %}