コード例 #1
0
 /**
  * Download assignment file
  */
 function downloadFileObject()
 {
     global $rbacsystem;
     $file = $_POST["file"] ? $_POST["file"] : $_GET["file"];
     // check read permission
     $this->checkPermission("read");
     if (!isset($file)) {
         ilUtil::sendFailure($this->lng->txt("exc_select_one_file"), true);
         $this->ctrl->redirect($this, "view");
     }
     // check, whether file belongs to assignment
     include_once "./Modules/Exercise/classes/class.ilExAssignment.php";
     $files = ilExAssignment::getFiles($this->object->getId(), (int) $_GET["ass_id"]);
     $file_exist = false;
     foreach ($files as $lfile) {
         if ($lfile["name"] == urldecode($file)) {
             $file_exist = true;
             break;
         }
     }
     if (!$file_exist) {
         echo "FILE DOES NOT EXIST";
         exit;
     }
     // check whether assignment as already started
     $ass = new ilExAssignment((int) $_GET["ass_id"]);
     $not_started_yet = false;
     if ($ass->getStartTime() > 0 && time() - $ass->getStartTime() <= 0) {
         $not_started_yet = true;
     }
     // deliver file
     if (!$not_started_yet) {
         include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php";
         $storage = new ilFSStorageExercise($this->object->getId(), (int) $_GET["ass_id"]);
         $p = $storage->getAssignmentFilePath(urldecode($file));
         ilUtil::deliverFile($p, urldecode($file));
     }
     return true;
 }