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_edit_update_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 | $c_commu_topic_id = $requests['target_c_commu_topic_id']; |
---|
16 | // ---------- |
---|
17 | |
---|
18 | list($event, $errors) = p_c_event_add_confirm_event4request(true); |
---|
19 | if ($event['invite_period_year'].$event['invite_period_month'].$event['invite_period_day'] != '') { |
---|
20 | $invite_period = $event['invite_period_year']."-".$event['invite_period_month']."-".$event['invite_period_day']; |
---|
21 | } else { |
---|
22 | $invite_period = ''; |
---|
23 | } |
---|
24 | |
---|
25 | //--- 権限チェック |
---|
26 | //イベント管理者 or コミュニティ管理者 |
---|
27 | |
---|
28 | if (!db_commu_is_c_event_admin($c_commu_topic_id, $u) && |
---|
29 | !db_commu_is_c_commu_admin($event['c_commu_id'], $u)) { |
---|
30 | handle_kengen_error(); |
---|
31 | } |
---|
32 | //--- |
---|
33 | |
---|
34 | //エラーチェック |
---|
35 | $err_msg = $errors; |
---|
36 | |
---|
37 | if (!$event['open_date_month'] || !$event['open_date_day'] || !$event['open_date_year']) { |
---|
38 | $err_msg[] = "開催日時を入力してください"; |
---|
39 | } elseif (!t_checkdate($event['open_date_month'], $event['open_date_day'], $event['open_date_year'])) { |
---|
40 | $err_msg[] = "開催日時は存在しません"; |
---|
41 | } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) < mktime(0, 0, 0)) { |
---|
42 | $err_msg[] = "開催日時は過去に指定できません"; |
---|
43 | } |
---|
44 | |
---|
45 | if ($event['invite_period_month'].$event['invite_period_day'].$event['invite_period_year'] != "") { |
---|
46 | if (!$event['invite_period_month'] || !$event['invite_period_day'] || !$event['invite_period_year']) { |
---|
47 | $err_msg[] = "募集期限は存在しません"; |
---|
48 | } elseif (!t_checkdate($event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) { |
---|
49 | $err_msg[] = "募集期限は存在しません"; |
---|
50 | } elseif (mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year']) < mktime(0, 0, 0)) { |
---|
51 | $err_msg[] = "募集期限は過去に指定できません"; |
---|
52 | } elseif (mktime(0, 0, 0, $event['open_date_month'], $event['open_date_day'], $event['open_date_year']) |
---|
53 | < mktime(0, 0, 0, $event['invite_period_month'], $event['invite_period_day'], $event['invite_period_year'])) { |
---|
54 | $err_msg[] = "募集期限は開催日時より未来に指定できません"; |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | if ($err_msg) { |
---|
59 | $_REQUEST = $event; |
---|
60 | $_REQUEST['err_msg'] = $err_msg; |
---|
61 | $_REQUEST['target_c_commu_topic_id'] = $c_commu_topic_id; |
---|
62 | openpne_forward('ktai', 'page', "c_event_edit"); |
---|
63 | exit; |
---|
64 | } |
---|
65 | |
---|
66 | $update_c_commu_topic = array( |
---|
67 | 'name' => $event['title'], |
---|
68 | 'open_date' => $event['open_date_year']."-".$event['open_date_month']."-".$event['open_date_day'], |
---|
69 | 'open_date_comment' => $event['open_date_comment'], |
---|
70 | 'open_pref_id' => $event['open_pref_id'], |
---|
71 | 'open_pref_comment' => $event['open_pref_comment'], |
---|
72 | 'invite_period' => $invite_period, |
---|
73 | 'event_flag' => 1, |
---|
74 | 'capacity' => $event['capacity'], |
---|
75 | ); |
---|
76 | db_commu_update_c_commu_topic($c_commu_topic_id, $update_c_commu_topic); |
---|
77 | |
---|
78 | |
---|
79 | $update_c_commu_topic_comment = array( |
---|
80 | 'body' => $event['detail'], |
---|
81 | ); |
---|
82 | db_commu_update_c_commu_topic_comment($c_commu_topic_id, $update_c_commu_topic_comment); |
---|
83 | |
---|
84 | $p = array('target_c_commu_topic_id' => $c_commu_topic_id); |
---|
85 | openpne_redirect('ktai', 'page_c_bbs', $p); |
---|
86 | } |
---|
87 | } |
---|
88 | |
---|
89 | ?> |
---|