From eb631fdcca6da4f10c846fe7745c9155cd30afd7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 6 May 2011 14:22:46 +0200 Subject: [PATCH] Fixing breadcrumb, fixing bug when moving files, removing delete all and make invisible to all see #3374 --- main/work/work.lib.php | 127 ++++++++++++++++++----------------------- main/work/work.php | 119 ++++++++++++++------------------------ 2 files changed, 99 insertions(+), 147 deletions(-) diff --git a/main/work/work.lib.php b/main/work/work.lib.php index 9a94c4e8af..c3a6f1c5bc 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -28,31 +28,28 @@ function display_action_links($cur_dir_path, $always_show_tool_options, $always_ $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : ''; $curdirpath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : empty($curdirpath); - ///why is that here? - //$origin = api_get_tools_lists($origin); - echo '
'; - if (strlen($cur_dir_path) > 0 && $cur_dir_path != '/') { $parent_dir = dirname($cur_dir_path); $display_output .= ''.Display::return_icon('back.png', get_lang('BackToWorksList'),'','32').''; } else { if ($_GET['display_tool_options'] == 'true' OR $_GET['display_upload_form'] == 'true') { if ($origin != 'learnpath') { - echo ''.Display::return_icon('back.png', get_lang('BackToWorksList'),'','32').''; + //$display_output .= ''.Display::return_icon('back.png', get_lang('BackToWorksList'),'','32').''; } } } - if (!$always_show_tool_options && api_is_allowed_to_edit(null, true) && $origin != 'learnpath') { - + if (!$always_show_tool_options && api_is_allowed_to_edit(null, true) && $origin != 'learnpath') { if (empty($curdirpath)) { - $display_output .= ''.Display::return_icon('back.png', get_lang('BackToWorksList'),'','32').''; + //$display_output .= ''.Display::return_icon('back.png', get_lang('BackToWorksList'),'','32').''; } // Create dir if ($cur_dir_path == '/') { $display_output .= ''.Display::return_icon('new_work.png', get_lang('CreateAssignment'),'','32').''; } - // Options - $display_output .= ''.Display::return_icon('settings.png', get_lang('EditToolOptions'),'','32').''; + if (empty($curdirpath) || $curdirpath == '.') { + // Options + $display_output .= ''.Display::return_icon('settings.png', get_lang('EditToolOptions'),'','32').''; + } } if (!$always_show_upload_form && api_is_allowed_to_session_edit(false, true) && (isset($_GET['curdirpath']) && (!empty($_GET['curdirpath']) && $_GET['curdirpath'] != '.') )) { @@ -68,10 +65,10 @@ function display_action_links($cur_dir_path, $always_show_tool_options, $always_ } if (empty($curdirpath) or $curdirpath != '.') { - $display_output .= ''.Display::return_icon('delete_na.png', get_lang('Delete'),'','32').''; + //$display_output .= ''.Display::return_icon('delete_na.png', get_lang('Delete'),'','32').''; } else { - $display_output .= ''. - Display::return_icon('delete.png', get_lang('Delete'),'','32').''; + /*$display_output .= ''. + Display::return_icon('delete.png', get_lang('Delete'),'','32').'';*/ } // make all files visible or invisible $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); @@ -80,16 +77,19 @@ function display_action_links($cur_dir_path, $always_show_tool_options, $always_ if ($sql_result) { $columnStatus = Database::fetch_array($sql_result); - - if ($columnStatus['Default'] == 1) { - $display_output .= ''. - Display::return_icon('visible.png', get_lang('MakeAllPapersInvisible'),'','32')."\n"; - } else { - $display_output .= ''. - Display::return_icon('invisible.png', get_lang('MakeAllPapersVisible'),'','32')."\n"; - } + /* + if (empty($curdirpath) || $curdirpath == '.') { + if ($columnStatus['Default'] == 1) { + $display_output .= ''. + Display::return_icon('visible.png', get_lang('MakeAllPapersInvisible'),'','32')."\n"; + } else { + $display_output .= ''. + Display::return_icon('invisible.png', get_lang('MakeAllPapersVisible'),'','32')."\n"; + } + }*/ } } + if (api_is_allowed_to_edit(null, true)) { global $publication; if (empty($curdirpath) or $curdirpath != '.' or $cur_dir_path != '/') { @@ -106,10 +106,12 @@ function display_action_links($cur_dir_path, $always_show_tool_options, $always_ } } } + if ($display_output != '') { + echo '
'; echo $display_output; - } - echo '
'; + echo '
'; + } } /** @@ -341,19 +343,16 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC //Get list from database if ($is_allowed_to_edit) { - $sql_get_publications_list = "SELECT * " . - "FROM ".$work_table." " . - "WHERE url LIKE BINARY '$sub_course_dir%' " . - "AND url NOT LIKE BINARY '$sub_course_dir%/%' " .$add_in_where_query. - $condition_session. - " ORDER BY sent_date DESC"; - - $sql_get_publications_num = "SELECT count(*) " . - "FROM ".$work_table." " . - "WHERE url LIKE BINARY '$sub_course_dir%' " . - "AND url NOT LIKE BINARY '$sub_course_dir%/%' " .$add_in_where_query. - $condition_session. - " ORDER BY id"; + $sql_get_publications_list = "SELECT * FROM ".$work_table." " . + "WHERE url LIKE BINARY '$sub_course_dir%' " . + "AND url NOT LIKE BINARY '$sub_course_dir%/%' " .$add_in_where_query.$condition_session. + " ORDER BY sent_date DESC"; + + $sql_get_publications_num = "SELECT count(*) FROM ".$work_table." " . + "WHERE url LIKE BINARY '$sub_course_dir%' " . + "AND url NOT LIKE BINARY '$sub_course_dir%/%' " .$add_in_where_query. + $condition_session. + " ORDER BY id"; } else { if (!empty($_SESSION['toolgroup'])) { @@ -365,15 +364,13 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC } $sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query ".$add_in_where_query." $condition_session ORDER BY id"; - $sql_get_publications_num = "SELECT count(url) " . - "FROM ".$work_table." " . - "WHERE url LIKE BINARY '$sub_course_dir%' " . - "AND url NOT LIKE BINARY '$sub_course_dir%/%' " .$add_in_where_query. - $condition_session. - " ORDER BY id"; + $sql_get_publications_num = "SELECT count(url) FROM ".$work_table." " . + "WHERE url LIKE BINARY '$sub_course_dir%' AND url NOT LIKE BINARY '$sub_course_dir%/%' " .$add_in_where_query. + $condition_session. + " ORDER BY id"; } -// echo $sql_get_publications_list; + //echo $sql_get_publications_list; $sql_result = Database::query($sql_get_publications_list); $sql_result_num = Database::query($sql_get_publications_num); @@ -389,10 +386,10 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC $table_header[] = array(get_lang('Qualification'), true); } - $table_header[] = array(get_lang('Date'), true, 'style="width:70px"'); + $table_header[] = array(get_lang('Date'), true, 'style="width:160px"'); if ($origin != 'learnpath') { - $table_header[] = array(get_lang('Actions'), false, 'style="width:80px"'); + $table_header[] = array(get_lang('Actions'), false, 'style="width:90px"'); $table_header[] = array('RealDate', true); } @@ -418,8 +415,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC foreach($table_header as $item) { $column_order[$i] = $i; $i++; - } - + } if ($count_files != 0) { if ($sub_course_dir == '/work') { @@ -722,18 +718,12 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC $icon = Display::return_icon('work.png', get_lang('Assignment'),array(), 22); if (!empty($display_edit_form) && isset($clean_edit_dir) && $clean_edit_dir == $mydir) { - $row[] = $icon; + $row[] = $icon; $row[] = ''.$form_folder->toHtml(); // form to edit the directory's name } else { $row[] = ''.$icon.''; $add_to_name = ''; - /* - $tbl_gradebook_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); - $sql = "SELECT weight FROM ". $tbl_gradebook_link ." WHERE type='3' AND ref_id= '".$id2."'"; - $result = Database::query($sql); - $count = Database::num_rows($result); - */ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php'; $link_id = is_resource_in_course_gradebook(api_get_course_id(), 3 , $id2 , api_get_session_id()); $count = 0; @@ -836,16 +826,16 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC if ($is_allowed_to_edit) { $action = ''; - $action .= ''.Display::return_icon('rate_work.png', get_lang('CorrectAndRate'),array(), 22).''; - $action .= ''.Display::return_icon('delete.png', get_lang('WorkDelete'),'',22).''; + $action .= ''.Display::return_icon('rate_work.png', get_lang('CorrectAndRate'),array(), 22).''; $action .= ''.Display::return_icon('move.png', get_lang('Move'),array(), 22).''; if ($work->accepted == '1') { $action .= ''.Display::return_icon('visible.png', get_lang('Invisible'),array(), 22).''; } else { - $action .= ''.Display::return_icon('invisible.png', get_lang('Visible'),array(), 22).''; + $action .= ''.Display::return_icon('invisible.png', get_lang('Visible'),array(), 22).' '; } + $action .= ''.Display::return_icon('delete.png', get_lang('WorkDelete'),'',22).''; $row[] = $action; - // the user that is not course admin can only edit/delete own document + // the user that is not course admin can only edit/delete own document } elseif ($row2['insert_user_id'] == $_user['user_id']) { $action = ''; $action .= ''.Display::return_icon('edit.png', get_lang('Modify'),array(), 22).''; @@ -962,7 +952,6 @@ 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 $move_file = intval($move_file); $tbl_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION); @@ -971,20 +960,20 @@ function build_work_move_to_selector($folders, $curdirpath, $move_file, $group_d $title = Database::fetch_row($result); global $gradebook; - $form = '
'."\n"; - $form .= '
'.get_lang('MoveFile').'
'; - $form .= ''."\n"; + $form = ''; + $form .= '
'.get_lang('MoveFile').' - '.Security::remove_XSS($title[0]).'
'; + $form .= ''; $form .= '
- *'.sprintf(get_lang('MoveXTo'), $title[0]).' + *'.get_lang('Select').'
'; - $form .= ' '; //group documents cannot be uploaded in the root if ($group_dir == '') { if ($curdirpath != '/') { - $form .= ''; + //$form .= ''; } if (is_array($folders)) { foreach ($folders as $fid => $folder) { @@ -993,7 +982,7 @@ function build_work_move_to_selector($folders, $curdirpath, $move_file, $group_d //2. inside the folder you want to move //3. inside a subfolder of the folder you want to move if (($curdirpath != $folder) && ($folder != $move_file) && (substr($folder, 0, strlen($move_file) + 1) != $move_file.'/')) { - $form .= ''."\n"; + $form .= ''; } } } @@ -1011,19 +1000,17 @@ function build_work_move_to_selector($folders, $curdirpath, $move_file, $group_d } } - $form .= ''."\n"; + $form .= ''; $form .= '
'; $form .= '
-
-
+
'; $form .= '
'; $form .= '
'; - return $form; } diff --git a/main/work/work.php b/main/work/work.php index 8960132c57..e536275a80 100755 --- a/main/work/work.php +++ b/main/work/work.php @@ -141,7 +141,7 @@ $id = isset($_REQUEST['id']) ? strval(intval($_REQUEST['id'])) : ''; // get data for publication assignment $has_expired = false; $has_ended = false; -$curdirpath = isset($_GET['curdirpath']) ? Database::escape_string($_GET['curdirpath']) : ''; +$curdirpath = isset($_REQUEST['curdirpath']) ? Database::escape_string($_REQUEST['curdirpath']) : ''; //This means that we are in a folder assignment $sql_select ='SELECT id, description FROM '.Database :: get_course_table(TABLE_STUDENT_PUBLICATION).' WHERE filetype = '."'folder'".' and has_properties != '."''".' and url = '."'/".$curdirpath."'".' LIMIT 1'; @@ -160,16 +160,17 @@ $cur_dir_path = ''; if (isset ($_GET['curdirpath']) && $_GET['curdirpath'] != '') { //$cur_dir_path = preg_replace('#[\.]+/#','',$_GET['curdirpath']); //escape '..' hack attempts //now using common security approach with security lib - $in_course = Security :: check_abs_path($base_work_dir . '/' . $_GET['curdirpath'], $base_work_dir); + $in_course = Security :: check_abs_path($base_work_dir . '/' . $_GET['curdirpath'], $base_work_dir); if (!$in_course) { $cur_dir_path = "/"; } else { $cur_dir_path = $_GET['curdirpath']; - } + } } elseif (isset ($_POST['curdirpath']) && $_POST['curdirpath'] != '') { //$cur_dir_path = preg_replace('#[\.]+/#','/',$_POST['curdirpath']); //escape '..' hack attempts //now using common security approach with security lib $in_course = Security :: check_abs_path($base_work_dir . '/' . $_POST['curdirpath'], $base_work_dir); + echo '2'; if (!$in_course) { $cur_dir_path = "/"; } else { @@ -264,11 +265,8 @@ if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') { $gradebook = ''; } -if (!empty($gradebook) && $gradebook == 'view') { - $interbreadcrumb[] = array ( - 'url' => '../gradebook/' . $_SESSION['gradebook_dest'], - 'name' => get_lang('ToolGradebook') - ); +if (!empty($gradebook) && $gradebook == 'view') { + $interbreadcrumb[] = array ('url' => '../gradebook/' . $_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); } if (!empty($_SESSION['toolgroup'])) { @@ -278,36 +276,22 @@ if (!empty($_SESSION['toolgroup'])) { $interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$_SESSION['toolgroup'], 'name' => get_lang('GroupSpace').' '.$group_properties['name']); $url_dir =''; - $interbreadcrumb[] = array ('url' => $url_dir,'name' => get_lang('StudentPublications')); + $interbreadcrumb[] = array ('url' =>'#','name' => get_lang('StudentPublications')); - //if (!$display_tool_options && !$display_upload_form) - //{ - // interbreadcrumb for the current directory root path - $dir_array = explode('/', $cur_dir_path); - $array_len = count($dir_array); - /* - if ($array_len > 0) { - $url_dir = 'work.php?&curdirpath=/'; - $interbreadcrumb[] = array ( - 'url' => $url_dir, - 'name' => get_lang('HomeDirectory')); - }*/ - $dir_acum = ''; - for ($i = 0; $i < $array_len; $i++) { - $url_dir = 'work.php?&curdirpath=' . $dir_acum . $dir_array[$i]; - $interbreadcrumb[] = array ( - 'url' => $url_dir, - 'name' => $dir_array[$i] - ); - $dir_acum .= $dir_array[$i] . '/'; - } - //} + $dir_array = explode('/', $cur_dir_path); + $array_len = count($dir_array); + + $dir_acum = ''; + for ($i = 0; $i < $array_len; $i++) { + $url_dir = 'work.php?&curdirpath=' . $dir_acum . $dir_array[$i]; + $interbreadcrumb[] = array ('url' => $url_dir,'name' => $dir_array[$i]); + $dir_acum .= $dir_array[$i] . '/'; + } + if ($display_upload_form) { - $interbreadcrumb[] = array ( - 'url' => 'work.php', - 'name' => get_lang('UploadADocument')); + $interbreadcrumb[] = array ('url' => 'work.php','name' => get_lang('UploadADocument')); } if ($display_tool_options) { @@ -317,58 +301,43 @@ if (!empty($_SESSION['toolgroup'])) { } if ($_GET['createdir'] == 1) { - $interbreadcrumb[] = array ( - 'url' => 'work.php', - 'name' => get_lang('CreateFolder')); + $interbreadcrumb[] = array ('url' => 'work.php','name' => get_lang('CreateFolder')); } - Display :: display_header(null); - -} else { - +} else { if (isset($origin) && $origin != 'learnpath') { $url_dir = ''; - $interbreadcrumb[] = array ('url' => $url_dir.'?gradebook='.$gradebook, 'name' => get_lang('StudentPublications')); - //if (!$display_tool_options && !$display_upload_form) - //{ - //------interbreadcrumb for the current directory root path + + if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '.' || $display_upload_form || $display_tool_options || $_GET['createdir'] == 1) { + $interbreadcrumb[] = array ('url' => 'work.php', 'name' => get_lang('StudentPublications')); + } else { + $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('StudentPublications')); + } + $dir_array = explode('/', $cur_dir_path); $array_len = count($dir_array); - /*if ($array_len > 0) { - $url_dir = 'work.php?gradebook='.$gradebook.'&curdirpath=/'; - $interbreadcrumb[] = array ( - 'url' => $url_dir, - 'name' => get_lang('HomeDirectory')); - }*/ - $dir_acum = ''; for ($i = 0; $i < $array_len; $i++) { $url_dir = 'work.php?gradebook='.$gradebook.'&curdirpath=' . $dir_acum . $dir_array[$i]; - $interbreadcrumb[] = array ( - 'url' => $url_dir, - 'name' => $dir_array[$i] - ); + if (isset($_REQUEST['curdirpath']) && $_REQUEST['curdirpath'] != '.' || $display_upload_form || $display_tool_options || $_GET['createdir'] == 1) { + $interbreadcrumb[] = array ('url' => $url_dir ,'name' => $dir_array[$i]); + } else { + $interbreadcrumb[] = array ('url' => '#','name' => $dir_array[$i]); + } $dir_acum .= $dir_array[$i] . '/'; } - // } - + if ($display_upload_form) { - $interbreadcrumb[] = array ( - 'url' => 'work.php?gradebook='.$gradebook, - 'name' => get_lang('UploadADocument')); + $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('UploadADocument')); } if ($display_tool_options) { - $interbreadcrumb[] = array ( - 'url' => 'work.php?gradebook='.$gradebook, - 'name' => get_lang('EditToolOptions')); + $interbreadcrumb[] = array ('url' => '#', 'name' => get_lang('EditToolOptions')); } if ($_GET['createdir'] == 1) { - $interbreadcrumb[] = array ( - 'url' => 'work.php?gradebook='.$gradebook, - 'name' => get_lang('CreateDir')); - } + $interbreadcrumb[] = array ('url' => '#','name' => get_lang('CreateDir')); + } Display :: display_header(null); @@ -716,11 +685,11 @@ if (isset ($_POST['move_to']) && isset ($_POST['move_file'])) { update_work_url($move_file_id, 'work' . $move_to_path, $move_to); //set the current path - $cur_dir_path = $move_to_path; - $cur_dir_path_url = urlencode($move_to_path); + //$cur_dir_path = $move_to_path; + //$cur_dir_path_url = urlencode($move_to_path); // update all the parents in the table item propery - $list_id = get_parent_directories($cur_dir_path); + $list_id = get_parent_directories($move_to_path); for ($i = 0; $i < count($list_id); $i++) { api_item_property_update($_course, 'work', $list_id[$i], 'FolderUpdated', $user_id); } @@ -1312,7 +1281,7 @@ if ($is_course_member) { $row = Database::fetch_array($result); $qualification_over = $row['qualification']; $form->addElement('text', 'qualification', get_lang('Qualification'), 'size="10"'); - $form->addElement('html', '
'.get_lang('QualificationNumeric').' : '.$qualification_over.'
'); + $form->addElement('html', '
'.get_lang('QualificationNumeric').' : '.$qualification_over.'
'); $form->addElement('hidden', 'qualification_over', $qualification_over); } @@ -1457,7 +1426,6 @@ if ($display_tool_options) { } /* Display list of student publications */ - if ($cur_dir_path == '/') { $my_cur_dir_path = ''; } else { @@ -1500,7 +1468,7 @@ if (!$display_upload_form && !$display_tool_options) { } } $cidreq = isset($_GET['cidreq']) ? Security::remove_XSS($_GET['cidreq']) : ''; - $curdirpath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : ''; + $curdirpath = isset($_REQUEST['curdirpath']) ? Security::remove_XSS($_REQUEST['curdirpath']) : ''; $filter = isset($_REQUEST['filter']) ? (int)$_REQUEST['filter'] : ''; if ($origin != 'learnpath') { @@ -1518,13 +1486,10 @@ if (!$display_upload_form && !$display_tool_options) { if ($display_list_users_without_publication) { display_list_users_without_publication($publication['id']); } else { - //var_dump($add_query); display_student_publications_list($base_work_dir . '/' . $my_cur_dir_path, 'work/' . $my_cur_dir_path, $currentCourseRepositoryWeb, $link_target_parameter, $dateFormatLong, $origin,$add_query); } } -/* Footer */ - if ($origin != 'learnpath') { //we are not in the learning path tool Display :: display_footer();