MDL-69055 core_badges: display password/oauth fields properly
[moodle.git] / badges / classes / form / external_backpack.php
index f92febd..e5c495c 100644 (file)
@@ -80,16 +80,16 @@ class external_backpack extends \moodleform {
         $issuercontact = $CFG->badges_defaultissuercontact;
         $mform->addElement('static', 'issuerinfo', get_string('defaultissuercontact', 'core_badges'), $issuercontact);
 
-        if ($backpack && $backpack->apiversion != OPEN_BADGES_V2P1) {
-            $mform->addElement('passwordunmask', 'password', get_string('defaultissuerpassword', 'core_badges'));
-            $mform->setType('password', PARAM_RAW);
-            $mform->addHelpButton('password', 'defaultissuerpassword', 'badges');
-            $mform->hideIf('password', 'apiversion', 'eq', 1);
-        } else {
-            $oauth2options = badges_get_oauth2_service_options();
-            $mform->addElement('select', 'oauth2_issuerid', get_string('oauth2issuer', 'core_badges'), $oauth2options);
-            $mform->setType('oauth2_issuerid', PARAM_INT);
-        }
+        $mform->addElement('passwordunmask', 'password', get_string('defaultissuerpassword', 'core_badges'));
+        $mform->setType('password', PARAM_RAW);
+        $mform->addHelpButton('password', 'defaultissuerpassword', 'badges');
+        $mform->hideIf('password', 'apiversion', 'neq', 2);
+
+        $oauth2options = badges_get_oauth2_service_options();
+        $mform->addElement('select', 'oauth2_issuerid', get_string('oauth2issuer', 'core_badges'), $oauth2options);
+        $mform->setType('oauth2_issuerid', PARAM_INT);
+        $mform->hideIf('oauth2_issuerid', 'apiversion', 'neq', '2.1');
+
         if ($backpack) {
             $this->set_data($backpack);
         }