' . __( 'LDAP Not Supported', ADAUTHINT_TEXT_DOMAIN ) . '
' . __( 'Your PHP configuration does not appear to support LDAP connections; therefore, the Active Directory Authentication Integration plug-in will not work at all. It is recommended that you deactivate the plug-in until you are able to update your PHP configuration to support LDAP.', ADAUTHINT_TEXT_DOMAIN ) . '
';
} /* _ldap_not_supported() function */
/**
* Print the current log to an admin notice
*/
function _flush_log_to_notice() {
if( $this->_loglevel && !empty( $this->_debug ) ) {
echo '
_log_flush();
return true;
} /* display_admin_page() function */
/**
* Update options for a whole network
*
* Only invoked when the plugin is network-active. If
* the plugin is only active on one blog/site, or the
* multi-site functions of WordPress are not set up,
* this function is not called.
*/
function update_wpms_options() {
if( ADAI_IS_NETWORK_ACTIVE ) {
/* If the WP Multi Network plug-in is installed and active,
* then we should propagate the settings to all other networks
*/
if( ADAI_IS_MULTINETWORK && $this->update_all_networks ) {
global $wpdb;
$networks = $wpdb->get_results( $wpdb->prepare( 'SELECT DISTINCT id FROM ' . $wpdb->site ) );
if( is_array( $networks ) ) { /* We retrieved an array of site IDs */
if( !method_exists( $this, 'switch_to_site' ) )
continue;
foreach( $networks as $network ) {
global $adai_current_network, $adai_original_network, $site_id;
$adai_current_network = $network->id;
$adai_original_network = $site_id;
$this->_log( ADAI_LOG_INFO, 'Preparing to update sitewide options for ' . $network->id );
$this->switch_to_site( $adai_current_network );
if( current_user_can( 'delete_users' ) ) {
$this->update_site_options( $adai_current_network, $adai_original_network );
} else {
$this->_log( ADAI_LOG_ERROR, 'The current user does not appear to be a super admin for the network with an ID of ' . $adai_current_network . ', therefore, the site options for that network were not updated.' );
}
$this->restore_current_site();
}
} elseif( current_user_can( 'delete_users' ) ) { /* We only found one network */
$this->_log( ADAI_LOG_INFO, 'WPMN plugin was found, but only one network seems to exist, so only options for the current network are updated.' );
$this->update_site_options();
} else {
$this->_log( ADAI_LOG_ERROR, 'Multiple networks were not found, so an attempt was made to update the current network. However, the current user does not appear to have the appropriate permissions to perform this action. Therefore, no options were updated.' );
}
} else { /* The WPMN plugin is not installed or active */
$this->_log( ADAI_LOG_INFO, 'The WPMN plugin was not found, so only options for current network are updated' );
if( current_user_can( 'delete_users' ) )
$this->update_site_options();
else
$this->_log( ADAI_LOG_ERROR, 'The current user does not appear to have the appropriate permissions to update these options.' );
}
}
} /* update_wpms_options() function */
function update_site_options( $current_network=NULL, $original_network=NULL ) {
foreach( array_keys( $this->options_info ) as $optgroup ) {
if( $current_network == $original_network || ( array_key_exists( 'update_all_networks', $_POST[ $optgroup ] ) && $_POST[$optgroup]['update_all_networks'] == 'true' ) ) {
$this->_log( ADAI_LOG_INFO, 'The network options for ' . $optgroup . ' were updated' . ( ( !empty( $current_network ) ) ? ' on the network with an ID of ' . $current_network : '' ) . '.' );
update_site_option( $optgroup, $options );
}
}
}
/**
* Initiate our admin page
* @uses ADAuthInt_Plugin::options
* @uses register_setting()
* @uses add_settings_section()
* @uses add_settings_field()
*/
function init_admin(){
if( !count( $this->options_objs ) )
$this->_load_options();
foreach( $this->options as $optgroup=>$options ) {
if( is_array( $options ) ) {
register_setting( ADAUTHINT_OPTIONS_PAGE, $optgroup, array( $this, 'validate_options_' . $optgroup ) );
add_settings_section(
/*$id = */$optgroup . '_group',
/*$title = */__( $this->subtitles[$optgroup], ADAUTHINT_TEXT_DOMAIN ),
/*$callback = */array( $this, 'build_options_' . $optgroup ),
/*$page = */ADAUTHINT_OPTIONS_PAGE
);
foreach( array_keys( $options ) as $k ) {
add_settings_field(
/*$id =*/ $k,
/*$title =*/ __( $this->options_objs[$optgroup][$k]->opt_label, ADAUTHINT_TEXT_DOMAIN ),
/*$callback =*/ array( &$this->options_objs[$optgroup][$k], 'build_field' ),
/*$page =*/ ADAUTHINT_OPTIONS_PAGE,
/*$section =*/ $optgroup . '_group'
);
}
}
}
} /* init_admin() function */
/**
* Build the Server Options group
* @uses ADAuthInt_Plugin::build_options_group()
*/
function build_options_adauthint_server_opts() {
$this->build_options_group( $this->options_info['adauthint_server_opts'], 'adauthint_server_opts' );
return;
} /* build_options_adauthint_server_opts function */
/**
* Build the User Options group
* @uses ADAuthInt_Plugin::build_options_group()
*/
function build_options_adauthint_user_opts() {
$this->build_options_group( $this->options_info['adauthint_user_opts'], 'adauthint_user_opts' );
return;
} /* build_options_adauthint_user_opts function */
/**
* Build the Authority Options group
* @uses ADAuthInt_Plugin::build_options_group()
*/
function build_options_adauthint_auth_opts() {
$this->build_options_group( $this->options_info['adauthint_auth_opts'], 'adauthint_auth_opts' );
return;
} /* build_options_adauthint_auth_opts function */
/**
* Build the Security Options group
* @uses ADAuthInt_Plugin::build_options_group()
*/
function build_options_adauthint_security_opts() {
$this->build_options_group( $this->options_info['adauthint_security_opts'], 'adauthint_security_opts' );
return;
} /* build_options_adauthint_security_opts function */
/**
* General options building function
*
* This function is used to build each of the options groups for this plug-in
* @param array $group The appropriate portion of the ADAuthInt_Plugin::options_info array for this group of options
* @param string $sect The name of the options group to build
*/
function build_options_group( $group=array(), $sect ) {
if( $this->_loglevel >= ADAI_LOG_DEBUG ) {
ob_start();
var_dump( $this->options_objs );
$this->_log( ADAI_LOG_DEBUG, ob_get_contents() );
ob_end_clean();
}
$section_notes = array(
'adauthint_server_opts' => 'Information about the active directory server.',
'adauthint_user_opts' => 'Information about how to handle individual user accounts',
'adauthint_security_opts' => 'Various security options to help prevent brute-force attacks',
'adauthint_auth_opts' => 'Authorization options, allowing you to set up specific user groups based on Active Directory groups, etc.',
);
echo '