jdarwood007 commited on 2023-03-14 16:34:18
Showing 3 changed files, with 92 additions and 5 deletions.
Fixes #11 As well this also will submit the poster ip/email/name instead of the current user. This should allow this to work against guest accounts.
... | ... |
@@ -279,6 +279,40 @@ class SFS |
279 | 279 |
$context['token_check'] = 'sfs_submit-' . $memID; |
280 | 280 |
$cache_key = 'sfs_check_member-' . $memID; |
281 | 281 |
|
282 |
+ // Do we have a message? |
|
283 |
+ $poster_name = null; |
|
284 |
+ $poster_email = null; |
|
285 |
+ $poster_ip = null; |
|
286 |
+ $post_body = null; |
|
287 |
+ if (isset($_GET['msg']) && intval($_GET['msg']) > 0) |
|
288 |
+ { |
|
289 |
+ $request = $smcFunc['db_query']('', ' |
|
290 |
+ SELECT poster_name, poster_email, poster_ip, body |
|
291 |
+ FROM {db_prefix}messages |
|
292 |
+ WHERE id_msg = {int:id_msg} |
|
293 |
+ AND ( |
|
294 |
+ id_member = {int:id_member} |
|
295 |
+ OR id_member = 0 |
|
296 |
+ ) |
|
297 |
+ AND {query_see_message_board} |
|
298 |
+ ', |
|
299 |
+ array( |
|
300 |
+ 'id_msg' => (int) $_GET['msg'], |
|
301 |
+ 'id_member' => $memID, |
|
302 |
+ 'actor_is_admin' => $context['user']['is_admin'] ? 1 : 0 |
|
303 |
+ )); |
|
304 |
+ if ($smcFunc['db_num_rows']($request) == 1) |
|
305 |
+ { |
|
306 |
+ list($poster_name, $poster_email, $poster_ip, $post_body) = $smcFunc['db_fetch_row']($request); |
|
307 |
+ $poster_ip = inet_dtop($poster_ip); |
|
308 |
+ } |
|
309 |
+ $smcFunc['db_free_result']($request); |
|
310 |
+ |
|
311 |
+ $context['reason'] = $smcFunc['htmlspecialchars']($post_body); |
|
312 |
+ } |
|
313 |
+ else |
|
314 |
+ $context['reason'] = ''; |
|
315 |
+ |
|
282 | 316 |
// Are we submitting this? |
283 | 317 |
if ($context['sfs_allow_submit'] && (isset($_POST['sfs_submit']) || isset($_POST['sfs_submitban']))) |
284 | 318 |
{ |
... | ... |
@@ -287,9 +321,9 @@ class SFS |
287 | 321 |
validateToken($context['token_check'], 'post'); |
288 | 322 |
|
289 | 323 |
$data = [ |
290 |
- 'username' => $user_profile[$memID]['real_name'], |
|
291 |
- 'email' => $user_profile[$memID]['email_address'], |
|
292 |
- 'ip_addr' => $user_profile[$memID]['member_ip'], |
|
324 |
+ 'username' => !empty($poster_name) ? $poster_name : $user_profile[$memID]['real_name'], |
|
325 |
+ 'email' => !empty($poster_email) ? $poster_email : $user_profile[$memID]['email_address'], |
|
326 |
+ 'ip_addr' => !empty($poster_ip) ? $poster_ip : $user_profile[$memID]['member_ip'], |
|
293 | 327 |
'api_key' => $modSettings['sfs_apikey'] |
294 | 328 |
]; |
295 | 329 |
$post_data = http_build_query($data, '', '&'); |
... | ... |
@@ -309,7 +343,7 @@ class SFS |
309 | 343 |
$context['submission_success'] = $this->txt('sfs_submission_success'); |
310 | 344 |
} |
311 | 345 |
|
312 |
- // CHeck if we have this info. |
|
346 |
+ // Check if we have this info. |
|
313 | 347 |
if (($cache = cache_get_data($cache_key)) === null || ($response = $this->decodeJSON($cache, true)) === null) |
314 | 348 |
{ |
315 | 349 |
$checks = [ |
... | ... |
@@ -1501,4 +1535,47 @@ class SFS |
1501 | 1535 |
if (in_array($variable, array('softwareName', 'softwareVersion'))) |
1502 | 1536 |
return $this->{$variable}; |
1503 | 1537 |
} |
1538 |
+ |
|
1539 |
+ /** |
|
1540 |
+ * The hook to setup quick buttons menu. |
|
1541 |
+ * |
|
1542 |
+ * @param array $profile_areas All the mod buttons. |
|
1543 |
+ * |
|
1544 |
+ * @api |
|
1545 |
+ * @CalledIn SMF 2.1 |
|
1546 |
+ * @version 1.4.0 |
|
1547 |
+ * @since 1.4.0 |
|
1548 |
+ * @uses integrate_prepare_display_context - Hook SMF2.1 |
|
1549 |
+ * @return void We update the output to add the more action for SFS. |
|
1550 |
+ */ |
|
1551 |
+ public static function hook_prepare_display_context(&$output, &$message, $counter): void |
|
1552 |
+ { |
|
1553 |
+ global $smcFunc, $scripturl, $context; |
|
1554 |
+ |
|
1555 |
+ $output['quickbuttons']['more']['sfs'] = array( |
|
1556 |
+ 'label' => $smcFunc['classSFS']->txt('sfs_admin_area'), |
|
1557 |
+ 'href' => $scripturl . '?action=profile;area=sfs;u=' . $output['member']['id'] . ';msg=' . $output['id'], |
|
1558 |
+ 'icon' => 'sfs', |
|
1559 |
+ 'show' => $context['can_moderate_forum'] |
|
1560 |
+ ); |
|
1561 |
+ } |
|
1562 |
+ |
|
1563 |
+ /** |
|
1564 |
+ * We don't do any mod buttons, just use this to inject some CSS. |
|
1565 |
+ * |
|
1566 |
+ * @param array $mod_buttons All the mod buttons. |
|
1567 |
+ * |
|
1568 |
+ * @api |
|
1569 |
+ * @CalledIn SMF 2.1 |
|
1570 |
+ * @version 1.4.0 |
|
1571 |
+ * @since 1.4.0 |
|
1572 |
+ * @uses integrate_mod_buttons - Hook SMF2.1 |
|
1573 |
+ * @return void We add some css. |
|
1574 |
+ */ |
|
1575 |
+ public static function hook_mod_buttons(&$mod_buttons): void |
|
1576 |
+ { |
|
1577 |
+ global $settings; |
|
1578 |
+ |
|
1579 |
+ addInlineCss('.main_icons.sfs::before { background: url(' . $settings['default_images_url'] . '/admin/sfs.webp) no-repeat; background-size: contain;}'); |
|
1580 |
+ } |
|
1504 | 1581 |
} |
1505 | 1582 |
\ No newline at end of file |
... | ... |
@@ -85,7 +85,7 @@ function template_profile_tracksfs() |
85 | 85 |
</div> |
86 | 86 |
<div class="roundframe"> |
87 | 87 |
<div>', $txt['sfs_evidence'], '</div> |
88 |
- <textarea name="reason" rows="4"></textarea> |
|
88 |
+ <textarea name="reason" rows="4" cols="60">', $context['reason'], '</textarea> |
|
89 | 89 |
<div class="righttext"> |
90 | 90 |
<input id="notify_submit" type="submit" name="sfs_submit" value="', $txt['sfs_submit'], '" class="button"> |
91 | 91 |
<input id="notify_submit" type="submit" name="sfs_submitban" value="', $txt['sfs_submit_ban'], '" class="button"> |
... | ... |
@@ -81,6 +81,10 @@ |
81 | 81 |
<!-- Profile Section --> |
82 | 82 |
<hook hook="integrate_pre_profile_areas" function="SFS::hook_pre_profile_areas" /> |
83 | 83 |
|
84 |
+ <!-- Display Section --> |
|
85 |
+ <hook hook="integrate_prepare_display_context" function="SFS::hook_prepare_display_context" /> |
|
86 |
+ <hook hook="integrate_mod_buttons" function="SFS::hook_mod_buttons" /> |
|
87 |
+ |
|
84 | 88 |
<redirect url="?action=admin;area=modsettings;sa=sfs" /> |
85 | 89 |
</install> |
86 | 90 |
|
... | ... |
@@ -105,6 +109,10 @@ |
105 | 109 |
<!-- Profile Section --> |
106 | 110 |
<hook hook="integrate_pre_profile_areas" function="SFS::hook_pre_profile_areas" reverse="true" /> |
107 | 111 |
|
112 |
+ <!-- Display Section --> |
|
113 |
+ <hook hook="integrate_prepare_display_context" function="SFS::hook_prepare_display_context" reverse="true" /> |
|
114 |
+ <hook hook="integrate_mod_buttons" function="SFS::hook_mod_buttons" reverse="true" /> |
|
115 |
+ |
|
108 | 116 |
<!-- language files, removed --> |
109 | 117 |
<remove-file name="$themes_dir/default/languages/StopForumSpam.english.php" /> |
110 | 118 |
<remove-file name="$themes_dir/default/languages/StopForumSpam.finnish.php" /> |
... | ... |
@@ -125,6 +133,8 @@ |
125 | 133 |
<require-file name="SFS-Subs-Admin.php" destination="$sourcedir" /> |
126 | 134 |
<require-file name="SFS-Subs-Logs.php" destination="$sourcedir" /> |
127 | 135 |
<hook hook="integrate_pre_profile_areas" function="SFS::hook_pre_profile_areas" /> |
136 |
+ <hook hook="integrate_prepare_display_context" function="SFS::hook_prepare_display_context" /> |
|
137 |
+ <hook hook="integrate_mod_buttons" function="SFS::hook_mod_buttons" /> |
|
128 | 138 |
|
129 | 139 |
<!-- this dir may not exist in SMF --> |
130 | 140 |
<create-dir name="admin" destination="$themedir/images" /> |
131 | 141 |