Feature #272 - Edition of comments in "Dropbox" tool. Function simplification in "Assignments" tool.

skala
Ivan Tcholakov 15 years ago
parent 02c7a86e61
commit 6928690ac0
  1. 152
      main/dropbox/dropbox_class.inc.php
  2. 4
      main/dropbox/dropbox_config.inc.php
  3. 17
      main/dropbox/dropbox_download.php
  4. 27
      main/dropbox/dropbox_functions.inc.php
  5. 23
      main/dropbox/dropbox_init.inc.php
  6. 38
      main/dropbox/dropbox_submit.php
  7. 65
      main/dropbox/index.php
  8. 17
      main/work/work.php
  9. 1
      tests/main/dropbox/dropbox_functions.inc.test.php

@ -8,38 +8,37 @@
* 3 classes have been defined:
* - Dropbox_Work:
* . id
* . uploader_id => who sent it // RH: Mailing: or mailing pseudo_id
* . uploader_id => who sent it
* . uploaderName
* . filename => name of file stored on the server
* . filesize // RH: Mailing: zero for sent zip
* . 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
* . last_upload_date => date when file was last sent
* . isOldWork => has the work already been uploaded before
*
* . feedback_date => date of most recent feedback // RH: Feedback
* . feedback => feedback text (or HTML?) // RH: Feedback
* . 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
* // RH: Mailing: or mailing pseudo_id
* ["feedback_date"]["feedback"] // RH: Feedback
*
* - 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
* . _orderBy => private property used for determining the field by which the works have to be ordered
*
* @version 1.30
* @copyright 2004
* @author Jan Bols <jan@ivpv.UGent.be>
* with contributions by René Haentjens <rene.haentjens@UGent.be> (see RH)
* with contributions by René Haentjens <rene.haentjens@UGent.be>
* @package chamilo.dropbox
*/
class Dropbox_Work {
@ -54,7 +53,7 @@ class Dropbox_Work {
public $upload_date;
public $last_upload_date;
public $isOldWork;
public $feedback_date, $feedback; // RH: Feedback
public $feedback_date, $feedback;
/**
* Constructor calls private functions to create a new work or retreive an existing work from DB
@ -69,7 +68,6 @@ class Dropbox_Work {
* @return Dropbox_Work
*/
function Dropbox_Work($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null) {
if (func_num_args() > 1) {
$this->_createNewWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
} else {
@ -146,7 +144,7 @@ class Dropbox_Work {
)";
$result = Database::query($sql);
$this->id = Database::insert_id(); //get automatically inserted id
$this->id = Database::insert_id(); // Get automatically inserted id
}
// Insert entries into person table
@ -164,13 +162,13 @@ class Dropbox_Work {
* @param unknown_type $id
*/
function _createExistingWork($id) {
global $_user, $dropbox_cnf; // RH: Feedback
global $_user, $dropbox_cnf;
// Do some sanity checks
settype($id, 'integer') or die(get_lang('GeneralError').' (code 205)'); //set $id to correct type
settype($id, 'integer') or die(get_lang('GeneralError').' (code 205)'); // Set $id to correct type
$id = intval($id);
// get the data from DB
// Get the data from DB
$sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
FROM ".$dropbox_cnf['tbl_file']."
WHERE id='".Database::escape_string($id)."'";
@ -212,7 +210,6 @@ class Dropbox_Work {
$this->feedback2= $feedback2;
}
/*
// RH: Feedback
$result = Database::query("SELECT feedback_date, feedback, cat_id FROM ".
dropbox_cnf('tbl_post')." WHERE dest_user_id='".$_user['user_id'].
"' AND file_id='".$id."'");
@ -267,13 +264,13 @@ class Dropbox_SentWork extends Dropbox_Work
// Do sanity checks on recipient_ids array & property fillin
// The sanity check for ex-coursemembers is already done in base constructor
settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); //set $uploader_id to correct type
settype($uploader_id, 'integer') or die(get_lang('GeneralError').' (code 208)'); // Set $uploader_id to correct type
$justSubmit = false; // RH: mailing zip-file or just upload
$justSubmit = false;
if ( is_int($recipient_ids)) {
$justSubmit = true;
$recipient_ids = array($recipient_ids + $this->id);
} elseif ( count($recipient_ids) == 0) { // RH: Just Upload
} elseif ( count($recipient_ids) == 0) {
$justSubmit = true;
$recipient_ids = array($uploader_id);
}
@ -292,7 +289,7 @@ class Dropbox_SentWork extends Dropbox_Work
$sql = "INSERT INTO ".$dropbox_cnf['tbl_post']."
(file_id, dest_user_id, session_id)
VALUES ('".Database::escape_string($this->id)."', '".Database::escape_string($rec['id'])."', ".intval($_SESSION['id_session']).")";
$result = Database::query($sql); //if work already exists no error is generated
$result = Database::query($sql); // If work already exists no error is generated
// Insert entries into person table
$sql = "INSERT INTO ".$dropbox_cnf['tbl_person']."
@ -300,14 +297,14 @@ class Dropbox_SentWork extends Dropbox_Work
VALUES ('".Database::escape_string($this->id)."'
, '".Database::escape_string($rec['id'])."'
)";
// RH: do not add recipient in person table if mailing zip or just upload
// Do not add recipient in person table if mailing zip or just upload.
if (!$justSubmit) {
$result = Database::query($sql); //if work already exists no error is generated
$result = Database::query($sql); // If work already exists no error is generated
}
// Update item_property (previously last_tooledit) table for each recipient
// Update item_property table for each recipient
global $_course, $dropbox_cnf;
if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
$ownerid = getUserOwningThisMailing($ownerid);
}
@ -325,20 +322,21 @@ class Dropbox_SentWork extends Dropbox_Work
*/
function _createExistingSentWork ($id) {
global $dropbox_cnf;
// Call constructor of Dropbox_Work object
$this->Dropbox_Work($id);
// Do sanity check. The sanity check for ex-coursemembers is already done in base constructor
settype($id, 'integer') or die(get_lang('GeneralError').' (code 211)'); //set $id to correct type
settype($id, 'integer') or die(get_lang('GeneralError').' (code 211)'); // Set $id to correct type
// Fill in recipients array/
$this->recipients = array(); // RH: Feedback: added to SELECT
// Fill in recipients array
$this->recipients = array();
$sql = "SELECT dest_user_id, feedback_date, feedback
FROM ".$dropbox_cnf['tbl_post']."
WHERE file_id='".Database::escape_string($id)."'";
$result = Database::query($sql);
while ($res = Database::fetch_array($result)) {
// check for deleted users
// Check for deleted users
$dest_user_id = $res['dest_user_id'];
$recipientName = getUserNameFromId($dest_user_id);
//$this->category = $res['cat_id'];
@ -346,7 +344,7 @@ class Dropbox_SentWork extends Dropbox_Work
$this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
} else {
$this->recipients[] = array('id' => $dest_user_id, 'name' => $recipientName, 'user_id' => $dest_user_id,
'feedback_date' => $res['feedback_date'], 'feedback' => $res['feedback']); // RH: Feedback
'feedback_date' => $res['feedback_date'], 'feedback' => $res['feedback']);
}
}
}
@ -354,13 +352,14 @@ class Dropbox_SentWork extends Dropbox_Work
class Dropbox_Person
{
public $receivedWork; //array of Dropbox_Work objects
public $sentWork; //array of Dropbox_SentWork objects
// The receivedWork and the sentWork arrays are sorted.
public $receivedWork; // an array of Dropbox_Work objects
public $sentWork; // an array of Dropbox_SentWork objects
public $userId = 0;
public $isCourseAdmin = false;
public $isCourseTutor = false;
public $_orderBy = ''; //private property that determines by which field
//the receivedWork and the sentWork arrays are sorted
public $_orderBy = ''; // private property that determines by which field
/**
* Constructor for recreating the Dropbox_Person object
@ -378,7 +377,7 @@ class Dropbox_Person
$this->receivedWork = array();
$this->sentWork = array();
//Note: perhaps include an ex coursemember check to delete old files
// Note: perhaps include an ex coursemember check to delete old files
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
@ -386,7 +385,7 @@ class Dropbox_Person
$post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
$person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
$file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
// find all entries where this person is the recipient
// Find all entries where this person is the recipient
$sql = "SELECT r.file_id, r.cat_id
FROM $post_tbl r, $person_tbl p
WHERE r.dest_user_id = '".Database::escape_string($this->userId)."'
@ -402,7 +401,7 @@ class Dropbox_Person
$this->receivedWork[] = $temp;
}
// find all entries where this person is the sender/uploader
// Find all entries where this person is the sender/uploader
$sql = "SELECT f.id
FROM $file_tbl f, $person_tbl p
WHERE f.uploader_id = '".Database::escape_string($this->userId)."'
@ -431,13 +430,13 @@ class Dropbox_Person
$sort = $this->_orderBy;
$aval = $a->$sort;
$bval = $b->$sort;
if ($sort == 'recipients') { //the recipients property is an array so we do the comparison based on the first item of the recipients array
if ($sort == 'recipients') { // The recipients property is an array so we do the comparison based on the first item of the recipients array
$aval = $aval[0]['name'];
$bval = $bval[0]['name'];
}
if ($sort == 'filesize') { //filesize is not a string, so we use other comparison technique
if ($sort == 'filesize') { // Filesize is not a string, so we use other comparison technique
return $aval < $bval ? -1 : 1;
} elseif ($sort == 'title') { // natural order for sorting titles is more "human-friendly"
} elseif ($sort == 'title') { // Natural order for sorting titles is more "human-friendly"
return api_strnatcmp($aval, $bval);
} else {
return api_strcasecmp($aval, $bval);
@ -445,15 +444,12 @@ class Dropbox_Person
}
/**
* method that sorts the objects in the sentWork array, dependent on the $sort parameter.
* A method that sorts the objects in the sentWork array, dependent on the $sort parameter.
* $sort can be lastDate, firstDate, title, size, ...
*
* @param unknown_type $sort
*/
function orderSentWork($sort) {
/*
*/
switch($sort) {
case 'lastDate':
$this->_orderBy = 'last_upload_date';
@ -475,9 +471,9 @@ class Dropbox_Person
break;
default:
$this->_orderBy = 'last_upload_date';
} // switch
}
usort($this->sentWork, array($this, '_cmpWork')); //this calls the _cmpWork method
usort($this->sentWork, array($this, '_cmpWork'));
}
/**
@ -507,23 +503,21 @@ class Dropbox_Person
break;
default:
$this->_orderBy = 'last_upload_date';
} // switch
}
usort($this->receivedWork, array($this, '_cmpWork')); //this calls the _cmpWork method
usort($this->receivedWork, array($this, '_cmpWork'));
}
/**
* Deletes all the received work of this person
*
*/
function deleteAllReceivedWork () {
global $dropbox_cnf;
//delete entries in person table concerning received works
// Delete entries in person table concerning received works
foreach ($this->receivedWork as $w) {
Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'");
}
removeUnusedFiles(); //check for unused files
removeUnusedFiles(); // Check for unused files
}
/**
@ -532,7 +526,6 @@ class Dropbox_Person
function deleteReceivedWorkFolder($id) {
global $dropbox_cnf;
$id = intval($id);
$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']." where cat_id = '".$id."' ";
if (!Database::query($sql)) return false;
$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']." where cat_id = '".$id."' ";
@ -547,38 +540,39 @@ class Dropbox_Person
*
* @param integer $id
*/
function deleteReceivedWork ($id) {
$id = intval($id);
function deleteReceivedWork($id) {
global $dropbox_cnf;
//id check
$id = intval($id);
// index check
$found = false;
foreach($this->receivedWork as $w) {
foreach ($this->receivedWork as $w) {
if ($w->id == $id) {
$found = true;
break;
}
}
if (! $found) {
if (!$found) {
if(!$this->deleteReceivedWorkFolder($id)) {
die(get_lang('GeneralError').' (code 216)');
}
}
//delete entries in person table concerning received works
// Delete entries in person table concerning received works
Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE user_id='".$this->userId."' AND file_id='".$id."'");
removeUnusedFiles(); //check for unused files
removeUnusedFiles(); // Check for unused files
}
/**
* Deletes all the sent dropbox files of this person
*/
function deleteAllSentWork () {
function deleteAllSentWork() {
global $dropbox_cnf;
//delete entries in person table concerning sent works
foreach ($this->sentWork as $w) {
Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE user_id='".$this->userId."' AND file_id='".$w->id."'");
removeMoreIfMailing($w->id); // RH: Mailing: see init1
removeMoreIfMailing($w->id);
}
removeUnusedFiles(); //check for unused files
removeUnusedFiles(); // Check for unused files
}
/**
@ -586,28 +580,28 @@ class Dropbox_Person
*
* @param unknown_type $id
*/
function deleteSentWork ($id) {
function deleteSentWork($id) {
global $dropbox_cnf;
$id = intval($id);
global $dropbox_cnf;
//index check
// index check
$found = false;
foreach($this->sentWork as $w) {
foreach ($this->sentWork as $w) {
if ($w->id == $id) {
$found = true;
break;
}
}
if (!$found) {
if(!$this->deleteReceivedWorkFolder($id)) {
if (!$this->deleteReceivedWorkFolder($id)) {
die(get_lang('GeneralError').' (code 219)');
}
}
//$file_id = $this->sentWork[$index]->id; // RH: Mailing
//delete entries in person table concerning sent works
//$file_id = $this->sentWork[$index]->id;
// Delete entries in person table concerning sent works
Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE user_id='".$this->userId."' AND file_id='".$id."'");
removeMoreIfMailing($id); // RH: Mailing: see init1
removeUnusedFiles(); //check for unused files
removeMoreIfMailing($id);
removeUnusedFiles(); // Check for unused files
}
/**
@ -620,16 +614,17 @@ class Dropbox_Person
global $_course, $dropbox_cnf;
$id = intval($id);
//id check
$found = false; $wi = -1;
foreach($this->receivedWork as $w) {
// index check
$found = false;
$wi = -1;
foreach ($this->receivedWork as $w) {
$wi++;
if ($w->id == $id){
$found = true;
break;
} // foreach (... as $wi -> $w) gives error 221! (no idea why...)
}
if (! $found) {
if (!$found) {
die(get_lang('GeneralError').' (code 221)');
}
@ -641,7 +636,7 @@ class Dropbox_Person
Database::escape_string($feedback_date)."', feedback='".Database::escape_string($text).
"' WHERE dest_user_id='".$this->userId."' AND file_id='".$id."'");
//update item_property (previously last_tooledit) table
// Update item_property table
if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
$ownerid = getUserOwningThisMailing($ownerid);
@ -655,7 +650,7 @@ class Dropbox_Person
* @param string $type
* @param string $value
*/
function filter_received_work($type,$value) {
function filter_received_work($type, $value) {
global $dropbox_cnf;
$new_received_work = array();
@ -663,8 +658,7 @@ class Dropbox_Person
switch ($type) {
case 'uploader_id':
if ($work->uploader_id == $value ||
($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
getUserOwningThisMailing($work->uploader_id) == $value)) {
($work->uploader_id > $dropbox_cnf['mailingIdBase'] && getUserOwningThisMailing($work->uploader_id) == $value)) {
$new_received_work[] = $work;
}
break;

@ -4,7 +4,7 @@
/**
* DEBUGGING VARS
*/
$DEBUG = false;
$DEBUG = false; // TODO: Is this needed?
/**
* DATABASE TABLE VARIABLES
@ -32,7 +32,7 @@ $dropbox_cnf['allowStudentToStudent'] = string_2_boolean(api_get_setting('dropb
$dropbox_cnf['allowGroup'] = string_2_boolean(api_get_setting('dropbox_allow_group'));
/**
* RH: INITIALISE MAILING VARIABLES
* INITIALISE MAILING VARIABLES
*/
$dropbox_cnf['allowMailing'] = string_2_boolean(api_get_setting('dropbox_allow_mailing')); // false = no mailing functionality
$dropbox_cnf['mailingIdBase'] = 10000000; // bigger than any user_id,

@ -19,7 +19,7 @@ require_once 'dropbox_functions.inc.php';
// the dropbox class
require_once 'dropbox_class.inc.php';
require_once api_get_path(LIBRARY_PATH).'/document.lib.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
/* DOWNLOAD A FOLDER */
@ -231,7 +231,7 @@ else {
* @version 1.21
* @copyright 2004-2005
* @author Jan Bols <jan@ivpv.UGent.be>, main programmer
* @author René Haentjens <rene.haentjens@UGent.be>, several contributions (see RH)
* @author René Haentjens <rene.haentjens@UGent.be>, several contributions
* @author Roan Embrechts, virtual course support
*
* @package chamilo.dropbox
@ -249,8 +249,9 @@ if (!isset($_user['user_id']) || !$is_course_member) {
exit();
}
if ($_GET['mailing']) // RH: Mailing detail window call
getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '500'); // RH or die
if ($_GET['mailing']) {
getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '500');
}
/* SANITY CHECKS OF GET DATA & FILE */
@ -269,7 +270,7 @@ if (!is_file($path)) {
/* SEND HEADERS */
require_once api_get_path(LIBRARY_PATH) . '/document.lib.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
$mimetype = DocumentManager::file_get_mime_type(true);
$fileparts = explode('.', $file);
@ -296,9 +297,9 @@ if (!in_array(strtolower($fileparts [$filepartscount - 1]), array('doc', 'xls',
* before sending a file to the browser, the "Open" option on Internet Explorer's file download dialog will not work properly. If the user clicks "Open" instead of "Save," the target application will open an empty file, because the downloaded file was not cached. The user will have to save the file to their hard drive in order to use it.
* Make sure to leave these headers out if you'd like your visitors to be able to use IE's "Open" option.
*/
header( "Pragma: \n");
header( "Cache-Control: \n");
header( "Cache-Control: public\n"); // IE cannot download from sessions without a cache
header("Pragma: \n");
header("Cache-Control: \n");
header("Cache-Control: public\n"); // IE cannot download from sessions without a cache
/*if (isset($_SERVER['HTTPS'])) {
/**

@ -547,12 +547,14 @@ function display_add_form() {
$current_user_id = '';
foreach ($complete_user_list_for_dropbox as $current_user) {
if (($dropbox_person -> isCourseTutor
|| $dropbox_person -> isCourseAdmin
|| dropbox_cnf('allowStudentToStudent') // RH: also if option is set
|| $current_user['status'] != 5 // always allow teachers
|| $current_user['tutor_id'] == 1 // always allow tutors
) && $current_user['user_id'] != $_user['user_id']) { // don't include yourself
if ($current_user['user_id'] == $current_user_id) continue;
|| $dropbox_person -> isCourseAdmin
|| dropbox_cnf('allowStudentToStudent')
|| $current_user['status'] != 5 // Always allow teachers.
|| $current_user['tutor_id'] == 1 // Always allow tutors.
) && $current_user['user_id'] != $_user['user_id']) { // Don't include yourself.
if ($current_user['user_id'] == $current_user_id) {
continue;
}
$full_name = $current_user['lastcommafirst'];
$current_user_id = $current_user['user_id'];
echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>';
@ -575,11 +577,11 @@ function display_add_form() {
}
}
if (($dropbox_person -> isCourseTutor || $dropbox_person -> isCourseAdmin) && dropbox_cnf('allowMailing')) { // RH: Mailing starting point
if (($dropbox_person -> isCourseTutor || $dropbox_person -> isCourseAdmin) && dropbox_cnf('allowMailing')) {
// echo '<option value="mailing">'.get_lang('MailingInSelect').'</option>';
}
if (dropbox_cnf('allowJustUpload')) { // RH
if (dropbox_cnf('allowJustUpload')) {
//echo '<option value="upload">'.get_lang('JustUploadInSelect').'</option>';
echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>';
}
@ -606,7 +608,7 @@ function display_add_form() {
* returns username or false if user isn't registered anymore
* @todo check if this function is still necessary. There might be a library function for this.
*/
function getUserNameFromId($id) { // RH: Mailing: return 'Mailing ' + id
function getUserNameFromId($id) {
global $dropbox_cnf;
$mailingId = $id - dropbox_cnf('mailingIdBase');
@ -675,7 +677,6 @@ function removeUnusedFiles() {
}
/**
* RH: Mailing (2 new functions)
*
* Mailing zip-file is posted to (dest_user_id = ) mailing pseudo_id
* and is only visible to its uploader (user_id).
@ -770,8 +771,8 @@ function store_add_dropbox() {
}
// Check if all the recipients are valid
else {
$thisIsAMailing = false; // RH: Mailing selected as destination
$thisIsJustUpload = false; // RH
$thisIsAMailing = false;
$thisIsJustUpload = false;
foreach ($_POST['recipients'] as $rec) {
if ($rec == 'mailing') {
$thisIsAMailing = true;
@ -847,7 +848,7 @@ function store_add_dropbox() {
// 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) { // RH: Mailing: adapted
if ($dropbox_overwrite) {
$dropbox_person = new Dropbox_Person($_user['user_id'], api_is_course_admin(), api_is_course_tutor());
foreach ($dropbox_person->sentWork as $w) {

@ -11,7 +11,7 @@
* @version 1.31
* @copyright 2004-2005
* @author Jan Bols <jan@ivpv.UGent.be>, main programmer
* @author René Haentjens, severalcontributions <rene.haentjens@UGent.be> (see RH)
* @author René Haentjens, severalcontributions <rene.haentjens@UGent.be>
* @author Roan Embrechts, virtual course support
* @author Patrick Cool <patrick.cool@UGent.be>
Chamilo Config Settings (AWACS)
@ -34,7 +34,7 @@ $language_file = 'dropbox';
// including the basic Chamilo initialisation file
require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'security.lib.php';
require_once api_get_path(LIBRARY_PATH).'security.lib.php';
// the dropbox configuration parameters
require_once 'dropbox_config.inc.php';
@ -45,28 +45,28 @@ require_once 'dropbox_config.inc.php';
// the dropbox file that contains additional functions
require_once 'dropbox_functions.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
// protecting the script
api_protect_course_script();
/* Libraries */
require_once api_get_path(LIBRARY_PATH) . 'debug.lib.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'course.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php'; // TODO: Is this needed? Another technology is used for testing/debugging now.
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
// including the library for the sortable table
require_once api_get_path(LIBRARY_PATH) . 'tablesort.lib.php';
require_once api_get_path(LIBRARY_PATH).'tablesort.lib.php';
// including the library for the dropbox
require_once 'dropbox_class.inc.php';
// including some libraries that are also used in the documents tool
require_once api_get_path(SYS_CODE_PATH) . 'document/document.inc.php'; // we use a function build_document_icon_tag
require_once api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php'; // the function choose_image is used
require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php'; // we use a function build_document_icon_tag
require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php'; // the function choose_image is used
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
/* Virtual course support */
@ -90,7 +90,6 @@ if ($_GET['action'] == 'add') {
}
/* Create javascript and htmlHeaders */
// RH: Mailing: new function confirmsend
$javascript = "<script type=\"text/javascript\">
function confirmsend ()

@ -63,8 +63,8 @@ if (isset($_POST['submitWork'])) {
$error = true;
$errormsg = get_lang('NoUserSelected');
} else {
$thisIsAMailing = false; // RH: Mailing selected as destination
$thisIsJustUpload = false; // RH
$thisIsAMailing = false;
$thisIsJustUpload = false;
foreach ($_POST['recipients'] as $rec) {
if ($rec == 'mailing') {
@ -138,7 +138,7 @@ if (isset($_POST['submitWork'])) {
$_POST['authors'] = getUserNameFromId($_user['user_id']);
}
if ($dropbox_overwrite) { // RH: Mailing: adapted
if ($dropbox_overwrite) {
$dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
foreach ($dropbox_person->sentWork as $w) {
@ -175,17 +175,17 @@ if (isset($_POST['submitWork'])) {
}
if ($error) {}
elseif ($thisIsAMailing) { // RH: $newWorkRecipients is integer - see class
elseif ($thisIsAMailing) {
if (preg_match(dropbox_cnf('mailingZipRegexp'), $dropbox_title)) {
$newWorkRecipients = dropbox_cnf('mailingIdBase');
} else {
$error = true;
$errormsg = $dropbox_title . ': ' . get_lang('MailingWrongZipfile');
}
} elseif ( $thisIsJustUpload) { // RH: $newWorkRecipients is empty array
} elseif ($thisIsJustUpload) {
$newWorkRecipients = array();
} else {
// creating the array that contains all the users who will receive the file
// Creating the array that contains all the users who will receive the file
$newWorkRecipients = array();
foreach ($_POST['recipients'] as $rec) {
if (strpos($rec, 'user_') === 0) {
@ -226,7 +226,7 @@ if (isset($_POST['submitWork'])) {
/**
* RH: EXAMINE OR SEND MAILING (NEW)
* EXAMINE OR SEND MAILING (NEW)
*/
if (isset($_GET['mailingIndex'])) { // examine or send
@ -427,24 +427,22 @@ if (isset($_GET['mailingIndex'])) { // examine or send
/**
* DELETE RECEIVED OR SENT FILES - EDIT FEEDBACK // RH: Feedback
* DELETE RECEIVED OR SENT FILES - EDIT FEEDBACK
* - DELETE ALL RECEIVED FILES
* - DELETE 1 RECEIVED FILE
* - DELETE ALL SENT FILES
* - DELETE 1 SENT FILE
* - EDIT FEEDBACK // RH: Feedback
* - EDIT FEEDBACK
*/
if (isset($_GET['deleteReceived']) || isset($_GET['deleteSent'])
|| isset( $_GET['showFeedback']) || isset( $_GET['editFeedback'])) { // RH: Feedback
if ($_GET['mailing']) { // RH: Mailing
getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '408'); // RH or die
|| isset( $_GET['showFeedback']) || isset( $_GET['editFeedback'])) {
if ($_GET['mailing']) {
getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '408');
$dropbox_person = new Dropbox_Person($_GET['mailing'], $is_courseAdmin, $is_courseTutor);
} else {
$dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
}
// RH: these two are needed, I think
if (isset($_SESSION['sentOrder'])) {
$dropbox_person->orderSentWork($_SESSION['sentOrder']);
}
@ -456,7 +454,7 @@ if (isset($_GET['deleteReceived']) || isset($_GET['deleteSent'])
die(get_lang('GeneralError').' (code 408)');
}*/
$tellUser = get_lang('FileDeleted'); // RH: Feedback
$tellUser = get_lang('FileDeleted');
if (isset($_GET['deleteReceived'])) {
if ($_GET['deleteReceived'] == 'all') {
@ -466,7 +464,7 @@ if (isset($_GET['deleteReceived']) || isset($_GET['deleteSent'])
} else {
die(get_lang('GeneralError').' (code 409)');
}
} elseif (isset( $_GET['deleteSent'])) { // RH: Feedback
} elseif (isset( $_GET['deleteSent'])) {
if ($_GET['deleteSent'] == 'all') {
$dropbox_person->deleteAllSentWork( );
} elseif (is_numeric($_GET['deleteSent'])) {
@ -474,11 +472,11 @@ if (isset($_GET['deleteReceived']) || isset($_GET['deleteSent'])
} else {
die(get_lang('GeneralError').' (code 410)');
}
} elseif (isset($_GET['showFeedback'])) { // RH: Feedback
} elseif (isset($_GET['showFeedback'])) {
$w = new Dropbox_SentWork($id = $_GET['showFeedback']);
if ($w->uploader_id != $_user['user_id']) {
getUserOwningThisMailing($w->uploader_id, $_user['user_id'], '411'); // RH or die
getUserOwningThisMailing($w->uploader_id, $_user['user_id'], '411');
}
foreach ($w -> recipients as $r) {
@ -497,7 +495,7 @@ if (isset($_GET['deleteReceived']) || isset($_GET['deleteSent'])
$tellUser = get_lang('ShowFeedback');
} else { // if ( isset( $_GET['editFeedback'])) { // RH: Feedback
} else { // if ( isset( $_GET['editFeedback'])) {
$id = $_GET['editFeedback'];
$found = false;
foreach ($dropbox_person->receivedWork as $w) {
@ -519,7 +517,7 @@ if (isset($_GET['deleteReceived']) || isset($_GET['deleteSent'])
}
/**
* RESULTMESSAGE FOR DELETE FILE OR EDIT FEEDBACK // RH: Feedback
* RESULTMESSAGE FOR DELETE FILE OR EDIT FEEDBACK
*/
$return_message = get_lang('BackList');
}

@ -8,7 +8,7 @@
* @version 1.3
*
* @author Jan Bols <jan@ivpv.UGent.be>, main programmer, initial version
* @author René Haentjens <rene.haentjens@UGent.be>, several contributions (see RH)
* @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)
*
@ -70,7 +70,7 @@ Version 1.2
- 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 (see RH comments in code)
- mailing functionality (René Haentjens)
- allowStudentToStudent and allowJustUpload options (id.)
- help in separate window (id.)
@ -91,7 +91,7 @@ Version 1.4 (Yannick Warnier)
/* INIT SECTION */
// the file that contains all the initialisation stuff (and includes all the configuration stuff)
// The file that contains all the initialisation stuff (and includes all the configuration stuff)
require_once 'dropbox_init.inc.php';
// get the last time the user accessed the tool
@ -102,15 +102,14 @@ if ($_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') {
$last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX];
}
// do the tracking
// Do the tracking
event_access_tool(TOOL_DROPBOX);
//this var is used to give a unique value to every page request. This is to prevent resubmiting data
// 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 */
// Tool introduction
Display::display_introduction_section(TOOL_DROPBOX);
/* ACTIONS: add a dropbox file, add a dropbox category. */
@ -127,11 +126,11 @@ if (isset($_POST['submitWork'])) {
$check = Security::check_token();
if ($check) {
Display :: display_confirmation_message(store_add_dropbox());
//include_once('dropbox_submit.php');
//require_once 'dropbox_submit.php';
}
}
// display the form for adding a category
// Display the form for adding a category
if ($_GET['action'] == 'addreceivedcategory' or $_GET['action'] == 'addsentcategory') {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
@ -139,7 +138,7 @@ if ($_GET['action'] == 'addreceivedcategory' or $_GET['action'] == 'addsentcateg
display_addcategory_form($_POST['category_name'],'',$_GET['action']);
}
// editing a category: displaying the form
// Editing a category: displaying the form
if ($_GET['action'] == 'editcategory' and isset($_GET['id'])) {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
@ -152,7 +151,7 @@ if ($_GET['action'] == 'editcategory' and isset($_GET['id'])) {
}
}
// storing a new or edited category
// Storing a new or edited category
if (isset($_POST['StoreCategory'])) {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
@ -239,9 +238,9 @@ if (isset($_GET['error']) AND !empty($_GET['error'])) {
if ($_GET['action'] != 'add') {
// getting all the categories in the dropbox for the given user
// Getting all the categories in the dropbox for the given user
$dropbox_categories = get_dropbox_categories();
// creating the arrays with the categories for the received files and for the sent files
// Greating the arrays with the categories for the received files and for the sent files
foreach ($dropbox_categories as $category) {
if ($category['received'] == '1') {
$dropbox_received_category[] = $category;
@ -356,17 +355,17 @@ if ($_GET['action'] != 'add') {
$view_dropbox_category_received = 0;
}
// object initialisation
// Object initialisation
$dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor); // note: are the $is_courseAdmin and $is_courseTutor parameters needed????
// constructing the array that contains the total number of feedback messages per document.
// Constructing the array that contains the total number of feedback messages per document.
$number_feedback = get_total_number_feedback();
// sorting and paging options
// Sorting and paging options
$sorting_options = array();
$paging_options = array();
// the headers of the sortable tables
// The headers of the sortable tables
$column_header = array();
$column_header[] = array('', false, '');
$column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
@ -411,7 +410,7 @@ if ($_GET['action'] != 'add') {
$column_order[] = 7;
$column_order[] = 8;
// the content of the sortable table = the received files
// The content of the sortable table = the received files
foreach ($dropbox_person -> receivedWork as $dropbox_file) {
$dropbox_file_data = array();
if ($view_dropbox_category_received == $dropbox_file->category) { // we only display the files that are in the category that we are in.
@ -421,7 +420,7 @@ if ($_GET['action'] != 'add') {
$_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array();
}
// new icon
// New icon
$new_icon = '';
if ($dropbox_file->last_upload_date > $last_access AND !in_array($dropbox_file->id, $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
$new_icon = '&nbsp;'.Display::return_icon('new.gif', get_lang('New'));
@ -441,10 +440,10 @@ if ($_GET['action'] != 'add') {
<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.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
//$action_icons=' <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'">'.Display::return_icon('deplacer.gif',get_lang('Move')).'</a>
// <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
// this is a hack to have an additional row in a sortable table
// This is a hack to have an additional row in a sortable table
if ($_GET['action'] == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
$action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
$action_icons .= "</td></tr>\n"; // 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'])."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td>\n</tr>\n";
}
if (api_get_session_id() == 0) {
@ -453,21 +452,19 @@ if ($_GET['action'] != 'add') {
$dropbox_file_data[] = $action_icons;
}
$action_icons = '';
$dropbox_file_data[] = $dropbox_file->last_upload_date; //date
$dropbox_data_recieved[] = $dropbox_file_data;
}
}
// the content of the sortable table = the categories (if we are not in the root)
// The content of the sortable table = the categories (if we are not in the root)
if ($view_dropbox_category_received == 0) {
foreach ($dropbox_categories as $category) { // note: this can probably be shortened since the categories for the received files are already in the $dropbox_received_category array;
foreach ($dropbox_categories as $category) { // Note: This can probably be shortened since the categories for the received files are already in the $dropbox_received_category array;
$dropbox_category_data = array();
if ($category['received'] == '1') {
$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
$dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear
// The icon of the category
$dropbox_category_data[] = build_document_icon_tag('folder', $category['cat_name']);
$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('folder_zip.gif', get_lang('Save'), array('width' => '16px', 'height' => '16px', 'style' => 'float:right;')).'</a><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']).'">'.$category['cat_name'].'</a>';
$dropbox_category_data[] = '';
@ -509,17 +506,17 @@ if ($_GET['action'] != 'add') {
$view_dropbox_category_sent = 0;
}
// object initialisation
// Object initialisation
$dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor);
// constructing the array that contains the total number of feedback messages per document.
// Constructing the array that contains the total number of feedback messages per document.
$number_feedback = get_total_number_feedback();
// sorting and paging options
// Sorting and paging options
$sorting_options = array();
$paging_options = array();
// the headers of the sortable tables
// The headers of the sortable tables
$column_header = array();
$column_header[] = array('', false, '');
@ -567,7 +564,7 @@ if ($_GET['action'] != 'add') {
$column_order[] = 7;
$column_order[] = 8;
// the content of the sortable table = the received files
// The content of the sortable table = the received files
foreach ($dropbox_person -> sentWork as $dropbox_file) {
$dropbox_file_data = array();
@ -589,7 +586,7 @@ if ($_GET['action'] != 'add') {
<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.'">'.Display::return_icon('comment_bubble.gif', get_lang('Comment')).'</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.'">'.Display::return_icon('deplacer_fichier.gif', get_lang('Move')).'</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.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
// this is a hack to have an additional row in a sortable table
// This is a hack to have an additional row in a sortable table
if ($_GET['action'] == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id==$_GET['id']) {
$action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
$action_icons .= "<tr>\n\t<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'])."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td>\n</tr>\n";
@ -601,7 +598,7 @@ if ($_GET['action'] != 'add') {
}
}
// the content of the sortable table = the categories (if we are not in the root)
// The content of the sortable table = the categories (if we are not in the root)
if ($view_dropbox_category_sent == 0) {
foreach ($dropbox_categories as $category) {
$dropbox_category_data = array();
@ -615,7 +612,7 @@ if ($_GET['action'] != 'add') {
$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'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</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(\''.$category['cat_name'].'\');">'.Display::return_icon('delete.gif', get_lang('Delete')).'</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(\''.$category['cat_name'].'\');">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
}
if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
$dropbox_data_sent[] = $dropbox_category_data;

@ -1471,25 +1471,10 @@ function draw_date_picker($prefix, $default = '') {
list($d_year, $d_month, $d_day) = split('-', $parts[0]);
list($d_hour, $d_minute) = split(':', $parts[1]);
$month_list = array(
1=>get_lang('JanuaryLong'),
2=>get_lang('FebruaryLong'),
3=>get_lang('MarchLong'),
4=>get_lang('AprilLong'),
5=>get_lang('MayLong'),
6=>get_lang('JuneLong'),
7=>get_lang('JulyLong'),
8=>get_lang('AugustLong'),
9=>get_lang('SeptemberLong'),
10=>get_lang('OctoberLong'),
11=>get_lang('NovemberLong'),
12=>get_lang('DecemberLong')
);
$minute = range(10, 59);
array_unshift($minute, '00', '01', '02', '03', '04', '05', '06', '07', '08', '09');
$date_form = make_select($prefix.'_day', array_combine(range(1, 31), range(1, 31)), $d_day);
$date_form .= make_select($prefix.'_month', $month_list, $d_month);
$date_form .= make_select($prefix.'_month', array_combine(range(1, 12), api_get_months_long()), $d_month);
$date_form .= make_select($prefix.'_year', array($d_year => $d_year, $d_year + 1 => $d_year + 1), $d_year).'&nbsp;&nbsp;&nbsp;&nbsp;';
$date_form .= make_select($prefix.'_hour', array_combine(range(0, 23), range(0, 23)), $d_hour).' : ';
$date_form .= make_select($prefix.'_minute', $minute, $d_minute);

@ -186,7 +186,6 @@ class TestDropboxFunctions extends UnitTestCase {
}
/**
* RH: Mailing (2 new functions)
* Mailing zip-file is posted to (dest_user_id = ) mailing pseudo_id
* and is only visible to its uploader (user_id).
* Mailing content files have uploader_id == mailing pseudo_id, a normal recipient,

Loading…
Cancel
Save