SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: quantumeventgames on February 10, 2010, 06:50:34 PM

Title: Download System Block
Post by: quantumeventgames on February 10, 2010, 06:50:34 PM
Hi,

I'm having some trouble with a modified Download System block. I want to honor the user permissions and not display files that the current user does not have a right to see. Can someone with more experience than I look over this and comment as to what maybe wrong. Thanks

Also, I'm now having problems adding code to a php block. At first I could add without any problems. Now if I add something as simple as:

Code: [Select]
echo "test";
I get the syntax error in your code message.  Frustrating. Any idea on this? Now I have to use phpMyAdmin and directly insert the code.

Code: [Select]
global $db_prefix, $scripturl, $smcFunc;

global $user_info;

if (!$context['user']['is_guest'])
$groupsdata = implode($user_info['groups'],',');
else
$groupsdata = -1;

$request = $smcFunc['db_query']('',"SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.title AS ftitle,
c.title, m.real_Name, m.ID_MEMBER AS mID_MEMBER
FROM ({db_prefix}down_file AS f, {db_prefix}down_cat AS )
LEFT JOIN {db_prefix}members AS m  ON (f.ID_MEMBER = m.ID_MEMBER)
LEFT JOIN {db_prefix}down_catperm AS c ON (c.ID_GROUP IN ($groupsdata) AND c.ID_CAT = f.ID_CAT)

WHERE f.ID_CAT = c.ID_CAT
AND f.approved = '1'
AND (c.view IS NULL || c.view =1) GROUP by f.ID_FILE
ORDER BY f.ID_FILE DESC
LIMIT 35");
while($row = $smcFunc['db_fetch_assoc']($request)) {
echo '<table width="100%" cellpadding="2" cellspacing="0">
<tr>
<td valign="top" class="smalltext">', sp_embed_image('dot'), ' <a href="',$scripturl,'?action=downloads;sa=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a></td>
<td valign="top" class="smalltext" align="right">',$row['totaldownloads'],'</td>
</tr>
</table>';
}
Title: Re: Download System Block
Post by: quantumeventgames on February 11, 2010, 08:29:24 PM
Ok, this updated version will honor permissions.

Code: [Select]
global $db_prefix, $scripturl, $smcFunc;

global $user_info;

if (!$context['user']['is_guest'])
$groupsdata = implode($user_info['groups'],',');
else
$groupsdata = -1;

$request = $smcFunc['db_query']('',"SELECT f.ID_FILE, f.ID_MEMBER, f.date, f.ID_CAT, f.title AS ftitle, f.totaldownloads, f.views,
c.title, m.real_Name, m.ID_MEMBER AS mID_MEMBER
FROM ({db_prefix}down_file AS f, {db_prefix}down_cat AS c)
LEFT JOIN {db_prefix}members AS m  ON (f.ID_MEMBER = m.ID_MEMBER)
LEFT JOIN {db_prefix}down_catperm AS p ON (p.ID_GROUP IN ($groupsdata) AND p.ID_CAT = f.ID_CAT)

WHERE f.ID_CAT = c.ID_CAT
AND f.approved = '1'
AND (p.view IS NULL || p.view =1) GROUP by f.ID_FILE
ORDER BY f.ID_FILE DESC
LIMIT 35
");
while($row = mysql_fetch_assoc($request)) {
echo '<table width="100%" cellpadding="2" cellspacing="0">
<tr>
<td valign="top" class="smalltext">', sp_embed_image('dot'), '  <a href="',$scripturl,'?action=downloads;sa=view;id=',$row['ID_FILE'],'">',$row['ftitle'],'</a></td>
<td valign="top" class="smalltext" align="right">',$row['totaldownloads'],'/',$row['views'], '</td>
</tr>
</table>';
}
Title: Re: Download System Block
Post by: MrSir88 on February 23, 2010, 09:50:19 AM
Where is the actual code for the downloads block?  I must have overlooked it.
SimplePortal 2.3.8 © 2008-2024, SimplePortal