OSDN Git Service

add ACS webapp, sql, htdocs
[acs/acs.git] / webapp / modules / User / actions / FileDetailAction.class.php
diff --git a/webapp/modules/User/actions/FileDetailAction.class.php b/webapp/modules/User/actions/FileDetailAction.class.php
new file mode 100644 (file)
index 0000000..104b1c6
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+/**
+ * ¥Õ¥¡¥¤¥ë¾ÜºÙ¾ðÊó
+ * $Id: FileDetailAction.class.php,v 1.8 2007/03/29 01:55:17 w-ota Exp $
+ */
+
+class FileDetailAction extends BaseAction
+{
+       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_user_community_id = $request->getParameter('id');
+               // ÂоݤȤʤë¥Õ¥©¥ë¥ÀID¤ò¼èÆÀ
+               $target_user_community_folder_id = $request->getParameter('folder_id');
+               // ¾ÜºÙ¾ðÊó¤òɽ¼¨¤¹¤ë¥Õ¥¡¥¤¥ëID¤ò¼èÆÀ
+               $file_id = $request->getParameter('file_id');
+
+               // É½¼¨¤¹¤ë¥Ú¡¼¥¸¤Î½êÍ­¼Ô¾ðÊó¼èÆÀ
+               $target_user_info_row = ACSUser::get_user_info_row_by_user_community_id($target_user_community_id);
+
+               // ¥Õ¥©¥ë¥À¾ðÊó¼èÆÀ
+               $user_folder_obj = new ACSUserFolder($target_user_community_id,
+                               $acs_user_info_row,
+                               $target_user_community_folder_id);
+               $folder_obj = $user_folder_obj->get_folder_obj();
+
+               // ¥Õ¥©¥ë¥À¤Î¸ø³«ÈϰϤǥ¢¥¯¥»¥¹À©¸æ
+               if (!$user_folder_obj->has_privilege($target_user_info_row)) {
+                       $controller->forward(SECURE_MODULE, SECURE_ACTION);
+                       return;
+               }
+
+               // ¥ë¡¼¥È¥Õ¥©¥ë¥Àľ²¼¤Î¥Õ¥¡¥¤¥ë¤ÏËܿͰʳ°¥¢¥¯¥»¥¹ÉÔ²Ä
+               $privilege_array = $this->getCredential();
+               //if ($folder_obj->get_is_root_folder() && !in_array('USER_PAGE_OWNER', $privilege_array)) {
+               if ($folder_obj->get_is_root_folder() && !$this->get_execute_privilege()) {
+                       $controller->forward(SECURE_MODULE, SECURE_ACTION);
+                       return;
+               }
+
+               // ¥Õ¥¡¥¤¥ë¾ðÊó¼èÆÀ
+               $file_obj = ACSFile::get_file_info_instance($file_id);
+
+               // ¥Õ¥¡¥¤¥ë¤Î¾ÜºÙ¾ðÊó
+               $file_detail_info_row = ACSFileDetailInfo::get_file_detail_info_row($file_id);
+
+               // ¥Õ¥¡¥¤¥ë¤ÎÍúÎò¾ðÊó
+               $file_history_row_array = ACSFileHistory::get_file_history_row_array($file_id);
+               // ¥Õ¥¡¥¤¥ëÍúÎò¤´¤È¤Î¥³¥á¥ó¥È
+               foreach ($file_history_row_array as $index => $file_history_row) {
+                       $file_history_row_array[$index]['file_history_comment_row_array'] = ACSFileHistoryComment::get_file_history_comment_row_array($file_history_row['file_history_id']);
+               }
+
+               // ¥Õ¥¡¥¤¥ë¥¢¥¯¥»¥¹ÍúÎòÅÐÏ¿
+               if ($acs_user_info_row['is_acs_user']) {
+                       ACSFile::set_file_access_history($acs_user_info_row['user_community_id'], $file_id);
+               }
+
+               // Â­À×¾ðÊó¼èÆÀ
+               $footprint_url = $this->getControllerPath('User', 'FileDetail')
+                                               . "&id=" . $target_user_community_id
+                                               . "&file_id=" . $file_obj->get_file_id()
+                                               . "&folder_id=" . $user_folder_obj->folder_obj->get_folder_id();
+               $where  = "foot.contents_link_url = '" . $footprint_url . "'";
+               $where .= " AND foot.visitor_community_id = '" . $acs_user_info_row['user_community_id'] . "'";
+               $footprint_info = ACSUser::get_footprint_list($target_user_community_id, $where);
+
+               // set
+               $request->setAttribute('target_user_info_row', $target_user_info_row);
+               $request->setAttribute('file_obj', $file_obj);
+               $request->setAttribute('user_folder_obj', $user_folder_obj);
+               $request->setAttribute('file_detail_info_row', $file_detail_info_row);
+               $request->setAttribute('file_history_row_array', $file_history_row_array);
+               $request->setAttribute('footprint_info', $footprint_info);
+
+               return View::SUCCESS;
+       }
+       
+       function isSecure () {
+               return false;
+       }
+       function getCredential () {
+               return array('USER_PAGE_OWNER');
+       }
+
+       function get_execute_privilege () {
+               $context = $this->getContext();
+               $user = $context->getUser();
+
+               // Èó¥í¥°¥¤¥ó¥æ¡¼¥¶¡¢ËܿͰʳ°¤ÏNG
+               if ($user->hasCredential('PUBLIC_USER')
+                                || !$user->hasCredential('USER_PAGE_OWNER')) {
+                       return false;
+               }
+               return true;
+       }
+}
+
+?>