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;
     }
     $acs_user_info_row = $user->getAttribute('acs_user_info_row');
     $target_community_id = $request->getParameter('community_id');
     $target_community_folder_id = $request->getParameter('folder_id');
     $file_id = $request->getParameter('file_id');
     $file_history_id = $request->getParameter('file_history_id');
     // アクセス制御 // プットフォルダ、ファイルはNG
     $file_obj = ACSFile::get_file_info_instance($file_id);
     if ($file_obj->get_owner_community_id() != $target_community_id) {
         $controller->forward(SECURE_MODULE, SECURE_ACTION);
         return;
         //return VIEW_NONE;
     }
     $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
     $community_folder_obj = new ACSUserFolder($target_community_id, $acs_user_info_row, $target_community_folder_id);
     $folder_obj = $community_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_msg('Community', '', 'M001'));
     }
     // ファイル詳細情報へ遷移
     $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}");
     //return VIEW_NONE;
 }
Exemplo n.º 2
0
 /**
  * 履歴ファイルダウンロード
  *
  * @param none
  *
  * @return none
  */
 function download_history_file($file_history_id, $mode = '')
 {
     $file_history_row = ACSFileHistory::get_file_history_row($file_history_id);
     // ファイルパス
     if ($mode == 'thumb') {
         $file_path = $file_history_row['thumbnail_server_file_name'];
     } else {
         $file_path = $file_history_row['server_file_name'];
     }
     // ファイルが読み込みできない場合
     if (!is_readable(ACS_FOLDER_DIR . $file_path)) {
         header("Cache-Control: public, max-age=0");
         header("Pragma:");
         echo "Not Found";
         return;
     }
     // ダウンロードファイル名
     //		$download_file_name = mb_convert_encoding($this->get_display_file_name(), mb_http_output());
     $download_file_name = $this->get_display_file_name();
     // Content-type
     $content_type = $file_history_row['mime_type'];
     if ($content_type == '') {
         $content_type = 'application/octet-stream';
     }
     // charset (textの場合)
     if (preg_match('/text/', $content_type)) {
         $str = implode('', file(ACS_FOLDER_DIR . $file_path));
         $encoding = mb_detect_encoding($str, 'auto');
         if ($encoding == 'ASCII' && mb_http_output() != 'pass') {
             $content_type .= "; charset=" . mb_preferred_mime_name(mb_http_output());
         } else {
             $content_type .= "; charset=" . mb_preferred_mime_name($encoding);
         }
     }
     // action: inline(ブラウザ内表示), attachment(ダウンロードダイアログ)
     //if (preg_match('/text|image/', $content_type)) {
     if (preg_match('/image/', $file_history_row['mime_type']) || preg_match('/text/', $file_history_row['mime_type'])) {
         $action = 'inline';
     } else {
         $action = 'attachment';
     }
     // HTTPヘッダを吐く (action: inline, attachment)
     //		header("Content-disposition: $action; filename=\"$download_file_name\"");
     header("Content-disposition: {$action}; attachment; filename=\"" . ACSFile::get_download_name($download_file_name) . '"');
     header("Content-type: {$content_type}");
     // output_bufferingを無効にする
     mb_http_output('pass');
     if ($mode == 'thumb') {
         header("Cache-Control: public, max-age=1800");
         header("Pragma:");
     } else {
         header("Cache-Control: public, max-age=0");
         header("Pragma:");
     }
     // ファイルを読み出す
     readfile(ACS_FOLDER_DIR . $file_path);
 }