diff --git a/admin/tool/oauth2/classes/form/issuer.php b/admin/tool/oauth2/classes/form/issuer.php index a5d6c971adc..f466509f46d 100644 --- a/admin/tool/oauth2/classes/form/issuer.php +++ b/admin/tool/oauth2/classes/form/issuer.php @@ -115,28 +115,6 @@ class issuer extends persistent { $mform->addElement('checkbox', 'basicauth', get_string('usebasicauth', 'tool_oauth2')); $mform->addHelpButton('basicauth', 'usebasicauth', 'tool_oauth2'); - // Login scopes. - $mform->addElement('text', 'loginscopes', get_string('issuerloginscopes', 'tool_oauth2')); - $mform->addRule('loginscopes', null, 'required', null, 'client'); - $mform->addRule('loginscopes', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); - $mform->addHelpButton('loginscopes', 'issuerloginscopes', 'tool_oauth2'); - - // Login scopes offline. - $mform->addElement('text', 'loginscopesoffline', get_string('issuerloginscopesoffline', 'tool_oauth2')); - $mform->addRule('loginscopesoffline', null, 'required', null, 'client'); - $mform->addRule('loginscopesoffline', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); - $mform->addHelpButton('loginscopesoffline', 'issuerloginscopesoffline', 'tool_oauth2'); - - // Login params. - $mform->addElement('text', 'loginparams', get_string('issuerloginparams', 'tool_oauth2')); - $mform->addRule('loginparams', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); - $mform->addHelpButton('loginparams', 'issuerloginparams', 'tool_oauth2'); - - // Login params offline. - $mform->addElement('text', 'loginparamsoffline', get_string('issuerloginparamsoffline', 'tool_oauth2')); - $mform->addRule('loginparamsoffline', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); - $mform->addHelpButton('loginparamsoffline', 'issuerloginparamsoffline', 'tool_oauth2'); - // Base Url. $mform->addElement('text', 'baseurl', get_string('issuerbaseurl', 'tool_oauth2')); $mform->addRule('baseurl', get_string('maximumchars', '', 1024), 'maxlength', 1024, 'client'); @@ -145,24 +123,61 @@ class issuer extends persistent { $mform->addRule('baseurl', null, 'required', null, 'client'); } - // Allowed Domains. - $mform->addElement('text', 'alloweddomains', get_string('issueralloweddomains', 'tool_oauth2')); - $mform->addRule('alloweddomains', get_string('maximumchars', '', 1024), 'maxlength', 1024, 'client'); - $mform->addHelpButton('alloweddomains', 'issueralloweddomains', 'tool_oauth2'); - // Image. $mform->addElement('text', 'image', get_string('issuerimage', 'tool_oauth2'), 'maxlength="1024"'); $mform->addRule('image', get_string('maximumchars', '', 1024), 'maxlength', 1024, 'client'); $mform->addHelpButton('image', 'issuername', 'tool_oauth2'); // Show on login page. - $mform->addElement('checkbox', 'showonloginpage', get_string('issuershowonloginpage', 'tool_oauth2')); - $mform->addHelpButton('showonloginpage', 'issuershowonloginpage', 'tool_oauth2'); + $options = [ + \core\oauth2\issuer::EVERYWHERE => get_string('issueruseineverywhere', 'tool_oauth2'), + \core\oauth2\issuer::LOGINONLY => get_string('issueruseinloginonly', 'tool_oauth2'), + \core\oauth2\issuer::SERVICEONLY => get_string('issueruseininternalonly', 'tool_oauth2'), + ]; + $mform->addElement('select', 'showonloginpage', get_string('issuerusein', 'tool_oauth2'), $options); + $mform->addHelpButton('showonloginpage', 'issuerusein', 'tool_oauth2'); + + // Name on login page. + $mform->addElement('text', 'loginpagename', get_string('issuerloginpagename', 'tool_oauth2')); + $mform->addRule('loginpagename', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); + $mform->addHelpButton('loginpagename', 'issuerloginpagename', 'tool_oauth2'); + $mform->hideIf('loginpagename', 'showonloginpage', 'eq', \core\oauth2\issuer::SERVICEONLY); + + // Login scopes. + $mform->addElement('text', 'loginscopes', get_string('issuerloginscopes', 'tool_oauth2')); + $mform->addRule('loginscopes', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); + $mform->addHelpButton('loginscopes', 'issuerloginscopes', 'tool_oauth2'); + $mform->hideIf('loginscopes', 'showonloginpage', 'eq', \core\oauth2\issuer::SERVICEONLY); + + // Login scopes offline. + $mform->addElement('text', 'loginscopesoffline', get_string('issuerloginscopesoffline', 'tool_oauth2')); + $mform->addRule('loginscopesoffline', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); + $mform->addHelpButton('loginscopesoffline', 'issuerloginscopesoffline', 'tool_oauth2'); + $mform->hideIf('loginscopesoffline', 'showonloginpage', 'eq', \core\oauth2\issuer::SERVICEONLY); + + // Login params. + $mform->addElement('text', 'loginparams', get_string('issuerloginparams', 'tool_oauth2')); + $mform->addRule('loginparams', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); + $mform->addHelpButton('loginparams', 'issuerloginparams', 'tool_oauth2'); + $mform->hideIf('loginparams', 'showonloginpage', 'eq', \core\oauth2\issuer::SERVICEONLY); + + // Login params offline. + $mform->addElement('text', 'loginparamsoffline', get_string('issuerloginparamsoffline', 'tool_oauth2')); + $mform->addRule('loginparamsoffline', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); + $mform->addHelpButton('loginparamsoffline', 'issuerloginparamsoffline', 'tool_oauth2'); + $mform->hideIf('loginparamsoffline', 'showonloginpage', 'eq', \core\oauth2\issuer::SERVICEONLY); + + // Allowed Domains. + $mform->addElement('text', 'alloweddomains', get_string('issueralloweddomains', 'tool_oauth2')); + $mform->addRule('alloweddomains', get_string('maximumchars', '', 1024), 'maxlength', 1024, 'client'); + $mform->addHelpButton('alloweddomains', 'issueralloweddomains', 'tool_oauth2'); + $mform->hideIf('alloweddomains', 'showonloginpage', 'eq', \core\oauth2\issuer::SERVICEONLY); if ($this->showrequireconfirm) { // Require confirmation email for new accounts. $mform->addElement('advcheckbox', 'requireconfirmation', get_string('issuerrequireconfirmation', 'tool_oauth2')); $mform->addHelpButton('requireconfirmation', 'issuerrequireconfirmation', 'tool_oauth2'); + $mform->hideIf('requireconfirmation', 'showonloginpage', 'eq', \core\oauth2\issuer::SERVICEONLY); } if ($this->type == 'imsobv2p1' || $issuer->get('servicetype') == 'imsobv2p1') { @@ -209,4 +224,36 @@ class issuer extends persistent { $mform->getElement('servicetype')->setValue($this->type); } } + + /** + * Define extra validation mechanims. + * + * The data here: + * - does not include {@link self::$fieldstoremove}. + * - does include {@link self::$foreignfields}. + * - was converted to map persistent-like data, e.g. array $description to string $description + int $descriptionformat. + * + * You can modify the $errors parameter in order to remove some validation errors should you + * need to. However, the best practice is to return new or overriden errors. Only modify the + * errors passed by reference when you have no other option. + * + * Do not add any logic here, it is only intended to be used by child classes. + * + * @param stdClass $data Data to validate. + * @param array $files Array of files. + * @param array $errors Currently reported errors. + * @return array of additional errors, or overridden errors. + */ + protected function extra_validation($data, $files, array &$errors) { + $errors = []; + if ($data->showonloginpage != \core\oauth2\issuer::SERVICEONLY) { + if (!strlen(trim($data->loginscopes))) { + $errors['loginscopes'] = get_string('required'); + } + if (!strlen(trim($data->loginscopesoffline))) { + $errors['loginscopesoffline'] = get_string('required'); + } + } + return $errors; + } } diff --git a/admin/tool/oauth2/classes/output/renderer.php b/admin/tool/oauth2/classes/output/renderer.php index b838d0af482..23c41b0033b 100644 --- a/admin/tool/oauth2/classes/output/renderer.php +++ b/admin/tool/oauth2/classes/output/renderer.php @@ -54,7 +54,9 @@ class renderer extends plugin_renderer_base { $table->head = [ get_string('name'), get_string('configuredstatus', 'tool_oauth2'), - get_string('loginissuer', 'tool_oauth2'), + get_string('issuerusedforlogin', 'tool_oauth2'), + get_string('issuerdisplayas', 'tool_oauth2'), + get_string('issuerusedforinternal', 'tool_oauth2'), get_string('discoverystatus', 'tool_oauth2') . ' ' . $this->help_icon('discovered', 'tool_oauth2'), get_string('systemauthstatus', 'tool_oauth2') . ' ' . $this->help_icon('systemaccountconnected', 'tool_oauth2'), get_string('edit'), @@ -93,12 +95,22 @@ class renderer extends plugin_renderer_base { $configuredstatuscell = new html_table_cell($configured); // Login issuer. - if (!empty($issuer->get('showonloginpage'))) { + if ((int)$issuer->get('showonloginpage') != issuer::SERVICEONLY) { + $loginissuer = $this->pix_icon('yes', get_string('loginissuer', 'tool_oauth2'), 'tool_oauth2'); + $logindisplayas = s($issuer->get_display_name()); + } else { + $loginissuer = $this->pix_icon('no', get_string('notloginissuer', 'tool_oauth2'), 'tool_oauth2'); + $logindisplayas = ''; + } + $loginissuerstatuscell = new html_table_cell($loginissuer); + + // Internal services issuer. + if ((int)$issuer->get('showonloginpage') != issuer::LOGINONLY) { $loginissuer = $this->pix_icon('yes', get_string('loginissuer', 'tool_oauth2'), 'tool_oauth2'); } else { $loginissuer = $this->pix_icon('no', get_string('notloginissuer', 'tool_oauth2'), 'tool_oauth2'); } - $loginissuerstatuscell = new html_table_cell($loginissuer); + $internalissuerstatuscell = new html_table_cell($loginissuer); // Discovered. if (!empty($issuer->get('scopessupported'))) { @@ -188,6 +200,8 @@ class renderer extends plugin_renderer_base { $namecell, $configuredstatuscell, $loginissuerstatuscell, + $logindisplayas, + $internalissuerstatuscell, $discoverystatuscell, $systemauthstatuscell, $editcell, diff --git a/admin/tool/oauth2/issuers.php b/admin/tool/oauth2/issuers.php index 6383ef2c46b..ad720c4d5d1 100644 --- a/admin/tool/oauth2/issuers.php +++ b/admin/tool/oauth2/issuers.php @@ -195,7 +195,7 @@ if ($mform && $mform->is_cancelled()) { echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('pluginname', 'tool_oauth2')); echo $OUTPUT->doc_link('OAuth2_Services', get_string('serviceshelp', 'tool_oauth2')); - $issuers = core\oauth2\api::get_all_issuers(); + $issuers = core\oauth2\api::get_all_issuers(true); echo $renderer->issuers_table($issuers); echo $renderer->container_start(); diff --git a/admin/tool/oauth2/lang/en/tool_oauth2.php b/admin/tool/oauth2/lang/en/tool_oauth2.php index 9ff13af03a4..c37bda1a97b 100644 --- a/admin/tool/oauth2/lang/en/tool_oauth2.php +++ b/admin/tool/oauth2/lang/en/tool_oauth2.php @@ -70,6 +70,8 @@ $string['issuerdisabled'] = 'Identity issuer disabled'; $string['issuerenabled'] = 'Identity issuer enabled'; $string['issuerimage_help'] = 'An image URL used to show a logo for this issuer. May be displayed on login page.'; $string['issuerimage'] = 'Logo URL'; +$string['issuerloginpagename'] = 'Name displayed on the login page'; +$string['issuerloginpagename_help'] = 'If specified, this name will be used on the login page instead of the service name above'; $string['issuerloginparams'] = 'Additional parameters included in a login request.'; $string['issuerloginparams_help'] = 'Some systems require additional parameters for a login request in order to read the user\'s basic profile.'; $string['issuerloginparamsoffline'] = 'Additional parameters included in a login request for offline access.'; @@ -85,6 +87,14 @@ $string['issuershowonloginpage'] = 'Show on login page'; $string['issuerrequireconfirmation_help'] = 'Require that all users verify their email address before they can log in with OAuth. This applies to newly created accounts as part of the login process, or when an existing Moodle account is connected to an OAuth login via matching email addresses.'; $string['issuerrequireconfirmation'] = 'Require email verification'; $string['issuers'] = 'Issuers'; +$string['issuerusein'] = 'This service will be used'; +$string['issuerusein_help'] = 'OAuth 2 services can be used in some internal services, on the login page, or both, if needed'; +$string['issueruseineverywhere'] = 'Login page and internal services'; +$string['issueruseininternalonly'] = 'Internal services only'; +$string['issueruseinloginonly'] = 'Login page only'; +$string['issuerusedforlogin'] = 'Login'; +$string['issuerusedforinternal'] = 'Services'; +$string['issuerdisplayas'] = 'Display as'; $string['loginissuer'] = 'Allow login'; $string['microsoft_service'] = 'Microsoft'; $string['nextcloud_service'] = 'Nextcloud'; diff --git a/auth/oauth2/classes/auth.php b/auth/oauth2/classes/auth.php index 41527292b70..251adbff50a 100644 --- a/auth/oauth2/classes/auth.php +++ b/auth/oauth2/classes/auth.php @@ -166,17 +166,6 @@ class auth extends \auth_plugin_base { return false; } - /** - * Do some checks on the identity provider before showing it on the login page. - * @param core\oauth2\issuer $issuer - * @return boolean - */ - private function is_ready_for_login_page(\core\oauth2\issuer $issuer) { - return $issuer->get('enabled') && - $issuer->is_configured() && - !empty($issuer->get('showonloginpage')); - } - /** * Return a list of identity providers to display on the login page. * @@ -184,17 +173,17 @@ class auth extends \auth_plugin_base { * @return array List of arrays with keys url, iconurl and name. */ public function loginpage_idp_list($wantsurl) { - $providers = \core\oauth2\api::get_all_issuers(); + $providers = \core\oauth2\api::get_all_issuers(true); $result = []; if (empty($wantsurl)) { $wantsurl = '/'; } foreach ($providers as $idp) { - if ($this->is_ready_for_login_page($idp)) { + if ($idp->is_available_for_login()) { $params = ['id' => $idp->get('id'), 'wantsurl' => $wantsurl, 'sesskey' => sesskey()]; $url = new moodle_url('/auth/oauth2/login.php', $params); $icon = $idp->get('image'); - $result[] = ['url' => $url, 'iconurl' => $icon, 'name' => $idp->get('name')]; + $result[] = ['url' => $url, 'iconurl' => $icon, 'name' => $idp->get_display_name()]; } } return $result; diff --git a/auth/oauth2/classes/output/renderer.php b/auth/oauth2/classes/output/renderer.php index 12435603891..07a0428afe6 100644 --- a/auth/oauth2/classes/output/renderer.php +++ b/auth/oauth2/classes/output/renderer.php @@ -28,7 +28,7 @@ use html_table; use html_table_cell; use html_table_row; use html_writer; -use auth\oauth2\linked_login; +use auth_oauth2\linked_login; use moodle_url; defined('MOODLE_INTERNAL') || die(); @@ -43,7 +43,7 @@ class renderer extends plugin_renderer_base { /** * This function will render one beautiful table with all the linked_logins. * - * @param \auth\oauth2\linked_login[] $linkedlogins - list of all linked logins. + * @param linked_login[] $linkedlogins - list of all linked logins. * @return string HTML to output. */ public function linked_logins_table($linkedlogins) { diff --git a/auth/oauth2/linkedlogins.php b/auth/oauth2/linkedlogins.php index 146e261857e..30df5d44d7b 100644 --- a/auth/oauth2/linkedlogins.php +++ b/auth/oauth2/linkedlogins.php @@ -45,7 +45,7 @@ if ($action == 'new') { $issuerid = required_param('issuerid', PARAM_INT); $issuer = \core\oauth2\api::get_issuer($issuerid); - if (!$issuer->is_authentication_supported() || !$issuer->get('showonloginpage') || !$issuer->get('enabled')) { + if (!$issuer->is_available_for_login()) { throw new \moodle_exception('issuernologin', 'auth_oauth2'); } @@ -89,19 +89,20 @@ $linkedlogin = null; auth_oauth2\api::clean_orphaned_linked_logins(); -$issuers = \core\oauth2\api::get_all_issuers(); +$issuers = \core\oauth2\api::get_all_issuers(true); $anyshowinloginpage = false; $issuerbuttons = array(); foreach ($issuers as $issuer) { - if (!$issuer->is_authentication_supported() || !$issuer->get('showonloginpage') || !$issuer->get('enabled')) { + if (!$issuer->is_available_for_login()) { continue; } $anyshowinloginpage = true; $addparams = ['action' => 'new', 'issuerid' => $issuer->get('id'), 'sesskey' => sesskey(), 'logout' => true]; $addurl = new moodle_url('/auth/oauth2/linkedlogins.php', $addparams); - $issuerbuttons[$issuer->get('id')] = $renderer->single_button($addurl, get_string('createnewlinkedlogin', 'auth_oauth2', s($issuer->get('name')))); + $issuerbuttons[$issuer->get('id')] = $renderer->single_button($addurl, get_string('createnewlinkedlogin', 'auth_oauth2', + s($issuer->get_display_name()))); } if (!$anyshowinloginpage) { diff --git a/auth/oauth2/login.php b/auth/oauth2/login.php index 9abb2a32cdf..949b5a10e4c 100644 --- a/auth/oauth2/login.php +++ b/auth/oauth2/login.php @@ -37,6 +37,9 @@ if (!\auth_oauth2\api::is_enabled()) { } $issuer = new \core\oauth2\issuer($issuerid); +if (!$issuer->is_available_for_login()) { + throw new \moodle_exception('issuernologin', 'auth_oauth2'); +} $returnparams = ['wantsurl' => $wantsurl, 'sesskey' => sesskey(), 'id' => $issuerid]; $returnurl = new moodle_url('/auth/oauth2/login.php', $returnparams); diff --git a/lib/classes/oauth2/api.php b/lib/classes/oauth2/api.php index 6219c8dc98c..ed6b4fd935d 100644 --- a/lib/classes/oauth2/api.php +++ b/lib/classes/oauth2/api.php @@ -110,10 +110,16 @@ class api { /** * List all the issuers, ordered by the sortorder field + * + * @param bool $showall also include issues that are configured to be shown only on login page * @return \core\oauth2\issuer[] */ - public static function get_all_issuers() { - return issuer::get_records([], 'sortorder'); + public static function get_all_issuers(bool $showall = false) { + if ($showall) { + return issuer::get_records([], 'sortorder'); + } else { + return array_values(issuer::get_records_select('showonloginpage<>?', [issuer::LOGINONLY], 'sortorder')); + } } /** diff --git a/lib/classes/oauth2/issuer.php b/lib/classes/oauth2/issuer.php index ce4d32f384b..c2e06c0d630 100644 --- a/lib/classes/oauth2/issuer.php +++ b/lib/classes/oauth2/issuer.php @@ -36,6 +36,13 @@ use lang_string; */ class issuer extends persistent { + /** @var int Issuer is displayed on both login page and in the services lists */ + const EVERYWHERE = 1; + /** @var int Issuer is displayed on the login page only */ + const LOGINONLY = 2; + /** @var int Issuer is displayed only in the services lists and can not be used for login */ + const SERVICEONLY = 0; + const TABLE = 'oauth2_issuer'; /** @@ -70,8 +77,8 @@ class issuer extends persistent { 'default' => true ), 'showonloginpage' => array( - 'type' => PARAM_BOOL, - 'default' => false + 'type' => PARAM_INT, + 'default' => self::SERVICEONLY, ), 'basicauth' => array( 'type' => PARAM_BOOL, @@ -115,6 +122,11 @@ class issuer extends persistent { 'null' => NULL_ALLOWED, 'default' => null, ), + 'loginpagename' => array( + 'type' => PARAM_TEXT, + 'null' => NULL_ALLOWED, + 'default' => null, + ), ); } @@ -173,9 +185,25 @@ class issuer extends persistent { * @return boolean */ public function is_authentication_supported() { + debugging('Method is_authentication_supported() is deprecated, please use is_available_for_login()', + DEBUG_DEVELOPER); return (!empty($this->get_endpoint_url('userinfo'))); } + /** + * Is this issue fully configured and enabled and can be used for login/signup + * + * @return bool + * @throws \coding_exception + */ + public function is_available_for_login() { + return $this->get('id') && + $this->is_configured() && + $this->get('showonloginpage') != issuer::SERVICEONLY && + $this->get('enabled') && + !empty($this->get_endpoint_url('userinfo')); + } + /** * Return true if this issuer looks like it has been configured. * @@ -231,4 +259,13 @@ class issuer extends persistent { } return true; } + + /** + * Display name for the issuers used on the login page + * + * @return string + */ + public function get_display_name() { + return $this->get('loginpagename') ? $this->get('loginpagename') : $this->get('name'); + } } diff --git a/lib/classes/oauth2/refresh_system_tokens_task.php b/lib/classes/oauth2/refresh_system_tokens_task.php index 1249cdf3405..00f247a20c6 100644 --- a/lib/classes/oauth2/refresh_system_tokens_task.php +++ b/lib/classes/oauth2/refresh_system_tokens_task.php @@ -84,7 +84,7 @@ class refresh_system_tokens_task extends scheduled_task { * Throw exceptions on errors (the job will be retried). */ public function execute() { - $issuers = \core\oauth2\api::get_all_issuers(); + $issuers = \core\oauth2\api::get_all_issuers(true); $tasksuccess = true; foreach ($issuers as $issuer) { if ($issuer->is_system_account_connected()) { diff --git a/lib/classes/oauth2/service/facebook.php b/lib/classes/oauth2/service/facebook.php index 92ec1f513d2..29af16e4e61 100644 --- a/lib/classes/oauth2/service/facebook.php +++ b/lib/classes/oauth2/service/facebook.php @@ -42,7 +42,7 @@ class facebook extends openidconnect implements issuer_interface { 'baseurl' => '', 'loginscopes' => 'public_profile email', 'loginscopesoffline' => 'public_profile email', - 'showonloginpage' => true, + 'showonloginpage' => issuer::EVERYWHERE, 'servicetype' => 'facebook', ]; diff --git a/lib/classes/oauth2/service/google.php b/lib/classes/oauth2/service/google.php index 77d27cc9a2b..253c6d36527 100644 --- a/lib/classes/oauth2/service/google.php +++ b/lib/classes/oauth2/service/google.php @@ -39,7 +39,7 @@ class google extends openidconnect implements issuer_interface { 'image' => 'https://accounts.google.com/favicon.ico', 'baseurl' => 'https://accounts.google.com/', 'loginparamsoffline' => 'access_type=offline&prompt=consent', - 'showonloginpage' => true, + 'showonloginpage' => issuer::EVERYWHERE, 'servicetype' => 'google', ]; $issuer = new issuer(0, $record); diff --git a/lib/classes/oauth2/service/microsoft.php b/lib/classes/oauth2/service/microsoft.php index d5d6e7ff7d2..3a891a3c1c9 100644 --- a/lib/classes/oauth2/service/microsoft.php +++ b/lib/classes/oauth2/service/microsoft.php @@ -42,7 +42,7 @@ class microsoft extends openidconnect implements issuer_interface { 'baseurl' => '', 'loginscopes' => 'openid profile email user.read', 'loginscopesoffline' => 'openid profile email user.read offline_access', - 'showonloginpage' => true, + 'showonloginpage' => issuer::EVERYWHERE, 'servicetype' => 'microsoft', ]; diff --git a/lib/db/install.xml b/lib/db/install.xml index fdeba8596f2..3d5113f6c3b 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -3824,6 +3824,7 @@ + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 188906cf131..2e0508cfc1b 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2564,5 +2564,20 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2021041300.01); } + if ($oldversion < 2021041600.01) { + + // Define field loginpagename to be added to oauth2_issuer. + $table = new xmldb_table('oauth2_issuer'); + $field = new xmldb_field('loginpagename', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'servicetype'); + + // Conditionally launch add field loginpagename. + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2021041600.01); + } + return true; } diff --git a/repository/googledocs/tests/generator/lib.php b/repository/googledocs/tests/generator/lib.php index 294fcbdf690..cc875a48575 100644 --- a/repository/googledocs/tests/generator/lib.php +++ b/repository/googledocs/tests/generator/lib.php @@ -49,7 +49,7 @@ class repository_googledocs_generator extends testing_repository_generator { 'image' => 'https://accounts.google.com/favicon.ico', 'baseurl' => 'https://accounts.google.com/', 'loginparamsoffline' => 'access_type=offline&prompt=consent', - 'showonloginpage' => true + 'showonloginpage' => issuer::EVERYWHERE ]; $issuer = new issuer(0, $issuerrecord); diff --git a/version.php b/version.php index d03ea843071..adca8434e0b 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2021041600.00; // 20201109 = branching date YYYYMMDD - do not modify! +$version = 2021041600.01; // 20201109 = branching date YYYYMMDD - do not modify! // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '3.11dev+ (Build: 20210416)';// Human-friendly version name