Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ucp_attachments.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 7.16 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  /**
015  * @ignore
016  */
017  if (!defined('IN_PHPBB'))
018  {
019      exit;
020  }
021   
022  /**
023  * ucp_attachments
024  * User attachments
025  */
026  class ucp_attachments
027  {
028      var $u_action;
029   
030      function main($id, $mode)
031      {
032          global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request;
033   
034          $start        = $request->variable('start', 0);
035          $sort_key    = $request->variable('sk', 'a');
036          $sort_dir    = $request->variable('sd', 'a');
037   
038          $delete        = (isset($_POST['delete'])) ? true : false;
039          $delete_ids    = array_keys($request->variable('attachment', array(0)));
040   
041          if ($delete && sizeof($delete_ids))
042          {
043              // Validate $delete_ids...
044              $sql = 'SELECT attach_id
045                  FROM ' . ATTACHMENTS_TABLE . '
046                  WHERE poster_id = ' . $user->data['user_id'] . '
047                      AND is_orphan = 0
048                      AND ' . $db->sql_in_set('attach_id', $delete_ids);
049              $result = $db->sql_query($sql);
050   
051              $delete_ids = array();
052              while ($row = $db->sql_fetchrow($result))
053              {
054                  $delete_ids[] = $row['attach_id'];
055              }
056              $db->sql_freeresult($result);
057          }
058   
059          if ($delete && sizeof($delete_ids))
060          {
061              $s_hidden_fields = array(
062                  'delete'    => 1
063              );
064   
065              foreach ($delete_ids as $attachment_id)
066              {
067                  $s_hidden_fields['attachment'][$attachment_id] = 1;
068              }
069   
070              if (confirm_box(true))
071              {
072                  /** @var \phpbb\attachment\manager $attachment_manager */
073                  $attachment_manager = $phpbb_container->get('attachment.manager');
074                  $attachment_manager->delete('attach', $delete_ids);
075                  unset($attachment_manager);
076   
077                  meta_refresh(3, $this->u_action);
078                  $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>');
079                  trigger_error($message);
080              }
081              else
082              {
083                  confirm_box(false, (sizeof($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields));
084              }
085          }
086   
087          // Select box eventually
088          $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']);
089          $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');
090   
091          $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
092   
093          $s_sort_key = '';
094          foreach ($sort_key_text as $key => $value)
095          {
096              $selected = ($sort_key == $key) ? ' selected="selected"' : '';
097              $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
098          }
099   
100          $s_sort_dir = '';
101          foreach ($sort_dir_text as $key => $value)
102          {
103              $selected = ($sort_dir == $key) ? ' selected="selected"' : '';
104              $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
105          }
106   
107          if (!isset($sort_key_sql[$sort_key]))
108          {
109              $sort_key = 'a';
110          }
111   
112          $order_by = $sort_key_sql[$sort_key] . ' ' . (($sort_dir == 'a') ? 'ASC' : 'DESC');
113   
114          $sql = 'SELECT COUNT(attach_id) as num_attachments
115              FROM ' . ATTACHMENTS_TABLE . '
116              WHERE poster_id = ' . $user->data['user_id'] . '
117                  AND is_orphan = 0';
118          $result = $db->sql_query($sql);
119          $num_attachments = $db->sql_fetchfield('num_attachments');
120          $db->sql_freeresult($result);
121   
122          // Ensure start is a valid value
123          /* @var $pagination \phpbb\pagination */
124          $pagination = $phpbb_container->get('pagination');
125          $start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments);
126   
127          $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
128              FROM ' . ATTACHMENTS_TABLE . ' a
129                  LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)
130                  LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1)
131              WHERE a.poster_id = ' . $user->data['user_id'] . "
132                  AND a.is_orphan = 0
133              ORDER BY $order_by";
134          $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
135   
136          $row_count = 0;
137          if ($row = $db->sql_fetchrow($result))
138          {
139              $template->assign_var('S_ATTACHMENT_ROWS', true);
140   
141              do
142              {
143                  if ($row['in_message'])
144                  {
145                      $view_topic = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&amp;p={$row['post_msg_id']}");
146                  }
147                  else
148                  {
149                      $view_topic = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_id']}&amp;p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}";
150                  }
151   
152                  $template->assign_block_vars('attachrow', array(
153                      'ROW_NUMBER'        => $row_count + ($start + 1),
154                      'FILENAME'            => $row['real_filename'],
155                      'COMMENT'            => bbcode_nl2br($row['attach_comment']),
156                      'EXTENSION'            => $row['extension'],
157                      'SIZE'                => get_formatted_filesize($row['filesize']),
158                      'DOWNLOAD_COUNT'    => $row['download_count'],
159                      'POST_TIME'            => $user->format_date($row['filetime']),
160                      'TOPIC_TITLE'        => ($row['in_message']) ? $row['message_title'] : $row['topic_title'],
161   
162                      'ATTACH_ID'            => $row['attach_id'],
163                      'POST_ID'            => $row['post_msg_id'],
164                      'TOPIC_ID'            => $row['topic_id'],
165   
166                      'S_IN_MESSAGE'        => $row['in_message'],
167   
168                      'U_VIEW_ATTACHMENT'    => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']),
169                      'U_VIEW_TOPIC'        => $view_topic)
170                  );
171   
172                  $row_count++;
173              }
174              while ($row = $db->sql_fetchrow($result));
175          }
176          $db->sql_freeresult($result);
177   
178          $base_url = $this->u_action . "&amp;sk=$sort_key&amp;sd=$sort_dir";
179          $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);
180   
181          $template->assign_vars(array(
182              'TOTAL_ATTACHMENTS'        => $num_attachments,
183              'NUM_ATTACHMENTS'        => $user->lang('NUM_ATTACHMENTS', $num_attachments),
184   
185              'L_TITLE'                => $user->lang['UCP_ATTACHMENTS'],
186   
187              'U_SORT_FILENAME'        => $this->u_action . "&amp;sk=a&amp;sd=" . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
188              'U_SORT_FILE_COMMENT'    => $this->u_action . "&amp;sk=b&amp;sd=" . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
189              'U_SORT_EXTENSION'        => $this->u_action . "&amp;sk=c&amp;sd=" . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
190              'U_SORT_FILESIZE'        => $this->u_action . "&amp;sk=d&amp;sd=" . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'),
191              'U_SORT_DOWNLOADS'        => $this->u_action . "&amp;sk=e&amp;sd=" . (($sort_key == 'e' && $sort_dir == 'a') ? 'd' : 'a'),
192              'U_SORT_POST_TIME'        => $this->u_action . "&amp;sk=f&amp;sd=" . (($sort_key == 'f' && $sort_dir == 'a') ? 'd' : 'a'),
193              'U_SORT_TOPIC_TITLE'    => $this->u_action . "&amp;sk=g&amp;sd=" . (($sort_key == 'g' && $sort_dir == 'a') ? 'd' : 'a'),
194   
195              'S_DISPLAY_MARK_ALL'    => ($num_attachments) ? true : false,
196              'S_DISPLAY_PAGINATION'    => ($num_attachments) ? true : false,
197              'S_UCP_ACTION'            => $this->u_action,
198              'S_SORT_OPTIONS'         => $s_sort_key,
199              'S_ORDER_SELECT'        => $s_sort_dir)
200          );
201   
202          $this->tpl_name = 'ucp_attachments';
203          $this->page_title = 'UCP_ATTACHMENTS';
204      }
205  }
206