3 * ·Ç¼¨ÈÄ¡¡Åê¹Æµ¡Ç½¡¡action¥¯¥é¥¹
4 * Åê¹Æ¾ðÊó¡¡³Îǧ¡¦ÅÐÏ¿½èÍý
5 * @package acs/webapp/modules/Community/action
8 * @version $Revision: 1.12 $ $Date: 2006/12/19 10:17:26 $
10 // $Id: BBSPreAction.class.php,v 1.12 2006/12/19 10:17:26 w-ota Exp $
11 class BBSPreAction extends BaseAction
17 function getDefaultView() {
18 $context = $this->getContext();
19 $controller = $context->getController();
20 $request = $context->getRequest();
21 $user = $context->getUser();
23 if (!$this->get_execute_privilege()) {
24 $controller->forward(SECURE_MODULE, SECURE_ACTION);
28 $acs_user_info_row = $user->getAttribute('acs_user_info_row');
29 // ÂоݤȤʤ륳¥ß¥å¥Ë¥Æ¥£ID¤ò¼èÆÀ
30 $community_id = $request->getParameter('community_id');
32 $community_row = ACSCommunity::get_community_row($community_id);
34 $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'));
37 $request->setAttribute('community_row', $community_row);
38 $request->setAttribute('acs_user_info_row', $acs_user_info_row);
39 $request->setAttribute('open_level_master_row_array', $open_level_master_row_array);
46 $context = $this->getContext();
47 $controller = $context->getController();
48 $request = $context->getRequest();
49 $user = $context->getUser();
51 if (!$this->get_execute_privilege()) {
52 $controller->forward(SECURE_MODULE, SECURE_ACTION);
56 //mode¡¡²èÌ̤ÎÁ«°Ü¤ò¼èÆÀ¤¹¤ë
57 $move_id = $request->getParameter('move_id');
59 $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'));
61 $acs_user_info_row = $user->getAttribute('acs_user_info_row');
62 // ÂоݤȤʤ륳¥ß¥å¥Ë¥Æ¥£ID¤ò¼èÆÀ
63 $community_id = $request->getParameter('community_id');
69 $err = 'OK'; //¥¨¥é¡¼Ãͤνé´ü²½
70 //¡ù¡ù¡¡¤³¤³¤«¤é¤Û¤ÜƱ¤¸
71 // ²èÌ̾å¤Î¥Õ¥©¡¼¥à¾ðÊó¤ò¼èÆÀ¤¹¤ë
72 $form['subject'] = $request->getParameter('subject');//·ï̾¡§subject
73 $form['body'] = $request->getParameter('body'); //ÆâÍÆ¡§body
74 $form['open_level_code'] = $request->getParameter('open_level_code'); //¸ø³«ÈÏ°Ï¥³¡¼¥É¡§open_level_code
75 foreach ($open_level_master_row_array as $open_level_master_row) {
76 if($open_level_master_row['open_level_code'] == $form['open_level_code']){
77 $form['open_level_name'] = htmlspecialchars($open_level_master_row['open_level_name']) ;//¸ø³«ÈÏ°Ïɽ¼¨Ì¾¡§open_level_name
80 $form['new_file'] = $request->getParameter('new_file'); //²èÁü¡§new_file
81 //¥Õ¥¡¥¤¥ë¾ðÊó¤Î¤¢¤ë¤Ê¤·¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤ª¤¯
82 if (!ini_get('mbstring.encoding_translation')) {
83 $form['file_name'] = mb_convert_encoding($_FILES['new_file']['name'], mb_internal_encoding(), mb_http_output());
85 $form['file_name'] = $_FILES['new_file']['name'];
88 if($form['file_name'] != ''){
89 /* ¥Ç¥£¥ì¥¯¥È¥ê¸ºß¥Á¥§¥Ã¥¯ */
91 $to_dir = ACS_TEMPORARY_FILE_DIR;
92 if(!file_exists($to_dir)) {mkdir($to_dir); chmod($to_dir, 0777);}
93 //¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¾ì¹ç¡¢²¾ÃÖ¤¾ì½ê¤òÀßÄꤹ¤ë
94 $_FILES['new_file']['upload_tmp_dir'] = ACS_TEMPORARY_FILE_DIR;
95 //²¾ÃÖ¤¤Î¥Õ¥¡¥¤¥ë̾¤òÀßÄꤹ¤ë
96 $type_name = session_id();
97 $upload = $_FILES['new_file']['upload_tmp_dir'];
98 $upload .= $type_name;
99 if ( !move_uploaded_file( $_FILES['new_file']['tmp_name'], $upload ) ) {
100 echo "¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿\n";
102 $_FILES['new_file']['tmp_name'] = $upload;
103 $form['file_obj'] = $_FILES['new_file'];
104 $user->setAttribute('new_file_info',$upload);
105 $user->setAttribute('new_file_obj',$_FILES['new_file']);
107 $form['xdate'] = $request->getParameter('xdate'); //·ÇºÜºÇ½ªÆü¡§xdate
108 //·ÇºÜºÇ½ªÆü¥Ç¥Õ¥©¥ë¥ÈÃÍ
109 if($form['xdate'] == ''){
112 //±ÜÍ÷µö²Ä¥³¥ß¥å¥Ë¥Æ¥£
113 $form['trusted_community_id_array'] = $request->getParameter('trusted_community_id_array');
114 $form['trusted_community_row_array'] = ACSCommunity::get_each_community_row_array($form['trusted_community_id_array']);
116 $form['community_id'] = $community_id; //Åö¥³¥ß¥å¥Ë¥Æ¥£¤ÎID
117 $form['user_community_id'] = $acs_user_info_row['user_community_id']; // Åê¹Æ¼Ôprint "form_row:";
120 $form['is_ml_send'] = $request->getParameter('is_ml_send'); //²èÁü¡§new_file
121 //¡ù¡ù¡¡¤³¤³¤Þ¤Ç¤Û¤ÜƱ¤¸
122 $user->setAttribute('new_form_obj',$form);
124 return View::SUCCESS;
130 /* ÅÐÏ¿³ÎÄê¥Ü¥¿¥ó¡Ö¤Ï¤¤¡×¤è¤ê */
131 }else if($move_id==2){
132 //¡ù¡ù¡¡¤³¤³¤«¤é¤Û¤ÜƱ
133 // ²èÌ̾å¤Î¥Õ¥©¡¼¥à¾ðÊó¤ò¼èÆÀ¤¹¤ë
134 $form = $user->getAttribute('new_form_obj');
135 $new_file_obj = $form['file_obj'];
136 //¡ù¡ù¡¡¤³¤³¤Þ¤Ç¤Û¤ÜƱ¤¸
138 ACSDB::_do_query("BEGIN");
139 if($form['file_name'] != ""){ //¥Õ¥¡¥¤¥ë¾ðÊ󤬤¢¤Ã¤¿¾ì¹ç
140 //1.¥Õ¥¡¥¤¥ë¾ðÊó¼èÆÀ(¿·µ¬)
141 $file_obj = ACSFile::get_upload_file_info_instance($user->getAttribute('new_file_obj'),$community_id,$form['user_community_id']);
143 $form['new_file'] = $file_obj;
146 $ret = ACSBBS::set_bbs($form);
148 ACSDB::_do_query("COMMIT");
149 // ·Ç¼¨ÈÄ¥¢¥¯¥»¥¹ÍúÎò
150 ACSBBS::set_bbs_access_history($acs_user_info_row['user_community_id'], $ret);
152 ACSDB::_do_query("ROLLBACK");
156 // ML¥ª¥×¥·¥ç¥ó¤¢¤ê¤Î¾ì¹ç
157 if ($form['is_ml_send']=='t') {
159 // ML¥¹¥Æ¡¼¥¿¥¹¤Î¼èÆÀ
160 $ml_status_row = ACSCommunity::get_contents_row(
161 $community_id, ACSMsg::get_mst('contents_type_master','D62'));
162 $ml_status = $ml_status_row['contents_value'];
164 // MLͤê¤Î¾ì¹ç¥á¡¼¥ë¤òÁ÷¿®
165 if ($bbs_id_seq && $ml_status == 'ACTIVE') {
168 $subject = str_replace('{BBSID}',
169 $bbs_id_seq,ACS_COMMUNITY_ML_SUBJECT_FORMAT) . $form['subject'];
172 ACSCommunityMail::send_community_mailing_list(
174 $acs_user_info_row['mail_addr'],
180 $action_url = $this->getControllerPath('Community', 'BBS'). '&community_id=' . $community_id. '&move_id=4';
182 header("Location: $action_url");
186 function getRequestMethods() {
187 return Request::POST;
190 function validate () {
194 function registerValidators (&$validatorManager) {
195 $context = $this->getContext();
196 $controller = $context->getController();
197 $request = $context->getRequest();
198 $user = $context->getUser();
200 $move_id = $request->getParameter('move_id');
202 // ÆþÎϲèÌ̤«¤é¤Î¾ì¹ç¤Î¤ß¡¢ÆþÎÏ¥Á¥§¥Ã¥¯¤ò¤¹¤ë
205 parent::regValidateName($validatorManager,
208 ACSMsg::get_msg('Community', 'BBSPreAction.class.php', 'M001'));
209 parent::regValidateName($validatorManager,
212 ACSMsg::get_msg('Community', 'BBSPreAction.class.php', 'M002'));
213 parent::regValidateName($validatorManager,
216 ACSMsg::get_msg('Community', 'BBSPreAction.class.php', 'M003'));
220 $xdate = $request->getParameter('xdate');
222 $validator =& new DateValidator($controller);
223 $criteria = array('date_error' => ACSMsg::get_msg('Community', 'BBSPreAction.class.php', 'M004'));
224 $validator->initialize($criteria);
225 //$validatorManager->register('xdate', $validator);
226 $validatorManager->registerValidator('xdate', $validator);
231 function handleError () {
232 return $this->execute();
235 function isSecure () {
239 function getCredential () {
240 return array('COMMUNITY_MEMBER');
243 function get_execute_privilege () {
244 $context = $this->getContext();
245 $user = $context->getUser();
247 // ¥³¥ß¥å¥Ë¥Æ¥£¥á¥ó¥Ð¤ÏOK
248 if ($user->hasCredential('COMMUNITY_MEMBER')) {