3 // $Id: RestoreHistoryFileAction.class.php,v 1.2 2006/11/20 08:44:25 w-ota Exp $
5 class RestoreHistoryFileAction extends BaseAction
8 function getDefaultView() {
9 $context = $this->getContext();
10 $controller = $context->getController();
11 $request = $context->getRequest();
12 $user = $context->getUser();
14 $acs_user_info_row = $user->getAttribute('acs_user_info_row');
15 $target_user_community_id = $request->getParameter('id');
16 $target_user_community_folder_id = $request->getParameter('folder_id');
17 $file_id = $request->getParameter('file_id');
18 $file_history_id = $request->getParameter('file_history_id');
20 if (!$this->get_execute_privilege()) {
21 $controller->forward(SECURE_MODULE, SECURE_ACTION);
25 $file_info_row = ACSFileInfoModel::select_file_info_row($file_id);
26 $file_history_row = ACSFileHistory::get_file_history_row($file_history_id);
29 $request->setAttribute('file_info_row', $file_info_row);
30 $request->setAttribute('file_history_row', $file_history_row);
37 $context = $this->getContext();
38 $controller = $context->getController();
39 $request = $context->getRequest();
40 $user = $context->getUser();
42 $acs_user_info_row = $user->getAttribute('acs_user_info_row');
43 $target_user_community_id = $request->getParameter('id');
44 $target_user_community_folder_id = $request->getParameter('folder_id');
45 $file_id = $request->getParameter('file_id');
46 $file_history_id = $request->getParameter('file_history_id');
48 if (!$this->get_execute_privilege()) {
49 $controller->forward(SECURE_MODULE, SECURE_ACTION);
53 $file_info_row = ACSFileInfoModel::select_file_info_row($file_id);
54 $file_history_row = ACSFileHistory::get_file_history_row($file_history_id);
57 $form = $request->ACSGetParameters();
62 $user_folder_obj = new ACSUserFolder($target_user_community_id,
64 $target_user_community_folder_id);
65 $folder_obj = $user_folder_obj->get_folder_obj();
68 $ret = $folder_obj->restore_history_file($file_info_row, $file_history_row);
71 print "ERROR: Restore file failed.";
74 // ¥Õ¥¡¥¤¥ëÍúÎò¾ðÊóÅÐÏ¿
76 $file_info_row = ACSFileInfoModel::select_file_info_row($file_id);
77 $ret = ACSFileHistory::set_file_history($file_info_row, $acs_user_info_row['user_community_id'], $form['comment'], ACSMsg::get_mst('file_history_operation_master','D0301'));
80 // ¥Õ¥¡¥¤¥ë¾ÜºÙ¾ðÊó¤ØÁ«°Ü
81 $file_detail_url = $this->getControllerPath('User', 'FileDetail');
82 $file_detail_url .= '&id=' . $target_user_community_id;
83 $file_detail_url .= '&file_id=' . $file_id;
84 $file_detail_url .= '&folder_id=' . $target_user_community_folder_id;
85 header("Location: $file_detail_url");
88 function getRequestMethods () {
92 function isSecure () {
96 function getCredential() {
97 return array('USER_PAGE_OWNER');
100 function get_execute_privilege () {
101 $context = $this->getContext();
102 $user = $context->getUser();
104 // Èó¥í¥°¥¤¥ó¥æ¡¼¥¶¡¢ËܿͰʳ°¤ÏNG
105 if ($user->hasCredential('PUBLIC_USER')
106 || !$user->hasCredential('USER_PAGE_OWNER')) {