aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Siegfried <david.siegfried@uni-vechta.de>2022-09-30 08:29:51 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2022-09-30 08:29:51 +0000
commitff24292c8f72dfba0c8e7c5bf275c82f5901008d (patch)
treeec8c0befcdee69059a2555176a5eb38a2ab8eff3
parente6fea248e6b166bff7811a2dd4f0a836c3fbf3b6 (diff)
replace course-filter in course-management and add order function, closes #1583
Closes #1583 Merge request studip/studip!1013
-rw-r--r--app/controllers/course/admission.php122
-rw-r--r--app/controllers/course/basicdata.php98
-rw-r--r--app/controllers/course/management.php42
-rw-r--r--app/controllers/course/room_requests.php48
-rw-r--r--app/controllers/course/study_areas.php58
-rw-r--r--app/controllers/course/timesrooms.php24
-rw-r--r--app/views/course/shared/order_settings.php14
-rw-r--r--db/migrations/5.3.3_tic_1583_course_selector.php31
-rw-r--r--lib/classes/AdminCourseFilter.class.php48
-rw-r--r--lib/classes/sidebar/CourseManagementSelectWidget.php47
-rw-r--r--lib/classes/sidebar/SelectWidget.php14
-rw-r--r--lib/classes/sidebar/SidebarWidget.php8
-rw-r--r--resources/assets/javascripts/bootstrap/forms.js11
-rw-r--r--resources/assets/stylesheets/scss/i18n.scss1
-rw-r--r--templates/sidebar/select-widget.php2
15 files changed, 313 insertions, 255 deletions
diff --git a/app/controllers/course/admission.php b/app/controllers/course/admission.php
index 1e8832e..78f1c1d 100644
--- a/app/controllers/course/admission.php
+++ b/app/controllers/course/admission.php
@@ -18,10 +18,8 @@ class Course_AdmissionController extends AuthenticatedController
/**
* common tasks for all actions
*/
- function before_filter (&$action, &$args)
+ public function before_filter (&$action, &$args)
{
- global $perm;
-
parent::before_filter($action, $args);
$course_id = $args[0] ?? '';
@@ -32,7 +30,7 @@ class Course_AdmissionController extends AuthenticatedController
if (!get_object_type($this->course_id, ['sem']) ||
SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode ||
- !$perm->have_studip_perm("tutor", $this->course_id)) {
+ !$GLOBALS['perm']->have_studip_perm('tutor', $this->course_id)) {
throw new Trails_Exception(403);
}
@@ -56,24 +54,14 @@ class Course_AdmissionController extends AuthenticatedController
/**
* Shows the current restrictions for course participation.
*/
- function index_action()
+ public function index_action()
{
URLHelper::addLinkParam('return_to_dialog', Request::isDialog());
$this->sidebar = Sidebar::get();
- if ($GLOBALS['perm']->have_perm('admin')) {
- $list = new SelectWidget(_('Veranstaltungen'), '?#admin_top_links', 'cid');
-
- foreach (AdminCourseFilter::get()->getCoursesForAdminWidget() as $seminar) {
- $list->addElement(new SelectElement(
- $seminar['Seminar_id'],
- $seminar['Name'],
- $seminar['Seminar_id'] === Context::getId(),
- $seminar['VeranstaltungsNummer'] . ' ' . $seminar['Name']
- ));
- }
- $list->size = 8;
- $this->sidebar->addWidget($list);
+ if ($GLOBALS['perm']->have_studip_perm('admin', $this->course_id)) {
+ $widget = new CourseManagementSelectWidget();
+ $this->sidebar->addWidget($widget);
}
$this->all_domains = UserDomain::getUserDomains();
@@ -85,41 +73,49 @@ class Course_AdmissionController extends AuthenticatedController
foreach (CourseSet::getCoursesetsByInstituteId($this->course->institut_id) as $cs) {
$cs = new CourseSet($cs['set_id']);
if ($cs->isUserAllowedToAssignCourse($this->user_id, $this->course_id)) {
- $available_coursesets[] = ['id' => $cs->getId(),
- 'name' => $cs->getName(),
- 'chdate' => $cs->getChdate(),
- 'my_own' => $cs->getUserId() === $GLOBALS['user']->id];
+ $available_coursesets[] = [
+ 'id' => $cs->getId(),
+ 'name' => $cs->getName(),
+ 'chdate' => $cs->getChdate(),
+ 'my_own' => $cs->getUserId() === $GLOBALS['user']->id
+ ];
}
}
foreach (CourseSet::getglobalCoursesets() as $cs) {
$cs = new CourseSet($cs['set_id']);
if ($cs->isUserAllowedToAssignCourse($this->user_id, $this->course_id)) {
- $available_coursesets[] = ['id' => $cs->getId(),
- 'name' => $cs->getName(),
- 'chdate' => $cs->getChdate(),
- 'my_own' => $cs->getUserId() === $GLOBALS['user']->id];
+ $available_coursesets[] = [
+ 'id' => $cs->getId(),
+ 'name' => $cs->getName(),
+ 'chdate' => $cs->getChdate(),
+ 'my_own' => $cs->getUserId() === $GLOBALS['user']->id
+ ];
}
}
$available_coursesets = $available_coursesets->findBy('chdate', strtotime('-1 year'), '>');
$available_coursesets->orderBy('name');
$this->available_coursesets = $available_coursesets;
- PageLayout::postMessage(MessageBox::info(_("Für diese Veranstaltung sind keine Anmelderegeln festgelegt. Die Veranstaltung ist damit für alle Nutzer zugänglich.")));
+ PageLayout::postInfo(
+ _('Für diese Veranstaltung sind keine Anmelderegeln festgelegt. Die Veranstaltung ist damit für alle Nutzer zugänglich.')
+ );
} else {
if ($this->current_courseset->isSeatDistributionEnabled() && !$this->course->admission_turnout) {
- PageLayout::postMessage(MessageBox::info(_("Diese Veranstaltung ist teilnahmebeschränkt, aber die maximale Teilnehmendenanzahl ist nicht gesetzt.")));
+ PageLayout::postInfo(
+ _('Diese Veranstaltung ist teilnahmebeschränkt, aber die maximale Teilnehmendenanzahl ist nicht gesetzt.')
+ );
}
}
$lockdata = LockRules::getObjectRule($this->course_id);
- if (!empty($lockdata['description']) && LockRules::CheckLockRulePermission($this->course_id)) {
- PageLayout::postMessage(MessageBox::info(formatLinks($lockdata['description'])));
+ if ($lockdata['description'] && LockRules::CheckLockRulePermission($this->course_id)) {
+ PageLayout::postInfo(formatLinks($lockdata['description']));
}
}
/**
* Change preliminary admission settings.
*/
- function change_admission_prelim_action()
+ public function change_admission_prelim_action()
{
CSRFProtection::verifyUnsafeRequest();
PageLayout::setTitle(_('Anmeldemodus ändern'));
@@ -151,7 +147,10 @@ class Course_AdmissionController extends AuthenticatedController
restoreLanguage();
}
if ($num_moved) {
- PageLayout::postMessage(MessageBox::success(sprintf(_("%s Teilnehmende wurden auf vorläufigen Eintrag gesetzt."), $num_moved)));
+ PageLayout::postSuccess(sprintf(
+ _('%s Teilnehmende wurden auf vorläufigen Eintrag gesetzt.'),
+ $num_moved
+ ));
}
}
if ($this->course->admission_prelim == 0 && $this->course->getNumPrelimParticipants()) {
@@ -167,7 +166,10 @@ class Course_AdmissionController extends AuthenticatedController
restoreLanguage();
}
if ($num_moved) {
- PageLayout::postMessage(MessageBox::success(sprintf(_("%s Teilnehmende wurden in die Veranstaltung übernommen."), $num_moved)));
+ PageLayout::postSuccess(sprintf(
+ _('%s Teilnehmende wurden in die Veranstaltung übernommen.'),
+ $num_moved
+ ));
}
}
if (Request::submitted('change_admission_prelim_no')) {
@@ -181,13 +183,16 @@ class Course_AdmissionController extends AuthenticatedController
$num_moved += $applicant->delete();
}
if ($num_moved) {
- PageLayout::postMessage(MessageBox::success(sprintf(_("%s vorläufige Teilnehmende wurden entfernt."), $num_moved)));
+ PageLayout::postSuccess(sprintf(
+ _('%s vorläufige Teilnehmende wurden entfernt.'),
+ $num_moved
+ ));
$this->course->resetRelation('admission_applicants');
}
}
}
if ($this->course->store()) {
- PageLayout::postMessage(MessageBox::success(_("Der Anmeldemodus wurde geändert.")));
+ PageLayout::postSuccess(_("Der Anmeldemodus wurde geändert."));
}
unset($question);
}
@@ -206,7 +211,7 @@ class Course_AdmissionController extends AuthenticatedController
/**
* Change free access settings.
*/
- function change_free_access_action()
+ public function change_free_access_action()
{
CSRFProtection::verifyUnsafeRequest();
if (Request::submitted('change_free_access')) {
@@ -284,12 +289,15 @@ class Course_AdmissionController extends AuthenticatedController
}
if ($num_moved) {
$this->course->resetRelation('admission_applicants');
- PageLayout::postMessage(MessageBox::success(sprintf(_("%s Wartende wurden entfernt."), $num_moved)));
+ PageLayout::postSuccess(sprintf(
+ _('%s Wartende wurden entfernt.'),
+ $num_moved
+ ));
}
}
if ($this->course->store()) {
- PageLayout::postMessage(MessageBox::success(_("Die Teilnehmendenanzahl wurde geändert.")));
+ PageLayout::postSuccess(_('Die Teilnehmendenanzahl wurde geändert.'));
}
unset($question);
}
@@ -299,12 +307,12 @@ class Course_AdmissionController extends AuthenticatedController
} else {
$this->request = $request;
$this->button_yes = 'change_admission_turnout_yes';
- PageLayout::postMessage(MessageBox::info($question));
+ PageLayout::postInfo($question);
$this->render_template('course/admission/_change_admission.php');
}
}
- function change_domains_action()
+ public function change_domains_action()
{
CSRFProtection::verifyUnsafeRequest();
if (Request::submitted('change_domains') && !LockRules::Check($this->course_id, 'user_domain')) {
@@ -331,7 +339,10 @@ class Course_AdmissionController extends AuthenticatedController
CourseSet::addCourseToSet($cs->getId(), $this->course_id);
$cs->load();
if (in_array($this->course_id, $cs->getCourses())) {
- PageLayout::postMessage(MessageBox::success(sprintf(_("Die Zuordnung zum Anmeldeset %s wurde durchgeführt."), htmlReady($cs->getName()))));
+ PageLayout::postSuccess(sprintf(
+ _('Die Zuordnung zum Anmeldeset %s wurde durchgeführt.'),
+ htmlReady($cs->getName())
+ ));
}
}
}
@@ -352,11 +363,12 @@ class Course_AdmissionController extends AuthenticatedController
CourseSet::removeCourseFromSet($cs->getId(), $this->course_id);
$cs->load();
if (!in_array($this->course_id, $cs->getCourses())) {
- PageLayout::postMessage(MessageBox::success(sprintf(_("Die Zuordnung zum Anmeldeset %s wurde aufgehoben."), htmlReady($cs->getName()))));
+ PageLayout::postSuccess(sprintf(
+ _('Die Zuordnung zum Anmeldeset %s wurde aufgehoben.'),
+ htmlReady($cs->getName())
+ ));
}
- if (!count($cs->getCourses())
- && $cs->isGlobal()
- && $cs->getUserid() != '') {
+ if (!count($cs->getCourses()) && $cs->isGlobal() && $cs->getUserid() != '') {
$cs->delete();
}
if ($this->course->getNumWaiting()) {
@@ -371,7 +383,9 @@ class Course_AdmissionController extends AuthenticatedController
}
if ($num_moved) {
$this->course->resetRelation('admission_applicants');
- PageLayout::postMessage(MessageBox::success(sprintf(_("%s Wartende wurden entfernt."), $num_moved)));
+ PageLayout::postSuccess(sprintf(
+ _('%s Wartende wurden entfernt.'), $num_moved
+ ));
}
}
}
@@ -381,12 +395,12 @@ class Course_AdmissionController extends AuthenticatedController
} else {
$this->request = ['change_course_set_unassign' => 1];
$this->button_yes = 'change_course_set_unassign_yes';
- PageLayout::postMessage(MessageBox::info($question));
+ PageLayout::postInfo($question);
$this->render_template('course/admission/_change_admission.php');
}
}
- function explain_course_set_action()
+ public function explain_course_set_action()
{
$cs = new CourseSet(Request::option('set_id'));
if ($cs->getId()) {
@@ -420,7 +434,7 @@ class Course_AdmissionController extends AuthenticatedController
if ($rule instanceof LockedAdmission) {
$course_set_id = CourseSet::getGlobalLockedAdmissionSetId();
CourseSet::addCourseToSet($course_set_id, $this->course_id);
- PageLayout::postMessage(MessageBox::success(_("Die Veranstaltung wurde gesperrt.")));
+ PageLayout::postSuccess(_('Die Veranstaltung wurde gesperrt.'));
$this->redirect($this->action_url('index'));
return;
} else {
@@ -442,7 +456,7 @@ class Course_AdmissionController extends AuthenticatedController
$course_set->setName(trim(Request::get('instant_course_set_name')));
}
if (count($errors)) {
- PageLayout::postMessage(MessageBox::error(_("Speichern fehlgeschlagen"), array_map('htmlready', $errors)));
+ PageLayout::postError(_('Speichern fehlgeschlagen'), array_map('htmlready', $errors));
} else {
$rule->store();
$course_set->setPrivate(true);
@@ -453,7 +467,7 @@ class Course_AdmissionController extends AuthenticatedController
$course_set->addAdmissionRule($another_rule);
}
$course_set->store();
- PageLayout::postMessage(MessageBox::success(_("Die Anmelderegel wurde erzeugt und der Veranstaltung zugewiesen.")));
+ PageLayout::postSuccess(_("Die Anmelderegel wurde erzeugt und der Veranstaltung zugewiesen."));
$this->redirect($this->action_url('index'));
return;
}
@@ -476,7 +490,7 @@ class Course_AdmissionController extends AuthenticatedController
}
}
- function edit_courseset_action($cs_id)
+ public function edit_courseset_action($cs_id)
{
$cs = new CourseSet($cs_id);
if ($cs->isUserAllowedToEdit($this->user_id)) {
@@ -491,7 +505,7 @@ class Course_AdmissionController extends AuthenticatedController
}
}
- function save_courseset_action($cs_id)
+ public function save_courseset_action($cs_id)
{
$cs = new CourseSet($cs_id);
if ($cs->isUserAllowedToEdit($this->user_id)) {
@@ -506,7 +520,7 @@ class Course_AdmissionController extends AuthenticatedController
}
}
- function after_filter($action, $args)
+ public function after_filter($action, $args)
{
if (Request::isXhr() && !Request::get('return_to_dialog')) {
foreach ($this->response->headers as $k => $v) {
diff --git a/app/controllers/course/basicdata.php b/app/controllers/course/basicdata.php
index efff192..7475813 100644
--- a/app/controllers/course/basicdata.php
+++ b/app/controllers/course/basicdata.php
@@ -14,6 +14,7 @@
* @since 2.0
*/
+
class Course_BasicdataController extends AuthenticatedController
{
public $msg = [];
@@ -262,8 +263,6 @@ class Course_BasicdataController extends AuthenticatedController
*/
public function view_action($course_id = null)
{
- global $user, $perm, $_fullname_sql;
-
$deputies_enabled = Config::get()->DEPUTIES_ENABLE;
//damit QuickSearch funktioniert:
@@ -278,7 +277,7 @@ class Course_BasicdataController extends AuthenticatedController
Navigation::activateItem('/course/admin/details');
//Berechtigungscheck:
- if (!$perm->have_studip_perm("tutor",$this->course_id)) {
+ if (!$GLOBALS['perm']->have_studip_perm('tutor', $this->course_id)) {
throw new AccessDeniedException(_("Sie haben keine Berechtigung diese " .
"Veranstaltung zu verändern."));
}
@@ -313,47 +312,48 @@ class Course_BasicdataController extends AuthenticatedController
}
$this->dozentUserSearch = new PermissionSearch(
- $search_template,
- sprintf(_("%s suchen"), get_title_for_status('dozent', 1, $sem->status)),
- "user_id",
- ['permission' => 'dozent',
- 'seminar_id' => $this->course_id,
- 'sem_perm' => 'dozent',
- 'institute' => $sem_institutes
- ]
- );
+ $search_template,
+ sprintf(_("%s suchen"), get_title_for_status('dozent', 1, $sem->status)),
+ "user_id",
+ [
+ 'permission' => 'dozent',
+ 'seminar_id' => $this->course_id,
+ 'sem_perm' => 'dozent',
+ 'institute' => $sem_institutes
+ ]
+ );
$this->dozenten_title = get_title_for_status('dozent', 1, $sem->status);
$this->deputies_enabled = $deputies_enabled;
if ($this->deputies_enabled) {
$this->deputies = Deputy::findDeputies($this->course_id);
$this->deputySearch = new PermissionSearch(
- "user_not_already_in_sem_or_deputy",
- sprintf(_("%s suchen"), get_title_for_status('deputy', 1, $sem->status)),
- "user_id",
- ['permission' => Deputy::getValidPerms(), 'seminar_id' => $this->course_id]
- );
+ "user_not_already_in_sem_or_deputy",
+ sprintf(_("%s suchen"), get_title_for_status('deputy', 1, $sem->status)),
+ "user_id",
+ ['permission' => Deputy::getValidPerms(), 'seminar_id' => $this->course_id]
+ );
$this->deputy_title = get_title_for_status('deputy', 1, $sem->status);
}
$this->tutoren = $sem->getMembers('tutor');
$this->tutorUserSearch = new PermissionSearch(
- $search_template,
- sprintf(_("%s suchen"), get_title_for_status('tutor', 1, $sem->status)),
- "user_id",
- ['permission' => ['dozent','tutor'],
- 'seminar_id' => $this->course_id,
- 'sem_perm' => ['dozent','tutor'],
- 'institute' => $sem_institutes
- ]
- );
+ $search_template,
+ sprintf(_("%s suchen"), get_title_for_status('tutor', 1, $sem->status)),
+ "user_id",
+ ['permission' => ['dozent','tutor'],
+ 'seminar_id' => $this->course_id,
+ 'sem_perm' => ['dozent','tutor'],
+ 'institute' => $sem_institutes
+ ]
+ );
$this->tutor_title = get_title_for_status('tutor', 1, $sem->status);
$instUsers = new SimpleCollection(InstituteMember::findByInstituteAndStatus($sem->getInstitutId(), 'tutor'));
$this->tutorsOfInstitute = $instUsers->pluck('user_id');
unset($instUsers);
- $this->perm_dozent = $perm->have_studip_perm("dozent", $this->course_id);
+ $this->perm_dozent = $GLOBALS['perm']->have_studip_perm("dozent", $this->course_id);
$this->mkstring = $data['mkdate'] ? date("d.m.Y, H:i", $data['mkdate']) : _("unbekannt");
$this->chstring = $data['chdate'] ? date("d.m.Y, H:i", $data['chdate']) : _("unbekannt");
$lockdata = LockRules::getObjectRule($this->course_id);
@@ -364,46 +364,28 @@ class Course_BasicdataController extends AuthenticatedController
$sidebar = Sidebar::get();
$widget = new ActionsWidget();
- $widget->addLink(
- _('Bild ändern'),
- $this->url_for('avatar/update/course', $course_id),
- Icon::create('edit')
+
+ $widget->addLink(_('Bild ändern'),
+ $this->url_for('avatar/update/course', $course_id),
+ Icon::create('edit')
);
if ($this->deputies_enabled) {
- $newstatus = null;
- $text = null;
-
- if (Deputy::isDeputy($user->id, $this->course_id)) {
+ if (Deputy::isDeputy($GLOBALS['user']->id, $this->course_id)) {
$newstatus = 'dozent';
$text = _('Lehrende werden');
- } else if (in_array($user->id, array_keys($this->dozenten)) && count($this->dozenten) > 1) {
+ } else if (in_array($GLOBALS['user']->id, array_keys($this->dozenten)) && count($this->dozenten) > 1) {
$newstatus = 'deputy';
$text = _('Vertretung werden');
}
-
- if ($text) {
- $widget->addLink(
- $text,
- $this->url_for('course/basicdata/switchdeputy', $this->course_id, $newstatus),
- Icon::create('persons')
- );
- }
+ $widget->addLink($text,
+ $this->url_for('course/basicdata/switchdeputy', $this->course_id, $newstatus),
+ Icon::create('persons')
+ );
}
$sidebar->addWidget($widget);
- // Entry list for admin upwards.
- if ($perm->have_studip_perm('admin', $this->course_id)) {
- $list = new SelectWidget(_('Veranstaltungen'), '?#admin_top_links', 'cid');
-
- foreach (AdminCourseFilter::get()->getCoursesForAdminWidget() as $seminar) {
- $list->addElement(new SelectElement(
- $seminar['Seminar_id'],
- $seminar['Name'],
- $seminar['Seminar_id'] === Context::getId(),
- $seminar['VeranstaltungsNummer'] . ' ' . $seminar['Name']
- ));
- }
- $list->size = 8;
- $sidebar->addWidget($list);
+ if ($GLOBALS['perm']->have_studip_perm('admin', $this->course->id)) {
+ $widget = new CourseManagementSelectWidget();
+ $sidebar->addWidget($widget);
}
}
diff --git a/app/controllers/course/management.php b/app/controllers/course/management.php
index 1753919..2738a12 100644
--- a/app/controllers/course/management.php
+++ b/app/controllers/course/management.php
@@ -27,6 +27,7 @@ class Course_ManagementController extends AuthenticatedController
if (!$GLOBALS['perm']->have_studip_perm("tutor", $GLOBALS['SessionSeminar'])) {
throw new AccessDeniedException();
}
+
if (Context::isCourse()) {
$sem_class = $GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][Context::get()->status]['class']] ?: SemClass::getDefaultSemClass();
} else {
@@ -35,7 +36,6 @@ class Course_ManagementController extends AuthenticatedController
if (!$sem_class->isModuleAllowed("CoreAdmin")) {
throw new Exception(_('Dies ist eine Studiengruppe und kein Seminar!'));
}
-
PageLayout::setTitle(sprintf(_("%s - Verwaltung"), Context::getHeaderLine()));
PageLayout::setHelpKeyword('Basis.InVeranstaltungVerwaltung');
}
@@ -45,7 +45,7 @@ class Course_ManagementController extends AuthenticatedController
*
* @return void
*/
- function index_action()
+ public function index_action()
{
Navigation::activateItem('course/admin/main');
@@ -89,7 +89,7 @@ class Course_ManagementController extends AuthenticatedController
}
}
if ($GLOBALS['perm']->have_perm('admin')) {
- $is_locked =$course->lock_rule;
+ $is_locked = $course->lock_rule;
$actions->addLink(
_('Sperrebene ändern') . ' (' . ($is_locked ? _('gesperrt') : _('nicht gesperrt')) . ')',
URLHelper::getURL($this->url_for('course/management/lock'), ['studip_ticket' => Seminar_Session::get_ticket()]),
@@ -103,33 +103,37 @@ class Course_ManagementController extends AuthenticatedController
URLHelper::getURL('dispatch.php/course/change_view/set_changed_view'),
Icon::create('visibility-invisible')
);
-
$sidebar->addWidget($actions);
- // Entry list for admin upwards.
if ($GLOBALS['perm']->have_studip_perm('admin', $course->id)) {
- $list = new SelectWidget(_('Veranstaltungen'), '?#admin_top_links', 'cid');
- $seminars = AdminCourseFilter::get()->getCoursesForAdminWidget();
- foreach ($seminars as $seminar) {
- $list->addElement(new SelectElement(
- $seminar['Seminar_id'],
- $seminar['Name'],
- $seminar['Seminar_id'] === $course->id,
- $seminar['VeranstaltungsNummer'] . ' ' . $seminar['Name']
- ));
- }
- $list->size = min(8, count($seminars));
- $sidebar->addWidget($list);
+ $widget = new CourseManagementSelectWidget();
+ $sidebar->addWidget($widget);
}
}
}
+ public function order_settings_action()
+ {
+ PageLayout::setTitle(_('Sortiereinstellungen'));
+ $this->order_by_field = UserConfig::get($GLOBALS['user']->id)->COURSE_MANAGEMENT_SELECTOR_ORDER_BY ?? 'name';
+ $this->render_template('course/shared/order_settings');
+ }
+
+ public function store_order_settings_action()
+ {
+ CSRFProtection::verifyUnsafeRequest();
+ UserConfig::get($GLOBALS['user']->id)->store('COURSE_MANAGEMENT_SELECTOR_ORDER_BY', Request::get('order_by', 'name'));
+ PageLayout::postSuccess(_('Die Sortiereinstellungen wurden erfolgreich gespeichert.'));
+
+ $this->redirect(URLHelper::getURL(Request::get('from')));
+ }
+
/**
* change the visibility of a course
*
* @return void
*/
- function change_visibility_action()
+ public function change_visibility_action()
{
if ((Config::get()->ALLOW_DOZENT_VISIBILITY || $GLOBALS['perm']->have_perm('admin'))
&& !LockRules::Check($GLOBALS['SessionSeminar'], 'seminar_visibility')
@@ -198,7 +202,7 @@ class Course_ManagementController extends AuthenticatedController
} else {
$msg = _('Die Sperrebene wurde erfolgreich zurückgesetzt!');
}
- PageLayout::postMessage(MessageBox::success($msg));
+ PageLayout::postSuccess($msg);
}
}
$this->relocate($this->action_url('index'));
diff --git a/app/controllers/course/room_requests.php b/app/controllers/course/room_requests.php
index d23b5c7..1cc3796 100644
--- a/app/controllers/course/room_requests.php
+++ b/app/controllers/course/room_requests.php
@@ -14,6 +14,7 @@
* @category Stud.IP
* @package admin
*/
+
class Course_RoomRequestsController extends AuthenticatedController
{
/**
@@ -81,19 +82,9 @@ class Course_RoomRequestsController extends AuthenticatedController
);
Sidebar::get()->addWidget($actions);
- if ($GLOBALS['perm']->have_perm('admin')) {
- $list = new SelectWidget(_('Veranstaltungen'), '?#admin_top_links', 'cid');
-
- foreach (AdminCourseFilter::get()->getCoursesForAdminWidget() as $seminar) {
- $list->addElement(new SelectElement(
- $seminar['Seminar_id'],
- $seminar['Name'],
- $seminar['Seminar_id'] === Context::getId(),
- $seminar['VeranstaltungsNummer'] . ' ' . $seminar['Name']
- ));
- }
- $list->size = 8;
- Sidebar::get()->addWidget($list);
+ if ($GLOBALS['perm']->have_studip_perm('admin', $this->course_id)) {
+ $widget = new CourseManagementSelectWidget();
+ Sidebar::Get()->addWidget($widget);
}
}
@@ -121,28 +112,29 @@ class Course_RoomRequestsController extends AuthenticatedController
_('Das Erstellen von Raumanfragen ist nicht erlaubt!')
);
}
- $options = array();
- $this->url_params = array();
+ $options = [];
+ $this->url_params = [];
if (Request::get('origin') !== null) {
$this->url_params['origin'] = Request::get('origin');
}
if (!RoomRequest::existsByCourse($this->course_id)) {
- $options[] = array('value' => 'course',
- 'name' => _('alle regelmäßigen und unregelmäßigen Termine der Veranstaltung')
- );
+ $options[] = [
+ 'value' => 'course',
+ 'name' => _('alle regelmäßigen und unregelmäßigen Termine der Veranstaltung')
+ ];
}
foreach (SeminarCycleDate::findBySeminar($this->course_id) as $cycle) {
if (!RoomRequest::existsByMetadate($cycle->getId())) {
$name = _("alle Termine einer regelmäßigen Zeit");
$name .= ' (' . $cycle->toString('full') . ')';
- $options[] = array('value' => 'cycle_' . $cycle->getId(), 'name' => $name);
+ $options[] = ['value' => 'cycle_' . $cycle->getId(), 'name' => $name];
}
}
foreach (CourseDate::findBySeminar_id($this->course_id) as $date) {
if (!RoomRequest::existsByDate($date['termin_id'])) {
$name = _("Einzeltermin der Veranstaltung");
$name .= ' (' . $date->getFullname() . ')';
- $options[] = array('value' => 'date_' . $date['termin_id'], 'name' => $name);
+ $options[] = ['value' => 'date_' . $date['termin_id'], 'name' => $name];
}
}
$this->options = $options;
@@ -455,9 +447,8 @@ class Course_RoomRequestsController extends AuthenticatedController
if (empty($session_data['selected_properties']['seats'])) {
$this->course = Course::find($this->course_id);
$admission_turnout = $this->course->admission_turnout;
- $this->selected_properties['seats'] = $admission_turnout
- ? $admission_turnout
- : Config::get()->RESOURCES_ROOM_REQUEST_DEFAULT_SEATS;
+ $this->selected_properties['seats'] =
+ $admission_turnout ?: Config::get()->RESOURCES_ROOM_REQUEST_DEFAULT_SEATS;
}
if (Request::isPost()) {
@@ -537,7 +528,6 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->request->reply_recipients = 'requester';
}
- $storing_successful = false;
if ($this->request->isDirty()) {
$storing_successful = $this->request->store();
} else {
@@ -756,9 +746,7 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->request->category_id = $session_data['category_id'];
$this->request->updateProperties($session_data['selected_properties']);
$this->request->resource_id = (
- $this->selected_room_id
- ? $this->selected_room_id
- : ''
+ $this->selected_room_id ?: ''
);
$this->request->comment = Request::get('comment');
if (Request::get('reply_lecturers')) {
@@ -772,7 +760,6 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->request->user_id = $this->current_user->id;
}
- $storing_successful = false;
if ($this->request->isDirty()) {
$storing_successful = $this->request->store();
} else {
@@ -859,9 +846,7 @@ class Course_RoomRequestsController extends AuthenticatedController
if (!$this->seats) {
$admission_turnout = $this->course->admission_turnout;
- $this->seats = $admission_turnout
- ? $admission_turnout
- : Config::get()->RESOURCES_ROOM_REQUEST_DEFAULT_SEATS;
+ $this->seats = $admission_turnout ?: Config::get()->RESOURCES_ROOM_REQUEST_DEFAULT_SEATS;
}
if (Request::isPost()) {
@@ -947,7 +932,6 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->request->closed = 0;
}
- $storing_successful = false;
if ($this->request->isDirty()) {
$storing_successful = $this->request->store();
} else {
diff --git a/app/controllers/course/study_areas.php b/app/controllers/course/study_areas.php
index fcb6440..e7365f1 100644
--- a/app/controllers/course/study_areas.php
+++ b/app/controllers/course/study_areas.php
@@ -15,18 +15,12 @@
*/
require_once 'lib/webservices/api/studip_lecture_tree.php';
-//require_once 'lib/classes/coursewizardsteps/StudyAreasWizardStep.php';
class Course_StudyAreasController extends AuthenticatedController
{
-
-
// see Trails_Controller#before_filter
- function before_filter(&$action, &$args)
+ public function before_filter(&$action, &$args)
{
-
- global $perm;
-
parent::before_filter($action, $args);
// Search for course object
@@ -34,11 +28,9 @@ class Course_StudyAreasController extends AuthenticatedController
$this->locked = LockRules::Check($this->course->id, 'sem_tree');
// check course object and perms
- if (!is_null($this->course)
- && !$perm->have_studip_perm("tutor", $this->course->id)
- ) {
+ if (isset($this->course) && !$GLOBALS['perm']->have_studip_perm('tutor', $this->course->id)) {
$this->set_status(403);
- return FALSE;
+ return false;
}
// Init Studyareas-Step for
@@ -59,8 +51,9 @@ class Course_StudyAreasController extends AuthenticatedController
}
- function show_action()
+ public function show_action()
{
+ Navigation::activateItem('course/admin/study_areas');
$this->url_params = [];
if (Request::get('from')) {
$this->url_params['from'] = Request::get('from');
@@ -68,27 +61,11 @@ class Course_StudyAreasController extends AuthenticatedController
if (Request::get('open_node')) {
$this->url_params['open_node'] = Request::get('open_node');
}
- if (!Request::isXhr()) {
-
- Navigation::activateItem('course/admin/study_areas');
- $sidebar = Sidebar::get();
-
- if ($this->course) {
- // Entry list for admin upwards.
- if ($GLOBALS['perm']->have_studip_perm('admin', $GLOBALS['SessionSeminar'])) {
- $list = new SelectWidget(_('Veranstaltungen'), '?#admin_top_links', 'cid');
-
- foreach (AdminCourseFilter::get()->getCoursesForAdminWidget() as $seminar) {
- $list->addElement(new SelectElement(
- $seminar['Seminar_id'],
- $seminar['Name'],
- $seminar['Seminar_id'] === Context::getId(),
- $seminar['VeranstaltungsNummer'] . ' ' . $seminar['Name']
- ));
- }
- $list->size = 8;
- $sidebar->addWidget($list);
- }
+
+ if ($this->course) {
+ if ($GLOBALS['perm']->have_studip_perm('admin', $this->course->id)) {
+ $widget = new CourseManagementSelectWidget();
+ Sidebar::Get()->addWidget($widget);
}
}
if (Request::get('open_node')) {
@@ -100,7 +77,7 @@ class Course_StudyAreasController extends AuthenticatedController
$this->tree = $this->step->getStepTemplate($this->values, 0, 0);
}
- function ajax_action()
+ public function ajax_action()
{
$parameter = Request::getArray('parameter');
$method = Request::get('method');
@@ -112,9 +89,6 @@ class Course_StudyAreasController extends AuthenticatedController
case 'getSemTreeLevel':
$json = $this->step->getSemTreeLevel($parameter[0]);
break;
- case 'getAncestorTree':
- $json = $this->step->getAncestorTree($parameter[0]);
- break;
default:
$json = $this->step->getAncestorTree($parameter[0]);
break;
@@ -123,7 +97,7 @@ class Course_StudyAreasController extends AuthenticatedController
$this->render_json($json);
}
- function save_action()
+ public function save_action()
{
if($this->locked) {
throw new Trails_Exception(403);
@@ -153,12 +127,12 @@ class Course_StudyAreasController extends AuthenticatedController
$studyareas = Request::getArray('studyareas');
if (empty($studyareas) && $this->is_required()) {
- PageLayout::postMessage(MessageBox::error(_('Sie müssen mindestens einen Studienbereich auswählen')));
+ PageLayout::postError(_('Sie müssen mindestens einen Studienbereich auswählen'));
$this->redirect($url);
return;
}
if (!empty($studyareas) && !$this->is_required()) {
- PageLayout::postMessage(MessageBox::error(_('Sie dürfen keine Studienbereiche zuweisen.')));
+ PageLayout::postError(_('Sie dürfen keine Studienbereiche zuweisen.'));
$this->redirect($url);
return;
}
@@ -172,9 +146,9 @@ class Course_StudyAreasController extends AuthenticatedController
}
if (!$msg) {
- PageLayout::postMessage(MessageBox::success(_('Die Studienbereichszuordnung wurde übernommen.')));
+ PageLayout::postSuccess(_('Die Studienbereichszuordnung wurde übernommen.'));
} else {
- PageLayout::postMessage(MessageBox::error($msg));
+ PageLayout::postError($msg);
}
$this->redirect($url);
}
diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php
index 4ae955f..6b48385 100644
--- a/app/controllers/course/timesrooms.php
+++ b/app/controllers/course/timesrooms.php
@@ -5,6 +5,7 @@
* @license GPL2 or any later version
* @since 3.4
*/
+
class Course_TimesroomsController extends AuthenticatedController
{
/**
@@ -304,8 +305,7 @@ class Course_TimesroomsController extends AuthenticatedController
/**
* Primary function to edit date-informations
*
- * @param $termin_id
- * @param null $metadate_id
+ * @param string $termin_id
*/
public function editDate_action($termin_id)
{
@@ -1431,23 +1431,9 @@ class Course_TimesroomsController extends AuthenticatedController
}
Sidebar::Get()->addWidget($widget);
- if ($GLOBALS['perm']->have_perm('admin')) {
- $list = new SelectWidget(
- _('Veranstaltungen'),
- $this->url_for('course/timesrooms/index'),
- 'cid'
- );
-
- foreach (AdminCourseFilter::get()->getCoursesForAdminWidget() as $seminar) {
- $list->addElement(new SelectElement(
- $seminar['Seminar_id'],
- $seminar['Name'],
- $seminar['Seminar_id'] === Context::getId(),
- $seminar['VeranstaltungsNummer'] . ' ' . $seminar['Name']
- ));
- }
- $list->size = 8;
- Sidebar::Get()->addWidget($list);
+ if ($GLOBALS['perm']->have_studip_perm('admin', $this->course->id)) {
+ $widget = new CourseManagementSelectWidget();
+ Sidebar::Get()->addWidget($widget);
}
}
diff --git a/app/views/course/shared/order_settings.php b/app/views/course/shared/order_settings.php
new file mode 100644
index 0000000..714e29f
--- /dev/null
+++ b/app/views/course/shared/order_settings.php
@@ -0,0 +1,14 @@
+<form method="post" action="<?= $controller->store_order_settings() ?>" class="default">
+ <input type="hidden" name="from" value="<?= Request::get('from')?>">
+ <?= CSRFProtection::tokenTag() ?>
+ <label>
+ <?= _('Letzte Veranstaltungsliste sortieren nach') ?>
+ <select name="order_by">
+ <option value="name" <? if ($order_by_field === 'name') echo 'selected'; ?>><?= _('Veranstaltungsname') ?></option>
+ <option value="number" <? if ($order_by_field === 'number') echo 'selected'; ?>><?= _('Veranstaltungsnummer') ?></option>
+ </select>
+ </label>
+ <footer data-dialog-button>
+ <?= \Studip\Button::createAccept(_('Speichern')) ?>
+ </footer>
+</form>
diff --git a/db/migrations/5.3.3_tic_1583_course_selector.php b/db/migrations/5.3.3_tic_1583_course_selector.php
new file mode 100644
index 0000000..0b3f27b
--- /dev/null
+++ b/db/migrations/5.3.3_tic_1583_course_selector.php
@@ -0,0 +1,31 @@
+<?php
+
+final class Tic1583CourseSelector extends Migration
+{
+ public function description()
+ {
+ return 'adds the sorting option for the quick course selection';
+ }
+
+ public function up()
+ {
+ $query = 'INSERT INTO `config` (`field`, `value`, `type`, `range`, `mkdate`, `chdate`, `description`)
+ VALUES (:name, :value, :type, :range, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)';
+ $statement = DBManager::get()->prepare($query);
+ $statement->execute([
+ 'name' => 'COURSE_MANAGEMENT_SELECTOR_ORDER_BY',
+ 'description' => 'Gibt an, nach welchem Kriterium die Veranstaltungsschnellwauswahl innerhalb der Veranstaltungsverwaltung sortiert werden soll',
+ 'range' => 'user',
+ 'type' => 'string',
+ 'value' => 'name'
+ ]);
+ }
+
+ public function down()
+ {
+ DBManager::get()->exec("DELETE `config`, `config_values`
+ FROM `config` LEFT JOIN `config_values` USING (`field`)
+ WHERE `field` = 'COURSE_MANAGEMENT_SELECTOR_ORDER_BY'");
+ }
+
+}
diff --git a/lib/classes/AdminCourseFilter.class.php b/lib/classes/AdminCourseFilter.class.php
index 2324ff2..7ec1c7b 100644
--- a/lib/classes/AdminCourseFilter.class.php
+++ b/lib/classes/AdminCourseFilter.class.php
@@ -158,7 +158,7 @@ class AdminCourseFilter
/**
* Adds a filter for all courses of the given semester.
* @param string $semester_id : ID of the given semester.
- * @return $this
+ * @return AdminCourseFilter
* @throws Exception if semester_id does not exist
*/
public function filterBySemester($semester_id)
@@ -180,7 +180,7 @@ class AdminCourseFilter
/**
* Adds a filter for a sem_type or many sem_types if the parameter is an array.
* @param array|integer $type : id or ids of sem_types
- * @return $this
+ * @return AdminCourseFilter
*/
public function filterByType($type)
{
@@ -197,7 +197,7 @@ class AdminCourseFilter
/**
* Adds a filter for an institut_id or many institut_ids if the parameter is an array.
* @param array|integer $institut_ids : id or ids of institutes
- * @return $this
+ * @return AdminCourseFilter
*/
public function filterByInstitute($institut_ids)
{
@@ -220,7 +220,7 @@ class AdminCourseFilter
/**
* Adds a filter for an stgteil_id or many stgteil_ids if the parameter is an array.
* @param array|integer $stgteil_ids : id or ids of stgteile
- * @return $this
+ * @return AdminCourseFilter
*/
public function filterByStgTeil($stgteil_ids)
{
@@ -265,6 +265,10 @@ class AdminCourseFilter
return $this;
}
+ /**
+ * @param array|string $user_ids
+ * @return AdminCourseFilter
+ */
public function filterByDozent($user_ids)
{
$this->settings['query']['joins']['dozenten'] = [
@@ -285,8 +289,8 @@ class AdminCourseFilter
/**
* Adds a filter for a textstring, that can be the coursenumber, the name of the course
* or the last name of one of the dozenten.
- * @param string $text : the searchstring
- * @return $this
+ * @param string $text the searchstring
+ * @return AdminCourseFilter
*/
public function filterBySearchstring($text)
{
@@ -314,7 +318,7 @@ class AdminCourseFilter
/**
* @param string $attribute : column, name of the column, yb whcih we should order the results
* @param string $flag : "ASC" or "DESC for ascending order or descending order,
- * @return $this
+ * @return AdminCourseFilter
* @throws Exception if $flag does not exist
*/
public function orderBy($attribute, $flag = 'ASC')
@@ -331,12 +335,12 @@ class AdminCourseFilter
/**
* Adds a where filter.
- * @param string $where : any where condition like "sem_classes.overview = 'CoreOverview'"
- * @param array $parameter : an array of parameter that appear in the $where query.
- * @param null|string $id : an id of the where-query. Use this to possibly
+ * @param string $where any where condition like "sem_classes.overview = 'CoreOverview'"
+ * @param array $parameter an array of parameter that appear in the $where query.
+ * @param null|string $id an id of the where-query. Use this to possibly
* avoid double where conditions or allow deleting the condition
* by plugins if necessary. Can be omitted.
- * @return $this
+ * @return AdminCourseFilter
*/
public function where($where, $parameter = [], $id = null)
{
@@ -353,7 +357,7 @@ class AdminCourseFilter
* Also saves the settings in the session.
* Note that a notification AdminCourseFilterWillQuery will be posted, before the result is computed.
* Plugins may register at this event to fully alter this AdminCourseFilter-object and so the resultset.
- * @return array : associative array with seminar_ids as keys and seminar-data-arrays as values.
+ * @return array associative array with seminar_ids as keys and seminar-data-arrays as values.
*/
public function getCourses($grouped = true)
{
@@ -368,7 +372,7 @@ class AdminCourseFilter
}
/**
- * @return number of courses that this filter would return
+ * @return integer number of courses that this filter would return
*/
public function countCourses()
{
@@ -376,23 +380,29 @@ class AdminCourseFilter
if (empty($this->settings['query']['where'])) {
return 0;
}
- return DBManager::get()->fetchColumn($this->createQuery(true), $this->settings['parameter']);
+ return (int)DBManager::get()->fetchColumn($this->createQuery(true), $this->settings['parameter']);
}
/**
* Returns the data of the resultset of the AdminCourseFilter.
*
+ * @param string $order_by possible values name or number
+ *
* Note that a notification AdminCourseFilterWillQuery will be posted, before the result is computed.
* Plugins may register at this event to fully alter this AdminCourseFilter-object and so the resultset.
- * @return array : associative array with seminar_ids as keys and seminar-data-arrays as values.
+ * @return array associative array with seminar_ids as keys and seminar-data-arrays as values.
*/
- public function getCoursesForAdminWidget()
+ public function getCoursesForAdminWidget(string $order_by = 'name')
{
$count_courses = $this->countCourses();
+ $order = 'seminare.name';
+ if ($order_by === 'number') {
+ $order = 'seminare.veranstaltungsnummer, seminare.name';
+ }
if ($count_courses && $count_courses <= $this->max_show_courses) {
$settings = $this->settings;
$this->settings['query']['select'] = [];
- $this->settings['query']['orderby'] = 'seminare.name';
+ $this->settings['query']['orderby'] = $order;
$ret = $this->getCourses(false);
$this->settings = $settings;
return $ret;
@@ -402,8 +412,8 @@ class AdminCourseFilter
/**
* Creates the sql-query from the $this->settings['query']
- * @only_count : boolean
- * @return string : the big query
+ * @param boolean $only_count : boolean
+ * @return string the big query
*/
public function createQuery($only_count = false)
{
diff --git a/lib/classes/sidebar/CourseManagementSelectWidget.php b/lib/classes/sidebar/CourseManagementSelectWidget.php
new file mode 100644
index 0000000..3973502
--- /dev/null
+++ b/lib/classes/sidebar/CourseManagementSelectWidget.php
@@ -0,0 +1,47 @@
+<?php
+
+class CourseManagementSelectWidget extends SelectWidget
+{
+ public $course = null;
+ public $order_by_field;
+
+ public function __construct()
+ {
+ parent::__construct(_('Veranstaltungen'), '?#admin_top_links', 'cid');
+
+ $this->course = Course::findCurrent();
+ $this->order_by_field = UserConfig::get($GLOBALS['user']->id)->COURSE_MANAGEMENT_SELECTOR_ORDER_BY ?? 'name';
+ }
+
+ public function render($variables = [])
+ {
+ $extra = sprintf(
+ '<a href="%s" title="%s" data-dialog="size=auto">%s</a>',
+ URLHelper::getURL('dispatch.php/course/management/order_settings', ['cid' => $this->course->id, 'from' => Request::url()]),
+ _('Sortiereinstellungen'),
+ Icon::create('settings')
+ );
+ $this->setExtra($extra);
+ $this->class = 'nested-select';
+ $this->setDropdownAutoWidth(true);
+ $seminars = AdminCourseFilter::get()->getCoursesForAdminWidget($this->order_by_field);
+ foreach ($seminars as $seminar) {
+ if ($this->order_by_field === 'number') {
+ $seminar_name = trim($seminar['VeranstaltungsNummer'] . ' ' . $seminar['Name']);
+ } else {
+ $seminar_name = $seminar['Name'];
+
+ if ($seminar['VeranstaltungsNummer']) {
+ $seminar_name .= sprintf(' (%s)', trim($seminar['VeranstaltungsNummer']));
+ }
+ }
+ $this->addElement(new SelectElement(
+ $seminar['Seminar_id'],
+ $seminar_name,
+ $seminar['Seminar_id'] === $this->course->id,
+ trim($seminar['VeranstaltungsNummer'] . ' ' . $seminar['Name'])
+ ));
+ }
+ return parent::render($variables);
+ }
+}
diff --git a/lib/classes/sidebar/SelectWidget.php b/lib/classes/sidebar/SelectWidget.php
index ce311f6..7397175 100644
--- a/lib/classes/sidebar/SelectWidget.php
+++ b/lib/classes/sidebar/SelectWidget.php
@@ -19,15 +19,15 @@ class SelectWidget extends SidebarWidget
*/
public function __construct($title, $url, $name, $method = 'get', $multiple = false)
{
+ parent::__construct();
$this->template = 'sidebar/select-widget';
-
$this->setTitle($title);
$this->setUrl($url);
$this->setSelectParameterName($name);
$this->setRequestMethod($method);
$this->setMultiple($multiple);
-
$this->template_variables['max_length'] = 30;
+ $this->template_variables['dropdownAutoWidth'] = false;
}
/**
@@ -88,6 +88,16 @@ class SelectWidget extends SidebarWidget
}
/**
+ * set the dropdown auto width (default: false)
+ * @param $dropdownAutoWidth
+ * @return void
+ */
+ public function setDropdownAutoWidth($dropdownAutoWidth)
+ {
+ $this->template_variables['dropdownAutoWidth'] = $dropdownAutoWidth;
+ }
+
+ /**
* Sets whether selecting multiple values is allowed or not
* @param bool $multiple true if selection multiple values should be allowed
*/
diff --git a/lib/classes/sidebar/SidebarWidget.php b/lib/classes/sidebar/SidebarWidget.php
index 7075b8a..6feb153 100644
--- a/lib/classes/sidebar/SidebarWidget.php
+++ b/lib/classes/sidebar/SidebarWidget.php
@@ -19,7 +19,7 @@ class SidebarWidget extends Widget
/**
* Sets the ID of the HTML element that represents the widget.
*
- * @param $id The element-ID to be used for the widget.
+ * @param string $id The element-ID to be used for the widget.
*
*/
public function setId(string $id)
@@ -40,7 +40,7 @@ class SidebarWidget extends Widget
/**
* Sets the title of the widget.
*
- * @param String $title The title of the widget
+ * @param string $title The title of the widget
*/
public function setTitle($title)
{
@@ -50,7 +50,7 @@ class SidebarWidget extends Widget
/**
* Returns the title of the widget
*
- * @return mixed The title of the widget of false if no title has been set
+ * @return string The title of the widget of false if no title has been set
*/
public function getTitle()
{
@@ -101,7 +101,7 @@ class SidebarWidget extends Widget
* Renders the widget.
* The widget will only be rendered if it contains at least one element.
*
- * @return String The THML code of the rendered sidebar widget
+ * @return string The THML code of the rendered sidebar widget
*/
public function render($variables = [])
{
diff --git a/resources/assets/javascripts/bootstrap/forms.js b/resources/assets/javascripts/bootstrap/forms.js
index 3bf5026..a70af54 100644
--- a/resources/assets/javascripts/bootstrap/forms.js
+++ b/resources/assets/javascripts/bootstrap/forms.js
@@ -175,7 +175,7 @@ function createSelect2(element) {
return;
}
- var select_classes = $(element)
+ let select_classes = $(element)
.removeClass('select2-awaiting')
.attr('class'),
option = $('<option>'),
@@ -185,7 +185,9 @@ function createSelect2(element) {
.css('opacity', 0)
.appendTo('body'),
wrapper = $('<div class="select2-wrapper">').css('display', cloned.css('display')),
- placeholder;
+ placeholder,
+ dropdownAutoWidth = $(element).data('dropdown-auto-width')
+ ;
cloned.remove();
$(wrapper)
@@ -208,10 +210,11 @@ function createSelect2(element) {
allowClear: placeholder !== undefined,
minimumResultsForSearch: $(element).closest('.sidebar').length > 0 ? 15 : 10,
placeholder: placeholder,
+ dropdownAutoWidth: dropdownAutoWidth,
dropdownParent: $(element).closest('.ui-dialog,.sidebar,body'),
templateResult: function(data, container) {
if (data.element) {
- var option_classes = $(data.element).attr('class'),
+ let option_classes = $(data.element).attr('class'),
element_data = $(data.element).data();
$(container).addClass(option_classes);
@@ -223,7 +226,7 @@ function createSelect2(element) {
return data.text;
},
templateSelection: function(data, container) {
- var result = $('<span class="select2-selection__content">').text(data.text),
+ let result = $('<span class="select2-selection__content">').text(data.text),
element_data = $(data.element).data();
if (element_data && element_data.textColor) {
result.css('color', element_data.textColor);
diff --git a/resources/assets/stylesheets/scss/i18n.scss b/resources/assets/stylesheets/scss/i18n.scss
index 70136a1..7239879 100644
--- a/resources/assets/stylesheets/scss/i18n.scss
+++ b/resources/assets/stylesheets/scss/i18n.scss
@@ -15,7 +15,6 @@ div.i18n_group {
height: 31px;
overflow: hidden;
max-width: $max-width;
- z-index: 2;
appearance: none;
diff --git a/templates/sidebar/select-widget.php b/templates/sidebar/select-widget.php
index cadd277..7c7b039 100644
--- a/templates/sidebar/select-widget.php
+++ b/templates/sidebar/select-widget.php
@@ -3,7 +3,7 @@
<?= (strtolower($method) == 'post') ? CSRFProtection::tokenTag() : ''; ?>
<select class="sidebar-selectlist <?= $class ?> <? if ($__is_nested): ?>nested-select<? endif; ?>" <? !empty($size) ? printf('size="%u"', $size) : '' ?> <?= !empty($attributes) ? arrayToHtmlAttributes($attributes) : '' ?>
name="<?= sprintf('%s%s', htmlReady($name), $multiple ? '[]' : '') ?>" <? if ($multiple) echo 'multiple'; ?>
- aria-label="<?= htmlReady($title) ?>">
+ aria-label="<?= htmlReady($title) ?>" <?= $dropdownAutoWidth ? 'data-dropdown-auto-width="1"' : '' ?>>
<? foreach ($elements as $element): ?>
<? if ($element instanceof SelectGroupElement && count($element->getElements()) > 0): ?>