mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
show the attach icon in viewforum. added cached extensions (we need them within viewtopic)
git-svn-id: file:///svn/phpbb/trunk@3777 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
d054df5007
commit
8a04466b3f
6 changed files with 93 additions and 59 deletions
|
@ -200,7 +200,7 @@ function gen_forum_rules($mode, &$forum_id)
|
|||
{
|
||||
global $SID, $template, $auth, $user;
|
||||
|
||||
$rules = array('post', 'reply', 'edit', 'delete', 'attach');
|
||||
$rules = array('post', 'reply', 'edit', 'delete', 'attach', 'download');
|
||||
|
||||
foreach ($rules as $rule)
|
||||
{
|
||||
|
@ -773,6 +773,41 @@ function obtain_icons(&$icons)
|
|||
return;
|
||||
}
|
||||
|
||||
// Obtain allowed extensions
|
||||
function obtain_attach_extensions(&$extensions)
|
||||
{
|
||||
global $db, $cache;
|
||||
|
||||
if ($cache->exists('extensions'))
|
||||
{
|
||||
$extensions = $cache->get('extensions');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't count on forbidden extensions table, because it is not allowed to allow forbidden extensions at all
|
||||
$sql = "SELECT e.extension, g.cat_id, g.download_mode, g.upload_icon
|
||||
FROM " . EXTENSIONS_TABLE . " e, " . EXTENSION_GROUPS_TABLE . " g
|
||||
WHERE e.group_id = g.group_id
|
||||
AND g.allow_group = 1";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$extensions = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$extension = strtolower(trim($row['extension']));
|
||||
|
||||
$extensions[$extension]['display_cat'] = intval($row['cat_id']);
|
||||
$extensions[$extension]['download_mode'] = intval($row['download_mode']);
|
||||
$extensions[$extension]['upload_icon'] = trim($row['upload_icon']);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$cache->put('extensions', $extensions);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function generate_board_url()
|
||||
{
|
||||
global $config;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -193,6 +193,7 @@ CREATE TABLE phpbb_extension_groups (
|
|||
cat_id tinyint(2) DEFAULT '0' NOT NULL,
|
||||
allow_group tinyint(1) DEFAULT '0' NOT NULL,
|
||||
download_mode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
|
||||
upload_icon varchar(100) DEFAULT '',
|
||||
max_filesize int(20) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (group_id)
|
||||
);
|
||||
|
|
|
@ -58,11 +58,11 @@
|
|||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr align="left" valign="middle">
|
||||
<td><!-- IF topicrow.S_TOPIC_UNAPPROVED --><a href="{topicrow.U_MCP_QUEUE}">{UNAPPROVED_IMG}</a> <!-- ENDIF --><!-- IF topicrow.S_TOPIC_REPORTED --><a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a> <!-- ENDIF --></td>
|
||||
<td width="100%"><span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />{topicrow.GOTO_PAGE}</td>
|
||||
<td width="100%"><span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.ATTACH_ICON_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />{topicrow.GOTO_PAGE}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- ELSE -->
|
||||
<span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />{topicrow.GOTO_PAGE}</span>
|
||||
<span class="topictitle">{topicrow.NEWEST_POST_IMG}{topicrow.ATTACH_ICON_IMG}{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></span><span class="gensmall"><br />{topicrow.GOTO_PAGE}</span>
|
||||
<!-- ENDIF -->
|
||||
</td>
|
||||
<td class="row2" align="center" valign="middle"><span class="name">{topicrow.TOPIC_AUTHOR}</span></td>
|
||||
|
|
|
@ -461,6 +461,7 @@ if ($forum_data['forum_postable'])
|
|||
'NEWEST_POST_IMG' => $newest_post_img,
|
||||
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
||||
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? '<img src="' . $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] . '" width="' . $icons[$row['icon_id']]['width'] . '" height="' . $icons[$row['icon_id']]['height'] . '" alt="" title="" />' : '',
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_attach', '') : '',
|
||||
|
||||
'S_ROW_COUNT' => $i,
|
||||
'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test,
|
||||
|
|
|
@ -715,7 +715,7 @@ if ($row = $db->sql_fetchrow($result))
|
|||
|
||||
|
||||
// Does post have an attachment? If so, add it to the list
|
||||
if ($row['post_attach'])
|
||||
if ($row['post_attachment'])
|
||||
{
|
||||
$attach_list[] = $post_id;
|
||||
}
|
||||
|
@ -890,25 +890,21 @@ else
|
|||
trigger_error($user->lang['NO_TOPIC']);
|
||||
}
|
||||
|
||||
|
||||
// If we have attachments, grab them ... based on Acyd Burns 2.0.x Mod
|
||||
// If we have attachments, grab them ...
|
||||
if (sizeof($attach_list))
|
||||
{
|
||||
$sql = "SELECT a.post_id, d.*
|
||||
FROM " . ATTACHMENTS_TABLE . " a, " . ATTACHMENTS_DESC_TABLE . " d
|
||||
WHERE a.post_id IN (" . implode(', ', $attach_list) . ")
|
||||
AND a.attach_id = d.attach_id
|
||||
ORDER BY d.filetime " . $display_order;
|
||||
ORDER BY d.filetime " . ((!$config['display_order']) ? "ASC" : "DESC");
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$extensions = array();
|
||||
obtain_attach_extensions($extensions);
|
||||
|
||||
if ($db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'L_POSTED_ATTACHMENTS' => $lang['Posted_attachments'],
|
||||
'L_KILOBYTE' => $lang['KB'])
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -920,9 +916,12 @@ if (sizeof($attach_list))
|
|||
// No attachments exist, but post table thinks they do
|
||||
// so go ahead and reset post_attach flags
|
||||
$sql = "UPDATE " . POSTS_TABLE . "
|
||||
SET post_attach = 0
|
||||
SET post_attachment = 0
|
||||
WHERE post_id IN (" . implode(', ', $attach_list) . ")";
|
||||
$db->sql_query($sql);
|
||||
|
||||
// We need to update the topic indicator too if the
|
||||
// complete topic is now without an attachment
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue