/** * コミュニティを登録する * * @param $form コミュニティ情報 * return 成功(コミュニティID) / 失敗(false) */ static function set_community($form) { // コミュニティ種別マスタ $community_type_master_array = ACSDB::get_master_array('community_type'); //$community_type_code = array_search('コミュニティ', $community_type_master_array); $community_type_code = array_search(ACSMsg::get_mst('community_type_master', 'D40'), $community_type_master_array); // コンテンツ種別マスタ $contents_type_master_array = ACSDB::get_master_array('contents_type'); // コミュニティメンバ種別マスタ $community_member_type_master_array = ACSDB::get_master_array('community_member_type'); $org_form = $form; ACSLib::escape_sql_array($form); ACSLib::get_sql_value_array($form); // BEGIN ACSDB::_do_query("BEGIN"); // (1) コミュニティ (community) $community_id_seq = ACSDB::get_next_seq('community_id_seq'); $admission_flag = ACSLib::get_pg_boolean($org_form['admission_flag']); $sql = "INSERT INTO community"; $sql .= " (community_id, community_name, community_type_code, category_code, admission_flag)"; $sql .= " VALUES ('{$community_id_seq}', {$form['community_name']}, '{$community_type_code}', {$form['category_code']}, '{$admission_flag}')"; $ret = ACSDB::_do_query($sql); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } // contents // (2-1) (コミュニティ全体) $contents_form = array(); $contents_form['community_id'] = $community_id_seq; //$contents_form['contents_type_code'] = array_search('全体', $contents_type_master_array); $contents_form['contents_type_code'] = array_search(ACSMsg::get_mst('contents_type_master', 'D00'), $contents_type_master_array); $contents_form['contents_value'] = ''; $contents_form['open_level_code'] = ACSAccessControl::get_default_open_level_code(ACSMsg::get_mst('community_type_master', 'D40'), ACSMsg::get_mst('contents_type_master', 'D00')); $ret = ACSCommunity::set_contents($contents_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } // (2-2) コミュニティプロフィール $contents_form = array(); $contents_form['community_id'] = $community_id_seq; $contents_form['contents_type_code'] = array_search(ACSMsg::get_mst('contents_type_master', 'D07'), $contents_type_master_array); $contents_form['contents_value'] = $org_form['community_profile']; $contents_form['open_level_code'] = ACSAccessControl::get_default_open_level_code(ACSMsg::get_mst('community_type_master', 'D40'), ACSMsg::get_mst('contents_type_master', 'D07')); $ret = ACSCommunity::set_contents($contents_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } // (3) 参加資格 (join_trusted_community) if (is_array($org_form['join_trusted_community_id_array'])) { $join_trusted_community_form = array(); $join_trusted_community_form['community_id'] = $community_id_seq; foreach ($org_form['join_trusted_community_id_array'] as $trusted_community_id) { $join_trusted_community_form['trusted_community_id'] = $trusted_community_id; $ret = ACSCommunity::set_join_trusted_community($join_trusted_community_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } } } // (4) 公開範囲 電子掲示板 // contents $contents_form = array(); $contents_form['community_id'] = $community_id_seq; $contents_form['contents_type_code'] = array_search(ACSMsg::get_mst('contents_type_master', 'D41'), $contents_type_master_array); $contents_form['contents_value'] = ''; $contents_form['open_level_code'] = $org_form['bbs_open_level_code']; $ret = ACSCommunity::set_contents($contents_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } // contents_trusted_community if (is_array($org_form['bbs_trusted_community_id_array'])) { $contents_trusted_community_form = array(); $contents_trusted_community_form['community_id'] = $community_id_seq; $contents_trusted_community_form['contents_type_code'] = array_search(ACSMsg::get_mst('contents_type_master', 'D41'), $contents_type_master_array); $contents_trusted_community_form['open_level_code'] = $org_form['bbs_open_level_code']; foreach ($org_form['bbs_trusted_community_id_array'] as $trusted_community_id) { $contents_trusted_community_form['trusted_community_id'] = $trusted_community_id; $ret = ACSCommunity::set_contents_trusted_community($contents_trusted_community_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } } } // (5) 公開範囲 コミュニティフォルダ (cotents) // contents $contents_form = array(); $contents_form['community_id'] = $community_id_seq; $contents_form['contents_type_code'] = array_search(ACSMsg::get_mst('contents_type_master', 'D31'), $contents_type_master_array); $contents_form['contents_value'] = ''; $contents_form['open_level_code'] = $org_form['community_folder_open_level_code']; $ret = ACSCommunity::set_contents($contents_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } // contents_trusted_community if (is_array($org_form['community_folder_trusted_community_id_array'])) { $contents_trusted_community_form = array(); $contents_trusted_community_form['community_id'] = $community_id_seq; $contents_trusted_community_form['contents_type_code'] = array_search(ACSMsg::get_mst('contents_type_master', 'D31'), $contents_type_master_array); $contents_trusted_community_form['open_level_code'] = $org_form['community_folder_open_level_code']; foreach ($org_form['community_folder_trusted_community_id_array'] as $trusted_community_id) { $contents_trusted_community_form['trusted_community_id'] = $trusted_community_id; $ret = ACSCommunity::set_contents_trusted_community($contents_trusted_community_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } } } // (6) 公開範囲 全体 // contents $contents_form = array(); $contents_form['community_id'] = $community_id_seq; //$contents_form['contents_type_code'] = array_search('全体', $contents_type_master_array); $contents_form['contents_type_code'] = array_search(ACSMsg::get_mst('contents_type_master', 'D00'), $contents_type_master_array); $contents_form['contents_value'] = ''; $contents_form['open_level_code'] = $org_form['self_open_level_code']; $ret = ACSCommunity::set_contents($contents_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } // (7) コミュニティ管理者をセットする $community_admin_form = array(); $community_admin_form['community_id'] = $community_id_seq; $community_admin_form['user_community_id'] = $org_form['user_community_id']; $ret = ACSCommunity::set_community_admin($community_admin_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } // (8) コミュニティML // contents // コミュニティMLアドレス if ($org_form['community_ml_address']) { $contents_form = array(); $contents_form['community_id'] = $community_id_seq; $contents_form['contents_type_code'] = array_search(ACSMsg::get_mst('contents_type_master', 'D61'), $contents_type_master_array); $contents_form['contents_value'] = $org_form['community_ml_address']; $contents_form['open_level_code'] = ACSAccessControl::get_default_open_level_code(ACSMsg::get_mst('community_type_master', 'D40'), ACSMsg::get_mst('contents_type_master', 'D61')); $ret = ACSCommunity::set_contents($contents_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } // コミュニティMLステータス $contents_form = array(); $contents_form['community_id'] = $community_id_seq; $contents_form['contents_type_code'] = array_search(ACSMsg::get_mst('contents_type_master', 'D62'), $contents_type_master_array); $contents_form['contents_value'] = 'QUEUE'; $contents_form['open_level_code'] = ACSAccessControl::get_default_open_level_code(ACSMsg::get_mst('community_type_master', 'D40'), ACSMsg::get_mst('contents_type_master', 'D62')); $ret = ACSCommunity::set_contents($contents_form); if (!$ret) { ACSDB::_do_query("ROLLBACK"); return $ret; } } // COMMIT ACSDB::_do_query("COMMIT"); return $community_id_seq; }