Bywalec
Postów: 434 Pomógł: 20
Data rejestracji: 05.02.2006 21:20
|
Witam.
Pobawiłem się dziś łączeniem tematów. Funkcję skopiowałem żywcem z Fusionboarda.
Aby wprowadzić funkcje łączenia tematów należało w pliku forum/options.php
(zamienić linie ~199)
} else {
redirect("index.php");
}
require_once THEMES."templates/footer.php";
?>
na:
// łączenie i dzielenie tematow
} elseif(isset($_GET['step']) && $_GET['step'] == "split"){
if(isset($_POST['split_thread'])){
$toMove = ""; $i = 0; $firstPost = "";
foreach($_POST as $post=>$move){
if(!ereg("move_", $post) || !$move) continue;
$toMove .= ($i > 0 ? " OR " : "")."post_id='".str_replace('move_', '', $post)."'";
if(!$i) $firstPost = dbarray(dbquery("select * from ".DB_POSTS." where post_id='".str_replace('move_', '', $post)."'"));
$i++;
}
$subject = (isset($_POST['thread_subject']) ? addslash(stripinput($_POST['thread_subject'])) : "");
$forum = (isset($_POST['thread_forum']) && isNum($_POST['thread_forum']) ? $_POST['thread_forum'] : $_GET['forum_id']);
$result = dbquery("INSERT INTO ".DB_THREADS." (forum_id, thread_subject, thread_author, thread_views, thread_lastpost, thread_lastpostid, thread_lastuser, thread_postcount, thread_poll, thread_sticky, thread_locked)
VALUES('$forum', '$subject', '".$firstPost['post_author']."', '0', '".time()."', '0', '".$firstPost['post_author']."', '1', '0', '0', '0')");
$threadid = mysql_insert_id();
$result = dbquery("update ".DB_POSTS." set thread_id='$threadid', forum_id='$forum' where $toMove");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where thread_id='$threadid' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "thread_id='$threadid'");
$result = dbquery("update ".DB_THREADS." set thread_lastpost='".$lastPost['post_datestamp']."',
thread_lastpostid='".$lastPost['post_id']."',
thread_lastuser='".$lastPost['post_author']."',
thread_postcount='$postCount'
where thread_id='$threadid'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where forum_id='$forum' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "forum_id='$forum'");
$result = dbquery("update ".DB_FORUMS." set forum_lastpost='".$lastPost['post_datestamp']."',
forum_threadcount=forum_threadcount+1,
forum_lastuser='".$lastPost['post_author']."',
forum_postcount='$postCount'
where forum_id='$forum'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where thread_id='".$_GET['thread_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "thread_id='".$_GET['thread_id']."'");
$result = dbquery("update ".DB_THREADS." set thread_lastpost='".$lastPost['post_datestamp']."',
thread_lastpostid='".$lastPost['post_id']."',
thread_lastuser='".$lastPost['post_author']."',
thread_postcount='$postCount'
where thread_id='".$_GET['thread_id']."'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where forum_id='".$_GET['forum_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "forum_id='".$_GET['forum_id']."'");
$result = dbquery("update ".DB_FORUMS." set forum_lastpost='".$lastPost['post_datestamp']."',
forum_threadcount=forum_threadcount+1,
forum_lastuser='".$lastPost['post_author']."',
forum_postcount='$postCount'
where forum_id='".$_GET['forum_id']."'");
opentable($locale['fb215']);
echo "<div style='text-align:center'><br />".$locale['fb222']."<br />\n";
echo "<a href='viewthread.php?thread_id=".$_GET['thread_id']."'>".$locale['fb223']."</a> :: \n";
echo "<a href='viewthread.php?thread_id=$threadid'>".$locale['fb224']."</a> :: \n";
echo "<a href='viewforum.php?forum_id=".$_GET['forum_id']."'>".$locale['402']."</a> :: \n";
echo "<a href='index.php'>".$locale['403']."</a><br /><br /></div>\n";
} else {
$possibleParents = "";
$c_res = dbquery("select * from ".$db_prefix."forums where forum_cat='0'");
while($c_data = dbarray($c_res)){
$possibleParents .= "<optgroup label='".$c_data['forum_name']."'>\n";
$p_res = dbquery("SELECT * FROM ".DB_FORUMS." WHERE forum_cat='".$c_data['forum_id']."' ORDER BY forum_order");
while($p_data = dbarray($p_res)){
$sel = ($p_data['forum_id'] == $_GET['forum_id'] ? " SELECTED" : "");
$possibleParents .= "<option value='".$p_data['forum_id']."'$sel>".$p_data['forum_name']."</option>\n";
}
$possibleParents .= "</optgroup>\n";
}
opentable($locale['fb215']);
echo "<form action='".FUSION_SELF."?step=split&thread_id=".$_GET['thread_id']."&forum_id=".$_GET['forum_id']."' method='post' name='splitform'>\n";
echo "<table width='350' cellspacing='1' cellpadding='0' class='tbl-border center'>\n";
echo "<tr>\n<td class='tbl2'>".$locale['fb216']."</td>\n<td class='tbl1' width='1%'>";
echo "<input name='thread_subject' class='textbox' type='textbox' style='width:220px;'></td>\n</tr>\n";
echo "<tr>\n<td class='tbl2'>".$locale['fb217']."</td>\n<td class='tbl1'>";
echo "<select name='thread_forum' class='textbox' style='width:220px;'>\n$possibleParents</select></td>\n</tr>\n";
echo "</table>\n";
closetable();
tablebreak();
opentable($locale['fb218']);
$result = dbquery("select * from ".DB_POSTS." p
left join ".DB_USERS." u on u.user_id=p.post_author
where p.thread_id='".$_GET['thread_id']."'");
$i = 0;
while($data = dbarray($result)){
$i++;
if($i < 2) continue;
echo "<table width='100%' cellspacing='1' cellpadding='0' class='tbl-border'>\n";
echo "<tr>\n<td class='tbl2'>".$locale['fb219']."<b>".showdate("forumdate", $data['post_datestamp'])."</b>".$locale['fb220'];
echo "<b>".$data['user_name']."</b></td><td class='tbl2' style='width:80px;white-space:nowrap;'>\n";
echo "<input type='checkbox' name='move_".$data['post_id']."' value='1' /> ".$locale['fb221']."</td>\n</tr>\n";
echo "<tr>\n<td class='tbl1' colspan='2'>".nl2br(trimlink($data['post_message'], 120))."</td>\n</tr>\n";
echo "</table><br />\n";
}
echo "<div align='center'><input type='submit' name='split_thread' value='".$locale['fb215']."' class='button'></div>\n</form>\n";
}
closetable();
} elseif(isset($_GET['step']) && $_GET['step'] == "merge"){
if(isset($_POST['merge_thread'])){
$toMove = ""; $i = 0;
foreach($_POST as $post=>$move){
if(!ereg("move_", $post) || !$move) continue;
$toMove .= ($i > 0 ? " OR " : "")."post_id='".str_replace('move_', '', $post)."'";
$i++;
}
$merge_id = (isset($_POST['merge_id']) && isNum($_POST['merge_id']) ? $_POST['merge_id'] : 0);
$result = dbquery("select * from ".DB_THREADS." where thread_id='$merge_id'");
if(!dbrows($result)) redirect(FUSION_SELF."?step=merge&thread_id=".$_GET['thread_id']."&forum_id=".$_GET['forum_id']."&status=notfound");
$data = dbarray($result);
$threadid = $data['thread_id'];
$result = dbquery("update ".DB_POSTS." set thread_id='$threadid', forum_id='".$data['forum_id']."' where $toMove");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where thread_id='$threadid' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "thread_id='$threadid'");
$result = dbquery("update ".DB_THREADS." set thread_lastpost='".$lastPost['post_datestamp']."',
thread_lastpostid='".$lastPost['post_id']."',
thread_lastuser='".$lastPost['post_author']."',
thread_postcount='$postCount'
where thread_id='$threadid'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where forum_id='".$data['forum_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "forum_id='".$data['forum_id']."'");
$result = dbquery("update ".DB_FORUMS." set forum_lastpost='".$lastPost['post_datestamp']."',
forum_lastuser='".$lastPost['post_author']."',
forum_postcount='$postCount'
where forum_id='".$data['forum_id']."'");
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where thread_id='".$_GET['thread_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "thread_id='".$_GET['thread_id']."'");
$result = dbquery("update ".DB_THREADS." set thread_lastpost='".$lastPost['post_datestamp']."',
thread_lastpostid='".$lastPost['post_id']."',
thread_lastuser='".$lastPost['post_author']."',
thread_postcount='$postCount'
where thread_id='".$_GET['thread_id']."'");
if(!dbcount("(post_id)", DB_POSTS, "thread_id='".$_GET['thread_id']."'")){
$result = dbquery("delete from ".DB_THREADS." where thread_id='".$_GET['thread_id']."'");
$result = dbquery("delete from ".DB_THREAD_NOTIFY." where thread_id='".$_GET['thread_id']."'");
$delete=true;
} else { $delete=false; }
$lastPost = dbarray(dbquery("select * from ".DB_POSTS." where forum_id='".$_GET['forum_id']."' order by post_id desc limit 1"));
$postCount = dbcount("(post_id)", DB_POSTS, "forum_id='".$_GET['forum_id']."'");
$result = dbquery("update ".DB_FORUMS." set forum_lastpost='".$lastPost['post_datestamp']."',
forum_lastuser='".$lastPost['post_author']."',
forum_postcount='$postCount'
where forum_id='".$_GET['forum_id']."'");
opentable($locale['fb225']);
echo "<div style='text-align:center'><br />".$locale['fb231']."<br />\n";
if(!$delete) echo "<a href='viewthread.php?thread_id=".$_GET['thread_id']."'>".$locale['fb232']."</a> :: \n";
echo "<a href='viewthread.php?thread_id=$threadid'>".$locale['fb233']."</a> :: \n";
echo "<a href='viewforum.php?forum_id=".$_GET['forum_id']."'>".$locale['402']."</a> :: \n";
echo "<a href='index.php'>".$locale['403']."</a><br /><br /></div>\n";
} else {
opentable($locale['fb225']);
if(isset($_GET['status']) && $_GET['status'] == "notfound") echo "<div align='center'>".$locale['fb234']."</div><br />\n";
echo "<form action='".FUSION_SELF."?step=merge&thread_id=".$_GET['thread_id']."&forum_id=".$_GET['forum_id']."' method='post' name='splitform'>\n";
echo "<table width='350' cellspacing='1' cellpadding='0' class='tbl-border center'>\n";
echo "<tr>\n<td class='tbl2'>".$locale['fb226']."</td>\n<td class='tbl1' width='1%'>";
echo "<input name='merge_id' class='textbox' type='textbox' style='width:100px;'></td>\n</tr>\n";
echo "</table>\n";
closetable();
tablebreak();
opentable($locale['fb218']);
$result = dbquery("select * from ".DB_POSTS." p
left join ".DB_USERS." u on u.user_id=p.post_author
where p.thread_id='".$_GET['thread_id']."'");
while($data = dbarray($result)){
echo "<table width='100%' cellspacing='1' cellpadding='0' class='tbl-border'>\n";
echo "<tr>\n<td class='tbl2'>".$locale['fb219']."<b>".showdate("forumdate", $data['post_datestamp'])."</b>".$locale['fb220'];
echo "<b>".$data['user_name']."</b></td><td class='tbl2' style='width:80px;white-space:nowrap;'>\n";
echo "<input type='checkbox' name='move_".$data['post_id']."' value='1' /> ".$locale['fb221']."</td>\n</tr>\n";
echo "<tr>\n<td class='tbl1' colspan='2'>".nl2br(trimlink($data['post_message'], 120))."</td>\n</tr>\n";
echo "</table><br />\n";
}
echo "<div align='center'><input type='submit' name='merge_thread' value='".$locale['fb225']."' class='button'></div>\n</form>\n";
}
closetable();
} else {
redirect("index.php");
}
//
require_once THEMES."templates/footer.php";
?>
oraz na początku dodać (po linii ~21)
include LOCALE.LOCALESET."forum/main.php";
W pliku locale/Polish/forum/main.php dodać na dole przed ?>
/* Split Thread */
$locale['fb215'] = "Podziel temat";
$locale['fb216'] = "Nowy nazwa:";
$locale['fb217'] = "Nowe forum:";
$locale['fb218'] = "Przegląd tematu";
$locale['fb219'] = "Napisane: ";
$locale['fb220'] = " przez ";
$locale['fb221'] = "Przenieś posty";
$locale['fb222'] = "Wybrane posty zostały przeniesione do nowego tematu!";
$locale['fb223'] = "Idź do oryginalnego tematu";
$locale['fb224'] = "Idź do nowego tematu";
/* Merge Thread */
$locale['fb225'] = "Połącz tematy";
$locale['fb226'] = "Numer ID docelowego tematu:";
$locale['fb227'] = "Przegląd tematu";
$locale['fb228'] = "Napisane: ";
$locale['fb229'] = " przez ";
$locale['fb230'] = "Przenieś posty";
$locale['fb231'] = "Wybrane posty zostały połączone z innym tematem!";
$locale['fb232'] = "Idź do oryginalnego tematu";
$locale['fb233'] = "Idź do połączonego tematu";
$locale['fb234'] = "Numer ID tematu nie mógł zostać znaleziony!";
W pliku forum/viewthread.php dodać po linii (~399)
echo "<option value='move'>".$locale['526']."</option>\n";
to
echo "<option value='split'>".$locale['fb215']."</option>\n";
echo "<option value='merge'>".$locale['fb225']."</option>\n";
PW od moderatora:
- Odświeżenie Tematu - bartek124 15.07 - 19:53
Edytowane przez szymon dnia 20.11.2009 16:53:53
|