From f25d2c704bf74e6ceb3b3e07ee3aa675e883f02a Mon Sep 17 00:00:00 2001 From: Cristian Fasanando Date: Thu, 14 Jan 2010 10:45:14 -0500 Subject: [PATCH 1/2] fixed - copy course documents with visibility - CT#392 --- .../classes/CourseRestorer.class.php | 27 ++++++++++++++----- main/inc/lib/fileUpload.lib.php | 11 +++++--- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index b49c4f41f1..5ffd8dfc69 100755 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -197,18 +197,30 @@ class CourseRestorer $perm = api_get_setting('permissions_for_new_directories'); $perm = octdec(!empty($perm)?$perm:0770); $dirs = explode('/', dirname($document->path)); - if (count($dirs)==1) { - if ($this->file_type==FOLDER) { - $new = substr($document->path, 8); - $created_dir = create_unexisting_directory($destination_course,api_get_user_id(),0, 0 ,$path.'document',$new,basename($new)); - } - } else { + + //if (count($dirs)==1) { + + if ($document->file_type==FOLDER) { + $visibility = $document->item_properties[0]['visibility']; + $new = substr($document->path, 8); + if (!is_dir($path.'document/'.$new)) { + $sql = "SELECT id FROM ".$table." WHERE path='/".Database::escape_string($new)."'"; + $res = Database::query($sql, __FILE__, __LINE__); + $num_result = Database::num_rows($res); + if ($num_result==0) { + $created_dir = create_unexisting_directory($destination_course,api_get_user_id(),0, 0 ,$path.'document',$new,basename($new),$visibility); + } + } + } + + //} + /* + else { $my_temp = ''; for ($i=1; $i<=count($dirs); $i++) { $my_temp .= $dirs[$i]; if (!is_dir($path.'document/'.$my_temp)) { $sql = "SELECT id FROM ".$table." WHERE path='/".Database::escape_string($my_temp)."'"; - //echo '
'; $res = Database::query($sql, __FILE__, __LINE__); $num_result = Database::num_rows($res); if ($num_result==0) { @@ -218,6 +230,7 @@ class CourseRestorer $my_temp .= '/'; } } + */ /* echo '
'; echo '------------------------'; diff --git a/main/inc/lib/fileUpload.lib.php b/main/inc/lib/fileUpload.lib.php index 446392be11..2440fe0492 100755 --- a/main/inc/lib/fileUpload.lib.php +++ b/main/inc/lib/fileUpload.lib.php @@ -1380,7 +1380,7 @@ function search_img_from_html($htmlFile) * boolean false otherwise */ -function create_unexisting_directory($_course,$user_id,$to_group_id,$to_user_id,$base_work_dir,$desired_dir_name, $title = null) +function create_unexisting_directory($_course,$user_id,$to_group_id,$to_user_id,$base_work_dir,$desired_dir_name, $title = null, $visibility = '') { $nb = ''; while ( file_exists($base_work_dir.$desired_dir_name.$nb) ) @@ -1400,8 +1400,13 @@ function create_unexisting_directory($_course,$user_id,$to_group_id,$to_user_id, if ($document_id) { //update document item_property - $current_session_id = api_get_session_id(); - api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'FolderCreated',$user_id,$to_group_id,$to_user_id,null,null,$current_session_id); + $current_session_id = api_get_session_id(); + if ($visibility !== '') { + $visibilities = array(0 => 'invisible', 1 => 'visible', 2 => 'delete'); + api_item_property_update($_course,TOOL_DOCUMENT,$document_id,$visibilities[$visibility],$user_id,$to_group_id,$to_user_id,null,null,$current_session_id); + } else { + api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'FolderCreated',$user_id,$to_group_id,$to_user_id,null,null,$current_session_id); + } return $desired_dir_name.$nb; } } From 21649d704ad35a50f9598eb076e74950a265a98b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 14 Jan 2010 10:57:08 -0500 Subject: [PATCH 2/2] Fixing bug when trying to move up or down glossary terms --- main/glossary/index.php | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/main/glossary/index.php b/main/glossary/index.php index dce52a140b..cd0b32342c 100755 --- a/main/glossary/index.php +++ b/main/glossary/index.php @@ -41,8 +41,8 @@ event_access_tool(TOOL_GLOSSARY); // displaying the header if (isset($_GET['action']) && ($_GET['action'] == 'addglossary' || $_GET['action'] == 'edit_glossary')) { -$tool='GlossaryManagement'; -$interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('Glossary')); + $tool='GlossaryManagement'; + $interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('Glossary')); } Display::display_header(get_lang(ucfirst($tool))); @@ -140,6 +140,23 @@ if (api_is_allowed_to_edit(null,true)) { // footer Display::display_footer(); + +/** + +@todo lots of cleaning + +1. All the functions below should be move to glossary.class.php +2. glossary.class.php should be renamed to glossary.lib.php and moved to inc/lib +3. glossary_ajax_request.php file should be deleted. The content of that file should be move to inc/ajax/glossary.ajax.php +4. We should call all functions like Glossary::display_something(); + +http://support.chamilo.org/issues/510 + +Julio Montoya + + +*/ + /** * This functions stores the glossary in the database * @@ -487,15 +504,14 @@ function get_glossary_data($from, $number_of_items, $column, $direction) */ function actions_filter($glossary_id,$url_params,$row) { - if (!$_SESSION['max_glossary_display'] OR $_SESSION['max_glossary_display'] == '') - { + if (!$_SESSION['max_glossary_display'] OR $_SESSION['max_glossary_display'] == '') { $_SESSION['max_glossary_display'] = get_max_glossary_item(); } if (empty($_GET['glossary_column'])) { - if ($row[0] > 1) - { - $return .= ''.Display::return_icon('up.gif', get_lang('Up')).''; + if ($row[0] > 1) { + + $return .= ''.Display::return_icon('up.gif', get_lang('Up')).''; } else { @@ -504,7 +520,7 @@ function actions_filter($glossary_id,$url_params,$row) } if ($row[0] < $_SESSION['max_glossary_display']) { - $return .= ''.Display::return_icon('down.gif',get_lang('Down')).''; + $return .= ''.Display::return_icon('down.gif',get_lang('Down')).''; } else { @@ -512,12 +528,12 @@ function actions_filter($glossary_id,$url_params,$row) } } - $return .= ''.Display::return_icon('edit.gif',get_lang('Edit')).''; + $return .= ''.Display::return_icon('edit.gif',get_lang('Edit')).''; $glossary_data = get_glossary_information($row[5]); $glossary_term = $glossary_data['glossary_title']; - $return .= ''.Display::return_icon('delete.gif', get_lang('Delete')).''; + $return .= ''.Display::return_icon('delete.gif', get_lang('Delete')).''; return $return; } @@ -589,7 +605,7 @@ function move_glossary($direction, $glossary_id) $sortorder = 'ASC'; } - $sql = "SELECT * FROM $t_glossary ORDER BY display_order $sortorder"; + echo $sql = "SELECT * FROM $t_glossary ORDER BY display_order $sortorder"; $res = Database::query($sql, __FILE__, __LINE__); while ($row = Database::fetch_array($res)) {