Index: index.php
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/index.php,v
retrieving revision 1.30.2.9.2.19
diff -u -r1.30.2.9.2.19 index.php
--- index.php	6 Nov 2004 16:13:48 -0000	1.30.2.9.2.19
+++ index.php	24 Nov 2004 12:54:04 -0000
@@ -978,6 +978,32 @@
 				}
 	
 				###
+				# Lock is on or off
+				###
+				if ( $GLOBALS['settings']['locks'] )
+				{
+					html_table_col_begin ();
+					$lock = @end($files['locks']);
+					if ( $lock ) 
+					{
+						if ( !ereg('Second-',$lock[0]['timeout']))
+						{
+							html_text ($lock[0]['timeout']);
+						}
+						else
+						{
+							$t = explode('-',$lock[0]['timeout']);
+							html_text ($t[1] .'s');
+						}
+					}
+					else
+					{
+						html_text('-');
+					}
+					html_table_col_end ();
+				}
+				
+				###
 				# MIME type
 				###
 	
@@ -1156,6 +1182,12 @@
 								html_form_select_begin ('menu',0,"document.getElementById('file_menu').selectedIndex>5 ? (document.getElementById('menu_todir').disabled=false) : document.getElementById('form_files').submit()",NULL,True,'file_menu');
 									html_form_option ('',lang('Menu -->'),1);
 									html_form_option ('edit',lang('Edit'));
+									//FIXME: This is only available for webdav 'till now
+									//if ( $GLOBALS['phpgw_info']['server']['file_repository'] == 'dav' )
+									{
+										html_form_option ('lock',lang('Lock'));
+										html_form_option ('unlock',lang('Unlock'));
+									}
 									html_form_option ('rename',lang('Rename'));
 									html_form_option ('delete',lang('Delete'));
 									html_form_option ('edit_comments',lang('Edit comments'));
@@ -1362,10 +1394,9 @@
 		html_table_row_end ();
 		html_table_end ();
 	}
-	elseif ($edit_save)
+	elseif ($edit_save || $edit_leave)
 	{
 		$content = $edit_file_content;
-
 		if ($GLOBALS['phpgw']->vfs->write (array (
 				'string'	=> $edit_file,
 				'relatives'	=> array (RELATIVE_ALL),
@@ -1375,14 +1406,26 @@
 		{
 			html_text_bold (lang('Saved %1', $path.'/'.$edit_file));
 			html_break (2);
-			html_link_back ();
+//			html_link_back ();
 		}
 		else
 		{
 			html_text_error (lang('Could not save %1', $path.'/'.$edit_file));
 			html_break (2);
+//			html_link_back ();
+		}
+		if ( $edit_leave )
+		{
 			html_link_back ();
 		}
+		$file_ar = array ('string'    => $edit_file,'relatives' => array (RELATIVE_ALL),'owner_lid' => False);
+		if ( $lock_hidden && $edit_leave )
+		{
+			$file_ar['token'] = $lock_hidden;
+			$GLOBALS['phpgw']->vfs->unlock($file_ar);
+		}
+		if ( $edit_leave ) unset($lock_hidden);
+		unset($file_ar);
 	}
 
 /* This doesn't work just yet
@@ -1420,7 +1463,8 @@
 	###
 	# Now we display the edit boxes and forms
 	###
-
+	if ( !$edit_leave )
+	{
 	for ($j = 0; $j != $numoffiles; $j++)
 	{
 		###
@@ -1433,12 +1477,18 @@
 			continue;
 		}
 
+		$file_ar = array ( 'string'    => $fileman[$j], 'relatives' => array (RELATIVE_ALL));
 		if ($fileman[$j] && $GLOBALS['phpgw']->vfs->file_exists (array (
 						'string'	=> $fileman[$j],
 						'relatives'	=> array (RELATIVE_ALL)
 			))
 		)
 		{
+			if ( empty($lock_hidden) && $GLOBALS['phpgw']->vfs->lock($file_ar) )
+			{
+				$GLOBALS['phpgw']->vfs->add_lock_override($file_ar);
+			}
+			unset($lock_hidden);
 			if ($edit_file)
 			{
 				$content = stripslashes ($edit_file_content);
@@ -1450,6 +1500,7 @@
 
 			html_table_begin ('100%');
 			html_form_begin ($GLOBALS['appname'].'/index.php?path='.$path);
+					html_form_input('hidden', 'lock_hidden', $GLOBALS['phpgw']->vfs->lock_token($file_ar));
 					html_form_input ('hidden', 'edit', True);
 						html_form_input ('hidden', 'edit_file', $fileman[$j]);
 			
@@ -1473,12 +1524,16 @@
 								html_form_input ('submit', 'edit_save', lang('Save %1', html_encode ($fileman[$j], 1)));
 					//			html_break (1);
 					//			html_form_input ('submit', 'edit_save_all', lang('Save all'));
+								html_break(1);
+								html_form_input ('submit', 'edit_leave', lang('Leave edit Session') );
 							html_table_col_end ();
 						html_table_row_end ();
 						html_break (2);
 					html_form_end ();
 			html_table_end ();
 		}
+		unset($file_ar);
+	}
 	}
 }
 
@@ -1852,6 +1907,65 @@
 	html_break (2);
 	html_link_back ();
 }
-
+##
+# Handle locking files
+##
+elseif($menu == 'lock')
+{
+	while (list ($num, $file) = @each ($fileman))
+	{
+		$fileop = array ( 'string'        => $path . '/' . $file,
+				'relatives'     => array (RELATIVE_NONE),
+				'checksubdirs'  => False,
+				'nofiles'       => True
+				);
+		if ( $GLOBALS['settings']['lock_timeout'] )
+		{
+			$fileop += array('timeout' => $GLOBALS['settings']['lock_timeout']);
+		}
+		else
+		{
+			$fileop += array('timeout' => 3600);
+		}
+		if ( ($ans = $GLOBALS['phpgw']->vfs->lock($fileop)) )
+		{
+			html_text( lang( 'Locking the files ok !' ) );
+			$tok = $GLOBALS['phpgw']->vfs->lock_token($fileop);
+			$fileinfo['token'] = $tok;
+			//Doing this allow us (and only us !) to work on the file for this session
+			$GLOBALS['phpgw']->vfs->add_lock_override($fileop,$tok);
+		}
+		else
+		{
+			html_text( lang( 'Locking file failed !' ));
+		}
+	}
+	html_break (2);
+	html_link_back ();
+}
+elseif($menu == 'unlock')
+{
+	while (list ($num, $file) = @each ($fileman))
+	{
+		$fileop = array ( 'string'        => $path . '/' . $file,
+				'relatives'     => array (RELATIVE_NONE),
+				'checksubdirs'  => False,
+				'nofiles'       => True,
+				'owner_lid'		=> False //<= So default user now
+				);
+		$tok = $GLOBALS['phpgw']->vfs->lock_token($fileop);
+		$fileop['token'] = $tok;
+		if ( $GLOBALS['phpgw']->vfs->unlock($fileop) )
+		{
+			html_text(lang( 'unlocking ok' ) );
+		}
+		else
+		{
+			html_text( lang( 'unlocking failed !' ));
+		}
+	}
+	html_break (2);
+	html_link_back ();
+}
 html_page_close ();
 ?>
Index: preferences.php
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/preferences.php,v
retrieving revision 1.6.2.2.2.8
diff -u -r1.6.2.2.2.8 preferences.php
--- preferences.php	26 Feb 2004 01:45:07 -0000	1.6.2.2.2.8
+++ preferences.php	19 Nov 2004 08:52:53 -0000
@@ -37,6 +37,11 @@
 	   displayed name, value values are choices in the dropdown
 	*/
 	$other_dropdown = array ("show_upload_boxes" => array (lang("Default number of upload fields to show"), "1", "5", "10", "20", "30"));
+	//if ( $GLOBALS['phpgw_info']['server']['file_repository'] == 'dav' )
+	{
+		// the 0 value is for getting the default from apache server
+		$other_dropdown += array ('lock_timeout' => array(lang('File/Dir Locks Timeout (in seconds)'),"0","600","3600","28800","Infinite"));
+	}
 	
 	/*
 	   To add a input field preferences, add it here.  Key is internal name, value key is
Index: inc/main.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/inc/Attic/main.inc.php,v
retrieving revision 1.14.2.2.2.4
diff -u -r1.14.2.2.2.4 main.inc.php
--- inc/main.inc.php	26 Feb 2004 01:45:08 -0000	1.14.2.2.2.4
+++ inc/main.inc.php	19 Nov 2004 08:52:53 -0000
@@ -83,8 +83,11 @@
 # This is used both by internally and externally for things like preferences
 ###
 
+//if ( $GLOBALS['phpgw_info']['server']['file_repository'] == 'dav' )
+{
 $file_attributes = Array(
 	'name' => lang('File Name'),
+	'locks' => lang('Locks'),
 	'mime_type' => lang('MIME Type'),
 	'size' => lang('Size'),
 	'created' => lang('Created'),
@@ -97,6 +100,7 @@
 	'comment' => lang('Comment'),
 	'version' => lang('Version')
 );
+}
 
 ###
 # Calculate and display B or KB or MB
Index: setup/phpgw_en.lang
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/setup/phpgw_en.lang,v
retrieving revision 1.1.2.3.2.7
diff -u -r1.1.2.3.2.7 phpgw_en.lang
--- setup/phpgw_en.lang	6 Oct 2004 19:28:24 -0000	1.1.2.3.2.7
+++ setup/phpgw_en.lang	19 Nov 2004 08:52:53 -0000
@@ -11,15 +11,15 @@
 copy to	filemanager	en	Copy To
 copy to:	filemanager	en	Copy to:
 could not copy %1 to %2	filemanager	en	Could not copy %1 to %2
-Could not copy %1 to %2 Quota exceeded	filemanager	en	Could not copy %1 to %2 Quota exceeded
+could not copy %1 to %2 quota exceeded	filemanager	en	Could not copy %1 to %2 Quota exceeded
 could not create %1	filemanager	en	Could not create %1
 could not create directory %1	filemanager	en	Could not create directory %1
 could not delete %1	filemanager	en	Could not delete %1
 could not move %1 to %2	filemanager	en	Could not move %1 to %2
-Could not move %1 to %2 Quota exceeded	filemanager	en	Could not move %1 to %2 Quota exceeded
+could not move %1 to %2 quota exceeded	filemanager	en	Could not move %1 to %2 Quota exceeded
 could not rename %1 to %2	filemanager	en	Could not rename %1 to %2
 could not save %1	filemanager	en	Could not save %1
-could not upload %1 Quota exceeded	filemanager	en	could not upload %1 Quota exceeded
+could not upload %1 quota exceeded	filemanager	en	could not upload %1 Quota exceeded
 create file	filemanager	en	Create File
 create folder	filemanager	en	Create Folder
 created	filemanager	en	Created
@@ -39,7 +39,7 @@
 edit	filemanager	en	Edit
 edit comments	filemanager	en	Edit comments
 edit quota	filemanager	en	Edit Quota
-Enter comma separated Quota value in MB	filemanager	en	Enter comma separated Quota value in MB
+enter comma separated quota value in mb	filemanager	en	Enter comma separated Quota value in MB
 erroneous input! check quota value!	filemanager	en	Erroneous input! Check Quota value!
 error running command	filemanager	en	Error running command
 execute	filemanager	en	Execute
@@ -50,6 +50,7 @@
 file name	filemanager	en	File Name
 file names cannot contain "%1"	filemanager	en	File names cannot contain "%1"
 file names cannot contain \ or /	filemanager	en	File names cannot contain \ or /
+file/dir locks timeout (in seconds)	filemanager	en	File/Dir Locks Timeout (in seconds)
 filemanager	common	en	Filemanager
 filemanager preferences	filemanager	en	FileManager preferences
 files	filemanager	en	Files
@@ -59,7 +60,12 @@
 go to your home directory	filemanager	en	Go to your home directory
 go to:	filemanager	en	Go to:
 home	filemanager	en	Home
+leave edit session	filemanager	en	Leave edit Session
+lock	filemanager	en	Lock
 locked	filemanager	en	Locked
+locking file failed !	filemanager	en	Locking file failed !
+locking the files ok !	filemanager	en	Locking the files ok !
+locks	filemanager	en	Locks
 menu -->	filemanager	en	Menu -->
 mime type	filemanager	en	MIME Type
 modified	filemanager	en	Modified
@@ -73,6 +79,7 @@
 owner	filemanager	en	Owner
 preview %1	filemanager	en	Preview %1
 preview of %1	filemanager	en	Preview of %1
+préférences	preferences	en	Préférences
 refresh	filemanager	en	Refresh
 rename	filemanager	en	Rename
 renamed %1 to %2	filemanager	en	Renamed %1 to %2
@@ -90,6 +97,9 @@
 sort by:	filemanager	en	Sort by:
 total files	filemanager	en	Total Files
 unknown mime-type defaults to text/plain when viewing	filemanager	en	Unknown MIME-type defaults to text/plain when viewing
+unlock	filemanager	en	Unlock
+unlocking failed !	filemanager	en	unlocking failed !
+unlocking ok	filemanager	en	unlocking ok
 unused space	filemanager	en	Unused space
 up	filemanager	en	Up
 update	filemanager	en	Update
Index: setup/phpgw_fr.lang
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/setup/phpgw_fr.lang,v
retrieving revision 1.1.2.4.2.4
diff -u -r1.1.2.4.2.4 phpgw_fr.lang
--- setup/phpgw_fr.lang	6 Oct 2004 19:28:24 -0000	1.1.2.4.2.4
+++ setup/phpgw_fr.lang	19 Nov 2004 08:52:53 -0000
@@ -11,15 +11,15 @@
 copy to	filemanager	fr	Copier vers
 copy to:	filemanager	fr	Copier vers:
 could not copy %1 to %2	filemanager	fr	N'a pas pu copier %1 vers %2
-Could not copy %1 to %2 Quota exceeded	filemanager	fr	N'a pas pu copier %1 vers %2 Quota dépassé
+could not copy %1 to %2 quota exceeded	filemanager	fr	N'a pas pu copier %1 vers %2 Quota dépassé
 could not create %1	filemanager	fr	N'a pas pu créér %1
 could not create directory %1	filemanager	fr	N'a pas pu créér le répertoire %1
 could not delete %1	filemanager	fr	N'a pas pu effacer %1
 could not move %1 to %2	filemanager	fr	N'a pas pu déplacer %1 to %2
-Could not move %1 to %2 Quota exceeded	filemanager	fr	N'a pas pu déplacer %1 vers %2 Quota dépassé
+could not move %1 to %2 quota exceeded	filemanager	fr	N'a pas pu déplacer %1 vers %2 Quota dépassé
 could not rename %1 to %2	filemanager	fr	N'a pas pu renommer %1 to %2
 could not save %1	filemanager	fr	N'a pas pu enregistrer %1
-could not upload %1 Quota exceeded	filemanager	fr	N'a pas pu uploader %1 Quota dépassé
+could not upload %1 quota exceeded	filemanager	fr	N'a pas pu uploader %1 Quota dépassé
 create file	filemanager	fr	Créér fichier
 create folder	filemanager	fr	Créér dossier
 created	filemanager	fr	Créé
@@ -32,14 +32,14 @@
 deleted %1	filemanager	fr	%1 effacé
 directory	filemanager	fr	Répertoire
 directory %1 already exists	filemanager	fr	Le répertoire %1 existe déjà
-Directory %1 does not exist	filemanager	fr	Le répertoire %1 n'existe pas
+directory %1 does not exist	filemanager	fr	Le répertoire %1 n'existe pas
 directory names cannot contain "%1"	filemanager	fr	Les noms de répertoire ne peuvent pas contenir "%1"
 display attributes	filemanager	fr	Afficher les attributs
 download	filemanager	fr	Downloader
 edit	filemanager	fr	Modifier
 edit comments	filemanager	fr	Modifier les commentaires
 edit quota	filemanager	fr	Modifier le Quota
-Enter comma separated Quota value in MB	filemanager	fr	Entrez les valeurs de Quota en MO séparées par des virgules
+enter comma separated quota value in mb	filemanager	fr	Entrez les valeurs de Quota en MO séparées par des virgules
 erroneous input! check quota value!	filemanager	fr	Entrée incorrecte! Vérifiez la valeur de Quota!
 error running command	filemanager	fr	Erreur à l'exécution de la commande
 execute	filemanager	fr	Exécuter
@@ -49,7 +49,8 @@
 file %1 could not be created.	filemanager	fr	Le fichier %1 n'a pas pu être créé.
 file name	filemanager	fr	Nom du fichier
 file names cannot contain "%1"	filemanager	fr	Les noms de fichier ne peuvent contenir "%1"
-File names cannot contain \ or /	filemanager	fr	Les noms de fichier ne peuvent contenir \ ou /
+file names cannot contain \ or /	filemanager	fr	Les noms de fichier ne peuvent contenir \ ou /
+file/dir locks timeout (in seconds)	filemanager	fr	Éxpiration du délai de bloquage du verrou (en secondes)
 filemanager	common	fr	Gestionnaire de fichiers
 filemanager preferences	filemanager	fr	Préférences filemanager
 files	filemanager	fr	Fichiers
@@ -59,7 +60,12 @@
 go to your home directory	filemanager	fr	Aller dans votre répertoire "home" (maison)
 go to:	filemanager	fr	Aller dans:
 home	filemanager	fr	Maison
-locked	filemanager	fr	Verouillé
+leave edit session	filemanager	fr	Quitter la session de modification
+lock	filemanager	fr	Verrouiller
+locked	filemanager	fr	Verrouillé
+locking file failed !	filemanager	fr	La tentative de verrouillage a échoué !
+locking the files ok !	filemanager	fr	Le(s) verrou(s) est(sont) acquis
+locks	filemanager	fr	Verrous
 menu -->	filemanager	fr	Menu -->
 mime type	filemanager	fr	Type MIME
 modified	filemanager	fr	Modifié
@@ -73,6 +79,7 @@
 owner	filemanager	fr	Propriétaire
 preview %1	filemanager	fr	Prévisualisation %1
 preview of %1	filemanager	fr	Prévisualisation de %1
+préférences	preferences	fr	Préférences
 refresh	filemanager	fr	Rafraîchir
 rename	filemanager	fr	Renommer
 renamed %1 to %2	filemanager	fr	Renommé %1 en %2
@@ -90,6 +97,9 @@
 sort by:	filemanager	fr	Trié par:
 total files	filemanager	fr	Total de fichiers
 unknown mime-type defaults to text/plain when viewing	filemanager	fr	text/plain utilisé par défaut si type MIME inconnu
+unlock	filemanager	fr	Déverrouiller
+unlocking failed !	filemanager	fr	La tentative de déverrouillage a échoué !
+unlocking ok	filemanager	fr	Le(s) verrou(s) a(ont) été retiré(s)
 unused space	filemanager	fr	Espace inutilisé
 up	filemanager	fr	Haut
 update	filemanager	fr	Mettre à jour
@@ -102,4 +112,4 @@
 view documents in new window	filemanager	fr	Voir les documents dans une nouvelle fenêtre
 view documents on server (if available)	filemanager	fr	Voir les documents sur le serveur (si disponible)
 who	filemanager	fr	Qui
-You do not have access to %1	filemanager	fr	Vous n'avez pas accès à %1
+you do not have access to %1	filemanager	fr	Vous n'avez pas accès à %1
Index: tests/test.php
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/tests/test.php,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 test.php
--- tests/test.php	6 Nov 2004 16:13:47 -0000	1.1.2.2
+++ tests/test.php	19 Nov 2004 08:52:53 -0000
@@ -5,7 +5,7 @@
                                 "noappheader" => False,
                                 "enable_vfs_class" => True);
 
-include("../header.inc.php");
+include("../../header.inc.php");
 
 /*
 	General format for output is:
@@ -17,6 +17,7 @@
 html_break (1);
 
 $sep = SEP;
+$phpgw =& $GLOBALS['phpgw'];
 $user = $phpgw->vfs->working_lid;
 $homedir = $phpgw->vfs->fakebase . "/" . $user;
 $realhomedir = preg_replace ("|/|", $sep, $homedir);
