only small addition for further use...

git-svn-id: file:///svn/phpbb/trunk@4162 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-06-21 12:36:00 +00:00
parent 3d36530308
commit 251a5b8f94
6 changed files with 56 additions and 47 deletions

View file

@ -283,7 +283,7 @@ function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = '
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
if (count($post_id_array) == 0) if (!count($post_id_array))
{ {
return; return;
} }
@ -312,7 +312,7 @@ function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = '
} }
} }
if (count($post_id_array) == 0) if (!count($post_id_array))
{ {
return; return;
} }
@ -335,7 +335,7 @@ function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = '
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
if (count($attach_id_array) == 0) if (!count($attach_id_array))
{ {
return; return;
} }
@ -359,7 +359,7 @@ function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = '
} }
} }
if (count($attach_id_array) == 0) if (!count($attach_id_array))
{ {
return; return;
} }
@ -421,22 +421,22 @@ function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = '
} }
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . '
WHERE attach_id IN (' . implode(', ', $attach_id_array) . ') WHERE attach_id IN (" . implode(', ', $attach_id_array) . ")
AND ' . $sql_id . ' IN (' . implode(', ', $post_id_array) . ')'; AND $sql_id IN (" . implode(', ', $post_id_array) . ")";
$db->sql_query($sql); $db->sql_query($sql);
foreach ($attach_id_array as $attach_id) foreach ($attach_id_array as $attach_id)
{ {
$sql = 'SELECT attach_id $sql = 'SELECT attach_id
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . "
WHERE attach_id = ' . $attach_id; WHERE attach_id = $attach_id";
$select_result = $db->sql_query($sql); $select_result = $db->sql_query($sql);
if (!is_array($db->sql_fetchrow($select_result))) if (!is_array($db->sql_fetchrow($select_result)))
{ {
$sql = 'SELECT attach_id, physical_filename, thumbnail $sql = 'SELECT attach_id, physical_filename, thumbnail
FROM ' . ATTACHMENTS_DESC_TABLE . ' FROM ' . ATTACHMENTS_DESC_TABLE . "
WHERE attach_id = ' . $attach_id; WHERE attach_id = $attach_id";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
// delete attachments // delete attachments
@ -490,9 +490,9 @@ function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = '
$topic_id = intval($row['topic_id']); $topic_id = intval($row['topic_id']);
$sql = 'SELECT post_id $sql = 'SELECT post_id
FROM ' . POSTS_TABLE . ' FROM ' . POSTS_TABLE . "
WHERE topic_id = ' . $topic_id . ' WHERE topic_id = $topic_id
GROUP BY post_id'; GROUP BY post_id";
$result2 = $db->sql_query($sql); $result2 = $db->sql_query($sql);
$post_ids = array(); $post_ids = array();
@ -508,29 +508,29 @@ function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = '
$post_id_sql = implode(', ', $post_ids); $post_id_sql = implode(', ', $post_ids);
$sql = 'SELECT attach_id $sql = 'SELECT attach_id
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . "
WHERE post_id IN (' . $post_id_sql . ') '; WHERE post_id IN ($post_id_sql)";
$select_result = $db->sql_query_limit($sql, 1); $select_result = $db->sql_query_limit($sql, 1);
$set_id = (!is_array($db->sql_fetchrow($select_result))) ? 0 : 1; $set_id = (!is_array($db->sql_fetchrow($select_result))) ? 0 : 1;
$db->sql_freeresult($select_result); $db->sql_freeresult($select_result);
$sql = 'UPDATE ' . TOPICS_TABLE . ' $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_attachment = ' . $set_id . ' SET topic_attachment = $set_id
WHERE topic_id = ' . $topic_id; WHERE topic_id = $topic_id";
$db->sql_query($sql); $db->sql_query($sql);
foreach ($post_ids as $post_id) foreach ($post_ids as $post_id)
{ {
$sql = 'SELECT attach_id $sql = 'SELECT attach_id
FROM ' . ATTACHMENTS_TABLE . ' FROM ' . ATTACHMENTS_TABLE . "
WHERE post_id = ' . $post_id; WHERE post_id = $post_id";
$select_result = $db->sql_query_limit($sql, 1); $select_result = $db->sql_query_limit($sql, 1);
$set_id = (!is_array($db->sql_fetchrow($select_result))) ? 0 : 1; $set_id = (!is_array($db->sql_fetchrow($select_result))) ? 0 : 1;
$db->sql_freeresult($select_result); $db->sql_freeresult($select_result);
$sql = 'UPDATE ' . POSTS_TABLE . ' $sql = 'UPDATE ' . POSTS_TABLE . "
SET post_attachment = ' . $set_id . ' SET post_attachment = $set_id
WHERE post_id = ' . $post_id; WHERE post_id = $post_id";
$db->sql_query($sql); $db->sql_query($sql);
} }
} }
@ -1045,7 +1045,9 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
'comment' => trim($attach_row['comment']) 'comment' => trim($attach_row['comment'])
); );
$sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . ' WHERE attach_id = ' . intval($attach_row['attach_id']); $sql = 'UPDATE ' . ATTACHMENTS_DESC_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $attach_sql) . '
WHERE attach_id = ' . intval($attach_row['attach_id']);
$db->sql_query($sql); $db->sql_query($sql);
} }
else else
@ -1062,7 +1064,8 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
'thumbnail' => $attach_row['thumbnail'] 'thumbnail' => $attach_row['thumbnail']
); );
$sql = 'INSERT INTO ' . ATTACHMENTS_DESC_TABLE . ' ' . $db->sql_build_array('INSERT', $attach_sql); $sql = 'INSERT INTO ' . ATTACHMENTS_DESC_TABLE . ' ' .
$db->sql_build_array('INSERT', $attach_sql);
$db->sql_query($sql); $db->sql_query($sql);
$attach_sql = array( $attach_sql = array(
@ -1073,21 +1076,22 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
'user_id_to' => 0 'user_id_to' => 0
); );
$sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $attach_sql); $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' .
$db->sql_build_array('INSERT', $attach_sql);
$db->sql_query($sql); $db->sql_query($sql);
} }
} }
if (count($attachment_data)) if (count($attachment_data))
{ {
$sql = "UPDATE " . POSTS_TABLE . " $sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 1 SET post_attachment = 1
WHERE post_id = " . $post_data['post_id']; WHERE post_id = ' . $post_data['post_id'];
$db->sql_query($sql); $db->sql_query($sql);
$sql = "UPDATE " . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_attachment = 1 SET topic_attachment = 1
WHERE topic_id = " . $post_data['topic_id']; WHERE topic_id = ' . $post_data['topic_id'];
$db->sql_query($sql); $db->sql_query($sql);
} }
} }

View file

@ -832,6 +832,7 @@ CREATE TABLE phpbb_topics (
topic_last_poster_id INTEGER DEFAULT 0 NOT NULL, topic_last_poster_id INTEGER DEFAULT 0 NOT NULL,
topic_last_poster_name VARCHAR(30), topic_last_poster_name VARCHAR(30),
topic_last_post_time INTEGER DEFAULT 0 NOT NULL, topic_last_post_time INTEGER DEFAULT 0 NOT NULL,
topic_last_view_time INTEGER DEFAULT 0 NOT NULL,
topic_moved_id INTEGER DEFAULT 0 NOT NULL, topic_moved_id INTEGER DEFAULT 0 NOT NULL,
poll_title VARCHAR(255) DEFAULT '' NOT NULL, poll_title VARCHAR(255) DEFAULT '' NOT NULL,
poll_start INTEGER DEFAULT 0 NOT NULL, poll_start INTEGER DEFAULT 0 NOT NULL,

View file

@ -576,6 +576,7 @@ CREATE TABLE phpbb_topics (
topic_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, topic_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
topic_last_poster_name varchar(30), topic_last_poster_name varchar(30),
topic_last_post_time int(11) DEFAULT '0' NOT NULL, topic_last_post_time int(11) DEFAULT '0' NOT NULL,
topic_last_view_time int(11) DEFAULT '0' NOT NULL,
topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
poll_title varchar(255) NOT NULL, poll_title varchar(255) NOT NULL,
poll_start int(11) NOT NULL DEFAULT '0', poll_start int(11) NOT NULL DEFAULT '0',

View file

@ -362,7 +362,7 @@ INSERT INTO phpbb_moderator_cache (user_id, forum_id, username) VALUES (2, 2, 'A
# MSSQL IDENTITY phpbb_topics ON # # MSSQL IDENTITY phpbb_topics ON #
# -- Demo Topic # -- Demo Topic
INSERT INTO phpbb_topics (topic_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_post_time) VALUES (1, 'Welcome to phpBB 2', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 1, 2, 'Admin', 972086460); INSERT INTO phpbb_topics (topic_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_post_time, topic_last_view_time) VALUES (1, 'Welcome to phpBB 2', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 1, 2, 'Admin', 972086460, 972086460);
# MSSQL IDENTITY phpbb_topics OFF # # MSSQL IDENTITY phpbb_topics OFF #

View file

@ -509,6 +509,8 @@ if ($forum_data['forum_type'] == FORUM_POST)
$last_post_time = $user->format_date($row['topic_last_post_time']); $last_post_time = $user->format_date($row['topic_last_post_time']);
$last_view_time = $user->format_date($row['topic_last_view_time']);
// This will allow the style designer to output a different header // This will allow the style designer to output a different header
// or even seperate the list of announcements from sticky and normal // or even seperate the list of announcements from sticky and normal
// topics // topics
@ -522,6 +524,7 @@ if ($forum_data['forum_type'] == FORUM_POST)
'FIRST_POST_TIME' => $first_post_time, 'FIRST_POST_TIME' => $first_post_time,
'LAST_POST_TIME' => $last_post_time, 'LAST_POST_TIME' => $last_post_time,
'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_AUTHOR' => $last_post_author,
'LAST_VIEW_TIME' => $last_view_time,
'GOTO_PAGE' => $goto_page, 'GOTO_PAGE' => $goto_page,
'REPLIES' => ($auth->acl_get('m_approve')) ? $row['topic_replies_real'] : $row['topic_replies'], 'REPLIES' => ($auth->acl_get('m_approve')) ? $row['topic_replies_real'] : $row['topic_replies'],
'VIEWS' => $row['topic_views'], 'VIEWS' => $row['topic_views'],

View file

@ -1045,7 +1045,7 @@ unset($user_cache);
if (!preg_match("#&t=$topic_id#", $user->data['session_page'])) if (!preg_match("#&t=$topic_id#", $user->data['session_page']))
{ {
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_views = topic_views + 1 SET topic_views = topic_views + 1, topic_last_view_time = " . time() . "
WHERE topic_id = $topic_id"; WHERE topic_id = $topic_id";
$db->sql_query($sql); $db->sql_query($sql);