Browse Source

Fixing breadcrumb when creating a folder

Julio Montoya 14 years ago
parent
commit
059bd61fcb
2 changed files with 8 additions and 13 deletions
  1. 3 2
      main/document/document.inc.php
  2. 5 11
      main/document/document.php

+ 3 - 2
main/document/document.inc.php

@@ -701,10 +701,11 @@ function display_user_link_document($user_id, $name) {
  * Creates form that asks for the directory name.
  * @return string	html-output text for the form
  */
-function create_dir_form() {
+function create_dir_form($current_dir_id) {
     global $document_id;
     $new_folder_text = '<form action="'.api_get_self().'" method="post">';
-    $new_folder_text .= '<input type="hidden" name="dir_id" value="'.$document_id.'" />';
+    $new_folder_text .= '<input type="hidden" name="dir_id" value="'.intval($document_id).'" />';
+    $new_folder_text .= '<input type="hidden" name="id" value="'.intval($current_dir_id).'" />';
 
     // Form title
     $new_folder_text .= '<div class="row"><div class="form_header">'.get_lang('CreateDir').'</div></div>';

+ 5 - 11
main/document/document.php

@@ -87,22 +87,16 @@ $(document).ready( function() {
 });
 </script>';
 
-// Session
-/*
-if (isset($_GET['id_session'])) {
-    $_SESSION['id_session'] = intval($_GET['id_session']);
-}*/
 // Create directory certificates
 DocumentManager::create_directory_certificate_in_course(api_get_course_id());
 
 //Hack in order to use document.php?id=X 
-if (isset($_GET['id'])) {
-    $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id());
+if (isset($_REQUEST['id'])) {
+    $document_data = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id());
     //@todo replace all 
     $_GET['curdirpath'] = $document_data['path'];    
 }
 
-
 // What's the current path?
 // We will verify this a bit further down
 if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '') {
@@ -359,7 +353,7 @@ $image_files_only = '';
 if ($is_certificate_mode) {
     $interbreadcrumb[]= array('url' => '../gradebook/index.php', 'name' => get_lang('Gradebook'));
 } else {
-    if ((isset($_GET['id']) && $_GET['id'] != 0) || isset($_GET['curdirpath'])) {
+    if ((isset($_GET['id']) && $_GET['id'] != 0) || isset($_GET['curdirpath']) || isset($_GET['createdir'])) {
         $interbreadcrumb[]= array('url' => 'document.php', 'name' => get_lang('Documents'));
     } else {
         $interbreadcrumb[]= array('url' => '#', 'name' => get_lang('Documents'));
@@ -400,7 +394,7 @@ for ($i = 0; $i < $array_len; $i++) {
     //does not repeat the name group in the url
     if (!empty($_SESSION['_gid'])) {
         unset($dir_array[1]);
-        }
+    }
     $dir_acum .= $dir_array[$i].'/';
 }
 
@@ -673,7 +667,7 @@ if($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folde
 
     // Show them the form for the directory name
     if (isset($_GET['createdir'])) {
-        echo create_dir_form();
+        echo create_dir_form($document_id);
     }
 }