UCP -> Attachments

git-svn-id: file:///svn/phpbb/trunk@4652 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-11-06 15:05:50 +00:00
parent 75ccd0e13c
commit 558b8ee7ff
6 changed files with 243 additions and 4 deletions

View file

@ -0,0 +1,152 @@
<?php
// -------------------------------------------------------------
//
// $Id$
//
// FILENAME : ucp_attachments.php
// STARTED : Mon Nov 03, 2003
// COPYRIGHT : © 2001, 2003 phpBB Group
// WWW : http://www.phpbb.com/
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
//
// -------------------------------------------------------------
//
// * Use this for ucp integration - changeable user id
//
class ucp_attachments extends module
{
function ucp_attachments($id, $mode)
{
global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $SID;
$start = request_var('start', 0);
$delete = (isset($_POST['delete'])) ? true : false;
$confirm = (isset($_POST['confirm'])) ? true : false;
$delete_ids = isset($_REQUEST['attachment']) ? array_keys(array_map('intval', $_REQUEST['attachment'])) : array();
if ($delete && $confirm && sizeof($delete_ids))
{
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
delete_attachments('attach', $delete_ids);
meta_refresh(3, "ucp.$phpEx$SID&amp;i=$id");
$message = ((sizeof($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id\">", '</a>');
trigger_error($message);
}
else if ($delete && sizeof($delete_ids))
{
$s_hidden_fields = '<input type="hidden" name="delete" value="1" />';
foreach ($delete_ids as $attachment_id)
{
$s_hidden_fields .= '<input type="hidden" name="attachment[' . $attachment_id . ']" value="1" />';
}
// Confirm Attachment Deletion
$template->assign_vars(array(
'S_CONFIRM_DELETE' => true,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'L_TITLE' => $user->lang['UCP_ATTACH'],
'MESSAGE_TITLE' => $user->lang['CONFIRM'],
'MESSAGE_TEXT' => (sizeof($delete_ids) == 1) ? $user->lang['CONFIRM_DELETE_ATTACHMENT'] : $user->lang['CONFIRM_DELETE_ATTACHMENTS'],
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id")
);
$this->display($user->lang['UCP_ATTACHMENTS'], 'ucp_attachments.html');
exit;
}
$sort_key = request_var('sk', 'a');
$sort_dir = request_var('sd', 'a');
// Select box eventually
$sort_key_text = array('a' => $user->lang['SORT_FILENAME'], 'b' => $user->lang['SORT_COMMENT'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']);
$sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title');
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
$s_sort_key = '';
foreach ($sort_key_text as $key => $value)
{
$selected = ($sort_key == $key) ? ' selected="selected"' : '';
$s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
$s_sort_dir = '';
foreach ($sort_dir_text as $key => $value)
{
$selected = ($sort_dir == $key) ? ' selected="selected"' : '';
$s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
$order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
$sql = 'SELECT COUNT(*) as num_attachments
FROM ' . ATTACHMENTS_TABLE . '
WHERE poster_id = ' . $user->data['user_id'];
$result = $db->sql_query_limit($sql, 1);
$num_attachments = $db->sql_fetchfield('num_attachments', 0, $result);
$db->sql_freeresult($result);
$sql = 'SELECT a.*, t.topic_title
FROM ' . ATTACHMENTS_TABLE . ' a, ' . TOPICS_TABLE . ' t
WHERE a.topic_id = t.topic_id
AND a.poster_id = ' . $user->data['user_id'] . '
ORDER BY ' . $order_by;
$result = $db->sql_query_limit($sql, $config['posts_per_page'], $start);
$i = 0;
while ($row = $db->sql_fetchrow($result))
{
$topic_title = (strlen($row['topic_title']) > 32) ? substr($row['topic_title'], 0, 30) . '...' : $row['topic_title'];
$view_topic = "{$phpbb_root_path}viewtopic.$phpEx$SID&amp;t=" . $row['topic_id'] . '&amp;p=' . $row['post_id'] . '#' . $row['post_id'];
$topic_title = '<a href="' . $view_topic . '" class="gen" target="_blank">' . $topic_title . '</a>';
$template->assign_block_vars('attachrow', array(
'ROW_NUMBER' => $i + ($start + 1),
'S_ROW_COUNT' => $i,
'ATTACH_ID' => $row['attach_id'],
'FILENAME' => $row['real_filename'],
'COMMENT' => str_replace("\n", '<br />', $row['comment']),
'EXTENSION' => $row['extension'],
'SIZE' => ($row['filesize'] >= 1048576) ? (round($row['filesize'] / 1048576 * 100) / 100) . ' ' . $user->lang['MB'] : (($row['filesize'] >= 1024) ? (round($row['filesize'] / 1024 * 100) / 100) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']),
'DOWNLOAD_COUNT' => $row['download_count'],
'POST_TIME' => $user->format_date($row['filetime'], $user->lang['DATE_FORMAT']),
'TOPIC_TITLE' => $topic_title,
'U_VIEW_ATTACHMENT' => $phpbb_root_path . 'download.' . $phpEx . $SID . '&amp;id=' . $row['attach_id'])
);
$i++;
}
$db->sql_freeresult($result);
$template->assign_vars(array(
'PAGE_NUMBER' => on_page($num_attachments, $config['posts_per_page'], $start),
'PAGINATION' => generate_pagination("ucp.$phpEx$SID&amp;i=$id&amp;sk=$sort_key&amp;sd=$sort_dir", $num_attachments, $config['posts_per_page'], $start),
'L_TITLE' => $user->lang['UCP_ATTACH'],
'U_SORT_FILENAME' => "ucp.$phpEx$SID&amp;i=$id&amp;sk=a&amp;sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_FILE_COMMENT' => "ucp.$phpEx$SID&amp;i=$id&amp;sk=b&amp;sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_EXTENSION' => "ucp.$phpEx$SID&amp;i=$id&amp;sk=c&amp;sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_FILESIZE' => "ucp.$phpEx$SID&amp;i=$id&amp;sk=d&amp;sd=" . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_DOWNLOADS' => "ucp.$phpEx$SID&amp;i=$id&amp;sk=e&amp;sd=" . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_POST_TIME' => "ucp.$phpEx$SID&amp;i=$id&amp;sk=f&amp;sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_TOPIC_TITLE' => "ucp.$phpEx$SID&amp;i=$id&amp;sk=g&amp;sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
'S_DISPLAY_MARK_ALL' => ($num_attachments) ? true : false,
'S_DISPLAY_PAGINATION' => ($num_attachments) ? true : false,
'S_UCP_ACTION' => "ucp.$phpEx$SID&amp;i=$id",
'S_SORT_OPTIONS' => $s_sort_key,
'S_ORDER_SELECT' => $s_sort_dir)
);
$this->display($user->lang['UCP_ATTACHMENTS'], 'ucp_attachments.html');
}
}
?>

View file

@ -383,6 +383,7 @@ INSERT INTO phpbb_modules (module_type, module_title, module_filename, module_or
INSERT INTO phpbb_modules (module_type, module_title, module_filename, module_order, module_enabled, module_subs, module_acl) VALUES ('ucp', 'PROFILE', 'profile', 2, 1, 'profile_info\r\nreg_details\r\nsignature\r\navatar', '');
INSERT INTO phpbb_modules (module_type, module_title, module_filename, module_order, module_enabled, module_subs, module_acl) VALUES ('ucp', 'PREFS', 'prefs', 3, 1, 'personal\r\nview\r\npost', '');
INSERT INTO phpbb_modules (module_type, module_title, module_filename, module_order, module_enabled, module_subs, module_acl) VALUES ('ucp', 'ZEBRA', 'zebra', 4, 1, 'friends\r\nfoes', '');
INSERT INTO phpbb_modules (module_type, module_title, module_filename, module_order, module_enabled, module_subs, module_acl) VALUES ('ucp', 'ATTACHMENTS', 'attachments', 5, 1, '', 'u_attach');
# MSSQL IDENTITY phpbb_modules OFF #

View file

@ -1678,7 +1678,6 @@ $lang += array(
'MANAGE_EXTENSIONS' => 'Manage Extensions',
'MANAGE_EXTENSIONS_EXPLAIN' => 'Here you can manage your allowed extensions. To activate your Extensions, please refer to the extension groups management panel. We strongly recommend not to allow scripting extensions (such as php, php3, php4, phtml, pl, cgi, asp, aspx...)',
'EXTENSION' => 'Extension',
'ADD_EXTENSION' => 'Add extension',
'EXTENSIONS_UPDATED' => 'Extensions successfully updated',
'EXTENSION_EXIST' => 'The Extension %s already exist',

View file

@ -455,7 +455,8 @@ $lang += array(
'ALL_POSTS' => 'All Posts',
'BACK_TO_TOP' => 'Top',
'POST_SUBJECT' => 'Post subject',
'POST_SUBJECT' => 'Post Subject',
'TOPIC_TITLE' => 'Topic Title',
'KARMA_LEVEL' => 'Karma Level',
'READ_PROFILE' => 'Profile',
'SEND_EMAIL' => 'Email',
@ -569,7 +570,6 @@ $lang += array(
'LOCK_POST' => 'Lock Post',
'LOCK_POST_EXPLAIN' => 'Prevent editing',
'CONFIRM_DELETE' => 'Are you sure you want to delete this post?',
'CANNOT_EDIT_TIME' => 'You can no longer edit or delete that post',
'CANNOT_EDIT_POST_LOCKED' => 'This post has been locked. You can no longer edit that post.',
'FLOOD_ERROR' => 'You cannot make another post so soon after your last.',
@ -677,6 +677,7 @@ $lang += array(
'EXTENSION_DISABLED_AFTER_POSTING' => 'The extension <b>%s</b> has been deactivated and can no longer be displayed.', // used in Posts and PM's, replace %s with extension
'DESCRIPTION' => 'Description',
'DOWNLOAD' => 'Download',
'DOWNLOADS' => 'Downloads',
'FILESIZE' => 'Filesize',
'FILE_NOT_FOUND_404' => 'The file <b>%s</b> does not exist.',
'DOWNLOADED' => 'Downloaded',
@ -851,6 +852,26 @@ $lang += array(
'WRONG_ACTIVATION' => 'The activation key you supplied does not match any in the database',
);
// ucp_attachments
$lang += array(
'CONFIRM_DELETE_ATTACHMENT' => 'Are you sure you want to delete this attachment?',
'CONFIRM_DELETE_ATTACHMENTS'=> 'Are you sure you want to delete these attachments?',
'ATTACHMENT_DELETED' => 'Attachment successfully deleted',
'ATTACHMENTS_DELETED' => 'Attachments successfully deleted',
'EXTENSION' => 'Extension',
'SORT_FILENAME' => 'Filename',
'SORT_COMMENT' => 'File Comment',
'SORT_EXTENSION' => 'Extension',
'SORT_SIZE' => 'Filesize',
'SORT_DOWNLOADS' => 'Downloads',
'SORT_POST_TIME' => 'Post Time',
'SORT_TOPIC_TITLE' => 'Topic Title',
'UCP_NO_ATTACHMENTS' => 'You have posted no files'
);
// ucp_remind
$lang += array(
'SEND_PASSWORD' => 'Send password',

View file

@ -336,7 +336,7 @@ if ($mode == 'delete' && (($poster_id == $user->data['user_id'] && $user->data['
$template->assign_vars(array(
'MESSAGE_TITLE' => $user->lang['DELETE_MESSAGE'],
'MESSAGE_TEXT' => $user->lang['CONFIRM_DELETE'],
'MESSAGE_TEXT' => $user->lang['CONFIRM_DELETE_POST'],
'S_CONFIRM_ACTION' => "posting.$phpEx$SID",
'S_HIDDEN_FIELDS' => $s_hidden_fields)

View file

@ -0,0 +1,66 @@
<!-- $Id$ -->
<!-- INCLUDE ucp_header.html -->
<!-- IF S_CONFIRM_DELETE -->
<table class="tablebg" width="80%" cellspacing="1" cellpadding="4" border="0" align="right">
<tr>
<th height="28" valign="middle">{MESSAGE_TITLE}</th>
</tr>
<tr>
<td class="row1" align="center"><span class="gen"><br />{MESSAGE_TEXT}<br /><br />{S_HIDDEN_FIELDS}<input type="submit" name="confirm" value="{L_YES}" class="btnmain" />&nbsp;&nbsp;<input type="submit" name="cancel" value="{L_NO}" class="btnlite" /></span></td>
</tr>
</table>
<!-- ELSEIF attachrow -->
<table class="tablebg" width="80%" cellspacing="1" cellpadding="4" border="0" align="right">
<tr>
<th height="28" nowrap="nowrap">#</th>
<th nowrap="nowrap" width="15%"><a class="th" href="{U_SORT_FILENAME}">{L_FILENAME}</a></th>
<th nowrap="nowrap" width="25%"><a class="th" href="{U_SORT_FILE_COMMENT}">{L_FILE_COMMENT}</a></th>
<th nowrap="nowrap" width="5%"><a class="th" href="{U_SORT_EXTENSION}">{L_EXTENSION}</a></th>
<th nowrap="nowrap" width="5%"><a class="th" href="{U_SORT_FILESIZE}">{L_FILESIZE}</a></th>
<th nowrap="nowrap" width="5%"><a class="th" href="{U_SORT_DOWNLOADS}">{L_DOWNLOADS}</a></th>
<th nowrap="nowrap" width="5%"><a class="th" href="{U_SORT_POST_TIME}">{L_POST_TIME}</a></th>
<th nowrap="nowrap" width="15%"><a class="th" href="{U_SORT_TOPIC_TITLE}">{L_TOPIC_TITLE}</a></th>
<th width="2%" nowrap="nowrap">{L_DELETE}</th>
</tr>
<!-- BEGIN attachrow -->
<!-- IF attach.S_ROW_COUNT is even -->
<tr class="row2">
<!-- ELSE -->
<tr class="row1">
<!-- ENDIF -->
<td class="gen" align="center" width="2%">&nbsp;{attachrow.ROW_NUMBER}&nbsp;</td>
<td class="gen" align="center"><a href="{attachrow.U_VIEW_ATTACHMENT}" target="file">{attachrow.FILENAME}</a></td>
<td class="gen" align="center">{attachrow.COMMENT}</td>
<td class="gen" align="center">{attachrow.EXTENSION}</td>
<td class="gen" align="center" valign="middle" nowrap="nowrap">{attachrow.SIZE}</td>
<td class="gen" align="center">{attachrow.DOWNLOAD_COUNT}</td>
<td class="gensmall" align="center" valign="middle" nowrap="nowrap">&nbsp;{attachrow.POST_TIME}&nbsp;</td>
<td class="gen" align="center">{attachrow.TOPIC_TITLE}</td>
<td align="center" valign="middle"><input type="checkbox" name="attachment[{attachrow.ATTACH_ID}]" value="1" /></td>
</tr>
<!-- END attachrow -->
<tr>
<td class="cat" colspan="7" height="28"><div align="center"><span class="gen">{L_SORT_BY}: </span><select name="sk">{S_SORT_OPTIONS}</select> <select name="sd">{S_ORDER_SELECT}</select>&nbsp;<input type="submit" name="sort" value="{L_SORT}" class="btnlite" /></div></td>
<td class="cat" colspan="2" height="28" align="right"><input type="submit" name="delete" value="{L_DELETE_MARKED}" class="btnlite" /></td>
</tr>
</table>
<!-- ELSE -->
<table class="tablebg" width="80%" cellspacing="1" cellpadding="4" border="0" align="right">
<tr>
<th>{L_UCP_NO_ATTACHMENTS}</th>
</tr>
</table>
<!-- ENDIF -->
<!-- INCLUDE ucp_footer.html -->