phpBB

Code Changes

File: includes/ucp/ucp_attachments.php

  Unmodified   Added   Modified   Removed
Line 29Line 29

function main($id, $mode)
{


function main($id, $mode)
{

		global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request;

		global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container, $request, $auth;


$start = $request->variable('start', 0);
$sort_key = $request->variable('sk', 'a');


$start = $request->variable('start', 0);
$sort_key = $request->variable('sk', 'a');

Line 38Line 38
		$delete		= (isset($_POST['delete'])) ? true : false;
$delete_ids = array_keys($request->variable('attachment', array(0)));


		$delete		= (isset($_POST['delete'])) ? true : false;
$delete_ids = array_keys($request->variable('attachment', array(0)));


		if ($delete && sizeof($delete_ids))

		if ($delete && count($delete_ids))

		{
// Validate $delete_ids...

		{
// Validate $delete_ids...

			$sql = 'SELECT attach_id
FROM ' . ATTACHMENTS_TABLE . '
WHERE poster_id = ' . $user->data['user_id'] . '
AND is_orphan = 0
AND ' . $db->sql_in_set('attach_id', $delete_ids);







			$sql = 'SELECT a.attach_id, p.post_edit_locked, t.topic_status, f.forum_id, f.forum_status
FROM ' . ATTACHMENTS_TABLE . ' a
LEFT JOIN ' . POSTS_TABLE . ' p
ON (a.post_msg_id = p.post_id AND a.in_message = 0)
LEFT JOIN ' . TOPICS_TABLE . ' t
ON (t.topic_id = p.topic_id AND a.in_message = 0)
LEFT JOIN ' . FORUMS_TABLE . ' f
ON (f.forum_id = t.forum_id AND a.in_message = 0)
WHERE a.poster_id = ' . $user->data['user_id'] . '
AND a.is_orphan = 0
AND ' . $db->sql_in_set('a.attach_id', $delete_ids);

			$result = $db->sql_query($sql);

$delete_ids = array();
while ($row = $db->sql_fetchrow($result))
{

			$result = $db->sql_query($sql);

$delete_ids = array();
while ($row = $db->sql_fetchrow($result))
{

 
				if (!$auth->acl_get('m_edit', $row['forum_id']) && ($row['forum_status'] == ITEM_LOCKED || $row['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']))
{
continue;
}


				$delete_ids[] = $row['attach_id'];
}
$db->sql_freeresult($result);
}


				$delete_ids[] = $row['attach_id'];
}
$db->sql_freeresult($result);
}


		if ($delete && sizeof($delete_ids))

		if ($delete && count($delete_ids))

		{
$s_hidden_fields = array(
'delete' => 1

		{
$s_hidden_fields = array(
'delete' => 1

Line 75Line 86
				unset($attachment_manager);

meta_refresh(3, $this->u_action);

				unset($attachment_manager);

meta_refresh(3, $this->u_action);

				$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>');

				$message = ((count($delete_ids) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');

				trigger_error($message);
}
else
{

				trigger_error($message);
}
else
{

				confirm_box(false, (sizeof($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields));

				confirm_box(false, (count($delete_ids) == 1) ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields));

			}
}


			}
}


Line 124Line 135
		$pagination = $phpbb_container->get('pagination');
$start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments);


		$pagination = $phpbb_container->get('pagination');
$start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments);


		$sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title

		$sql = 'SELECT a.*, t.topic_title, pr.message_subject as message_title, p.post_edit_locked, t.topic_status, f.forum_id, f.forum_status

			FROM ' . ATTACHMENTS_TABLE . ' a

			FROM ' . ATTACHMENTS_TABLE . ' a

 
				LEFT JOIN ' . POSTS_TABLE . ' p ON (a.post_msg_id = p.post_id AND a.in_message = 0)

				LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)

				LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)

				LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1)


				LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id AND a.in_message = 0)
LEFT JOIN ' . PRIVMSGS_TABLE . ' pr ON (a.post_msg_id = pr.msg_id AND a.in_message = 1)

			WHERE a.poster_id = ' . $user->data['user_id'] . "
AND a.is_orphan = 0
ORDER BY $order_by";

			WHERE a.poster_id = ' . $user->data['user_id'] . "
AND a.is_orphan = 0
ORDER BY $order_by";

Line 164Line 177
					'TOPIC_ID'			=> $row['topic_id'],

'S_IN_MESSAGE' => $row['in_message'],

					'TOPIC_ID'			=> $row['topic_id'],

'S_IN_MESSAGE' => $row['in_message'],

 
					'S_LOCKED'			=> !$row['in_message'] && !$auth->acl_get('m_edit', $row['forum_id']) && ($row['forum_status'] == ITEM_LOCKED || $row['topic_status'] == ITEM_LOCKED || $row['post_edit_locked']),


'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']),
'U_VIEW_TOPIC' => $view_topic)


'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $row['attach_id']),
'U_VIEW_TOPIC' => $view_topic)