Add update dropbox file see BT#10896

pull/2487/head
jmontoyaa 9 years ago
parent 739289a123
commit 8480b72c80
  1. 75
      main/dropbox/dropbox_class.inc.php
  2. 281
      main/dropbox/dropbox_functions.inc.php
  3. 38
      main/dropbox/index.php
  4. 15
      main/dropbox/update.php
  5. 15
      main/inc/ajax/dropbox.ajax.php
  6. 23
      main/inc/lib/formvalidator/FormValidator.class.php

@ -7,32 +7,32 @@
*
* 3 classes have been defined:
* - Dropbox_Work:
* . id
* . uploader_id => who sent it
* . filename => name of file stored on the server
* . filesize
* . title => name of file returned to user. This is the original name of the file
* except when the original name contained spaces. In that case the spaces
* will be replaced by _
* . description
* . author
* . upload_date => date when file was first sent
* . last_upload_date => date when file was last sent
* . isOldWork => has the work already been uploaded before
* . id
* . uploader_id => who sent it
* . filename => name of file stored on the server
* . filesize
* . title => name of file returned to user. This is the original name of the file
* except when the original name contained spaces. In that case the spaces
* will be replaced by _
* . description
* . author
* . upload_date => date when file was first sent
* . last_upload_date => date when file was last sent
* . isOldWork => has the work already been uploaded before
*
* . feedback_date => date of most recent feedback
* . feedback => feedback text (or HTML?)
*
* - Dropbox_SentWork extends Dropbox_Work
* . recipients => array of ["id"]["name"] lists the recipients of the work
* . recipients => array of ["id"]["name"] lists the recipients of the work
*
* - Dropbox_Person:
* . userId
* . receivedWork => array of Dropbox_Work objects
* . sentWork => array of Dropbox_SentWork objects
* . isCourseTutor
* . isCourseAdmin
* . _orderBy => private property used for determining the field by which the works have to be ordered
* . userId
* . receivedWork => array of Dropbox_Work objects
* . sentWork => array of Dropbox_SentWork objects
* . isCourseTutor
* . isCourseAdmin
* . _orderBy => private property used for determining the field by which the works have to be ordered
*
* @version 1.30
* @copyright 2004
@ -223,6 +223,36 @@ class Dropbox_Work
$this->feedback2 = $feedback2;
}
}
/**
* @return bool
*/
public function updateFile()
{
$course_id = api_get_course_int_id();
if (empty($this->id) || empty($course_id)) {
return false;
}
$params = [
'uploader_id' => $this->uploader_id,
'filename' => $this->filename,
'filesize' => $this->filesize,
'title' => $this->title,
'description' => $this->description,
'author' => $this->author,
'upload_date' => $this->upload_date,
'last_upload_date' => $this->last_upload_date,
'session_id' => api_get_session_id()
];
Database::update(
Database::get_course_table(TABLE_DROPBOX_FILE),
$params,
['c_id = ? AND id = ?' => [$course_id, $this->id]]
);
return true;
}
}
class Dropbox_SentWork extends Dropbox_Work
@ -264,7 +294,6 @@ class Dropbox_SentWork extends Dropbox_Work
*/
public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
{
$dropbox_cnf = getDropboxConf();
$_course = api_get_course_info();
// Call constructor of Dropbox_Work object
@ -357,12 +386,11 @@ class Dropbox_SentWork extends Dropbox_Work
/**
* private function creating existing object by retreiving info from db
*
* @param unknown_type $id
* @param int $id
*/
public function _createExistingSentWork($id)
{
$id = intval($id);
$course_id = api_get_course_int_id();
// Call constructor of Dropbox_Work object
@ -378,7 +406,6 @@ class Dropbox_SentWork extends Dropbox_Work
// Check for deleted users
$dest_user_id = $res['dest_user_id'];
$user_info = api_get_user_info($dest_user_id);
//$this->category = $res['cat_id'];
if (!$user_info) {
$this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
} else {
@ -551,7 +578,7 @@ class Dropbox_Person
/**
* Deletes a sent dropbox file of this person with id=$id
*
* @param unknown_type $id
* @param int $id
*/
public function deleteSentWork($id)
{

@ -184,8 +184,15 @@ function delete_category($action, $id, $user_id = null)
*@ return html code of the form that appears in a message box.
* @author Julio Montoya - function rewritten
*/
function display_move_form($part, $id, $target = array(), $extra_params = array(), $viewReceivedCategory, $viewSentCategory, $view)
{
function display_move_form(
$part,
$id,
$target = array(),
$extra_params = array(),
$viewReceivedCategory,
$viewSentCategory,
$view
) {
$form = new FormValidator(
'form1',
'post',
@ -200,7 +207,7 @@ function display_move_form($part, $id, $target = array(), $extra_params = array(
$options[$category['cat_id']] = $category['cat_name'];
}
$form->addElement('select', 'move_target', get_lang('MoveFileTo'), $options);
$form->addElement('button', 'do_move', get_lang('MoveFile'));
$form->addButtonMove(get_lang('MoveFile'), 'do_move');
$form->display();
}
@ -225,7 +232,6 @@ function store_move($id, $target, $part)
(isset($target) && $target != '') &&
(isset($part) && $part != '')
) {
if ($part == 'received') {
$sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_POST)."
SET cat_id = ".intval($target)."
@ -470,12 +476,17 @@ function display_addcategory_form($category_name = '', $id = '', $action)
}
/**
* this function displays the form to upload a new item to the dropbox.
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006
*/
function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view)
* this function displays the form to upload a new item to the dropbox.
*
* @param $viewReceivedCategory
* @param $viewSentCategory
* @param $view
* @param int $id
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Julio Montoya
* @version march 2006
*/
function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = 0)
{
$course_info = api_get_course_info();
$_user = api_get_user_info();
@ -490,18 +501,23 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
$is_courseTutor
);
$idCondition = !empty($id) ? '&id='.(int) $id : '';
$url = api_get_self().'?view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&'.api_get_cidreq().$idCondition;
$form = new FormValidator(
'sent_form',
'post',
api_get_self().'?view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&'.api_get_cidreq(),
$url,
null,
array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);')
array(
'enctype' => 'multipart/form-data',
'onsubmit' => 'javascript: return checkForm(this);',
)
);
$form->addElement('header', get_lang('UploadNewFile'));
$maxFileSize = api_get_setting('dropbox_max_filesize');
$form->addElement('hidden', 'MAX_FILE_SIZE', $maxFileSize);
$form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'origin', $origin);
$form->addElement(
@ -513,7 +529,13 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
$allowOverwrite = api_get_setting('dropbox_allow_overwrite');
if ($allowOverwrite == 'true') {
$form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
$form->addElement(
'checkbox',
'cb_overwrite',
null,
get_lang('OverwriteFile'),
array('id' => 'cb_overwrite')
);
}
// List of all users in this course and all virtual courses combined with it
@ -575,7 +597,12 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
if (!empty($complete_user_list_for_dropbox)) {
foreach ($complete_user_list_for_dropbox as $k => $e) {
$complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname']));
$complete_user_list_for_dropbox[$k] = $e + array(
'lastcommafirst' => api_get_person_name(
$e['firstname'],
$e['lastname']
),
);
}
$complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
}
@ -584,7 +611,6 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
Create the options inside the select box:
List all selected users their user id as value and a name string as display
*/
$current_user_id = '';
$allowStudentToStudent = api_get_setting('dropbox_allow_student_to_student');
$options = array();
@ -639,15 +665,17 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
$options['user_'.$_user['user_id']] = get_lang('JustUploadInSelect');
}
$form->addSelect(
'recipients',
get_lang('SendTo'),
$options,
array(
'multiple' => 'multiple',
'size' => '10'
)
);
if (empty($idCondition)) {
$form->addSelect(
'recipients',
get_lang('SendTo'),
$options,
array(
'multiple' => 'multiple',
'size' => '10'
)
);
}
$form->addButtonUpload(get_lang('Upload'), 'submitWork');
$headers = array(
@ -663,21 +691,27 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
array('enctype' => 'multipart/form-data', 'id' => 'fileupload')
);
$multipleForm->addSelect(
'recipients',
get_lang('SendTo'),
$options,
array(
'multiple' => 'multiple',
'size' => '10',
'id' => 'recipient_form'
)
);
if (empty($idCondition)) {
$multipleForm->addSelect(
'recipients',
get_lang('SendTo'),
$options,
array(
'multiple' => 'multiple',
'size' => '10',
'id' => 'recipient_form'
)
);
}
$url = api_get_path(WEB_AJAX_PATH).'dropbox.ajax.php?'.api_get_cidreq().'&a=upload_file&id=';
$multipleForm->addHtml('<div id="multiple_form" style="display:none">');
$url = api_get_path(WEB_AJAX_PATH).'dropbox.ajax.php?'.api_get_cidreq().'&a=upload_file&'.$idCondition;
if (empty($idCondition)) {
$multipleForm->addHtml('<div id="multiple_form" style="display:none">');
}
$multipleForm->addMultipleUpload($url);
$multipleForm->addHtml('</div>');
if (empty($idCondition)) {
$multipleForm->addHtml('</div>');
}
echo Display::tabs(
$headers,
@ -801,56 +835,79 @@ function removeMoreIfMailing($file_id)
/**
* @param array $file
* @param Dropbox_SentWork $work
*
* @return array|null|string
*/
function store_add_dropbox($file = [])
function store_add_dropbox($file = [], $work = null)
{
$_course = api_get_course_info();
$_user = api_get_user_info();
$dropbox_cnf = getDropboxConf();
if (empty($file)) {
$file = isset($_FILES['file']) ? $_FILES['file'] : null;
}
// Validating the form data
if (empty($work)) {
// Validating the form data
// there are no recipients selected
if (!isset($_POST['recipients']) || count($_POST['recipients']) <= 0) {
return get_lang('YouMustSelectAtLeastOneDestinee');
} else {
// Check if all the recipients are valid
$thisIsAMailing = false;
$thisIsJustUpload = false;
foreach ($_POST['recipients'] as $rec) {
if ($rec == 'mailing') {
$thisIsAMailing = true;
} elseif ($rec == 'upload') {
$thisIsJustUpload = true;
} elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_')))) {
Display::addFlash(
Display::return_message(
get_lang('InvalideUserDetected'),
'warning'
)
);
return false;
} elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) {
Display::addFlash(
Display::return_message(
get_lang('InvalideGroupDetected'),
'warning'
)
);
// there are no recipients selected
if (!isset($_POST['recipients']) || count($_POST['recipients']) <= 0) {
return get_lang('YouMustSelectAtLeastOneDestinee');
} else {
// Check if all the recipients are valid
$thisIsAMailing = false;
$thisIsJustUpload = false;
foreach ($_POST['recipients'] as $rec) {
if ($rec == 'mailing') {
$thisIsAMailing = true;
} elseif ($rec == 'upload') {
$thisIsJustUpload = true;
} elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_')))) {
Display::addFlash(Display::return_message(get_lang('InvalideUserDetected'), 'warning'));
return false;
} elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) {
Display::addFlash(Display::return_message(get_lang('InvalideGroupDetected'), 'warning'));
return false;
return false;
}
}
}
}
// we are doing a mailing but an additional recipient is selected
if ($thisIsAMailing && (count($_POST['recipients']) != 1)) {
Display::addFlash(Display::return_message(get_lang('MailingSelectNoOther'), 'warning'));
// we are doing a mailing but an additional recipient is selected
if ($thisIsAMailing && (count($_POST['recipients']) != 1)) {
Display::addFlash(
Display::return_message(
get_lang('MailingSelectNoOther'),
'warning'
)
);
return false;
}
return false;
}
// 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
// yourself AND to a different person (I do this quite often with my e-mails)
if ($thisIsJustUpload && (count($_POST['recipients']) != 1)) {
Display::addFlash(Display::return_message(get_lang('MailingJustUploadSelectNoOther'), 'warning'));
return false;
// 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
// yourself AND to a different person (I do this quite often with my e-mails)
if ($thisIsJustUpload && (count($_POST['recipients']) != 1)) {
Display::addFlash(
Display::return_message(
get_lang('MailingJustUploadSelectNoOther'),
'warning'
)
);
return false;
}
}
if (empty($file['name'])) {
@ -859,14 +916,12 @@ function store_add_dropbox($file = [])
}
// are we overwriting a previous file or sending a new one
$dropbox_overwrite = false;
if (isset($_POST['cb_overwrite']) && $_POST['cb_overwrite']) {
$dropbox_overwrite = true;
}
// doing the upload
$dropbox_filename = $file['name'];
$dropbox_filesize = $file['size'];
$dropbox_filetype = $file['type'];
@ -902,7 +957,12 @@ function store_add_dropbox($file = [])
//filter extension
if (!filter_extension($dropbox_filename)) {
Display::addFlash(Display::return_message(get_lang('UplUnableToSaveFileFilteredExtension'), 'warning'));
Display::addFlash(
Display::return_message(
get_lang('UplUnableToSaveFileFilteredExtension'),
'warning'
)
);
return false;
}
@ -910,8 +970,7 @@ function store_add_dropbox($file = [])
$dropbox_title = $dropbox_filename;
// note: I think we could better migrate everything from here on to
// separate functions: store_new_dropbox, store_new_mailing, store_just_upload
if ($dropbox_overwrite) {
if ($dropbox_overwrite && empty($work)) {
$dropbox_person = new Dropbox_Person(
$_user['user_id'],
api_is_course_admin(),
@ -937,27 +996,32 @@ function store_add_dropbox($file = [])
$dropbox_filename = $_user['username'] . "_" . $dropbox_filename . "_".uniqid('');
}
// creating the array that contains all the users who will receive the file
$new_work_recipients = array();
foreach ($_POST['recipients'] as $rec) {
if (strpos($rec, 'user_') === 0) {
$new_work_recipients[] = substr($rec, strlen('user_'));
} elseif (strpos($rec, 'group_') === 0) {
$groupInfo = GroupManager::get_group_properties(substr($rec, strlen('group_')));
$userList = GroupManager::get_subscribed_users($groupInfo['iid']);
foreach ($userList as $usr) {
if (!in_array($usr['user_id'], $new_work_recipients) && $usr['user_id'] != $_user['user_id']) {
$new_work_recipients[] = $usr['user_id'];
if (empty($work)) {
// creating the array that contains all the users who will receive the file
$new_work_recipients = array();
foreach ($_POST['recipients'] as $rec) {
if (strpos($rec, 'user_') === 0) {
$new_work_recipients[] = substr($rec, strlen('user_'));
} elseif (strpos($rec, 'group_') === 0) {
$groupInfo = GroupManager::get_group_properties(substr($rec, strlen('group_')));
$userList = GroupManager::get_subscribed_users($groupInfo);
foreach ($userList as $usr) {
if (!in_array($usr['user_id'], $new_work_recipients) && $usr['user_id'] != $_user['user_id']) {
$new_work_recipients[] = $usr['user_id'];
}
}
}
}
}
@move_uploaded_file($dropbox_filetmpname, api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/dropbox/' . $dropbox_filename);
@move_uploaded_file(
$dropbox_filetmpname,
api_get_path(SYS_COURSE_PATH).$_course['path'].'/dropbox/'.$dropbox_filename
);
$b_send_mail = api_get_course_setting('email_alert_on_new_doc_dropbox');
if ($b_send_mail) {
if ($b_send_mail && empty($work)) {
foreach ($new_work_recipients as $recipient_id) {
$recipent_temp = api_get_user_info($recipient_id);
$additionalParameters = array(
@ -997,20 +1061,35 @@ function store_add_dropbox($file = [])
}
}
$result = new Dropbox_SentWork(
$_user['user_id'],
$dropbox_title,
isset($_POST['description']) ? $_POST['description'] : '',
api_get_user_id(),
$dropbox_filename,
$dropbox_filesize,
$new_work_recipients
);
if (empty($work)) {
// Create new
$result = new Dropbox_SentWork(
$_user['user_id'],
$dropbox_title,
isset($_POST['description']) ? $_POST['description'] : '',
api_get_user_id(),
$dropbox_filename,
$dropbox_filesize,
$new_work_recipients
);
} else {
// Update
$work->title = $dropbox_title;
$work->filename = $dropbox_filename;
$work->filesize = $dropbox_filesize;
$work->upload_date = api_get_utc_datetime();
$work->last_upload_date = api_get_utc_datetime();
$work->description = isset($_POST['description']) ? $_POST['description'] : '';
$work->uploader_id = api_get_user_id();
$work->updateFile();
$result = $work;
}
Security::clear_token();
Display::addFlash(Display::return_message(get_lang('FileUploadSucces')));
return $result;
}
/**
@ -1043,7 +1122,7 @@ function format_feedback($feedback)
{
$userInfo = api_get_user_info($feedback['author_user_id']);
$output = UserManager::getUserProfileLink($userInfo);
$output .= '&nbsp;&nbsp;'.api_convert_and_format_date($feedback['feedback_date'], DATE_TIME_FORMAT_LONG).'<br />';
$output .= '&nbsp;&nbsp;'.Display::dateToStringAgoAndLongDate($feedback['feedback_date']).'<br />';
$output .= '<div style="padding-top:6px">'.nl2br($feedback['feedback']).'</div><hr size="1" noshade/><br />';
return $output;
}
@ -1063,7 +1142,7 @@ function feedback_form()
$token = Security::get_token();
$return .= '<textarea name="feedback" style="width: 80%; height: 80px;"></textarea>';
$return .= '<input type="hidden" name="sec_token" value="'.$token.'"/>';
$return .= '<br /><button type="submit" class="add" name="store_feedback" value="'.get_lang('Ok').'"
$return .= '<br /><button type="submit" class="btn btn-primary" name="store_feedback" value="'.get_lang('Ok').'"
onclick="javascript: document.form_dropbox.attributes.action.value = document.location;">'.get_lang('AddComment').'</button>';
} else {
$return .= get_lang('AllUsersHaveDeletedTheFileAndWillNotSeeFeedback');

@ -24,9 +24,6 @@ $showSentReceivedTabs = true;
// Do the tracking
Event::event_access_tool(TOOL_DROPBOX);
// This var is used to give a unique value to every page request. This is to prevent resubmiting data
$dropbox_unid = md5(uniqid(rand(), true));
/* DISPLAY SECTION */
Display::display_introduction_section(TOOL_DROPBOX);
@ -50,11 +47,10 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
// Display the form for adding a new dropbox item.
if ($action == 'add') {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
display_add_form(
$dropbox_unid,
$viewReceivedCategory,
$viewSentCategory,
$view
@ -62,10 +58,10 @@ if ($action == 'add') {
}
if (isset($_POST['submitWork'])) {
$check = Security::check_token();
if ($check) {
$check = Security::check_token();
if ($check) {
store_add_dropbox();
}
}
}
// Display the form for adding a category
@ -255,7 +251,9 @@ if ($action != 'add') {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'), '', ICON_SIZE_MEDIUM)."</a>\n";
}
if (empty($viewSentCategory)) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'), '', ICON_SIZE_MEDIUM)."</a>";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".
Display::return_icon('upload_file.png', get_lang('UploadNewFile'), '', ICON_SIZE_MEDIUM).
"</a>";
}
echo '</div>';
} else {
@ -263,12 +261,17 @@ if ($action != 'add') {
echo '<div class="actions">';
if ($view_dropbox_category_sent != 0) {
echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'), '', ICON_SIZE_MEDIUM)."</a>";
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.
Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'), '', ICON_SIZE_MEDIUM).
"</a>";
} else {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'), '', ICON_SIZE_MEDIUM)."</a>\n";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".
Display::return_icon('new_folder.png', get_lang('AddNewCategory'), '', ICON_SIZE_MEDIUM)."</a>\n";
}
if (empty($viewSentCategory)) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'), '', ICON_SIZE_MEDIUM)."</a>";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".
Display::return_icon('upload_file.png', get_lang('UploadNewFile'), '', ICON_SIZE_MEDIUM).
"</a>";
}
echo '</div>';
}
@ -405,7 +408,7 @@ if ($action != 'add') {
// This is a hack to have an additional row in a sortable table
if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
$action_icons .= "</td></tr>"; // Ending the normal row of the sortable table
$action_icons .= '<tr><td colspan="2"><a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
}
@ -570,7 +573,10 @@ if ($action != 'add') {
$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=viewfeedback&id='.$dropbox_file->id.'&'.$sort_params.'">'.
Display::return_icon('discuss.png', get_lang('Comment'), '', ICON_SIZE_SMALL).
'</a>
'</a>
<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/update.php?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=update&id='.$dropbox_file->id.'&'.$sort_params.'">'.
Display::return_icon('upload_file.png', get_lang('Update'), '', ICON_SIZE_SMALL).
'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=movesent&move_id='.$dropbox_file->id.'&'.$sort_params.'">'.
Display::return_icon('move.png', get_lang('Move'), '', ICON_SIZE_SMALL).'
</a>

@ -1,5 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once 'dropbox_init.inc.php';
api_protect_course_script();
@ -19,9 +19,20 @@ if (empty($work)) {
}
if (isset($_POST['submitWork'])) {
store_add_dropbox(null, true);
store_add_dropbox(null, $work);
}
$viewReceivedCategory = isset($_GET['view_received_category']) ? Security::remove_XSS($_GET['view_received_category']) : '';
$viewSentCategory = isset($_GET['view_sent_category']) ? Security::remove_XSS($_GET['view_sent_category']) : '';
$view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : '';
echo Display::page_header($work->title);
display_add_form(
$viewReceivedCategory,
$viewSentCategory,
$view,
$id
);
Display::display_footer();

@ -15,12 +15,22 @@ switch ($action) {
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$recipients = isset($_POST['recipients']) ? $_POST['recipients'] : '';
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if (empty($recipients)) {
if (empty($recipients) && empty($id)) {
$resultList[] = ['error' => get_lang('YouMustSelectAtLeastOneDestinee')];
echo json_encode(['files' => $resultList]);
exit;
}
$work = null;
if (!empty($id)) {
$work = new Dropbox_SentWork($id);
if (empty($work)) {
$resultList[] = ['error' => get_lang('Error')];
echo json_encode(['files' => $resultList]);
exit;
}
}
if (!empty($_FILES)) {
$files = $_FILES['files'];
@ -38,10 +48,9 @@ switch ($action) {
$globalFile = [];
$globalFile['files'] = $file;
/** @var Dropbox_SentWork $result */
$result = store_add_dropbox($file);
$result = store_add_dropbox($file, $work);
$json = array();
if (!empty($result)) {
$json['name'] = Display::url(
api_htmlentities($result->title),

@ -443,6 +443,29 @@ EOT;
);
}
/**
* Returns a move style button
* @param string $label Text appearing on the button
* @param string $name Element name (for form treatment purposes)
* @param bool $createElement Whether to use the create or add method
*
* @return HTML_QuickForm_button
*/
public function addButtonMove($label, $name = 'submit', $createElement = false)
{
return $this->addButton(
$name,
$label,
'arrow-circle-right',
'primary',
null,
null,
array(),
$createElement
);
}
/**
* Returns a button with the primary color and a paper-plane icon
* @param string $label Text appearing on the button

Loading…
Cancel
Save