Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: live627 on May 13, 2008, 01:32:13 AM

Title: Attachment Notice
Post by: live627 on May 13, 2008, 01:32:13 AM
Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=1180)

Created By : Dragooon
Tested with : 1.1.5, 2.0.18
Name : Attachment Notice
Version : 1.1


Shows a notice under a post if it got attachment(s) and the user doesn't have permissions to view it


Changelog
Version 1.1
Version 1.0
Title: Re: Attachment Notice
Post by: Apllicmz on May 13, 2008, 02:05:07 AM
Good Work
Translate portuguese and Brazilian

Utf8
<file name="$languagedir/Modifications.portuguese-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
// Attachment notice strings
$txt['num_disabled_attachments'] = 'N&atilde;o h&aacute; anexo (s), neste lugar e voc&ecirc; n&atilde;o pode visualizar ou fazer download';
]]></add>
</operation>
</file>
<file name="$languagedir/Modifications.brazilian-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
// Attachment notice strings
$txt['num_disabled_attachments'] = 'N&atilde;o h&aacute; anexo (s), neste lugar e voc&ecirc; n&atilde;o pode visualizar ou fazer download';
]]></add>
</operation>
</file>



Normal

</file>
<file name="$languagedir/Modifications.portuguese.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
// Attachment notice strings
$txt['num_disabled_attachments'] = 'Não há anexo (s), neste lugar e você não pode visualizar ou fazer download';
]]></add>
</operation>
</file>
<file name="$languagedir/Modifications.brazilian.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
// Attachment notice strings
$txt['num_disabled_attachments'] = 'Não há anexo (s), neste lugar e você não pode visualizar ou fazer download';
]]></add>
</operation>
</file>
Title: Re: Attachment Notice
Post by: rumfa on May 14, 2008, 03:42:36 AM
This is the whole package ready to install, but with additional Serbian languages "serbian-lat and serbian-utf8"  Enjoy.
Уживајте :П ...

Hopefully i'm am not violeting any mod rights...It's easier like this. ;)
Title: Re: Attachment Notice
Post by: уιℓмαz on May 17, 2008, 11:13:50 AM
Thanks for modification. I translated this into Turkish.

<file name="$languagedir/Modifications.turkish.php" error="skip">
   <operation>
      <search position="end" />
      <add><![CDATA[
// Attachment notice strings
$txt['num_disabled_attachments'] = 'Bu mesajda %s dosya eki mevcut ancak indirmeye yetkiniz yok.';
]]></add>
   </operation>
</file>


UTF-8 support
<file name="$languagedir/Modifications.turkish-utf8.php" error="skip">
   <operation>
      <search position="end" />
      <add><![CDATA[
// Attachment notice strings
$txt['num_disabled_attachments'] = 'Bu mesajda %s dosya eki mevcut ancak indirmeye yetkiniz yok.';
]]></add>
   </operation>
</file>
Title: Re: Attachment Notice
Post by: 58tbird on August 01, 2008, 10:51:02 AM
Good idea - thank you!  Now visitors won't be confused, and it provides an opportunity to encourage membership.  ;)
Title: Re: Attachment Notice
Post by: marglar on August 31, 2008, 01:51:29 PM
This is exactly what I need, but I've installed it and can't seem to make it work.

It says it installed properly but I don't see any directions.

As a simple test, I have "Guest" set both view and post attachments turned off.

When I view a post with attachments, I don't see the message telling me that there are attachments available if I log in.

Can anyone help?
Title: Re: Attachment Notice
Post by: X3mE on October 01, 2008, 03:47:26 AM
Will there be a 2.0b4 version?
Title: Re: Attachment Notice
Post by: X3mE on October 20, 2008, 08:48:18 PM
Has anyone managed to get this running on 2.0b4?
Title: Re: Attachment Notice
Post by: darklord2 on November 18, 2008, 04:08:36 PM
FANTASTIC!
The Smallest Usefull Mod ever...

Translated to Persian:


<file name="$languagedir/Modifications.persian.php">
<operation>
<search position="end" />
<add><![CDATA[
// Attachment notice strings
$txt['num_disabled_attachments'] = 'این مطلب حاوی %s پیوست می باشد، برای دریافت پیوست ها باید لاگین کنید.';
]]></add>
</operation>
</file>
<file name="$languagedir/Modifications.persian-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
// Attachment notice strings
$txt['num_disabled_attachments'] = 'این مطلب حاوی %s پیوست می باشد، برای دریافت پیوست ها باید لاگین کنید.';
]]></add>
</operation>
</file>
Title: Re: Attachment Notice
Post by: X3mE on November 18, 2008, 08:06:35 PM
I still can't get it running od 2.0b4 :/
Title: Re: Attachment Notice
Post by: Dragooon on November 19, 2008, 08:34:46 AM
@X3mE - Does it show a Test failed after Dispaly.template.php?
Title: Re: Attachment Notice
Post by: X3mE on November 19, 2008, 08:39:45 AM
Quote from: Dragooon on November 19, 2008, 08:34:46 AM
@X3mE - Does it show a Test failed after Dispaly.template.php?

Yes, it does.
Title: Re: Attachment Notice
Post by: Dragooon on November 19, 2008, 08:45:49 AM
Any other file?
Title: Re: Attachment Notice
Post by: X3mE on November 19, 2008, 09:02:48 AM
No, just the display.template.php file.
Title: Re: Attachment Notice
Post by: X3mE on November 24, 2008, 11:15:23 PM
I've edited the installation script myself, replaced the search code in display.template.php and I can confirm it works on 2.0b4. Here is the modified package.
Title: Re: Attachment Notice
Post by: Dragooon on November 25, 2008, 05:42:18 AM
Thanks for that, I wasn't able to make out some time.
Title: Re: Attachment Notice
Post by: Phat^Trance on January 11, 2009, 05:19:31 AM
is it possible to ad a "register or login" link with the text? right now when a guest views a attachment they get this message:

There are 8 attachment(s) in this post which you cannot view or download
BlindVine.jpg
Bluez.jpg
HiResMesh.jpg
Knight of Silence.png


there would be  nice to have a text that says that they need to login or register to view the attachments, is that possible to add?

thx
Title: Re: Attachment Notice
Post by: FragaCampos on February 25, 2009, 11:28:21 AM
Thanks.
Very useful mod.
Title: Re: Attachment Notice
Post by: Phat^Trance on February 19, 2010, 07:42:50 AM
Bumping this thread, still need help with this:


is it possible to ad a "register or login" link with the text? right now when a guest views a attachment they get this message:

There are 8 attachment(s) in this post which you cannot view or download
BlindVine.jpg
Bluez.jpg
HiResMesh.jpg
Knight of Silence.png


there would be  nice to have a text that says that they need to login or register to view the attachments, is that possible to add?

thx
Title: Re: Attachment Notice
Post by: Apllicmz on March 03, 2010, 01:06:23 AM
when update dont forget
i see this erro
Title: Re: Attachment Notice
Post by: FragaCampos on September 07, 2010, 09:17:36 AM
Any chance of updating this to 2.0 RC3, please?
Title: Re: Attachment Notice
Post by: ehsizzup on November 09, 2010, 09:59:06 PM
Quote from: Phat^Trance on February 19, 2010, 07:42:50 AM
Bumping this thread, still need help with this:


is it possible to ad a "register or login" link with the text? right now when a guest views a attachment they get this message:

There are 8 attachment(s) in this post which you cannot view or download
BlindVine.jpg
Bluez.jpg
HiResMesh.jpg
Knight of Silence.png


there would be  nice to have a text that says that they need to login or register to view the attachments, is that possible to add?

thx

This can easily be accomplished by changing the language modification file(s) to read something like this.....

$txt['num_disabled_attachments'] = 'There are %s attachment(s) in this post which GUESTS cannot view or download.<br /><br /><font color="#444444">Please</font> <a href="' . $scripturl . '?action=login">login</a><font color="#444444"> if you are already a member or</font> <a href="' . $scripturl . '?action=register">register</a><font color="#444444"> to view attachments and unlock other advanced website features.</font><br /><br />';


I added the font color stuff, but you can kill that if you want.

Clear your SMF cache after that and you should be good to go.


PS.  Great mod.  Should be a standard feature.  Prevents confusion over missing attachments and motivates to join.
Title: Re: Attachment Notice
Post by: Neverhurry on November 14, 2010, 02:13:38 PM
Quote from: FragaCampos on September 07, 2010, 09:17:36 AM
Any chance of updating this to 2.0 RC3, please?

Please, who can help to us to manually install to 2.0 rc3? Thanks.
Title: Re: Attachment Notice
Post by: fdr77 on December 11, 2010, 06:01:37 PM
Quote from: Neverhurry on November 14, 2010, 02:13:38 PM
Quote from: FragaCampos on September 07, 2010, 09:17:36 AM
Any chance of updating this to 2.0 RC3, please?

Please, who can help to us to manually install to 2.0 rc3? Thanks.
I too would for 2.0 rc4 :)
Title: Re: Attachment Notice
Post by: 9083ja on August 09, 2011, 07:27:29 PM
mod for 2.0 final ??
Title: Re: Attachment Notice
Post by: Oldiesmann on September 11, 2011, 03:36:57 PM
Only one minor change needed to make this work with 2.0 final. The template code that it searches for has changed slightly when we went to a more semantic style. I've attached a newer version in this post: http://www.simplemachines.org/community/index.php?msg=3158102
Title: Re: Attachment Notice
Post by: Arvacon on January 12, 2014, 06:55:49 AM
Ηι. This topic is indeed old now, but I was wondering if this mod can work with the last smf version as well, after some small modifications.
Is it possible?
Title: Re: Attachment Notice
Post by: ApplianceJunk on February 01, 2014, 07:10:50 PM
I know this is a very old mod/topic but would like to see it updated for 2.0.7

Thanks,
Title: Re: Attachment Notice
Post by: ApplianceJunk on July 19, 2014, 07:18:26 PM
2.0.8 now :(
Title: Re: Attachment Notice
Post by: pobo424 on February 22, 2021, 03:24:56 AM
I try to add the "Attachment Notice" mod, the skin I use https://custom.simplemachines.org/themes/index.php?lemma=2921, modifies the ./Sources/Display.php file as it says but I get an error "mysql_fetch_assoc",

// Fetch attachments.
if (!empty($modSettings['attachmentEnable']) && allowedTo('view_attachments'))
{
$request = $smcFunc['db_query']('', '
SELECT
a.id_attach, a.id_folder, a.id_msg, a.filename, a.file_hash, IFNULL(a.size, 0) AS filesize, a.downloads, a.approved,
a.width, a.height' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : ',
IFNULL(thumb.id_attach, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height') . '
FROM {db_prefix}attachments AS a' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : '
LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = a.id_thumb)') . '
WHERE a.id_msg IN ({array_int:message_list})
AND a.attachment_type = {int:attachment_type}',
array(
'message_list' => $messages,
'attachment_type' => 0,
'is_approved' => 1,
)
);
$temp = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
continue;

$temp[$row['id_attach']] = $row;

if (!isset($attachments[$row['id_msg']]))
$attachments[$row['id_msg']] = array();
}
$smcFunc['db_free_result']($request);

// This is better than sorting it with the query...
ksort($temp);

foreach ($temp as $row)
{
$attachments[$row['id_msg']][] = $row;
}
}
elseif(!empty($modSettings['attachmentEnable']) && !allowedTo('view_attachments'))
{
$request = $smcFunc['db_query']('','
SELECT
id_msg, filename
FROM {db_prefix}attachments
WHERE ID_MSG IN ({array_int:message_list})
AND attachment_type = {int:attachment_type}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
AND approved = {int:is_approved}'),
array(
'message_list' => $messages,
'attachment_type' => 0,
'is_approved' => 1,
));
$temp = array();
while($row = mysql_fetch_assoc($request))
{
$temp[$row['filename']] = $row;
if(!isset($attachments['disabled_'.$row['id_msg']]))
$attachments['disabled_'.$row['id_msg']] = array();
}
mysql_free_result($request);

ksort($temp);

foreach($temp as $row)
$attachments['disabled_'.$row['id_msg']][] = $row;


f it modifies the code to be similar to the one above, it doesn't stick out anymore but the code doesn't work

// Fetch attachments.
if (!empty($modSettings['attachmentEnable']) && allowedTo('view_attachments'))
{
$request = $smcFunc['db_query']('', '
SELECT
a.id_attach, a.id_folder, a.id_msg, a.filename, a.file_hash, IFNULL(a.size, 0) AS filesize, a.downloads, a.approved,
a.width, a.height' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : ',
IFNULL(thumb.id_attach, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height') . '
FROM {db_prefix}attachments AS a' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : '
LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = a.id_thumb)') . '
WHERE a.id_msg IN ({array_int:message_list})
AND a.attachment_type = {int:attachment_type}',
array(
'message_list' => $messages,
'attachment_type' => 0,
'is_approved' => 1,
)
);
$temp = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
continue;

$temp[$row['id_attach']] = $row;

if (!isset($attachments[$row['id_msg']]))
$attachments[$row['id_msg']] = array();
}
$smcFunc['db_free_result']($request);

// This is better than sorting it with the query...
ksort($temp);

foreach ($temp as $row)
{
$attachments[$row['id_msg']][] = $row;
}
}
elseif(!empty($modSettings['attachmentEnable']) && !allowedTo('view_attachments'))
{
$request = $smcFunc['db_query']('','
SELECT
id_msg, filename
FROM {db_prefix}attachments
WHERE ID_MSG IN ({array_int:message_list})
AND attachment_type = {int:attachment_type}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
AND approved = {int:is_approved}'),
array(
'message_list' => $messages,
'attachment_type' => 0,
'is_approved' => 1,
));
$temp = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$temp[$row['filename']] = $row;
if(!isset($attachments['disabled_'.$row['id_msg']]))
$attachments['disabled_'.$row['id_msg']] = array();
}
$smcFunc['db_free_result']($request);

ksort($temp);

foreach($temp as $row)
{
$attachments['disabled_'.$row['id_msg']][] = $row;
}
}


I use smf 2.0.18, added translations, added in ./Themes/ SunRise/Display.template.php

if(!empty($message['disabled_attachments']))
{
echo '
<hr width="100%" size="1" class="hrcolor" />
<div style="overflow: auto; width: 100%;">
<span class="smalltext" style="color:#556B2F">',sprintf($txt['num_disabled_attachments'],$message['num_disabled_attachments']),'</span>';
foreach($message['disabled_attachments'] as $attachment)
echo '<div style="color:#556B2F">',$attachment['filename'],'</div>';
echo '</div>';
}

echo '

<div class="moderatorbar">
<div class="smalltext modified" id="modified_', $message['id'], '">';


could someone verify the code for which the mod does not work? is there any alternative? thanks in advance for your help and attention