function execute()
 {
     $context = $this->getContext();
     $controller = $context->getController();
     $request = $context->getRequest();
     $user = $context->getUser();
     if (!$this->get_execute_privilege()) {
         $controller->forward(SECURE_MODULE, SECURE_ACTION);
         return;
     }
     $acs_user_info_row = $user->getAttribute('acs_user_info_row');
     // 対象となるコミュニティIDを取得
     $community_id = $request->ACSgetParameter('community_id');
     $form = $request->ACSGetParameters();
     // コミュニティ情報
     $community_row = ACSCommunity::get_community_profile_row($community_id);
     // forward
     $done_obj = new ACSDone();
     ACSDB::_do_query("BEGIN");
     // 生成されたwaiting_idの配列
     $waiting_id_array = array();
     $ret = 1;
     // 1:成功 / 0:失敗
     foreach ($form['trusted_community_id_array'] as $link_community_id) {
         if (ACSCommunity::is_community_admin($acs_user_info_row['user_community_id'], $link_community_id)) {
             // リンク依頼先コミュニティの管理者である場合は承認待ち登録せずに、即座にリンクを追加する
             if ($form['link_type'] == 'parent') {
                 $ret = ACSCommunity::set_community_link($link_community_id, $community_id);
             } elseif ($form['link_type'] == 'sub') {
                 $ret = ACSCommunity::set_community_link($community_id, $link_community_id);
             }
         } else {
             if ($form['link_type'] == 'parent') {
                 // 親コミュニティ追加承認待ち登録
                 $waiting_id = ACSWaiting::set_waiting_for_parent_community_link($link_community_id, $community_id, $acs_user_info_row['user_community_id'], $form['message']);
             } elseif ($form['link_type'] == 'sub') {
                 // サブコミュニティ追加承認待ち登録
                 $waiting_id = ACSWaiting::set_waiting_for_sub_community_link($link_community_id, $community_id, $acs_user_info_row['user_community_id'], $form['message']);
             }
             if ($waiting_id) {
                 // 生成されたwaiting情報を保持
                 array_push($waiting_id_array, $waiting_id);
             } else {
                 $ret = 0;
             }
         }
         if (!$ret) {
             ACSDB::_do_query("ROLLBACK");
             break;
         }
     }
     if ($ret) {
         // COMMIT
         ACSDB::_do_query("COMMIT");
         // 生成されたwaiting情報を元に複数メール送信
         foreach ($waiting_id_array as $waiting_id) {
             // コミュニティ間リンク追加依頼通知メール
             ACSWaiting::send_admission_request_notify_mail($waiting_id);
         }
         $done_obj->set_title(ACSMsg::get_msg('Community', 'AddCommunityLinkAction.class.php', 'M001'));
         $done_obj->set_message(ACSMsg::get_msg('Community', 'AddCommunityLinkAction.class.php', 'M002'));
         $done_obj->add_link(ACSMsg::get_msg('Community', 'AddCommunityLinkAction.class.php', 'M003'), $this->getControllerPath('Community', 'CommunityLink') . '&community_id=' . $community_row['community_id']);
         $done_obj->add_link($community_row['community_name'] . ' ' . ACSMsg::get_msg('Community', 'AddCommunityLinkAction.class.php', 'M004'), $this->getControllerPath('Community', DEFAULT_ACTION) . '&community_id=' . $community_row['community_id']);
     } else {
         $done_obj->set_message('失敗しました。');
     }
     $request->setAttribute('done_obj', $done_obj);
     $controller->forward('Common', 'Done');
 }
 function execute()
 {
     $context = $this->getContext();
     $controller = $context->getController();
     $request = $context->getRequest();
     $user = $context->getUser();
     $acs_user_info_row = $user->getAttribute('acs_user_info_row');
     // 対象となるコミュニティIDを取得
     $form = $request->ACSgetParameters();
     // 待機種別マスタ
     $waiting_type_master_array = ACSDB::get_master_array('waiting_type');
     // 待機状態マスタ
     $waiting_status_master_array = ACSDB::get_master_array('waiting_status');
     // 待機情報
     $waiting_row = ACSWaiting::get_waiting_row($form['waiting_id']);
     // コミュニティ情報
     $community_row = ACSCommunity::get_community_row($waiting_row['community_id']);
     // forward
     $done_obj = new ACSDone();
     if ($form['accept_button']) {
         // 承認ボタン押下時 //
         ACSDB::_do_query("BEGIN");
         if ($waiting_row['waiting_type_name'] == ACSMsg::get_mst('waiting_type_master', 'D20')) {
             // コミュニティメンバ追加
             $community_member_form = array();
             $community_member_form['community_id'] = $waiting_row['community_id'];
             $community_member_form['user_community_id'] = $waiting_row['waiting_community_id'];
             $ret = ACSCommunity::set_community_member($community_member_form);
         } elseif ($waiting_row['waiting_type_name'] == ACSMsg::get_mst('waiting_type_master', 'D40')) {
             // コミュニティ間リンク設定
             $ret = ACSCommunity::set_community_link($waiting_row['community_id'], $waiting_row['waiting_community_id']);
         } elseif ($waiting_row['waiting_type_name'] == ACSMsg::get_mst('waiting_type_master', 'D50')) {
             // コミュニティ間リンク設定
             $ret = ACSCommunity::set_community_link($waiting_row['waiting_community_id'], $waiting_row['community_id']);
         }
         if ($ret) {
             // 承認済みをセット
             $ret = ACSWaiting::update_waiting_waiting_status_code($form['waiting_id'], ACSMsg::get_mst('waiting_status_master', 'D20'), $acs_user_info_row['user_community_id'], $form['reply_message']);
             if ($ret) {
                 ACSDB::_do_query("COMMIT");
                 // 整合性保持
                 if ($waiting_row['waiting_type_name'] == ACSMsg::get_mst('waiting_type_master', 'D20')) {
                     // 参加の重複を解除
                     ACSWaiting::update_waiting_for_join_community($waiting_row['community_id'], $waiting_row['waiting_community_id']);
                     // 招待の重複を解除
                     ACSWaiting::update_waiting_for_invite_to_community($waiting_row['waiting_community_id'], $waiting_row['community_id']);
                 } elseif ($waiting_row['waiting_type_name'] == ACSMsg::get_mst('waiting_type_master', 'D40')) {
                     // 親コミュニティ追加の重複解除
                     ACSWaiting::update_waiting_for_parent_community_link($waiting_row['community_id'], $waiting_row['waiting_community_id']);
                     // サブコミュニティ追加の重複解除
                     ACSWaiting::update_waiting_for_sub_community_link($waiting_row['waiting_community_id'], $waiting_row['community_id']);
                 } elseif ($waiting_row['waiting_type_name'] == ACSMsg::get_mst('waiting_type_master', 'D50')) {
                     // サブコミュニティ追加の重複解除
                     ACSWaiting::update_waiting_for_sub_community_link($waiting_row['community_id'], $waiting_row['waiting_community_id']);
                     // 親コミュニティ追加の重複解除
                     ACSWaiting::update_waiting_for_parent_community_link($waiting_row['waiting_community_id'], $waiting_row['community_id']);
                 }
                 // 返信メッセージ
                 if ($form['reply_message'] != '') {
                     $ret = ACSWaiting::send_admission_accept_notify_mail($form['waiting_id']);
                 }
                 $done_obj->set_title(ACSMsg::get_tag_replace(ACSMsg::get_msg('Community', 'WaitingListAction.class.php', 'FIN_ADM'), array("{WAITING_TYPE_NAME}" => $waiting_row[waiting_type_name])));
                 $done_obj->set_message(ACSMsg::get_msg('Community', 'WaitingListAction.class.php', 'M001'));
             } else {
                 $done_obj->set_message(ACSMsg::get_msg('Community', 'WaitingListAction.class.php', 'M002'));
             }
         } else {
             ACSDB::_do_query("ROLLBACK");
         }
     } elseif ($form['reject_button']) {
         // 拒否ボタン押下時
         $ret = ACSWaiting::update_waiting_waiting_status_code($form['waiting_id'], ACSMsg::get_mst('waiting_status_master', 'D30'), $acs_user_info_row['user_community_id']);
         if ($ret) {
             $done_obj->set_title(ACSMsg::get_tag_replace(ACSMsg::get_msg('Community', 'WaitingListAction.class.php', 'FIN_DIS'), array("{WAITING_TYPE_NAME}" => $waiting_row[waiting_type_name])));
             $done_obj->set_message(ACSMsg::get_msg('Community', 'WaitingListAction.class.php', 'M001'));
         } else {
             $done_obj->set_message(ACSMsg::get_msg('Community', 'WaitingListAction.class.php', 'M002'));
         }
     }
     $done_obj->add_link(ACSMsg::get_tag_replace(ACSMsg::get_msg('Community', 'WaitingListAction.class.php', 'BACK_TO_CM'), array("{COMMUNITY_NAME}" => $community_row['community_name'])), $this->getControllerPath('Community', DEFAULT_ACTION) . '&community_id=' . $community_row['community_id']);
     $request->setAttribute('done_obj', $done_obj);
     $controller->forward('Common', 'Done');
 }