Dokeos PHP Cross Reference Learning Management Systems

Source: /main/dropbox/dropbox_init.inc.php - 334 lines - 9329 bytes - Summary - Text - Print

Description: First initialisation file with initialisation of variables and without outputting anything to browser. 1. Calls global.inc.php and lang file 2. Initialises $dropbox_cnf array with all relevant vars 3. Often used functions

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

title

Description

title

Description

title

Description

title

title

Body