Allow same name in publications see BT#11678

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent 064c993458
commit 98aeb95b53
  1. 3
      main/inc/ajax/work.ajax.php
  2. 53
      main/inc/lib/formvalidator/FormValidator.class.php
  3. 40
      main/work/work.lib.php

@ -51,7 +51,8 @@ switch ($action) {
$groupId,
$userId,
$file,
true
false,
false
);
$json = array();

@ -1316,12 +1316,12 @@ EOT;
*/
private function addMultipleUploadJavascript($url, $inputName)
{
$icon = Display::return_icon('file_txt.gif');
$this->addHtml("
<script>
$(function () {
'use strict';
$('#".$this->getAttribute('id')."').submit(function(){
$('#".$this->getAttribute('id')."').submit(function() {
return false;
});
@ -1363,33 +1363,25 @@ EOT;
previewCrop: true,
dropzone: $('#dropzone')
}).on('fileuploadadd', function (e, data) {
data.context = $('<div/>').appendTo('#files');
data.context = $('<div class=\"row\" style=\"margin-bottom:35px\" />').appendTo('#files');
$.each(data.files, function (index, file) {
var node = $('<p/>').append($('<span/>').text(file.name));
/*if (!index) {
node
.append('<br>')
.append(uploadButton.clone(true).data(data));
}*/
var node = $('<div class=\"col-sm-5\">').text(file.name);
node.appendTo(data.context);
}
);
}).on('fileuploadprocessalways', function (e, data) {
var index = data.index,
file = data.files[index],
node = $(data.context.children()[index]);
if (file.preview) {
node
.prepend('<br>')
.prepend(file.preview);
node
.append('<br>')
.append($('<span class=\"text-success\"/>').text('" . addslashes(get_lang('UplUploadSucceeded')) . "'));
}
if (file.error) {
node
.append('<br>')
.append($('<span class=\"text-danger\"/>').text(file.error));
data.context
.prepend($('<div class=\"col-sm-2\">').html(file.preview))
;
} else {
data.context
.prepend($('<div class=\"col-sm-2\">').html('".$icon."'))
;
}
if (index + 1 === data.files.length) {
data.context.find('button')
@ -1408,22 +1400,20 @@ EOT;
var link = $('<a>')
.attr('target', '_blank')
.prop('href', file.url);
$(data.context.children()[index]).wrap(link);
$(data.context.children()[index]).parent().wrap(link);
var successMessage = $('<div class=\"col-sm-3\">').html($('<span class=\"alert alert-success\"/>').text('" . addslashes(get_lang('UplUploadSucceeded')) . "'));
$(data.context.children()[index]).parent().append(successMessage);
} else if (file.error) {
var error = $('<span class=\"text-danger\"/>').text(file.error);
$(data.context.children()[index])
.append('<br>')
.append(error);
var error = $('<div class=\"col-sm-3\">').html($('<span class=\"alert alert-danger\"/>').text(file.error));
$(data.context.children()[index]).parent().append(error);
}
});
}).on('fileuploadfail', function (e, data) {
$.each(data.files, function (index) {
var failedMessage = '" . addslashes(get_lang('UplUploadFailed')) . "';
var error = $('<span class=\"text-danger\"/>').text(failedMessage);
$(data.context.children()[index])
.append('<br>')
.append(error);
var error = $('<div class=\"col-sm-3\">').html($('<span class=\"alert alert-danger\"/>').text(failedMessage));
$(data.context.children()[index]).parent().append(error);
});
}).prop('disabled', !$.support.fileInput)
.parent().addClass($.support.fileInput ? undefined : 'disabled');
@ -1431,8 +1421,7 @@ EOT;
$('.fileinput-button').hide();
});
</script>"
);
</script>");
}
}

@ -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;

Loading…
Cancel
Save