Removing global calls.

1.9.x
Julio Montoya 11 years ago
parent 9f97ec827d
commit fa93fdf7ed
  1. 3
      main/dropbox/dropbox_config.inc.php
  2. 229
      main/dropbox/dropbox_functions.inc.php
  3. 35
      main/dropbox/dropbox_init.inc.php
  4. 4
      main/dropbox/index.php

@ -6,7 +6,6 @@
*/ */
$dropbox_cnf['tbl_user'] = Database::get_main_table(TABLE_MAIN_USER); $dropbox_cnf['tbl_user'] = Database::get_main_table(TABLE_MAIN_USER);
$dropbox_cnf['tbl_course_user'] = Database::get_main_table(TABLE_MAIN_COURSE_USER); $dropbox_cnf['tbl_course_user'] = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$dropbox_cnf['tbl_post'] = Database::get_course_table(TABLE_DROPBOX_POST); $dropbox_cnf['tbl_post'] = Database::get_course_table(TABLE_DROPBOX_POST);
$dropbox_cnf['tbl_file'] = Database::get_course_table(TABLE_DROPBOX_FILE); $dropbox_cnf['tbl_file'] = Database::get_course_table(TABLE_DROPBOX_FILE);
$dropbox_cnf['tbl_person'] = Database::get_course_table(TABLE_DROPBOX_PERSON); $dropbox_cnf['tbl_person'] = Database::get_course_table(TABLE_DROPBOX_PERSON);
@ -43,3 +42,5 @@ $dropbox_cnf['mailingWhereUSERID'] = 'username';
$dropbox_cnf['mailingWhereLOGINNAME'] = 'username'; $dropbox_cnf['mailingWhereLOGINNAME'] = 'username';
$dropbox_cnf['mailingFileRegexp'] = '/^(.+)\.\w{1,4}$/'; $dropbox_cnf['mailingFileRegexp'] = '/^(.+)\.\w{1,4}$/';
$dropbox_cnf['sent_received_tabs'] = true; $dropbox_cnf['sent_received_tabs'] = true;
return $dropbox_cnf;

@ -7,6 +7,7 @@
* to one file -- Patrick Cool <patrick.cool@UGent.be>, Ghent University * to one file -- Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Julio Montoya adding c_id support * @author Julio Montoya adding c_id support
*/ */
use \ChamiloSession as Session;
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
@ -25,18 +26,21 @@ $(document).ready(function () {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006 * @version march 2006
*/ */
function handle_multiple_actions() { function handle_multiple_actions()
global $_user, $is_courseAdmin, $is_courseTutor; {
$_user = api_get_user_info();
// STEP 1: are we performing the actions on the received or on the sent files? $is_courseAdmin = api_is_course_admin();
if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'download_received') { $is_courseTutor = api_is_course_tutor();
$part = 'received';
} elseif ($_POST['action'] == 'delete_sent' || $_POST['action'] == 'download_sent') { // STEP 1: are we performing the actions on the received or on the sent files?
$part = 'sent'; if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'download_received') {
} $part = 'received';
} elseif ($_POST['action'] == 'delete_sent' || $_POST['action'] == 'download_sent') {
$part = 'sent';
}
// STEP 2: at least one file has to be selected. If not we return an error message // STEP 2: at least one file has to be selected. If not we return an error message
$ids = Request::get('id', array()); $ids = issset($_GET['id']) ? $_GET['id'] : array();
if (count($ids)>0) { if (count($ids)>0) {
$checked_file_ids = $_POST['id']; $checked_file_ids = $_POST['id'];
} else { } else {
@ -47,38 +51,38 @@ function handle_multiple_actions() {
} }
} }
} }
$checked_file_ids = $_POST['id']; $checked_file_ids = $_POST['id'];
if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) { if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) {
return get_lang('CheckAtLeastOneFile'); return get_lang('CheckAtLeastOneFile');
} }
// STEP 3A: deleting // STEP 3A: deleting
if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'delete_sent') { if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'delete_sent') {
$dropboxfile = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor); $dropboxfile = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
foreach ($checked_file_ids as $key => $value) { foreach ($checked_file_ids as $key => $value) {
if ($_GET['view'] == 'received') { if ($_GET['view'] == 'received') {
$dropboxfile->deleteReceivedWork($value); $dropboxfile->deleteReceivedWork($value);
$message = get_lang('ReceivedFileDeleted'); $message = get_lang('ReceivedFileDeleted');
} }
if ($_GET['view'] == 'sent' OR empty($_GET['view'])) { if ($_GET['view'] == 'sent' OR empty($_GET['view'])) {
$dropboxfile->deleteSentWork($value); $dropboxfile->deleteSentWork($value);
$message = get_lang('SentFileDeleted'); $message = get_lang('SentFileDeleted');
} }
} }
return $message; return $message;
} }
// STEP 3B: giving comment // STEP 3B: giving comment
if ($_POST['actions'] == 'comment') { if ($_POST['actions'] == 'comment') {
// This has not been implemented. // This has not been implemented.
// The idea was that it would be possible to write the same feedback for the selected documents. // The idea was that it would be possible to write the same feedback for the selected documents.
} }
// STEP 3C: moving // STEP 3C: moving
if (strstr($_POST['action'], 'move_')) { if (strstr($_POST['action'], 'move_')) {
// check move_received_n or move_sent_n command // check move_received_n or move_sent_n command
if (strstr($_POST['action'], 'received')) { if (strstr($_POST['action'], 'received')) {
$part = 'received'; $part = 'received';
$to_cat_id = str_replace('move_received_', '', $_POST['action']); $to_cat_id = str_replace('move_received_', '', $_POST['action']);
} else { } else {
@ -86,16 +90,25 @@ function handle_multiple_actions() {
$to_cat_id = str_replace('move_sent_', '', $_POST['action']); $to_cat_id = str_replace('move_sent_', '', $_POST['action']);
} }
foreach ($checked_file_ids as $key => $value) { foreach ($checked_file_ids as $key => $value) {
store_move($value, $to_cat_id, $part); store_move($value, $to_cat_id, $part);
} }
return get_lang('FilesMoved'); return get_lang('FilesMoved');
} }
// STEP 3D: downloading // STEP 3D: downloading
if ($_POST['action'] == 'download_sent' || $_POST['action'] == 'download_received') { if ($_POST['action'] == 'download_sent' || $_POST['action'] == 'download_received') {
zip_download($checked_file_ids); zip_download($checked_file_ids);
} }
}
/**
* Get conf settings
* @return array
*/
function getDropboxConf()
{
return Session::read('dropbox_conf');
} }
/** /**
@ -109,16 +122,19 @@ function handle_multiple_actions() {
function delete_category($action, $id, $user_id = null) function delete_category($action, $id, $user_id = null)
{ {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$is_courseAdmin = api_is_course_admin();
global $dropbox_cnf; $is_courseTutor = api_is_course_tutor();
global $is_courseAdmin, $is_courseTutor; $dropbox_cnf = getDropboxConf();
if (empty($user_id)) { if (empty($user_id)) {
$user_id = api_get_user_id(); $user_id = api_get_user_id();
} }
$cat = get_dropbox_category($id); $cat = get_dropbox_category($id);
if (count($cat)==0) { return false; } if (count($cat)==0) {
return false;
}
if ($cat['user_id'] != $user_id && !api_is_platform_admin($user_id)) { if ($cat['user_id'] != $user_id && !api_is_platform_admin($user_id)) {
return false; return false;
} }
@ -193,7 +209,8 @@ function display_move_form($part, $id, $target = array(), $extra_params = array(
*/ */
function store_move($id, $target, $part) function store_move($id, $target, $part)
{ {
global $_user, $dropbox_cnf; $_user = api_get_user_info();
$dropbox_cnf = getDropboxConf();
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if ((isset($id) AND $id != '') AND (isset($target) AND $target != '') AND (isset($part) AND $part != '')) { if ((isset($id) AND $id != '') AND (isset($target) AND $target != '') AND (isset($part) AND $part != '')) {
@ -281,9 +298,8 @@ function display_file_checkbox($id, $part) {
function get_dropbox_categories($filter = '') function get_dropbox_categories($filter = '')
{ {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
global $_user; $_user = api_get_user_info();
global $dropbox_cnf; $dropbox_cnf = getDropboxConf();
$return_array = array(); $return_array = array();
$session_id = api_get_session_id(); $session_id = api_get_session_id();
@ -308,7 +324,7 @@ function get_dropbox_categories($filter = '')
*/ */
function get_dropbox_category($id) function get_dropbox_category($id)
{ {
global $dropbox_cnf; $dropbox_cnf = getDropboxConf();
$course_id = api_get_course_int_id(); $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."'"; $sql = "SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE c_id = $course_id AND cat_id='".$id."'";
@ -334,10 +350,11 @@ function get_dropbox_category($id)
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006 * @version march 2006
*/ */
function store_addcategory() { function store_addcategory()
{
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
global $_user; $_user = api_get_user_info();
global $dropbox_cnf; $dropbox_cnf = getDropboxConf();
// check if the target is valid // check if the target is valid
if ($_POST['target'] == 'sent') { if ($_POST['target'] == 'sent') {
@ -390,8 +407,9 @@ function store_addcategory() {
* *
* @version march 2006 * @version march 2006
*/ */
function display_addcategory_form($category_name = '', $id = '', $action) { function display_addcategory_form($category_name = '', $id = '', $action)
global $dropbox_cnf; {
$dropbox_cnf = getDropboxConf();
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$title = get_lang('AddNewCategory'); $title = get_lang('AddNewCategory');
@ -428,7 +446,7 @@ function display_addcategory_form($category_name = '', $id = '', $action) {
$class = 'add'; $class = 'add';
} }
$form = new FormValidator('add_new_category', 'post', api_get_self().'?view="'.Security::remove_XSS($_GET['view'])); $form = new FormValidator('add_new_category', 'post', api_get_self().'?view='.Security::remove_XSS($_GET['view']));
$form->addElement('header', $title); $form->addElement('header', $title);
if (isset($id) AND $id != '') { if (isset($id) AND $id != '') {
@ -453,10 +471,16 @@ function display_addcategory_form($category_name = '', $id = '', $action) {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006 * @version march 2006
*/ */
function display_add_form() { function display_add_form($dropbox_unid)
global $_user, $is_courseAdmin, $is_courseTutor, $course_info, $origin, $dropbox_unid; {
$course_info = api_get_course_info();
$_user = api_get_user_info();
$is_courseAdmin = api_is_course_admin();
$is_courseTutor = api_is_course_tutor();
$origin = isset($_GET['origin']) ? $_GET['origin'] : null;
$token = Security::get_token(); $token = Security::get_token();
$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); $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);"> <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);">
@ -589,8 +613,9 @@ function display_add_form() {
* returns username or false if user isn't registered anymore * 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. * @todo check if this function is still necessary. There might be a library function for this.
*/ */
function getUserNameFromId($id) { function getUserNameFromId($id)
global $dropbox_cnf; {
$dropbox_cnf = getDropboxConf();
$mailingId = $id - dropbox_cnf('mailingIdBase'); $mailingId = $id - dropbox_cnf('mailingIdBase');
if ($mailingId > 0) { if ($mailingId > 0) {
@ -611,7 +636,8 @@ function getUserNameFromId($id) {
* returns loginname or false if user isn't registered anymore * returns loginname or false if user isn't registered anymore
* @todo check if this function is still necessary. There might be a library function for this. * @todo check if this function is still necessary. There might be a library function for this.
*/ */
function getLoginFromId($id) { function getLoginFromId($id)
{
$id = intval($id); $id = intval($id);
$sql = "SELECT username $sql = "SELECT username
FROM " . dropbox_cnf('tbl_user') . " FROM " . dropbox_cnf('tbl_user') . "
@ -624,12 +650,12 @@ function getLoginFromId($id) {
/** /**
* @return boolean indicating if user with user_id=$user_id is a course member * @return boolean indicating if user with user_id=$user_id is a course member
* @todo eliminate global
* @todo check if this function is still necessary. There might be a library function for this. * @todo check if this function is still necessary. There might be a library function for this.
*/ */
function isCourseMember($user_id) { function isCourseMember($user_id)
global $_course; {
$course_code = $_course['sysCode']; $_course = api_get_course_info();
$course_code = $_course['code'];
$is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, true); $is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, true);
return $is_course_member; return $is_course_member;
} }
@ -638,7 +664,8 @@ function isCourseMember($user_id) {
* Checks if there are files in the dropbox_file table that aren't used anymore in dropbox_person table. * Checks if there are files in the dropbox_file table that aren't used anymore in dropbox_person table.
* If there are, all entries concerning the file are deleted from the db + the file is deleted from the server * If there are, all entries concerning the file are deleted from the db + the file is deleted from the server
*/ */
function removeUnusedFiles() { function removeUnusedFiles()
{
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// select all files that aren't referenced anymore // select all files that aren't referenced anymore
@ -676,8 +703,8 @@ function removeUnusedFiles() {
function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '') function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '')
{ {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$dropbox_cnf = getDropboxConf();
global $dropbox_cnf;
$mailingPseudoId = intval($mailingPseudoId); $mailingPseudoId = intval($mailingPseudoId);
$sql = "SELECT f.uploader_id $sql = "SELECT f.uploader_id
FROM " . $dropbox_cnf['tbl_file'] . " f FROM " . $dropbox_cnf['tbl_file'] . " f
@ -702,7 +729,7 @@ function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '')
function removeMoreIfMailing($file_id) function removeMoreIfMailing($file_id)
{ {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
global $dropbox_cnf; $dropbox_cnf = getDropboxConf();
// when deleting a mailing zip-file (posted to mailingPseudoId): // when deleting a mailing zip-file (posted to mailingPseudoId):
// 1. the detail window is no longer reachable, so // 1. the detail window is no longer reachable, so
// for all content files, delete mailingPseudoId from person-table // for all content files, delete mailingPseudoId from person-table
@ -735,22 +762,23 @@ function removeMoreIfMailing($file_id)
*/ */
function dropbox_cnf($variable) function dropbox_cnf($variable)
{ {
return $GLOBALS['dropbox_cnf'][$variable]; $dropbox_cnf = getDropboxConf();
return $dropbox_cnf[$variable];
} }
function store_add_dropbox() { function store_add_dropbox()
global $dropbox_cnf; {
global $_user; $_course = api_get_course_info();
global $_course; $_user = api_get_user_info();
$dropbox_cnf = getDropboxConf();
// Validating the form data // Validating the form data
// there are no recipients selected // there are no recipients selected
if (!isset($_POST['recipients']) || count( $_POST['recipients']) <= 0) { if (!isset($_POST['recipients']) || count( $_POST['recipients']) <= 0) {
return get_lang('YouMustSelectAtLeastOneDestinee'); return get_lang('YouMustSelectAtLeastOneDestinee');
} } else {
// Check if all the recipients are valid // Check if all the recipients are valid
else {
$thisIsAMailing = false; $thisIsAMailing = false;
$thisIsJustUpload = false; $thisIsJustUpload = false;
foreach ($_POST['recipients'] as $rec) { foreach ($_POST['recipients'] as $rec) {
@ -782,7 +810,6 @@ function store_add_dropbox() {
return get_lang('NoFileSpecified'); return get_lang('NoFileSpecified');
} }
// are we overwriting a previous file or sending a new one // are we overwriting a previous file or sending a new one
$dropbox_overwrite = false; $dropbox_overwrite = false;
@ -927,7 +954,7 @@ function display_user_link_work($user_id, $name = '') {
*/ */
function feedback($array) { function feedback($array) {
$output = null; $output = null;
foreach ($array as $key => $value) { foreach ($array as $value) {
$output .= format_feedback($value); $output .= format_feedback($value);
} }
$output .= feedback_form(); $output .= feedback_form();
@ -943,7 +970,8 @@ function feedback($array) {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006 * @version march 2006
*/ */
function format_feedback($feedback) { function format_feedback($feedback)
{
$output = display_user_link_work($feedback['author_user_id']); $output = display_user_link_work($feedback['author_user_id']);
$output .= '&nbsp;&nbsp;'.api_convert_and_format_date($feedback['feedback_date'], DATE_TIME_FORMAT_LONG).'<br />'; $output .= '&nbsp;&nbsp;'.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 />'; $output .= '<div style="padding-top:6px">'.nl2br($feedback['feedback']).'</div><hr size="1" noshade/><br />';
@ -957,7 +985,8 @@ function format_feedback($feedback) {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006 * @version march 2006
*/ */
function feedback_form() { function feedback_form()
{
$return = get_lang('AddNewFeedback').'<br />'; $return = get_lang('AddNewFeedback').'<br />';
$number_users_who_see_file = check_if_file_exist($_GET['id']); $number_users_who_see_file = check_if_file_exist($_GET['id']);
if ($number_users_who_see_file) { if ($number_users_who_see_file) {
@ -973,7 +1002,7 @@ function feedback_form() {
} }
function user_can_download_file($id, $user_id) { function user_can_download_file($id, $user_id) {
global $dropbox_cnf; $dropbox_cnf = getDropboxConf();
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$id = intval($id); $id = intval($id);
$user_id = intval($user_id); $user_id = intval($user_id);
@ -991,7 +1020,7 @@ function user_can_download_file($id, $user_id) {
// we now check if the other users have not delete this document yet. If this is the case then it is useless to see the // we now check if the other users have not delete this document yet. If this is the case then it is useless to see the
// add feedback since the other users will never get to see the feedback. // add feedback since the other users will never get to see the feedback.
function check_if_file_exist($id) { function check_if_file_exist($id) {
global $dropbox_cnf; $dropbox_cnf = getDropboxConf();
$id = intval($id); $id = intval($id);
$course_id = api_get_course_int_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;
@ -1012,8 +1041,9 @@ function check_if_file_exist($id) {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006 * @version march 2006
*/ */
function store_feedback() { function store_feedback()
global $dropbox_cnf; {
$dropbox_cnf = getDropboxConf();
if (!is_numeric($_GET['id'])) { if (!is_numeric($_GET['id'])) {
return get_lang('FeedbackError'); return get_lang('FeedbackError');
} }
@ -1040,16 +1070,10 @@ function store_feedback() {
* @version march 2006 * @version march 2006
*/ */
function zip_download($array) { function zip_download($array) {
global $_course; $_course = api_get_course_info();
global $dropbox_cnf; $dropbox_cnf = getDropboxConf();
global $files;
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$sys_course_path = api_get_path(SYS_COURSE_PATH);
// place to temporarily stash the zipfiles
$temp_zip_dir = api_get_path(SYS_COURSE_PATH);
$array = array_map('intval', $array); $array = array_map('intval', $array);
// note: we also have to add the check if the user has received or sent this file. // note: we also have to add the check if the user has received or sent this file.
@ -1100,7 +1124,8 @@ function my_pre_add_callback($p_event, &$p_header) {
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, March 2006 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, March 2006
* @author Ivan Tcholakov, 2010, code for html metadata has been added. * @author Ivan Tcholakov, 2010, code for html metadata has been added.
*/ */
function generate_html_overview($files, $dont_show_columns = array(), $make_link = array()) { function generate_html_overview($files, $dont_show_columns = array(), $make_link = array())
{
$return = '<!DOCTYPE html'."\n"; $return = '<!DOCTYPE html'."\n";
$return .= "\t".'PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'."\n"; $return .= "\t".'PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'."\n";
$return .= "\t".'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n"; $return .= "\t".'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
@ -1113,7 +1138,7 @@ function generate_html_overview($files, $dont_show_columns = array(), $make_link
$return .= "<table border=\"1px\">\n"; $return .= "<table border=\"1px\">\n";
$counter = 0; $counter = 0;
foreach ($files as $key => $value) { foreach ($files as $value) {
// Adding the header. // Adding the header.
if ($counter == 0) { if ($counter == 0) {
@ -1157,7 +1182,7 @@ function generate_html_overview($files, $dont_show_columns = array(), $make_link
* @version march 2006 * @version march 2006
*/ */
function get_total_number_feedback($file_id = '') { function get_total_number_feedback($file_id = '') {
global $dropbox_cnf; $dropbox_cnf = getDropboxConf();
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$sql = "SELECT COUNT(feedback_id) AS total, file_id FROM ".$dropbox_cnf['tbl_feedback']." $sql = "SELECT COUNT(feedback_id) AS total, file_id FROM ".$dropbox_cnf['tbl_feedback']."
WHERE c_id = $course_id GROUP BY file_id"; WHERE c_id = $course_id GROUP BY file_id";

@ -32,18 +32,14 @@ use \ChamiloSession as Session;
$language_file = array('dropbox', 'document'); $language_file = array('dropbox', 'document');
// This var disables the link in the breadcrumbs on top of the page
//$noPHP_SELF = true;
// including the basic Chamilo initialisation file // including the basic Chamilo initialisation file
require '../inc/global.inc.php'; require_once '../inc/global.inc.php';
$is_allowed_in_course = api_is_allowed_to_edit(false, true);
$current_course_tool = TOOL_DROPBOX; $current_course_tool = TOOL_DROPBOX;
// the dropbox configuration parameters // the dropbox configuration parameters
require_once 'dropbox_config.inc.php'; $dropbox_cnf = require_once 'dropbox_config.inc.php';
Session::write('dropbox_conf', $dropbox_cnf);
// the dropbox sanity files (adds a new table and some new fields)
//require_once 'dropbox_sanity.inc.php';
// the dropbox file that contains additional functions // the dropbox file that contains additional functions
require_once 'dropbox_functions.inc.php'; require_once 'dropbox_functions.inc.php';
@ -71,6 +67,9 @@ $course_code = api_get_course_id();
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
$session_id = api_get_session_id(); $session_id = api_get_session_id();
$action = isset($_GET['action']) ? $_GET['action'] : null;
$view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
if (empty($session_id)) { if (empty($session_id)) {
$is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, false); $is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, false);
} else { } else {
@ -83,7 +82,7 @@ if (empty($session_id)) {
// off all the documents that have already been sent. // off all the documents that have already been sent.
// @todo consider moving the javascripts in a function that displays the javascripts // @todo consider moving the javascripts in a function that displays the javascripts
// only when it is needed. // only when it is needed.
if ($_GET['action'] == 'add') { if ($action == 'add') {
$dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor); $dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
} }
@ -201,18 +200,18 @@ $htmlHeadXtra[] = '<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="-1">'; <meta http-equiv="expires" content="-1">';
$checked_files = false; $checked_files = false;
if (!$_GET['view'] OR $_GET['view'] == 'received') { if (!$view OR $view == 'received') {
$part = 'received'; $part = 'received';
} elseif ($_GET['view'] = 'sent') { } elseif ($view = 'sent') {
$part = 'sent'; $part = 'sent';
} else { } else {
header ('location: index.php?view='.$_GET['view'].'&error=Error'); header ('location: index.php?view='.$view.'&error=Error');
} }
if (($_POST['action'] == 'download_received' || $_POST['action'] == 'download_sent') and !$_POST['store_feedback']) { if (($_POST['action'] == 'download_received' || $_POST['action'] == 'download_sent') and !$_POST['store_feedback']) {
$checked_file_ids = $_POST['id']; $checked_file_ids = $_POST['id'];
if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) { if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) {
header ('location: index.php?view='.$_GET['view'].'&error=CheckAtLeastOneFile'); header ('location: index.php?view='.$view.'&error=CheckAtLeastOneFile');
} else { } else {
handle_multiple_actions(); handle_multiple_actions();
} }
@ -235,25 +234,25 @@ if ((!$is_allowed_in_course || !$is_course_member) && !api_is_allowed_to_edit(nu
/* BREADCRUMBS */ /* BREADCRUMBS */
if ($_GET['view'] == 'received') { if ($view == 'received') {
$interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', '')); $interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', ''));
$nameTools = get_lang('ReceivedFiles'); $nameTools = get_lang('ReceivedFiles');
if ($_GET['action'] == 'addreceivedcategory') { if ($action == 'addreceivedcategory') {
$interbreadcrumb[] = array('url' => '../dropbox/index.php?view=received', 'name' => get_lang('ReceivedFiles')); $interbreadcrumb[] = array('url' => '../dropbox/index.php?view=received', 'name' => get_lang('ReceivedFiles'));
$nameTools = get_lang('AddNewCategory'); $nameTools = get_lang('AddNewCategory');
} }
} }
if ($_GET['view'] == 'sent' OR empty($_GET['view'])) { if ($view == 'sent' OR empty($view)) {
$interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', '')); $interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', ''));
$nameTools = get_lang('SentFiles'); $nameTools = get_lang('SentFiles');
if ($_GET['action'] == 'addsentcategory') { if ($action == 'addsentcategory') {
$interbreadcrumb[] = array('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles')); $interbreadcrumb[] = array('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles'));
$nameTools = get_lang('AddNewCategory'); $nameTools = get_lang('AddNewCategory');
} }
if ($_GET['action'] == 'add') { if ($action == 'add') {
$interbreadcrumb[] = array ('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles')); $interbreadcrumb[] = array ('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles'));
$nameTools = get_lang('UploadNewFile'); $nameTools = get_lang('UploadNewFile');
} }

@ -98,7 +98,7 @@ require_once 'dropbox_init.inc.php';
// get the last time the user accessed the tool // get the last time the user accessed the tool
if ($_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') { if ($_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') {
$last_access = get_last_tool_access(TOOL_DROPBOX, $_course['code'], $_user['user_id']); $last_access = get_last_tool_access(TOOL_DROPBOX);
$_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access; $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access;
} else { } else {
$last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX]; $last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX];
@ -138,7 +138,7 @@ if ($action == 'add') {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed(); api_not_allowed();
} }
display_add_form(); display_add_form($dropbox_unid);
} }
if (isset($_POST['submitWork'])) { if (isset($_POST['submitWork'])) {

Loading…
Cancel
Save