Newer
Older
);
}
if (in_array('room_time', $filter_config)) {
$dates = $course->getAllDatesInSemester($this->semester);
$date_strings = $dates->toStringArray(true);
$row['room_time'] = implode("\n", $date_strings) ?: _('nicht angegeben');
}
if (in_array('requests', $filter_config)) {

André Noack
committed
$row['requests'] = $course->room_requests->count();
}
if (in_array('teachers', $filter_config)) {
$row['teachers'] = implode(
', ',

André Noack
committed
array_map(
function ($d) {
return $d->getUserFullName();
},
CourseMember::findByCourseAndStatus($course->id, 'dozent')
)
}
if (in_array('members', $filter_config)) {
$row['members'] = $course->getNumParticipants();
}
if (in_array('waiting', $filter_config)) {
$row['waiting'] = $course->getNumWaiting();
}
if (in_array('preliminary', $filter_config)) {
$row['preliminary'] = $course->getNumPrelimParticipants();
}
if (in_array('last_activity', $filter_config)) {
$row['last_activity'] = strftime('%x', lastActivity($course->id));
}
if (in_array('semester', $filter_config)) {
$row['semester'] = $course->getTextualSemester();

Rasmus Fuhse
committed
if (in_array('institute', $filter_config)) {
$row['institute'] = $course->home_institut ? (string) $course->home_institut['name'] : $course['institut_id'];

Rasmus Fuhse
committed
}
foreach (PluginManager::getInstance()->getPlugins(AdminCourseContents::class) as $plugin) {
foreach ($plugin->adminAvailableContents() as $index => $label) {
if (in_array($plugin->getPluginId() . "_" . $index, $filter_config)) {

André Noack
committed
$content = $plugin->adminAreaGetCourseContent($course, $index);
if ($content instanceof Flexi\Template) {
$content = $content->render();
}
$row[$plugin->getPluginId() . "_" . $index] = strip_tags($content);
$data[$course->id] = $row;
}
$captions = [];
foreach ($filter_config as $index) {
$captions[$index] = $view_filters[$index];
}
foreach (PluginManager::getInstance()->getPlugins(AdminCourseContents::class) as $plugin) {
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
foreach ($plugin->adminAvailableContents() as $index => $label) {
if (in_array($plugin->getPluginId() . "_" . $index, $filter_config)) {
$captions[$plugin->getPluginId() . "_" . $index] = $label;
}
}
}
$tmpname = md5(uniqid('Veranstaltungsexport'));
if (array_to_csv($data, $GLOBALS['TMP_PATH'] . '/' . $tmpname, $captions)) {
$this->redirect(FileManager::getDownloadURLForTemporaryFile(
$tmpname,
'Veranstaltungen_Export.csv'
));
return;
}
} else {
PageLayout::setTitle(_('Spalten zum Export auswählen'));
$this->fields = $this->getViewFilters();
$this->selection = $this->getFilterConfig();
}
}
/**
* Set the lockrules of courses
*/
public function set_lockrule_action()
{
if (!$GLOBALS['perm']->have_perm('admin')) {
throw new AccessDeniedException();
}
$result = false;
$courses = Request::getArray('lock_sem');
$errors = [];
if (!empty($courses)) {
foreach ($courses as $course_id => $value) {
if ($GLOBALS['perm']->have_studip_perm('dozent', $course_id)) {
// force to pre selection
if (Request::get('lock_sem_all') && Request::submitted('all')) {
$value = Request::get('lock_sem_all');
}
$course = Course::find($course_id);
if ($course->lock_rule === $value) {
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
continue;
}
$course->setValue('lock_rule', $value);
if (!$course->store()) {
$errors[] = $course->name;
} else {
$result = true;
}
}
}
if ($result) {
PageLayout::postSuccess(_('Die gewünschten Änderungen wurden erfolgreich durchgeführt!'));
}
if ($errors) {
PageLayout::postError(
_('Bei den folgenden Veranstaltungen ist ein Fehler aufgetreten'),
array_map('htmlReady', $errors)
);
}
}
$this->redirect('admin/courses/index');
}
/**
* Lock or unlock courses
*/
public function set_locked_action()
{
$admission_locked = Request::getArray('admission_locked');
$all_courses = Request::getArray('all_sem');
$course_set_id = CourseSet::getGlobalLockedAdmissionSetId();
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
foreach ($all_courses as $course_id) {
if ($GLOBALS['perm']->have_studip_perm('dozent', $course_id)) {
$set = CourseSet::getSetForCourse($course_id);
if (!is_null($set)) {
if (!$set->hasAdmissionRule('LockedAdmission')) {
continue;
}
if ($set->hasAdmissionRule('LockedAdmission') && !isset($admission_locked[$course_id])) {
if (CourseSet::removeCourseFromSet($set->getId(), $course_id)) {
$log_msg = _('Veranstaltung wurde entsperrt');
}
}
}
if (is_null($set) && isset($admission_locked[$course_id])) {
if (CourseSet::addCourseToSet($course_set_id, $course_id)) {
$log_msg = sprintf(_('Veranstaltung wurde gesperrt, set_id: %s'), $course_set_id);
}
}
if ($log_msg) {
StudipLog::log('SEM_CHANGED_ACCESS', $course_id, null, $log_msg);
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
}
}
}
PageLayout::postSuccess(_('Die gewünschten Änderungen wurden ausgeführt!'));
$this->redirect('admin/courses/index');
}
/**
* Set the visibility of a course
*/
public function set_visibility_action()
{
$result = false;
$visibilites = Request::intArray('visibility');
$all_courses = Request::getArray('all_sem');
$errors = [];
if (!empty($all_courses)) {
foreach ($all_courses as $course_id) {
if ($GLOBALS['perm']->have_studip_perm('tutor', $course_id)) {
$course = Course::find($course_id);
if ($course->isOpenEnded() || $course->end_semester->visible) {
$visibility = $visibilites[$course_id] ?? 0;
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
if ($course->visible == $visibility) {
continue;
}
$course->visible = $visibility;
if (!$course->store()) {
$errors[] = $course->name;
} else {
$result = true;
StudipLog::log($visibility ? 'SEM_VISIBLE' : 'SEM_INVISIBLE', $course->id);
}
}
}
}
if ($result) {
PageLayout::postSuccess(_('Die Sichtbarkeit wurde bei den gewünschten Veranstatungen erfolgreich geändert!'));
}
if ($errors) {
PageLayout::postError(
_('Bei den folgenden Veranstaltungen ist ein Fehler aufgetreten'),
array_map('htmlReady', $errors)
);
}
}
$this->redirect('admin/courses/index');
}
/**
* Set the additional course informations
*/
public function set_aux_lockrule_action()
{
$result = false;
$courses = Request::getArray('lock_sem');
$lock_sem_forced = Request::getArray('lock_sem_forced');
$errors = [];
if (!empty($courses)) {
foreach ($courses as $course_id => $value) {
if ($GLOBALS['perm']->have_studip_perm('tutor', $course_id)) {
// force to pre selection
if (Request::submitted('all')) {
$value = Request::get('lock_sem_all');
$value_forced = Request::int('aux_all_forced', 0);
$value_forced = $lock_sem_forced[$course_id] ?? 0;
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
}
$course = Course::find($course_id);
if (!$value) {
$value_forced = 0;
}
$course->setValue('aux_lock_rule', $value);
$course->setValue('aux_lock_rule_forced', $value_forced);
$ok = $course->store();
if ($ok === false) {
$errors[] = $course->name;
} elseif ($ok) {
$result = true;
}
}
}
if ($result) {
PageLayout::postSuccess(_('Die gewünschten Änderungen wurden erfolgreich durchgeführt!'));
}
if ($errors) {
PageLayout::postError(
_('Bei den folgenden Veranstaltungen ist ein Fehler aufgetreten'),
array_map('htmlReady', $errors)
);
}
}
$this->redirect('admin/courses/index');
}
/**
* Marks a course as complete/incomplete.
*
* @param String $course_id Id of the course
*/
public function toggle_complete_action($course_id)
{
if (!$GLOBALS['perm']->have_studip_perm('tutor', $course_id)) {
throw new AccessDeniedException();
}
$course = Course::find($course_id);
$course->completion = ((int)$course->completion + 1) % 3;
$course->store();
if (Request::isXhr()) {
$this->render_json([
'state' => (int)$course->completion,
'label' => $course->getCompetionLabel(),
]);
} else {
$this->redirect('admin/courses/index#course-' . $course_id);
}
}
/**
* Changes the notice for a course.
*
* @param string $course_id
*/
public function notice_action(Course $course)
{
if (Request::isPost()) {
$course->config->store('COURSE_ADMIN_NOTICE', trim(Request::get('notice')));
if (Request::isXhr()) {
$this->response->add_header('X-Dialog-Execute', 'STUDIP.AdminCourses.App.loadCourse');
$this->response->add_header('X-Dialog-Close', '1');
$this->render_text($course->id);
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
} else {
$this->redirect($this->indexURL("#course-{$course->id}"));
}
return;
}
$this->course = $course;
$this->notice = $course->config->COURSE_ADMIN_NOTICE;
}
/**
* Return a specifically action or all available actions
* @param null $selected
* @return array
*/
private function getActions($selected = null)
{
// array for the avaiable modules
$sem_filter = $this->semester ? $this->semester->beginn : 'all';
$actions = [
1 => [
'name' => _('Grunddaten'),
'title' => _('Grunddaten'),
'url' => 'dispatch.php/course/basicdata/view?cid=%s',
'attributes' => ['data-dialog' => 'size=big'],
],
2 => [
'name' => _('Studienbereiche'),
'title' => _('Studienbereiche'),
'url' => 'dispatch.php/course/study_areas/show/?cid=%s&from=admin/courses',
'attributes' => ['data-dialog' => 'size=big'],
],
3 => [
'name' => _('Zeiten/Räume'),
'title' => _('Zeiten/Räume'),
'url' => 'dispatch.php/course/timesrooms/index?cid=%s',
'attributes' => ['data-dialog' => 'size=big'],
'params' => [
'newFilter' => $sem_filter,
'cmd' => 'applyFilter'
],
],
8 => [
'name' => _('Sperrebene'),
'title' => _('Sperrebenen'),
'url' => 'dispatch.php/admin/courses/set_lockrule',
'multimode' => true,
'partial' => 'lock.php',
],
9 => [
'name' => _('Sichtbarkeit'),
'title' => _('Sichtbarkeit'),
'url' => 'dispatch.php/admin/courses/set_visibility',
'multimode' => true,
'partial' => 'visibility.php',
],
10 => [
'name' => _('Zusatzangaben'),
'title' => _('Zusatzangaben'),
'url' => 'dispatch.php/admin/courses/set_aux_lockrule',
'multimode' => true,
'partial' => 'aux-select.php',
],
11 => [
'name' => _('Veranstaltung kopieren'),
'title' => _('Kopieren'),
'url' => 'dispatch.php/course/wizard/copy/%s',
'attributes' => ['data-dialog' => 'size=big'],
],
14 => [
'name' => 'Zugangsberechtigungen',
'title' => _('Zugangsberechtigungen'),
'url' => 'dispatch.php/course/admission?cid=%s',
'attributes' => ['data-dialog' => 'size=big'],
],
16 => [
'name' => _('Löschen'),
'title' => _('Löschen'),
'url' => 'dispatch.php/course/archive/confirm',
'multimode' => true,
'partial' => 'add_to_archive.php',
],
17 => [
'name' => _('Gesperrte Veranstaltungen'),
'title' => _('Einstellungen speichern'),
'url' => 'dispatch.php/admin/courses/set_locked',
'multimode' => true,
'partial' => 'admission_locked.php',
],
18 => [
'name' => _('Startsemester'),
'title' => _('Startsemester'),
'url' => 'dispatch.php/course/timesrooms/editSemester?cid=%s&origin=admin_courses',
'attributes' => ['data-dialog' => 'size=400'],
],
19 => [
'name' => _('LV-Gruppen'),
'title' => _('LV-Gruppen'),
'url' => 'dispatch.php/course/lvgselector?cid=%s&from=admin/courses',
'attributes' => ['data-dialog' => 'size=big'],
],
20 => [
'name' => _('Notiz'),
'title' => _('Notiz'),
'url' => $this->noticeURL('%s'),
'attributes' => ['data-dialog' => 'size=auto'],
'partial' => 'notice-action.php',
],
21 => [
'name' => _('Mehrfachzuordnung von Studienbereichen'),
'title' => _('Mehrfachzuordnung von Studienbereichen'),
'url' => 'dispatch.php/admin/tree/batch_assign_semtree',
'dialogform' => true,
'multimode' => true,
'partial' => 'batch_assign_semtree.php'
],
22 => [
'name' => _('Teilnehmendenexport'),
'title' => _('Teilnehmendenexport'),
'url' => 'dispatch.php/admin/user/batch_export_members',
'dialogform' => true,
'multimode' => true,
'partial' => 'batch_export_members.php'
],
23 => [
'name' => _('Nachricht schreiben'),
'title' => _('Nachricht schreiben'),
'url' => 'dispatch.php/massmail/quick/courses',
'dialogform' => true,
'multimode' => true,
'partial' => 'massmail.php'
]
];
if (!$GLOBALS['perm']->have_perm('admin')) {
unset($actions[8]);
if (!Config::get()->ALLOW_DOZENT_DELETE) {
unset($actions[16]);
}
}
if (!$GLOBALS['perm']->have_perm('dozent')) {
unset($actions[11]);
unset($actions[16]);
}
ksort($actions);
foreach (PluginManager::getInstance()->getPlugins(AdminCourseAction::class) as $plugin) {
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
$actions[get_class($plugin)] = [
'name' => $plugin->getPluginName(),
'title' => $plugin->getPluginName(),
'url' => $plugin->getAdminActionURL(),
'attributes' => ['data-dialog' => 'size=big'],
'multimode' => $plugin->useMultimode()
];
}
if (is_null($selected)) {
return $actions;
}
return $actions[$selected];
}
/**
* Set and return all needed view filters
* @return array
*/
private function getViewFilters()
{
$views = [
'avatar' => _('Avatar'),
'number' => _('Nr.'),
'name' => _('Name'),
'type' => _('Veranstaltungstyp'),
'room_time' => _('Raum/Zeit'),
'semester' => _('Semester'),

Rasmus Fuhse
committed
'institute' => _('Einrichtung'),
'requests' => _('Raumanfragen'),
'teachers' => _('Lehrende'),
'members' => _('Teilnehmende'),
'waiting' => _('Personen auf Warteliste'),
'preliminary' => _('Vorläufige Anmeldungen'),
'contents' => _('Inhalt'),
'last_activity' => _('Letzte Aktivität'),
];
foreach (PluginManager::getInstance()->getPlugins(AdminCourseContents::class) as $plugin) {
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
foreach ($plugin->adminAvailableContents() as $index => $label) {
$views[$plugin->getPluginId() . "_" . $index] = $label;
}
}
return $views;
}
/**
* Returns the teacher for a given cours
*
* @param String $course_id Id of the course
* @return array of user infos [user_id, username, Nachname, fullname]
*/
private function getTeacher($course_id)
{
$teachers = CourseMember::findByCourseAndStatus($course_id, 'dozent');
$collection = SimpleCollection::createFromArray($teachers);
return $collection->map(function (CourseMember $teacher) {
return [
'user_id' => $teacher->user_id,
'username' => $teacher->username,
'Nachname' => $teacher->nachname,
'fullname' => $teacher->getUserFullname('no_title_rev'),
];
});
}
/**
* Adds the institutes selector to the sidebar
*/
private function getInstSelector()
$list = [];
if ($GLOBALS['perm']->have_perm('root') || (count($this->insts) > 1)) {
$list[] = new SelectElement(
$GLOBALS['perm']->have_perm('root') ? _('Alle') : _('Alle meine Einrichtungen')
);
}
foreach ($this->insts as $institut) {
$list[] =
new SelectElement(
$institut['Institut_id'],
(!$institut['is_fak'] ? ' ' : '') . $institut['Name'],
$GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT === $institut['Institut_id']

Rasmus Fuhse
committed
&& !$GLOBALS['user']->cfg->MY_INSTITUTES_INCLUDE_CHILDREN
//check if the institute is a faculty.
//If true, then add another option to display all courses
//from that faculty and all its institutes.
//$institut is an array, we can't use the method isFaculty() here!
if ($institut['fakultaets_id'] === $institut['Institut_id']) {
$list[] =
new SelectElement(
$institut['Institut_id'] . '_withinst', //_withinst = with institutes
' ' . $institut['Name'] . ' +' . _('Institute'),

Rasmus Fuhse
committed
$GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT === $institut['Institut_id']
&& $GLOBALS['user']->cfg->MY_INSTITUTES_INCLUDE_CHILDREN
return new SelectListElement(_('Einrichtung'), 'institute', $list, false, ['class' => 'institute-list', 'onchange' => "STUDIP.AdminCourses.changeFiltersDependendOnInstitute($(this).val()); return false;"], false);
}
/**
* Adds the semester selector to the sidebar
*/
private function getSemesterSelector()
{
$semesters = array_reverse(Semester::getAll());
$list = [];
$list[] = new SelectElement('', _('Alle'));
foreach ($semesters as $semester) {
$list[] = new SelectElement(
$semester->id,
$semester->name,
$semester->id === $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE
return new SelectListElement(_('Semester'), 'sem_select', $list, false, ['onchange' => "STUDIP.AdminCourses.App.changeFilter({semester_id: $(this).val()}); return false;"], false);
/**
* Adds the studiengangteil selector to the sidebar
*/
private function getStgteilSelector($institut_id = null)
$institut_id = $institut_id ?: $GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT;

Rasmus Fuhse
committed
if (str_contains($institut_id, '_')) {
$institut_id = substr($institut_id, 0, strpos($institut_id, '_'));
}
$stgteile = StudiengangTeil::getAllEnriched('fach_name', 'ASC', ['mvv_fach_inst.institut_id' => $institut_id]);
$list = [];
if (!$institut_id || $institut_id === 'all') {
$list[] = new SelectElement('', _('Wählen Sie eine Einrichtung'));
} else if (count($stgteile) === 0) {
$list[] = new SelectElement('', _('Keine Studiengangteile zu der gewählten Einrichtung'));
} else {
$list[] = new SelectElement('', _('Alle'));
foreach ($stgteile as $stgteil) {
$list[] = new SelectElement(
$stgteil->id,
$stgteil->getDisplayName(),
$stgteil->id === $GLOBALS['user']->cfg->MY_COURSES_SELECTED_STGTEIL
return new SelectListElement(_('Studiengangteil'), 'stgteil_select', $list, false, ['onchange' => "STUDIP.AdminCourses.App.changeFilter({stgteil: $(this).val()}); return false;"], false);
}
/**
* Adds HTML-Selector to the sidebar
* @param null $selected_action
*/
private function setActionsWidget()
{
$actions = $this->getActions();
$sidebar = Sidebar::Get();
$list = new SelectWidget(_('Aktionsbereichauswahl'), $this->url_for('admin/courses/set_action_type'), 'action_area');
foreach ($actions as $index => $action) {
$list->addElement(new SelectElement(
$index,
$action['name'],
$GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA == $index),
'action-aria-' . $index
);
$list->setOnSubmitHandler("STUDIP.AdminCourses.App.changeActionArea($(this).find('select').val()); return false;");
$sidebar->addWidget($list, 'editmode');
}
/**
* Returns a course type widthet depending on all available courses and theirs types
* @param string $selected
* @param array $params
*/
private function getCourseTypeWidget()
$list = [];
$list[] = new SelectElement(
'', _('Alle')
);
foreach ($GLOBALS['SEM_CLASS'] as $class_id => $class) {
if ($class['studygroup_mode']) {
continue;
}
$element = new SelectElement(
$class_id,
$class['name'],
$GLOBALS['user']->cfg->MY_COURSES_TYPE_FILTER === (string)$class_id
$list[] = $element->setAsHeader();
foreach ($class->getSemTypes() as $id => $result) {
$element = new SelectElement(
$class_id . '_' . $id,
$result['name'],
$GLOBALS['user']->cfg->MY_COURSES_TYPE_FILTER === $class_id . '_' . $id
$list[] = $element->setIndentLevel(1);
return new SelectListElement(_('Veranstaltungstypfilter'), 'course_type', $list, false, ['onchange' => "STUDIP.AdminCourses.App.changeFilter({course_type: $(this).val()}); return false;"], false);
}
/**
* Returns a widget to selected a specific teacher
* @param array $teachers
*/
private function getTeacherWidget($institut_id = null)

André Noack
committed
if ($institut_id) {
if (str_contains($institut_id, '_')) {
$institut_id = substr($institut_id, 0, strpos($institut_id, '_'));
$GLOBALS['user']->cfg->store('MY_INSTITUTES_INCLUDE_CHILDREN', 1);
} else {
$GLOBALS['user']->cfg->store('MY_INSTITUTES_INCLUDE_CHILDREN', 0);
}
} else {
$institut_id = $GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT;

Rasmus Fuhse
committed
}

André Noack
committed
$teachers = [];

André Noack
committed
$include_children = $GLOBALS['user']->cfg->MY_INSTITUTES_INCLUDE_CHILDREN ? ' OR Institute.fakultaets_id = :institut_id ' : '';
if ($institut_id) {
$teachers = DBManager::get()->fetchAll("
SELECT auth_user_md5.*, user_info.*
FROM auth_user_md5
LEFT JOIN user_info ON (auth_user_md5.user_id = user_info.user_id)
INNER JOIN user_inst ON (user_inst.user_id = auth_user_md5.user_id)
INNER JOIN Institute ON (Institute.Institut_id = user_inst.Institut_id)

André Noack
committed
WHERE (Institute.Institut_id = :institut_id $include_children)
AND user_inst.inst_perms = 'dozent'
GROUP BY auth_user_md5.user_id
ORDER BY auth_user_md5.Nachname ASC, auth_user_md5.Vorname ASC
", [
'institut_id' => $institut_id
],
function ($data) {
$ret['user_id'] = $data['user_id'];
unset($data['user_id']);
$ret['fullname'] = User::build($data)->getFullName("full_rev");
return $ret;
}
);
}
$list = [];
if (!$institut_id || $institut_id === 'all') {
$list[] = new SelectElement('', _('Wählen Sie eine Einrichtung'));
} else if (count($teachers) === 0) {
$list[] = new SelectElement('', _('Keine Lehrenden in der gewählten Einrichtung'));
} else {
$list[] = new SelectElement('', _('Alle'));
foreach ($teachers as $teacher) {
$list[] = new SelectElement(
$teacher['user_id'],
$teacher['fullname'],
$GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER === $teacher['user_id']
return new SelectListElement(_('Lehrendenfilter'), 'teacher_filter', $list, false, ['onchange' => "STUDIP.AdminCourses.App.changeFilter({teacher_filter: $(this).val()}); return false;"], false);
}
/**
* Adds a search widget to the sidebar
*/
private function setSearchWiget()
{
$sidebar = Sidebar::Get();
$search = new SearchWidget(URLHelper::getURL('dispatch.php/admin/courses'));
$search->addNeedle(
_('Freie Suche'),
'search',
true,
null,
'',
$GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT
);
$search->setOnSubmitHandler("STUDIP.AdminCourses.App.changeFilter({search: $(this).find('input').val()}); return false;");
$search->setOnClearHandler("STUDIP.AdminCourses.App.changeFilter({search: ''});");
$sidebar->addWidget($search, 'filter_search');
}
/**
* Returns the filter configuration.
*
* @return array containing the filter configuration
*/

Jan-Hendrik Willms
committed
private function getFilterConfig(): array
{
$available_filters = array_keys($this->getViewFilters());
$temp = $GLOBALS['user']->cfg->MY_COURSES_ADMIN_VIEW_FILTER_ARGS;
if ($temp) {
$config = json_decode($temp, true);
if (!is_array($config)) {
$config = [];
}
$config = array_intersect($config, $available_filters);
} else {
$config = [];
}
if (!$config) {
$config = $this->setFilterConfig([
'number', 'name', 'semester', 'institute', 'teachers'
]);
return array_values($config);
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
}
/**
* Sets the filter configuration.
*
* @param Array $config Filter configuration
* @return array containing the filter configuration
*/
private function setFilterConfig($config)
{
$config = $config ?: array_keys($this->getViewFilters());
$GLOBALS['user']->cfg->store('MY_COURSES_ADMIN_VIEW_FILTER_ARGS', json_encode($config));
return $config;
}
/**
* Returns the default element configuration.
*
* @return array containing the default element configuration
*/
private function getActiveElementsDefault()
{
return [
'search' => true,
'institute' => true,
'semester' => true,
'stgteil' => true,
'courseType' => true,
'teacher' => true,
];
}
/**
* Returns the active element configuration of the current user.
*
* @return array containing the active element configuration
*/
private function getActiveElements()
{
$active_elements = $GLOBALS['user']->cfg->ADMIN_COURSES_SIDEBAR_ACTIVE_ELEMENTS;
if ($active_elements) {
return json_decode($active_elements, true);
} else {
return $this->getActiveElementsDefault();
}
}
/**
* Sets the active element configuration for the current user.
*
* @param Array $active_elements element configuration
*/
private function setActiveElements($active_elements)
{
if ($active_elements == $this->getActiveElementsDefault()) {
$GLOBALS['user']->cfg->delete('ADMIN_COURSES_SIDEBAR_ACTIVE_ELEMENTS');
} else {
$GLOBALS['user']->cfg->store('ADMIN_COURSES_SIDEBAR_ACTIVE_ELEMENTS', json_encode($active_elements));
}
}
}