[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 /** 15 * @ignore 16 */ 17 if (!defined('IN_PHPBB')) 18 { 19 exit; 20 } 21 22 /** 23 * ucp_attachments 24 * User attachments 25 */ 26 class ucp_attachments 27 { 28 var $u_action; 29 30 function main($id, $mode) 31 { 32 global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container; 33 34 $start = request_var('start', 0); 35 $sort_key = request_var('sk', 'a'); 36 $sort_dir = request_var('sd', 'a'); 37 38 $delete = (isset($_POST['delete'])) ? true : false; 39 $confirm = (isset($_POST['confirm'])) ? true : false; 40 $delete_ids = array_keys(request_var('attachment', array(0))); 41 42 if ($delete && sizeof($delete_ids)) 43 { 44 // Validate $delete_ids... 45 $sql = 'SELECT attach_id 46 FROM ' . ATTACHMENTS_TABLE . ' 47 WHERE poster_id = ' . $user->data['user_id'] . ' 48 AND is_orphan = 0 49 AND ' . $db->sql_in_set('attach_id', $delete_ids); 50 $result = $db->sql_query($sql); 51 52 $delete_ids = array(); 53 while ($row = $db->sql_fetchrow($result)) 54 { 55 $delete_ids[] = $row['attach_id']; 56 } 57 $db->sql_freeresult($result); 58 } 59 60 if ($delete && sizeof($delete_ids)) 61 { 62 $s_hidden_fields = array( 63 'delete' => 1 64 ); 65 66 foreach ($delete_ids as $attachment_id) 67 { 68 $s_hidden_fields['attachment'][$attachment_id] = 1; 69 } 70 71 if (confirm_box(true)) 72 { 73 if (!function_exists('delete_attachments')) 74 { 75 include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); 76 } 77 78 delete_attachments('attach', $delete_ids); 79 80 meta_refresh(3, $this->u_action); 81 $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>'); 82 trigger_error($message); 83 } 84 else 85 { 86 confirm_box(false, (sizeof($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields)); 87 } 88 } 89 90 // Select box eventually 91 $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']); 92 $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'); 93 94 $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); 95 96 $s_sort_key = ''; 97 foreach ($sort_key_text as $key => $value) 98 { 99 $selected = ($sort_key == $key) ? ' selected="selected"' : ''; 100 $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; 101 } 102 103 $s_sort_dir = ''; 104 foreach ($sort_dir_text as $key => $value) 105 { 106 $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; 107 $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>'; 108 } 109 110 if (!isset($sort_key_sql[$sort_key])) 111 { 112 $sort_key = 'a'; 113 } 114 115 $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'); 116 117 $sql = 'SELECT COUNT(attach_id) as num_attachments 118 FROM ' . ATTACHMENTS_TABLE . ' 119 WHERE poster_id = ' . $user->data['user_id'] . ' 120 AND is_orphan = 0'; 121 $result = $db->sql_query($sql); 122 $num_attachments = $db->sql_fetchfield('num_attachments'); 123 $db->sql_freeresult($result); 124 125 // Ensure start is a valid value 126 $pagination = $phpbb_container->get('pagination'); 127 $start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments); 128 129 $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title 130 FROM ' . ATTACHMENTS_TABLE . ' a 131 LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) 132 LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1) 133 WHERE a.poster_id = ' . $user->data['user_id'] . " 134 AND a.is_orphan = 0 135 ORDER BY $order_by"; 136 $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); 137 138 $row_count = 0; 139 if ($row = $db->sql_fetchrow($result)) 140 { 141 $template->assign_var('S_ATTACHMENT_ROWS', true); 142 143 do 144 { 145 if ($row['in_message']) 146 { 147 $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&p={$row['post_msg_id']}"); 148 } 149 else 150 { 151 $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}"; 152 } 153 154 $template->assign_block_vars('attachrow', array( 155 'ROW_NUMBER' => $row_count + ($start + 1), 156 'FILENAME' => $row['real_filename'], 157 'COMMENT' => bbcode_nl2br($row['attach_comment']), 158 'EXTENSION' => $row['extension'], 159 'SIZE' => get_formatted_filesize($row['filesize']), 160 'DOWNLOAD_COUNT' => $row['download_count'], 161 'POST_TIME' => $user->format_date($row['filetime']), 162 'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'], 163 164 'ATTACH_ID' => $row['attach_id'], 165 'POST_ID' => $row['post_msg_id'], 166 'TOPIC_ID' => $row['topic_id'], 167 168 'S_IN_MESSAGE' => $row['in_message'], 169 170 'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']), 171 'U_VIEW_TOPIC' => $view_topic) 172 ); 173 174 $row_count++; 175 } 176 while ($row = $db->sql_fetchrow($result)); 177 } 178 $db->sql_freeresult($result); 179 180 $base_url = $this->u_action . "&sk=$sort_key&sd=$sort_dir"; 181 $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); 182 183 $template->assign_vars(array( 184 'TOTAL_ATTACHMENTS' => $num_attachments, 185 'NUM_ATTACHMENTS' => $user->lang('NUM_ATTACHMENTS', $num_attachments), 186 187 'L_TITLE' => $user->lang['UCP_ATTACHMENTS'], 188 189 'U_SORT_FILENAME' => $this->u_action . "&sk=a&sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), 190 'U_SORT_FILE_COMMENT' => $this->u_action . "&sk=b&sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'), 191 'U_SORT_EXTENSION' => $this->u_action . "&sk=c&sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'), 192 'U_SORT_FILESIZE' => $this->u_action . "&sk=d&sd=" . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'), 193 'U_SORT_DOWNLOADS' => $this->u_action . "&sk=e&sd=" . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'), 194 'U_SORT_POST_TIME' => $this->u_action . "&sk=f&sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'), 195 'U_SORT_TOPIC_TITLE' => $this->u_action . "&sk=g&sd=" . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'), 196 197 'S_DISPLAY_MARK_ALL' => ($num_attachments) ? true : false, 198 'S_DISPLAY_PAGINATION' => ($num_attachments) ? true : false, 199 'S_UCP_ACTION' => $this->u_action, 200 'S_SORT_OPTIONS' => $s_sort_key, 201 'S_ORDER_SELECT' => $s_sort_dir) 202 ); 203 204 $this->tpl_name = 'ucp_attachments'; 205 $this->page_title = 'UCP_ATTACHMENTS'; 206 } 207 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |