X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=webapp%2Fmodules%2FUser%2Factions%2FRestoreHistoryFileAction.class.php;fp=webapp%2Fmodules%2FUser%2Factions%2FRestoreHistoryFileAction.class.php;h=7ad15a84c1e31b66df3aba3dfabe900595aa9a0b;hb=5b9f238c81808ea11bff12536ee867e3c3b7fc07;hp=0000000000000000000000000000000000000000;hpb=8f9121013e0e238a039705ba092ca08b5234d632;p=acs%2Facs.git diff --git a/webapp/modules/User/actions/RestoreHistoryFileAction.class.php b/webapp/modules/User/actions/RestoreHistoryFileAction.class.php new file mode 100644 index 0000000..7ad15a8 --- /dev/null +++ b/webapp/modules/User/actions/RestoreHistoryFileAction.class.php @@ -0,0 +1,113 @@ +getContext(); + $controller = $context->getController(); + $request = $context->getRequest(); + $user = $context->getUser(); + + $acs_user_info_row = $user->getAttribute('acs_user_info_row'); + $target_user_community_id = $request->getParameter('id'); + $target_user_community_folder_id = $request->getParameter('folder_id'); + $file_id = $request->getParameter('file_id'); + $file_history_id = $request->getParameter('file_history_id'); + + if (!$this->get_execute_privilege()) { + $controller->forward(SECURE_MODULE, SECURE_ACTION); + return; + } + + $file_info_row = ACSFileInfoModel::select_file_info_row($file_id); + $file_history_row = ACSFileHistory::get_file_history_row($file_history_id); + + // set + $request->setAttribute('file_info_row', $file_info_row); + $request->setAttribute('file_history_row', $file_history_row); + + return View::SUCCESS; + } + + // 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'); + $target_user_community_id = $request->getParameter('id'); + $target_user_community_folder_id = $request->getParameter('folder_id'); + $file_id = $request->getParameter('file_id'); + $file_history_id = $request->getParameter('file_history_id'); + + if (!$this->get_execute_privilege()) { + $controller->forward(SECURE_MODULE, SECURE_ACTION); + return; + } + + $file_info_row = ACSFileInfoModel::select_file_info_row($file_id); + $file_history_row = ACSFileHistory::get_file_history_row($file_history_id); + + // form + $form = $request->ACSGetParameters(); + + // ¥Õ¥¡¥¤¥ëÉü³è½èÍý + + // ¥Õ¥©¥ë¥Àobj + $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(); + + // file_info¹¹¿· + $ret = $folder_obj->restore_history_file($file_info_row, $file_history_row); + + if (!$ret) { + print "ERROR: Restore file failed."; + } + + // ¥Õ¥¡¥¤¥ëÍúÎò¾ðÊóÅÐÏ¿ + if ($ret) { + $file_info_row = ACSFileInfoModel::select_file_info_row($file_id); + $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')); + } + + // ¥Õ¥¡¥¤¥ë¾ÜºÙ¾ðÊó¤ØÁ«°Ü + $file_detail_url = $this->getControllerPath('User', 'FileDetail'); + $file_detail_url .= '&id=' . $target_user_community_id; + $file_detail_url .= '&file_id=' . $file_id; + $file_detail_url .= '&folder_id=' . $target_user_community_folder_id; + header("Location: $file_detail_url"); + } + + function getRequestMethods () { + return Request::POST; + } + + 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; + } +} + +?>