2015-03-05, 03:07 PM
Can anybody help me with this code!
I am fetching and showing the thread's tags in the edit post but how to update the existing tags on submit since the table alredy contains old tags I juts wanna replece them with new!
I am fetching and showing the thread's tags in the edit post but how to update the existing tags on submit since the table alredy contains old tags I juts wanna replece them with new!
function systemtags_insert_tags_thread(&$thread)
{
global $mybb, $db;
if($mybb->input['tags'])
{
$stags = strip_tags($mybb->input['tags']);
$tagsht = htmlspecialchars_uni($stags);
$searchcodes = explode(",", $mybb->input['systemtag_disablecodes']);
$rtags = str_replace($searchcodes, " ", $tagsht);
$rtagsp_br = preg_replace("/\r\n|\r/", " ", $rtags);
$tags = trim($rtagsp_br);
$explode = explode(",", $tags);
$array = array();
foreach($explode as $tag)
{
if(strlen($tag) >= 3)
{
$array[] = $tag;
}
}
$insert = implode(", ",$array);
$insert = $db->escape_string($insert);
$inserttags = array(
"tid" => $thread->tid,
"tags" => $insert
);
$aid = $db->insert_id();
$db->insert_query("tags", $inserttags);
}
}
function systemtags_validate_tags(&$thread)
{
global $mybb,$posthandler, $lang;
$lang->load("tags");
if (!$mybb->input['tags'])
{
$posthandler->set_error($lang->notags);
return false;
}
if($mybb->input['tags'])
{
$stags = strip_tags($mybb->input['tags']);
$tagsht = htmlspecialchars_uni($stags);
$searchcodes = explode(",", $mybb->settings['systemtag_disablecodes']);
$rtags = str_replace($searchcodes, " ", $tagsht);
$tags = preg_replace('/\s*,\s*/', ',', $rtags);
$tags = rtrim($tags, ", \t\n");
$explode = explode(",", $tags);
$tagnum = 0;
foreach($explode as $tag)
{
if(strlen($tag) >= 3)
{
++$tagnum;
}
else
{
$posthandler->set_error($lang->tagsfivecaracters);
return false;
}
if (!preg_match('/^[a-zA-Z0-9 .]+$/', $tag))
{
$posthandler->set_error($lang->numberslettersonly);
return false;
}
}
}
}
function systemtags_postbit_tags(&$post)
{
global $db, $mybb, $templates, $theme,$postcounter;
if($postcounter == 1)
{
$query = $db->simple_select("tags", "tags", "tid=".$post['tid']);
$fortag = $db->fetch_array($query);
if(!empty($fortag['tags']))
{
$explode = explode(", ",$fortag['tags']);
$tagspostbit = "<div class='systemtag'>";
$counttag = 0;
foreach($explode as $tag)
{
$tagspostbit .= "<div class=\"systemtag_element\"><a href=\"tags/".$tag.".html\"><span class=\"smalltext\"><b>".$tag."</b></span></a></div>";
++$counttag;
}
$tagspostbit .= "</div>";
eval("\$post['tags'] = \"".$templates->get("tags_postbit")."\";");
}
}
}
function edit_tags()
{
global $db, $usertags, $tid;
$query = $db->query("
SELECT *
FROM ".TABLE_PREFIX."tags t
WHERE t.tid = $tid
");
while($tag = $db->fetch_array($query))
{
$usertags = $tag['tags'];
}
}