/**
  * @brief 특정 모두의 첨부파일 모두 삭제
  **/
 function deleteModuleFiles($module_srl)
 {
     // 전체 첨부파일 목록을 구함
     $args->module_srl = $module_srl;
     $output = executeQueryArray('file.getModuleFiles', $args);
     if (!$output) {
         return $output;
     }
     $files = $output->data;
     // DB에서 삭제
     $args->module_srl = $module_srl;
     $output = executeQuery('file.deleteModuleFiles', $args);
     if (!$output->toBool()) {
         return $output;
     }
     // 실제 파일 삭제 (일단 약속에 따라서 한번에 삭제)
     FileHandler::removeDir(sprintf("./files/attach/images/%s/", $module_srl));
     FileHandler::removeDir(sprintf("./files/attach/binaries/%s/", $module_srl));
     // DB에서 구한 파일 목록을 삭제
     $path = array();
     $cnt = count($files);
     for ($i = 0; $i < $cnt; $i++) {
         $uploaded_filename = $files[$i]->uploaded_filename;
         FileHandler::removeFile($uploaded_filename);
         $path_info = pathinfo($uploaded_filename);
         if (!in_array($path_info['dirname'], $path)) {
             $path[] = $path_info['dirname'];
         }
     }
     // 해당 글의 첨부파일 디렉토리 삭제
     for ($i = 0; $i < count($path); $i++) {
         FileHandler::removeBlankDir($path[$i]);
     }
     return $output;
 }
 /**
  * Delete the attachment of a particular module
  *
  * @param int $module_srl Sequence of module to delete files
  * @return Object
  */
 function deleteModuleFiles($module_srl)
 {
     // Get a full list of attachments
     $args = new stdClass();
     $args->module_srl = $module_srl;
     $columnList = array('file_srl', 'uploaded_filename');
     $output = executeQueryArray('file.getModuleFiles', $args, $columnList);
     if (!$output) {
         return $output;
     }
     $files = $output->data;
     // Remove from the DB
     $args->module_srl = $module_srl;
     $output = executeQuery('file.deleteModuleFiles', $args);
     if (!$output->toBool()) {
         return $output;
     }
     // Remove the file
     FileHandler::removeDir(sprintf("./files/attach/images/%s/", $module_srl));
     FileHandler::removeDir(sprintf("./files/attach/binaries/%s/", $module_srl));
     // Remove the file list obtained from the DB
     $path = array();
     $cnt = count($files);
     for ($i = 0; $i < $cnt; $i++) {
         $uploaded_filename = $files[$i]->uploaded_filename;
         FileHandler::removeFile($uploaded_filename);
         $path_info = pathinfo($uploaded_filename);
         if (!in_array($path_info['dirname'], $path)) {
             $path[] = $path_info['dirname'];
         }
     }
     // Remove a file directory of the document
     for ($i = 0; $i < count($path); $i++) {
         FileHandler::removeBlankDir($path[$i]);
     }
     return $output;
 }
Esempio n. 3
0
 /**
  * @brief 지정된 디렉토리에 내용이 없으면 삭제
  **/
 function removeBlankDir($path)
 {
     $item_cnt = 0;
     $path = FileHandler::getRealPath($path);
     if (!is_dir($path)) {
         return;
     }
     $directory = dir($path);
     while ($entry = $directory->read()) {
         if ($entry == "." || $entry == "..") {
             continue;
         }
         if (is_dir($path . "/" . $entry)) {
             $item_cnt = FileHandler::removeBlankDir($path . '/' . $entry);
         }
     }
     $directory->close();
     if ($item_cnt < 1) {
         @rmdir($path);
     }
 }
Esempio n. 4
0
 /**
  * Delete all attachments of a particular document
  *
  * @param int $upload_target_srl Upload target srl to delete files
  * @return Object
  **/
 function deleteFiles($upload_target_srl)
 {
     // Get a list of attachements
     $oFileModel =& getModel('file');
     $columnList = array('uploaded_filename', 'module_srl');
     $file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
     // Success returned if no attachement exists
     if (!is_array($file_list) || !count($file_list)) {
         return new Object();
     }
     // Remove from the DB
     $args->upload_target_srl = $upload_target_srl;
     $output = executeQuery('file.deleteFiles', $args);
     if (!$output->toBool()) {
         return $output;
     }
     // Delete the file
     $path = array();
     $file_count = count($file_list);
     for ($i = 0; $i < $file_count; $i++) {
         $uploaded_filename = $file_list[$i]->uploaded_filename;
         FileHandler::removeFile($uploaded_filename);
         $module_srl = $file_list[$i]->module_srl;
         $path_info = pathinfo($uploaded_filename);
         if (!in_array($path_info['dirname'], $path)) {
             $path[] = $path_info['dirname'];
         }
     }
     // Remove a file directory of the document
     for ($i = 0; $i < count($path); $i++) {
         FileHandler::removeBlankDir($path[$i]);
     }
     return $output;
 }
Esempio n. 5
0
 /**
  * @brief 특정 문서의 첨부파일을 모두 삭제
  **/
 function deleteFiles($upload_target_srl)
 {
     // 첨부파일 목록을 받음
     $oFileModel =& getModel('file');
     $file_list = $oFileModel->getFiles($upload_target_srl);
     // 첨부파일이 없으면 성공 return
     if (!is_array($file_list) || !count($file_list)) {
         return new Object();
     }
     // DB에서 삭제
     $args->upload_target_srl = $upload_target_srl;
     $output = executeQuery('file.deleteFiles', $args);
     if (!$output->toBool()) {
         return $output;
     }
     // 실제 파일 삭제
     $path = array();
     $file_count = count($file_list);
     for ($i = 0; $i < $file_count; $i++) {
         $uploaded_filename = $file_list[$i]->uploaded_filename;
         FileHandler::removeFile($uploaded_filename);
         $module_srl = $file_list[$i]->module_srl;
         $path_info = pathinfo($uploaded_filename);
         if (!in_array($path_info['dirname'], $path)) {
             $path[] = $path_info['dirname'];
         }
     }
     // 해당 글의 첨부파일 디렉토리 삭제
     for ($i = 0; $i < count($path); $i++) {
         FileHandler::removeBlankDir($path[$i]);
     }
     return $output;
 }