Browse Source

fix messages and lang vars for copy files

Juan Carlos Raña 14 years ago
parent
commit
90a025900c

+ 8 - 6
main/document/document.inc.php

@@ -173,14 +173,16 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility
 		} else {
 			$force_download_html = ($size==0)?'':'<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon($forcedownload_icon, get_lang('Download'), array('height'=>'16', 'width' => '16')).'</a>';
 		}
-		//copy files to users myfiles
-		$copy_myfiles_link = ($filetype == 'file') ? api_get_self().'?'.api_get_cidreq().'&amp;action=copytomyfiles&amp;id='.$url_path.$req_gid :api_get_self().'?'.api_get_cidreq();
 		
-		if($filetype == 'file')
-		{		
-		$copy_to_myfiles='<a href="'.$copy_myfiles_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon('briefcase_small.png', get_lang('CopyToMyFiles'), array('height'=>'16', 'width' => '16')).'&nbsp;&nbsp;</a>';		
+		//copy files to users myfiles
+		if(api_get_setting('users_copy_files') == 'true'){
+			$copy_myfiles_link = ($filetype == 'file') ? api_get_self().'?'.api_get_cidreq().'&curdirpath='.$_GET['curdirpath'].'&amp;action=copytomyfiles&amp;id='.$url_path.$req_gid :api_get_self().'?'.api_get_cidreq();
+			
+			if($filetype == 'file')
+			{		
+			$copy_to_myfiles='<a href="'.$copy_myfiles_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon('briefcase_small.png', get_lang('CopyToMyFiles'), array('height'=>'16', 'width' => '16')).'&nbsp;&nbsp;</a>';		
+			}
 		}
-		
 		return '<a href="'.$url.'" title="'.$tooltip_title_alt.'" target="'.$target.'"'.$visibility_class.' style="float:left">'.$title.'</a>'.$force_download_html.$copy_to_myfiles;
 		//end copy files to users myfiles
 	} else {

+ 21 - 6
main/document/document.php

@@ -318,7 +318,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'downloadfolder' && (api_get_se
 }
 
 // Copy a file to general my files user's
-if (isset($_GET['action']) && $_GET['action'] == 'copytomyfiles' && (api_get_setting('students_copy_files') == 'true')) {	
+if (isset($_GET['action']) && $_GET['action'] == 'copytomyfiles' && api_get_setting('users_copy_files') == 'true') {	
 	
 	$clean_get_id = Security::remove_XSS($_GET['id']);
 	$user_folder  = api_get_path(SYS_CODE_PATH).'upload/users/'.api_get_user_id().'/my_files/';
@@ -327,13 +327,15 @@ if (isset($_GET['action']) && $_GET['action'] == 'copytomyfiles' && (api_get_set
 		}
 
 		$file = $sys_course_path.$_course['path'].'/document'.$clean_get_id;
-		$copyfile = $user_folder.basename($clean_get_id);
+		$copyfile = $user_folder.basename($clean_get_id);		
 		if (file_exists($copyfile)) {
-			//Display::display_error_message(get_lang('Overwrite. Warning already copy'));//TODO: fix message and show acept or cancel
-		}
-		if (!copy($file, $copyfile)) {
-			//Display::display_error_message(get_lang('Copy Failled'));//TODO: fix message
+			$copy_to_myfiles_message_overwrite  = 	get_lang('AlreadyCopy');			
+		}elseif (!copy($file, $copyfile)) {
+			$copy_to_myfiles_message_failled	=	get_lang('CopyFailled');			
+		}else{	
+			$copy_to_myfiles_message_relased	=	get_lang('CopyReleased');
 		}
+
 }
 
 
@@ -401,6 +403,19 @@ if (!empty($_SESSION['_gid'])) {
 	Display::display_introduction_section(TOOL_DOCUMENT);
 }
 
+/*	COPY TO MY FILES MESSAGES */
+if(!empty($copy_to_myfiles_message_failled)){
+	Display::display_error_message($copy_to_myfiles_message_failled);
+}
+else{
+	if(!empty($copy_to_myfiles_message_overwrite)){
+		Display::display_warning_message($copy_to_myfiles_message_overwrite);
+	}
+	if (!empty($copy_to_myfiles_message_relased)){
+		Display::display_confirmation_message($copy_to_myfiles_message_relased);
+	}
+}
+
 if ($is_allowed_to_edit || $group_member_with_upload_rights) { // TEACHER ONLY
 
 	/*	MOVE FILE OR DIRECTORY */

+ 3 - 3
main/install/db_main.sql

@@ -753,7 +753,7 @@ VALUES
 ('block_copy_paste_for_students',NULL,'radio','Editor','false','BlockCopyPasteForStudentsTitle','BlockCopyPasteForStudentsComment',NULL,NULL, 0),
 ('more_buttons_maximized_mode',NULL,'radio','Editor','false','MoreButtonsForMaximizedModeTitle','MoreButtonsForMaximizedModeComment',NULL,NULL, 0),
 ('students_download_folders',NULL,'radio','Tools','true','AllowStudentsDownloadFoldersTitle','AllowStudentsDownloadFoldersComment',NULL,NULL, 0),
-('students_copy_files',NULL,'radio','Tools','true','AllowStudentsCopyFilesTitle','AllowStudentsCopyFilesComment',NULL,NULL, 0),
+('users_copy_files',NULL,'radio','Tools','true','AllowUsersCopyFilesTitle','AllowUsersCopyFilesComment',NULL,NULL, 0),
 ('show_tabs', 'social', 'checkbox', 'Platform', 'true', 'ShowTabsTitle','ShowTabsComment',NULL,'TabsSocial', 0),
 ('allow_students_to_create_groups_in_social',NULL,'radio','Tools','false','AllowStudentsToCreateGroupsInSocialTitle','AllowStudentsToCreateGroupsInSocialComment',NULL,NULL, 0),
 ('allow_send_message_to_all_platform_users',NULL,'radio','Tools','false','AllowSendMessageToAllPlatformUsersTitle','AllowSendMessageToAllPlatformUsersComment',NULL,NULL, 0),
@@ -968,8 +968,8 @@ VALUES
 ('more_buttons_maximized_mode','false','No'),
 ('students_download_folders','true','Yes'),
 ('students_download_folders','false','No'),
-('students_copy_files','true','Yes'),
-('students_copy_files','false','No'),
+('users_copy_files','true','Yes'),
+('users_copy_files','false','No'),
 ('allow_students_to_create_groups_in_social','true','Yes'),
 ('allow_students_to_create_groups_in_social','false','No'),
 ('allow_send_message_to_all_platform_users','true','Yes'),

+ 2 - 2
main/lang/english/admin.inc.php

@@ -1269,6 +1269,6 @@ $ErrorReadingZip = "Error reading ZIP file";
 $ErrorStylesheetFilesExtensionsInsideZip = "The only accepted extensions in the ZIP file are jpg, jpeg, png, gif and css.";
 $MyTextHere = "Enter your text here...";
 $FieldTypeSocialProfile = "Social network link";
-$AllowStudentsCopyFilesTitle = "Allow students to copy files from a course in your area personal file";
-$AllowStudentsCopyFilesComment = "Allows students to copy files from a course in your personal area, visible through the Social Network or through the html editor when they are out of a course";
+$AllowUsersCopyFilesTitle = "Allow users to copy files from a course in your area personal file";
+$AllowUsersCopyFilesComment = "Allows users to copy files from a course in your personal area, visible through the Social Network or through the html editor when they are out of a course";
 ?>

+ 2 - 2
main/lang/spanish/admin.inc.php

@@ -1269,6 +1269,6 @@ $ErrorReadingZip = "Error leyendo el archivo ZIP";
 $ErrorStylesheetFilesExtensionsInsideZip = "Las únicas extensiones aceptadas en el archivo ZIP son jpg, jpeg, png, gif y css.";
 $MyTextHere = "Introduzca su texto aquí...";
 $FieldTypeSocialProfile = "Vínculo red social";
-$AllowStudentsCopyFilesTitle = "Permitir a los estudiantes copiar archivos de un curso en su área de archivos personales";
-$AllowStudentsCopyFilesComment = "Permite a los estudiantes copiar archivos de un curso en su área personal, visible a través de la herramienta de Red Social o mediante el editor de HTML cuando se encuentran fuera de un curso";
+$AllowUsersCopyFilesTitle = "Permitir a los usuarios copiar archivos de un curso en su área de archivos personales";
+$AllowUsersCopyFilesComment = "Permite a los usuarios copiar archivos de un curso en su área personal, visible a través de la herramienta de Red Social o mediante el editor de HTML cuando se encuentran fuera de un curso";
 ?>