aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_posting.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2006-05-20 18:39:35 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2006-05-20 18:39:35 +0000
commit5029170afbe7e74a0c46b3b3f1ecca83697ced42 (patch)
tree4762e7d8d4d3b723d681f0bf5a88f65b266978b2 /phpBB/includes/functions_posting.php
parent037f0bf4da281981dd5bc0e217325d2c49531409 (diff)
downloadforums-5029170afbe7e74a0c46b3b3f1ecca83697ced42.tar
forums-5029170afbe7e74a0c46b3b3f1ecca83697ced42.tar.gz
forums-5029170afbe7e74a0c46b3b3f1ecca83697ced42.tar.bz2
forums-5029170afbe7e74a0c46b3b3f1ecca83697ced42.tar.xz
forums-5029170afbe7e74a0c46b3b3f1ecca83697ced42.zip
- fixed a few smaller things
git-svn-id: file:///svn/phpbb/trunk@5952 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_posting.php')
-rw-r--r--phpBB/includes/functions_posting.php49
1 files changed, 19 insertions, 30 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index cc4afd0ba4..2210be1ab9 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -682,15 +682,27 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
global $user, $db, $template, $auth;
global $phpbb_root_path, $phpEx, $SID;
- $topic_ids = $draft_rows = array();
+ $topic_ids = $forum_ids = $draft_rows = array();
// Load those drafts not connected to forums/topics
// If forum_id == 0 AND topic_id == 0 then this is a PM draft
- $sql = 'SELECT *
- FROM ' . DRAFTS_TABLE . '
- WHERE user_id = ' . $user->data['user_id'] . '
- AND (forum_id = 0 OR topic_id = 0)
- ORDER BY save_time DESC';
+ if (!$topic_id && !$forum_id)
+ {
+ $sql_and = 'AND d.forum_id = 0 AND d.topic_id = 0';
+ }
+ else
+ {
+ $sql_and = '';
+ $sql_and .= ($forum_id) ? 'AND d.forum_id = ' . $forum_id : '';
+ $sql_and .= ($topic_id) ? 'AND d.topic_id = ' . $topic_id : '';
+ }
+
+ $sql = 'SELECT d.*, f.forum_id, f.forum_name
+ FROM ' . DRAFTS_TABLE . ' d
+ LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = d.forum_id)
+ WHERE d.user_id = ' . $user->data['user_id'] . "
+ $sql_and
+ ORDER BY d.save_time DESC";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -703,35 +715,12 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
}
$db->sql_freeresult($result);
- // Only those fitting into this forum now...
- if ($forum_id || $topic_id)
- {
- $sql = 'SELECT d.draft_id, d.topic_id, d.forum_id, d.draft_subject, d.save_time, f.forum_name
- FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f
- WHERE d.user_id = ' . $user->data['user_id'] . '
- AND d.forum_id = f.forum_id ' .
- (($forum_id) ? " AND d.forum_id = $forum_id" : '') . '
- ORDER BY d.save_time DESC';
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- if ($row['topic_id'])
- {
- $topic_ids[] = (int) $row['topic_id'];
- }
- $draft_rows[] = $row;
- }
- $db->sql_freeresult($result);
- }
-
if (!sizeof($draft_rows))
{
return;
}
$topic_rows = array();
-
if (sizeof($topic_ids))
{
$sql = 'SELECT topic_id, forum_id, topic_title
@@ -746,7 +735,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
$db->sql_freeresult($result);
}
unset($topic_ids);
-
+
$template->assign_var('S_SHOW_DRAFTS', true);
foreach ($draft_rows as $draft)