コード例 #1
0
ファイル: StudipLog.class.php プロジェクト: ratbird/hope
 /**
  * Finds all seminars by given search string. Searches for the name of
  * existing or already deleted seminars.
  * 
  * @param string $needle The needle to search for.
  * @return array 
  */
 public static function searchSeminar($needle)
 {
     $result = array();
     // search for active seminars
     $courses = Course::findBySQL("VeranstaltungsNummer LIKE CONCAT('%', :needle, '%')\n                     OR seminare.Name LIKE CONCAT('%', :needle, '%')", array(':needle' => $needle));
     foreach ($courses as $course) {
         $title = sprintf('%s %s (%s)', $course->VeranstaltungsNummer, my_substr($course->name, 0, 40), $course->start_semester->name);
         $result[] = array($course->getId(), $title);
     }
     // search deleted seminars
     // SemName and Number is part of info field, old id (still in DB) is in affected column
     $log_action_ids_archived_seminar = SimpleORMapCollection::createFromArray(LogAction::findBySQL("name IN ('SEM_ARCHIVE', 'SEM_DELETE_FROM_ARCHIVE')"))->pluck('action_id');
     $log_events_archived_seminar = LogEvent::findBySQL("info LIKE CONCAT('%', ?, '%')\n                AND action_id IN (?) ", array($needle, $log_action_ids_archived_seminar));
     foreach ($log_events_archived_seminar as $log_event) {
         $title = sprintf('%s (%s)', my_substr($log_event->info, 0, 40), _('gelöscht'));
         $result[] = array($log_event->affected_range_id, $title);
     }
     return $result;
 }
コード例 #2
0
ファイル: ProfileModel.php プロジェクト: ratbird/hope
 /**
  * Creates an array with all seminars
  *
  * @return array
  */
 function getDozentSeminars()
 {
     $semester = $courses = array();
     $semester[] = Semester::findNext();
     $semester[] = Semester::findCurrent();
     $semester[] = Semester::findByTimestamp(Semester::findCurrent()->beginn - 1);
     if (Config::get()->IMPORTANT_SEMNUMBER) {
         $field = 'veranstaltungsnummer';
     } else {
         $field = 'name';
     }
     $allcourses = new SimpleCollection(Course::findBySQL("INNER JOIN seminar_user USING(Seminar_id) WHERE user_id=? AND seminar_user.status='dozent' AND seminare.visible=1", array($this->current_user->id)));
     foreach (array_filter($semester) as $one) {
         $courses[$one->name] = $allcourses->filter(function ($c) use($one) {
             return $c->start_time <= $one->beginn && ($one->beginn <= $c->start_time + $c->duration_time || $c->duration_time == -1);
         })->orderBy($field);
         if (!$courses[$one->name]->count()) {
             unset($courses[$one->name]);
         }
     }
     return $courses;
 }
コード例 #3
0
ファイル: market.php プロジェクト: Krassmus/LehrMarktplatz
 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));
 }