Index: /sandbox/filemanager/setup/phpgw_pt-br.lang
===================================================================
--- /sandbox/filemanager/setup/phpgw_pt-br.lang	(revision 1865)
+++ /sandbox/filemanager/setup/phpgw_pt-br.lang	(revision 1879)
@@ -95,4 +95,8 @@
 Files moved to %1 successfuly	filemanager	pt-br	Arquivos movidos para %1 com sucesso
 Archive	filemanager	pt-br	Arquivar
+Unarchive	filemanager	pt-br	Desarquivar
+New Folder	filemanager	pt-br	Nova pasta
+Remove Folder	filemanager	pt-br	Apagar pasta
+Do you really want to remove folder: %1?	filemanager	pt-br	Você realmente deseja apagar a pasta: %1?
 Your operation was successfully executed	filemanager	pt-br	Sua operação foi executada com sucesso
 Wrong password	filemanager	pt-br	Senha errada
@@ -147,4 +151,5 @@
 Cancel	filemanager	pt-br	Cancelar
 Save	filemanager	pt-br	Salvar
+My folder	filemanager	pt-br	Minha pasta
 Edit folders	filemanager	pt-br	Editar pastas
 Share folders	filemanager	pt-br	Compartilhar pastas
Index: /sandbox/filemanager/inc/class.uifilemanager.inc.php
===================================================================
--- /sandbox/filemanager/inc/class.uifilemanager.inc.php	(revision 1854)
+++ /sandbox/filemanager/inc/class.uifilemanager.inc.php	(revision 1879)
@@ -31,5 +31,8 @@
 			'dir_ls' => True,
 			'search' => True,
+			'get_folders_list' => True,
 			'showUploadboxes' => True,
+			'createdir' => True,
+			'removedir' => True,
 			'uploadModel'=>True
 		);
@@ -59,5 +62,4 @@
 		var $cdtodir; // for switching dir.
 		var $newfile_or_dir;
-		var $newdir_x;
 		var $newfile_x;
 		var $createfile_var;
@@ -348,4 +350,5 @@
 			echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/drag_area.js'></script>";
 			echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/handler.js'></script>";
+			echo "<script src='./phpgwapi/js/dftree/dftree.js'></script>";
 
 			include('load_lang.php');
@@ -468,13 +471,4 @@
 
 
-			/* Update the vfs */
-			if ($this->update_x == 'True') 
-			{
-				$this->bo->vfs->update_real(array(
-					'string' => $this->path,
-					'relatives' => array(RELATIVE_ALL)
-				));
-			}
-
 			# Default is to sort by name
 			if(!$this->sortby)
@@ -488,8 +482,4 @@
 			{
 				$this->createfile();
-			}
-			elseif($this->newfile_or_dir && $this->newdir_x)
-			{
-				$this->createdir();
 			}
 			elseif($this->copy_to_x)
@@ -564,5 +554,5 @@
 				$files = $this->files_array[$i];
 
-				if(!$this->prefs['dotfiles'] && ereg("^\.", $files['name']))
+				if($files['mime_type'] == "Directory" || (!$this->prefs['dotfiles'] && ereg("^\.", $files['name'])))
 				{
 					continue;
@@ -597,5 +587,21 @@
 			echo serialize($return);
 		}
-
+		function get_folders_list()
+		{
+			$this->update_groups();	
+			$this->groups_applications = array();
+
+			foreach ($this->readable_groups as $value)
+			{
+				$applications = CreateObject('phpgwapi.applications', $value['account_id']);
+				$this->groups_applications[$value['account_name']] = $applications->read_account_specific();
+			}
+
+			// selectbox for change/move/and copy to
+			$this->dirs = $this->all_other_directories();
+			foreach($this->dirs as $dir)
+				$return[] = $dir['directory'] . $dir['name'];
+			echo serialize($return);
+		}
 		function fileListing()
 		{
@@ -608,10 +614,7 @@
 				$vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">';
 				$vars[css]='<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">';
+				$vars[css].='<link rel="stylesheet" type="text/css" href="phpgwapi/js/dftree/dftree.css">';
 				$vars[preferences]='<input type="hidden" id="userPreferences" value=\''.serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']).'\'>';
 				$vars[script]='<script>initDrawApi();</script>';
-
-				// create dir and file button
-				//TODO : create folder with problems
-				//$toolbar3.=$this->toolButton('newdir','createdir',lang('Create Folder'));
 				
 				$vars[new_button]=$this->toolButton('new','createfile',lang('New...'));
@@ -629,15 +632,5 @@
 					$vars[tools_button] = "";
 
-				// selectbox for change/move/and copy to
-				$this->dirs=$this->all_other_directories();
-				foreach($this->dirs as $elem){
-					if ($this->path == $elem['directory'].$elem['name'])
-						$class = 'sl';
-					else
-						$class = 'l';
-					$vars[folders].='<br><span onclick="load(\''.$elem['directory'].$elem['name'].'\',this)" class="'.$class.'" onmouseover="this.style.border=\'1px solid black\'" onmouseout="this.style.border=\'1px solid transparent\'">'.$elem['name'].'</span>';
-				}
-
-				$this->dirs=$this->all_other_directories();
+/*				$this->dirs=$this->all_other_directories();
 				foreach($this->dirs as $dir)
 					if((($dir['directory'] . $dir['name']) != $this->path) && $this->bo->vfs->file_exists(array('string' => $dir['directory'] . $dir['name'],'relatives' => array(RELATIVE_NONE))))
@@ -646,6 +639,5 @@
 						$dirs_options .= $this->html_form_option($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']);
 					}
-
-				$toolbar.='<select name="todir" style="visibility:hidden">'.$dirs_options.'</select>';
+				$toolbar.='<select name="todir" style="visibility:hidden">'.$dirs_options.'</select>';*/
 
 				$vars[toolbar1]=$toolbar;
@@ -833,54 +825,61 @@
 		}
 
+		function removedir()
+		{
+			$now = intval(time() / 5);
+			for ($i=0;$i<20;$i++)
+				$now.=$now;
+			$toRemove = $this->path ^ $now;
+			if ( $this->bo->vfs->rm(array( 'string' => $toRemove,
+				'relatives' => array (RELATIVE_NONE)
+			)) )
+				echo "True";
+			else
+				echo "False";
+		}
 		function createdir()
 		{
-			if($this->newdir_x && $this->newfile_or_dir)
-			{
-				if($this->bo->badchar = $this->bo->bad_chars($this->newfile_or_dir, True, True))
-				{
-					$this->messages[]= lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1);
-				}
-
-				/* TODO is this right or should it be a single $ ? */
-				if($$this->newfile_or_dir[strlen($this->newfile_or_dir)-1] == ' ' || $this->newfile_or_dir[0] == ' ')
-				{
-					$this->messages[]= lang('Error:').lang('Cannot create directory because it begins or ends in a space');
-				}
-
-				$ls_array = $this->bo->vfs->ls(array(
-					'string'	=> $this->path . '/' . $this->newfile_or_dir,
-					'relatives'	=> array(RELATIVE_NONE),
-					'checksubdirs'	=> False,
-					'nofiles'	=> True
-				));
-
-				$fileinfo = $ls_array[0];
-
-				if($fileinfo['name'])
-				{
-					if($fileinfo['mime_type'] != 'Directory')
-					{
-						$this->messages[]= lang('Error:').lang('%1 already exists as a file',$fileinfo['name']);
-					}
-					else
-					{
-						$this->messages[]= lang('Error:').lang('Directory %1 already exists', $fileinfo['name']);
-					}
+			if($this->bo->badchar = $this->bo->bad_chars($this->filename, True, True))
+			{
+				echo lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1);
+				return;
+			}
+			/* TODO is this right or should it be a single $ ? */
+			if($this->filename[strlen($this->filename)-1] == ' ' || $this->filename[0] == ' ')
+			{
+				echo lang('Error:').lang('Cannot create directory because it begins or ends in a space');
+			}
+			$ls_array = $this->bo->vfs->ls(array(
+				'string'	=> $this->path . '/' . $this->filename,
+				'relatives'	=> array(RELATIVE_NONE),
+				'checksubdirs'	=> False,
+				'nofiles'	=> True
+			));
+
+			$fileinfo = $ls_array[0];
+
+			if($fileinfo['name'])
+			{
+				if($fileinfo['mime_type'] != 'Directory')
+				{
+					echo lang('Error:').lang('%1 already exists as a file',$fileinfo['name']);
 				}
 				else
 				{
-					if($this->bo->vfs->mkdir(array('string' => $this->newfile_or_dir)))
-					{
-						$this->messages[]=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir);
-					}
-					else
-					{
-						$this->messages[]=lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir);
-					}
-				}
-
-				$this->readFilesInfo();
-				$this->filelisting();
-			}
+					echo lang('Error:').lang('Directory %1 already exists', $fileinfo['name']);
+				}
+			}
+			else
+			{
+				if($this->bo->vfs->mkdir(array('string' => $this->filename)))
+				{
+					echo lang('Created directory %1', $this->disppath.'/'.$this->filename);
+				}
+				else
+				{
+					echo lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->filename);
+				}
+			}
+			echo lang('Directory created');
 		}
 		function getReturnExecuteForm(){
Index: /sandbox/filemanager/js/draw_api.js
===================================================================
--- /sandbox/filemanager/js/draw_api.js	(revision 1874)
+++ /sandbox/filemanager/js/draw_api.js	(revision 1879)
@@ -150,5 +150,4 @@
 	loadPreferences();
 	currentPath = document.getElementById('currentPath').value;
-	toolbar.control('reload');
 	document.getElementById('divAppboxHeader').innerHTML = title_app;
 	displayMessages();
@@ -156,7 +155,6 @@
 	window.onresize = resizeDiv;
 	document.body.style.overflow = "hidden";
-
-}
-
+	cExecute('./index.php?menuaction=filemanager.uifilemanager.get_folders_list',handler.draw_folders_list);
+}
 
 function folderList(){
@@ -555,10 +553,8 @@
 				document.getElementById("em_message_search").focus();';
 			elements[1]['img'] = templatePath+'images/search.gif';
-			/*
-			   elements[2] = new Array();
-			   elements[2]['text'] = get_lang('Edit Folders');
-			   elements[2]['url'] = 'javascript:EditFolders()';
-			   elements[2]['img'] = 'images/mime16_directory.png';
-			   */
+			elements[2] = new Array();
+			elements[2]['text'] = get_lang('Edit Folders');
+			elements[2]['url'] = 'javascript:editFolders()';
+			elements[2]['img'] = templatePath+'images/button_createdir.png';
 			elements[3] = new Array();
 			elements[3]['text'] = get_lang('Share Folders');
@@ -592,4 +588,40 @@
 	draw_window_card('preview','./index.php?menuaction=filemanager.vfs_functions.summary&file='+base64_encode(filename)+"&path="+base64_encode(currentPath));
 }
+function editFolders(operation){
+	if (operation == 'new'){
+		var name = prompt(get_lang('Enter with the name of new file/directory'), '');
+		if (name != null && name != '')
+		{
+			var parentDir = document.getElementById('folders_box').value;
+			cExecute('./index.php?menuaction=filemanager.uifilemanager.createdir&path='+base64_encode(parentDir)+'&filename='+base64_encode(name),handler.refreshDir);
+			currentPath = parentDir+'/'+name;
+			close_window();
+		}
+	}
+	else
+	if (operation == 'remove'){
+			var Dfolder = document.getElementById('folders_box').value;
+			if (confirm(get_lang('Do you really want to remove folder: %1?',Dfolder), ''))
+			{
+				var now = new Date();
+				nowTs = parseInt(now.getTime()/5000).toString();
+				for (var i=0 ;i < 20; i++)
+					nowTs+=nowTs;
+				var toRemove = crypt(Dfolder,nowTs);
+				cExecute('./index.php?menuaction=filemanager.uifilemanager.removedir&path='+base64_encode(toRemove),handler.refreshDir);
+		                var lastIndex = Dfolder.lastIndexOf('/');
+				currentPath = Dfolder.substr(0,lastIndex);
+				close_window();
+			}
+	}
+	else{
+	var buf = "<select id='folders_box'>";
+	for (var i=0; i < folders.length; i++)
+		buf += "<option value='"+folders[i]+"'>"+folders[i]+"</option>";
+	buf += "</select>";
+	code = "<table><tbody><tr><td>"+buf+"</td></tr><tr><td><input type='button' onclick='editFolders(\"new\")' value='"+get_lang('new folder')+"'></td><td><input type='button' onclick='editFolders(\"remove\")' value='"+get_lang('remove folder')+"'></td></tr></tbody></table>";
+	draw_window(code);
+	}
+}
 
 function draw_window_card(id,url){
Index: /sandbox/filemanager/js/handler.js
===================================================================
--- /sandbox/filemanager/js/handler.js	(revision 1869)
+++ /sandbox/filemanager/js/handler.js	(revision 1879)
@@ -121,4 +121,35 @@
 
 }
+handler.prototype.draw_folders_list = function (data) {
+	toolbar.control('reload');
+	folders_tree = new dFTree({name: 'main'});
+	folders = unserialize(data);
+	var rootFold = new dNode({id:'root', caption:get_lang("filemanager")});
+	folders_tree.add(rootFold,'root');
+	var myfolder = new dNode({id:folders[0], caption:get_lang("My Folder"),onClick:'load(\''+folders[0]+'\',this)'});
+	folders_tree.add(myfolder,'root');
+	for (var i=1;i<folders.length;i++)
+	{
+		var lastIndex = folders[i].lastIndexOf('/');
+		var name = folders[i].substr(lastIndex+1,folders[i].length);
+		var parentDir = folders[i].substr(0,lastIndex);
+		if (parentDir == '/home')
+		{
+			parentDir = 'root';
+			folder = new dNode({id:folders[i], caption:name, plusSign:true, onClick:'load(\''+folders[i]+'\',this)'});
+		}
+		else
+			folder = new dNode({id:folders[i], caption:name, plusSign:false, onClick:'load(\''+folders[i]+'\',this)'});
+	        folders_tree.add(folder,parentDir);
+	}
+	document.getElementById('content_folders').innerHTML = "";
+	folders_tree.draw(document.getElementById('content_folders'));
+        folders_tree.openTo(currentPath);
+	folders_tree.getNodeById(currentPath)._select();
+}
+handler.prototype.refreshDir = function (data) {
+	cExecute('./index.php?menuaction=filemanager.uifilemanager.get_folders_list',handler.draw_folders_list);
+	toolbar.control('reload');
+}
 
 var handler = new handler();
Index: /sandbox/filemanager/js/global.js
===================================================================
--- /sandbox/filemanager/js/global.js	(revision 1874)
+++ /sandbox/filemanager/js/global.js	(revision 1879)
@@ -19,4 +19,5 @@
 var permissions = new Array();
 var preferences = new Array();
+var folders = new Array();
 
 var KEY_ENTER = 13;
Index: /sandbox/filemanager/templates/default/main.tpl
===================================================================
--- /sandbox/filemanager/templates/default/main.tpl	(revision 1809)
+++ /sandbox/filemanager/templates/default/main.tpl	(revision 1879)
@@ -42,5 +42,5 @@
 		<tr>
                         <td class="image-menu" valign="top" style="padding:0px">
-                                <div id="content_folders" class="menu-degrade" style="height:100%;width:170px;overflow:auto">{folders}</div>
+                                <div id="content_folders" class="menu-degrade" style="height:100%;width:170px;overflow:auto"></div>
                         </td>
                 </tr>
