--- /dev/null
+<?php
+/**
+ * ·Ç¼¨ÈÄ¡¡Åê¹Æµ¡Ç½¡¡action¥¯¥é¥¹
+ * Åê¹Æ¾ðÊó¡¡³Îǧ¡¦ÅÐÏ¿½èÍý
+ * @package acs/webapp/modules/Community/action
+ * @author akitsu
+ * @since PHP 4.0
+ * @version $Revision: 1.12 $ $Date: 2006/12/19 10:17:26 $
+ */
+// $Id: BBSPreAction.class.php,v 1.12 2006/12/19 10:17:26 w-ota Exp $
+class BBSPreAction extends BaseAction
+{
+ //field
+ var $form;
+
+ // GET
+ function getDefaultView() {
+ $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->getParameter('community_id');
+ // ¥³¥ß¥å¥Ë¥Æ¥£¾ðÊó
+ $community_row = ACSCommunity::get_community_row($community_id);
+ // ¸ø³«ÈÏ°Ï
+ $open_level_master_row_array = ACSAccessControl::get_open_level_master_row_array(ACSMsg::get_mst('community_type_master','D40'), ACSMsg::get_mst('contents_type_master','D42'));
+
+ // set
+ $request->setAttribute('community_row', $community_row);
+ $request->setAttribute('acs_user_info_row', $acs_user_info_row);
+ $request->setAttribute('open_level_master_row_array', $open_level_master_row_array);
+
+ return View::SUCCESS;
+ }
+
+ // POST
+ 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;
+ }
+
+ //mode¡¡²èÌ̤ÎÁ«°Ü¤ò¼èÆÀ¤¹¤ë
+ $move_id = $request->getParameter('move_id');
+ // ¸ø³«ÈÏ°Ï
+ $open_level_master_row_array = ACSAccessControl::get_open_level_master_row_array(ACSMsg::get_mst('community_type_master','D40'), ACSMsg::get_mst('contents_type_master','D42'));
+ // ¥æ¡¼¥¶¡¼¾ðÊó
+ $acs_user_info_row = $user->getAttribute('acs_user_info_row');
+ // ÂоݤȤʤ륳¥ß¥å¥Ë¥Æ¥£ID¤ò¼èÆÀ
+ $community_id = $request->getParameter('community_id');
+ //¥¨¥é¡¼¤Î½é´ü²½
+
+
+/* ÆþÎϲèÌ̤è¤ê */
+ if($move_id==1){
+ $err = 'OK'; //¥¨¥é¡¼Ãͤνé´ü²½
+//¡ù¡ù¡¡¤³¤³¤«¤é¤Û¤ÜƱ¤¸
+ // ²èÌ̾å¤Î¥Õ¥©¡¼¥à¾ðÊó¤ò¼èÆÀ¤¹¤ë
+ $form['subject'] = $request->getParameter('subject');//·ï̾¡§subject
+ $form['body'] = $request->getParameter('body'); //ÆâÍÆ¡§body
+ $form['open_level_code'] = $request->getParameter('open_level_code'); //¸ø³«ÈÏ°Ï¥³¡¼¥É¡§open_level_code
+ foreach ($open_level_master_row_array as $open_level_master_row) {
+ if($open_level_master_row['open_level_code'] == $form['open_level_code']){
+ $form['open_level_name'] = htmlspecialchars($open_level_master_row['open_level_name']) ;//¸ø³«ÈÏ°Ïɽ¼¨Ì¾¡§open_level_name
+ }
+ }
+ $form['new_file'] = $request->getParameter('new_file'); //²èÁü¡§new_file
+ //¥Õ¥¡¥¤¥ë¾ðÊó¤Î¤¢¤ë¤Ê¤·¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤ª¤¯
+ if (!ini_get('mbstring.encoding_translation')) {
+ $form['file_name'] = mb_convert_encoding($_FILES['new_file']['name'], mb_internal_encoding(), mb_http_output());
+ } else {
+ $form['file_name'] = $_FILES['new_file']['name'];
+ }
+
+ if($form['file_name'] != ''){
+ /* ¥Ç¥£¥ì¥¯¥È¥ê¸ºß¥Á¥§¥Ã¥¯ */
+ // ¤Ê¤¤¾ì¹ç¤ÏºîÀ®¤¹¤ë
+ $to_dir = ACS_TEMPORARY_FILE_DIR;
+ if(!file_exists($to_dir)) {mkdir($to_dir); chmod($to_dir, 0777);}
+ //¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¾ì¹ç¡¢²¾ÃÖ¤¾ì½ê¤òÀßÄꤹ¤ë
+ $_FILES['new_file']['upload_tmp_dir'] = ACS_TEMPORARY_FILE_DIR;
+ //²¾ÃÖ¤¤Î¥Õ¥¡¥¤¥ë̾¤òÀßÄꤹ¤ë
+ $type_name = session_id();
+ $upload = $_FILES['new_file']['upload_tmp_dir'];
+ $upload .= $type_name;
+ if ( !move_uploaded_file( $_FILES['new_file']['tmp_name'], $upload ) ) {
+ echo "¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿\n";
+ }
+ $_FILES['new_file']['tmp_name'] = $upload;
+ $form['file_obj'] = $_FILES['new_file'];
+ $user->setAttribute('new_file_info',$upload);
+ $user->setAttribute('new_file_obj',$_FILES['new_file']);
+ }
+ $form['xdate'] = $request->getParameter('xdate'); //·ÇºÜºÇ½ªÆü¡§xdate
+ //·ÇºÜºÇ½ªÆü¥Ç¥Õ¥©¥ë¥ÈÃÍ
+ if($form['xdate'] == ''){
+ $form[xdate] ='';
+ }
+ //±ÜÍ÷µö²Ä¥³¥ß¥å¥Ë¥Æ¥£
+ $form['trusted_community_id_array'] = $request->getParameter('trusted_community_id_array');
+ $form['trusted_community_row_array'] = ACSCommunity::get_each_community_row_array($form['trusted_community_id_array']);
+
+ $form['community_id'] = $community_id; //Åö¥³¥ß¥å¥Ë¥Æ¥£¤ÎID
+ $form['user_community_id'] = $acs_user_info_row['user_community_id']; // Åê¹Æ¼Ôprint "form_row:";
+
+ // MLÁ÷¿®¥ª¥×¥·¥ç¥ó
+ $form['is_ml_send'] = $request->getParameter('is_ml_send'); //²èÁü¡§new_file
+//¡ù¡ù¡¡¤³¤³¤Þ¤Ç¤Û¤ÜƱ¤¸
+ $user->setAttribute('new_form_obj',$form);
+
+ return View::SUCCESS;
+
+
+
+
+
+/* ÅÐÏ¿³ÎÄê¥Ü¥¿¥ó¡Ö¤Ï¤¤¡×¤è¤ê */
+ }else if($move_id==2){
+//¡ù¡ù¡¡¤³¤³¤«¤é¤Û¤ÜƱ
+ // ²èÌ̾å¤Î¥Õ¥©¡¼¥à¾ðÊó¤ò¼èÆÀ¤¹¤ë
+ $form = $user->getAttribute('new_form_obj');
+ $new_file_obj = $form['file_obj'];
+//¡ù¡ù¡¡¤³¤³¤Þ¤Ç¤Û¤ÜƱ¤¸
+ // DB¤Ø¤Î½ñ¤¹þ¤ßÅù
+ ACSDB::_do_query("BEGIN");
+ if($form['file_name'] != ""){ //¥Õ¥¡¥¤¥ë¾ðÊ󤬤¢¤Ã¤¿¾ì¹ç
+ //1.¥Õ¥¡¥¤¥ë¾ðÊó¼èÆÀ(¿·µ¬)
+ $file_obj = ACSFile::get_upload_file_info_instance($user->getAttribute('new_file_obj'),$community_id,$form['user_community_id']);
+ //form¾ðÊó¤ØÅÐÏ¿
+ $form['new_file'] = $file_obj;
+ }
+ //2.bbs¥Æ¡¼¥Ö¥ë¾ðÊó
+ $ret = ACSBBS::set_bbs($form);
+ if($ret){
+ ACSDB::_do_query("COMMIT");
+ // ·Ç¼¨ÈÄ¥¢¥¯¥»¥¹ÍúÎò
+ ACSBBS::set_bbs_access_history($acs_user_info_row['user_community_id'], $ret);
+ }else{
+ ACSDB::_do_query("ROLLBACK");
+ }
+ $bbs_id_seq = $ret;
+
+ // ML¥ª¥×¥·¥ç¥ó¤¢¤ê¤Î¾ì¹ç
+ if ($form['is_ml_send']=='t') {
+
+ // ML¥¹¥Æ¡¼¥¿¥¹¤Î¼èÆÀ
+ $ml_status_row = ACSCommunity::get_contents_row(
+ $community_id, ACSMsg::get_mst('contents_type_master','D62'));
+ $ml_status = $ml_status_row['contents_value'];
+
+ // MLͤê¤Î¾ì¹ç¥á¡¼¥ë¤òÁ÷¿®
+ if ($bbs_id_seq && $ml_status == 'ACTIVE') {
+
+ // ·ï̾ÊÔ½¸
+ $subject = str_replace('{BBSID}',
+ $bbs_id_seq,ACS_COMMUNITY_ML_SUBJECT_FORMAT) . $form['subject'];
+
+ // MLÁ÷¿®
+ ACSCommunityMail::send_community_mailing_list(
+ $community_id,
+ $acs_user_info_row['mail_addr'],
+ $subject,
+ $form['body']);
+ }
+ }
+
+ $action_url = $this->getControllerPath('Community', 'BBS'). '&community_id=' . $community_id. '&move_id=4';
+
+ header("Location: $action_url");
+ }
+}
+
+ function getRequestMethods() {
+ return Request::POST;
+ }
+
+ function validate () {
+ return TRUE;
+ }
+
+ function registerValidators (&$validatorManager) {
+ $context = $this->getContext();
+ $controller = $context->getController();
+ $request = $context->getRequest();
+ $user = $context->getUser();
+
+ $move_id = $request->getParameter('move_id');
+
+ // ÆþÎϲèÌ̤«¤é¤Î¾ì¹ç¤Î¤ß¡¢ÆþÎÏ¥Á¥§¥Ã¥¯¤ò¤¹¤ë
+ if ($move_id == 1) {
+ /* ɬ¿Ü¥Á¥§¥Ã¥¯ */
+ parent::regValidateName($validatorManager,
+ "subject",
+ true,
+ ACSMsg::get_msg('Community', 'BBSPreAction.class.php', 'M001'));
+ parent::regValidateName($validatorManager,
+ "body",
+ true,
+ ACSMsg::get_msg('Community', 'BBSPreAction.class.php', 'M002'));
+ parent::regValidateName($validatorManager,
+ "open_level_code",
+ true,
+ ACSMsg::get_msg('Community', 'BBSPreAction.class.php', 'M003'));
+
+ /* ÆüÉÕ¥Á¥§¥Ã¥¯ */
+ // ·ÇºÜ½ªÎ»Æü
+ $xdate = $request->getParameter('xdate');
+ if ($xdate) {
+ $validator =& new DateValidator($controller);
+ $criteria = array('date_error' => ACSMsg::get_msg('Community', 'BBSPreAction.class.php', 'M004'));
+ $validator->initialize($criteria);
+ //$validatorManager->register('xdate', $validator);
+ $validatorManager->registerValidator('xdate', $validator);
+ }
+ }
+ }
+
+ function handleError () {
+ return $this->execute();
+ }
+
+ function isSecure () {
+ return false;
+ }
+
+ function getCredential () {
+ return array('COMMUNITY_MEMBER');
+ }
+
+ function get_execute_privilege () {
+ $context = $this->getContext();
+ $user = $context->getUser();
+
+ // ¥³¥ß¥å¥Ë¥Æ¥£¥á¥ó¥Ð¤ÏOK
+ if ($user->hasCredential('COMMUNITY_MEMBER')) {
+ return true;
+ }
+ return false;
+ }
+}
+
+?>