dokeos-dropbox
[ class tree: dokeos-dropbox ] [ index: dokeos-dropbox ] [ all elements ]

Source for file dropbox_init.inc.php

Documentation is available at dropbox_init.inc.php

  1. <?php // $Id: dropbox_init1.inc.php,v 1.29 2005/09/12 08:16:16 renehaentjens Exp $
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2006 Dokeos S.A.
  7.     Copyright (c) 2006 Ghent University (UGent)
  8.     Copyright (c) various contributors
  9.  
  10.     For a full list of contributors, see "credits.txt".
  11.     The full license can be read in "license.txt".
  12.  
  13.     This program is free software; you can redistribute it and/or
  14.     modify it under the terms of the GNU General Public License
  15.     as published by the Free Software Foundation; either version 2
  16.     of the License, or (at your option) any later version.
  17.  
  18.     See the GNU General Public License for more details.
  19.  
  20.     Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  21.     Mail: info@dokeos.com
  22. ==============================================================================
  23. */
  24. /**
  25. ==============================================================================
  26.  * First initialisation file with initialisation of variables and
  27.  * without outputting anything to browser.
  28.  * 1. Calls global.inc.php and lang file
  29.  * 2. Initialises $dropbox_cnf array with all relevant vars
  30.  * 3. Often used functions
  31.  *
  32.  * @version 1.31
  33.  * @copyright 2004-2005
  34.  * @author Jan Bols <jan@ivpv.UGent.be>, main programmer
  35.  * @author Rene Haentjens, severalcontributions <rene.haentjens@UGent.be> (see RH)
  36.  * @author Roan Embrechts, virtual course support
  37.  * @author Patrick Cool <patrick.cool@UGent.be>
  38.                  Dokeos Config Settings (AWACS)
  39.                  Refactoring
  40.                  tool introduction
  41.                  folders
  42.                  download file / folder (download icon)
  43.                  same action on multiple documents
  44.                  extended feedback
  45.  * @package dokeos.dropbox
  46. ==============================================================================
  47.  */
  48.  
  49. /*
  50. ==============================================================================
  51.         INIT SECTION
  52. ==============================================================================
  53. */ 
  54. // name of the language file that needs to be included 
  55. $language_file "dropbox";    
  56.  
  57. //this var disables the link in the breadcrumbs on top of the page
  58. //$noPHP_SELF = TRUE;    
  59.  
  60. // including the basic Dokeos initialisation file
  61. require("../inc/global.inc.php");
  62. require_once(api_get_path(LIBRARY_PATH"security.lib.php");
  63.  
  64. // the dropbox configuration parameters
  65. require_once('dropbox_config.inc.php');
  66.  
  67. // the dropbox sanity files (adds a new table and some new fields)
  68. //require_once('dropbox_sanity.inc.php');
  69.  
  70. // the dropbox file that contains additional functions
  71. require_once('dropbox_functions.inc.php');
  72.  
  73. require(api_get_path(INCLUDE_PATH).'/conf/mail.conf.php');
  74.  
  75. include_once(api_get_path(LIBRARY_PATH'mail.lib.inc.php');
  76. include_once(api_get_path(LIBRARY_PATH'fileUpload.lib.php');
  77.  
  78. // protecting the script 
  79.  
  80.  
  81. /*
  82. -----------------------------------------------------------
  83.     Libraries
  84. -----------------------------------------------------------
  85. */ 
  86. require_once(api_get_path(LIBRARY_PATH)."/debug.lib.inc.php");
  87. require_once(api_get_path(LIBRARY_PATH"/course.lib.php");
  88. require_once(api_get_path(LIBRARY_PATH"/groupmanager.lib.php");
  89.  
  90.  
  91. // including the library for the sortable table
  92. require_once(api_get_path(LIBRARY_PATH).'/tablesort.lib.php');
  93.  
  94. // including the library for the dropbox
  95. require_once"dropbox_class.inc.php");
  96.  
  97. // including the library to do the tracking
  98. require_once(api_get_path(LIBRARY_PATH).'/events.lib.inc.php');
  99.  
  100. // including some libraries that are also used in the documents tool
  101. require_once('../document/document.inc.php');  // we use a function build_document_icon_tag
  102. require_once(api_get_path(LIBRARY_PATH).'/fileDisplay.lib.php')// the function choose_image is used 
  103. require_once(api_get_path(LIBRARY_PATH).'/document.lib.php');
  104.  
  105.  
  106.  
  107. /*
  108. -----------------------------------------------------------
  109.     Virtual course support
  110. -----------------------------------------------------------
  111. */ 
  112. $user_id api_get_user_id();
  113. $course_code $_course['sysCode'];
  114. $course_info Database::get_course_info($course_code);
  115. $is_course_member CourseManager::is_user_subscribed_in_real_or_linked_course($user_id$course_info);
  116.  
  117.  
  118. /*
  119. -----------------------------------------------------------
  120.     Object Initialisation
  121. -----------------------------------------------------------
  122. */
  123. // we need this here because the javascript to re-upload the file needs an array
  124. // off all the documents that have already been sent. 
  125. // @todo consider moving the javascripts in a function that displays the javascripts
  126. // only when it is needed. 
  127. if ($_GET['action']=='add')
  128. {
  129.     $dropbox_person new Dropbox_Person$_user['user_id']$is_courseAdmin$is_courseTutor);
  130. }
  131.  
  132. /*
  133. -----------------------------------------------------------
  134.     create javascript and htmlHeaders
  135.     // RH: Mailing: new function confirmsend
  136. -----------------------------------------------------------
  137. */
  138.  
  139. $javascript "<script>
  140.     function confirmsend ()
  141.     {
  142.         if (confirm(\"".dropbox_lang("mailingConfirmSend""noDLTT")."\")){
  143.             return true;
  144.         } else {
  145.             return false;
  146.         }
  147.         return true;
  148.     }
  149.  
  150.     function confirmation (name)
  151.     {
  152.         if (confirm(\"".dropbox_lang("confirmDelete""noDLTT")." : \"+ name )){
  153.             return true;
  154.         } else {
  155.             return false;
  156.         }
  157.         return true;
  158.     }
  159.  
  160.     function checkForm (frm)
  161.     {
  162.         if (frm.elements['recipients[]'].selectedIndex < 0){
  163.             alert(\"".dropbox_lang("noUserSelected""noDLTT")."\");
  164.             return false;
  165.         } else if (frm.file.value == '') {
  166.             alert(\"".dropbox_lang("noFileSpecified""noDLTT")."\");
  167.             return false;
  168.         } else {
  169.             return true;
  170.         }
  171.     }
  172.     ";
  173.  
  174. if (dropbox_cnf("allowOverwrite"))
  175. {
  176.     $javascript .= "
  177.         var sentArray = new Array(";    //sentArray keeps list of all files still available in the sent files list
  178.                                         //of the user.
  179.                                         //This is used to show or hide the overwrite file-radio button of the upload form
  180.     for($i=0$i<count($dropbox_person->sentWork)$i++)
  181.     {
  182.         if ($i 0)
  183.         {
  184.             $javascript .= ", ";
  185.         }
  186.         $javascript .= "'".$dropbox_person->sentWork[$i]->title."'";
  187.         //echo '***'.$dropbox_person->sentWork[$i]->title;
  188.     }
  189.     $javascript .=");
  190.  
  191.         function checkfile(str)
  192.         {
  193.  
  194.             ind = str.lastIndexOf('/'); //unix separator
  195.             if (ind == -1) ind = str.lastIndexOf('\\\');    //windows separator
  196.             filename = str.substring(ind+1, str.length);
  197.  
  198.             found = 0;
  199.             for (i=0; i<sentArray.length; i++) {
  200.                 if (sentArray[i] == filename) found=1;
  201.             }
  202.  
  203.             //always start with unchecked box
  204.             el = getElement('cb_overwrite');
  205.             el.checked = false;
  206.  
  207.             //show/hide checkbox
  208.             if (found == 1) {
  209.                 displayEl('overwrite');
  210.             } else {
  211.                 undisplayEl('overwrite');
  212.             }
  213.         }
  214.  
  215.         function getElement(id)
  216.         {
  217.             return document.getElementById ? document.getElementById(id) :
  218.             document.all ? document.all(id) : null;
  219.         }
  220.  
  221.         function displayEl(id)
  222.         {
  223.             var el = getElement(id);
  224.             if (el && el.style) el.style.display = '';
  225.         }
  226.  
  227.         function undisplayEl(id)
  228.         {
  229.             var el = getElement(id);
  230.             if (el && el.style) el.style.display = 'none';
  231.         }";
  232. }
  233.  
  234. $javascript .="
  235.     </script>";
  236.  
  237. $htmlHeadXtra[$javascript;
  238.  
  239. $htmlHeadXtra[=
  240. "<script>
  241. function confirmation (name)
  242. {
  243.     if (confirm(\" "get_lang("AreYouSureToDelete"." \"+ name + \" ?\"))
  244.         {return true;}
  245.     else
  246.         {return false;}
  247. }
  248. </script>";
  249.  
  250. api_session_register('javascript');
  251.  
  252. $htmlHeadXtra['<meta http-equiv="cache-control" content="no-cache">
  253.     <meta http-equiv="pragma" content="no-cache">
  254.     <meta http-equiv="expires" content="-1">';
  255.  
  256.  
  257.  
  258. $checked_files=false;
  259. if (!$_GET['view'OR $_GET['view']=='received')
  260. {
  261.     $part='received';
  262. }
  263. elseif ($_GET['view']='sent')
  264. {
  265.     $part='sent';
  266. }
  267. else 
  268. {
  269.     header ('location: index.php?view='.$_GET['view'].'&error=Error');
  270. }
  271. if (($_POST['action']=='download_received' || $_POST['action']=='download_sent'and !$_POST['store_feedback'])
  272. {
  273.     {
  274.     $checked_file_ids $_POST['id'];
  275.     if (!is_array($checked_file_ids|| count($checked_file_ids)==0)
  276.     {
  277.         header ('location: index.php?view='.$_GET['view'].'&error=CheckAtLeastOneFile');
  278.         exit
  279.     }
  280.     else 
  281.         handle_multiple_actions();
  282.         exit
  283.     }
  284. }
  285.  
  286. /*
  287.  * ========================================
  288.  *         AUTHORISATION SECTION
  289.  * ========================================
  290.  * Prevents access of all users that are not course members
  291.  */
  292. if((!$is_allowed_in_course || !$is_courseMember&& !api_is_allowed_to_edit())
  293. {
  294.     if ($origin != 'learnpath')
  295.     {
  296.         api_not_allowed(true);//print headers/footers
  297.     }else{
  298.         api_not_allowed();
  299.     }
  300.     exit();
  301. }
  302.  
  303. /*
  304. ==============================================================================
  305.         HEADER & TITLE
  306. ==============================================================================
  307. */ 
  308.  
  309. $nameTools dropbox_lang("dropbox""noDLTT");
  310.  
  311. if ($origin != 'learnpath')
  312. {
  313.     Display::display_header($nameTools,"Dropbox");
  314. }
  315. else // if we come from the learning path we have to include the stylesheet and the required javascripts manually. 
  316. {
  317.     echo '<link rel="stylesheet" type="text/css" href="',api_get_path(WEB_CODE_PATH)'css/default.css">';
  318.     echo $javascript;
  319. }
  320.  
  321. ?>

Documentation generated on Thu, 12 Jun 2008 13:21:47 -0500 by phpDocumentor 1.4.1