[ Index ] |
PHP Cross Reference of phpBB 3.0 Beta 3 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * @package ucp 5 * @version $Id: ucp_attachments.php,v 1.23 2006/10/30 16:19:20 acydburn Exp $ 6 * @copyright (c) 2005 phpBB Group 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 8 * 9 */ 10 11 /** 12 * ucp_attachments 13 * User attachments 14 * @package ucp 15 */ 16 class ucp_attachments 17 { 18 var $u_action; 19 20 function main($id, $mode) 21 { 22 global $template, $user, $db, $config, $phpEx, $phpbb_root_path; 23 24 $start = request_var('start', 0); 25 $sort_key = request_var('sk', 'a'); 26 $sort_dir = request_var('sd', 'a'); 27 28 $delete = (isset($_POST['delete'])) ? true : false; 29 $confirm = (isset($_POST['confirm'])) ? true : false; 30 $delete_ids = isset($_REQUEST['attachment']) ? array_keys(array_map('intval', $_REQUEST['attachment'])) : array(); 31 32 if ($delete && sizeof($delete_ids)) 33 { 34 $s_hidden_fields = array( 35 'delete' => 1 36 ); 37 38 foreach ($delete_ids as $attachment_id) 39 { 40 $s_hidden_fields['attachment'][$attachment_id] = 1; 41 } 42 43 if (confirm_box(true)) 44 { 45 if (!function_exists('delete_attachments')) 46 { 47 include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); 48 } 49 delete_attachments('attach', $delete_ids); 50 51 meta_refresh(3, $this->u_action); 52 $message = ((sizeof($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); 53 trigger_error($message); 54 } 55 else 56 { 57 confirm_box(false, (sizeof($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields)); 58 } 59 } 60 61 // Select box eventually 62 $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']); 63 $sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.attach_comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title'); 64 65 $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); 66 67 $s_sort_key = ''; 68 foreach ($sort_key_text as $key => $value) 69 { 70 $selected = ($sort_key == $key) ? ' selected="selected"' : ''; 71 $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; 72 } 73 74 $s_sort_dir = ''; 75 foreach ($sort_dir_text as $key => $value) 76 { 77 $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; 78 $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; 79 } 80 81 if (!isset($sort_key_sql[$sort_key])) 82 { 83 $sort_key = 'a'; 84 } 85 86 $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); 87 88 $sql = 'SELECT COUNT(attach_id) as num_attachments 89 FROM ' . ATTACHMENTS_TABLE . ' 90 WHERE poster_id = ' . $user->data['user_id'] . ' 91 AND is_orphan = 0'; 92 $result = $db->sql_query($sql); 93 $num_attachments = $db->sql_fetchfield('num_attachments'); 94 $db->sql_freeresult($result); 95 96 $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title 97 FROM ' . ATTACHMENTS_TABLE . ' a 98 LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) 99 LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1) 100 WHERE a.poster_id = ' . $user->data['user_id'] . " 101 AND a.is_orphan = 0 102 ORDER BY $order_by"; 103 $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); 104 105 $row_count = 0; 106 if ($row = $db->sql_fetchrow($result)) 107 { 108 $template->assign_var('S_ATTACHMENT_ROWS', true); 109 110 do 111 { 112 if ($row['in_message']) 113 { 114 $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}"); 115 } 116 else 117 { 118 $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}"; 119 } 120 121 $template->assign_block_vars('attachrow', array( 122 'ROW_NUMBER' => $row_count + ($start + 1), 123 'FILENAME' => $row['real_filename'], 124 'COMMENT' => str_replace("\n", '<br />', $row['attach_comment']), 125 'EXTENSION' => $row['extension'], 126 'SIZE' => ($row['filesize'] >= 1048576) ? ($row['filesize'] >> 20) . ' ' . $user->lang['MB'] : (($row['filesize'] >= 1024) ? ($row['filesize'] >> 10) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']), 127 'DOWNLOAD_COUNT' => $row['download_count'], 128 'POST_TIME' => $user->format_date($row['filetime']), 129 'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'], 130 131 'ATTACH_ID' => $row['attach_id'], 132 'POST_ID' => $row['post_msg_id'], 133 'TOPIC_ID' => $row['topic_id'], 134 135 'S_IN_MESSAGE' => $row['in_message'], 136 137 'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download.$phpEx", 'id=' . $row['attach_id']), 138 'U_VIEW_TOPIC' => $view_topic) 139 ); 140 141 $row_count++; 142 } 143 while ($row = $db->sql_fetchrow($result)); 144 } 145 $db->sql_freeresult($result); 146 147 $template->assign_vars(array( 148 'PAGE_NUMBER' => on_page($num_attachments, $config['topics_per_page'], $start), 149 'PAGINATION' => generate_pagination($this->u_action . "&sk=$sort_key&sd=$sort_dir", $num_attachments, $config['topics_per_page'], $start), 150 'TOTAL_ATTACHMENTS' => $num_attachments, 151 152 'L_TITLE' => $user->lang['UCP_ATTACHMENTS'], 153 154 'U_SORT_FILENAME' => $this->u_action . "&sk=a&sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), 155 'U_SORT_FILE_COMMENT' => $this->u_action . "&sk=b&sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), 156 'U_SORT_EXTENSION' => $this->u_action . "&sk=c&sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'), 157 'U_SORT_FILESIZE' => $this->u_action . "&sk=d&sd=" . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'), 158 'U_SORT_DOWNLOADS' => $this->u_action . "&sk=e&sd=" . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'), 159 'U_SORT_POST_TIME' => $this->u_action . "&sk=f&sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'), 160 'U_SORT_TOPIC_TITLE' => $this->u_action . "&sk=g&sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'), 161 162 'S_DISPLAY_MARK_ALL' => ($num_attachments) ? true : false, 163 'S_DISPLAY_PAGINATION' => ($num_attachments) ? true : false, 164 'S_UCP_ACTION' => $this->u_action, 165 'S_SORT_OPTIONS' => $s_sort_key, 166 'S_ORDER_SELECT' => $s_sort_dir) 167 ); 168 169 $this->tpl_name = 'ucp_attachments'; 170 $this->page_title = 'UCP_ATTACHMENTS'; 171 } 172 } 173 174 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 22 00:35:05 2006 | Cross-referenced by PHPXref 0.6 |