Hallo
Ich habe Wordpress United, dass PHPbb mit Worpdress verbindet und ein Addon für WPU, was PHPbb Post heisst. Es macht aus jedem Beitrag, den ich schreibe einen Thread in einem Subforum. Könnte man dieses Plugin auch so einstellen, dass es nur ein Thread macht, wenn ein Beitrag in die Kategorie XY gelegt wird. Wenn man dann ein Beitrag in die Kategorie AB legt sollte dann keiner erscheinen.
Kann man das machen?
hier der Code des Plugins für WPU:
PHP
<?php
/*
Plugin Name: phpBB Post
Plugin URI: http://www.tecnosquad.com/
Description: Plugin creates topics in your phpBB forum, when you publish posts in WP.
Version: 0.001
Author: Amenadiel
Author http://www.tecnosquad.com/
*/
// ------------ definitions --------------
$posterID =7; // ID of the poster bot
$postername ='Blog-Beitrag'; // Name of the poster bot
$defboard =2; // The board in which the comments posts will be
$forumprefix='phpbb_'; // prefix of your forum tables
$forumURL= 'http://lateknightsgang.la.funpic.de/forum/'; // URL of the forum http://lateknightsgang.la.funpic.de/
$blogURL= 'http://lateknightsgang.la.funpic.de'; // URL of the blog http://www.yourblog.com/
$discusstext= 'Im Forum besprechen'; // text of the blog link: "Comment this on the forum"
$backtext='Kommentiere diesen Artikel'; //text of the forum post: "Comment this article"
// ------------ actions --------------
add_action('activate_phpbb_post/phpbb_post.php', 'phpbb_install');
add_action('publish_post', 'phpbb_setpost');
add_filter('the_content', 'phpbb_add_forumlink');
if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
add_action('init', 'phpbb_install');
}
function phpbb_install() {
global $table_prefix, $wpdb;
$posts_table = $table_prefix . "phpbb_post_posts";
$sql0 = "CREATE TABLE ".$posts_table." ( `id` int(10) NOT NULL AUTO_INCREMENT, `post_id` int(10) NOT NULL default '1', `topic_id` int(10) NOT NULL default '1', PRIMARY KEY (`id`) );";
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
dbDelta($sql0);
}
function phpbb_add_forumlink($content = '') {
global $id, $wpdb, $table_prefix, $forumURL, $discusstext, $forumprefix;
$posts_table = $table_prefix . "phpbb_post_posts";
$topic_id = $wpdb->get_var("SELECT topic_id FROM `$posts_table` WHERE `post_id` = $id LIMIT 1;");
if ($topic_id != "") {
$content = $content . "<p><a href='".$forumURL."viewtopic.php?t=".$topic_id."'>".$discusstext;
$topic_posts = $wpdb->get_var("SELECT topic_replies FROM `".$forumprefix."topics` WHERE `topic_id` = $topic_id LIMIT 1;");
$content = $content . " (".$topic_posts.")";
$content = $content . "</a></p> ";
}
return $content;
}
function phpbb_setpost($post_ID) { // function for publish & save actions
global $wpdb, $table_prefix, $backtext, $blogURL, $defboard ;
$posts_table = $table_prefix . "phpbb_post_posts";
$post = get_post($post_ID);
$title = mysql_real_escape_string($post->post_title);
$content = mysql_real_escape_string(nl2br($post->post_content));
$author = $post->post_author;
$author_name = get_author_name( $author );
$now = gmdate('Y-m-d H:i:s');
// $forum = phpbb_getoption('bb_forum');
$meta = get_post_meta($post_ID, "tags");
if (phpbb_topic_exist($post_ID)) {
} else {
$topic_id = phpbb_bb_new_topic( $title, $defboard, $author, $author_name, $now );
if ($topic_id) {
phpbb_set_permlinks($topic_id,$post_ID);
$contenido='<font size=4>'.$backtext.'<br><a href="'.$blogURL.'?p='.$post_ID.'">'.$title.'</a></font>';
phpbb_bb_new_post($topic_id, $contenido, $forum, $author, $now);
if ($meta[0] != "") { phpbb_tags($meta[0], $topic_id, $author); }
}
}
return $post_ID;
}
function phpbb_topic_exist($post_id) { // Exists topic or not
global $table_prefix, $wpdb;
$posts_table = $table_prefix . "phpbb_post_posts";
$topic_id=$wpdb->get_var("SELECT topic_id FROM `$posts_table` WHERE `post_id` = $post_id LIMIT 1;");
if ($topic_id != '') {
return true;
} else {
return false;
}
}
function phpbb_set_permlinks($topic_id,$post_ID) { // adding ID's of topic in forum & post in WP to db
global $table_prefix, $wpdb, $forumprefix, $defboard;
$posts_table = $table_prefix . "phpbb_post_posts";
$wpdb->query("INSERT INTO `$posts_table` VALUES ('', ". $post_ID .", ". $topic_id .");");
return true;
}
function phpbb_bb_new_topic( $title, $forum, $author, $author_name, $now ) { // making new topic in phpbb
global $wpdb ,$otherdb, $defboard, $posterID, $postername, $forumprefix;
// $bb_table_prefix = phpbb_getoption('bb_prefix');
if ( $forum && $title ) {
$wpdb->query("INSERT INTO `".$forumprefix."topics` (forum_id, topic_title, topic_poster, topic_time)
VALUES ($defboard, '$title', $posterID, '$now')");
$topic_id = $wpdb->insert_id;
$wpdb->query("UPDATE `".$forumprefix."forums` SET forum_topics = forum_topics + 1 WHERE forum_id = ".$defboard."");
$wpdb->query("UPDATE `".$forumprefix."forums` SET forum_posts = forum_posts + 1 WHERE forum_id = ".$defboard."");
return $topic_id;
} else {
return false;
}
}
function phpbb_bb_new_post( $topic_id, $content, $forum, $author, $now ) { // making new post in phpbb
global $wpdb, $otherdb, $posterID, $postername, $defboard, $forumprefix;
$ora = gmdate('Y-m-d H:i:s');
$wpdb->query("INSERT INTO `".$forumprefix."posts` (
`post_id` ,
`topic_id` ,
`forum_id` ,
`poster_id` ,
`post_time` ,
`poster_ip` ,
`post_username` ,
`enable_bbcode` ,
`enable_html` ,
`enable_smilies` ,
`enable_sig` ,
`post_edit_time` ,
`post_edit_count`
)
VALUES (
NULL , $topic_id, '$defboard', '$posterID', '$ora', '127.0.0.1', '$postername', '1', '0', '1', '1', NULL , '0'
);");
$post_id= $wpdb->insert_id;
$wpdb->query("INSERT INTO `".$forumprefix."posts_text` (
`post_id` ,
`bbcode_uid` ,
`post_subject` ,
`post_text`
)
VALUES ('$post_id', '', '', '$content');");
$wpdb->query("UPDATE `".$forumprefix."topics` SET `topic_first_post_id` = '$post_id',
`topic_last_post_id` = '$post_id' WHERE `".$forumprefix."topics`.`topic_id` ='$topic_id' LIMIT 1 ;");
$wpdb->query("UPDATE `".$forumprefix."forums` SET forum_last_post_id =".$post_id." WHERE forum_id = 1");
}
?>
Alles anzeigen