OSDN Git Service

add ACS webapp, sql, htdocs
[acs/acs.git] / webapp / modules / Community / actions / DeleteBBSAction.class.php
diff --git a/webapp/modules/Community/actions/DeleteBBSAction.class.php b/webapp/modules/Community/actions/DeleteBBSAction.class.php
new file mode 100644 (file)
index 0000000..96c9e22
--- /dev/null
@@ -0,0 +1,113 @@
+<?php
+/**
+ * ·Ç¼¨ÈÄ¡¡Åê¹Æ ºï½ü½èÍý¡¡¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹
+ * DeleteBBSAction.class.php
+ *
+ * @author  $Author: w-ota $
+ * @version ver1.0 $  2006/02/23 $
+ */
+
+class DeleteBBSAction extends BaseAction
+{
+       // GET
+       function getDefaultView() {
+               $context = $this->getContext();
+               $controller = $context->getController();
+               $request = $context->getRequest();
+               $user = $context->getUser();
+       
+               if (!$this->get_execute_privilege()) {
+                       $controller->forward(SECURE_MODULE, SECURE_ACTION);
+                       return;
+               }
+
+               // get parameter
+               $target_community_id       = $request->getParameter('community_id');
+               $bbs_id                                 = $request->getParameter('bbs_id');
+
+               $bbs_change_url = $this->getControllerPath('Community','BBS');
+               $bbs_change_url .= '&community_id=' . $target_community_id .'&bbs_id=' .$bbs_id;
+               
+               $delete_bbs_url = $this->getControllerPath('Community','DeleteBBS') .'&community_id=' . $target_community_id .'&bbs_id=' .$bbs_id;
+               $back_url = $bbs_change_url;
+
+               $request->setAttribute('delete_bbs_url', $delete_bbs_url);
+               $request->setAttribute('back_url', $back_url);
+               // É½¼¨
+               return View::SUCCESS;
+       }
+
+       // POST
+       function execute() {
+               $context = $this->getContext();
+               $controller = $context->getController();
+               $request = $context->getRequest();
+               $user = $context->getUser();
+       
+               if (!$this->get_execute_privilege()) {
+                       $controller->forward(SECURE_MODULE, SECURE_ACTION);
+                       return;
+               }
+               //ºï½ü½èÍý¤ò¹Ô¤¦
+               $target_community_id    = $request->getParameter('community_id');
+               $acs_user_info_row              = $user->getAttribute('acs_user_info_row');
+               $bbs_id                 = $request->getParameter('bbs_id');
+               //¥Õ¥¡¥¤¥ë¾ðÊó¥Æ¡¼¥Ö¥ë¤Î¥Ç¡¼¥¿ºï½ü
+               $bbs_obj = ACSBBS::get_bbs_row($bbs_id);
+               if(!$bbs_obj){
+                       echo ACSMsg::get_msg('Community', 'DeleteBBSAction.class.php', 'M001');
+               }
+               $ret =ACSBBS::delete_bbs($bbs_obj);
+               if (!$ret) {
+                       echo "ERROR: delete article failed";
+               }
+
+               //ɽ¼¨
+               $bbs_change_url = $this->getControllerPath('Community','BBS');
+       $bbs_change_url .= '&community_id=' . $target_community_id .'&bbs_id=' .$bbs_id;
+               header("Location: $bbs_change_url");
+       }
+
+       function getRequestMethods () {
+               return Request::POST;
+       }
+
+       function isSecure () {
+               return false;
+       }
+
+       function getCredential () {
+               $context = $this->getContext();
+               $controller = $context->getController();
+               $request =  $context->getRequest();
+               $user = $context->getUser();
+               return array('EXECUTE');
+       }
+
+       function get_execute_privilege () {
+               $context = $this->getContext();
+               $controller = $context->getController();
+               $request =  $context->getRequest();
+               $user = $context->getUser();
+
+               $acs_user_info_row = $user->getAttribute('acs_user_info_row');
+
+               // ´ÉÍý¿Í¤ÏOK
+               if ($user->hasCredential('COMMUNITY_ADMIN')) {
+                       return true;
+               }
+               
+               // ½ñ¤­¹þ¤ó¤À¥á¥ó¥ÐËܿͤÏOK
+               if ($user->hasCredential('COMMUNITY_MEMBER')) {
+                       $bbs_row = ACSBBS::get_bbs_row($request->getParameter('bbs_id'));
+                       if ($acs_user_info_row['user_community_id'] == $bbs_row['user_community_id']) {
+                               return true;
+                       }
+               }
+
+               return false;
+       }
+
+}
+?>