1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2007 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | class pc_do_c_event_edit_update_c_commu_topic extends OpenPNE_Action |
---|
8 | { |
---|
9 | function execute($requests) |
---|
10 | { |
---|
11 | $u = $GLOBALS['AUTH']->uid(); |
---|
12 | |
---|
13 | |
---|
14 | // --- リクエスト変数 |
---|
15 | $c_commu_topic_id = $requests['target_c_commu_topic_id']; |
---|
16 | // ---------- |
---|
17 | $upfile_obj1 = $_FILES['image_filename1']; |
---|
18 | $upfile_obj2 = $_FILES['image_filename2']; |
---|
19 | $upfile_obj3 = $_FILES['image_filename3']; |
---|
20 | |
---|
21 | |
---|
22 | list($event, $errors) = p_c_event_add_confirm_event4request(true); |
---|
23 | if ($event['invite_period_year'].$event['invite_period_month'].$event['invite_period_day'] != '') { |
---|
24 | $invite_period = $event['invite_period_year']."-".$event['invite_period_month']."-".$event['invite_period_day']; |
---|
25 | } else { |
---|
26 | $invite_period = ""; |
---|
27 | } |
---|
28 | $c_commu_id = $event['c_commu_id']; |
---|
29 | |
---|
30 | //--- 権限チェック |
---|
31 | //イベント管理者 or コミュニティ管理者 |
---|
32 | |
---|
33 | if (!db_commu_is_c_event_admin($c_commu_topic_id, $u) && |
---|
34 | !db_commu_is_c_commu_admin($c_commu_id, $u)) { |
---|
35 | handle_kengen_error(); |
---|
36 | } |
---|
37 | $c_commu = db_commu_c_commu4c_commu_id2($c_commu_id); |
---|
38 | if ($c_commu['topic_authority'] == 'admin_only' && |
---|
39 | !db_commu_is_c_commu_admin($c_commu_id, $u)) { |
---|
40 | handle_kengen_error(); |
---|
41 | } |
---|
42 | //--- |
---|
43 | |
---|
44 | //エラーチェック |
---|
45 | $err_msg = $errors; |
---|
46 | |
---|
47 | if (!$event['open_date_month'] || !$event['open_date_day'] || !$event['open_date_year']) { |
---|
48 | $err_msg[] = "開催日時を入力してください"; |
---|
49 | } elseif (!t_checkdate($event['open_date_month'], $event['open_date_day'], $event['open_date_year'])) { |
---|
50 | $err_msg[] = "開催日時は存在しません"; |
---|
51 | } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) < mktime(0, 0, 0)) { |
---|
52 | $err_msg[] = "開催日時は過去に指定できません"; |
---|
53 | } |
---|
54 | |
---|
55 | if ($event['invite_period_month'].$event['invite_period_day'].$event['invite_period_year'] != "") { |
---|
56 | if (!$event['invite_period_month'] || !$event['invite_period_day'] || !$event['invite_period_year']) { |
---|
57 | $err_msg[] = "募集期限は存在しません"; |
---|
58 | } elseif (!t_checkdate($event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) { |
---|
59 | $err_msg[] = "募集期限は存在しません"; |
---|
60 | } elseif (mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year']) < mktime(0, 0, 0)) { |
---|
61 | $err_msg[] = "募集期限は過去に指定できません"; |
---|
62 | } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) |
---|
63 | < mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) { |
---|
64 | $err_msg[] = "募集期限は開催日時より未来に指定できません"; |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | if ($upfile_obj1['error'] !== UPLOAD_ERR_NO_FILE) { |
---|
69 | if (!($image = t_check_image($upfile_obj1))) { |
---|
70 | $err_msg[] = '画像1は'.IMAGE_MAX_FILESIZE.'KB以内のGIF・JPEG・PNGにしてください'; |
---|
71 | } |
---|
72 | } |
---|
73 | if ($upfile_obj2['error'] !== UPLOAD_ERR_NO_FILE) { |
---|
74 | if (!($image = t_check_image($upfile_obj2))) { |
---|
75 | $err_msg[] = '画像2は'.IMAGE_MAX_FILESIZE.'KB以内のGIF・JPEG・PNGにしてください'; |
---|
76 | } |
---|
77 | } |
---|
78 | if ($upfile_obj3['error'] !== UPLOAD_ERR_NO_FILE) { |
---|
79 | if (!($image = t_check_image($upfile_obj3))) { |
---|
80 | $err_msg[] = '画像3は'.IMAGE_MAX_FILESIZE.'KB以内のGIF・JPEG・PNGにしてください'; |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | if ($err_msg) { |
---|
85 | $_REQUEST = $event; |
---|
86 | $_REQUEST['err_msg'] = $err_msg; |
---|
87 | $_REQUEST['target_c_commu_topic_id'] = $c_commu_topic_id; |
---|
88 | openpne_forward('pc', 'page', "c_event_edit"); |
---|
89 | exit; |
---|
90 | } |
---|
91 | |
---|
92 | //画像コピー |
---|
93 | $sessid = session_id(); |
---|
94 | t_image_clear_tmp($sessid); |
---|
95 | if (file_exists($upfile_obj1["tmp_name"])) { |
---|
96 | $tmpfile1 = t_image_save2tmp($upfile_obj1, $sessid, "t_1"); |
---|
97 | } |
---|
98 | if (file_exists($upfile_obj2["tmp_name"])) { |
---|
99 | $tmpfile2 = t_image_save2tmp($upfile_obj2, $sessid, "t_2"); |
---|
100 | } |
---|
101 | if (file_exists($upfile_obj3["tmp_name"])) { |
---|
102 | $tmpfile3 = t_image_save2tmp($upfile_obj3, $sessid, "t_3"); |
---|
103 | } |
---|
104 | |
---|
105 | if ($tmpfile1) { |
---|
106 | $filename1 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_1", $tmpfile1); |
---|
107 | } |
---|
108 | if ($tmpfile2) { |
---|
109 | $filename2 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_2", $tmpfile2); |
---|
110 | } |
---|
111 | if ($tmpfile3) { |
---|
112 | $filename3 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_3", $tmpfile3); |
---|
113 | } |
---|
114 | t_image_clear_tmp(session_id()); |
---|
115 | |
---|
116 | |
---|
117 | $update_c_commu_topic = array( |
---|
118 | 'name' => $event['title'], |
---|
119 | 'open_date' => $event['open_date_year']."-".$event['open_date_month']."-".$event['open_date_day'], |
---|
120 | 'open_date_comment' => $event['open_date_comment'], |
---|
121 | 'open_pref_id' => $event['open_pref_id'], |
---|
122 | 'open_pref_comment' => $event['open_pref_comment'], |
---|
123 | 'invite_period' => $invite_period, |
---|
124 | 'event_flag' => 1, |
---|
125 | 'capacity' => $event['capacity'], |
---|
126 | ); |
---|
127 | db_commu_update_c_commu_topic($c_commu_topic_id, $update_c_commu_topic); |
---|
128 | |
---|
129 | |
---|
130 | $update_c_commu_topic_comment = array( |
---|
131 | 'body' => $event['detail'], |
---|
132 | ); |
---|
133 | $c_topic = db_commu_c_topic4c_commu_topic_id_2($c_commu_topic_id); |
---|
134 | if ($filename1) { |
---|
135 | $update_c_commu_topic_comment["image_filename1"] = $filename1; |
---|
136 | image_data_delete($c_topic['image_filename1']); |
---|
137 | } |
---|
138 | if ($filename2) { |
---|
139 | $update_c_commu_topic_comment["image_filename2"] = $filename2; |
---|
140 | image_data_delete($c_topic['image_filename2']); |
---|
141 | } |
---|
142 | if ($filename3) { |
---|
143 | $update_c_commu_topic_comment["image_filename3"] = $filename3; |
---|
144 | image_data_delete($c_topic['image_filename3']); |
---|
145 | } |
---|
146 | db_commu_update_c_commu_topic_comment($c_commu_topic_id, $update_c_commu_topic_comment); |
---|
147 | |
---|
148 | $p = array('target_c_commu_topic_id' => $c_commu_topic_id); |
---|
149 | openpne_redirect('pc', 'page_c_event_detail', $p); |
---|
150 | } |
---|
151 | } |
---|
152 | |
---|
153 | ?> |
---|