. /** * Admin settings for googleoauth2 auth plugin. * * @package auth_googleoauth2 * @copyright 2015 Jerome Mouneyrac * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once("lib.php"); require_once("locallib.php"); // This is needed for getting my website url global $CFG,$OUTPUT; // SETUP DEFAULTS FOR SETTINGS if (!isset($config->googleipinfodbkey)) { $config->googleipinfodbkey = ''; } if (!isset($config->userprefix)) { $config->userprefix = 'social_user_'; } if (!isset($config->displaybuttons)) { $config->displaybuttons = 1; } if (!isset($config->saveaccesstoken)) { $config->saveaccesstoken = 0; } if (!isset ($config->authdomains)) { $config->authdomains = ''; } if (!isset ($config->donotcreatenewuser)) { $config->donotcreatenewuser = 0; } if (!isset ($config->providerlinksstyle)) { $config->providerlinksstyle = 'horizontal'; } echo '
'; print_string('auth_googlesettings', 'auth_googleoauth2'); // LIST PROVIDERS CONFIG OPTIONS $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 ' |
||
' . get_string($providername, "auth_googleoauth2") . ' |
||
| '; 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 ' | '; $parse = parse_url($CFG->wwwroot); if ( $CFG->loginhttps ) { // If loginhttps is enabled, the redirect are https:// based $parse['securescheme'] = "https"; } else { $parse['securescheme'] = $parse['scheme']; } if ( isset ($parse['path']) ) { // If a path exists, then add the delimiter $parse['path'] = '/' . $parse['path']; } else { $parse['path'] = ''; } print_string('auth_' . $clientidname, 'auth_googleoauth2', array( 'jsorigins' => $parse['scheme'] . '://' . $parse['host'], 'siteurl' => $CFG->wwwroot, 'domain' => $CFG->wwwroot, 'redirecturls' => $parse['securescheme'] . '://' . $parse['host'] . $parse['path'] . '/auth/googleoauth2/' . $providername . '_redirect.php', 'callbackurl' => $parse['securescheme'] . '://' . $parse['host'] . $parse['path'] . '/auth/googleoauth2/' . $providername . '_redirect.php', 'sitedomain' => $parse['host'] )); echo ' | |
| '; 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 ' | '; print_string('auth_' . $clientsecretname, 'auth_googleoauth2'); echo ' | |
' . get_string("othersettings", "auth_googleoauth2") . ' |
||
| '; 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 ' | '; print_string('auth_googleipinfodbkey', 'auth_googleoauth2', (object) array( 'website' => $CFG->wwwroot )); echo ' | |
| '; echo html_writer::empty_tag('input', array( 'type' => 'text', 'id' => 'userprefix', 'name' => 'userprefix', 'class' => 'userprefix', 'value' => $config->userprefix )); if (isset($err["userprefix"])) { echo $OUTPUT->error_text($err["userprefix"]); } echo ' | '; print_string('auth_userprefixdesc', 'auth_googleoauth2'); echo ' | |
| '; $checked = empty($config->displaybuttons) ? '' : 'checked'; echo html_writer::checkbox('displaybuttons', 1, $checked, '', array( 'type' => 'checkbox', 'id' => 'displaybuttons', 'class' => 'displaybuttons' )); if (isset($err["displaybuttons"])) { echo $OUTPUT->error_text($err["displaybuttons"]); } echo ' | ';
$code = '<?php require_once($CFG->dirroot . \'/auth/googleoauth2/lib.php\');
auth_googleoauth2_display_buttons(); ?>';
print_string('displaybuttonshelp', 'auth_googleoauth2', $code);
echo ' | |
| '; $providerlinksstyleoptions = array( 'vertical' => get_string('vertical', 'auth_googleoauth2'), 'horizontal' => get_string('horizontal', 'auth_googleoauth2')); echo html_writer::select($providerlinksstyleoptions, 'providerlinksstyle',$config->providerlinksstyle, "" ); if (isset($err["providerlinksstyle"])) { echo $OUTPUT->error_text($err["providerlinksstyle"]); } echo ' | '; print_string('providerlinksstylehelp', 'auth_googleoauth2'); echo ' | |
| '; $checked = empty($config->saveaccesstoken) ? '' : 'checked'; echo html_writer::checkbox('saveaccesstoken', 1, $checked, '', array( 'type' => 'checkbox', 'id' => 'saveaccesstoken', 'class' => 'saveaccesstoken' )); if (isset($err["saveaccesstoken"])) { echo $OUTPUT->error_text($err["saveaccesstoken"]); } echo ' | '; print_string('saveaccesstokenhelp', 'auth_googleoauth2'); echo ' | |
| '; $checked = empty($config->donotcreatenewuser)?'':'checked'; echo html_writer::checkbox('donotcreatenewuser', 1, $checked, '', array( 'type' => 'checkbox', 'id' => 'donotcreatenewuser', 'class' => 'donotcreatenewuser')); if (isset($err["donotcreatenewuser"])) { echo $OUTPUT->error_text($err["donotcreatenewuser"]); } echo ' | '; print_string('donotcreatenewuserhelp', 'auth_googleoauth2'); echo ' | |
| '; echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'authdomains', 'name' => 'authdomains', 'class' => 'authdomains', 'value' => $config->authdomains)); if (isset($err["authdomains"])) { echo $OUTPUT->error_text($err["authdomains"]); } echo ' | '; print_string('authdomainshelp', 'auth_googleoauth2') ; echo ' | |
' . get_string("stattitle", "auth_googleoauth2") . ' |
||
| '; echo $OUTPUT->box_start(); // Calculate how many login per providers. $providerstats = googleoauth2_get_stats(); $strothermoodle = get_string('othermoodle', 'auth_googleoauth2'); $strstattitle = get_string('stattitlecaption', 'auth_googleoauth2', $providerstats); echo ' '; echo $OUTPUT->box_end(); echo ' | ||