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_topic_add_insert_c_commu_topic extends OpenPNE_Action |
---|
8 | { |
---|
9 | function execute($requests) |
---|
10 | { |
---|
11 | $u = $GLOBALS['AUTH']->uid(); |
---|
12 | |
---|
13 | $c_commu_id = $requests['c_commu_id']; |
---|
14 | $title = $requests['title']; |
---|
15 | $image_filename1_tmpfile = $requests['image_filename1_tmpfile']; |
---|
16 | $image_filename2_tmpfile = $requests['image_filename2_tmpfile']; |
---|
17 | $image_filename3_tmpfile = $requests['image_filename3_tmpfile']; |
---|
18 | $body = $requests['body']; |
---|
19 | |
---|
20 | //---添付ファイル |
---|
21 | $filename4_tmpfile = $requests['filename4_tmpfile']; |
---|
22 | |
---|
23 | //---権限チェック |
---|
24 | //コミュニティ参加者 |
---|
25 | |
---|
26 | $status = db_common_commu_status($u, $c_commu_id); |
---|
27 | |
---|
28 | if (!$status['is_commu_member']) { |
---|
29 | handle_kengen_error(); |
---|
30 | } |
---|
31 | |
---|
32 | $c_commu = db_commu_c_commu4c_commu_id2($c_commu_id); |
---|
33 | |
---|
34 | //トピック作成権限チェック |
---|
35 | if ($c_commu['topic_authority'] == 'admin_only' && !db_commu_is_c_commu_admin($c_commu_id, $u)) { |
---|
36 | $_REQUEST['target_c_commu_id'] = $c_commu_id; |
---|
37 | $_REQUEST['msg'] = "トピックは管理者だけが作成できます"; |
---|
38 | openpne_forward('pc', 'page', "c_home"); |
---|
39 | exit; |
---|
40 | } |
---|
41 | //--- |
---|
42 | |
---|
43 | $insert_c_commu_topic = array( |
---|
44 | "name" => $title, |
---|
45 | "c_commu_id" => $c_commu_id, |
---|
46 | "c_member_id" => $u, |
---|
47 | "event_flag" => 0 |
---|
48 | ); |
---|
49 | |
---|
50 | $c_commu_topic_id = db_commu_insert_c_commu_topic($insert_c_commu_topic); |
---|
51 | |
---|
52 | if ($image_filename1_tmpfile) { |
---|
53 | $filename1 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_1", $image_filename1_tmpfile); |
---|
54 | } |
---|
55 | if ($image_filename2_tmpfile) { |
---|
56 | $filename2 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_2", $image_filename2_tmpfile); |
---|
57 | } |
---|
58 | if ($image_filename3_tmpfile) { |
---|
59 | $filename3 = image_insert_c_image4tmp("t_{$c_commu_topic_id}_3", $image_filename3_tmpfile); |
---|
60 | } |
---|
61 | |
---|
62 | // 添付ファイルをDBに入れる |
---|
63 | if ($filename4_tmpfile) { |
---|
64 | $filename4 = file_insert_c_file4tmp("t_{$c_commu_topic_id}_4", $filename4_tmpfile); |
---|
65 | } |
---|
66 | |
---|
67 | //テンポラリファイルを削除(画像と同時) |
---|
68 | t_image_clear_tmp(session_id()); |
---|
69 | |
---|
70 | $insert_c_commu_topic_comment = array( |
---|
71 | "c_commu_id" => $c_commu_id, |
---|
72 | "c_member_id" => $u, |
---|
73 | "body" => $body, |
---|
74 | "number" => 0, |
---|
75 | "c_commu_topic_id" => $c_commu_topic_id, |
---|
76 | "image_filename1" => !empty($filename1) ? $filename1 : '', |
---|
77 | "image_filename2" => !empty($filename2) ? $filename2 : '', |
---|
78 | "image_filename3" => !empty($filename3) ? $filename3 : '', |
---|
79 | "filename4" => !empty($filename4) ? $filename4 : '', |
---|
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 | $p = array('target_c_commu_topic_id' => $c_commu_topic_id); |
---|
89 | |
---|
90 | openpne_redirect('pc', 'page_c_topic_detail', $p); |
---|
91 | } |
---|
92 | } |
---|
93 | |
---|
94 | ?> |
---|