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_do_c_event_add_insert_c_commu_topic extends OpenPNE_Action |
---|
8 | { |
---|
9 | function execute($requests) |
---|
10 | { |
---|
11 | $u = $GLOBALS['AUTH']->uid(); |
---|
12 | |
---|
13 | // --- リクエスト変数 |
---|
14 | $tmpfile1 = $requests['image_filename1_tmpfile']; |
---|
15 | $tmpfile2 = $requests['image_filename2_tmpfile']; |
---|
16 | $tmpfile3 = $requests['image_filename3_tmpfile']; |
---|
17 | // ---------- |
---|
18 | |
---|
19 | //---添付ファイル |
---|
20 | if (OPENPNE_USE_FILEUPLOAD) { |
---|
21 | $filename4_tmpfile = $requests['filename4_tmpfile']; |
---|
22 | $filename4_original_filename = $requests['filename4_original_filename']; |
---|
23 | |
---|
24 | if ($filename4_tmpfile) { |
---|
25 | // 拡張子制限 |
---|
26 | if (!util_check_file_extention($filename4_original_filename)) { |
---|
27 | $_REQUEST['target_c_commu_id'] = $requests['c_commu_id']; |
---|
28 | $_REQUEST['err_msg'] = sprintf('アップロードできるファイルの種類は(%s)です', util_get_file_allowed_extensions('string')); |
---|
29 | openpne_forward('pc', 'page', "c_event_add"); |
---|
30 | exit; |
---|
31 | } |
---|
32 | } |
---|
33 | } |
---|
34 | |
---|
35 | //--- 権限チェック |
---|
36 | //コミュニティ参加者 |
---|
37 | |
---|
38 | list($event, $errors) = p_c_event_add_confirm_event4request(true); |
---|
39 | |
---|
40 | $status = db_common_commu_status($u, $event['c_commu_id']); |
---|
41 | if (!$status['is_commu_member']) { |
---|
42 | handle_kengen_error(); |
---|
43 | } |
---|
44 | |
---|
45 | $c_commu = db_commu_c_commu4c_commu_id2($event['c_commu_id']); |
---|
46 | |
---|
47 | //トピック作成権限チェック |
---|
48 | if ($c_commu['topic_authority'] == 'admin_only' && !db_commu_is_c_commu_admin($event['c_commu_id'], $u)) { |
---|
49 | $_REQUEST['target_c_commu_id'] = $event['c_commu_id']; |
---|
50 | $_REQUEST['msg'] = "イベントは管理者だけが作成できます"; |
---|
51 | openpne_forward('pc', 'page', "c_home"); |
---|
52 | exit; |
---|
53 | } |
---|
54 | //--- |
---|
55 | |
---|
56 | // エラーチェック |
---|
57 | $err_msg = $errors; |
---|
58 | |
---|
59 | if (!$event['open_date_month'] || !$event['open_date_day'] || !$event['open_date_year']) { |
---|
60 | $err_msg[] = "開催日時を入力してください"; |
---|
61 | } elseif (!t_checkdate($event['open_date_month'], $event['open_date_day'], $event['open_date_year'])) { |
---|
62 | $err_msg[] = "開催日時は存在しません"; |
---|
63 | } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) < mktime(0, 0, 0)) { |
---|
64 | $err_msg[] = "開催日時は過去に指定できません"; |
---|
65 | } |
---|
66 | |
---|
67 | if ($event['invite_period_month'].$event['invite_period_day'].$event['invite_period_year'] != "") { |
---|
68 | if (!$event['invite_period_month'] || !$event['invite_period_day'] || !$event['invite_period_year']) { |
---|
69 | $err_msg[] = "募集期限は存在しません"; |
---|
70 | } elseif (!t_checkdate($event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) { |
---|
71 | $err_msg[] = "募集期限は存在しません"; |
---|
72 | } elseif (mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year']) < mktime(0, 0, 0)) { |
---|
73 | $err_msg[] = "募集期限は過去に指定できません"; |
---|
74 | } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) |
---|
75 | < mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) { |
---|
76 | $err_msg[] = "募集期限は開催日時より未来に指定できません"; |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | if ($err_msg) { |
---|
81 | $_REQUEST = $event; |
---|
82 | $_REQUEST['target_c_commu_id'] = $event['c_commu_id']; |
---|
83 | $_REQUEST['err_msg'] = $err_msg; |
---|
84 | openpne_forward('pc', 'page', "c_event_add"); |
---|
85 | exit; |
---|
86 | } |
---|
87 | |
---|
88 | if ($event['invite_period_year'].$event['invite_period_month'].$event['invite_period_day']!="") { |
---|
89 | $invite_period = $event['invite_period_year']."-".$event['invite_period_month']."-".$event['invite_period_day']; |
---|
90 | } |
---|
91 | |
---|
92 | $insert_c_commu_topic = array( |
---|
93 | "name" => $event['title'], |
---|
94 | "c_commu_id" => $event['c_commu_id'], |
---|
95 | "c_member_id" => $u, |
---|
96 | "open_date" => $event['open_date_year']."-".$event['open_date_month']."-".$event['open_date_day'], |
---|
97 | "open_date_comment" => $event['open_date_comment'], |
---|
98 | "open_pref_id" => $event['open_pref_id'], |
---|
99 | "open_pref_comment" => $event['open_pref_comment'], |
---|
100 | "invite_period" => $invite_period, |
---|
101 | "event_flag" => 1, |
---|
102 | "capacity" => $event['capacity'], |
---|
103 | ); |
---|
104 | $c_commu_topic_id = db_commu_insert_c_commu_topic($insert_c_commu_topic); |
---|
105 | |
---|
106 | if ($tmpfile1) { |
---|
107 | $filename1 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_1", $tmpfile1); |
---|
108 | } |
---|
109 | if ($tmpfile2) { |
---|
110 | $filename2 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_2", $tmpfile2); |
---|
111 | } |
---|
112 | if ($tmpfile3) { |
---|
113 | $filename3 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_3", $tmpfile3); |
---|
114 | } |
---|
115 | if (OPENPNE_USE_FILEUPLOAD) { |
---|
116 | // 添付ファイルをDBに入れる |
---|
117 | if ($filename4_tmpfile) { |
---|
118 | $filename4 = file_insert_c_file4tmp("t_{$c_commu_topic_id}_4", $filename4_tmpfile, $filename4_original_filename); |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | //テンポラリファイルを削除(画像と同時) |
---|
123 | t_image_clear_tmp(session_id()); |
---|
124 | t_file_clear_tmp(session_id()); |
---|
125 | |
---|
126 | $insert_c_commu_topic_comment = array( |
---|
127 | "c_commu_id" => $event['c_commu_id'], |
---|
128 | "c_member_id" => $u, |
---|
129 | "body" => $event['detail'], |
---|
130 | "number" => 0, |
---|
131 | "c_commu_topic_id" => $c_commu_topic_id, |
---|
132 | "image_filename1" => !empty($filename1) ? $filename1 : '', |
---|
133 | "image_filename2" => !empty($filename2) ? $filename2 : '', |
---|
134 | "image_filename3" => !empty($filename3) ? $filename3 : '', |
---|
135 | "filename4" => !empty($filename4) ? $filename4 : '', |
---|
136 | ); |
---|
137 | $insert_id = db_commu_insert_c_commu_topic_comment_3($insert_c_commu_topic_comment); |
---|
138 | |
---|
139 | //お知らせメール送信(携帯へ) |
---|
140 | send_bbs_info_mail($insert_id, $u); |
---|
141 | //お知らせメール送信(PCへ) |
---|
142 | send_bbs_info_mail_pc($insert_id, $u); |
---|
143 | |
---|
144 | db_commu_insert_c_event_member_as_admin($c_commu_topic_id, $u); |
---|
145 | |
---|
146 | if (OPENPNE_USE_POINT_RANK) { |
---|
147 | //イベントを作成した人にポイント付与 |
---|
148 | $point = db_action_get_point4c_action_id(10); |
---|
149 | db_point_add_point($u, $point); |
---|
150 | } |
---|
151 | |
---|
152 | $p = array('target_c_commu_topic_id' => $c_commu_topic_id); |
---|
153 | openpne_redirect('pc', 'page_c_event_detail', $p); |
---|
154 | } |
---|
155 | } |
---|
156 | |
---|
157 | ?> |
---|