if($ns['ns_access_level'] > $member['mb_level']) { $ret = array('code'=>'-1', 'msg'=>'권한 없음'); echo wiki_json_encode($ret); exit; } $thumb =& wiki_class_load("Thumb"); $thumb_width = 30; $thumb_height = 30; $files = $media->getList($loc); foreach($files as $k=>$file) { if($file['img_width'] > 0) { $thumb_path = $thumb->getMediaThumb($loc, $filename=$file['source'], $thumb_width, $thumb_height, $quality=90, $crop=true); $files[$k]['thumb'] = $thumb_path; } else $files[$k]['thumb'] = ""; preg_match("/\.([a-zA-Z0-9]{2,4})$/", $file['source'], $m); if($m[1] && file_exists(WIKI_PATH.'/imgs/media_manager/ext/'.strtolower($m[1]).'.png')) { $files[$k]['ext_icon'] = $wiki['url'].'/imgs/media_manager/ext/'.strtolower($m[1]).'.png'; } else $files[$k]['ext_icon'] = $wiki['url'].'/imgs/media_manager/ext/_blank.png'; $files[$k]['filesize'] = wiki_file_size($file['filesize']); $files[$k]['bytes'] = $file['filesize']; } $ploc = wiki_get_parent_path($loc); $pNS = $media->getNS($ploc); $ret = array('code'=>1, 'files'=>$files, 'parent_mkdir_level'=>$pNS['ns_mkdir_level'], 'mkdir_level'=>$ns['ns_mkdir_level'], 'upload_level'=>$ns['ns_upload_level'], 'access_level'=>$ns['ns_access_level']); echo wiki_json_encode($ret); ?>
/** * * 폴더 삭제 * * 하위 폴더 또는 폴더내에 문서가 없을 경우 삭제하고, * 폴더가 삭제되었을 경우 상위 폴더를 재귀적으로 호출하여 불필요한 폴더들을 삭제한다. * * @param string $ns 폴더 경로 */ function checkAndRemove($ns) { if($ns == "/") return; $escapedNS = mysql_real_escape_string($ns); // load ns $namespace = sql_fetch("SELECT * FROM ".$this->wiki['ns_table']." AS ns LEFT JOIN ".$this->wiki['nsboard_table']." AS nb ON ns.bo_table = nb.bo_table AND ns.ns = nb.ns WHERE ns.bo_table = '".$this->wiki['bo_table']."' AND ns.ns = '$escapedNS'"); // if there's no document if(!$namespace['wr_id']) { // if there's no child, delete $child = sql_fetch("SELECT * FROM ".$this->wiki['ns_table']." WHERE ns LIKE '{$escapedNS}/%'"); if(!$child['ns']) { sql_query("DELETE FROM ".$this->wiki['ns_table']." WHERE bo_table = '".$this->wiki['bo_table']."' AND ns = '$escapedNS'"); // call recursivly about parent $this->checkAndRemove(wiki_get_parent_path($ns)); } } else { // if there's no child, set has_child false $child = sql_fetch("SELECT * FROM ".$this->wiki['ns_table']." WHERE ns LIKE '{$escapedNS}/%'"); if(!$child['ns']) { sql_query("UPDATE ".$this->wiki['ns_table']." SET has_child = 0 WHERE bo_table = '".$this->wiki['bo_table']."' AND ns = '$escapedNS'"); } } }
/** * * 폴더/파일 목록 * * FORMAT : {{folder=/folder1/folder2}} * * @param array $matches 매칭 결과 * @param array $params {@link NarinParser} 에서 전달하는 파라미터 * @return string 폴더/파일 목록 */ public function wiki_folder($matches, $params) { $tmp = explode("?", $matches[1]); $loc = $tmp[0]; parse_str(str_replace("&", "&", $tmp[1])); $wikiNS =& wiki_class_load("Namespace"); // Check level $n = $wikiNS->get($loc); if($this->member['mb_level'] < $n['ns_access_level']) return ""; $files = $wikiNS->getList($loc, $withArticle=true); if(!count($files)) return "{{".$matches[0]."}}"; $up = wiki_get_parent_path($loc); $str = "<ul class='folder_list' style='$style'>"; for($i=0; $i<count($files); $i++) { $str .= '<li class="'.$files[$i]['type'].'"><a href="'.$files[$i]['href'].'">'.$files[$i]['name'].'</a></li>'; } $str .= '</ul>'; return $str; }
echo wiki_json_encode(array('code'=>'-1', 'msg'=>'루트 폴더는 삭제할 수 없습니다.')); exit; } $media =& wiki_class_load("Media"); $parent_ns = wiki_get_parent_path($loc); $parent = $media->getNS($parent_ns); if($parent['ns_mkdir_level'] > $member['mb_level']) { echo wiki_json_encode(array('code'=>'-1', 'msg'=>'권한이 없습니다.')); exit; } $folder = $media->getNS($loc); if($folder['ns_mkdir_level'] > $member['mb_level'] || $folder['ns_access_level'] > $member['mb_level']) { echo wiki_json_encode(array('code'=>'-1', 'msg'=>'권한이 없습니다.')); exit; } $success = $media->deleteFolder($loc); if($success) { echo wiki_json_encode(array('code'=>1, 'updir'=>wiki_get_parent_path($loc))); } else { $ret = array('code'=>'-1', 'msg'=>'빈폴더가 아닙니다.'); echo wiki_json_encode($ret); } ?>