|
|
|
@ -222,9 +222,9 @@ function store_move($id, $target, $part) |
|
|
|
$dropbox_cnf = getDropboxConf(); |
|
|
|
$dropbox_cnf = getDropboxConf(); |
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
|
|
if ((isset($id) AND $id != '') AND |
|
|
|
if ((isset($id) && $id != '') && |
|
|
|
(isset($target) AND $target != '') AND |
|
|
|
(isset($target) && $target != '') && |
|
|
|
(isset($part) AND $part != '') |
|
|
|
(isset($part) && $part != '') |
|
|
|
) { |
|
|
|
) { |
|
|
|
|
|
|
|
|
|
|
|
if ($part == 'received') { |
|
|
|
if ($part == 'received') { |
|
|
|
@ -469,7 +469,7 @@ function display_addcategory_form($category_name = '', $id = '', $action) |
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
$title = get_lang('AddNewCategory'); |
|
|
|
$title = get_lang('AddNewCategory'); |
|
|
|
|
|
|
|
|
|
|
|
if (isset($id) AND $id != '') { |
|
|
|
if (isset($id) && $id != '') { |
|
|
|
// retrieve the category we are editing |
|
|
|
// retrieve the category we are editing |
|
|
|
$sql = "SELECT * FROM ".$dropbox_cnf['tbl_category']." |
|
|
|
$sql = "SELECT * FROM ".$dropbox_cnf['tbl_category']." |
|
|
|
WHERE c_id = $course_id AND cat_id = ".intval($id).""; |
|
|
|
WHERE c_id = $course_id AND cat_id = ".intval($id).""; |
|
|
|
@ -693,7 +693,53 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
$form->addButtonUpload(get_lang('Upload'), 'submitWork'); |
|
|
|
$form->addButtonUpload(get_lang('Upload'), 'submitWork'); |
|
|
|
$form->display(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$headers = array( |
|
|
|
|
|
|
|
get_lang('Upload'), |
|
|
|
|
|
|
|
get_lang('Upload').' ('.get_lang('Simple').')', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$multipleForm = new FormValidator( |
|
|
|
|
|
|
|
'sent_multiple', |
|
|
|
|
|
|
|
'post', |
|
|
|
|
|
|
|
'#', |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
array('enctype' => 'multipart/form-data', 'id' => 'fileupload') |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$multipleForm->addSelect( |
|
|
|
|
|
|
|
'recipients', |
|
|
|
|
|
|
|
get_lang('SendTo'), |
|
|
|
|
|
|
|
$options, |
|
|
|
|
|
|
|
array( |
|
|
|
|
|
|
|
'multiple' => 'multiple', |
|
|
|
|
|
|
|
'size' => '10', |
|
|
|
|
|
|
|
'id' => 'recipient_form' |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$multipleForm->addHtml(' |
|
|
|
|
|
|
|
<div id="multiple_form" style="display:none"> |
|
|
|
|
|
|
|
<div class="description-upload">'.get_lang('ClickToSelectOrDragAndDropMultipleFilesOnTheUploadField').'</div> |
|
|
|
|
|
|
|
<span class="btn btn-success fileinput-button"> |
|
|
|
|
|
|
|
<i class="glyphicon glyphicon-plus"></i> |
|
|
|
|
|
|
|
<span>'.get_lang('AddFiles').'</span> |
|
|
|
|
|
|
|
<!-- The file input field used as target for the file upload widget --> |
|
|
|
|
|
|
|
<input id="input_fileupload" type="file" name="files[]" multiple> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
<!-- The global progress bar --> |
|
|
|
|
|
|
|
<div id="progress" class="progress"> |
|
|
|
|
|
|
|
<div class="progress-bar progress-bar-success"></div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div id="files" class="files"></div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo Display::tabs($headers, array($multipleForm->returnForm(), $form->returnForm()), 'tabs'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -863,14 +909,20 @@ function dropbox_cnf($variable) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* @param array $file |
|
|
|
|
|
|
|
* |
|
|
|
* @return array|null|string |
|
|
|
* @return array|null|string |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function store_add_dropbox() |
|
|
|
function store_add_dropbox($file = []) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$_course = api_get_course_info(); |
|
|
|
$_course = api_get_course_info(); |
|
|
|
$_user = api_get_user_info(); |
|
|
|
$_user = api_get_user_info(); |
|
|
|
$dropbox_cnf = getDropboxConf(); |
|
|
|
$dropbox_cnf = getDropboxConf(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($file)) { |
|
|
|
|
|
|
|
$file = isset($_FILES['file']) ? $_FILES['file'] : null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Validating the form data |
|
|
|
// Validating the form data |
|
|
|
|
|
|
|
|
|
|
|
// there are no recipients selected |
|
|
|
// there are no recipients selected |
|
|
|
@ -886,28 +938,34 @@ function store_add_dropbox() |
|
|
|
} elseif ($rec == 'upload') { |
|
|
|
} elseif ($rec == 'upload') { |
|
|
|
$thisIsJustUpload = true; |
|
|
|
$thisIsJustUpload = true; |
|
|
|
} elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_')))) { |
|
|
|
} elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_')))) { |
|
|
|
return get_lang('InvalideUserDetected'); |
|
|
|
Display::addFlash(Display::return_message(get_lang('InvalideUserDetected'), 'warning')); |
|
|
|
|
|
|
|
return false; |
|
|
|
} elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) { |
|
|
|
} elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) { |
|
|
|
return get_lang('InvalideGroupDetected'); |
|
|
|
Display::addFlash(Display::return_message(get_lang('InvalideGroupDetected'), 'warning')); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// we are doing a mailing but an additional recipient is selected |
|
|
|
// we are doing a mailing but an additional recipient is selected |
|
|
|
if ($thisIsAMailing && (count($_POST['recipients']) != 1)) { |
|
|
|
if ($thisIsAMailing && (count($_POST['recipients']) != 1)) { |
|
|
|
return get_lang('MailingSelectNoOther'); |
|
|
|
Display::addFlash(Display::return_message(get_lang('MailingSelectNoOther'), 'warning')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// we are doing a just upload but an additional recipient is selected. |
|
|
|
// we are doing a just upload but an additional recipient is selected. |
|
|
|
// note: why can't this be valid? It is like sending a document to |
|
|
|
// note: why can't this be valid? It is like sending a document to |
|
|
|
// yourself AND to a different person (I do this quite often with my e-mails) |
|
|
|
// yourself AND to a different person (I do this quite often with my e-mails) |
|
|
|
if ($thisIsJustUpload && (count($_POST['recipients']) != 1)) { |
|
|
|
if ($thisIsJustUpload && (count($_POST['recipients']) != 1)) { |
|
|
|
return get_lang('MailingJustUploadSelectNoOther'); |
|
|
|
|
|
|
|
|
|
|
|
Display::addFlash(Display::return_message(get_lang('MailingJustUploadSelectNoOther'), 'warning')); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (empty($_FILES['file']['name'])) { |
|
|
|
if (empty($file['name'])) { |
|
|
|
$error = true; |
|
|
|
Display::addFlash(Display::return_message(get_lang('NoFileSpecified'), 'warning')); |
|
|
|
return get_lang('NoFileSpecified'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// are we overwriting a previous file or sending a new one |
|
|
|
// are we overwriting a previous file or sending a new one |
|
|
|
@ -919,23 +977,26 @@ function store_add_dropbox() |
|
|
|
|
|
|
|
|
|
|
|
// doing the upload |
|
|
|
// doing the upload |
|
|
|
|
|
|
|
|
|
|
|
$dropbox_filename = $_FILES['file']['name']; |
|
|
|
$dropbox_filename = $file['name']; |
|
|
|
$dropbox_filesize = $_FILES['file']['size']; |
|
|
|
$dropbox_filesize = $file['size']; |
|
|
|
$dropbox_filetype = $_FILES['file']['type']; |
|
|
|
$dropbox_filetype = $file['type']; |
|
|
|
$dropbox_filetmpname = $_FILES['file']['tmp_name']; |
|
|
|
$dropbox_filetmpname = $file['tmp_name']; |
|
|
|
|
|
|
|
|
|
|
|
// check if the filesize does not exceed the allowed size. |
|
|
|
// check if the filesize does not exceed the allowed size. |
|
|
|
if ($dropbox_filesize <= 0 || $dropbox_filesize > $dropbox_cnf['maxFilesize']) { |
|
|
|
if ($dropbox_filesize <= 0 || $dropbox_filesize > $dropbox_cnf['maxFilesize']) { |
|
|
|
return get_lang('DropboxFileTooBig'); |
|
|
|
Display::addFlash(Display::return_message(get_lang('DropboxFileTooBig'), 'warning')); |
|
|
|
// TODO: The "too big" message does not fit in the case of uploading zero-sized file. |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// check if the file is actually uploaded |
|
|
|
// check if the file is actually uploaded |
|
|
|
if (!is_uploaded_file($dropbox_filetmpname)) { // check user fraud : no clean error msg. |
|
|
|
if (!is_uploaded_file($dropbox_filetmpname)) { // check user fraud : no clean error msg. |
|
|
|
return get_lang('TheFileIsNotUploaded'); |
|
|
|
Display::addFlash(Display::return_message(get_lang('TheFileIsNotUploaded'), 'warning')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$upload_ok = process_uploaded_file($_FILES['file'], true); |
|
|
|
$upload_ok = process_uploaded_file($file, true); |
|
|
|
|
|
|
|
|
|
|
|
if (!$upload_ok) { |
|
|
|
if (!$upload_ok) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
@ -950,7 +1011,8 @@ function store_add_dropbox() |
|
|
|
|
|
|
|
|
|
|
|
//filter extension |
|
|
|
//filter extension |
|
|
|
if (!filter_extension($dropbox_filename)) { |
|
|
|
if (!filter_extension($dropbox_filename)) { |
|
|
|
return get_lang('UplUnableToSaveFileFilteredExtension'); |
|
|
|
Display::addFlash(Display::return_message(get_lang('UplUnableToSaveFileFilteredExtension'), 'warning')); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// set title |
|
|
|
// set title |
|
|
|
@ -973,10 +1035,13 @@ function store_add_dropbox() |
|
|
|
foreach ($dropbox_person->sentWork as $w) { |
|
|
|
foreach ($dropbox_person->sentWork as $w) { |
|
|
|
if ($w->title == $dropbox_filename) { |
|
|
|
if ($w->title == $dropbox_filename) { |
|
|
|
if (($w->recipients[0]['id'] > dropbox_cnf('mailingIdBase')) xor $thisIsAMailing) { |
|
|
|
if (($w->recipients[0]['id'] > dropbox_cnf('mailingIdBase')) xor $thisIsAMailing) { |
|
|
|
return get_lang('MailingNonMailingError'); |
|
|
|
Display::addFlash(Display::return_message(get_lang('MailingNonMailingError'), 'warning')); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (($w->recipients[0]['id'] == $_user['user_id']) xor $thisIsJustUpload) { |
|
|
|
if (($w->recipients[0]['id'] == $_user['user_id']) xor $thisIsJustUpload) { |
|
|
|
return get_lang('MailingJustUploadSelectNoOther'); |
|
|
|
|
|
|
|
|
|
|
|
Display::addFlash(Display::return_message(get_lang('MailingJustUploadSelectNoOther'), 'warning')); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
$dropbox_filename = $w->filename; |
|
|
|
$dropbox_filename = $w->filename; |
|
|
|
$found = true; // note: do we still need this? |
|
|
|
$found = true; // note: do we still need this? |
|
|
|
@ -1046,7 +1111,7 @@ function store_add_dropbox() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
new Dropbox_SentWork( |
|
|
|
$result = new Dropbox_SentWork( |
|
|
|
$_user['user_id'], |
|
|
|
$_user['user_id'], |
|
|
|
$dropbox_title, |
|
|
|
$dropbox_title, |
|
|
|
isset($_POST['description']) ? $_POST['description'] : '', |
|
|
|
isset($_POST['description']) ? $_POST['description'] : '', |
|
|
|
@ -1057,11 +1122,13 @@ function store_add_dropbox() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
Security::clear_token(); |
|
|
|
Security::clear_token(); |
|
|
|
return get_lang('FileUploadSucces'); |
|
|
|
Display::addFlash(Display::return_message(get_lang('FileUploadSucces'))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* this function transforms the array containing all the feedback into something visually attractive. |
|
|
|
* Transforms the array containing all the feedback into something visually attractive. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param an array containing all the feedback about the given message. |
|
|
|
* @param an array containing all the feedback about the given message. |
|
|
|
* |
|
|
|
* |
|
|
|
|