1 | <?php |
---|
2 | /** |
---|
3 | * @copyright 2005-2006 OpenPNE Project |
---|
4 | * @license http://www.php.net/license/3_01.txt PHP License 3.01 |
---|
5 | */ |
---|
6 | |
---|
7 | class pc_db_commu_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 | //コミュニティ参加者 |
---|
21 | |
---|
22 | $event = p_c_event_add_confirm_event4request(); |
---|
23 | |
---|
24 | $status = db_common_commu_status($u, $event['c_commu_id']); |
---|
25 | if (!$status['is_commu_member']) { |
---|
26 | handle_kengen_error(); |
---|
27 | } |
---|
28 | |
---|
29 | $c_commu = db_commu_c_commu4c_commu_id2($event['c_commu_id']); |
---|
30 | |
---|
31 | //トピック作成権限チェック |
---|
32 | if ($c_commu['topic_authority'] == 'admin_only' && !db_commu_is_c_commu_admin($event['c_commu_id'], $u)) { |
---|
33 | $_REQUEST['target_c_commu_id'] = $event['c_commu_id']; |
---|
34 | $_REQUEST['msg'] = "イベントは管理者だけが作成できます"; |
---|
35 | openpne_forward('pc', 'page', "c_home"); |
---|
36 | exit; |
---|
37 | } |
---|
38 | //--- |
---|
39 | |
---|
40 | |
---|
41 | if ($event['invite_period_year'].$event['invite_period_month'].$event['invite_period_day']!="") { |
---|
42 | $invite_period = $event['invite_period_year']."-".$event['invite_period_month']."-".$event['invite_period_day']; |
---|
43 | } else { |
---|
44 | $invite_period = ""; |
---|
45 | } |
---|
46 | |
---|
47 | $insert_c_commu_topic = array( |
---|
48 | "name" => $event['title'], |
---|
49 | "c_commu_id" => $event['c_commu_id'], |
---|
50 | "c_member_id" => $u, |
---|
51 | "open_date" => $event['open_date_year']."-".$event['open_date_month']."-".$event['open_date_day'], |
---|
52 | "open_date_comment" => $event['open_date_comment'], |
---|
53 | "open_pref_id" => $event['open_pref_id'], |
---|
54 | "open_pref_comment" => $event['open_pref_comment'], |
---|
55 | "invite_period" => $invite_period, |
---|
56 | "event_flag" => 1, |
---|
57 | ); |
---|
58 | $c_commu_topic_id = db_commu_insert_c_commu_topic($insert_c_commu_topic); |
---|
59 | |
---|
60 | if ($tmpfile1) { |
---|
61 | $filename1 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_1", $tmpfile1); |
---|
62 | } |
---|
63 | if ($tmpfile2) { |
---|
64 | $filename2 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_2", $tmpfile2); |
---|
65 | } |
---|
66 | if ($tmpfile3) { |
---|
67 | $filename3 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_3", $tmpfile3); |
---|
68 | } |
---|
69 | t_image_clear_tmp(session_id()); |
---|
70 | |
---|
71 | $insert_c_commu_topic_comment = array( |
---|
72 | "c_commu_id" => $event['c_commu_id'], |
---|
73 | "c_member_id" => $u, |
---|
74 | "body" => $event['detail'], |
---|
75 | "number" => 0, |
---|
76 | "c_commu_topic_id" => $c_commu_topic_id, |
---|
77 | "image_filename1" => !empty($filename1) ? $filename1 : '', |
---|
78 | "image_filename2" => !empty($filename2) ? $filename2 : '', |
---|
79 | "image_filename3" => !empty($filename3) ? $filename3 : '', |
---|
80 | ); |
---|
81 | $insert_id = db_commu_insert_c_commu_topic_comment_3($insert_c_commu_topic_comment); |
---|
82 | |
---|
83 | //お知らせメール送信(携帯へ) |
---|
84 | send_bbs_info_mail($insert_id, $u); |
---|
85 | //お知らせメール送信(PCへ) |
---|
86 | send_bbs_info_mail_pc($insert_id, $u); |
---|
87 | |
---|
88 | db_commu_insert_c_event_member_as_admin($c_commu_topic_id, $u); |
---|
89 | |
---|
90 | $p = array('target_c_commu_topic_id' => $c_commu_topic_id); |
---|
91 | openpne_redirect('pc', 'page_c_event_detail', $p); |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | ?> |
---|