Ejemplo n.º 1
0
 /**
  * コミュニティを更新する
  * 2006/3/9
  * @param $form コミュニティ情報
  * return 成功(コミュニティID) / 失敗(false)
  */
 static function update_community($form)
 {
     // コミュニティ種別マスタ
     $community_type_master_array = ACSDB::get_master_array('community_type');
     $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');
     $community_id_seq = $form['community_id'];
     $org_form = $form;
     ACSLib::escape_sql_array($form);
     ACSLib::get_sql_value_array($form);
     // BEGIN
     ACSDB::_do_query("BEGIN");
     // (1) コミュニティ (community)
     $admission_flag = ACSLib::get_pg_boolean($org_form['admission_flag']);
     $sql = "UPDATE community";
     $sql .= " SET community_name = {$form['community_name']},";
     $sql .= " category_code = {$form['category_code']},";
     $sql .= " admission_flag = {$form['admission_flag']}";
     $sql .= " WHERE community_id = {$community_id_seq}";
     $ret = ACSDB::_do_query($sql);
     if (!$ret) {
         ACSDB::_do_query("ROLLBACK");
         return $ret;
     }
     // (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)
     $join_trusted_community_form = array();
     $join_trusted_community_form['community_id'] = $community_id_seq;
     // join_trusted_community 前準備 旧データの一括削除
     $ret = ACSCommunity::delete_join_trusted_community($join_trusted_community_form);
     if (!$ret) {
         ACSDB::_do_query("ROLLBACK");
         return $ret;
     }
     //登録
     if (is_array($org_form['join_trusted_community_id_array'])) {
         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'];
         // contents_trusted_community 前準備 旧データの一括削除
         $ret = ACSCommunity::update_contents_trusted_community($contents_trusted_community_form);
         if (!$ret) {
             ACSDB::_do_query("ROLLBACK");
             return $ret;
         }
         //登録
         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'];
         // contents_trusted_community 前準備 旧データの一括削除
         $ret = ACSCommunity::update_contents_trusted_community($contents_trusted_community_form);
         if (!$ret) {
             ACSDB::_do_query("ROLLBACK");
             return $ret;
         }
         // 登録
         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(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) コミュニティ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;
 }