XPressME Integration Kit

Trac


Ignore:
Timestamp:
Apr 30, 2010, 2:28:40 PM (14 years ago)
Author:
toemon
Message:

D3Forum統合用フォーラムの自動作成処理を設ける。 Fixes #341

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme_class.php

    r592 r593  
    344344                } 
    345345        } 
     346        function D3Forum_create_new($d3forum_module_dir,$cat_id,$title){ 
     347                global $xoops_db; 
     348                $d3forum_forum_tbl = get_xoops_prefix() . $d3forum_module_dir ."_forums"; 
     349                $d3forum_forum_access_tbl = get_xoops_prefix() . $d3forum_module_dir ."_forum_access"; 
     350                $sql  = "INSERT INTO $d3forum_forum_tbl "; 
     351                $sql .=    "(cat_id, forum_desc, forum_title,forum_options) "; 
     352                $sql .=  "VALUES "; 
     353                $sql .=    "('$cat_id', '', '$title','a:0:{}')"; 
     354                $xoops_db->query($sql); 
     355                $insert_forum_id = mysql_insert_id(); 
     356                $sql  = "INSERT INTO $d3forum_forum_access_tbl "; 
     357                $sql .=    "(forum_id, groupid, can_post, can_edit, can_delete, post_auto_approved, is_moderator) "; 
     358                $sql .=  "VALUES "; 
     359                $sql .=    "($insert_forum_id, 1, 1, 1, 1, 1, 1)"; 
     360                $xoops_db->query($sql); 
     361                return $insert_forum_id; 
     362        } 
    346363         
    347364        function ReadPostData($post_data = null) 
     
    372389                                                $this->is_use_d3forum = true; 
    373390                                                $this->d3forum_module_dir = $d3f_set[1]; 
    374                                                 $this->d3forum_forum_id = $d3f_set[2]; 
     391                                                if (preg_match('/Create New In Cat=([0-9]*)/',$d3f_set[2],$matchs)){ 
     392                                                        $cat_id = $matchs[1]; 
     393                                                        $title = get_option('blogname'); 
     394                                                        $this->d3forum_forum_id = $this->D3Forum_create_new($this->d3forum_module_dir,$cat_id,$title); 
     395                                                } else { 
     396                                                        $this->d3forum_forum_id = $d3f_set[2]; 
     397                                                } 
    375398                                                $this->d3forum_external_link_format = get_xpress_dir_name() . '::xpressD3commentContent'; 
    376399                                                $this->D3Forum_link_set(); 
     
    728751                                                $forums_tb = get_xoops_prefix() . $module->dirname . '_forums'; 
    729752                                                $cat_tb = get_xoops_prefix() . $module->dirname . '_categories'; 
    730                                                 $sql= "SELECT * FROM $forums_tb LEFT JOIN $cat_tb ON $forums_tb.cat_id = $cat_tb.cat_id"; 
    731                                                 $forums = $xoops_db->get_results($sql); 
    732                                                 foreach ($forums as $forum) { 
    733                                                         if (($module->dirname == $this->d3forum_module_dir) &&  ($forum->forum_id == $this->d3forum_forum_id)){ 
    734                                                                 $selected = ' selected="selected"'; 
    735                                                                 $forum_div = 'forum|' . $module->dirname . '|' .  $forum->forum_id; 
    736                                                                 $forum_select = "$module->name($module->dirname) $forum->cat_title-$forum->forum_title(ID=$forum->forum_id)"; 
    737                                                                 $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n"; 
    738                                                         } else if (empty($forum->forum_external_link_format)){ 
    739                                                                 $selected = ''; 
    740                                                                 $forum_div = 'forum|' . $module->dirname . '|' .  $forum->forum_id; 
    741                                                                 $forum_select = "$module->name($module->dirname) $forum->cat_title-$forum->forum_title(ID=$forum->forum_id)"; 
    742                                                                 $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n"; 
     753                                                $cat_sql = "SELECT * FROM $cat_tb"; 
     754                                                $cats = $xoops_db->get_results($cat_sql); 
     755                                                foreach ($cats as $cat) { 
     756                                                        $sql= "SELECT * FROM $forums_tb WHERE $forums_tb.cat_id = $cat->cat_id"; 
     757                                                        $forums = $xoops_db->get_results($sql); 
     758                                                        foreach ($forums as $forum) { 
     759                                                                if (($module->dirname == $this->d3forum_module_dir) &&  ($forum->forum_id == $this->d3forum_forum_id)){ 
     760                                                                        $selected = ' selected="selected"'; 
     761                                                                        $forum_div = 'forum|' . $module->dirname . '|' .  $forum->forum_id; 
     762                                                                        $forum_select = "$module->name($module->dirname) $cat->cat_title-$forum->forum_title(ID=$forum->forum_id)"; 
     763                                                                        $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n"; 
     764                                                                } else if (empty($forum->forum_external_link_format)){ 
     765                                                                        $selected = ''; 
     766                                                                        $forum_div = 'forum|' . $module->dirname . '|' .  $forum->forum_id; 
     767                                                                        $forum_select = "$module->name($module->dirname) $cat->cat_title-$forum->forum_title(ID=$forum->forum_id)"; 
     768                                                                        $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n"; 
     769                                                                } 
    743770                                                        } 
     771                                                        $selected = ''; 
     772                                                        $forum_div = 'forum|' . $module->dirname . '|Create New In Cat=' .  $cat->cat_id; 
     773                                                        $forum_select = "$module->name($module->dirname) $cat->cat_title-" . __('Create New Forum', 'xpressme'); 
     774                                                        $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n"; 
    744775                                                } 
    745776                                                break; 
Note: See TracChangeset for help on using the changeset viewer.