From 9b2411a078a279cb4e24c0cc2ca78c032ad55e94 Mon Sep 17 00:00:00 2001 From: Thomas Hackl Date: Mon, 27 Jan 2025 15:52:02 +0000 Subject: Resolve "Fehler bei der Anmeldeset-Verwaltung" Closes #5086 Merge request studip/studip!3823 --- app/controllers/admin/courses.php | 1 - app/controllers/admission/courseset.php | 13 +- app/controllers/admission/rule.php | 152 ------------------ app/controllers/admission/ruleadministration.php | 1 - app/controllers/admission/userlist.php | 1 - app/controllers/course/admission.php | 105 +++++-------- app/controllers/course/details.php | 1 - app/views/admission/rule/configure.php | 11 -- app/views/admission/rule/save.php | 23 --- app/views/admission/rule/select_type.php | 37 ----- app/views/admission/rule/validate.php | 8 - app/views/course/admission/instant_course_set.php | 5 +- .../conditionaladmission/ConditionalAdmission.php | 20 +-- .../conditionaladmission/templates/configure.php | 3 - .../ConnectedcourseAdmission.class.php | 14 -- .../templates/configure.php | 5 - .../CourseMemberAdmission.php | 21 --- .../coursememberadmission/templates/configure.php | 3 - .../limitedadmission/LimitedAdmission.php | 17 -- .../limitedadmission/templates/configure.php | 3 - .../lockedadmission/LockedAdmission.php | 13 -- .../lockedadmission/templates/configure.php | 3 - .../ParticipantRestrictedAdmission.php | 14 -- .../templates/configure.php | 5 - .../passwordadmission/PasswordAdmission.php | 10 +- .../passwordadmission/templates/configure.php | 3 - .../PreferentialAdmission.php | 14 -- .../preferentialadmission/templates/configure.php | 3 - .../termsadmission/TermsAdmission.php | 15 -- .../termsadmission/templates/configure.php | 3 - .../timedadmission/TimedAdmission.php | 13 -- .../timedadmission/templates/configure.php | 3 - lib/classes/admission/AdmissionRule.php | 10 -- .../assets/javascripts/bootstrap/admission.js | 19 +-- resources/assets/javascripts/entry-admission.js | 1 - resources/assets/javascripts/entry-base.js | 1 + resources/assets/javascripts/lib/admission.js | 172 --------------------- resources/assets/javascripts/studip-ui.js | 4 +- resources/assets/stylesheets/scss/admission.scss | 31 ---- resources/vue/components/Quicksearch.vue | 3 +- resources/vue/components/StudipDialog.vue | 14 +- .../components/admission/AdmissionRuleConfig.vue | 20 ++- .../components/admission/ConfigureCourseSet.vue | 37 +++-- .../components/admission/CourseMemberAdmission.vue | 7 +- .../vue/components/admission/InstantCourseSet.vue | 102 ++++++++++++ .../admission/ParticipantRestrictedAdmission.vue | 37 +++-- .../vue/components/admission/TimedAdmission.vue | 3 +- .../vue/components/admission/ValidityTime.vue | 8 +- resources/vue/mixins/AdmissionRuleMixin.js | 2 +- templates/admission/rules/configure.php | 37 ----- templates/admission/rules/input_end.php | 1 - templates/admission/rules/input_start.php | 1 - templates/forms/quicksearch_input.php | 2 +- webpack.common.js | 1 - 54 files changed, 253 insertions(+), 803 deletions(-) delete mode 100644 app/controllers/admission/rule.php delete mode 100644 app/views/admission/rule/configure.php delete mode 100644 app/views/admission/rule/save.php delete mode 100644 app/views/admission/rule/select_type.php delete mode 100644 app/views/admission/rule/validate.php delete mode 100644 lib/admissionrules/conditionaladmission/templates/configure.php delete mode 100644 lib/admissionrules/connectedcourseadmission/templates/configure.php delete mode 100644 lib/admissionrules/coursememberadmission/templates/configure.php delete mode 100644 lib/admissionrules/limitedadmission/templates/configure.php delete mode 100644 lib/admissionrules/lockedadmission/templates/configure.php delete mode 100644 lib/admissionrules/participantrestrictedadmission/templates/configure.php delete mode 100644 lib/admissionrules/passwordadmission/templates/configure.php delete mode 100644 lib/admissionrules/preferentialadmission/templates/configure.php delete mode 100644 lib/admissionrules/termsadmission/templates/configure.php delete mode 100644 lib/admissionrules/timedadmission/templates/configure.php delete mode 100644 resources/assets/javascripts/entry-admission.js create mode 100644 resources/vue/components/admission/InstantCourseSet.vue delete mode 100644 templates/admission/rules/configure.php delete mode 100644 templates/admission/rules/input_end.php delete mode 100644 templates/admission/rules/input_start.php diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php index 2ff2a9e..0d65e13 100644 --- a/app/controllers/admin/courses.php +++ b/app/controllers/admin/courses.php @@ -298,7 +298,6 @@ class Admin_CoursesController extends AuthenticatedController PageLayout::setHelpKeyword('Basis.Veranstaltungen'); PageLayout::setTitle(_('Verwaltung von Veranstaltungen und Einrichtungen')); // Add admission functions. - PageLayout::addScript('studip-admission.js'); $this->max_show_courses = Config::get()->MAX_SHOW_ADMIN_COURSES; } diff --git a/app/controllers/admission/courseset.php b/app/controllers/admission/courseset.php index 90ae5f5..c13791f 100644 --- a/app/controllers/admission/courseset.php +++ b/app/controllers/admission/courseset.php @@ -34,8 +34,6 @@ class Admission_CoursesetController extends AuthenticatedController throw new AccessDeniedException(); } - PageLayout::addScript('studip-admission.js'); - $views = new ActionsWidget(); $views->addLink( _('Anmeldeset anlegen'), @@ -293,7 +291,8 @@ class Admission_CoursesetController extends AuthenticatedController $this->myUserlists ) ), - 'institute-search' => (string) $this->isearch + 'institute-search' => (string) $this->isearch, + 'instant-course-set-view' => $this->instant_course_set_view ]; if ($this->courseset) { @@ -374,9 +373,9 @@ class Admission_CoursesetController extends AuthenticatedController } PageLayout::postSuccess(sprintf(_('Das Anmeldeset: %s wurde gespeichert'), htmlReady($courseset->getName()))); if ($this->instant_course_set_view) { - $this->redirect($this->url_for('course/admission')); + $this->relocate('course/admission'); } else { - $this->redirect($this->url_for('admission/courseset/configure', $courseset->getId())); + $this->relocate('admission/courseset/configure', $courseset->getId()); } } } @@ -398,7 +397,7 @@ class Admission_CoursesetController extends AuthenticatedController $this->courseset->delete(); } - $this->redirect($this->url_for('admission/courseset')); + $this->relocate('admission/courseset'); } /** @@ -607,7 +606,7 @@ class Admission_CoursesetController extends AuthenticatedController if ($ok) { PageLayout::postSuccess(_('Die zugeordneten Veranstaltungen wurden konfiguriert.')); } - $this->redirect($this->url_for('admission/courseset/configure/' . $courseset->getId())); + $this->relocate('admission/courseset/configure/' . $courseset->getId()); return; } } diff --git a/app/controllers/admission/rule.php b/app/controllers/admission/rule.php deleted file mode 100644 index 2a41db4..0000000 --- a/app/controllers/admission/rule.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 - * @category Stud.IP - * @since 3.0 - */ - -class Admission_RuleController extends AuthenticatedController -{ - /** - * @see AuthenticatedController::before_filter - */ - public function before_filter(&$action, &$args) - { - parent::before_filter($action, $args); - - if ($GLOBALS['perm']->have_perm('admin') || ($GLOBALS['perm']->have_perm('dozent') && Config::get()->ALLOW_DOZENT_COURSESET_ADMIN)) { - Navigation::activateItem('/browse/coursesets'); - } - PageLayout::setTitle(_('Anmeldesets')); - - } - - /** - * Gets the template for the rule configuration form. - * - * @param String $ruleType Class name of the rule to configure. - * @param String $ruleId Optional ID of an existing rule. - */ - public function configure_action($ruleType = '', $ruleId = '') - { - $this->ruleTypes = AdmissionRule::getAvailableAdmissionRules(); - UserFilterField::getAvailableFilterFields(); - $this->ruleType = $ruleType; - // Check if rule data has been given via request. - if (Request::getArray('rules')) { - $rule_siblings = []; - foreach (Request::getManyObjects('rules', 'AdmissionRule') as $rule) { - if ($ruleType == get_class($rule) && $rule->getId() == Request::get('ruleId')) { - $this->rule = $rule; - } else { - $rule_siblings[$rule->getId()] = $rule; - } - } - if (!$this->rule && in_array($ruleType, array_keys($this->ruleTypes))) { - $this->rule = new $ruleType($ruleId); - } - $this->rule->setSiblings($rule_siblings); - } elseif (Request::get('rule')) { - $rule = Request::getObject('rule', 'AdmissionRule'); - if ($ruleType == get_class($rule)) { - $this->rule = $rule; - } - } elseif (in_array($ruleType, array_keys($this->ruleTypes))) { - $this->rule = new $ruleType($ruleId); - } - if ($this->rule) { - $this->ruleTemplate = $this->rule->getTemplate(); - } - } - - /** - * Shows a form for selecting which rule type to use. - * - * @param String $cs_id ID of a courseset the rule shall belong to. - */ - public function select_type_action($cs_id = '') - { - $this->ruleTypes = AdmissionRule::getAvailableAdmissionRules(); - $this->courseset = new CourseSet($cs_id); - $this->courseset->clearAdmissionRules(); - foreach (Request::getManyObjects('rules', 'AdmissionRule') as $rule) { - $this->courseset->addAdmissionRule($rule); - } - } - - /** - * Saves the given rule. - * - * @param String $ruleType The class name of the configured rule. - * @param String $ruleId ID of the rule to save, or empty if this is a new rule. - */ - public function save_action($ruleType, $ruleId = '') - { - CSRFProtection::verifyUnsafeRequest(); - - $this->rule = $this->loadRule($ruleType, $ruleId); - $requestData = Request::getInstance(); - // Check for start and end date and parse the String values to timestamps. - if (!empty($requestData['start_date'])) { - $parsed = date_parse($requestData['start_date']); - $timestamp = mktime($parsed['hour'], $parsed['minute'], 0, - $parsed['month'], $parsed['day'], $parsed['year']); - $requestData['start_time'] = $timestamp; - } - if (!empty($requestData['end_date'])) { - $parsed = date_parse($requestData['end_date']); - $timestamp = mktime($parsed['hour'], $parsed['minute'], 0, - $parsed['month'], $parsed['day'], $parsed['year']); - $requestData['end_time'] = $timestamp; - } - $this->rule->setAllData($requestData); - } - - /** - * Validates if the values given in the current request are sufficient to - * configure a rule of the given type. - * - * @param String $ruleType Class name of the rule to check. - * @param String $ruleId ID of the rule to save, or empty if this is a new rule. - */ - public function validate_action($ruleType, $ruleId = '') - { - $rule = $this->loadRule($ruleType, $ruleId); - $this->errors = $rule->validate(Request::getInstance()); - } - - /** - * Loads a rule by string and ensures that it is a subclass of the abstract - * admission rule. - * - * @param string $rule_type - * @param string $rule_id - * @return AdmissionRule - */ - private function loadRule(string $rule_type, string $rule_id = ''): AdmissionRule - { - static $initialized = false; - - if (!$initialized) { - // This is neccessary so that all admission rules are correctly - // loaded and known to the system - AdmissionRule::getAvailableAdmissionRules(); - $initialized = true; - } - - if (!is_a($rule_type, AdmissionRule::class, true)) { - throw new InvalidArgumentException('Rule type must be a subclass of ' . AdmissionRule::class); - } - - return new $rule_type($rule_id); - } -} diff --git a/app/controllers/admission/ruleadministration.php b/app/controllers/admission/ruleadministration.php index 1a16910..a012aeb 100644 --- a/app/controllers/admission/ruleadministration.php +++ b/app/controllers/admission/ruleadministration.php @@ -27,7 +27,6 @@ class Admission_RuleadministrationController extends AuthenticatedController $GLOBALS['perm']->check('root'); Navigation::activateItem('/admin/config/admissionrules'); - PageLayout::addScript('studip-admission.js'); $sidebar = Sidebar::Get(); diff --git a/app/controllers/admission/userlist.php b/app/controllers/admission/userlist.php index 3192a50..25ad0ec 100644 --- a/app/controllers/admission/userlist.php +++ b/app/controllers/admission/userlist.php @@ -26,7 +26,6 @@ class Admission_UserlistController extends AuthenticatedController PageLayout::setTitle(_('Personenlisten')); Navigation::activateItem('/browse/coursesets/userlists'); - PageLayout::addScript('studip-admission.js'); Sidebar::get()->addWidget(new ActionsWidget())->addLink( _('Personenliste anlegen'), diff --git a/app/controllers/course/admission.php b/app/controllers/course/admission.php index 94f8415..5b22c82 100644 --- a/app/controllers/course/admission.php +++ b/app/controllers/course/admission.php @@ -48,7 +48,6 @@ class Course_AdmissionController extends AuthenticatedController $this->is_locked['write_level'] = 'disabled readonly'; } AdmissionApplication::addMembers($this->course->id); - PageLayout::addScript('studip-admission.js'); URLHelper::addLinkParam('return_to_dialog', Request::get('return_to_dialog')); } @@ -208,7 +207,7 @@ class Course_AdmissionController extends AuthenticatedController } } if (empty($question)) { - $this->redirect($this->action_url('index')); + $this->relocate($this->action_url('index')); } else { $this->button_yes = 'change_admission_prelim_yes'; $this->button_no = 'change_admission_prelim_no'; @@ -249,7 +248,7 @@ class Course_AdmissionController extends AuthenticatedController PageLayout::postSuccess(_("Zugriff für externe Nutzer wurde geändert.")); } } - $this->redirect($this->action_url('index')); + $this->relocate($this->action_url('index')); } function change_admission_turnout_action() @@ -313,7 +312,7 @@ class Course_AdmissionController extends AuthenticatedController } } if (empty($question)) { - $this->redirect($this->action_url('index')); + $this->relocate($this->action_url('index')); } else { $this->request = $request; $this->button_yes = 'change_admission_turnout_yes'; @@ -338,7 +337,7 @@ class Course_AdmissionController extends AuthenticatedController PageLayout::postSuccess(_('Die zugelassenen Nutzerdomänen wurden geändert.')); } } - $this->redirect($this->action_url('index')); + $this->relocate($this->action_url('index')); } function change_course_set_action() @@ -402,7 +401,7 @@ class Course_AdmissionController extends AuthenticatedController } } if (empty($question)) { - $this->redirect($this->action_url('index')); + $this->relocate($this->action_url('index')); } else { $this->request = ['change_course_set_unassign' => 1]; $this->button_yes = 'change_course_set_unassign_yes'; @@ -437,66 +436,40 @@ class Course_AdmissionController extends AuthenticatedController $rule_types = AdmissionRule::getAvailableAdmissionRules(true); if (isset($rule_types[$type])) { $rule = new $type($rule_id); - $another_rule = null; - if (isset($rule_types[$another_type])) { - $another_rule = new $another_type($another_rule_id); - } - $course_set = CourseSet::getSetForRule($rule_id) ?: new CourseSet(); - if ((Request::isPost() && Request::submitted('save')) || $rule instanceof LockedAdmission) { - if ($rule instanceof LockedAdmission) { - $course_set_id = CourseSet::getGlobalLockedAdmissionSetId(); - CourseSet::addCourseToSet($course_set_id, $this->course_id); - PageLayout::postSuccess(_('Die Veranstaltung wurde gesperrt.')); - $this->redirect($this->action_url('index')); - return; - } else { - CSRFProtection::verifyUnsafeRequest(); - $errors = $rule->validate(Request::getInstance()); - if (empty($errors)) { - $rule->setAllData(Request::getInstance()); - } - if ($another_rule) { - $another_errors = $another_rule->validate(Request::getInstance()); - if (empty($another_errors)) { - $another_rule->setAllData(Request::getInstance()); - } - $errors = array_merge($errors, $another_errors); - } - if (!mb_strlen(trim(Request::get('instant_course_set_name')))) { - $errors[] = _("Bitte geben Sie einen Namen für die Anmelderegel ein!"); - } else { - $course_set->setName(trim(Request::get('instant_course_set_name'))); - } - if (count($errors)) { - PageLayout::postError(_('Speichern fehlgeschlagen'), array_map('htmlready', $errors)); - } else { - $rule->store(); - $course_set->setPrivate(true); - $course_set->addAdmissionRule($rule); - $course_set->setAlgorithm(new RandomAlgorithm());//TODO - $course_set->setCourses([$this->course_id]); - if ($another_rule) { - $course_set->addAdmissionRule($another_rule); - } - $course_set->store(); - PageLayout::postSuccess(_("Die Anmelderegel wurde erzeugt und der Veranstaltung zugewiesen.")); - $this->redirect($this->action_url('index')); - return; - } + + if ($type === 'LockedAdmission') { + + $courseset = CourseSet::getGlobalLockedAdmissionSetId(); + CourseSet::addCourseToSet($courseset, $this->course_id); + + PageLayout::postSuccess(_('Die Veranstaltung wurde gesperrt.')); + $this->relocate('course/admission'); + + } else { + + $another_rule = null; + if (isset($rule_types[$another_type])) { + $another_rule = new $another_type($another_rule_id); } + $course_set = CourseSet::getSetForRule($rule_id) ?: new CourseSet(); + $types = [$type]; + if ($another_rule) { + $types[] = $another_type; + } + $course_set_name = $rule->getName() . ': ' . $this->course->name; + + $props = [ + 'rule-types' => $types, + 'course-set-name' => $course_set_name, + 'course-id' => $this->course_id + ]; + + $this->render_vue_app( + Studip\VueApp::create('admission/InstantCourseSet') + ->withProps($props) + ); + } - if (!$course_set->getId()) { - $course_set->setName($rule->getName() . ': ' . $this->course->name); - } - $this->rule_template = $rule->getTemplate(); - $this->type = $type; - $this->rule_id = $rule_id; - if ($another_rule) { - $this->type = $this->type . '_' . $another_type; - $this->rule_id = $this->rule_id . '_' . $another_rule->getId(); - $this->rule_template = $this->rule_template . $another_rule->getTemplate(); - } - $this->course_set_name = $course_set->getName(); } else { throw new Trails\Exception(400); } @@ -510,7 +483,7 @@ class Course_AdmissionController extends AuthenticatedController $response = $this->relay('admission/courseset/configure/' . $cs->getId()); $this->body = $response->body; if (!empty($response->headers['Location'])) { - $this->redirect($response->headers['Location']); + $this->relocate($response->headers['Location']); } } else { throw new Trails\Exception(403); @@ -525,7 +498,7 @@ class Course_AdmissionController extends AuthenticatedController $response = $this->relay('admission/courseset/save/' . $cs->getId()); $this->body = $response->body; if ($response->headers['Location']) { - $this->redirect($response->headers['Location']); + $this->relocate($response->headers['Location']); } } else { throw new Trails\Exception(403); diff --git a/app/controllers/course/details.php b/app/controllers/course/details.php index ab1c2a6..d8ac254 100644 --- a/app/controllers/course/details.php +++ b/app/controllers/course/details.php @@ -196,7 +196,6 @@ class Course_DetailsController extends AuthenticatedController } else { PageLayout::setHelpKeyword('Basis.InVeranstaltungDetails'); PageLayout::setTitle($this->title . ' - ' . _('Details')); - PageLayout::addScript('studip-admission.js'); $sidebar = Sidebar::Get(); diff --git a/app/views/admission/rule/configure.php b/app/views/admission/rule/configure.php deleted file mode 100644 index 64908ee..0000000 --- a/app/views/admission/rule/configure.php +++ /dev/null @@ -1,11 +0,0 @@ - -
- diff --git a/app/views/admission/rule/save.php b/app/views/admission/rule/save.php deleted file mode 100644 index 0f6e8d8..0000000 --- a/app/views/admission/rule/save.php +++ /dev/null @@ -1,23 +0,0 @@ - -
-
- toString() ?> - -
- -
diff --git a/app/views/admission/rule/select_type.php b/app/views/admission/rule/select_type.php deleted file mode 100644 index 1a72a75..0000000 --- a/app/views/admission/rule/select_type.php +++ /dev/null @@ -1,37 +0,0 @@ - -
-
- - $classDetail) { - $disabled = $courseset && !$courseset->isAdmissionRuleAllowed($className) ? 'disabled' : ''; - ?> -
- -
- - -
- -
- - >'), 'configure', [ - 'onclick' => "return $('input[name=ruletype]:checked').val() ? STUDIP.Admission.configureRule($('input[name=ruletype]:checked').val(), '". - $controller->url_for('admission/rule/configure')."') : false"]) ?> - url_for('admission/courseset/configure'), ['onclick' => "STUDIP.Admission.closeDialog('configurerule'); return false;"]) ?> -
-
diff --git a/app/views/admission/rule/validate.php b/app/views/admission/rule/validate.php deleted file mode 100644 index 4311d8d..0000000 --- a/app/views/admission/rule/validate.php +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/app/views/course/admission/instant_course_set.php b/app/views/course/admission/instant_course_set.php index fdd9702..01409b3 100644 --- a/app/views/course/admission/instant_course_set.php +++ b/app/views/course/admission/instant_course_set.php @@ -8,8 +8,9 @@
- -
+ + +
diff --git a/lib/admissionrules/conditionaladmission/ConditionalAdmission.php b/lib/admissionrules/conditionaladmission/ConditionalAdmission.php index 10bcb99..55aa317 100644 --- a/lib/admissionrules/conditionaladmission/ConditionalAdmission.php +++ b/lib/admissionrules/conditionaladmission/ConditionalAdmission.php @@ -198,24 +198,6 @@ class ConditionalAdmission extends AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - */ - public function getTemplate() - { - // Open generic admission rule template. - $tpl = $GLOBALS['template_factory']->open('admission/rules/configure'); - $tpl->set_attribute('rule', $this); - $factory = new Flexi\Factory(__DIR__ . '/templates/'); - // Now open specific template for this rule and insert base template. - $tpl2 = $factory->open('configure'); - $tpl2->set_attribute('rule', $this); - $tpl2->set_attribute('tpl', $tpl->render()); - return $tpl2->render(); - } - - /** * Helper function for loading data from DB. Generic AdmissionRule data is * loaded with the parent load() method. */ @@ -371,7 +353,7 @@ class ConditionalAdmission extends AdmissionRule $obj->setValue($field['attributes']['value']); $condition->addField($obj); } - $this->addCondition($condition, $data['conditiongroup_'.$condition->getId()], $data['quota_'.$data['conditiongroup_'.$condition->getId()]] ?? 0); + $this->addCondition($condition); } foreach ($data['grouped-conditions'] as $group) { diff --git a/lib/admissionrules/conditionaladmission/templates/configure.php b/lib/admissionrules/conditionaladmission/templates/configure.php deleted file mode 100644 index d4e7a14..0000000 --- a/lib/admissionrules/conditionaladmission/templates/configure.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/lib/admissionrules/connectedcourseadmission/ConnectedcourseAdmission.class.php b/lib/admissionrules/connectedcourseadmission/ConnectedcourseAdmission.class.php index 40f32ac..2bc8557 100644 --- a/lib/admissionrules/connectedcourseadmission/ConnectedcourseAdmission.class.php +++ b/lib/admissionrules/connectedcourseadmission/ConnectedcourseAdmission.class.php @@ -47,20 +47,6 @@ class ConnectedcourseAdmission extends AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - */ - public function getTemplate() - { - $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); - // Now open specific template for this rule and insert base template. - $tpl = $factory->open('configure'); - $tpl->set_attribute('rule', $this); - return $tpl->render(); - } - - /** * Internal helper function for loading rule definition from database. */ public function load() diff --git a/lib/admissionrules/connectedcourseadmission/templates/configure.php b/lib/admissionrules/connectedcourseadmission/templates/configure.php deleted file mode 100644 index 4a60973..0000000 --- a/lib/admissionrules/connectedcourseadmission/templates/configure.php +++ /dev/null @@ -1,5 +0,0 @@ -

getName() ?>

- - \ No newline at end of file diff --git a/lib/admissionrules/coursememberadmission/CourseMemberAdmission.php b/lib/admissionrules/coursememberadmission/CourseMemberAdmission.php index 00bccee..c1a4cb0 100644 --- a/lib/admissionrules/coursememberadmission/CourseMemberAdmission.php +++ b/lib/admissionrules/coursememberadmission/CourseMemberAdmission.php @@ -78,27 +78,6 @@ class CourseMemberAdmission extends AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - */ - public function getTemplate() - { - // Open generic admission rule template. - $tpl = $GLOBALS['template_factory']->open('admission/rules/configure'); - $tpl->set_attribute('rule', $this); - - $search = new StandardSearch('Seminar_id'); - - return $this->getTemplateFactory()->render('configure', [ - 'rule' => $this, - 'tpl' => $tpl->render(), - 'courses' => $this->getDecodedCourses(), - 'search' => $search - ]); - } - - /** * Helper function for loading rule definition from database. */ public function load() diff --git a/lib/admissionrules/coursememberadmission/templates/configure.php b/lib/admissionrules/coursememberadmission/templates/configure.php deleted file mode 100644 index a86150b..0000000 --- a/lib/admissionrules/coursememberadmission/templates/configure.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/lib/admissionrules/limitedadmission/LimitedAdmission.php b/lib/admissionrules/limitedadmission/LimitedAdmission.php index c0339cc..20893d7 100644 --- a/lib/admissionrules/limitedadmission/LimitedAdmission.php +++ b/lib/admissionrules/limitedadmission/LimitedAdmission.php @@ -118,23 +118,6 @@ class LimitedAdmission extends AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - */ - public function getTemplate() { - // Open generic admission rule template. - $tpl = $GLOBALS['template_factory']->open('admission/rules/configure'); - $tpl->set_attribute('rule', $this); - $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); - // Now open specific template for this rule and insert base template. - $tpl2 = $factory->open('configure'); - $tpl2->set_attribute('rule', $this); - $tpl2->set_attribute('tpl', $tpl->render()); - return $tpl2->render(); - } - - /** * Internal helper function for loading rule definition from database. */ public function load() { diff --git a/lib/admissionrules/limitedadmission/templates/configure.php b/lib/admissionrules/limitedadmission/templates/configure.php deleted file mode 100644 index 5a2e0a9..0000000 --- a/lib/admissionrules/limitedadmission/templates/configure.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/lib/admissionrules/lockedadmission/LockedAdmission.php b/lib/admissionrules/lockedadmission/LockedAdmission.php index afef13a..4330220 100644 --- a/lib/admissionrules/lockedadmission/LockedAdmission.php +++ b/lib/admissionrules/lockedadmission/LockedAdmission.php @@ -67,19 +67,6 @@ class LockedAdmission extends AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - */ - public function getTemplate() { - $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); - // Now open specific template for this rule and insert base template. - $tpl = $factory->open('configure'); - $tpl->set_attribute('rule', $this); - return $tpl->render(); - } - - /** * Internal helper function for loading rule definition from database. */ public function load() { diff --git a/lib/admissionrules/lockedadmission/templates/configure.php b/lib/admissionrules/lockedadmission/templates/configure.php deleted file mode 100644 index 5be3f66..0000000 --- a/lib/admissionrules/lockedadmission/templates/configure.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/lib/admissionrules/participantrestrictedadmission/ParticipantRestrictedAdmission.php b/lib/admissionrules/participantrestrictedadmission/ParticipantRestrictedAdmission.php index 2954602..924ce4f 100644 --- a/lib/admissionrules/participantrestrictedadmission/ParticipantRestrictedAdmission.php +++ b/lib/admissionrules/participantrestrictedadmission/ParticipantRestrictedAdmission.php @@ -101,20 +101,6 @@ class ParticipantRestrictedAdmission extends AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - */ - public function getTemplate() - { - $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); - // Open specific template for this rule and insert base template. - $tpl = $factory->open('configure'); - $tpl->set_attribute('rule', $this); - return $tpl->render(); - } - - /** * Helper function for loading rule definition from database. */ public function load() diff --git a/lib/admissionrules/participantrestrictedadmission/templates/configure.php b/lib/admissionrules/participantrestrictedadmission/templates/configure.php deleted file mode 100644 index c2b50f3..0000000 --- a/lib/admissionrules/participantrestrictedadmission/templates/configure.php +++ /dev/null @@ -1,5 +0,0 @@ -
- -
diff --git a/lib/admissionrules/passwordadmission/PasswordAdmission.php b/lib/admissionrules/passwordadmission/PasswordAdmission.php index 85c6e2d..f94f1b4 100644 --- a/lib/admissionrules/passwordadmission/PasswordAdmission.php +++ b/lib/admissionrules/passwordadmission/PasswordAdmission.php @@ -175,10 +175,11 @@ class PasswordAdmission extends AdmissionRule * @param Array $data * @return AdmissionRule This object. */ - public function setAllData($data) { + public function setAllData($data) + { parent::setAllData($data); - if ($this->new || $data['password1'] !== '') { - $this->setPassword($data['password1']); + if ($this->new || $data['password'] !== '') { + $this->setPassword($data['password']); } return $this; } @@ -189,7 +190,8 @@ class PasswordAdmission extends AdmissionRule * @param String $clearText The clear text password to be set. * @return PasswordAdmission */ - public function setPassword($clearText) { + public function setPassword($clearText) + { $this->password = $this->hasher->HashPassword($clearText); return $this; } diff --git a/lib/admissionrules/passwordadmission/templates/configure.php b/lib/admissionrules/passwordadmission/templates/configure.php deleted file mode 100644 index 5a95b85..0000000 --- a/lib/admissionrules/passwordadmission/templates/configure.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/lib/admissionrules/preferentialadmission/PreferentialAdmission.php b/lib/admissionrules/preferentialadmission/PreferentialAdmission.php index 9617f2b..c92677a 100644 --- a/lib/admissionrules/preferentialadmission/PreferentialAdmission.php +++ b/lib/admissionrules/preferentialadmission/PreferentialAdmission.php @@ -329,20 +329,6 @@ class PreferentialAdmission extends AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - */ - public function getTemplate() - { - $factory = new Flexi\Factory(__DIR__.'/templates/'); - // Now open specific template for this rule and insert base template. - $tpl = $factory->open('configure'); - $tpl->set_attribute('rule', $this); - return $tpl->render(); - } - - /** * Helper function for loading data from DB. Generic AdmissionRule data is * loaded with the parent load() method. */ diff --git a/lib/admissionrules/preferentialadmission/templates/configure.php b/lib/admissionrules/preferentialadmission/templates/configure.php deleted file mode 100644 index 240e12c..0000000 --- a/lib/admissionrules/preferentialadmission/templates/configure.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/lib/admissionrules/termsadmission/TermsAdmission.php b/lib/admissionrules/termsadmission/TermsAdmission.php index 5e98513..3fda619 100644 --- a/lib/admissionrules/termsadmission/TermsAdmission.php +++ b/lib/admissionrules/termsadmission/TermsAdmission.php @@ -79,21 +79,6 @@ class TermsAdmission extends AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - * @throws Flexi\TemplateNotFoundException - */ - public function getTemplate() - { - $factory = new Flexi\Factory(__DIR__ . '/templates'); - $template = $factory->open('configure'); - $template->rule = $this; - - return $template->render(); - } - - /** * Does the current rule allow the given user to register as participant * in the given course? * diff --git a/lib/admissionrules/termsadmission/templates/configure.php b/lib/admissionrules/termsadmission/templates/configure.php deleted file mode 100644 index 48d4dfd..0000000 --- a/lib/admissionrules/termsadmission/templates/configure.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/lib/admissionrules/timedadmission/TimedAdmission.php b/lib/admissionrules/timedadmission/TimedAdmission.php index 69a828e..dad423f 100644 --- a/lib/admissionrules/timedadmission/TimedAdmission.php +++ b/lib/admissionrules/timedadmission/TimedAdmission.php @@ -96,19 +96,6 @@ class TimedAdmission extends AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - */ - public function getTemplate() { - $factory = new Flexi\Factory(dirname(__FILE__).'/templates/'); - // Open specific template for this rule and insert base template. - $tpl = $factory->open('configure'); - $tpl->set_attribute('rule', $this); - return $tpl->render(); - } - - /** * Helper function for loading rule definition from database. */ public function load() { diff --git a/lib/admissionrules/timedadmission/templates/configure.php b/lib/admissionrules/timedadmission/templates/configure.php deleted file mode 100644 index d39f6ab..0000000 --- a/lib/admissionrules/timedadmission/templates/configure.php +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/lib/classes/admission/AdmissionRule.php b/lib/classes/admission/AdmissionRule.php index 9855165..28adfec 100644 --- a/lib/classes/admission/AdmissionRule.php +++ b/lib/classes/admission/AdmissionRule.php @@ -310,16 +310,6 @@ abstract class AdmissionRule } /** - * Gets the template that provides a configuration GUI for this rule. - * - * @return String - */ - public function getTemplate() - { - return ''; - } - - /** * Internal helper function for loading rule definition from database. */ public function load() diff --git a/resources/assets/javascripts/bootstrap/admission.js b/resources/assets/javascripts/bootstrap/admission.js index c04ff24..2fff6cf 100644 --- a/resources/assets/javascripts/bootstrap/admission.js +++ b/resources/assets/javascripts/bootstrap/admission.js @@ -22,32 +22,15 @@ STUDIP.ready(function () { components[ruleType] = result.default; STUDIP.Vue.load().then(({ createApp }) => { - createApp({ - el: container, - components: components - }); + createApp({components}).mount(container); }); }); } }); - $(document).on('change', 'tr.course input', function() { - STUDIP.Admission.toggleNotSavedAlert(); - }); - $('a.userlist-delete-user').on('click', function() { $(this).closest('tr').remove(); return false; }); - - $('#courseset-form .autosave').on('click', () => { - STUDIP.Admission.autosaveCourseset(); - }); - - STUDIP.ready(() => { - $('#toggle-date-link').on('click', () => { - $('#admissionrule-valid-date').toggleClass('hidden-js'); - }); - }); }); diff --git a/resources/assets/javascripts/entry-admission.js b/resources/assets/javascripts/entry-admission.js deleted file mode 100644 index 5454d08..0000000 --- a/resources/assets/javascripts/entry-admission.js +++ /dev/null @@ -1 +0,0 @@ -import "./bootstrap/admission.js" diff --git a/resources/assets/javascripts/entry-base.js b/resources/assets/javascripts/entry-base.js index 2210471..db3d1f6 100644 --- a/resources/assets/javascripts/entry-base.js +++ b/resources/assets/javascripts/entry-base.js @@ -78,6 +78,7 @@ import "./bootstrap/oer.js" import "./bootstrap/courseware.js" import "./bootstrap/external_pages.js" import "./bootstrap/vips.js" +import "./bootstrap/admission.js" import "./mvv_course_wizard.js" import "./mvv.js" diff --git a/resources/assets/javascripts/lib/admission.js b/resources/assets/javascripts/lib/admission.js index 8c0413a..c735cb2 100644 --- a/resources/assets/javascripts/lib/admission.js +++ b/resources/assets/javascripts/lib/admission.js @@ -2,7 +2,6 @@ * Anmeldeverfahren und -sets * ------------------------------------------------------------------------ */ import { $gettext } from './gettext'; -import Dialog from './dialog.js'; const Admission = { @@ -46,143 +45,6 @@ const Admission = { return false; }, - configureRule: function(ruleType, targetUrl, ruleId) { - var urlparts = targetUrl.split('?'); - targetUrl = urlparts[0] + '/' + ruleType; - if (urlparts[1]) { - targetUrl += '?' + urlparts[1]; - } - - Dialog.fromURL(targetUrl, { - method: 'post', - size: 'auto', - title: $gettext('Anmelderegel konfigurieren'), - id: 'configurerule', - data: { ruleId: ruleId, rules: _.map($('#rules input[name="rules[]"]'), 'value') } - }); - - return false; - }, - - selectRuleType: function(source) { - Dialog.fromURL(source, { - title: $gettext('Anmelderegel konfigurieren'), - size: 'auto', - data: { rules: _.map($('#rules input[name="rules[]"]'), 'value') }, - method: 'post', - id: 'configurerule' - }); - return false; - }, - - saveRule: function(ruleId, targetId, targetUrl) { - if ($('#action').val() !== 'cancel') { - $.ajax({ - type: 'post', - url: targetUrl, - data: $('#ruleform').serialize(), - dataType: 'html', - success: function(data) { - if (data !== '') { - var result = ''; - if ($('#norules').length > 0) { - $('#norules').remove(); - $('#' + targetId).prepend('
'); - } - result += data; - if ($('#rule_' + ruleId).length !== 0) { - $('#rule_' + ruleId).replaceWith(result); - } else { - $('#rulelist').append(result); - } - } - }, - error: function(jqXHR, textStatus, errorThrown) { - alert('Status: ' + textStatus + '\nError: ' + errorThrown); - } - }); - } - Admission.closeDialog('configurerule'); - Admission.toggleNotSavedAlert(); - return false; - }, - - removeRule: function(targetId, containerId) { - var parent = $('#' + targetId).parent(); - $('#' + targetId).remove(); - if (parent.children('div').length === 0) { - parent.remove(); - var norules = $gettext('Sie haben noch keine Anmelderegeln festgelegt.'); - $('#' + containerId).prepend('' + '' + norules + ''); - } - Admission.toggleNotSavedAlert(); - }, - - toggleRuleDescription: function(targetId) { - $('#' + targetId).toggle(); - return false; - }, - - toggleDetails: function(arrowId, detailId) { - var oldSrc = $('#' + arrowId).attr('src'); - var newSrc = $('#' + arrowId).attr('rel'); - $('#' + arrowId).attr('src', newSrc); - $('#' + arrowId).attr('rel', oldSrc); - $('#' + detailId).slideToggle(); - return false; - }, - - /** - * - * @param String ruleId The rule to save. - * @param String errorTarget Target element ID where error messages will be - * shown. - * @param String validateUrl URL to call for validation. - * @param String savedTarget Target element ID where the saved rule will be - * displayed. - * @param String saveUrl URL to save the rule. - */ - checkAndSaveRule: function(ruleId, errorTarget, validateUrl, savedTarget, saveUrl) { - if (Admission.validateRuleConfig(errorTarget, validateUrl)) { - Admission.saveRule(ruleId, savedTarget, saveUrl); - Dialog.close({ id: 'configurerule' }); - } - return false; - }, - - validateRuleConfig: function(containerId, targetUrl) { - var valid = true; - var error = $.ajax({ - type: 'post', - async: false, - url: targetUrl, - data: $('#ruleform').serialize(), - dataType: 'html', - - error: function(jqXHR, textStatus, errorThrown) { - alert('Status: ' + textStatus + '\nError: ' + errorThrown); - } - }).responseText; - error = error.replace(/(\r\n|\n|\r)/gm, ''); - if ($.trim(error) != '') { - $('#' + containerId).html(error); - valid = false; - } - return valid; - }, - - removeUserFromUserlist: function(userId) { - var parent = $('#user_' + userId).parent(); - $('#user_' + userId).remove(); - if (parent.children('li').length === 0) { - var nousers = $gettext('Sie haben noch niemanden hinzugefügt.'); - $(parent) - .parent() - .append('' + '' + nousers + ''); - } - return false; - }, - updateInstitutes: function(elementId, instURL, courseURL, mode) { if (elementId !== '') { var query = ''; @@ -208,26 +70,6 @@ const Admission = { } }, - checkRuleActivation: function(target) { - var form = $('#' + target); - var globalActivation = form.find('input[name=enabled]'); - if (globalActivation.prop('checked')) { - $('#activation').show(); - if (form.find('input[name=activated]:checked').val() === 'studip') { - $('#institutes_activation').hide(); - } else { - $('#institutes_activation').show(); - } - } else { - $('#activation').hide(); - $('#institutes_activation').hide(); - } - }, - - closeDialog: function(elementId) { - $('#' + elementId).remove(); - }, - checkUncheckAll: function(inputName, mode) { switch (mode) { case 'check': @@ -251,20 +93,6 @@ const Admission = { toggleNotSavedAlert: function() { $('.hidden-alert').show(); - }, - - autosaveCourseset: function() { - $.post({ - url: $('#courseset-form').attr('action'), - data: $('#courseset-form').serialize() + '&submit=1', - dataType: 'html', - success: function() { - $('.hidden-alert').hide(); - }, - error: function(jqXHR, textStatus, errorThrown) { - alert('Status: ' + textStatus + '\nError: ' + errorThrown); - } - }); } }; diff --git a/resources/assets/javascripts/studip-ui.js b/resources/assets/javascripts/studip-ui.js index d6483f3..f563b31 100644 --- a/resources/assets/javascripts/studip-ui.js +++ b/resources/assets/javascripts/studip-ui.js @@ -11,7 +11,9 @@ import RestrictedDatesHelper from './lib/RestrictedDatesHelper'; $.widget( "ui.dialog", $.ui.dialog, { _allowInteraction: function( event ) { - return hasParentWhich(isCKBodyWrapper)(event.target) || this._super( event ); + return hasParentWhich(isCKBodyWrapper)(event.target) + || event.target.closest('.studip-dialog') !== null + || this._super( event ); }, }); diff --git a/resources/assets/stylesheets/scss/admission.scss b/resources/assets/stylesheets/scss/admission.scss index d9d978c..50fce65 100644 --- a/resources/assets/stylesheets/scss/admission.scss +++ b/resources/assets/stylesheets/scss/admission.scss @@ -1,17 +1,3 @@ -#rulelist div.admissionrule { - display: list-item; - list-style-type: disc; - margin-left: 25px; -} - -#toggle-date-container { - margin-top: 10px; - - img, svg { - vertical-align: text-bottom; - } -} - .hover_box { div { display: inline; @@ -88,23 +74,6 @@ form.default { } } -#userlists { - div { - margin-bottom: 10px; - - a { - &.userlist-action { - margin-left: 2px; - margin-right: 2px; - } - - img { - vertical-align: bottom; - } - } - } -} - form { fieldset { section { diff --git a/resources/vue/components/Quicksearch.vue b/resources/vue/components/Quicksearch.vue index 1a61513..9177ae5 100644 --- a/resources/vue/components/Quicksearch.vue +++ b/resources/vue/components/Quicksearch.vue @@ -32,7 +32,7 @@ diff --git a/resources/vue/components/admission/AdmissionRuleConfig.vue b/resources/vue/components/admission/AdmissionRuleConfig.vue index 921a6c2..d6d6e65 100644 --- a/resources/vue/components/admission/AdmissionRuleConfig.vue +++ b/resources/vue/components/admission/AdmissionRuleConfig.vue @@ -1,5 +1,5 @@ +
+ + {{ $gettext('Es sind ungültige Daten angegeben worden:') }} + + +
diff --git a/resources/vue/components/admission/ParticipantRestrictedAdmission.vue b/resources/vue/components/admission/ParticipantRestrictedAdmission.vue index 9f75b9a..96b6cfb 100644 --- a/resources/vue/components/admission/ParticipantRestrictedAdmission.vue +++ b/resources/vue/components/admission/ParticipantRestrictedAdmission.vue @@ -1,4 +1,4 @@ -