News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SMF 2.1 RC3 - Unapproved Attachments Issues

Started by GL700Wing, January 17, 2021, 02:20:06 AM

Previous topic - Next topic

GL700Wing

Note:  I also posted this information in the SMF 2.1.x Support board but it probably belongs here ...

I created a new SMF 2.1 RC3 forum using a release I downloaded from GitHub yesterday so that I could update my Image Attachment Thumbnail View mod to support SMF 2.1 RC3.

In the process of working out what changes I need for my mod to support SMF 2.1 RC3 I discovered the following:

  • There is no indication that attachments are awaiting approval in 'Profile of User > Show posts > Attachments'.
    In SMF 2.0.17 unapproved attachments are displayed in a row with a different coloured background and the attachment name is followed by the text '(Awaiting Approval)'.
  • If the 'Administration Center > Attachments and Avatars > Attachment Settings > Do not show attachments under the post if they are already embedded in it.' option is enabled:

    • Attachments that have been inserted inline and are awaiting approval are shown as 'Not a valid attachment ID.' in the body of the message for non-administrators and non-moderators; and
    • Attachments that have been inserted inline are not shown in the 'Attachments awaiting approval' block with the following consequences:

      • If all attachments have been inserted inline the 'Attachments awaiting approval' block is not displayed; and
      • If some attachments have been inserted inline the 'approve all' action applies to attachments that are not shown in the 'Attachments awaiting approval' block (this may result in admins/moderators unintentionally approving attachments).
  • If a member clicks on the link for an unapproved attachment in another member's profile via 'Profile of User > Show posts > Attachments' they get a '403 Forbidden' error.
    In SMF 2.0.17 the error message 'You do not have permission to approve items.' is displayed.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GL700Wing

#1
Quote from: GL700Wing on January 17, 2021, 02:20:06 AM
  • There is no indication that attachments are awaiting approval in 'Profile of User > Show posts > Attachments'.
    In SMF 2.0.17 unapproved attachments are displayed in a row with a different coloured background and the attachment name is followed by the text '(Awaiting Approval)'.

Worked out a fix for the first issue ...

In ./Sources/Profile-View.php (for adding '(Awaiting Approval)' after unapproved attachment name)

Find:
'format' => '<a href="' . $scripturl . '?action=dlattach;topic=%1$d.0;attach=%2$d">%3$s</a>'
Replace With:
'format' => '<a href="' . $scripturl . '?action=dlattach;topic=%1$d.0;attach=%2$d">%3$s%4$s</a>'

Find:
'filename' => false,
Add After:
'awaiting_approval' => false,

Find:
global $smcFunc, $board, $modSettings, $context;

// Retrieve some attachments.

Replace With:
global $smcFunc, $board, $modSettings, $context, $txt;

// Retrieve some attachments.


Find:
'approved' => $row['approved'],
Add After:
'awaiting_approval' => (empty($row['approved']) ? ' &nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''),




In ./Themes/default/GenericList.template.php (for fixing missing CSS class for unapproved attachments)
Note: Not sure if the array variable name for 'style' also needs to be changed - I couldn't find a list where it's defined in the same way as  'class'  ...

Find:
<td class="', $row_id, empty($row_data['class']) ? '' : ' ' . $row_data['class'] . '', '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', '>
Replace With:
<td class="', $row_id, empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row_data['style']) ? '' : ' style="' . $row_data['style'] . '"', '>
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

ozp

Nice catch.
I have made some improvements to attachments post RC3, but these problems are new to me.
Will see if I can make some fixes.

GL700Wing

Quote from: ozp on January 18, 2021, 09:54:45 AM
Nice catch.
I have made some improvements to attachments post RC3, but these problems are new to me.
Will see if I can make some fixes.
I worked out a  fix for 2.2 (ie, Attachments that have been inserted inline are not shown in the 'Attachments awaiting approval' block with the following consequences:)

In /Themes/default/Display.template.php
Find:
if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
Replace With:
if ($attachment['is_approved'] && !empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))




Also, and in order to be consistent with SMF 2.0, in the fix I suggested previously '(Awaiting Approval)' should be displayed after the filename link.

In ./Sources/Profile-View.php (for adding '(Awaiting Approval)' after unapproved attachment name)

Find:
'format' => '<a href="' . $scripturl . '?action=dlattach;topic=%1$d.0;attach=%2$d">%3$s</a>'
Replace With:
'format' => '<a href="' . $scripturl . '?action=dlattach;topic=%1$d.0;attach=%2$d">%3$s</a>%4$s'
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas


Advertisement: