From 357e9f4200c72b4e0499fefc5c5e3aa561d36187 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 16 Oct 2012 14:10:50 +0200 Subject: [PATCH] Hiding edit/move/delete buttons for "system folders" see #5649 --- main/document/document.inc.php | 51 +++++++++++++++++++++------------- main/document/document.php | 20 ------------- main/inc/lib/document.lib.php | 16 +++++++++-- 3 files changed, 45 insertions(+), 42 deletions(-) diff --git a/main/document/document.inc.php b/main/document/document.inc.php index d101d4898b..aa4fa1d301 100644 --- a/main/document/document.inc.php +++ b/main/document/document.inc.php @@ -255,9 +255,9 @@ function create_document_link($document_data, $show_as_icon = false, $counter = preg_match('/ogg$/i', urldecode($url))) { return '' . $title . '' . $force_download_html . $send_to . $copy_to_myfiles . $open_in_new_window_link . $pdf_icon; } elseif ( - //Show preview sith yoxview - //preg_match('/html$/i', urldecode($url)) || - //preg_match('/htm$/i', urldecode($url)) || + //Show preview sith yoxview + //preg_match('/html$/i', urldecode($url)) || + //preg_match('/htm$/i', urldecode($url)) || preg_match('/swf$/i', urldecode($url)) || preg_match('/png$/i', urldecode($url)) || preg_match('/gif$/i', urldecode($url)) || @@ -296,17 +296,17 @@ function create_document_link($document_data, $show_as_icon = false, $counter = $sound_preview = DocumentManager::generate_media_preview($counter); return $sound_preview; } elseif ( - //Show preview sith yoxview - //preg_match('/html$/i', urldecode($url)) || - //preg_match('/htm$/i', urldecode($url)) || - preg_match('/swf$/i', urldecode($url)) || - preg_match('/png$/i', urldecode($url)) || - preg_match('/gif$/i', urldecode($url)) || - preg_match('/jpg$/i', urldecode($url)) || - preg_match('/jpeg$/i', urldecode($url)) || - preg_match('/bmp$/i', urldecode($url)) || - preg_match('/svg$/i', urldecode($url)) || - (preg_match('/wav$/i', urldecode($url)) && preg_match('/_chnano_.wav$/i', urldecode($url)) && api_get_setting('enable_nanogong') == 'true') + //Show preview sith yoxview + //preg_match('/html$/i', urldecode($url)) || + //preg_match('/htm$/i', urldecode($url)) || + preg_match('/swf$/i', urldecode($url)) || + preg_match('/png$/i', urldecode($url)) || + preg_match('/gif$/i', urldecode($url)) || + preg_match('/jpg$/i', urldecode($url)) || + preg_match('/jpeg$/i', urldecode($url)) || + preg_match('/bmp$/i', urldecode($url)) || + preg_match('/svg$/i', urldecode($url)) || + (preg_match('/wav$/i', urldecode($url)) && preg_match('/_chnano_.wav$/i', urldecode($url)) && api_get_setting('enable_nanogong') == 'true') ) { //$url = 'showinframesmin.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;//with yoxview $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id'] . $req_gid; //without yoxview @@ -526,7 +526,10 @@ function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0, } $modify_icons .= ' ' . Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL); } else { - if ($is_certificate_mode) { + //Edit button + if (in_array($path, DocumentManager::get_system_folders())) { + $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); + } elseif ($is_certificate_mode ) { // gradebook category doesn't seem to be taken into account $modify_icons = '' . Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . ''; } else { @@ -552,10 +555,10 @@ function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0, } } } - if ($is_certificate_mode) { - $modify_icons .= ' ' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . ''; - $modify_icons .= ' ' . Display::return_icon($visibility_icon . '.png', get_lang('VisibilityCannotBeChanged'), array(), ICON_SIZE_SMALL) . ''; - Display::return_icon($visibility_icon . '.png', get_lang('VisibilityCannotBeChanged'), array(), ICON_SIZE_SMALL) . ''; + + //Move button + if ($is_certificate_mode || in_array($path, DocumentManager::get_system_folders())) { + $modify_icons .= ' ' . Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . ''; } else { if (api_get_session_id()) { if ($document_data['session_id'] == api_get_session_id()) { @@ -566,6 +569,12 @@ function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0, } else { $modify_icons .= ' ' . Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . ''; } + } + + //Visibility button + if ($is_certificate_mode) { + $modify_icons .= ' ' . Display::return_icon($visibility_icon . '.png', get_lang('VisibilityCannotBeChanged'), array(), ICON_SIZE_SMALL) . ''; + } else { if (api_is_allowed_to_edit() || api_is_platform_admin()) { if ($visibility_icon == 'invisible') { $tip_visibility = get_lang('Show'); @@ -575,7 +584,9 @@ function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0, $modify_icons .= ' ' . Display::return_icon($visibility_icon . '.png', $tip_visibility, '', ICON_SIZE_SMALL) . ''; } } - if (in_array($path, array('/audio', '/flash', '/images', '/shared_folder', '/video', '/chat_files', '/certificates'))) { + + //Delete button + if (in_array($path, DocumentManager::get_system_folders())) { $modify_icons .= ' ' . Display::return_icon('delete_na.png', get_lang('ThisFolderCannotBeDeleted'), array(), ICON_SIZE_SMALL); } else { if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && DocumentManager::get_default_certificate_id(api_get_course_id()) == $id) { diff --git a/main/document/document.php b/main/document/document.php index 7f2f6c211a..6702eaabc0 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -1059,26 +1059,6 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) { if (DocumentManager::is_folder_to_avoid($document_data['path'])) { continue; } -/* - // Hide HotPotatoes Certificates and all css folders - if ($document_data['path'] == '/HotPotatoes_files' || $document_data['path'] == '/certificates' || basename($document_data['path']) == 'css') { - continue; - } - - //Admin setting for Hide/Show the folders of all users - if (api_get_setting('show_users_folders') == 'false' && ($document_data['path'] == '/shared_folder' || strstr($document_data['path'], 'shared_folder_session_'))) { - continue; - } - - //Admin setting for Hide/Show Default folders to all users - if (api_get_setting('show_default_folders') == 'false' && ($document_data['path'] == '/images' || $document_data['path'] == '/flash' || $document_data['path'] == '/audio' || $document_data['path'] == '/video')) { - continue; - } - - //Admin setting for Hide/Show chat history folder - if (api_get_setting('show_chat_folder') == 'false' && $document_data['path'] == '/chat_files') { - continue; - }*/ // Show the owner of the file only in groups $user_link = ''; diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 3e33ed3ac8..8a7b86cb69 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -3175,8 +3175,20 @@ class DocumentManager { if (api_get_setting('show_chat_folder') == 'false') { $folders_to_avoid[] = '/chat_files'; } - return in_array($path, $folders_to_avoid); - + return in_array($path, $folders_to_avoid); + } + + static function get_system_folders() { + $system_folders = array( + '/certificates', + '/chat_files', + '/images', + '/flash', + '/audio', + '/video', + '/shared_folder' + ); + return $system_folders; } } //end class DocumentManager