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 ktai_do_c_event_add_insert_c_commu_topic extends OpenPNE_Action |
---|
8 | { |
---|
9 | function execute($requests) |
---|
10 | { |
---|
11 | $u = $GLOBALS['KTAI_C_MEMBER_ID']; |
---|
12 | $tail = $GLOBALS['KTAI_URL_TAIL']; |
---|
13 | |
---|
14 | //--- 権限チェック |
---|
15 | //コミュニティ参加者 |
---|
16 | |
---|
17 | list($event, $errors) = p_c_event_add_confirm_event4request(true); |
---|
18 | |
---|
19 | $status = db_common_commu_status($u, $event['c_commu_id']); |
---|
20 | if (!$status['is_commu_member']) { |
---|
21 | handle_kengen_error(); |
---|
22 | } |
---|
23 | |
---|
24 | $c_commu = db_commu_c_commu4c_commu_id2($event['c_commu_id']); |
---|
25 | |
---|
26 | //トピック作成権限チェック |
---|
27 | if ($c_commu['topic_authority'] == 'admin_only' && !db_commu_is_c_commu_admin($event['c_commu_id'], $u)) { |
---|
28 | ktai_display_error("イベントは管理者だけが作成できます"); |
---|
29 | } |
---|
30 | //--- |
---|
31 | |
---|
32 | //--- エラーチェック |
---|
33 | $err_msg = $errors; |
---|
34 | |
---|
35 | if (!$event['open_date_month'] || !$event['open_date_day'] || !$event['open_date_year']) { |
---|
36 | $err_msg[] = "開催日時を入力してください"; |
---|
37 | } elseif (!t_checkdate($event['open_date_month'], $event['open_date_day'], $event['open_date_year'])) { |
---|
38 | $err_msg[] = "開催日時は存在しません"; |
---|
39 | } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) < mktime(0, 0, 0)) { |
---|
40 | $err_msg[] = "開催日時は過去に指定できません"; |
---|
41 | } |
---|
42 | |
---|
43 | if ($event['invite_period_month'] . $event['invite_period_day'] . $event['invite_period_year'] != "") { |
---|
44 | if (!$event['invite_period_month'] || !$event['invite_period_day'] || !$event['invite_period_year']) { |
---|
45 | $err_msg[] = "募集期限は存在しません"; |
---|
46 | } elseif (!t_checkdate($event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) { |
---|
47 | $err_msg[] = "募集期限は存在しません"; |
---|
48 | } elseif (mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year']) < mktime(0, 0, 0)) { |
---|
49 | $err_msg[] = "募集期限は過去に指定できません"; |
---|
50 | } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) |
---|
51 | < mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) { |
---|
52 | $err_msg[] = "募集期限は開催日時より未来に指定できません"; |
---|
53 | } |
---|
54 | } |
---|
55 | if ( $event['capacity'] != "" && 1*$event['capacity'] < 1 ) |
---|
56 | $err_msg[] = "募集人数は1以上の数値を指定してください"; |
---|
57 | |
---|
58 | if ($err_msg) { |
---|
59 | $_REQUEST = $event; |
---|
60 | $_REQUEST['target_c_commu_id'] = $event['c_commu_id']; |
---|
61 | $_REQUEST['err_msg'] = $err_msg; |
---|
62 | openpne_forward('ktai', 'page', "c_event_add"); |
---|
63 | exit; |
---|
64 | } |
---|
65 | //--- |
---|
66 | |
---|
67 | if ($event['invite_period_year'] . $event['invite_period_month'] . $event['invite_period_day'] != "") { |
---|
68 | $invite_period = $event['invite_period_year'] . "-" . $event['invite_period_month'] . "-" . $event['invite_period_day']; |
---|
69 | } else { |
---|
70 | $invite_period = ''; |
---|
71 | } |
---|
72 | |
---|
73 | $insert_c_commu_topic = array( |
---|
74 | "name" => $event['title'], |
---|
75 | "c_commu_id" => $event['c_commu_id'], |
---|
76 | "c_member_id" => $u, |
---|
77 | "open_date" => $event['open_date_year']."-".$event['open_date_month']."-".$event['open_date_day'], |
---|
78 | "open_date_comment" => $event['open_date_comment'], |
---|
79 | "open_pref_id" => $event['open_pref_id'], |
---|
80 | "open_pref_comment" => $event['open_pref_comment'], |
---|
81 | "invite_period" => $invite_period, |
---|
82 | "event_flag" => 1, |
---|
83 | 'capacity' => $event['capacity'], |
---|
84 | ); |
---|
85 | $c_commu_topic_id = db_commu_insert_c_commu_topic($insert_c_commu_topic); |
---|
86 | |
---|
87 | $insert_c_commu_topic_comment = array( |
---|
88 | "c_commu_id" => $event['c_commu_id'], |
---|
89 | "c_member_id" => $u, |
---|
90 | "body" => $event['detail'], |
---|
91 | "number" => 0, |
---|
92 | "c_commu_topic_id" => $c_commu_topic_id, |
---|
93 | "image_filename1" => '', |
---|
94 | "image_filename2" => '', |
---|
95 | "image_filename3" => '', |
---|
96 | ); |
---|
97 | $insert_id = db_commu_insert_c_commu_topic_comment_3($insert_c_commu_topic_comment); |
---|
98 | |
---|
99 | //お知らせメール送信(携帯へ) |
---|
100 | send_bbs_info_mail($insert_id, $u); |
---|
101 | //お知らせメール送信(PCへ) |
---|
102 | send_bbs_info_mail_pc($insert_id, $u); |
---|
103 | |
---|
104 | db_commu_insert_c_event_member_as_admin($c_commu_topic_id, $u); |
---|
105 | |
---|
106 | if (OPENPNE_USE_POINT_RANK) { |
---|
107 | //イベントを作成した人にポイント付与 |
---|
108 | $point = db_action_get_point4c_action_id(10); |
---|
109 | db_point_add_point($u, $point); |
---|
110 | } |
---|
111 | |
---|
112 | $p = array('target_c_commu_topic_id' => $c_commu_topic_id); |
---|
113 | openpne_redirect('ktai', 'page_c_bbs', $p); |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | ?> |
---|