OSDN Git Service

e932425d60c9585b54c56d2f1d7fac6802d2566f
[acs/acs.git] / webapp / modules / Community / actions / EditBBSAction.class.php
1 <?php
2 // $Id: EditBBSAction.class.php,v 1.2 2006/11/20 08:44:12 w-ota Exp $
3
4 class EditBBSAction extends BaseAction
5 {
6         // GET
7         function getDefaultView() {
8                 $context = $this->getContext();
9                 $controller = $context->getController();
10                 $request = $context->getRequest();
11                 $user = $context->getUser();
12                 $acs_user_info_row = $user->getAttribute('acs_user_info_row');
13
14                 $community_id = $request->getParameter('community_id');
15                 $bbs_id = $request->getParameter('bbs_id');
16
17                 // ¥³¥ß¥å¥Ë¥Æ¥£¾ðÊó
18                 $community_row = ACSCommunity::get_community_row($community_id);
19
20                 // BBSµ­»ö°ìÍ÷
21                 $bbs_row = ACSBBS::get_bbs_row($bbs_id);
22
23                 // ¿®ÍêºÑ¤ß¥³¥ß¥å¥Ë¥Æ¥£°ìÍ÷
24                 $bbs_row['trusted_community_row_array'] = ACSBBS::get_bbs_trusted_community_row_array($bbs_row['bbs_id']);
25
26                 // set
27                 $request->setAttribute('community_row', $community_row);
28                 $request->setAttribute('bbs_row', $bbs_row);
29
30
31                 // (Åê¹Æ¼ÔËÜ¿Í or ¥³¥ß¥å¥Ë¥Æ¥£´ÉÍý¼Ô)¤Î¤ß¤¬¥¢¥¯¥»¥¹¤Ç¤­¤ë
32                 if ($acs_user_info_row['user_community_id'] != $bbs_row['user_community_id']
33                         && !ACSCommunity::is_community_admin($acs_user_info_row['user_community_id'], $community_row['community_id'])) {
34                         $controller->forward(SECURE_MODULE, SECURE_ACTION);
35                         return;
36                 }
37
38                 return View::INPUT;
39         }
40
41         // POST
42         function execute() {
43                 $context = $this->getContext();
44                 $controller = $context->getController();
45                 $request =  $context->getRequest();
46                 $user = $context->getUser();    
47                 $acs_user_info_row = $user->getAttribute('acs_user_info_row');
48
49                 $community_id = $request->getParameter('community_id');
50                 $bbs_id = $request->getParameter('bbs_id');
51
52                 // ÆþÎϥǡ¼¥¿
53                 $form = $request->ACSGetParameters();
54                 $form['user_community_id'] = $acs_user_info_row['user_community_id'];
55
56                 // bbs¹¹¿·
57                 ACSDB::_do_query("BEGIN");
58                 $ret = ACSBBS::update_bbs($form);
59                 if (!$ret) {
60                         ACSDB::_do_query("ROLLBACK");
61                         exit;
62                 }
63
64                 ACSDB::_do_query("COMMIT");
65
66                 $bbs_url = $this->getControllerPath('Community', 'BBS'). '&community_id=' . $community_id;
67                 header("Location: $bbs_url");
68         }
69
70         function getRequestMethods() {
71                 return Request::POST;
72         }
73
74         function isSecure() {
75                 return false;
76         }
77
78         function getCredential() {
79                 return array('COMMUNITY_MEMBER');
80         }
81
82         function validate () {
83                 return TRUE;
84         }
85
86         function registerValidators (&$validatorManager) {
87                 /* É¬¿Ü¥Á¥§¥Ã¥¯ */
88                 parent::regValidateName($validatorManager, 
89                                 "subject", 
90                                 true, 
91                                 ACSMsg::get_msg('Community', 'EditBBSAction.class.php', 'M001'));
92                 parent::regValidateName($validatorManager, 
93                                 "body", 
94                                 true, 
95                                 ACSMsg::get_msg('Community', 'EditBBSAction.class.php', 'M002'));
96         }
97
98         function handleError () {
99                 $context = $this->getContext();
100                 $controller = $context->getController();
101                 $request =  $context->getRequest();
102                 $user = $context->getUser();
103                 
104                 // ÆþÎÏÃͤò set
105                 $form = $request->ACSGetParameters();
106                 $request->setAttribute('form', $form);
107
108                 // ÆþÎϲèÌÌɽ¼¨
109                 return $this->getDefaultView();
110         }
111 }
112
113 ?>