-
-
Save telinc1/27e9e36d921ba27088cd46829544cca3 to your computer and use it in GitHub Desktop.
SMW Central Staff Feedback Form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* staff_comment.php, 2020-03-03 | |
* | |
* Copyright 2020 SMW Central. All rights reserved. | |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
* | |
* This code is proprietary. Unauthorized use or copying of this file | |
* outside SMW Central is strictly prohibited. | |
*/ | |
use SMWCentral\{EventLog, Forums}; | |
$this->handles('GET', 'POST')->authorize('registered'); | |
if($this->submitted()) | |
{ | |
$validator = $this->validator(); | |
$subject = $validator->string('subject')->between(1, 128)->value(); | |
$message = $validator->string('message')->between(1, 4150000)->value(); | |
$reveal = $validator->boolean('reveal', false)->value(); | |
$preview = false; | |
if(isset($_POST['preview'])) | |
{ | |
$preview = [ | |
'id' => 0, | |
'time' => time(), | |
'text' => $message, | |
'user' => ($reveal) ? getPostUser($this->user) : null, | |
'layout' => ['hide' => true] | |
]; | |
} | |
elseif($validator->passes()) | |
{ | |
try | |
{ | |
Forums::get(config('user.users.system'))->createThread( | |
42666, | |
($reveal) | |
? '[' . $this->user->getUsername() . ' / ' . $this->user->getID() . "] {$subject}" | |
: "[Anonymous] {$subject}", | |
$message | |
); | |
} | |
catch(Exception $exception) | |
{ | |
EventLog::addEvent('<strong>' . e(get_class($exception)) . '</strong> (' . e($exception->getMessage()) . ') from staff feedback', 'System Error'); | |
return $this->message(['key' => 'error', 'page' => 'main', 'success' => false]); | |
} | |
return $this->message(['key' => 'success', 'page' => 'main']); | |
} | |
} | |
else | |
{ | |
$subject = null; | |
$message = null; | |
$reveal = false; | |
$preview = false; | |
} | |
$form = $this->form(page('staff_comment'))->rte() | |
->title('editor') | |
->text('subject', $subject, ['id' => 'subject', 'required', 'maxlength' => 128]) | |
->textarea('message', $message, ['required', 'maxlength' => 4150000]) | |
->checkbox('reveal', $reveal) | |
->title(null) | |
->sequence(function($field) | |
{ | |
$field->submit()->submit('preview'); | |
}); | |
return $this->view('staff_comment', compact('subject', 'message', 'preview', 'form')) | |
->withScript('/js/emoticons.php', 'cuteedit'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table cellpadding="0" class="brdr"> | |
<tr> | |
<td colspan="2" class="title center border"><?= __('title') ?></td> | |
</tr> | |
<tr> | |
<td colspan="2" class="normal border"> | |
<?= __('body.main') ?><br><br> | |
<?= __('body.attitude') ?><br><br> | |
<?= __('body.response', [ | |
'link' => html('<a href="' . href('viewthread', ['t' => 93969]) . '">'), | |
'/link' => html('</a>') | |
]) ?> | |
</td> | |
</tr> | |
<tr><td class="space" colspan="2"></td></tr> | |
<?php if($preview !== false): ?> | |
<tr><td class="title center border" colspan="2">Preview</td></tr> | |
<?= e(renderPost($preview, /* thread */ false, /* menuSettings */ false, /* disableLayout */ true)) ?> | |
<tr><td class="space" colspan="2"></td></tr> | |
<?php endif; ?> | |
</table> | |
<?= e($form) ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'title' => 'Provide Staff Feedback', | |
'editor' => 'Editor', | |
'body' => [ | |
'main' => 'Problem with a staff member\'s attitude? Praise for a hard-working staff member who you feel is underappreciated? General ideas for the staff? Feel free to send feedback. It will only be used to help improve the site.', | |
'attitude' => 'If there is a problem with a staff member\'s attitude, please provide examples as it could be something which we are unaware of.', | |
'response' => 'We will respond to your message publicly in the {link}Staff Feedback Thread{/link} as long as it fits the criteria listed in the first post. If you choose to share your identity, we may also contact you regarding your feedback.' | |
], | |
'form' => [ | |
'subject' => 'subject', | |
'message' => 'Your feedback', | |
'reveal' => [ | |
'title' => 'Share identity', | |
'label' => 'Share my identity', | |
'description' => 'Staff feedback is fully anonymous by default. If you check this option, however, your username will be attached to your message, which will allow us to get back to you if necessary.' | |
], | |
'submit' => 'Send feedback', | |
'preview' => 'Preview message' | |
], | |
'success' => [ | |
'title' => 'Success', | |
'message' => 'Feedback sent.' | |
], | |
'error' => [ | |
'title' => 'Error', | |
'message' => 'An internal error occurred while sending your feedback. Please try again later.' | |
] | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 49 of staff_comment.php handles exceptions specially because error logs normally include the username.