diff --git a/main/work/work.lib.php b/main/work/work.lib.php
index 30937f2b0b..9d9681f952 100644
--- a/main/work/work.lib.php
+++ b/main/work/work.lib.php
@@ -325,22 +325,58 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
foreach($dirs_list as $dir)
{
+
$mydir = $my_sub_dir.$dir;
+ $display_edit_form = false;
+
+ if(isset($_GET['edit_dir']) && $_GET['edit_dir']==$mydir)
+ {
+ $display_edit_form = true;
+ $form_folder = new FormValidator('edit_dir', 'post', api_get_self().'?curdirpath='.$my_sub_dir.'&edit_dir='.$mydir);
+ $group_name[] = FormValidator :: createElement('text','dir_name');
+ $group_name[] = FormValidator :: createElement('submit','submit_edit_dir',get_lang('Ok'));
+ $form_folder -> addGroup($group_name,'my_group');
+ $form_folder -> addGroupRule('my_group',get_lang('ThisFieldIsRequired'),'required');
+ $form_folder -> setDefaults(array('my_group[dir_name]'=>$dir));
+ if($form_folder -> validate())
+ {
+ $values = $form_folder -> exportValues();
+ $values = $values['my_group'];
+ update_dir_name($mydir,$values['dir_name']);
+ $mydir = $my_sub_dir.$values['dir_name'];
+ $dir = $values['dir_name'];
+ $display_edit_form = false;
+ }
+ }
+
$action = '';
//display info depending on the permissions
$row = array();
$class = '';
$url = implode("/", array_map("rawurlencode", explode("/", $work->url)));
+
+ if($display_edit_form)
+ {
+ $row[] = $form_folder->toHtml();
+ }
+ else
+ {
+ $row[] = '
'.$dir.'';
+ }
+ $row[] = '';
+
$row[] = '
';
$row[] = ''.$dir.'';
+
$row[] = '';
$row[] = '';
if( $is_allowed_to_edit)
{
- //$action .= '
';
+ $action .= '
';
$action .= '
';
$action .= '
';
$row[] = $action;
@@ -669,4 +705,36 @@ function update_work_url($id,$new_path){
return $res2;
}
}
+
+/**
+ * Update the url of a dir in the student_publication table
+ * @param string old path
+ * @param string new path
+ */
+function update_dir_name($path, $new_name)
+{
+ global $base_work_dir;
+
+ include_once(api_get_path(LIBRARY_PATH) . "/fileManage.lib.php");
+ include_once(api_get_path(LIBRARY_PATH) . "/fileUpload.lib.php");
+
+ $path_to_dir = dirname($path);
+ if($path_to_dir=='.')
+ $path_to_dir = '';
+ else
+ $path_to_dir .= '/';
+
+ my_rename($base_work_dir.'/'.$path,$new_name);
+
+ $table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
+ $sql = 'SELECT id, url FROM '.$table.' WHERE url LIKE "work/'.$path.'/%"';
+ $rs = api_sql_query($sql, __FILE__, __LINE__);
+ while($work = Database :: fetch_array($rs))
+ {
+ $work_name = basename($work['url']);
+ //echo $work_name;
+ $sql = 'UPDATE '.$table.' SET url="work/'.$path_to_dir.$new_name.'/'.$work_name.'" WHERE id= '.$work['id'];
+ api_sql_query($sql, __FILE__, __LINE__);
+ }
+}
?>
\ No newline at end of file
diff --git a/main/work/work.php b/main/work/work.php
index e2ccd0519b..06010aca43 100644
--- a/main/work/work.php
+++ b/main/work/work.php
@@ -26,7 +26,7 @@
* @author Patrick Cool , 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 14651 2008-03-18 20:15:04Z juliomontoya $
+* @version $Id: work.php 14679 2008-03-21 14:15:28Z elixir_inter $
*
* @todo refactor more code into functions, use quickforms, coding standards, ...
*/
@@ -125,6 +125,7 @@ require_once(api_get_path(LIBRARY_PATH) . "course.lib.php");
require_once(api_get_path(LIBRARY_PATH) . "debug.lib.inc.php");
require_once(api_get_path(LIBRARY_PATH) . "events.lib.inc.php");
require_once(api_get_path(LIBRARY_PATH) . "security.lib.php");
+require_once(api_get_path(LIBRARY_PATH) . "formvalidator/FormValidator.class.php");
require_once('work.lib.php');
/*