aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Siegfried <david.siegfried@uni-vechta.de>2024-04-11 08:11:42 +0000
committerJan-Hendrik Willms <tleilax+github@gmail.com>2024-04-11 16:17:14 +0200
commitd50b7ce4fff0f068233ec3d8a9460668859ac9bb (patch)
tree0d669e5dceefa38852261433d8f5288a75320cbc
parent7051c822d51fca6a9b594117fcbd60876847c510 (diff)
fixes #3996
Closes #3996 Merge request studip/studip!2846
-rw-r--r--app/controllers/admin/courses.php163
1 files changed, 0 insertions, 163 deletions
diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php
index 7130cd2..4882f8e 100644
--- a/app/controllers/admin/courses.php
+++ b/app/controllers/admin/courses.php
@@ -1447,169 +1447,6 @@ class Admin_CoursesController extends AuthenticatedController
return $views;
}
- /**
- * Returns all courses matching set criteria.
- *
- * @param array $params Additional parameters
- * @param bool $display_all : boolean should we show all courses or check for a limit of 500 courses?
- * @return array of courses
- */
- private function getCourses($params = [], $display_all = false)
- {
- // Init
- if ($GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT === "all") {
- $inst = new SimpleCollection($this->insts);
- $inst->filter(function ($a) use (&$inst_ids) {
- $inst_ids[] = $a->Institut_id;
- });
- } else {
- //We must check, if the institute ID belongs to a faculty
- //and has the string _i appended to it.
- //In that case we must display the courses of the faculty
- //and all its institutes.
- //Otherwise we just display the courses of the faculty.
-
- $inst_id = $GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT;
-
- $institut = new Institute($inst_id);
-
- if (!$institut->isFaculty() || $GLOBALS['user']->cfg->MY_INSTITUTES_INCLUDE_CHILDREN) {
- // If the institute is not a faculty or the child insts are included,
- // pick the institute IDs of the faculty/institute and of all sub-institutes.
- $inst_ids[] = $inst_id;
- if ($institut->isFaculty()) {
- foreach ($institut->sub_institutes->pluck('Institut_id') as $institut_id) {
- $inst_ids[] = $institut_id;
- }
- }
- } else {
- // If the institute is a faculty and the child insts are not included,
- // pick only the institute id of the faculty:
- $inst_ids[] = $inst_id;
- }
- }
-
- $active_elements = $this->getActiveElements();
-
- $filter = AdminCourseFilter::get(true);
-
- if ($params['datafields']) {
- foreach ($params['datafields'] as $field_id => $value) {
- $datafield = DataField::find($field_id);
- if ($datafield) {
- //enable filtering by datafield values:
- //and use the where-clause for each datafield:
- $filter->settings['query']['joins']['de_'.$field_id] = [
- 'table' => "datafields_entries",
- 'join' => "LEFT JOIN",
- 'on' => "seminare.seminar_id = de_".$field_id.".range_id"
- ];
- $filter->where("(de_".$field_id.".datafield_id = :fieldId_".$field_id." "
- . "AND de_".$field_id.".content = :fieldValue_".$field_id.") "
- . ($datafield['default_value'] == $value ? " OR (de_".$field_id.".content IS NULL)" : "")." ",
- [
- 'fieldId_'.$field_id => $field_id,
- 'fieldValue_'.$field_id => $value
- ]
- );
- }
- }
- }
-
- $filter->where("sem_classes.studygroup_mode = '0'");
-
- // Get only children of given course
- if (!empty($params['parent_course'])) {
- $filter->where("parent_course = :parent",
- [
- 'parent' => $params['parent_course']
- ]
- );
- }
-
- if ($active_elements['semester'] && is_object($this->semester)) {
- $filter->filterBySemester($this->semester->getId());
- }
- if ($active_elements['courseType'] && $params['typeFilter'] && $params['typeFilter'] !== "all") {
- $parts = explode('_', $params['typeFilter']);
- $class_filter = $parts[0];
- $type_filter = $parts[1] ?? null;
- if (!$type_filter && !empty($GLOBALS['SEM_CLASS'][$class_filter])) {
- $type_filter = array_keys($GLOBALS['SEM_CLASS'][$class_filter]->getSemTypes());
- }
- $filter->filterByType($type_filter);
- }
- if ($active_elements['search'] && $GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT) {
- $filter->filterBySearchString($GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT);
- }
- if ($active_elements['teacher'] && $GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER && ($GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER !== "all")) {
- $filter->filterByDozent($GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER);
- }
- if ($active_elements['institute']) {
- $filter->filterByInstitute($inst_ids);
- }
- if ($GLOBALS['user']->cfg->MY_COURSES_SELECTED_STGTEIL && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_STGTEIL !== 'all') {
- $filter->filterByStgTeil($GLOBALS['user']->cfg->MY_COURSES_SELECTED_STGTEIL);
- }
- if ($params['sortby'] === "status") {
- $filter->orderBy(sprintf('sem_classes.name %s, sem_types.name %s, VeranstaltungsNummer %s', $params['sortFlag'], $params['sortFlag'], $params['sortFlag']), $params['sortFlag']);
- } elseif ($params['sortby'] === 'institute') {
- $filter->orderBy('Institute.Name', $params['sortFlag']);
- } elseif ($params['sortby']) {
- $filter->orderBy($params['sortby'], $params['sortFlag']);
- }
- $filter->storeSettings();
- $this->count_courses = $filter->countCourses();
- if ($this->count_courses && ($this->count_courses <= $filter->max_show_courses || $display_all)) {
- $courses = $filter->getCourses();
- } else {
- return [];
- }
-
- $seminars = [];
- if (!empty($courses)) {
- foreach ($courses as $seminar_id => $seminar) {
- $seminars[$seminar_id] = $seminar[0];
- $seminars[$seminar_id]['seminar_id'] = $seminar_id;
- $seminars[$seminar_id]['obj_type'] = 'sem';
- $dozenten = $this->getTeacher($seminar_id);
- $seminars[$seminar_id]['dozenten'] = $dozenten;
-
- if (in_array('contents', $params['view_filter'])) {
- $tools = new SimpleCollection(ToolActivation::findbyRange_id($seminar_id, "ORDER BY position"));
- $visit_data = get_objects_visits([$seminar_id], 0, null, null, $tools->pluck('plugin_id'));
- $seminars[$seminar_id]['visitdate'] = $visit_data[$seminar_id][0]['visitdate'];
- $seminars[$seminar_id]['last_visitdate'] = $visit_data[$seminar_id][0]['last_visitdate'];
- $seminars[$seminar_id]['tools'] = $tools;
- $seminars[$seminar_id]['navigation'] = MyRealmModel::getAdditionalNavigations(
- $seminar_id,
- $seminars[$seminar_id],
- $seminars[$seminar_id]['sem_class'] ?? null,
- $GLOBALS['user']->id,
- $visit_data[$seminar_id]
- );
- }
- //add last activity column:
- if (in_array('last_activity', $params['view_filter'])) {
- $seminars[$seminar_id]['last_activity'] = lastActivity($seminar_id);
- }
- if ((int)$this->selected_action === 17) {
- $seminars[$seminar_id]['admission_locked'] = false;
- if ($seminar[0]['course_set']) {
- $set = new CourseSet($seminar[0]['course_set']);
- if (!is_null($set) && $set->hasAdmissionRule('LockedAdmission')) {
- $seminars[$seminar_id]['admission_locked'] = 'locked';
- } else {
- $seminars[$seminar_id]['admission_locked'] = 'disable';
- }
- unset($set);
- }
- }
- }
- }
-
- return $seminars;
- }
/**
* Returns the teacher for a given cours