News:

Wondering if this will always be free?  See why free is better.

Main Menu

Attachment Notice

Started by live627, May 13, 2008, 01:32:13 AM

Previous topic - Next topic

FragaCampos

Any chance of updating this to 2.0 RC3, please?

ehsizzup

#21
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.

Neverhurry

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 am using SMF 2.0.1, curve themes.

fdr77

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 :)

9083ja


Oldiesmann

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
Michael Eshom
Christian Metal Fans

Arvacon

Ηι. 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?

ApplianceJunk

I know this is a very old mod/topic but would like to see it updated for 2.0.7

Thanks,


pobo424

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

Advertisement: