Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- wpDirAuth.php.orig 2014-06-03 10:11:25.000000000 +0100
- +++ wpDirAuth.php 2014-06-03 09:52:07.000000000 +0100
- @@ -137,7 +137,7 @@
- */
- //first we need to make sure we have access to the function
- if(! function_exists('is_plugin_active_for_network')){
- - require_once( ABSPATH . '/wp-admind/includes/plugin.php');
- + require_once( ABSPATH . '/wp-admin/includes/plugin.php');
- }
- /**
- @@ -258,7 +258,7 @@
- .$_SERVER['HTTP_USER_AGENT']
- .$_SERVER['REMOTE_ADDR']
- ).uniqid(microtime(),true);
- - update_site_option("dirAuthCookieMarker",$cookieMarker);
- + wpDirAuth_update_site_option("dirAuthCookieMarker",$cookieMarker);
- return $cookieMarker;
- }
- @@ -379,17 +379,17 @@
- $errorTitle = WPDIRAUTH_ERROR_TITLE;
- - $controllers = explode(',', get_site_option('dirAuthControllers'));
- - $baseDn = get_site_option('dirAuthBaseDn');
- - $preBindUser = get_site_option('dirAuthPreBindUser');
- - $preBindPassword = get_site_option('dirAuthPreBindPassword');
- - $accountSuffix = get_site_option('dirAuthAccountSuffix');
- - $filter = get_site_option('dirAuthFilter');
- - $enableSsl = get_site_option('dirAuthEnableSsl');
- - $boolUseGroups = get_site_option('dirAuthUseGroups');
- + $controllers = explode(',', wpDirAuth_get_site_option('dirAuthControllers'));
- + $baseDn = wpDirAuth_get_site_option('dirAuthBaseDn');
- + $preBindUser = wpDirAuth_get_site_option('dirAuthPreBindUser');
- + $preBindPassword = wpDirAuth_get_site_option('dirAuthPreBindPassword');
- + $accountSuffix = wpDirAuth_get_site_option('dirAuthAccountSuffix');
- + $filter = wpDirAuth_get_site_option('dirAuthFilter');
- + $enableSsl = wpDirAuth_get_site_option('dirAuthEnableSsl');
- + $boolUseGroups = wpDirAuth_get_site_option('dirAuthUseGroups');
- if($boolUseGroups == 1){
- - $strAuthGroups = get_site_option('dirAuthGroups');
- + $strAuthGroups = wpDirAuth_get_site_option('dirAuthGroups');
- }
- $returnKeys = unserialize(WPDIRAUTH_LDAP_RETURN_KEYS);
- @@ -633,32 +633,32 @@
- $loginScreenMsg = wpDirAuth_sanitize($_POST['dirAuthLoginScreenMsg'], true);
- $changePassMsg = wpDirAuth_sanitize($_POST['dirAuthChangePassMsg'], true);
- - update_site_option('dirAuthEnable', $enable);
- - update_site_option('dirAuthEnableSsl', $enableSsl);
- - update_site_option('dirAuthRequireSsl', $requireSsl);
- - update_site_option('dirAuthControllers', $controllers);
- - update_site_option('dirAuthBaseDn', $baseDn);
- - update_site_option('dirAuthPreBindUser', $preBindUser);
- - update_site_option('dirAuthAccountSuffix', $accountSuffix);
- - update_site_option('dirAuthFilter', $filter);
- - update_site_option('dirAuthInstitution', $institution);
- - update_site_option('dirAuthLoginScreenMsg', $loginScreenMsg);
- - update_site_option('dirAuthChangePassMsg', $changePassMsg);
- - update_site_option('dirAuthTOS', $TOS);
- - update_site_option('dirAuthUseGroups', $boolUseGroups);
- - update_site_option('dirAuthGroups', $strAuthGroups);
- - update_site_option('dirAuthMarketingSSOID', $strMarketingSSOID);
- + wpDirAuth_update_site_option('dirAuthEnable', $enable);
- + wpDirAuth_update_site_option('dirAuthEnableSsl', $enableSsl);
- + wpDirAuth_update_site_option('dirAuthRequireSsl', $requireSsl);
- + wpDirAuth_update_site_option('dirAuthControllers', $controllers);
- + wpDirAuth_update_site_option('dirAuthBaseDn', $baseDn);
- + wpDirAuth_update_site_option('dirAuthPreBindUser', $preBindUser);
- + wpDirAuth_update_site_option('dirAuthAccountSuffix', $accountSuffix);
- + wpDirAuth_update_site_option('dirAuthFilter', $filter);
- + wpDirAuth_update_site_option('dirAuthInstitution', $institution);
- + wpDirAuth_update_site_option('dirAuthLoginScreenMsg', $loginScreenMsg);
- + wpDirAuth_update_site_option('dirAuthChangePassMsg', $changePassMsg);
- + wpDirAuth_update_site_option('dirAuthTOS', $TOS);
- + wpDirAuth_update_site_option('dirAuthUseGroups', $boolUseGroups);
- + wpDirAuth_update_site_option('dirAuthGroups', $strAuthGroups);
- + wpDirAuth_update_site_option('dirAuthMarketingSSOID', $strMarketingSSOID);
- // Only store/override the value if a new one is being sent a bind user is set.
- if ( $preBindUser && $preBindPassword && ($preBindPassCheck == $preBindPassword) )
- - update_site_option('dirAuthPreBindPassword', $preBindPassword);
- + wpDirAuth_update_site_option('dirAuthPreBindPassword', $preBindPassword);
- // Clear the stored password if the Bind DN is null
- elseif ( ! $preBindUser)
- - update_site_option('dirAuthPreBindPassword', '');
- + wpDirAuth_update_site_option('dirAuthPreBindPassword', '');
- - if (get_site_option('dirAuthEnable') && !get_site_option('dirAuthCookieMarker'))
- + if (wpDirAuth_get_site_option('dirAuthEnable') && !wpDirAuth_get_site_option('dirAuthCookieMarker'))
- wpDirAuth_makeCookieMarker();
- echo '<div id="message" class="updated fade"><p>Your new settings were saved successfully.</p></div>';
- @@ -668,27 +668,27 @@
- }
- else {
- // Booleans
- - $enable = intval(get_site_option('dirAuthEnable')) == 1 ? 1 : 0;
- - $requireSsl = intval(get_site_option('dirAuthRequireSsl')) == 1 ? 1 : 0;
- - $TOS = intval(get_site_option('dirAuthTOS')) == 1 ? 1 : 0;
- - $boolUseGroups = intval(get_site_option('dirAuthUseGroups')) == 1 ? 1 : 0;
- + $enable = intval(wpDirAuth_get_site_option('dirAuthEnable')) == 1 ? 1 : 0;
- + $requireSsl = intval(wpDirAuth_get_site_option('dirAuthRequireSsl')) == 1 ? 1 : 0;
- + $TOS = intval(wpDirAuth_get_site_option('dirAuthTOS')) == 1 ? 1 : 0;
- + $boolUseGroups = intval(wpDirAuth_get_site_option('dirAuthUseGroups')) == 1 ? 1 : 0;
- //integers
- - $enableSsl = intval(get_site_option('dirAuthEnableSsl',0));
- + $enableSsl = intval(wpDirAuth_get_site_option('dirAuthEnableSsl',0));
- // Strings, no HTML
- - $controllers = wpDirAuth_sanitize(get_site_option('dirAuthControllers'));
- - $baseDn = wpDirAuth_sanitize(get_site_option('dirAuthBaseDn'));
- - $preBindUser = wpDirAuth_sanitize(get_site_option('dirAuthPreBindUser'));
- - $accountSuffix = wpDirAuth_sanitize(get_site_option('dirAuthAccountSuffix'));
- - $filter = wpDirAuth_sanitize(get_site_option('dirAuthFilter'));
- - $institution = wpDirAuth_sanitize(get_site_option('dirAuthInstitution'));
- - $strAuthGroups = wpDirAuth_sanitize((get_site_option('dirAuthGroups')));
- - $strMarketingSSOID = wpDirAuth_sanitize((get_site_option('dirAuthMarketingSSOID')));
- + $controllers = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthControllers'));
- + $baseDn = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthBaseDn'));
- + $preBindUser = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthPreBindUser'));
- + $accountSuffix = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthAccountSuffix'));
- + $filter = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthFilter'));
- + $institution = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthInstitution'));
- + $strAuthGroups = wpDirAuth_sanitize((wpDirAuth_get_site_option('dirAuthGroups')));
- + $strMarketingSSOID = wpDirAuth_sanitize((wpDirAuth_get_site_option('dirAuthMarketingSSOID')));
- // Have to be allowed to contain some HTML
- - $loginScreenMsg = wpDirAuth_sanitize(get_site_option('dirAuthLoginScreenMsg'), true);
- - $changePassMsg = wpDirAuth_sanitize(get_site_option('dirAuthChangePassMsg'), true);
- + $loginScreenMsg = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthLoginScreenMsg'), true);
- + $changePassMsg = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthChangePassMsg'), true);
- }
- $controllers = htmlspecialchars($controllers);
- @@ -955,7 +955,7 @@
- */
- function wpDirAuth_loginFormExtra()
- {
- - if (get_site_option('dirAuthEnable')) {
- + if (wpDirAuth_get_site_option('dirAuthEnable')) {
- if (isset($_SERVER['SCRIPT_URI']) && preg_match('|^http|',$_SERVER['SCRIPT_URI'])) {
- $selfURL = $_SERVER['SCRIPT_URI'];
- @@ -981,7 +981,7 @@
- //_log('contents of selfurl: '.$selfURL);
- - if (get_site_option('dirAuthRequireSsl') && (!preg_match('|^https|',$selfURL))) {
- + if (wpDirAuth_get_site_option('dirAuthRequireSsl') && (!preg_match('|^https|',$selfURL))) {
- $sslURL = str_replace('http://','https://',$selfURL);
- $refreshJS = '<script type="text/javascript">'."\n".'top.location.href=\''.$sslURL.'\';'."\n".'</script>" />';
- @@ -1002,13 +1002,13 @@
- exit;
- }
- - $dirAuthInstitution = stripslashes(get_site_option('dirAuthInstitution'));
- + $dirAuthInstitution = stripslashes(wpDirAuth_get_site_option('dirAuthInstitution'));
- if (!$dirAuthInstitution) $dirAuthInstitution = __('Directory');
- - $loginScreenMsg = stripslashes(get_site_option('dirAuthLoginScreenMsg'));
- + $loginScreenMsg = stripslashes(wpDirAuth_get_site_option('dirAuthLoginScreenMsg'));
- if (!$loginScreenMsg) $loginScreenMsg = __(sprintf(
- WPDIRAUTH_DEFAULT_LOGINSCREENMSG,
- - get_site_option('dirAuthInstitution')
- + wpDirAuth_get_site_option('dirAuthInstitution')
- ));
- echo '
- @@ -1038,15 +1038,15 @@
- }
- else {
- // Editing directory user profile, show password msg
- - $message = stripslashes(get_site_option('dirAuthChangePassMsg'));
- + $message = stripslashes(wpDirAuth_get_site_option('dirAuthChangePassMsg'));
- if (!$message) {
- $message = __(sprintf(
- WPDIRAUTH_DEFAULT_CHANGEPASSMSG,
- - stripslashes(get_site_option('dirAuthInstitution'))
- + stripslashes(wpDirAuth_get_site_option('dirAuthInstitution'))
- ));
- }
- - if (get_site_option('dirAuthTOS')) {
- + if (wpDirAuth_get_site_option('dirAuthTOS')) {
- // TOS option is ON
- if (($TOSDate = get_usermeta($profileuser->ID, 'wpDirAuthTOS')) === '') {
- if ($userdata->ID == $profileuser->ID) {
- @@ -1143,8 +1143,8 @@
- The password field is empty.'));
- }
- - $enable = get_site_option('dirAuthEnable');
- - $cookieMarker = get_site_option('dirAuthCookieMarker');
- + $enable = wpDirAuth_get_site_option('dirAuthEnable');
- + $cookieMarker = wpDirAuth_get_site_option('dirAuthCookieMarker');
- if (!$cookieMarker) {
- $cookieMarker = wpDirAuth_makeCookieMarker();
- @@ -1367,8 +1367,8 @@
- /**
- * Get wpsDirAuth options
- */
- - $enable = get_site_option('dirAuthEnable');
- - $cookieMarker = get_site_option('dirAuthCookieMarker');
- + $enable = wpDirAuth_get_site_option('dirAuthEnable');
- + $cookieMarker = wpDirAuth_get_site_option('dirAuthCookieMarker');
- if (!$cookieMarker) {
- $cookieMarker = wpDirAuth_makeCookieMarker();
- @@ -1518,12 +1518,12 @@
- function wpDirAuth_ConnectAndLookupUser($strSSOID){
- $boolFound = false;
- - $strBaseDn = get_site_option('dirAuthBaseDn');
- - $strPreBindUser = get_site_option('dirAuthPreBindUser','');
- - $strPreBindPassword = get_site_option('dirAuthPreBindPassword','');
- - $strAccountSuffix = get_site_option('dirAuthAccountSuffix');
- - $strFilter = get_site_option('dirAuthFilter');
- - $intEnableSSL = get_site_option('dirAuthEnableSsl');
- + $strBaseDn = wpDirAuth_get_site_option('dirAuthBaseDn');
- + $strPreBindUser = wpDirAuth_get_site_option('dirAuthPreBindUser','');
- + $strPreBindPassword = wpDirAuth_get_site_option('dirAuthPreBindPassword','');
- + $strAccountSuffix = wpDirAuth_get_site_option('dirAuthAccountSuffix');
- + $strFilter = wpDirAuth_get_site_option('dirAuthFilter');
- + $intEnableSSL = wpDirAuth_get_site_option('dirAuthEnableSsl');
- if ($strAccountSuffix) $strSSOID .= $strAccountSuffix;
- @@ -1531,7 +1531,7 @@
- $strFilterQuery = "($strFilter=$strSSOID)";
- - $aryControllers = wpDirAuth_shuffleControllers(explode(',', get_site_option('dirAuthControllers')));
- + $aryControllers = wpDirAuth_shuffleControllers(explode(',', wpDirAuth_get_site_option('dirAuthControllers')));
- if(is_wp_error($aryControllers)){
- return $aryControllers; //there werent any controllers to connect to
- @@ -1688,7 +1688,7 @@
- *
- */
- function wpDirAuth_add_user_contextual_help(){
- - $strMarketingSSOID = get_site_option('dirAuthMarketingSSOID','Username');
- + $strMarketingSSOID = wpDirAuth_get_site_option('dirAuthMarketingSSOID','Username');
- add_contextual_help('users_page_'.basename(__FILE__,'.php'),
- '<p>' . __('To add a directory authenticated user from your institution to your site, fill in the form on this screen. If you’re not sure which role to assign, you can use the link below to review the different roles and their capabilities. Here is a basic overview of roles:') . '</p>' .
- '<ul>' .
- @@ -1727,7 +1727,7 @@
- /**
- * How do we refer to their SSOID?
- */
- - $strMarketingSSOID = get_site_option('dirAuthMarketingSSOID','Username');
- + $strMarketingSSOID = wpDirAuth_get_site_option('dirAuthMarketingSSOID','Username');
- $strReferer = wpDirAuth_get_referer();
- @@ -1801,7 +1801,7 @@
- }
- - $strWpDirAuthRole = (isset($_POST['role']) && in_array($_POST['role'],array_keys(get_editable_roles()))) ? $_POST['role'] : get_site_option('default_role');
- + $strWpDirAuthRole = (isset($_POST['role']) && in_array($_POST['role'],array_keys(get_editable_roles()))) ? $_POST['role'] : wpDirAuth_get_site_option('default_role');
- $intBlogID = (isset($_POST['id']) && is_numeric($_POST['id'])) ? intval($_POST['id']) : '';
- if(isset($_POST['noconfirmation']) && $_POST['noconfirmation'] == 1) $boolConfirmationEmail = false;
- @@ -1835,7 +1835,7 @@
- }
- } else {
- $arySitesAddedTo[] = array(
- - 'blogname' =>get_site_option('blogname'),
- + 'blogname' =>wpDirAuth_get_site_option('blogname'),
- 'aoran' =>wpDirAuth_determine_A_or_An($strWpDirAuthRole),
- 'role' =>$strWpDirAuthRole,
- 'siteurl' =>site_url()
- @@ -1963,7 +1963,7 @@
- <th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
- <td><select name="role" id="role">
- <?php
- - $strCurrentRole = empty($strWpDirAuthRole) ? get_site_option('default_role') : $strWpDirAuthRole;
- + $strCurrentRole = empty($strWpDirAuthRole) ? wpDirAuth_get_site_option('default_role') : $strWpDirAuthRole;
- wp_dropdown_roles($strCurrentRole);
- ?>
- </select>
- @@ -2112,6 +2112,41 @@
- return $strReferer;
- }
- +
- + /**
- + * WordPress get_site_option overwrite using WPDIRAUTH_MULTISITE instead of is_multisite().
- + * Retrieve site option value based on name of option.
- + *
- + * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
- + * @param mixed $default Optional value to return if option doesn't exist. Default false.
- + * @param bool $use_cache Whether to use cache. Multisite only. Default true.
- + * @return mixed Value set for the option.
- + */
- + function wpDirAuth_get_site_option($option, $default = false, $use_cache = true){
- + if(WPDIRAUTH_MULTISITE){
- + return get_site_option($option, $default, $use_cache);
- + } else {
- + $default = apply_filters( 'default_site_option_' . $option, $default );
- + $value = get_option($option, $default);
- + return apply_filters( 'site_option_' . $option, $value );
- + }
- + }
- +
- + /**
- + * WordPress update_site_option overwrite using WPDIRAUTH_MULTISITE instead of is_multisite().
- + * Update the value of a site option that was already added.
- + *
- + * @param string $option Name of option. Expected to not be SQL-escaped.
- + * @param mixed $value Option value. Expected to not be SQL-escaped.
- + * @return bool False if value was not updated and true if value was updated.
- + */
- + function wpDirAuth_update_site_option($option, $value){
- + if(WPDIRAUTH_MULTISITE){
- + return update_site_option($option, $value);
- + } else {
- + return update_option($option, $value);
- + }
- + }
- }
- register_activation_hook(__FILE__, 'wpDirAuth_activation');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement