MDL-69055 core_badges: display password/oauth fields properly
authorSara Arjona <sara@moodle.com>
Tue, 11 Aug 2020 10:36:58 +0000 (12:36 +0200)
committerSara Arjona <sara@moodle.com>
Fri, 14 Aug 2020 15:10:17 +0000 (17:10 +0200)
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);
         }