123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- <?php
- use ChamiloSession as Session;
- require_once __DIR__.'/../inc/global.inc.php';
- $is_allowed_in_course = api_is_allowed_in_course();
- $is_courseTutor = api_is_course_tutor();
- $is_courseAdmin = api_is_course_admin();
- $current_course_tool = TOOL_DROPBOX;
- require_once 'dropbox_functions.inc.php';
- api_protect_course_script();
- $user_id = api_get_user_id();
- $course_code = api_get_course_id();
- $course_info = api_get_course_info($course_code);
- $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 (api_is_excluded_user_type()) {
- api_not_allowed(true);
- }
- if (empty($session_id)) {
- $is_course_member = CourseManager::is_user_subscribed_in_course(
- $user_id,
- $course_code,
- false
- );
- } else {
- $is_course_member = CourseManager::is_user_subscribed_in_course(
- $user_id,
- $course_code,
- true,
- $session_id
- );
- }
- if ($action == 'add') {
- $dropbox_person = new Dropbox_Person(
- $_user['user_id'],
- $is_courseAdmin,
- $is_courseTutor
- );
- }
- $javascript = "<script>
- function confirmsend()
- {
- if (confirm(\"".get_lang('MailingConfirmSend', '')."\")){
- return true;
- } else {
- return false;
- }
- return true;
- }
- function confirmation (name)
- {
- if (confirm(\"".get_lang('ConfirmDelete', '')." : \"+ name )){
- return true;
- } else {
- return false;
- }
- return true;
- }
- function checkForm (frm)
- {
- if (frm.elements['recipients[]'].selectedIndex < 0){
- alert(\"".get_lang('NoUserSelected', '')."\");
- return false;
- } else if (frm.file.value == '') {
- alert(\"".get_lang('NoFileSpecified', '')."\");
- return false;
- } else {
- return true;
- }
- }
- ";
- $allowOverwrite = api_get_setting('dropbox_allow_overwrite');
- if ($allowOverwrite == 'true') {
-
-
-
- $javascript .= " 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)
- {
- ind = str.lastIndexOf('/'); //unix separator
- if (ind == -1) ind = str.lastIndexOf('\\\'); //windows separator
- filename = str.substring(ind+1, str.length);
- found = 0;
- for (i=0; i<sentArray.length; i++) {
- if (sentArray[i] == filename) found=1;
- }
- //always start with unchecked box
- el = getElement('cb_overwrite');
- el.checked = false;
- //show/hide checkbox
- if (found == 1) {
- displayEl('overwrite');
- } else {
- undisplayEl('overwrite');
- }
- }
- function getElement(id)
- {
- return document.getElementById ? document.getElementById(id) :
- document.all ? document.all(id) : null;
- }
- function displayEl(id)
- {
- var el = getElement(id);
- if (el && el.style) el.style.display = '';
- }
- function undisplayEl(id)
- {
- var el = getElement(id);
- if (el && el.style) el.style.display = 'none';
- }";
- }
- $javascript .= "
- </script>";
- $htmlHeadXtra[] = $javascript;
- $htmlHeadXtra[] = "<script>
- function confirmation (name)
- {
- if (confirm(\" ". get_lang("AreYouSureToDeleteJS")." \"+ name + \" ?\"))
- {return true;}
- else
- {return false;}
- }
- </script>";
- Session::write('javascript', $javascript);
- $htmlHeadXtra[] = '<meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="expires" content="-1">';
- $htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload'));
- $htmlHeadXtra[] = "<script>
- $(function () {
- $('#recipient_form').on('change', function() {
- $('#multiple_form').show();
- });
- });
- </script>";
- $checked_files = false;
- if (!$view || $view == 'received') {
- $part = 'received';
- } elseif ($view = 'sent') {
- $part = 'sent';
- } else {
- header('location: index.php?'.api_get_cidreq().'&view='.$view.'&error=Error');
- exit;
- }
- 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?'.api_get_cidreq().'&view='.$view.'&error=CheckAtLeastOneFile');
- } else {
- handle_multiple_actions();
- }
- exit;
- }
- if ((!$is_allowed_in_course || !$is_course_member) && !api_is_allowed_to_edit(null, true)) {
- if ($origin != 'learnpath') {
- api_not_allowed(true);
- } else {
- api_not_allowed();
- }
- exit();
- }
- if ($view == 'received') {
- $interbreadcrumb[] = array(
- 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq(),
- 'name' => get_lang('Dropbox', ''),
- );
- $nameTools = get_lang('ReceivedFiles');
- if ($action == 'addreceivedcategory') {
- $interbreadcrumb[] = array(
- 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=received&'.api_get_cidreq(),
- 'name' => get_lang('ReceivedFiles'),
- );
- $nameTools = get_lang('AddNewCategory');
- }
- }
- if ($view == 'sent' || empty($view)) {
- $interbreadcrumb[] = array(
- 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq(),
- 'name' => get_lang('Dropbox')
- );
- $nameTools = get_lang('SentFiles');
- if ($action == 'addsentcategory') {
- $interbreadcrumb[] = array(
- 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=sent&'.api_get_cidreq(),
- 'name' => get_lang('SentFiles'),
- );
- $nameTools = get_lang('AddNewCategory');
- }
- if ($action == 'add') {
-
- $nameTools = get_lang('UploadNewFile');
- }
- if ($action == 'update') {
- $interbreadcrumb[] = array(
- 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=sent&'.api_get_cidreq(),
- 'name' => get_lang('SentFiles'),
- );
- $nameTools = get_lang('UpdateFile');
- }
- }
- if (isset($origin) && $origin == 'learnpath') {
- $htmlHeadXtra[] = $javascript;
- Display::display_reduced_header($nameTools, 'Dropbox');
- } else {
- Display::display_header($nameTools, 'Dropbox');
- }
|