Nilsons |
16th July 2009 12:51 |
Forums..
So i added to my forums locked reason and unlock reason... when i lock topic it posts new post - And there writes reason and who locked topic....
But i want to ask you how to do this- When i unlock topic the post that was posted with reason why locked automaticly removed ? what code i need to put?
Heres the code -
Code:
///// Add reason to locked code - TBDev - Dokty /////
if ($action == "setlocked")
{
$topicid = 0 + $_POST["topicid"];
if (!$topicid || get_user_class() < UC_MODERATOR)
die;
$res2345 = mysql_query("SELECT locked FROM topics WHERE id = " . $topicid) or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res2345) != 1)
die("Error - No topic with this ID.");
$arr2345 = mysql_fetch_assoc($res2345);
$locked = sqlesc($_POST["locked"]);
mysql_query("UPDATE topics SET locked=$locked WHERE id=$topicid") or sqlerr(__FILE__, __LINE__);
if (($locked != $arr2345["locked"]) && ($_POST["locked"] == "yes")) {
$body = sqlesc("Topic Locked by ".$CURUSER['username']."\nReason: ".$_POST["lockreason"].". ");
mysql_query("INSERT INTO posts (topicid, userid, added, body) VALUES($topicid, ".$CURUSER['id'].", '" . get_date_time() . "', $body)") or sqlerr(__FILE__, __LINE__);
$postid = mysql_insert_id() or die("Post id n/a");
update_topic_last_post($topicid);
}
if (($locked != $arr2345["locked"]) && ($_POST["locked"] == "no")) {
mysql_query("UPDATE posts"
$postid = mysql_insert_id() or die("Post id n/a");
update_topic_last_post($topicid);
$body = sqlesc("Topic UnLocked by ".$CURUSER['username']."\nReason: ".$_POST["lockreason"].". ");
mysql_query("INSERT INTO posts (topicid, userid, added, body) VALUES($topicid, ".$CURUSER['id'].", '" . get_date_time() . "', $body)") or sqlerr(__FILE__, __LINE__);
$postid = mysql_insert_id() or die("Post id n/a");
update_topic_last_post($topicid);
}
$returnto = str_replace ('&', '&', htmlentities($_POST["returnto"]));
header("Location: ".$returnto);
die;
}
I tried to do something but im not a coder im trying to learn something .. But i gues that i was doing wrong :D
Sorry my english is terrible :D
|