Replacing <form> with FormValidator cleaning code, removing globals calls; see BT#5749

1.9.x
Julio Montoya 11 years ago
parent fa93fdf7ed
commit a6e11df9ae
  1. 82
      main/dropbox/dropbox_class.inc.php
  2. 106
      main/dropbox/dropbox_functions.inc.php
  3. 125
      main/dropbox/dropbox_init.inc.php
  4. 45
      main/dropbox/dropbox_submit.php
  5. 203
      main/dropbox/index.php

@ -92,21 +92,23 @@ class Dropbox_Work
*/
public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
{
global $_user, $dropbox_cnf;
// Fill in the properties
$this->uploader_id = intval($uploader_id);
$this->uploaderName = getUserNameFromId($this->uploader_id);
$this->filename = $filename;
$this->filesize = $filesize;
$this->title = $title;
$this->description = $description;
$this->author = api_get_person_name($_user['firstName'], $_user['lastName']);
$this->last_upload_date = api_get_utc_datetime();
$course_id = api_get_course_int_id();
$_user = api_get_user_info();
$dropbox_cnf = getDropboxConf();
// Fill in the properties
$this->uploader_id = intval($uploader_id);
$this->uploaderName = getUserNameFromId($this->uploader_id);
$this->filename = $filename;
$this->filesize = $filesize;
$this->title = $title;
$this->description = $description;
$this->author = api_get_person_name($_user['firstName'], $_user['lastName']);
$this->last_upload_date = api_get_utc_datetime();
$course_id = api_get_course_int_id();
// Check if object exists already. If it does, the old object is used
// with updated information (authors, description, upload_date)
$this->isOldWork = false;
// Check if object exists already. If it does, the old object is used
// with updated information (authors, description, upload_date)
$this->isOldWork = false;
$sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
$result = Database::query($sql);
@ -138,7 +140,7 @@ class Dropbox_Work
, '".Database::escape_string($this->author)."'
, '".Database::escape_string($this->upload_date)."'
, '".Database::escape_string($this->last_upload_date)."'
, ".intval($_SESSION['id_session'])."
, ".api_get_session_id()."
)";
Database::query($sql);
@ -166,10 +168,12 @@ class Dropbox_Work
*
* @param int $id
*/
function _createExistingWork($id)
public function _createExistingWork($id)
{
$course_id = api_get_course_int_id();
global $_user, $dropbox_cnf;
$dropbox_cnf = getDropboxConf();
$action = isset($_GET['action']) ? $_GET['action'] : null;
// Do some sanity checks
$id = intval($id);
@ -205,7 +209,7 @@ class Dropbox_Work
$this->category = $res['cat_id'];
// Getting the feedback on the work.
if ($_GET['action'] == 'viewfeedback' AND $this->id == $_GET['id']) {
if ($action == 'viewfeedback' AND $this->id == $_GET['id']) {
$feedback2 = array();
$sql_feedback = "SELECT * FROM ".$dropbox_cnf['tbl_feedback']." WHERE c_id = $course_id AND file_id='".$id."' ORDER BY feedback_id ASC";
$result = Database::query($sql_feedback);
@ -247,17 +251,19 @@ class Dropbox_SentWork extends Dropbox_Work
/**
* private function creating a new SentWork object
*
* @param unknown_type $uploader_id
* @param unknown_type $title
* @param unknown_type $description
* @param unknown_type $author
* @param unknown_type $filename
* @param unknown_type $filesize
* @param unknown_type $recipient_ids
* @param int $uploader_id
* @param string $title
* @param string $description
* @param string $author
* @param string $filename
* @param int $filesize
* @param array $recipient_ids
*/
function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
{
global $dropbox_cnf;
$dropbox_cnf = getDropboxConf();
$_course = api_get_course_info();
// Call constructor of Dropbox_Work object
$this->Dropbox_Work($uploader_id, $title, $description, $author, $filename, $filesize);
@ -275,9 +281,11 @@ class Dropbox_SentWork extends Dropbox_Work
$justSubmit = true;
$recipient_ids = array($uploader_id);
}
if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
die(get_lang('GeneralError').' (code 209)');
}
foreach ($recipient_ids as $rec) {
if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
//if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
@ -314,7 +322,6 @@ class Dropbox_SentWork extends Dropbox_Work
}
// Update item_property table for each recipient
global $_course, $dropbox_cnf;
if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
$ownerid = getUserOwningThisMailing($ownerid);
}
@ -332,8 +339,7 @@ class Dropbox_SentWork extends Dropbox_Work
*/
function _createExistingSentWork ($id)
{
global $dropbox_cnf;
$dropbox_cnf = getDropboxConf();
$id = intval($id);
$course_id = api_get_course_int_id();
@ -533,7 +539,7 @@ class Dropbox_Person
*/
function deleteAllReceivedWork () {
$course_id = api_get_course_int_id();
global $dropbox_cnf;
$dropbox_cnf = getDropboxConf();
// Delete entries in person table concerning received works
foreach ($this->receivedWork as $w) {
Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'");
@ -546,7 +552,7 @@ class Dropbox_Person
*/
function deleteReceivedWorkFolder($id)
{
global $dropbox_cnf;
$dropbox_cnf = getDropboxConf();
$course_id = api_get_course_int_id();
$id = intval($id);
@ -567,7 +573,7 @@ class Dropbox_Person
function deleteReceivedWork($id)
{
$course_id = api_get_course_int_id();
global $dropbox_cnf;
$dropbox_cnf = getDropboxConf();
$id = intval($id);
// index check
@ -596,7 +602,7 @@ class Dropbox_Person
function deleteAllSentWork()
{
$course_id = api_get_course_int_id();
global $dropbox_cnf;
$dropbox_cnf = getDropboxConf();
//delete entries in person table concerning sent works
foreach ($this->sentWork as $w) {
Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'");
@ -613,8 +619,8 @@ class Dropbox_Person
function deleteSentWork($id)
{
$course_id = api_get_course_int_id();
$dropbox_cnf = getDropboxConf();
global $dropbox_cnf;
$id = intval($id);
// index check
@ -646,8 +652,9 @@ class Dropbox_Person
function updateFeedback($id, $text)
{
$course_id = api_get_course_int_id();
$_course = api_get_course_info();
$dropbox_cnf = getDropboxConf();
global $_course, $dropbox_cnf;
$id = intval($id);
// index check
@ -688,8 +695,7 @@ class Dropbox_Person
*/
function filter_received_work($type, $value)
{
global $dropbox_cnf;
$dropbox_cnf = getDropboxConf();
$new_received_work = array();
foreach ($this->receivedWork as $work) {
switch ($type) {

@ -179,9 +179,13 @@ 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())
function display_move_form($part, $id, $target = array(), $extra_params = array(), $viewReceivedCategory, $viewSentCategory, $view)
{
$form = new FormValidator('form1', 'post', api_get_self().'?view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&view='.Security::remove_XSS($_GET['view']).'&'.$extra_params);
$form = new FormValidator(
'form1',
'post',
api_get_self().'?view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&'.$extra_params
);
$form->addElement('header', get_lang('MoveFileTo'));
$form->addElement('hidden', 'id', intval($id));
$form->addElement('hidden', 'part', Security::remove_XSS($part));
@ -471,7 +475,7 @@ function display_addcategory_form($category_name = '', $id = '', $action)
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006
*/
function display_add_form($dropbox_unid)
function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view)
{
$course_info = api_get_course_info();
$_user = api_get_user_info();
@ -479,53 +483,29 @@ function display_add_form($dropbox_unid)
$is_courseTutor = api_is_course_tutor();
$origin = isset($_GET['origin']) ? $_GET['origin'] : null;
$token = Security::get_token();
$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
?>
<form method="post" action="index.php?view_received_category=<?php echo Security::remove_XSS($_GET['view_received_category']); ?>&view_sent_category=<?php echo Security::remove_XSS($_GET['view_sent_category']); ?>&view=<?php echo Security::remove_XSS($_GET['view']); ?>&<?php echo "origin=$origin"."&".api_get_cidreq(); ?>" enctype="multipart/form-data" onsubmit="javascript: return checkForm(this);">
<legend><?php echo get_lang('UploadNewFile'); ?></legend>
<div class="control-group">
<label>
<span class="form_required">*</span><?php echo get_lang('UploadFile'); ?>:
</label>
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value='<?php echo dropbox_cnf('maxFilesize'); ?>' />
<input type="file" name="file" size="20" <?php if (dropbox_cnf('allowOverwrite')) echo 'onChange="javascript: checkfile(this.value);"'; ?> />
<input type="hidden" name="dropbox_unid" value="<?php echo $dropbox_unid; ?>" />
<input type="hidden" name="sec_token" value="<?php echo $token; ?>" />
<?php
if ($origin == 'learnpath') {
echo '<input type="hidden" name="origin" value="learnpath" />';
}
?>
</div>
</div>
<?php
$form = new FormValidator(
'sent_form',
'post',
api_get_self().'?view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&'.api_get_cidreq(),
null,
array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);')
);
$form->addElement('header', get_lang('UploadNewFile'));
$form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize'));
$form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'origin', $origin);
$form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));
if (dropbox_cnf('allowOverwrite')) {
?>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="cb_overwrite" id="cb_overwrite" value="true" />
<?php echo get_lang('OverwriteFile'); ?>
</label>
</div>
</div>
<?php
$form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
}
?>
<div class="control-group">
<label class="control-label">
<?php echo get_lang('SendTo'); ?>
</label>
<div class="controls">
<?php
//list of all users in this course and all virtual courses combined with it
// List of all users in this course and all virtual courses combined with it
if (api_get_session_id()) {
$complete_user_list_for_dropbox = array();
if (api_get_setting('dropbox_allow_student_to_student')=='true' || $_user['status'] != STUDENT) {
@ -548,13 +528,13 @@ function display_add_form($dropbox_unid)
$complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
}
echo '<select name="recipients[]" size="10" multiple class="span4">';
/*
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 = '';
$options = array();
foreach ($complete_user_list_for_dropbox as $current_user) {
if (($dropbox_person -> isCourseTutor
|| $dropbox_person -> isCourseAdmin
@ -567,10 +547,12 @@ function display_add_form($dropbox_unid)
}
$full_name = $current_user['lastcommafirst'];
$current_user_id = $current_user['user_id'];
echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>';
$options['user_' . $current_user_id] = $full_name;
//echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>';
}
}
/*
* Show groups
*/
@ -581,32 +563,22 @@ function display_add_form($dropbox_unid)
if (count($complete_group_list_for_dropbox) > 0) {
foreach ($complete_group_list_for_dropbox as $current_group) {
if ($current_group['number_of_members'] > 0) {
echo '<option value="group_'.$current_group['id'].'">G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users').'</option>';
//echo '<option value="group_'.$current_group['id'].'">G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users').'</option>';
$options['group_'.$current_group['id']] = 'G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users');
}
}
}
}
if (($dropbox_person -> isCourseTutor || $dropbox_person -> isCourseAdmin) && dropbox_cnf('allowMailing')) {
// echo '<option value="mailing">'.get_lang('MailingInSelect').'</option>';
}
if (dropbox_cnf('allowJustUpload')) {
//echo '<option value="upload">'.get_lang('JustUploadInSelect').'</option>';
echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>';
//echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>';
$options['user_'.$_user['user_id']] = get_lang('JustUploadInSelect');
}
echo '</select>
</div>
</div>';
echo '
<div class="control-group">
<div class="controls">
<button type="Submit" class="upload" name="submitWork">'.get_lang('Upload', '').'</button>
</div>
</div>
';
echo '</form>';
$form->addElement('select', 'recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10', 'class' => 'span4'));
$form->addElement('button', 'submitWork', get_lang('Upload'));
$form->display();
}
/**
@ -766,6 +738,9 @@ function dropbox_cnf($variable)
return $dropbox_cnf[$variable];
}
/**
* @return array|null|string
*/
function store_add_dropbox()
{
$_course = api_get_course_info();
@ -855,7 +830,7 @@ function store_add_dropbox()
// set title
$dropbox_title = $dropbox_filename;
// set author
if ($_POST['authors'] == '') {
if (!isset($_POST['authors'])) {
$_POST['authors'] = getUserNameFromId($_user['user_id']);
}
@ -909,7 +884,7 @@ function store_add_dropbox()
}
}
new Dropbox_SentWork( $_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $new_work_recipients);
new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $new_work_recipients);
Security::clear_token();
return get_lang('FileUploadSucces');
@ -1187,6 +1162,7 @@ function get_total_number_feedback($file_id = '') {
$sql = "SELECT COUNT(feedback_id) AS total, file_id FROM ".$dropbox_cnf['tbl_feedback']."
WHERE c_id = $course_id GROUP BY file_id";
$result = Database::query($sql);
$return = array();
while ($row=Database::fetch_array($result)) {
$return[$row['file_id']] = $row['total'];
}

@ -1,6 +1,96 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @desc The dropbox is a personal (peer to peer) file exchange module that allows
* you to send documents to a certain (group of) users.
*
* @version 1.3
*
* @author Jan Bols <jan@ivpv.UGent.be>, main programmer, initial version
* @author René Haentjens <rene.haentjens@UGent.be>, several contributions
* @author Roan Embrechts, virtual course support
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (see history version 1.3)
*
* @package chamilo.dropbox
*
* @todo complete refactoring. Currently there are about at least 3 sql queries needed for every individual dropbox document.
* first we find all the documents that were sent (resp. received) by the user
* then for every individual document the user(s)information who received (resp. sent) the document is searched
* then for every individual document the feedback is retrieved
* @todo the implementation of the dropbox categories could (on the database level) have been done more elegantly by storing the category
* in the dropbox_person table because this table stores the relationship between the files (sent OR received) and the users
*/
/**
HISTORY
Version 1.1
------------
- dropbox_init1.inc.php: changed include statements to require statements. This way if a file is not found, it stops the execution of a script instead of continuing with warnings.
- dropbox_init1.inc.php: the include files "claro_init_global.inc.php" & "debug.lib.inc.php" are first checked for their existence before including them. If they don't exist, in the .../include dir, they get loaded from the .../inc dir. This change is necessary because the UCL changed the include dir to inc.
- dropbox_init1.inc.php: the databasetable name in the variable $dropbox_cnf["introTbl"] is chnged from "introduction" to "tool_intro"
- install.php: after submit, checks if the database uses accueil or tool_list as a tablename
- index.php: removed the behaviour of only the teachers that are allowed to delete entries
- index.php: added field "lastUploadDate" in table dropbox_file to store information about last update when resubmiting a file
- dropbox.inc.php: added $lang["lastUpdated"]
- index.php: entries in received list show when file was last updated if it is updated
- index.php: entries in sent list show when file was last resent if it was resent
- dropbox_submit.php: add a unique id to every uploaded file
- index.php: add POST-variable to the upload form with overwrite data when user decides to overwrite the previous sent file with new file
- dropbox_submit.php: add sanity checks on POST['overwrite'] data
- index.php: remove title field in upload form
- dropbox_submit.php: remove use of POST['title'] variable
- dropbox_init1.inc.php: added $dropbox_cnf["version"] variable
- dropbox_class.inc.php: add $this->lastUploadDate to Dropbox_work class
- dropbox.inc.php: added $lang['emptyTable']
- index.php: if the received or sent list is empty, a message is displayed
- dropbox_download.php: the $file var is set equal to the title-field of the filetable. So not constructed anymore by substracting the username from the filename
- index.php: add check to see if column lastUploadDate exists in filetable
- index.php: moved javascripts from dropbox_init2.inc.php to index.php
- index.php: when specifying an uploadfile in the form, a checkbox allowing the user to overwrite a previously sent file is shown when the specified file has the same name as a previously uploaded file of that user.
- index.php: assign all the metadata (author, description, date, recipient, sender) of an entry in a list to the class="dropbox_detail" and add css to html-header
- index.php: assign all dates of entries in list to the class="dropbox_date" and add CSS
- index.php: assign all persons in entries of list to the class="dropbox_person" and add CSS
- dropbox.inc.php: added $lang['dropbox_version'] to indicate the lates version. This must be equal to the $dropbox_cnf['version'] variable.
- dropbox_init1.inc.php: if the newest lang file isn't loaded by claro_init_global.inc.php from the .../lang dir it will be loaded locally from the .../plugin/dropbox/ dir. This way an administrator must not install the dropbox.inc.php in the .../lang/english dir, but he can leave it in the local .../plugin/dropbox/ dir. However if you want to present multiple language translations of the file you must still put the file in the /lang/ dir, because there is no language management system inside the .../plugin/dropbox dir.
- mime.inc.php: created this file. It contains an array $mimetype with all the mimetypes that are used by dropbox_download.php to give hinst to the browser during download about content
- dropbox_download.php: remove https specific headers because they're not necessary
- dropbox_download.php: use application/octet-stream as the default mime and inline as the default Content-Disposition
- dropbox.inc.php: add lang vars for "order by" action
- dropbox_class.inc.php: add methods orderSentWork, orderReceivedWork en _cmpWork and propery _orderBy to class Dropbox_person to take care of sorting
- index.php: add selectionlist to headers of sent/received lists to select "order by" and add code to keep selected value in sessionvar.
- index.php: moved part of a <a> hyperlink to previous line to remove the underlined space between symbol and title of a work entry in the sent/received list
- index.php: add filesize info in sent/received lists
- dropbox_submit.php: resubmit prevention only for GET action, because it gives some annoying behaviour in POST situation: white screen in IE6
Version 1.2
-----------
- adapted entire dropbox tool so it can be used as a default tool in Dokeos 1.5
- index.php: add event registration to log use of tool in stats tables
- index.php: upload form checks for correct user selection and file specification before uploading the script
- dropbox_init1.inc.php: added dropbox_cnf["allowOverwrite"] to allow or disallow overwriting of files
- index.php: author name textbox is automatically filled in
- mailing functionality (René Haentjens)
- allowStudentToStudent and allowJustUpload options (id.)
- help in separate window (id.)
Version 1.3 (Patrick Cool)
--------------------------
- sortable table
- categories
- fixing a security hole
- tabs (which can be disabled: see $dropbox_cnf['sent_received_tabs'])
- same action on multiple documents ([zip]download, move, delete)
- consistency with the docuements tool (open/download file, icons of documents, ...)
- zip download of complete folder
Version 1.4 (Yannick Warnier)
-----------------------------
- removed all self-built database tables names
*/
/**
* First initialisation file with initialisation of variables and
* without outputting anything to browser.
@ -23,6 +113,7 @@
extended feedback
* @package chamilo.dropbox
*/
/**
* Code
*/
@ -69,6 +160,7 @@ $session_id = api_get_session_id();
$action = isset($_GET['action']) ? $_GET['action'] : null;
$view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
$postAction = isset($_POST['action']) ? $_POST['action'] : null;
if (empty($session_id)) {
$is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, false);
@ -124,16 +216,20 @@ $javascript = "<script type=\"text/javascript\">
";
if (dropbox_cnf('allowOverwrite')) {
//sentArray keeps list of all files still available in the sent files list
//of the user.
//This is used to show or hide the overwrite file-radio button of the upload form
$javascript .= "
var sentArray = new Array("; //sentArray keeps list of all files still available in the sent files list
//of the user.
//This is used to show or hide the overwrite file-radio button of the upload form
for ($i = 0; $i < count($dropbox_person->sentWork); $i++) {
if ($i > 0) {
$javascript .= ", ";
}
$javascript .= "'".$dropbox_person->sentWork[$i]->title."'";
}
var sentArray = new Array(";
if (isset($dropbox_person)) {
for ($i = 0; $i < count($dropbox_person->sentWork); $i++) {
if ($i > 0) {
$javascript .= ", ";
}
$javascript .= "'".$dropbox_person->sentWork[$i]->title."'";
}
}
$javascript .= ");
function checkfile(str)
@ -208,7 +304,7 @@ if (!$view OR $view == 'received') {
header ('location: index.php?view='.$view.'&error=Error');
}
if (($_POST['action'] == 'download_received' || $_POST['action'] == 'download_sent') and !$_POST['store_feedback']) {
if (($postAction == 'download_received' || $postAction == 'download_sent') and !$_POST['store_feedback']) {
$checked_file_ids = $_POST['id'];
if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) {
header ('location: index.php?view='.$view.'&error=CheckAtLeastOneFile');
@ -260,9 +356,10 @@ if ($view == 'sent' OR empty($view)) {
/* HEADER & TITLE */
if ($origin != 'learnpath') {
if (isset($origin) && $origin == 'learnpath') {
// if we come from the learning path we have to include the stylesheet and the required javascripts manually.
echo '<link rel="stylesheet" type="text/css" href="', api_get_path(WEB_CODE_PATH), 'css/default.css">';
echo $javascript;
} else {
Display::display_header($nameTools, 'Dropbox');
} else { // if we come from the learning path we have to include the stylesheet and the required javascripts manually.
echo '<link rel="stylesheet" type="text/css" href="', api_get_path(WEB_CODE_PATH), 'css/default.css">';
echo $javascript;
}

@ -190,51 +190,6 @@ if (isset($_POST['submitWork'])) {
}
}
function findRecipient($thisFile) {
// string result = error message, array result = [user_id, lastname, firstname, status]
global $nameParts, $preFix, $preLen, $postFix, $postLen;
if (preg_match(dropbox_cnf('mailingFileRegexp'), $thisFile, $matches)) {
$thisName = $matches[1];
if (api_substr($thisName, 0, $preLen) == $preFix) {
if ($postLen == 0 || api_substr($thisName, -$postLen) == $postFix) {
$thisRecip = api_substr($thisName, $preLen, api_strlen($thisName) - $preLen - $postLen);
if ($thisRecip) {
return getUser($thisRecip);
}
return ' <'.get_lang('MailingFileNoRecip', '').'>';
} else {
return ' <'.get_lang('MailingFileNoPostfix', '').$postFix.'>';
}
} else {
return ' <'.get_lang('MailingFileNoPrefix', '').$preFix.'>';
}
} else {
return ' <'.get_lang('MailingFileFunny', '').'>';
}
}
function getUser($thisRecip) {
// string result = error message, array result = [user_id, lastname, firstname]
global $var, $sel;
if (isset($students)) {
unset($students);
}
$result = Database::query($sel . $thisRecip . "'");
while ( ($res = Database::fetch_array($result))) {$students[] = $res;}
Database::free_result($result);
if (count($students) == 1) {
return($students[0]);
} elseif (count($students) > 1) {
return ' <'.get_lang('MailingFileRecipDup', '').$var."= $thisRecip>";
} else {
return ' <'.get_lang('MailingFileRecipNotFound', '').$var."= $thisRecip>";
}
}
/**
* DELETE RECEIVED OR SENT FILES - EDIT FEEDBACK
* - DELETE ALL RECEIVED FILES

@ -1,98 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @desc The dropbox is a personal (peer to peer) file exchange module that allows
* you to send documents to a certain (group of) users.
*
* @version 1.3
*
* @author Jan Bols <jan@ivpv.UGent.be>, main programmer, initial version
* @author René Haentjens <rene.haentjens@UGent.be>, several contributions
* @author Roan Embrechts, virtual course support
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (see history version 1.3)
*
* @package chamilo.dropbox
*
* @todo complete refactoring. Currently there are about at least 3 sql queries needed for every individual dropbox document.
* first we find all the documents that were sent (resp. received) by the user
* then for every individual document the user(s)information who received (resp. sent) the document is searched
* then for every individual document the feedback is retrieved
* @todo the implementation of the dropbox categories could (on the database level) have been done more elegantly by storing the category
* in the dropbox_person table because this table stores the relationship between the files (sent OR received) and the users
*/
/**
HISTORY
Version 1.1
------------
- dropbox_init1.inc.php: changed include statements to require statements. This way if a file is not found, it stops the execution of a script instead of continuing with warnings.
- dropbox_init1.inc.php: the include files "claro_init_global.inc.php" & "debug.lib.inc.php" are first checked for their existence before including them. If they don't exist, in the .../include dir, they get loaded from the .../inc dir. This change is necessary because the UCL changed the include dir to inc.
- dropbox_init1.inc.php: the databasetable name in the variable $dropbox_cnf["introTbl"] is chnged from "introduction" to "tool_intro"
- install.php: after submit, checks if the database uses accueil or tool_list as a tablename
- index.php: removed the behaviour of only the teachers that are allowed to delete entries
- index.php: added field "lastUploadDate" in table dropbox_file to store information about last update when resubmiting a file
- dropbox.inc.php: added $lang["lastUpdated"]
- index.php: entries in received list show when file was last updated if it is updated
- index.php: entries in sent list show when file was last resent if it was resent
- dropbox_submit.php: add a unique id to every uploaded file
- index.php: add POST-variable to the upload form with overwrite data when user decides to overwrite the previous sent file with new file
- dropbox_submit.php: add sanity checks on POST['overwrite'] data
- index.php: remove title field in upload form
- dropbox_submit.php: remove use of POST['title'] variable
- dropbox_init1.inc.php: added $dropbox_cnf["version"] variable
- dropbox_class.inc.php: add $this->lastUploadDate to Dropbox_work class
- dropbox.inc.php: added $lang['emptyTable']
- index.php: if the received or sent list is empty, a message is displayed
- dropbox_download.php: the $file var is set equal to the title-field of the filetable. So not constructed anymore by substracting the username from the filename
- index.php: add check to see if column lastUploadDate exists in filetable
- index.php: moved javascripts from dropbox_init2.inc.php to index.php
- index.php: when specifying an uploadfile in the form, a checkbox allowing the user to overwrite a previously sent file is shown when the specified file has the same name as a previously uploaded file of that user.
- index.php: assign all the metadata (author, description, date, recipient, sender) of an entry in a list to the class="dropbox_detail" and add css to html-header
- index.php: assign all dates of entries in list to the class="dropbox_date" and add CSS
- index.php: assign all persons in entries of list to the class="dropbox_person" and add CSS
- dropbox.inc.php: added $lang['dropbox_version'] to indicate the lates version. This must be equal to the $dropbox_cnf['version'] variable.
- dropbox_init1.inc.php: if the newest lang file isn't loaded by claro_init_global.inc.php from the .../lang dir it will be loaded locally from the .../plugin/dropbox/ dir. This way an administrator must not install the dropbox.inc.php in the .../lang/english dir, but he can leave it in the local .../plugin/dropbox/ dir. However if you want to present multiple language translations of the file you must still put the file in the /lang/ dir, because there is no language management system inside the .../plugin/dropbox dir.
- mime.inc.php: created this file. It contains an array $mimetype with all the mimetypes that are used by dropbox_download.php to give hinst to the browser during download about content
- dropbox_download.php: remove https specific headers because they're not necessary
- dropbox_download.php: use application/octet-stream as the default mime and inline as the default Content-Disposition
- dropbox.inc.php: add lang vars for "order by" action
- dropbox_class.inc.php: add methods orderSentWork, orderReceivedWork en _cmpWork and propery _orderBy to class Dropbox_person to take care of sorting
- index.php: add selectionlist to headers of sent/received lists to select "order by" and add code to keep selected value in sessionvar.
- index.php: moved part of a <a> hyperlink to previous line to remove the underlined space between symbol and title of a work entry in the sent/received list
- index.php: add filesize info in sent/received lists
- dropbox_submit.php: resubmit prevention only for GET action, because it gives some annoying behaviour in POST situation: white screen in IE6
Version 1.2
-----------
- adapted entire dropbox tool so it can be used as a default tool in Dokeos 1.5
- index.php: add event registration to log use of tool in stats tables
- index.php: upload form checks for correct user selection and file specification before uploading the script
- dropbox_init1.inc.php: added dropbox_cnf["allowOverwrite"] to allow or disallow overwriting of files
- index.php: author name textbox is automatically filled in
- mailing functionality (René Haentjens)
- allowStudentToStudent and allowJustUpload options (id.)
- help in separate window (id.)
Version 1.3 (Patrick Cool)
--------------------------
- sortable table
- categories
- fixing a security hole
- tabs (which can be disabled: see $dropbox_cnf['sent_received_tabs'])
- same action on multiple documents ([zip]download, move, delete)
- consistency with the docuements tool (open/download file, icons of documents, ...)
- zip download of complete folder
Version 1.4 (Yannick Warnier)
-----------------------------
- removed all self-built database tables names
*/
/* INIT SECTION */
// The file that contains all the initialisation stuff (and includes all the configuration stuff)
require_once 'dropbox_init.inc.php';
@ -104,6 +12,12 @@ if ($_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') {
$last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX];
}
$postAction = isset($_POST['action']) ? $_POST['action'] : null;
$view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
$viewReceivedCategory = isset($_GET['view_received_category']) ? Security::remove_XSS($_GET['view_received_category']) : null;
$viewSentCategory = isset($_GET['view_sent_category']) ? Security::remove_XSS($_GET['view_sent_category']) : null;
// Do the tracking
event_access_tool(TOOL_DROPBOX);
@ -138,7 +52,7 @@ if ($action == 'add') {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
display_add_form($dropbox_unid);
display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view);
}
if (isset($_POST['submitWork'])) {
@ -183,7 +97,7 @@ if (isset($_POST['StoreCategory'])) {
}
if ($return_information['type'] == 'error') {
Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']);
display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $_POST['action']);
display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction);
}
}
@ -193,7 +107,15 @@ if (($action == 'movesent' OR $action == 'movereceived') AND isset($_GET['move_i
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
display_move_form(str_replace('move', '', $action), $_GET['move_id'], get_dropbox_categories(str_replace('move', '', $action)), $sort_params);
display_move_form(
str_replace('move', '', $action),
$_GET['move_id'],
get_dropbox_categories(str_replace('move', '', $action)),
$sort_params,
$viewReceivedCategory,
$viewSentCategory,
$view
);
}
if (isset($_POST['do_move'])) {
Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part']));
@ -229,9 +151,9 @@ if (($action == 'deletereceivedcategory' OR $action == 'deletesentcategory') AND
// only the download has is handled separately in dropbox_init_inc.php because this has to be done before the headers are sent
// (which also happens in dropbox_init.inc.php
if (!isset($_POST['feedback']) && (strstr($_POST['action'], 'move_received') OR
$_POST['action'] == 'delete_received' OR $_POST['action'] == 'download_received' OR
$_POST['action'] == 'delete_sent' OR $_POST['action'] == 'download_sent')) {
if (!isset($_POST['feedback']) && (strstr($postAction, 'move_received') OR
$postAction == 'delete_received' OR $postAction == 'download_received' OR
$postAction == 'delete_sent' OR $postAction == 'download_sent')) {
$display_message = handle_multiple_actions();
Display :: display_normal_message($display_message);
@ -272,12 +194,12 @@ if ($action != 'add') {
}
// ACTIONS
if ($_GET['view'] == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
if ($view == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
//echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
// This is for the categories
if (isset($_GET['view_received_category']) AND $_GET['view_received_category'] != '') {
$view_dropbox_category_received = Security::remove_XSS($_GET['view_received_category']);
if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
$view_dropbox_category_received = $viewReceivedCategory;
} else {
$view_dropbox_category_received = 0;
}
@ -287,32 +209,32 @@ if ($action != 'add') {
if (api_get_session_id() == 0) {
echo '<div class="actions">';
if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['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=0&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
$movelist[0] = 'Root'; // move_received selectbox content
} else {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.Security::remove_XSS($_GET['view']).'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
} else {
if (api_is_allowed_to_session_edit(false, true)) {
echo '<div class="actions">';
if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['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=0&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
$movelist[0] = 'Root'; // move_received selectbox content
} else {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.Security::remove_XSS($_GET['view']).'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
}
}
}
if (!$_GET['view'] OR $_GET['view'] == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
if (!$view OR $view == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
// This is for the categories
if (isset($_GET['view_sent_category']) AND $_GET['view_sent_category'] != '') {
$view_dropbox_category_sent = $_GET['view_sent_category'];
if (isset($viewSentCategory) AND $viewSentCategory != '') {
$view_dropbox_category_sent = $viewSentCategory;
} else {
$view_dropbox_category_sent = 0;
}
@ -322,13 +244,13 @@ if ($action != 'add') {
if (api_get_session_id() == 0) {
echo '<div class="actions">';
if ($view_dropbox_category_sent != 0) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category=0&amp;view='.Security::remove_XSS($_GET['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.'&amp;view_sent_category=0&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
} else {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".Security::remove_XSS($_GET['view'])."&amp;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."&amp;action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
}
if (empty($_GET['view_sent_category'])) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".Security::remove_XSS($_GET['view'])."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
if (empty($viewSentCategory)) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
}
echo '</div>';
} else {
@ -336,12 +258,12 @@ 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='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category=0&amp;view='.Security::remove_XSS($_GET['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.'&amp;view_sent_category=0&amp;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=".Security::remove_XSS($_GET['view'])."&amp;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."&amp;action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
}
if (empty($_GET['view_sent_category'])) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".Security::remove_XSS($_GET['view'])."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
if (empty($viewSentCategory)) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
}
echo '</div>';
}
@ -354,9 +276,9 @@ if ($action != 'add') {
?>
<ul class="nav nav-tabs">
<li <?php if (!$_GET['view'] OR $_GET['view'] == 'sent') { echo 'class="active"'; } ?> >
<li <?php if (!$view OR $view == 'sent') { echo 'class="active"'; } ?> >
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=sent" ><?php echo get_lang('SentFiles'); ?></a></li>
<li <?php if ($_GET['view'] == 'received') { echo 'class="active"'; } ?> >
<li <?php if ($view == 'received') { echo 'class="active"'; } ?> >
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=received" ><?php echo get_lang('ReceivedFiles'); ?></a></li>
</ul>
@ -365,10 +287,10 @@ if ($action != 'add') {
/* RECEIVED FILES */
if ($_GET['view'] == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
if ($view == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
// This is for the categories
if (isset($_GET['view_received_category']) AND $_GET['view_received_category'] != '') {
$view_dropbox_category_received = $_GET['view_received_category'];
if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
$view_dropbox_category_received = $viewReceivedCategory;
} else {
$view_dropbox_category_received = 0;
}
@ -453,16 +375,16 @@ if ($action != 'add') {
$dropbox_file_data[] = date_to_str_ago($last_upload_date).'<br /><span class="dropbox_date">'.api_format_date($last_upload_date).'</span>';
$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
// 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']) {
$action_icons .= "</td></tr>"; // Ending the normal row of the sortable table
$action_icons .= '<tr><td colspan="2"><a href="index.php?"'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category'])."&amp;view_sent_category=".Security::remove_XSS($_GET['view_sent_category'])."&amp;view=".Security::remove_XSS($_GET['view']).'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
$action_icons .= '<tr><td colspan="2"><a href="index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&amp;view_sent_category=".$viewSentCategory."&amp;view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
}
if (api_get_session_id() == 0) {
$dropbox_file_data[] = $action_icons;
@ -484,14 +406,14 @@ if ($action != 'add') {
$movelist[$category['cat_id']] = $category['cat_name'];
$dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear
// The icon of the category
$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'">';
$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">';
$dropbox_category_data[] = $link_open.build_document_icon_tag('folder', $category['cat_name']).'</a>';
$dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>';
$dropbox_category_data[] = '';
$dropbox_category_data[] = '';
$dropbox_category_data[] = '';
$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=editcategory&amp;id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletereceivedcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=editcategory&amp;id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletereceivedcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
}
if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
$dropbox_data_recieved[] = $dropbox_category_data;
@ -499,7 +421,7 @@ if ($action != 'add') {
}
}
// Displaying the table
$additional_get_parameters = array('view' => $_GET['view'], 'view_received_category' => $_GET['view_received_category'], 'view_sent_category' => $_GET['view_sent_category']);
$additional_get_parameters = array('view' => $view, 'view_received_category' => $viewReceivedCategory, 'view_sent_category' => $viewSentCategory);
$selectlist = array('delete_received' => get_lang('Delete'), 'download_received' => get_lang('Download'));
if (is_array($movelist)) {
foreach ($movelist as $catid => $catname){
@ -516,10 +438,10 @@ if ($action != 'add') {
/* SENT FILES */
if (!$_GET['view'] OR $_GET['view'] == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
if (!$view OR $view == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
// This is for the categories
if (isset($_GET['view_sent_category']) AND $_GET['view_sent_category'] != '') {
$view_dropbox_category_sent = $_GET['view_sent_category'];
if (isset($viewSentCategory) AND $viewSentCategory != '') {
$view_dropbox_category_sent = $viewSentCategory;
} else {
$view_dropbox_category_sent = 0;
}
@ -588,6 +510,7 @@ if ($action != 'add') {
$dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download">'.Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a><br />'.$dropbox_file->description;
$file_size = $dropbox_file->filesize;
$dropbox_file_data[] = format_file_size($file_size);
$receivers_celldata = null;
foreach ($dropbox_file->recipients as $recipient) {
$receivers_celldata = display_user_link_work($recipient['user_id'], $recipient['name']).', '.$receivers_celldata;
}
@ -600,14 +523,14 @@ if ($action != 'add') {
$receivers_celldata = '';
$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=movesent&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletesentfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=movesent&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletesentfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
// This is a hack to have an additional row in a sortable table
if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
$action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
$action_icons .= "<tr><td colspan=\"2\">";
$action_icons .= "<a href=\"index.php?".api_get_cidreq()."&view_received_category=".Security::remove_XSS($_GET['view_received_category'])."&view_sent_category=".Security::remove_XSS($_GET['view_sent_category'])."&view=".Security::remove_XSS($_GET['view']).'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>";
$action_icons .= "<a href=\"index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>";
$action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
}
$dropbox_file_data[] = $action_icons;
@ -624,7 +547,7 @@ if ($action != 'add') {
$dropbox_category_data = array();
if ($category['sent'] == '1') {
$dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear.
$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.$category['cat_id'].'&amp;view='.Security::remove_XSS($_GET['view']).'">';
$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$category['cat_id'].'&amp;view='.$view.'">';
$dropbox_category_data[] = $link_open.build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
$dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>';
//$dropbox_category_data[] = '';
@ -632,9 +555,9 @@ if ($action != 'add') {
//$dropbox_category_data[] = '';
$dropbox_category_data[] = '';
$dropbox_category_data[] = '';
$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=editcategory&id='.$category['cat_id'].'">'.
$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=editcategory&id='.$category['cat_id'].'">'.
Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletesentcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.
<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletesentcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
}
if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
@ -643,7 +566,7 @@ if ($action != 'add') {
}
}
// Displaying the table
$additional_get_parameters = array('view' => Security::remove_XSS($_GET['view']), 'view_received_category' => Security::remove_XSS($_GET['view_received_category']), 'view_sent_category' => Security::remove_XSS($_GET['view_sent_category']));
$additional_get_parameters = array('view' => $view, 'view_received_category' => $viewReceivedCategory, 'view_sent_category' => $viewSentCategory);
$selectlist = array('delete_received' => get_lang('Delete'), 'download_received' => get_lang('Download'));
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
$selectlist = array('download_received' => get_lang('Download'));

Loading…
Cancel
Save