示例#1
0
文件: wizard.php 项目: ratbird/hope
 /**
  * Wizard finished: we can create the course now. First store an empty,
  * invisible course for getting an ID. Then, iterate through steps and
  * set values from each step.
  * @return Course
  * @throws Exception
  */
 private function createCourse()
 {
     // Create a new (empty) course so that we get an ID.
     $course = new Course();
     $course->visible = 0;
     $course->store();
     // Each (required) step stores its own values at the course object.
     for ($i = 0; $i < sizeof($this->steps); $i++) {
         $step = $this->getStep($i);
         if ($step->isRequired($this->getValues())) {
             if ($stored = $step->storeValues($course, $this->getValues())) {
                 $course = $stored;
             } else {
                 $course = false;
                 break;
                 //throw new Exception(_('Die Daten aus Schritt ' . $i . ' konnten nicht gespeichert werden, breche ab.'));
             }
         }
     }
     // Check if "documents" module is activated and create "General" folder.
     $m = new Modules();
     if ($m->getStatus('documents', $course->id)) {
         $f = new DocumentFolder();
         $f->name = _('Allgemeiner Dateiordner');
         $f->description = _('Ablage für allgemeine Ordner und Dokumente der Veranstaltung');
         $f->range_id = $course->id;
         $f->seminar_id = $course->id;
         $f->user_id = $GLOBALS['user']->id;
         $f->permission = 7;
         $f->store();
     }
     // Cleanup session data.
     unset($_SESSION['coursewizard'][$this->temp_id]);
     return $course;
 }
示例#2
0
文件: folder.php 项目: ratbird/hope
    }

    if (Request::submitted("cancel"))  {
        $folder_system_data["upload"]='';
        $folder_system_data["refresh"]='';
        $folder_system_data["link"]='';
        $folder_system_data["update_link"]='';
        $folder_system_data["move"]='';
        $folder_system_data["mode"]='';
        $folder_system_data["zipupload"]='';
        unset($cmd);
    }
}

if ($folder_system_data["move"]) {
    $check_movable_item = StudipDocument::find($folder_system_data["move"]) ?: DocumentFolder::find($folder_system_data["move"]);
    if (@$check_movable_item->seminar_id != $SessionSeminar
        || (!$rechte && @$check_movable_item->user_id != $GLOBALS['user']->id)) {
        throw new AccessDeniedException();
    }
}

//verschieben / kopieren in andere Veranstaltung
if ($rechte && Request::submittedSome('move_to_sem', 'move_to_inst', 'move_to_top_folder')){
    if (!Request::submitted('move_to_top_folder')){
        $new_sem_id = Request::submitted('move_to_sem') ? Request::getArray('sem_move_id') : Request::getArray('inst_move_id');
    } else {
        $new_sem_id = array($SessSemName[1]);
    }
    if ($new_sem_id) {
        foreach($new_sem_id as $sid) {
示例#3
0
 public function add_to_course_action($material_id)
 {
     $this->material = new LernmarktplatzMaterial($material_id);
     if (Request::isPost() && Request::option("seminar_id") && $GLOBALS['perm']->have_studip_perm("autor", Request::option("seminar_id"))) {
         //$course = new Course(Request::option("seminar_id"));
         $query = "SELECT folder_id FROM folder WHERE range_id = ? ORDER BY name";
         $statement = DBManager::get()->prepare($query);
         $statement->execute(array(Request::option("seminar_id")));
         $folder_id = $statement->fetch(PDO::FETCH_COLUMN, 0);
         if ($folder_id && ($GLOBALS['perm']->have_studip_perm("tutor", Request::option("seminar_id")) || in_array("writable", DocumentFolder::find($folder_id)->getPermissions()))) {
             if ($this->material['host_id']) {
                 $path = $GLOBALS['TMP_PATH'] . "/tmp_download_" . md5(uniqid());
                 file_put_contents($path, file_get_contents($this->material->host->url . "download/" . $this->material['foreign_material_id']));
             } else {
                 $path = $this->material->getFilePath();
             }
             $document = StudipDocument::createWithFile($path, array('name' => $this->material['name'], 'range_id' => $folder_id, 'user_id' => $GLOBALS['user']->id, 'seminar_id' => Request::option("seminar_id"), 'description' => $this->material['description'] ?: $this->material['short_description'], 'filename' => $this->material['filename'], 'filesize' => filesize($path), 'author_name' => get_fullname()));
             PageLayout::postMessage(MessageBox::success(_("Datei wurde erfolgreich kopiert.")));
             $this->redirect(URLHelper::getURL("folder.php#anker", array('cid' => Request::option("seminar_id"), 'data' => array('cmd' => "tree", 'open' => array($folder_id => 1, $document->getId() => 1)), 'open' => $document->getId())));
             if ($this->material['host_id']) {
                 //cleanup
                 @unlink($path);
             }
         } else {
             PageLayout::postMessage(MessageBox::error(_("Veranstaltung hat keinen allgemeinen Dateiordner.")));
             $this->redirect(PluginEngine::getURL($this->plugin, array(), "market/details/" . $material_id));
         }
     }
     $this->courses = Course::findBySQL("INNER JOIN seminar_user USING (Seminar_id) WHERE seminar_user.user_id = ? ORDER BY seminare.mkdate DESC", array($GLOBALS['user']->id));
 }
示例#4
0
文件: Files.php 项目: ratbird/hope
 private function loadFolder($id)
 {
     $folder = new \DocumentFolder($id);
     // return NULL unless it exists
     if ($folder->isNew()) {
         return null;
     }
     $seminar_id = $folder->seminar_id;
     if (!self::isDocumentModuleActivated($seminar_id)) {
         $this->error(404, "Not found.");
     }
     if (!$GLOBALS['perm']->have_studip_perm('user', $seminar_id, $GLOBALS['user']->id)) {
         $this->error(401);
     }
     return $folder;
 }