Index: trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme_class.php
===================================================================
--- trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme_class.php	(revision 592)
+++ trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme_class.php	(revision 593)
@@ -344,4 +344,21 @@
 		}
 	}
+	function D3Forum_create_new($d3forum_module_dir,$cat_id,$title){
+		global $xoops_db;
+		$d3forum_forum_tbl = get_xoops_prefix() . $d3forum_module_dir ."_forums";
+		$d3forum_forum_access_tbl = get_xoops_prefix() . $d3forum_module_dir ."_forum_access";
+		$sql  = "INSERT INTO $d3forum_forum_tbl ";
+		$sql .=    "(cat_id, forum_desc, forum_title,forum_options) ";
+		$sql .=  "VALUES ";
+		$sql .=    "('$cat_id', '', '$title','a:0:{}')";
+		$xoops_db->query($sql);
+		$insert_forum_id = mysql_insert_id();
+		$sql  = "INSERT INTO $d3forum_forum_access_tbl ";
+		$sql .=    "(forum_id, groupid, can_post, can_edit, can_delete, post_auto_approved, is_moderator) ";
+		$sql .=  "VALUES ";
+		$sql .=    "($insert_forum_id, 1, 1, 1, 1, 1, 1)";
+		$xoops_db->query($sql);
+		return $insert_forum_id;
+	}
 	
 	function ReadPostData($post_data = null)
@@ -372,5 +389,11 @@
 						$this->is_use_d3forum = true;
 						$this->d3forum_module_dir = $d3f_set[1];
-						$this->d3forum_forum_id = $d3f_set[2];
+						if (preg_match('/Create New In Cat=([0-9]*)/',$d3f_set[2],$matchs)){
+							$cat_id = $matchs[1];
+							$title = get_option('blogname');
+							$this->d3forum_forum_id = $this->D3Forum_create_new($this->d3forum_module_dir,$cat_id,$title);
+						} else {
+							$this->d3forum_forum_id = $d3f_set[2];
+						}
 						$this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent';
 						$this->D3Forum_link_set();
@@ -728,18 +751,26 @@
 						$forums_tb = get_xoops_prefix() . $module->dirname . '_forums';
 						$cat_tb = get_xoops_prefix() . $module->dirname . '_categories';
-						$sql= "SELECT * FROM $forums_tb LEFT JOIN $cat_tb ON $forums_tb.cat_id = $cat_tb.cat_id";
-						$forums = $xoops_db->get_results($sql);
-						foreach ($forums as $forum) {
-							if (($module->dirname == $this->d3forum_module_dir) &&  ($forum->forum_id == $this->d3forum_forum_id)){
-								$selected = ' selected="selected"';
-								$forum_div = 'forum|' . $module->dirname . '|' .  $forum->forum_id;
-								$forum_select = "$module->name($module->dirname) $forum->cat_title-$forum->forum_title(ID=$forum->forum_id)";
-								$forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n";
-							} else if (empty($forum->forum_external_link_format)){
-								$selected = '';
-								$forum_div = 'forum|' . $module->dirname . '|' .  $forum->forum_id;
-								$forum_select = "$module->name($module->dirname) $forum->cat_title-$forum->forum_title(ID=$forum->forum_id)";
-								$forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n";
+						$cat_sql = "SELECT * FROM $cat_tb";
+						$cats = $xoops_db->get_results($cat_sql);
+						foreach ($cats as $cat) {
+							$sql= "SELECT * FROM $forums_tb WHERE $forums_tb.cat_id = $cat->cat_id";
+							$forums = $xoops_db->get_results($sql);
+							foreach ($forums as $forum) {
+								if (($module->dirname == $this->d3forum_module_dir) &&  ($forum->forum_id == $this->d3forum_forum_id)){
+									$selected = ' selected="selected"';
+									$forum_div = 'forum|' . $module->dirname . '|' .  $forum->forum_id;
+									$forum_select = "$module->name($module->dirname) $cat->cat_title-$forum->forum_title(ID=$forum->forum_id)";
+									$forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n";
+								} else if (empty($forum->forum_external_link_format)){
+									$selected = '';
+									$forum_div = 'forum|' . $module->dirname . '|' .  $forum->forum_id;
+									$forum_select = "$module->name($module->dirname) $cat->cat_title-$forum->forum_title(ID=$forum->forum_id)";
+									$forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n";
+								}
 							}
+							$selected = '';
+							$forum_div = 'forum|' . $module->dirname . '|Create New In Cat=' .  $cat->cat_id;
+							$forum_select = "$module->name($module->dirname) $cat->cat_title-" . __('Create New Forum', 'xpressme');
+							$forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n";
 						}
 						break;
