Skip to content
Snippets Groups Projects
Commit eef7f9f6 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fix jsonapi calls for studip trees, fixes #4746

Closes #4746

Merge request studip/studip!3543
parent 7355e3c9
No related branches found
No related tags found
No related merge requests found
......@@ -325,7 +325,7 @@ class RouteMap
$group->get('/tree-node/{id}', Routes\Tree\TreeShow::class);
$group->get('/tree-node/{id}/children', Routes\Tree\ChildrenOfTreeNode::class);
$group->get('/tree-node/{id}/courseinfo', Routes\Tree\CourseinfoOfTreeNode::class);
$group->get('/tree-node/{id}/courseinfo', Routes\Tree\CourseInfoOfTreeNode::class);
$group->get('/tree-node/{id}/courses', Routes\Tree\CoursesOfTreeNode::class);
$group->get('/tree-node/course/pathinfo/{classname}/{id}', Routes\Tree\PathinfoOfTreeNodeCourse::class);
$group->get('/tree-node/course/details/{id}', Routes\Tree\DetailsOfTreeNodeCourse::class);
......
......@@ -8,7 +8,7 @@ use Psr\Http\Message\ResponseInterface as Response;
use JsonApi\Errors\RecordNotFoundException;
use JsonApi\NonJsonApiController;
class CourseinfoOfTreeNode extends NonJsonApiController
class CourseInfoOfTreeNode extends NonJsonApiController
{
protected $allowedFilteringParameters = ['q', 'semester', 'semclass', 'recursive'];
......
......@@ -132,7 +132,8 @@ class RangeTreeNode extends SimpleORMap implements StudipTreeNode
'semester' => $semester_id
];
} else {
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = i.`seminar_id`)";
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = i.`seminar_id`)
WHERE 1";
$parameters = [];
}
......@@ -175,16 +176,18 @@ class RangeTreeNode extends SimpleORMap implements StudipTreeNode
): array
{
$query = "SELECT DISTINCT s.* FROM `seminar_inst` i";
$order_by = [];
if ($semester_id !== 'all') {
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = i.`seminar_id`)
LEFT JOIN `semester_courses` sc ON (i.`seminar_id` = sc.`course_id`)
WHERE sc.`semester_id` = :semester";
$parameters = [
'semester' => $semester_id
];
LEFT JOIN `semester_data` sd USING (`semester_id`)
WHERE sc.`semester_id` = :semester)";
$parameters = ['semester' => $semester_id];
$order_by[] = 'sd.`beginn`';
} else {
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = i.`seminar_id`)";
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = i.`seminar_id`)
WHERE 1";
$parameters = [];
}
......@@ -226,10 +229,11 @@ class RangeTreeNode extends SimpleORMap implements StudipTreeNode
}
if (Config::get()->IMPORTANT_SEMNUMBER) {
$query .= " ORDER BY s.`start_time`, s.`VeranstaltungsNummer`, s.`Name`";
} else {
$query .= " ORDER BY s.`start_time`, s.`Name`";
$order_by[] = 's.`VeranstaltungsNummer`';
}
$order_by[] = 's.`Name`';
$query .= " ORDER BY " . implode(', ', $order_by);
return DBManager::get()->fetchAll($query, $parameters, 'Course::buildExisting');
}
......
......@@ -516,7 +516,8 @@ class StudipStudyArea extends SimpleORMap implements StudipTreeNode
'semester' => $semester_id
];
} else {
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = t.`seminar_id`)";
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = t.`seminar_id`)
WHERE 1";
$parameters = [];
}
......@@ -557,16 +558,18 @@ class StudipStudyArea extends SimpleORMap implements StudipTreeNode
): array
{
$query = "SELECT DISTINCT s.* FROM `seminar_sem_tree` t";
$order_by = [];
if ($semester_id !== 'all') {
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = t.`seminar_id`)
LEFT JOIN `semester_courses` sc ON (t.`seminar_id` = sc.`course_id`)
LEFT JOIN `semester_data` sd USING (`semester_id`)
WHERE sc.`semester_id` = :semester";
$parameters = [
'semester' => $semester_id
];
$parameters = ['semester' => $semester_id];
$order_by = 'sd.`beginn`';
} else {
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = t.`seminar_id`)";
$query .= " JOIN `seminare` s ON (s.`Seminar_id` = t.`seminar_id`)
WHERE 1";
$parameters = [];
}
......@@ -606,10 +609,11 @@ class StudipStudyArea extends SimpleORMap implements StudipTreeNode
}
if (Config::get()->IMPORTANT_SEMNUMBER) {
$query .= " ORDER BY s.`start_time`, s.`VeranstaltungsNummer`, s.`Name`";
} else {
$query .= " ORDER BY s.`start_time`, s.`Name`";
$order_by[] = 's.`VeranstaltungsNummer`';
}
$order_by[] = 's.`Name`';
$query .= " ORDER BY " . implode(', ', $order_by);
return DBManager::get()->fetchAll($query, $parameters, 'Course::buildExisting');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment