Browse Source

[svn r18170] Logic changes - Fixed folders list when you want to move a document to them and added document title into "Move to" - see FS#3589

Cristian Fasanando 16 years ago
parent
commit
02944abfe9
2 changed files with 23 additions and 13 deletions
  1. 12 6
      main/work/work.lib.php
  2. 11 7
      main/work/work.php

+ 12 - 6
main/work/work.lib.php

@@ -1,4 +1,4 @@
-<?php //$Id: work.lib.php 18152 2009-02-02 16:25:28Z cfasanando $
+<?php //$Id: work.lib.php 18170 2009-02-02 22:13:45Z cfasanando $
 /* For licensing terms, see /dokeos_license.txt */
 /**
 *	@package dokeos.work
@@ -6,7 +6,7 @@
 * 	@author Patrick Cool <patrick.cool@UGent.be>, Ghent University - ability for course admins to specify wether uploaded documents are visible or invisible by default.
 * 	@author Roan Embrechts, code refactoring and virtual course support
 * 	@author Frederic Vauthier, directories management
-* 	@version $Id: work.lib.php 18152 2009-02-02 16:25:28Z cfasanando $
+* 	@version $Id: work.lib.php 18170 2009-02-02 22:13:45Z cfasanando $
 */
 /**
  * Displays action links (for admins, authorized groups members and authorized students)
@@ -752,11 +752,17 @@ function build_work_directory_selector($folders,$curdirpath,$group_dir='')
  * @return string html form
  */
 function build_work_move_to_selector($folders,$curdirpath,$move_file,$group_dir='')
-{
+{	
+	//gets file title
+	$tbl_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
+	$sql = "SELECT title FROM $tbl_work WHERE id ='".(int)$move_file."'";
+	$result = api_sql_query($sql,__FILE__,__LINE__);
+	$title = Database::fetch_row($result);
+	
 	$form = '<form name="move_to" action="'.api_get_self().'" method="POST">'."\n";
-	$form .= '<input type="hidden" name="move_file" value="'.$move_file.'" />'."\n";
-	$form .= get_lang('MoveTo').' <select name="move_to">'."\n";
-
+	$form .= '<input type="hidden" name="move_file" value="'.$move_file.'" />'."\n";	
+	$form .= sprintf(get_lang('MoveXTo'),$title[0]).' <select name="move_to">'."\n";
+	
 	//group documents cannot be uploaded in the root
 	if($group_dir=='') {
 		if($curdirpath!='/') {

+ 11 - 7
main/work/work.php

@@ -1,4 +1,4 @@
-<?php //$Id: work.php 18113 2009-02-01 11:25:38Z ivantcholakov $
+<?php //$Id: work.php 18170 2009-02-02 22:13:45Z cfasanando $
 /* For licensing terms, see /dokeos_license.txt */
 /**
 *	@package dokeos.work
@@ -6,7 +6,7 @@
 * 	@author Patrick Cool <patrick.cool@UGent.be>, Ghent University - ability for course admins to specify wether uploaded documents are visible or invisible by default.
 * 	@author Roan Embrechts, code refactoring and virtual course support
 * 	@author Frederic Vauthier, directories management
-*  	@version $Id: work.php 18113 2009-02-01 11:25:38Z ivantcholakov $
+*  	@version $Id: work.php 18170 2009-02-02 22:13:45Z cfasanando $
 *
 * 	@todo refactor more code into functions, use quickforms, coding standards, ...
 */
@@ -487,8 +487,7 @@ if (api_is_allowed_to_edit(false,true)) {
 			$added_slash = (substr($cur_dir_path, -1, 1) == '/') ? '' : '/';	
 				
 			$directory =replace_accents($_POST['new_dir']);
-			$dir_name = $cur_dir_path . $added_slash . replace_dangerous_char($directory);
-				
+			$dir_name = $cur_dir_path . $added_slash . replace_dangerous_char($directory);				
 			$created_dir = create_unexisting_work_directory($base_work_dir, $dir_name);
 			
 			// we insert here the directory in the table $work_table		
@@ -627,9 +626,14 @@ if (api_is_allowed_to_edit(false,true)) {
 	 
 	/* ----------------------
 	 * Move file form request
-	 ----------------------- */
-	if (!empty ($_REQUEST['move'])) {
-		$folders = get_subdirs_list($base_work_dir, 1);		
+	 ----------------------- */	 
+	if (!empty ($_REQUEST['move'])) {		 
+		$folders = array();
+		$sql = "SELECT url FROM $work_table  WHERE url LIKE '/%' AND post_group_id = '".(empty($_SESSION['toolgroup'])?0:$_SESSION['toolgroup'])."'";
+		$res = api_sql_query($sql,__FILE__,__LINE__);
+		while($folder = Database::fetch_array($res)) {			
+		$folders[] = substr($folder['url'],1,(strlen($folder['url'])-1));
+		}	
 		Display :: display_normal_message(build_work_move_to_selector($folders, $cur_dir_path, $_REQUEST['move']), false);
 	}
 	/* ------------------