OSDN Git Service

add ACS webapp, sql, htdocs
[acs/acs.git] / webapp / modules / Community / actions / FileHistoryCommentAction.class.php
diff --git a/webapp/modules/Community/actions/FileHistoryCommentAction.class.php b/webapp/modules/Community/actions/FileHistoryCommentAction.class.php
new file mode 100644 (file)
index 0000000..a0009bc
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+// $Id: FileHistoryCommentAction.class.php,v 1.3 2006/12/08 05:06:34 w-ota Exp $
+
+class FileHistoryCommentAction extends BaseAction
+{
+       // POST
+       function execute () {
+               $context = $this->getContext();
+               $controller = $context->getController();
+               $request =  $context->getRequest();
+               $user = $context->getUser();
+               $acs_user_info_row = $user->getAttribute('acs_user_info_row');
+
+               // ÂоݤȤʤ륳¥ß¥å¥Ë¥Æ¥£ID¤ò¼èÆÀ
+               $target_community_id = $request->getParameter('community_id');
+               // ÂоݤȤʤë¥Õ¥©¥ë¥ÀID¤ò¼èÆÀ
+               $target_community_folder_id = $request->getParameter('folder_id');
+               // ¾ÜºÙ¾ðÊó¤òɽ¼¨¤¹¤ë¥Õ¥¡¥¤¥ëID¤ò¼èÆÀ
+               $file_id = $request->getParameter('file_id');
+               // ¥Õ¥¡¥¤¥ëÍúÎòID
+               $file_history_id = $request->getParameter('file_history_id');
+
+               // form
+               $form = $request->ACSGetParameters();
+
+
+               // É½¼¨¤¹¤ë¥Ú¡¼¥¸¤Î½êÍ­¼Ô¾ðÊó¼èÆÀ
+               $target_community_row = ACSCommunity::get_community_row($target_community_id);
+               // ¥Õ¥©¥ë¥À¾ðÊó¼èÆÀ
+               $community_folder_obj = new ACSCommunityFolder($target_community_id,
+                                                                                                 $acs_user_info_row,
+                                                                                                 $target_community_folder_id);
+               $folder_obj = $community_folder_obj->get_folder_obj();
+
+
+               // ¥Õ¥¡¥¤¥ë¾ðÊó¼èÆÀ
+               $file_obj = ACSFile::get_file_info_instance($file_id);
+
+               // ¥Õ¥©¥ë¥À¤Î¸ø³«ÈϰϤǥ¢¥¯¥»¥¹À©¸æ
+               if (!$community_folder_obj->has_privilege($target_community_row)) {
+                       $controller->forward(SECURE_MODULE, SECURE_ACTION);
+                       return;
+               }
+
+               // ¥Õ¥¡¥¤¥ëÍúÎò¥³¥á¥ó¥È¤òÅÐÏ¿¤¹¤ë
+               if ($form['comment'] != '') {
+                       // ¥Õ¥¡¥¤¥ëÍúÎò¤¬1·ï¤âÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï"ºîÀ®"¤òÅÐÏ¿¤¹¤ë
+                       $file_history_row_array = ACSFileHistory::get_file_history_row_array($file_id);
+                       if (count($file_history_row_array) == 0) {
+                               $file_info_row = ACSFileInfoModel::select_file_info_row($file_id);
+                               $file_history_id = ACSFileHistory::set_file_history($file_info_row, $file_info_row['entry_user_community_id'], '', ACSMsg::get_mst('file_history_operation_master','D0101'));
+                       }
+
+                       $ret = ACSFileHistoryComment::set_file_history_comment($file_history_id, $acs_user_info_row['user_community_id'], $form['comment']);
+               }
+
+               // ¥Õ¥¡¥¤¥ë¾ÜºÙ¾ðÊó¤ØÁ«°Ü
+               $file_detail_url = $this->getControllerPath('Community', 'FileDetail');
+               $file_detail_url .= '&community_id=' . $target_community_id;
+               $file_detail_url .= '&file_id=' . $file_id;
+               $file_detail_url .= '&folder_id=' . $target_community_folder_id;
+               header("Location: $file_detail_url");
+       }
+
+       function isSecure () {
+               return false;
+       }
+       
+       function getRequestMethods () {
+               return Request::POST;
+       }
+
+       function validate () {
+               return TRUE;
+       }
+
+       function registerValidators (&$validatorManager) {
+               /* É¬¿Ü¥Á¥§¥Ã¥¯ */
+               parent::regValidateName($validatorManager, 
+                               "comment", 
+                               true, 
+                               ACSMsg::get_msg('Community', 'FileHistoryCommentAction.class.php', 'M001'));
+       }
+
+       function handleError () {
+               $context = $this->getContext();
+               $controller = $context->getController();
+               // °ÜÆ°°ìÍ÷¥¢¥¯¥·¥ç¥ó¸Æ¤Ó½Ð¤·
+               $controller->forward('Community', 'FileDetail');
+       }
+}
+
+?>