From 98aeb95b5384cd615996107d91e3b57ab1792971 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 15 Sep 2016 13:41:19 +0200 Subject: [PATCH] Allow same name in publications see BT#11678 --- main/inc/ajax/work.ajax.php | 3 +- .../lib/formvalidator/FormValidator.class.php | 53 ++++++++----------- main/work/work.lib.php | 40 +++++++++++--- 3 files changed, 56 insertions(+), 40 deletions(-) diff --git a/main/inc/ajax/work.ajax.php b/main/inc/ajax/work.ajax.php index 92a3577505..58faac0090 100755 --- a/main/inc/ajax/work.ajax.php +++ b/main/inc/ajax/work.ajax.php @@ -51,7 +51,8 @@ switch ($action) { $groupId, $userId, $file, - true + false, + false ); $json = array(); diff --git a/main/inc/lib/formvalidator/FormValidator.class.php b/main/inc/lib/formvalidator/FormValidator.class.php index 65dd4c94d2..1babc36890 100755 --- a/main/inc/lib/formvalidator/FormValidator.class.php +++ b/main/inc/lib/formvalidator/FormValidator.class.php @@ -1316,12 +1316,12 @@ EOT; */ private function addMultipleUploadJavascript($url, $inputName) { + $icon = Display::return_icon('file_txt.gif'); $this->addHtml(" " - ); + "); } } diff --git a/main/work/work.lib.php b/main/work/work.lib.php index d40234ac15..ba28079799 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -3333,7 +3333,12 @@ function uploadWork($my_folder_data, $_course, $isCorrection = false, $workInfo } if (empty($file['size'])) { - return array('error' => Display :: return_message(get_lang('UplUploadFailedSizeIsZero'), 'error')); + return array( + 'error' => Display:: return_message( + get_lang('UplUploadFailedSizeIsZero'), + 'error' + ), + ); } $updir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/work/'; //directory path to upload @@ -3535,11 +3540,21 @@ function checkExistingWorkFileName($filename, $workId) * @param int $userId * @param array $file * @param bool $checkDuplicated + * @param bool $showFlashMessage * * @return null|string */ -function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId, $userId, $file = [], $checkDuplicated = false) -{ +function processWorkForm( + $workInfo, + $values, + $courseInfo, + $sessionId, + $groupId, + $userId, + $file = [], + $checkDuplicated = false, + $showFlashMessage = true +) { $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); $courseId = $courseInfo['real_id']; @@ -3570,8 +3585,10 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId, } if (isset($result['error'])) { - $message = $result['error']; - Display::addFlash($message); + if ($showFlashMessage) { + $message = $result['error']; + Display::addFlash($message); + } $saveWork = false; } @@ -3654,10 +3671,19 @@ function processWorkForm($workInfo, $values, $courseInfo, $sessionId, $groupId, sendAlertToUsers($workId, $courseInfo, $sessionId); Event::event_upload($workId); $workData = get_work_data_by_id($workId); - Display::addFlash(Display::return_message(get_lang('DocAdd'))); + if ($showFlashMessage) { + Display::addFlash(Display::return_message(get_lang('DocAdd'))); + } } } else { - Display::addFlash(Display::return_message(get_lang('IsNotPosibleSaveTheDocument'), 'error')); + if ($showFlashMessage) { + Display::addFlash( + Display::return_message( + get_lang('IsNotPosibleSaveTheDocument'), + 'error' + ) + ); + } } return $workData;