1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2008 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | class pc_page_c_event_write_confirm extends OpenPNE_Action |
---|
8 | { |
---|
9 | function execute($requests) |
---|
10 | { |
---|
11 | $u = $GLOBALS['AUTH']->uid(); |
---|
12 | |
---|
13 | // --- リクエスト変数 |
---|
14 | $c_commu_topic_id = $requests['target_c_commu_topic_id']; |
---|
15 | $body = $requests['body']; |
---|
16 | $button = $requests['button']; |
---|
17 | // ---------- |
---|
18 | $upfile_obj1 = $_FILES['image_filename1']; |
---|
19 | $upfile_obj2 = $_FILES['image_filename2']; |
---|
20 | $upfile_obj3 = $_FILES['image_filename3']; |
---|
21 | |
---|
22 | $c_topic = db_commu_c_topic4c_commu_topic_id_2($c_commu_topic_id); |
---|
23 | $c_commu_id = $c_topic['c_commu_id']; |
---|
24 | |
---|
25 | //--- 権限チェック |
---|
26 | if (!db_commu_is_c_commu_view4c_commu_idAc_member_id($c_commu_id, $u)) { |
---|
27 | handle_kengen_error(); |
---|
28 | } |
---|
29 | if (!db_commu_is_writable_c_commu_topic_comment4c_commu_topic_id($c_commu_topic_id)) { |
---|
30 | $err_msg[] = 'コメントが1000番に達したので、このイベントにはコメントできません'; |
---|
31 | $_REQUEST['err_msg'] = $err_msg; |
---|
32 | openpne_forward('pc', 'page', "c_event_detail"); |
---|
33 | exit; |
---|
34 | } |
---|
35 | //--- |
---|
36 | |
---|
37 | if ($button == "イベントに参加する") { |
---|
38 | $event_write['add_event_member'] = 1; |
---|
39 | } elseif ($button == "参加をキャンセルする") { |
---|
40 | $event_write['add_event_member'] = -1; |
---|
41 | } |
---|
42 | |
---|
43 | //エラーチェック |
---|
44 | $err_msg = array(); |
---|
45 | |
---|
46 | if (trim($body) == '') $err_msg[] = "本文を入力してください"; |
---|
47 | |
---|
48 | if (!empty($upfile_obj1) && $upfile_obj1['error'] !== UPLOAD_ERR_NO_FILE) { |
---|
49 | if (!($image = t_check_image($upfile_obj1))) { |
---|
50 | $err_msg[] = '画像1は'.IMAGE_MAX_FILESIZE.'KB以内のGIF・JPEG・PNGにしてください'; |
---|
51 | } |
---|
52 | } |
---|
53 | if (!empty($upfile_obj2) && $upfile_obj2['error'] !== UPLOAD_ERR_NO_FILE) { |
---|
54 | if (!($image = t_check_image($upfile_obj2))) { |
---|
55 | $err_msg[] = '画像2は'.IMAGE_MAX_FILESIZE.'KB以内のGIF・JPEG・PNGにしてください'; |
---|
56 | } |
---|
57 | } |
---|
58 | if (!empty($upfile_obj3) && $upfile_obj3['error'] !== UPLOAD_ERR_NO_FILE) { |
---|
59 | if (!($image = t_check_image($upfile_obj3))) { |
---|
60 | $err_msg[] = '画像3は'.IMAGE_MAX_FILESIZE.'KB以内のGIF・JPEG・PNGにしてください'; |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | if ($event_write['add_event_member'] === 1 && $c_topic['capacity'] && $c_topic['capacity'] <= $c_topic['member_num'] ) { |
---|
65 | $err_msg[] = 'イベントの参加者数制限を超えています'; |
---|
66 | } |
---|
67 | |
---|
68 | if ($event_write['add_event_member']) { |
---|
69 | if (!db_commu_is_event_join_date($c_commu_topic_id)) { |
---|
70 | $err_msg[] = '現在このイベントへの参加・キャンセルの変更はできません'; |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | if ($err_msg) { |
---|
75 | $_REQUEST['err_msg'] = $err_msg; |
---|
76 | $_REQUEST['body'] = $body; |
---|
77 | openpne_forward('pc', 'page', "c_event_detail"); |
---|
78 | exit; |
---|
79 | } |
---|
80 | |
---|
81 | $sessid = session_id(); |
---|
82 | t_image_clear_tmp($sessid); |
---|
83 | $tmpfile1 = t_image_save2tmp($upfile_obj1, $sessid, "tc_1"); |
---|
84 | $tmpfile2 = t_image_save2tmp($upfile_obj2, $sessid, "tc_2"); |
---|
85 | $tmpfile3 = t_image_save2tmp($upfile_obj3, $sessid, "tc_3"); |
---|
86 | |
---|
87 | $this->set('inc_navi', fetch_inc_navi("c", $c_commu_id)); |
---|
88 | $event_write['target_c_commu_id'] = $c_commu_id; |
---|
89 | $event_write['target_c_commu_topic_id'] = $c_commu_topic_id; |
---|
90 | $event_write['body'] = $body; |
---|
91 | $event_write['image_filename1_tmpfile'] = $tmpfile1; |
---|
92 | $event_write['image_filename2_tmpfile'] = $tmpfile2; |
---|
93 | $event_write['image_filename3_tmpfile'] = $tmpfile3; |
---|
94 | $event_write['image_filename1'] = $upfile_obj1["name"]; |
---|
95 | $event_write['image_filename2'] = $upfile_obj2["name"]; |
---|
96 | $event_write['image_filename3'] = $upfile_obj3["name"]; |
---|
97 | |
---|
98 | $this->set('event_write', $event_write); |
---|
99 | return 'success'; |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | ?> |
---|