/** * Prints a form for configuring this authentication plugin. * * This function is called from admin/auth.php, and outputs a full page with * a form for configuring this plugin. * * TODO: as print_auth_lock_options() core function displays an old-fashion HTML table, I didn't bother writing * some proper Moodle code. This code is similar to other auth plugins (04/09/11) * * @param array $page An object containing all the data for this page. */ public function config_form($config, $err, $userfields) { global $OUTPUT, $CFG; echo '<div class="alert alert-success" role="alert">' . get_string('supportmaintenance', 'auth_googleoauth2') . '</div>'; // TODO: replace this table html ugliness by some nice bootstrap html code. echo '<table cellspacing="0" cellpadding="5" border="0"> <tr> <td colspan="3"> <h2 class="main">'; print_string('auth_googlesettings', 'auth_googleoauth2'); $providers = provider_list(); foreach ($providers as $providername) { $clientidname = $providername . 'clientid'; $clientsecretname = $providername . 'clientsecret'; // Set to defaults if undefined. if (!isset($config->{$clientidname})) { $config->{$clientidname} = ''; } if (!isset($config->{$clientsecretname})) { $config->{$clientsecretname} = ''; } // Client id. echo '</h2> </td> </tr> <tr style="vertical-align: top;"> <td align="right"><label for="' . $clientidname . '">'; print_string('auth_' . $clientidname . '_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => $clientidname, 'name' => $clientidname, 'class' => $clientidname, 'value' => $config->{$clientidname})); if (isset($err[$clientidname])) { echo $OUTPUT->error_text($err[$clientidname]); } echo '</td><td>'; $parse = parse_url($CFG->wwwroot); print_string('auth_' . $clientidname, 'auth_googleoauth2', array('jsorigins' => $parse['scheme'] . '://' . $parse['host'], 'siteurl' => $CFG->httpswwwroot, 'domain' => $CFG->httpswwwroot, 'redirecturls' => $CFG->httpswwwroot . '/auth/googleoauth2/' . $providername . '_redirect.php', 'callbackurl' => $CFG->httpswwwroot . '/auth/googleoauth2/' . $providername . '_redirect.php', 'sitedomain' => $parse['host'])); echo '</td></tr>'; // Client secret. echo '<tr style="vertical-align: top;"> <td align="right"><label for="' . $clientsecretname . '">'; print_string('auth_' . $clientsecretname . '_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => $clientsecretname, 'name' => $clientsecretname, 'class' => $clientsecretname, 'value' => $config->{$clientsecretname})); if (isset($err[$clientsecretname])) { echo $OUTPUT->error_text($err[$clientsecretname]); } echo '</td><td>'; print_string('auth_' . $clientsecretname, 'auth_googleoauth2'); echo '</td></tr> <tr style="min-height: 20px"><td> </td></tr>'; } if (!isset($config->googleipinfodbkey)) { $config->googleipinfodbkey = ''; } if (!isset($config->googleuserprefix)) { $config->googleuserprefix = 'social_user_'; } if (!isset($config->oauth2displaybuttons)) { $config->oauth2displaybuttons = 1; } // IPinfoDB. echo '<tr> <td align="right"><label for="googleipinfodbkey">'; print_string('auth_googleipinfodbkey_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleipinfodbkey', 'name' => 'googleipinfodbkey', 'class' => 'googleipinfodbkey', 'value' => $config->googleipinfodbkey)); if (isset($err["googleipinfodbkey"])) { echo $OUTPUT->error_text($err["googleipinfodbkey"]); } echo '</td><td>'; print_string('auth_googleipinfodbkey', 'auth_googleoauth2', (object) array('website' => $CFG->wwwroot)); echo '</td></tr>'; // User prefix. echo '<tr> <td align="right"><label for="googleuserprefix">'; print_string('auth_googleuserprefix_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleuserprefix', 'name' => 'googleuserprefix', 'class' => 'googleuserprefix', 'value' => $config->googleuserprefix)); if (isset($err["googleuserprefix"])) { echo $OUTPUT->error_text($err["googleuserprefix"]); } echo '</td><td>'; print_string('auth_googleuserprefix', 'auth_googleoauth2'); echo '</td></tr>'; // Display buttons. echo '<tr> <td align="right"><label for="oauth2displaybuttons">'; print_string('oauth2displaybuttons', 'auth_googleoauth2'); echo '</label></td><td>'; $checked = empty($config->oauth2displaybuttons) ? '' : 'checked'; echo html_writer::checkbox('oauth2displaybuttons', 1, $checked, '', array('type' => 'checkbox', 'id' => 'oauth2displaybuttons', 'class' => 'oauth2displaybuttons')); if (isset($err["oauth2displaybuttons"])) { echo $OUTPUT->error_text($err["oauth2displaybuttons"]); } echo '</td><td>'; $code = '<code><?php require_once($CFG->dirroot . \'/auth/googleoauth2/lib.php\'); auth_googleoauth2_display_buttons(); ?></code>'; print_string('oauth2displaybuttonshelp', 'auth_googleoauth2', $code); echo '</td></tr>'; // Block field options. // Hidden email options - email must be set to: locked. echo html_writer::empty_tag('input', array('type' => 'hidden', 'value' => 'locked', 'name' => 'lockconfig_field_lock_email')); // Display other field options. foreach ($userfields as $key => $userfield) { if ($userfield == 'email') { unset($userfields[$key]); } } print_auth_lock_options('googleoauth2', $userfields, get_string('auth_fieldlocks_help', 'auth'), false, false); echo '</table>'; // Calculate how many login per providers. $providerstats = (object) $this->get_stats(); $strothermoodle = get_string('othermoodle', 'auth_googleoauth2'); $strstattitle = get_string('stattitle', 'auth_googleoauth2', $providerstats); echo ' <center> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ [\'Provider\', \'Login total\'], [\'Google\', ' . $providerstats->google . '], [\'Facebook\', ' . $providerstats->facebook . ' ], [\'Github\', ' . $providerstats->github . ' ], [\'Linkedin\', ' . $providerstats->linkedin . ' ], [\'Microsoft\', ' . $providerstats->microsoft . ' ], [\'Dropbox\', ' . $providerstats->dropbox . ' ], [\'VK\', ' . $providerstats->vk . ' ], [\'Battle.net\', ' . $providerstats->battlenet . ' ], [\'' . $strothermoodle . '\', ' . $providerstats->moodle . ' ] ]); var options = { title: \'' . $strstattitle . '\', is3D: true, slices: { 0: { color: \'#D50F25\' }, 1: { color: \'#3b5998\' }, 2: { color: \'#eee\', fontcolor: \'black\'}, 3: { color: \'#007bb6\'}, 4: { color: \'#7cbb00\'}, 5: { color: \'#007ee5\'}, 6: { color: \'#45668e\'}, 7: { color: \'#00B4FF\'}, 8: { color: \'#ee7600\'} } }; var chart = new google.visualization.PieChart(document.getElementById(\'piechart\')); chart.draw(data, options); } </script> <div id="piechart" style="width: 900px; height: 500px;"></div> </center> '; }
/** * Prints a form for configuring this authentication plugin. * * This function is called from admin/auth.php, and outputs a full page with * a form for configuring this plugin. * * TODO: as print_auth_lock_options() core function displays an old-fashion HTML table, I didn't bother writing * some proper Moodle code. This code is similar to other auth plugins (04/09/11) * * @param array $page An object containing all the data for this page. */ function config_form($config, $err, $user_fields) { global $OUTPUT; // set to defaults if undefined if (!isset($config->googleclientid)) { $config->googleclientid = ''; } if (!isset($config->googleclientsecret)) { $config->googleclientsecret = ''; } if (!isset($config->facebookclientid)) { $config->facebookclientid = ''; } if (!isset($config->facebookclientsecret)) { $config->facebookclientsecret = ''; } if (!isset($config->messengerclientid)) { $config->messengerclientid = ''; } if (!isset($config->messengerclientsecret)) { $config->messengerclientsecret = ''; } if (!isset($config->googleipinfodbkey)) { $config->googleipinfodbkey = ''; } if (!isset($config->googleuserprefix)) { $config->googleuserprefix = 'social_user_'; } echo '<table cellspacing="0" cellpadding="5" border="0"> <tr> <td colspan="3"> <h2 class="main">'; print_string('auth_googlesettings', 'auth_googleoauth2'); // Google client id echo '</h2> </td> </tr> <tr> <td align="right"><label for="googleclientid">'; print_string('auth_googleclientid_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleclientid', 'name' => 'googleclientid', 'class' => 'googleclientid', 'value' => $config->googleclientid)); if (isset($err["googleclientid"])) { echo $OUTPUT->error_text($err["googleclientid"]); } echo '</td><td>'; print_string('auth_googleclientid', 'auth_googleoauth2'); echo '</td></tr>'; // Google client secret echo '<tr> <td align="right"><label for="googleclientsecret">'; print_string('auth_googleclientsecret_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleclientsecret', 'name' => 'googleclientsecret', 'class' => 'googleclientsecret', 'value' => $config->googleclientsecret)); if (isset($err["googleclientsecret"])) { echo $OUTPUT->error_text($err["googleclientsecret"]); } echo '</td><td>'; print_string('auth_googleclientsecret', 'auth_googleoauth2'); echo '</td></tr>'; // Facebook client id echo '<tr> <td align="right"><label for="facebookclientid">'; print_string('auth_facebookclientid_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'facebookclientid', 'name' => 'facebookclientid', 'class' => 'facebookclientid', 'value' => $config->facebookclientid)); if (isset($err["facebookclientid"])) { echo $OUTPUT->error_text($err["facebookclientid"]); } echo '</td><td>'; print_string('auth_facebookclientid', 'auth_googleoauth2'); echo '</td></tr>'; // Facebook client secret echo '<tr> <td align="right"><label for="facebookclientsecret">'; print_string('auth_facebookclientsecret_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'facebookclientsecret', 'name' => 'facebookclientsecret', 'class' => 'facebookclientsecret', 'value' => $config->facebookclientsecret)); if (isset($err["facebookclientsecret"])) { echo $OUTPUT->error_text($err["facebookclientsecret"]); } echo '</td><td>'; print_string('auth_facebookclientsecret', 'auth_googleoauth2'); echo '</td></tr>'; // Messenger client id echo '<tr> <td align="right"><label for="messengerclientid">'; print_string('auth_messengerclientid_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'messengerclientid', 'name' => 'messengerclientid', 'class' => 'messengerclientid', 'value' => $config->messengerclientid)); if (isset($err["messengerclientid"])) { echo $OUTPUT->error_text($err["messengerclientid"]); } echo '</td><td>'; print_string('auth_messengerclientid', 'auth_googleoauth2'); echo '</td></tr>'; // Messenger client secret echo '<tr> <td align="right"><label for="messengerclientsecret">'; print_string('auth_messengerclientsecret_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'messengerclientsecret', 'name' => 'messengerclientsecret', 'class' => 'messengerclientsecret', 'value' => $config->messengerclientsecret)); if (isset($err["messengerclientsecret"])) { echo $OUTPUT->error_text($err["messengerclientsecret"]); } echo '</td><td>'; print_string('auth_messengerclientsecret', 'auth_googleoauth2'); echo '</td></tr>'; // IPinfoDB echo '<tr> <td align="right"><label for="googleipinfodbkey">'; print_string('auth_googleipinfodbkey_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleipinfodbkey', 'name' => 'googleipinfodbkey', 'class' => 'googleipinfodbkey', 'value' => $config->googleipinfodbkey)); if (isset($err["googleipinfodbkey"])) { echo $OUTPUT->error_text($err["googleipinfodbkey"]); } echo '</td><td>'; print_string('auth_googleipinfodbkey', 'auth_googleoauth2'); echo '</td></tr>'; // User prefix echo '<tr> <td align="right"><label for="googleuserprefix">'; print_string('auth_googleuserprefix_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleuserprefix', 'name' => 'googleuserprefix', 'class' => 'googleuserprefix', 'value' => $config->googleuserprefix)); if (isset($err["googleuserprefix"])) { echo $OUTPUT->error_text($err["googleuserprefix"]); } echo '</td><td>'; print_string('auth_googleuserprefix', 'auth_googleoauth2'); echo '</td></tr>'; /// Block field options // Hidden email options - email must be set to: locked echo html_writer::empty_tag('input', array('type' => 'hidden', 'value' => 'locked', 'name' => 'lockconfig_field_lock_email')); //display other field options foreach ($user_fields as $key => $user_field) { if ($user_field == 'email') { unset($user_fields[$key]); } } print_auth_lock_options('googleoauth2', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); echo '</table>'; }
href="#rolemapping">Role Mapping</a></li> <li id="externalmapping_li" <?php if ($config->supportcourses != 'external') { echo 'style="display:none;"'; } ?> ><a <?php echo $config->supportcourses == 'external' && isset($err['samlexternal']) ? 'style="color:red;"' : ''; ?> href="#externalmapping">External Mapping Info</a></li> </ul> <div id="datamapping"> <table class="center"> <?php print_auth_lock_options('saml', $user_fields, '<!-- empty help -->', true, false); ?> </table> </div> <div id="coursemapping"> <?php if (isset($err['course_mapping_db']) && in_array("error_creating_course_mapping", $err['course_mapping_db'])) { echo '<span class="error">'; print_string("auth_saml_error_creating_course_mapping", "auth_saml"); echo '</span>'; } else { echo '<table id="newcourses" class="center">'; print_course_mapping_options($course_mapping, $config, $err); echo '
/** * Prints a form for configuring this authentication plugin. * * This function is called from admin/auth.php, and outputs a full page with * a form for configuring this plugin. * * TODO: as print_auth_lock_options() core function displays an old-fashion HTML table, I didn't bother writing * some proper Moodle code. This code is similar to other auth plugins (04/09/11) * * @param array $page An object containing all the data for this page. */ public function config_form($config, $err, $userfields) { global $OUTPUT, $CFG; echo '<table cellspacing="0" cellpadding="5" border="0"> <tr> <td colspan="3"> <h2 class="main">'; print_string('auth_googlesettings', 'auth_googleoauth2'); $providers = provider_list(); foreach ($providers as $providername) { $clientidname = $providername . 'clientid'; $clientsecretname = $providername . 'clientsecret'; // Set to defaults if undefined. if (!isset($config->{$clientidname})) { $config->{$clientidname} = ''; } if (!isset($config->{$clientsecretname})) { $config->{$clientsecretname} = ''; } // Client id. echo '</h2> </td> </tr> <tr> <td align="right"><label for="' . $clientidname . '">'; print_string('auth_' . $clientidname . '_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => $clientidname, 'name' => $clientidname, 'class' => $clientidname, 'value' => $config->{$clientidname})); if (isset($err[$clientidname])) { echo $OUTPUT->error_text($err[$clientidname]); } echo '</td><td>'; $parse = parse_url($CFG->wwwroot); print_string('auth_' . $clientidname, 'auth_googleoauth2', array('jsorigins' => $parse['scheme'] . '://' . $parse['host'], 'siteurl' => $CFG->httpswwwroot, 'domain' => $CFG->httpswwwroot, 'redirecturls' => $CFG->httpswwwroot . '/auth/googleoauth2/' . $providername . '_redirect.php', 'callbackurl' => $CFG->httpswwwroot . '/auth/googleoauth2/' . $providername . '_redirect.php', 'sitedomain' => $parse['host'])); echo '</td></tr>'; // Client secret. echo '<tr> <td align="right"><label for="' . $clientsecretname . '">'; print_string('auth_' . $clientsecretname . '_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => $clientsecretname, 'name' => $clientsecretname, 'class' => $clientsecretname, 'value' => $config->{$clientsecretname})); if (isset($err[$clientsecretname])) { echo $OUTPUT->error_text($err[$clientsecretname]); } echo '</td><td>'; print_string('auth_' . $clientsecretname, 'auth_googleoauth2'); echo '</td></tr>'; } if (!isset($config->googleipinfodbkey)) { $config->googleipinfodbkey = ''; } if (!isset($config->googleuserprefix)) { $config->googleuserprefix = 'social_user_'; } if (!isset($config->oauth2displaybuttons)) { $config->oauth2displaybuttons = 1; } // IPinfoDB. echo '<tr> <td align="right"><label for="googleipinfodbkey">'; print_string('auth_googleipinfodbkey_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleipinfodbkey', 'name' => 'googleipinfodbkey', 'class' => 'googleipinfodbkey', 'value' => $config->googleipinfodbkey)); if (isset($err["googleipinfodbkey"])) { echo $OUTPUT->error_text($err["googleipinfodbkey"]); } echo '</td><td>'; print_string('auth_googleipinfodbkey', 'auth_googleoauth2', (object) array('website' => $CFG->wwwroot)); echo '</td></tr>'; // User prefix. echo '<tr> <td align="right"><label for="googleuserprefix">'; print_string('auth_googleuserprefix_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleuserprefix', 'name' => 'googleuserprefix', 'class' => 'googleuserprefix', 'value' => $config->googleuserprefix)); if (isset($err["googleuserprefix"])) { echo $OUTPUT->error_text($err["googleuserprefix"]); } echo '</td><td>'; print_string('auth_googleuserprefix', 'auth_googleoauth2'); echo '</td></tr>'; // Display buttons. echo '<tr> <td align="right"><label for="oauth2displaybuttons">'; print_string('oauth2displaybuttons', 'auth_googleoauth2'); echo '</label></td><td>'; $checked = empty($config->oauth2displaybuttons) ? '' : 'checked'; echo html_writer::checkbox('oauth2displaybuttons', 1, $checked, '', array('type' => 'checkbox', 'id' => 'oauth2displaybuttons', 'class' => 'oauth2displaybuttons')); if (isset($err["oauth2displaybuttons"])) { echo $OUTPUT->error_text($err["oauth2displaybuttons"]); } echo '</td><td>'; $code = '<code><?php require_once($CFG->dirroot . \'/auth/googleoauth2/lib.php\'); auth_googleoauth2_display_buttons(); ?></code>'; print_string('oauth2displaybuttonshelp', 'auth_googleoauth2', $code); echo '</td></tr>'; // Block field options. // Hidden email options - email must be set to: locked. echo html_writer::empty_tag('input', array('type' => 'hidden', 'value' => 'locked', 'name' => 'lockconfig_field_lock_email')); // Display other field options. foreach ($userfields as $key => $userfield) { if ($userfield == 'email') { unset($userfields[$key]); } } print_auth_lock_options('googleoauth2', $userfields, get_string('auth_fieldlocks_help', 'auth'), false, false); echo '</table>'; }
/** * @link http://docs.moodle.org/dev/Authentication_plugins#config_form.28.24config.2C_.24err.2C_.24user_fields.29 * Prints a form for configuring this authentication plugin. * It's called from admin/auth.php, and outputs a full page with a form for configuring this plugin. * * @param object $config An object of Moodle global config. * @param array $err An array of current form errors * @return void. Just output form template * * @author Igor Sazonov */ function config_form($config, $err, $user_fields) { // set to defaults if undefined if (!isset($config->auth_lenauth_user_prefix)) { $config->auth_lenauth_user_prefix = 'lenauth_user_'; } if (!isset($config->auth_lenauth_default_country)) { $config->auth_lenauth_default_country = ''; } if (!isset($config->auth_lenauth_locale)) { $config->auth_lenauth_locale = 'en'; } /*if ( empty( $config->can_change_password ) ) { $config->can_change_password = 0; } else { $config->can_change_password = 1; }*/ if (empty($config->auth_lenauth_can_reset_password)) { $config->auth_lenauth_can_reset_password = 0; } else { $config->auth_lenauth_can_reset_password = 1; } if (empty($config->auth_lenauth_can_confirm)) { $config->auth_lenauth_can_confirm = 0; } else { $config->auth_lenauth_can_confirm = 1; } if (empty($config->auth_lenauth_retrieve_avatar)) { $config->auth_lenauth_retrieve_avatar = 0; } else { $config->auth_lenauth_retrieve_avatar = 1; } if (!isset($config->auth_lenauth_display_buttons)) { $config->auth_lenauth_display_buttons = 'inline-block'; } if (!isset($config->auth_lenauth_button_width)) { $config->auth_lenauth_button_width = 0; } if (!isset($config->auth_lenauth_button_margin_top)) { $config->auth_lenauth_button_margin_top = 10; } if (!isset($config->auth_lenauth_button_margin_right)) { $config->auth_lenauth_button_margin_right = 10; } if (!isset($config->auth_lenauth_button_margin_bottom)) { $config->auth_lenauth_button_margin_bottom = 10; } if (!isset($config->auth_lenauth_button_margin_left)) { $config->auth_lenauth_button_margin_left = 10; } if (!isset($config->auth_lenauth_display_div)) { $config->auth_lenauth_display_div = 'block'; } if (!isset($config->auth_lenauth_div_width)) { $config->auth_lenauth_div_width = 0; } if (!isset($config->auth_lenauth_div_margin_top)) { $config->auth_lenauth_div_margin_top = 0; } if (!isset($config->auth_lenauth_div_margin_right)) { $config->auth_lenauth_div_margin_right = 0; } if (!isset($config->auth_lenauth_div_margin_bottom)) { $config->auth_lenauth_div_margin_bottom = 0; } if (!isset($config->auth_lenauth_div_margin_left)) { $config->auth_lenauth_div_margin_left = 0; } if (!isset($config->auth_lenauth_order)) { $order_array = $this->_default_order; } else { $order_array = json_decode($config->auth_lenauth_order, true); } if (!isset($config->auth_lenauth_facebook_enabled)) { $config->auth_lenauth_facebook_enabled = 0; } if (!isset($config->auth_lenauth_facebook_app_id)) { $config->auth_lenauth_facebook_app_id = ''; } if (!isset($config->auth_lenauth_facebook_app_secret)) { $config->auth_lenauth_facebook_app_secret = ''; } if (!isset($config->auth_lenauth_facebook_button_text)) { $config->auth_lenauth_facebook_button_text = get_string('auth_lenauth_facebook_button_text_default', 'auth_lenauth'); } if (!isset($config->auth_lenauth_google_enabled)) { $config->auth_lenauth_google_enabled = 0; } if (!isset($config->auth_lenauth_google_client_id)) { $config->auth_lenauth_google_client_id = ''; } if (!isset($config->auth_lenauth_google_client_secret)) { $config->auth_lenauth_google_client_secret = ''; } if (!isset($config->auth_lenauth_google_project_id)) { $config->auth_lenauth_google_project_id = ''; } if (!isset($config->auth_lenauth_google_button_text)) { $config->auth_lenauth_google_button_text = get_string('auth_lenauth_google_button_text_default', 'auth_lenauth'); } if (!isset($config->auth_lenauth_yahoo_enabled)) { $config->auth_lenauth_yahoo_enabled = 0; } if (!isset($config->auth_lenauth_yahoo_oauth_version)) { $config->auth_lenauth_yahoo_oauth_version = 1; } if (!isset($config->auth_lenauth_yahoo_application_id)) { $config->auth_lenauth_yahoo_application_id = ''; } if (!isset($config->auth_lenauth_yahoo_consumer_key)) { $config->auth_lenauth_yahoo_consumer_key = ''; } if (!isset($config->auth_lenauth_yahoo_consumer_secret)) { $config->auth_lenauth_yahoo_consumer_secret = ''; } if (!isset($config->auth_lenauth_yahoo_button_text)) { $config->auth_lenauth_yahoo_button_text = get_string('auth_lenauth_yahoo_button_text_default', 'auth_lenauth'); } if (!isset($config->auth_lenauth_twitter_enabled)) { $config->auth_lenauth_twitter_enabled = 0; } if (!isset($config->auth_lenauth_twitter_consumer_key)) { $config->auth_lenauth_twitter_consumer_key = ''; } if (!isset($config->auth_lenauth_twitter_consumer_secret)) { $config->auth_lenauth_twitter_consumer_secret = ''; } if (!isset($config->auth_lenauth_twitter_application_id)) { $config->auth_lenauth_twitter_application_id = ''; } if (!isset($config->auth_lenauth_vk_enabled)) { $config->auth_lenauth_vk_enabled = 0; } if (!isset($config->auth_lenauth_vk_app_id)) { $config->auth_lenauth_vk_app_id = ''; } if (!isset($config->auth_lenauth_vk_app_secret)) { $config->auth_lenauth_vk_app_secret = ''; } if (!isset($config->auth_lenauth_vk_button_text)) { $config->auth_lenauth_vk_button_text = get_string('auth_lenauth_vk_button_text_default', 'auth_lenauth'); } if (!isset($config->auth_lenauth_yandex_enabled)) { $config->auth_lenauth_yandex_enabled = 0; } if (!isset($config->auth_lenauth_yandex_app_id)) { $config->auth_lenauth_yandex_app_id = ''; } if (!isset($config->auth_lenauth_yandex_app_password)) { $config->auth_lenauth_yandex_app_password = ''; } if (!isset($config->auth_lenauth_yandex_button_text)) { $config->auth_lenauth_yandex_button_text = get_string('auth_lenauth_yandex_button_text_default', 'auth_lenauth'); } if (!isset($config->auth_lenauth_mailru_enabled)) { $config->auth_lenauth_mailru_enabled = 0; } if (!isset($config->auth_lenauth_mailru_site_id)) { $config->auth_lenauth_mailru_site_id = ''; } if (!isset($config->auth_lenauth_mailru_client_private)) { $config->auth_lenauth_mailru_client_private = ''; } if (!isset($config->auth_lenauth_mailru_client_secret)) { $config->auth_lenauth_mailru_client_secret = ''; } if (!isset($config->auth_lenauth_mailru_button_text)) { $config->auth_lenauth_mailru_button_text = get_string('auth_lenauth_mailru_button_text_default', 'auth_lenauth'); } /*if ( !isset( $config->ok_enabled ) ) { $config->ok_enabled = 0; } if ( !isset( $config->ok_app_id ) ) { $config->ok_app_id = ''; } if ( !isset( $config->ok_public_key ) ) { $config->ok_public_key = ''; } if ( !isset( $config->ok_secret_key ) ) { $config->ok_secret_key = ''; } if ( !isset( $config->ok_button_text ) ) { $config->ok_button_text = get_string( 'auth_ok_button_text_default', 'auth_lenauth' ); } if ( !isset( $config->ok_social_id_field ) ) { $config->ok_social_id_field = ''; }*/ include 'view_admin_config.php'; print_auth_lock_options('lenauth', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); }
</div> <div class="form-item clearfix"> <div class="form-label"> <label for="profileurl"><?php print_string('auth_apilogin_label_profileurl', 'auth_apilogin'); ?> </label> </div> <div class="form-setting"> <div class="form-text"> <input name="profileurl" id="profileurl" type="text" value="<?php echo $config->profileurl; ?> " maxlength="256" style="width:96%" /> <?php echo isset($err['profileurl']) ? $OUTPUT->error_text($err['profileurl']) : ''; ?> </div> </div> <div class="form-description"><?php print_string('auth_apilogin_info_profileurl', 'auth_apilogin'); ?> </div> </div> </fieldset> <table cellspacing="0" cellpadding="5" border="0"> <?php print_auth_lock_options($this->authtype, $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); ?> </table>
/** * Prints a form for configuring this authentication plugin. * * This function is called from admin/auth.php, and outputs a full page with * a form for configuring this plugin. * * @param array $page An object containing all the data for this page. */ function config_form($config, $err, $user_fields) { global $OUTPUT, $CFG; // Set to defaults if undefined. if (!isset($config->consumer_key)) { $config->consumer_key = ''; } if (!isset($config->consumer_secret)) { $config->consumer_secret = ''; } if (!isset($config->baseurl)) { $config->baseurl = ''; } if (!isset($config->apiurl)) { $config->apiurl = ''; } if (!isset($config->apifunc)) { $config->apifunc = ''; } if (!isset($config->username)) { $config->username = ''; } echo '<table cellspacing="0" cellpadding="5" border="0"><tr><td colspan="3"><h2 class="main">'; print_string('auth_oauth_simplesettings', 'auth_oauth_simple'); echo '</h2></td></tr>'; // Consumer key. echo '<tr><td align="right"><label for="consumer_key">'; print_string('auth_consumer_key', 'auth_oauth_simple'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'consumer_key', 'name' => 'consumer_key', 'class' => 'consumer_key', 'value' => $config->consumer_key)); if (isset($err["consumer_key"])) { echo $OUTPUT->error_text($err["consumer_key"]); } echo '</td><td>'; print_string('auth_consumer_key_desc', 'auth_oauth_simple'); echo '</td></tr>'; // Consumer_secret. echo '<tr><td align="right"><label for="consumer_secret">'; print_string('auth_consumer_secret', 'auth_oauth_simple'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'consumer_secret', 'name' => 'consumer_secret', 'class' => 'consumer_secret', 'value' => $config->consumer_secret)); if (isset($err["consumer_secret"])) { echo $OUTPUT->error_text($err["consumer_secret"]); } echo '</td><td>'; print_string('auth_consumer_secret_desc', 'auth_oauth_simple'); echo '</td></tr>'; // URL base. echo '<tr><td align="right"><label for="baseurl">'; print_string('auth_baseurl', 'auth_oauth_simple'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'baseurl', 'name' => 'baseurl', 'class' => 'baseurl', 'value' => $config->baseurl)); if (isset($err["baseurl"])) { echo $OUTPUT->error_text($err["baseurl"]); } echo '</td><td>'; print_string('auth_baseurl_desc', 'auth_oauth_simple'); echo '</td></tr>'; // URL Api. echo '<tr><td align="right"><label for="apiurl">'; print_string('auth_apiurl', 'auth_oauth_simple'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'apiurl', 'name' => 'apiurl', 'class' => 'apiurl', 'value' => $config->apiurl)); if (isset($err["apiurl"])) { echo $OUTPUT->error_text($err["apiurl"]); } echo '</td><td>'; print_string('auth_apiurl_desc', 'auth_oauth_simple'); echo '</td></tr>'; // Func Api. echo '<tr><td align="right"><label for="apifunc">'; print_string('auth_apifunc', 'auth_oauth_simple'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'apifunc', 'name' => 'apifunc', 'class' => 'apifunc', 'value' => $config->apifunc)); if (isset($err["apifunc"])) { echo $OUTPUT->error_text($err["apifunc"]); } echo '</td><td>'; print_string('auth_apifunc_desc', 'auth_oauth_simple'); echo '</td></tr>'; // Username. echo '<tr><td align="right"><label for="username">'; print_string('username'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'username', 'name' => 'username', 'class' => 'username', 'value' => $config->username)); if (isset($err["username"])) { echo $OUTPUT->error_text($err["username"]); } echo '</td><td> </td></tr>'; /* // Block field options. // Hidden email options - email must be set to: locked. echo html_writer::empty_tag('input', array('type' => 'hidden', 'value' => 'locked', 'name' => 'lockconfig_field_lock_email')); // Display other field options. foreach ($user_fields as $key => $user_field) { if ($user_field == 'email') { unset($user_fields[$key]); } } */ print_auth_lock_options('oauth_simple', $user_fields, get_string('auth_fieldlocks_help', 'auth_oauth_simple'), true, false, $this->get_custom_user_profile_fields()); echo '</table>'; }
/** * Prints a form for configuring this authentication plugin. * * This function is called from admin/auth.php, and outputs a full page with * a form for configuring this plugin. * * TODO: as print_auth_lock_options() core function displays an old-fashion HTML table, I didn't bother writing * some proper Moodle code. This code is similar to other auth plugins (04/09/11) * * @param array $page An object containing all the data for this page. */ function config_form($config, $err, $user_fields) { global $OUTPUT, $CFG; // set to defaults if undefined if (!isset($config->googleclientid)) { $config->googleclientid = ''; } if (!isset($config->googleclientsecret)) { $config->googleclientsecret = ''; } if (!isset($config->facebookclientid)) { $config->facebookclientid = ''; } if (!isset($config->facebookclientsecret)) { $config->facebookclientsecret = ''; } if (!isset($config->messengerclientid)) { $config->messengerclientid = ''; } if (!isset($config->messengerclientsecret)) { $config->messengerclientsecret = ''; } if (!isset($config->githubclientid)) { $config->githubclientid = ''; } if (!isset($config->githubclientsecret)) { $config->githubclientsecret = ''; } if (!isset($config->linkedinclientid)) { $config->linkedinclientid = ''; } if (!isset($config->linkedinclientsecret)) { $config->linkedinclientsecret = ''; } if (!isset($config->googleipinfodbkey)) { $config->googleipinfodbkey = ''; } if (!isset($config->googleuserprefix)) { $config->googleuserprefix = 'social_user_'; } echo '<table cellspacing="0" cellpadding="5" border="0"> <tr> <td colspan="3"> <h2 class="main">'; print_string('auth_googlesettings', 'auth_googleoauth2'); // Google client id echo '</h2> </td> </tr> <tr> <td align="right"><label for="googleclientid">'; print_string('auth_googleclientid_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleclientid', 'name' => 'googleclientid', 'class' => 'googleclientid', 'value' => $config->googleclientid)); if (isset($err["googleclientid"])) { echo $OUTPUT->error_text($err["googleclientid"]); } echo '</td><td>'; $parse = parse_url($CFG->wwwroot); print_string('auth_googleclientid', 'auth_googleoauth2', array('jsorigins' => $parse['scheme'] . '://' . $parse['host'], 'redirecturls' => $CFG->wwwroot . '/auth/googleoauth2/google_redirect.php')); echo '</td></tr>'; // Google client secret echo '<tr> <td align="right"><label for="googleclientsecret">'; print_string('auth_googleclientsecret_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleclientsecret', 'name' => 'googleclientsecret', 'class' => 'googleclientsecret', 'value' => $config->googleclientsecret)); if (isset($err["googleclientsecret"])) { echo $OUTPUT->error_text($err["googleclientsecret"]); } echo '</td><td>'; print_string('auth_googleclientsecret', 'auth_googleoauth2'); echo '</td></tr>'; // Facebook client id echo '<tr> <td align="right"><label for="facebookclientid">'; print_string('auth_facebookclientid_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'facebookclientid', 'name' => 'facebookclientid', 'class' => 'facebookclientid', 'value' => $config->facebookclientid)); if (isset($err["facebookclientid"])) { echo $OUTPUT->error_text($err["facebookclientid"]); } echo '</td><td>'; print_string('auth_facebookclientid', 'auth_googleoauth2', (object) array('siteurl' => $CFG->wwwroot . '/auth/googleoauth2/facebook_redirect.php', 'sitedomain' => $parse['host'])); echo '</td></tr>'; // Facebook client secret echo '<tr> <td align="right"><label for="facebookclientsecret">'; print_string('auth_facebookclientsecret_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'facebookclientsecret', 'name' => 'facebookclientsecret', 'class' => 'facebookclientsecret', 'value' => $config->facebookclientsecret)); if (isset($err["facebookclientsecret"])) { echo $OUTPUT->error_text($err["facebookclientsecret"]); } echo '</td><td>'; print_string('auth_facebookclientsecret', 'auth_googleoauth2'); echo '</td></tr>'; // Messenger client id echo '<tr> <td align="right"><label for="messengerclientid">'; print_string('auth_messengerclientid_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'messengerclientid', 'name' => 'messengerclientid', 'class' => 'messengerclientid', 'value' => $config->messengerclientid)); if (isset($err["messengerclientid"])) { echo $OUTPUT->error_text($err["messengerclientid"]); } echo '</td><td>'; print_string('auth_messengerclientid', 'auth_googleoauth2', (object) array('domain' => $CFG->wwwroot)); echo '</td></tr>'; // Messenger client secret echo '<tr> <td align="right"><label for="messengerclientsecret">'; print_string('auth_messengerclientsecret_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'messengerclientsecret', 'name' => 'messengerclientsecret', 'class' => 'messengerclientsecret', 'value' => $config->messengerclientsecret)); if (isset($err["messengerclientsecret"])) { echo $OUTPUT->error_text($err["messengerclientsecret"]); } echo '</td><td>'; print_string('auth_messengerclientsecret', 'auth_googleoauth2'); echo '</td></tr>'; // Github client id echo '<tr> <td align="right"><label for="githubclientid">'; print_string('auth_githubclientid_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'githubclientid', 'name' => 'githubclientid', 'class' => 'githubclientid', 'value' => $config->githubclientid)); if (isset($err["githubclientid"])) { echo $OUTPUT->error_text($err["githubclientid"]); } echo '</td><td>'; print_string('auth_githubclientid', 'auth_googleoauth2', (object) array('callbackurl' => $CFG->wwwroot . '/auth/googleoauth2/github_redirect.php', 'siteurl' => $CFG->wwwroot)); echo '</td></tr>'; // Github client secret echo '<tr> <td align="right"><label for="githubclientsecret">'; print_string('auth_githubclientsecret_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'githubclientsecret', 'name' => 'githubclientsecret', 'class' => 'githubclientsecret', 'value' => $config->githubclientsecret)); if (isset($err["githubclientsecret"])) { echo $OUTPUT->error_text($err["githubclientsecret"]); } echo '</td><td>'; print_string('auth_githubclientsecret', 'auth_googleoauth2'); echo '</td></tr>'; // Linkedin client id echo '<tr> <td align="right"><label for="linkedinclientid">'; print_string('auth_linkedinclientid_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'linkedinclientid', 'name' => 'linkedinclientid', 'class' => 'linkedinclientid', 'value' => $config->linkedinclientid)); if (isset($err["linkedinclientid"])) { echo $OUTPUT->error_text($err["linkedinclientid"]); } echo '</td><td>'; print_string('auth_linkedinclientid', 'auth_googleoauth2', (object) array('callbackurl' => $CFG->wwwroot . '/auth/googleoauth2/linkedin_redirect.php', 'siteurl' => $CFG->wwwroot)); echo '</td></tr>'; // Linkedin client secret echo '<tr> <td align="right"><label for="linkedinclientsecret">'; print_string('auth_linkedinclientsecret_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'linkedinclientsecret', 'name' => 'linkedinclientsecret', 'class' => 'linkedinclientsecret', 'value' => $config->linkedinclientsecret)); if (isset($err["linkedinclientsecret"])) { echo $OUTPUT->error_text($err["linkedinclientsecret"]); } echo '</td><td>'; print_string('auth_linkedinclientsecret', 'auth_googleoauth2'); echo '</td></tr>'; // IPinfoDB echo '<tr> <td align="right"><label for="googleipinfodbkey">'; print_string('auth_googleipinfodbkey_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleipinfodbkey', 'name' => 'googleipinfodbkey', 'class' => 'googleipinfodbkey', 'value' => $config->googleipinfodbkey)); if (isset($err["googleipinfodbkey"])) { echo $OUTPUT->error_text($err["googleipinfodbkey"]); } echo '</td><td>'; print_string('auth_googleipinfodbkey', 'auth_googleoauth2', (object) array('website' => $CFG->wwwroot)); echo '</td></tr>'; // User prefix echo '<tr> <td align="right"><label for="googleuserprefix">'; print_string('auth_googleuserprefix_key', 'auth_googleoauth2'); echo '</label></td><td>'; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleuserprefix', 'name' => 'googleuserprefix', 'class' => 'googleuserprefix', 'value' => $config->googleuserprefix)); if (isset($err["googleuserprefix"])) { echo $OUTPUT->error_text($err["googleuserprefix"]); } echo '</td><td>'; print_string('auth_googleuserprefix', 'auth_googleoauth2'); echo '</td></tr>'; /// Block field options // Hidden email options - email must be set to: locked echo html_writer::empty_tag('input', array('type' => 'hidden', 'value' => 'locked', 'name' => 'lockconfig_field_lock_email')); //display other field options foreach ($user_fields as $key => $user_field) { if ($user_field == 'email') { unset($user_fields[$key]); } } print_auth_lock_options('googleoauth2', $user_fields, get_string('auth_fieldlocks_help', 'auth'), false, false); echo '</table>'; }