|
@@ -37,10 +37,10 @@ function handle_multiple_actions() {
|
|
|
|
|
|
// STEP 2: at least one file has to be selected. If not we return an error message
|
|
|
$ids = Request::get('id', array());
|
|
|
- if(count($ids)>0){
|
|
|
+ if(count($ids)>0){
|
|
|
$checked_file_ids = $_POST['id'];
|
|
|
}
|
|
|
- else{
|
|
|
+ else{
|
|
|
foreach ($_POST as $key => $value) {
|
|
|
if (strstr($value, $part.'_') AND $key != 'view_received_category' AND $key != 'view_sent_category') {
|
|
|
$checked_files = true;
|
|
@@ -112,11 +112,11 @@ function delete_category($action, $id, $user_id = null) {
|
|
|
|
|
|
global $dropbox_cnf;
|
|
|
global $is_courseAdmin, $is_courseTutor;
|
|
|
-
|
|
|
+
|
|
|
if (empty($user_id)) {
|
|
|
$user_id = api_get_user_id();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$cat = get_dropbox_category($id);
|
|
|
if (count($cat)==0) { return false; }
|
|
|
if ($cat['user_id'] != $user_id && !api_is_platform_admin($user_id)) {
|
|
@@ -166,7 +166,8 @@ function delete_category($action, $id, $user_id = null) {
|
|
|
* @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())
|
|
|
+{
|
|
|
$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->addElement('header', get_lang('MoveFileTo'));
|
|
|
$form->addElement('hidden', 'id', intval($id));
|
|
@@ -194,12 +195,13 @@ function display_move_form($part, $id, $target = array(), $extra_params = array(
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
|
|
|
* @version march 2006
|
|
|
*/
|
|
|
-function store_move($id, $target, $part) {
|
|
|
+function store_move($id, $target, $part)
|
|
|
+{
|
|
|
global $_user, $dropbox_cnf;
|
|
|
$course_id = api_get_course_int_id();
|
|
|
|
|
|
if ((isset($id) AND $id != '') AND (isset($target) AND $target != '') AND (isset($part) AND $part != '')) {
|
|
|
-
|
|
|
+
|
|
|
if ($part == 'received') {
|
|
|
$sql = "UPDATE ".$dropbox_cnf["tbl_post"]." SET cat_id='".Database::escape_string($target)."'
|
|
|
WHERE c_id = $course_id AND dest_user_id='".Database::escape_string($_user['user_id'])."'
|
|
@@ -229,7 +231,8 @@ function store_move($id, $target, $part) {
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
|
|
|
* @version march 2006
|
|
|
*/
|
|
|
-function display_action_options($part, $categories, $current_category = 0) {
|
|
|
+function display_action_options($part, $categories, $current_category = 0)
|
|
|
+{
|
|
|
echo '<select name="actions">';
|
|
|
echo '<option value="download">'.get_lang('Download').'</option>';
|
|
|
echo '<option value="delete">'.get_lang('Delete').'</option>';
|
|
@@ -279,7 +282,8 @@ function display_file_checkbox($id, $part) {
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
|
|
|
* @version march 2006
|
|
|
*/
|
|
|
-function get_dropbox_categories($filter = '') {
|
|
|
+function get_dropbox_categories($filter = '')
|
|
|
+{
|
|
|
$course_id = api_get_course_int_id();
|
|
|
global $_user;
|
|
|
global $dropbox_cnf;
|
|
@@ -309,7 +313,7 @@ function get_dropbox_categories($filter = '') {
|
|
|
function get_dropbox_category($id) {
|
|
|
global $dropbox_cnf;
|
|
|
$course_id = api_get_course_int_id();
|
|
|
- if (empty($id) or $id != intval($id)) { return array(); }
|
|
|
+ if (empty($id) or $id != intval($id)) { return array(); }
|
|
|
$sql = "SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE c_id = $course_id AND cat_id='".$id."'";
|
|
|
$res = Database::query($sql);
|
|
|
if ($res === false) {
|
|
@@ -522,8 +526,8 @@ function display_add_form() {
|
|
|
}
|
|
|
$complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
|
|
|
}
|
|
|
-
|
|
|
- echo '<select name="recipients[]" size="10" multiple class="span4">';
|
|
|
+
|
|
|
+ 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
|
|
@@ -574,7 +578,6 @@ function display_add_form() {
|
|
|
echo '</select>
|
|
|
</div>
|
|
|
</div>';
|
|
|
-
|
|
|
echo '
|
|
|
<div class="control-group">
|
|
|
<div class="controls">
|
|
@@ -582,7 +585,6 @@ function display_add_form() {
|
|
|
</div>
|
|
|
</div>
|
|
|
';
|
|
|
-
|
|
|
echo '</form>';
|
|
|
}
|
|
|
|
|
@@ -645,20 +647,18 @@ function removeUnusedFiles() {
|
|
|
// select all files that aren't referenced anymore
|
|
|
$sql = "SELECT DISTINCT f.id, f.filename
|
|
|
FROM " . dropbox_cnf('tbl_file') . " f
|
|
|
- LEFT JOIN " . dropbox_cnf('tbl_person') . " p
|
|
|
+ LEFT JOIN " . dropbox_cnf('tbl_person') . " p
|
|
|
ON (f.id = p.file_id)
|
|
|
WHERE p.user_id IS NULL AND
|
|
|
- f.c_id = $course_id
|
|
|
+ f.c_id = $course_id
|
|
|
";
|
|
|
$result = Database::query($sql);
|
|
|
while ($res = Database::fetch_array($result)) {
|
|
|
-
|
|
|
//delete the selected files from the post and file tables
|
|
|
$sql = "DELETE FROM " . dropbox_cnf('tbl_post') . " WHERE c_id = $course_id AND file_id = '" . $res['id'] . "'";
|
|
|
Database::query($sql);
|
|
|
$sql = "DELETE FROM " . dropbox_cnf('tbl_file') . " WHERE c_id = $course_id AND id ='" . $res['id'] . "'";
|
|
|
Database::query($sql);
|
|
|
-
|
|
|
//delete file from server
|
|
|
@unlink( dropbox_cnf('sysPath') . '/' . $res['filename']);
|
|
|
}
|
|
@@ -676,7 +676,8 @@ function removeUnusedFiles() {
|
|
|
*
|
|
|
* @todo check if this function is still necessary.
|
|
|
*/
|
|
|
-function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '') {
|
|
|
+function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '')
|
|
|
+{
|
|
|
$course_id = api_get_course_int_id();
|
|
|
|
|
|
global $dropbox_cnf;
|
|
@@ -684,9 +685,9 @@ function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '') {
|
|
|
$sql = "SELECT f.uploader_id
|
|
|
FROM " . $dropbox_cnf['tbl_file'] . " f
|
|
|
LEFT JOIN " . $dropbox_cnf['tbl_post'] . " p ON (f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
|
|
|
- WHERE
|
|
|
- p.dest_user_id = '" . $mailingPseudoId . "' AND
|
|
|
- p.c_id = $course_id
|
|
|
+ WHERE
|
|
|
+ p.dest_user_id = '" . $mailingPseudoId . "' AND
|
|
|
+ p.c_id = $course_id
|
|
|
";
|
|
|
$result = Database::query($sql);
|
|
|
|
|
@@ -701,7 +702,8 @@ function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '') {
|
|
|
* @author René Haentjens, Ghent University
|
|
|
* @todo check if this function is still necessary.
|
|
|
*/
|
|
|
-function removeMoreIfMailing($file_id) {
|
|
|
+function removeMoreIfMailing($file_id)
|
|
|
+{
|
|
|
$course_id = api_get_course_int_id();
|
|
|
global $dropbox_cnf;
|
|
|
// when deleting a mailing zip-file (posted to mailingPseudoId):
|
|
@@ -734,7 +736,8 @@ function removeMoreIfMailing($file_id) {
|
|
|
*
|
|
|
* @author René Haentjens, Ghent University
|
|
|
*/
|
|
|
-function dropbox_cnf($variable) {
|
|
|
+function dropbox_cnf($variable)
|
|
|
+{
|
|
|
return $GLOBALS['dropbox_cnf'][$variable];
|
|
|
}
|
|
|
|
|
@@ -806,9 +809,9 @@ function store_add_dropbox() {
|
|
|
if (!is_uploaded_file($dropbox_filetmpname)) { // check user fraud : no clean error msg.
|
|
|
return get_lang('TheFileIsNotUploaded');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$upload_ok = process_uploaded_file($_FILES['file'], true);
|
|
|
-
|
|
|
+
|
|
|
if (!$upload_ok) {
|
|
|
return null;
|
|
|
}
|
|
@@ -819,7 +822,7 @@ function store_add_dropbox() {
|
|
|
$dropbox_filename = replace_dangerous_char($dropbox_filename);
|
|
|
// Transform any .php file in .phps fo security
|
|
|
$dropbox_filename = php2phps($dropbox_filename);
|
|
|
-
|
|
|
+
|
|
|
//filter extension
|
|
|
if (!filter_extension($dropbox_filename)) {
|
|
|
return get_lang('UplUnableToSaveFileFilteredExtension');
|
|
@@ -926,6 +929,7 @@ function display_user_link_work($user_id, $name = '') {
|
|
|
* @version march 2006
|
|
|
*/
|
|
|
function feedback($array) {
|
|
|
+ $output = null;
|
|
|
foreach ($array as $key => $value) {
|
|
|
$output .= format_feedback($value);
|
|
|
}
|
|
@@ -943,7 +947,7 @@ function feedback($array) {
|
|
|
* @version march 2006
|
|
|
*/
|
|
|
function format_feedback($feedback) {
|
|
|
- $output .= display_user_link_work($feedback['author_user_id']);
|
|
|
+ $output = display_user_link_work($feedback['author_user_id']);
|
|
|
$output .= ' '.api_convert_and_format_date($feedback['feedback_date'], DATE_TIME_FORMAT_LONG).'<br />';
|
|
|
$output .= '<div style="padding-top:6px">'.nl2br($feedback['feedback']).'</div><hr size="1" noshade/><br />';
|
|
|
return $output;
|
|
@@ -957,7 +961,7 @@ function format_feedback($feedback) {
|
|
|
* @version march 2006
|
|
|
*/
|
|
|
function feedback_form() {
|
|
|
- $return = get_lang('AddNewFeedback').'<br />';
|
|
|
+ $return = get_lang('AddNewFeedback').'<br />';
|
|
|
$number_users_who_see_file = check_if_file_exist($_GET['id']);
|
|
|
if ($number_users_who_see_file) {
|
|
|
$token = Security::get_token();
|
|
@@ -976,14 +980,14 @@ function user_can_download_file($id, $user_id) {
|
|
|
$course_id = api_get_course_int_id();
|
|
|
$id = intval($id);
|
|
|
$user_id = intval($user_id);
|
|
|
-
|
|
|
- $sql = "SELECT file_id FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND user_id = $user_id AND file_id = ".$id;
|
|
|
+
|
|
|
+ $sql = "SELECT file_id FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND user_id = $user_id AND file_id = ".$id;
|
|
|
$result = Database::query($sql);
|
|
|
$number_users_who_see_file = Database::num_rows($result);
|
|
|
-
|
|
|
+
|
|
|
$sql = "SELECT file_id FROM ".$dropbox_cnf["tbl_post"]." WHERE c_id = $course_id AND dest_user_id = $user_id AND file_id = ".$id;
|
|
|
$result = Database::query($sql);
|
|
|
- $count = Database::num_rows($result);
|
|
|
+ $count = Database::num_rows($result);
|
|
|
return $number_users_who_see_file > 0 || $count > 0;
|
|
|
}
|
|
|
|
|
@@ -993,13 +997,13 @@ function check_if_file_exist($id) {
|
|
|
global $dropbox_cnf;
|
|
|
$id = intval($id);
|
|
|
$course_id = api_get_course_int_id();
|
|
|
- $sql = "SELECT file_id FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND file_id = ".$id;
|
|
|
+ $sql = "SELECT file_id FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND file_id = ".$id;
|
|
|
$result = Database::query($sql);
|
|
|
$number_users_who_see_file = Database::num_rows($result);
|
|
|
-
|
|
|
+
|
|
|
$sql = "SELECT file_id FROM ".$dropbox_cnf["tbl_post"]." WHERE c_id = $course_id AND file_id = ".$id;
|
|
|
$result = Database::query($sql);
|
|
|
- $count = Database::num_rows($result);
|
|
|
+ $count = Database::num_rows($result);
|
|
|
return $number_users_who_see_file > 0 || $count > 0;
|
|
|
}
|
|
|
|
|
@@ -1044,7 +1048,6 @@ function zip_download($array) {
|
|
|
global $files;
|
|
|
|
|
|
$course_id = api_get_course_int_id();
|
|
|
-
|
|
|
$sys_course_path = api_get_path(SYS_COURSE_PATH);
|
|
|
|
|
|
// place to temporarily stash the zipfiles
|
|
@@ -1058,7 +1061,7 @@ function zip_download($array) {
|
|
|
ON (person.file_id=file.id AND file.c_id = $course_id AND person.c_id = $course_id)
|
|
|
INNER JOIN ".$dropbox_cnf['tbl_post']." post
|
|
|
ON (post.file_id = file.id AND post.c_id = $course_id AND file.c_id = $course_id)
|
|
|
- WHERE file.id IN (".implode(', ',$array).") AND
|
|
|
+ WHERE file.id IN (".implode(', ',$array).") AND
|
|
|
file.id = person.file_id AND
|
|
|
(person.user_id = '".api_get_user_id()."' OR post.dest_user_id = '".api_get_user_id()."' ) ";
|
|
|
$result = Database::query($sql);
|
|
@@ -1070,7 +1073,7 @@ function zip_download($array) {
|
|
|
// Step 3: create the zip file and add all the files to it
|
|
|
$temp_zip_file = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().".zip";
|
|
|
$zip_folder = new PclZip($temp_zip_file);
|
|
|
- foreach ($files as $key => $value) {
|
|
|
+ foreach ($files as $value) {
|
|
|
$zip_folder->add(api_get_path(SYS_COURSE_PATH).$_course['path'].'/dropbox/'.$value['filename'], PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_CB_PRE_ADD, 'my_pre_add_callback');
|
|
|
}
|
|
|
$name = 'dropbox-'.api_get_utc_datetime().'.zip';
|