function sp_akismet_admin_options_form()
{
    $spAkismet = sp_get_option('spAkismet');
    spa_paint_open_panel();
    spa_paint_open_fieldset(__('Akismet', 'spab'), true, 'akismet');
    if (function_exists('akismet_http_post')) {
        $values = array(__('Do not use Akismet', 'spab'), __('Place Akismet marked spam posts into moderation', 'spab'), __('Do not save Akismet marked spam posts', 'spab'));
        spa_paint_radiogroup(__('Select Akismet Option', 'spab'), 'spAkismet', $values, $spAkismet, '', false, true);
    } else {
        _e('Akismet is not currently active on this site', 'spab');
    }
    spa_paint_close_fieldset();
    spa_paint_close_panel();
}
function spa_components_seo_form()
{
    ?>
<script type="text/javascript">
    jQuery(document).ready(function() {
    	spjAjaxForm('sfseoform', 'sfreloadse');
    });
</script>
<?php 
    $sfcomps = spa_get_seo_data();
    $ahahURL = SFHOMEURL . 'index.php?sp_ahah=components-loader&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;saveform=seo';
    ?>
	<form action="<?php 
    echo $ahahURL;
    ?>
" method="post" id="sfseoform" name="sfseo">
	<?php 
    echo sp_create_nonce('forum-adminform_seo');
    spa_paint_options_init();
    #== EXTENSIONS Tab ============================================================
    spa_paint_open_tab(spa_text('Components') . ' - ' . spa_text('SEO'));
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Page/Browser Title (SEO)'), true, 'seo-plugin-integration');
    spa_paint_checkbox(spa_text('Overwrite page/browser title with ours'), 'sfseo_overwrite', $sfcomps['sfseo_overwrite']);
    spa_paint_checkbox(spa_text('Include blog name in page/browser title'), 'sfseo_blogname', $sfcomps['sfseo_blogname']);
    spa_paint_checkbox(spa_text('Include page name in page/browser title'), 'sfseo_pagename', $sfcomps['sfseo_pagename']);
    spa_paint_checkbox(spa_text('Display page name on forum home page (Group View) only'), 'sfseo_homepage', $sfcomps['sfseo_homepage']);
    spa_paint_checkbox(spa_text('Include forum name in page/browser title'), 'sfseo_forum', $sfcomps['sfseo_forum']);
    spa_paint_checkbox(spa_text('Include topic name in page/browser title'), 'sfseo_topic', $sfcomps['sfseo_topic']);
    spa_paint_checkbox(spa_text('Exclude forum name in page/browser title on topic views only'), 'sfseo_noforum', $sfcomps['sfseo_noforum']);
    spa_paint_checkbox(spa_text('Include non-forum page view names (ie profile, member list, etc) in page/browser title'), 'sfseo_page', $sfcomps['sfseo_page']);
    spa_paint_input(spa_text('Title separator'), 'sfseo_sep', $sfcomps['sfseo_sep']);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Meta Tags Data'), true, 'meta-tags');
    $submessage = spa_text('Text you enter here will entered as a custom meta desciption tag if enabled in the option above');
    spa_paint_wide_textarea(spa_text('Custom meta description'), 'sfdescr', $sfcomps['sfdescr'], $submessage, 3);
    $submessage = spa_text('Enter keywords separated by commas');
    spa_paint_wide_textarea(spa_text('Custom meta keywords'), 'sfkeywords', $sfcomps['sfkeywords'], $submessage);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_components_seo_left_panel');
    spa_paint_tab_right_cell();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Meta Tags Setup'), true, 'meta-setup');
    $values = array(spa_text('Do not add meta description to any forum pages'), spa_text('Use custom meta description on all forum pages'), spa_text('Use custom meta description on main forum page only and use forum description on forum and topic pages'), spa_text('Use custom meta description on main forum page only, use forum description on forum pages and use topic title on topic pages'), spa_text('Use custom meta description on main forum page only, use forum description on forum pages and use first post excerpt (120 chars) on topic pages'));
    spa_paint_radiogroup(spa_text('Select meta description option'), 'sfdescruse', $values, $sfcomps['sfdescruse'], false, true);
    $values = array(spa_text('Do not add meta keywords to any forum pages'), spa_text('Use custom meta keywords (entered in left panel) on all forum pages'), spa_text('Use custom meta keywords for each forum on forum and topic view pages. Custom meta keywords (from left panel) used on other forum pages'));
    spa_paint_radiogroup(spa_text('Select meta keywords option'), 'sfusekeywords', $values, $sfcomps['sfusekeywords'], false, true);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_components_seo_right_panel');
    spa_paint_close_container();
    ?>
    	<div class="sfform-submit-bar">
        	<input type="submit" class="button-primary" id="saveit" name="saveit" value="<?php 
    spa_etext('Update SEO Component');
    ?>
" />
    	</div>
	</form>
<?php 
    spa_paint_close_tab();
}
function spa_profiles_options_form()
{
    ?>
<script type="text/javascript">
	spjAjaxForm('sfoptionsform', '');
</script>
<?php 
    $sfoptions = spa_get_options_data();
    $ahahURL = SFHOMEURL . 'index.php?sp_ahah=profiles-loader&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;saveform=options';
    ?>
	<form action="<?php 
    echo $ahahURL;
    ?>
" method="post" id="sfoptionsform" name="sfoptions">
	<?php 
    echo sp_create_nonce('forum-adminform_options');
    spa_paint_options_init();
    #== PROFILE OPTIONS Tab ============================================================
    spa_paint_open_tab(spa_text('Profiles') . ' - ' . spa_text('Profile Options'));
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Display Name Format'), true, 'display-name-format');
    spa_paint_checkbox(spa_text('Let member choose display name'), 'nameformat', $sfoptions['nameformat']);
    spa_paint_select_start(spa_text('Display name format if member cannot choose') . '<br />' . spa_text('(ignored if member allowed to choose)'), 'fixeddisplayformat', 'fixeddisplayformat');
    echo spa_display_name_format_options($sfoptions['fixeddisplayformat']);
    spa_paint_select_end();
    echo '<tr><td colspan="2"><br /><div class="sfoptionerror">';
    spa_etext('Warning: If you change the display name format, it may take some time on a large number of users to update them to the new format. Please be patient.');
    echo '</div><br />';
    echo '</td></tr>';
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Personal Photos'), true, 'personal-photos');
    spa_paint_input(spa_text('Maximum number of photos allowed'), 'photosmax', $sfoptions['photosmax'], false, false);
    spa_paint_input(spa_text('Maximum pixel width of photo display'), 'photoswidth', $sfoptions['photoswidth'], false, false);
    spa_paint_input(spa_text('Maximum pixel height of photo display'), 'photosheight', $sfoptions['photosheight'], false, false);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Signature Image Size'), true, 'sig-images');
    echo '<tr><td colspan="2">&nbsp;<u>' . spa_text('If you are allowing signature images (zero = not limited)') . ':</u></td></tr>';
    spa_paint_input(spa_text('Maximum signature width (pixels)'), 'sfsigwidth', $sfoptions['sfsigwidth']);
    spa_paint_input(spa_text('Maximum signature height (pixels)'), 'sfsigheight', $sfoptions['sfsigheight']);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('First Forum Visit'), true, 'first-forum-visit');
    spa_paint_checkbox(spa_text('Display profile form on login'), 'firstvisit', $sfoptions['firstvisit']);
    $show_password_fields = apply_filters('show_password_fields', true);
    if ($show_password_fields) {
        spa_paint_checkbox(spa_text('Force password change'), 'forcepw', $sfoptions['forcepw']);
    }
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_profiles_options_left_panel');
    spa_paint_tab_right_cell();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Display Profile Mode'), true, 'display-profile-mode');
    $values = array(spa_text('Popup window'), spa_text('Forum profile page'), spa_text('BuddyPress profile'), spa_text('WordPress author page'), spa_text('Other page'), spa_text('Mingle profile'));
    spa_paint_radiogroup(spa_text('Display profile information in'), 'displaymode', $values, $sfoptions['displaymode'], false, true);
    spa_paint_input(spa_text('URL for Other page'), 'displaypage', sp_filter_url_display($sfoptions['displaypage']), false, true);
    spa_paint_input(spa_text('Query String Variable Name'), 'displayquery', sp_filter_title_display($sfoptions['displayquery']), false, true);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Profile Entry Form Mode'), true, 'profile-entry-form-mode');
    $values = array(spa_text('Forum profile form'), spa_text('WordPress profile form'), spa_text('BuddyPress profile'), spa_text('Other form'), spa_text('Mingle profile'));
    spa_paint_radiogroup(spa_text('Enter profile information In'), 'formmode', $values, $sfoptions['formmode'], false, true);
    spa_paint_input(spa_text('URL for Other page'), 'formpage', sp_filter_url_display($sfoptions['formpage']), false, true);
    spa_paint_input(spa_text('Query string variable name'), 'formquery', sp_filter_title_display($sfoptions['formquery']), false, true);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Profile Overview Message'), true, 'profile-message');
    $submessage = spa_text('Text you enter here will be displayed to the User on their profile overview page');
    spa_paint_wide_textarea(spa_text('Profile overview message'), 'sfprofiletext', sp_filter_text_edit($sfoptions['sfprofiletext']), $submessage);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_profiles_options_right_panel');
    spa_paint_close_container();
    ?>
    	<div class="sfform-submit-bar">
    	   <input type="submit" class="button-primary" id="saveit" name="saveit" value="<?php 
    spa_etext('Update Profile Options');
    ?>
" />
    	</div>
	</form>
<?php 
    spa_paint_close_tab();
}
function spa_options_members_form()
{
    ?>
<script type="text/javascript">
    jQuery(document).ready(function() {
    	spjAjaxForm('sfmembersform', 'sfreloadms');
    });
</script>
<?php 
    global $wp_roles;
    $sfoptions = spa_get_members_data();
    $ahahURL = SFHOMEURL . 'index.php?sp_ahah=options-loader&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;saveform=members';
    ?>
	<form action="<?php 
    echo $ahahURL;
    ?>
" method="post" id="sfmembersform" name="sfmembers">
	<?php 
    echo sp_create_nonce('forum-adminform_members');
    spa_paint_options_init();
    #== MEMBERS Tab ============================================================
    spa_paint_open_tab(spa_text('Options') . ' - ' . spa_text('Member Settings'));
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Member Profiles'), true, 'member-profiles');
    spa_paint_checkbox(spa_text('Disallow members not logged in to post as guests'), 'sfcheckformember', $sfoptions['sfcheckformember']);
    spa_paint_checkbox(spa_text('Allow members to hide their online status'), 'sfhidestatus', $sfoptions['sfhidestatus']);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Member Name Linking'), true, 'member-name-linking');
    $values = array(spa_text('Nothing'), spa_text("Member's profile"), spa_text("Member's website"));
    spa_paint_radiogroup(spa_text("Link a member's name when displayed to"), 'namelink', $values, $sfoptions['namelink'], false, true);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Guest Settings'), true, 'guest-settings');
    spa_paint_checkbox(spa_text('Require guests to enter email address'), 'reqemail', $sfoptions['reqemail']);
    spa_paint_checkbox(spa_text('Store guest information in a cookie for subsequent visits'), 'storecookie', $sfoptions['storecookie']);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Inactive Members Account Auto Removal'), true, 'user-removal');
    spa_paint_checkbox(spa_text('Enable auto removal of member accounts'), 'sfuserremove', $sfoptions['sfuserremove']);
    spa_paint_checkbox(spa_text('Remove inactive members (if auto removal enabled)'), 'sfuserinactive', $sfoptions['sfuserinactive']);
    spa_paint_checkbox(spa_text('Remove members who have not posted  (if auto removal enabled)'), 'sfusernoposts', $sfoptions['sfusernoposts']);
    spa_paint_input(spa_text('Number of days back to remove inactive members and/or members with no posts (if auto removal enabled)'), 'sfuserperiod', $sfoptions['sfuserperiod']);
    if ($sfoptions['sched']) {
        $msg = spa_text('Users auto removal cron job is scheduled to run daily');
        echo '<tr><td class="message" colspan="2" style="line-height:2em;">&nbsp;<u>' . $msg . '</u></td></tr>';
    }
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Post Counts on Deletion'), true, 'delete-count');
    spa_paint_checkbox(spa_text('Adjust users post count when post deleted'), 'post_count_delete', $sfoptions['post_count_delete']);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_options_members_left_panel');
    spa_paint_tab_right_cell();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Blacklists'), true, 'member-blacklists');
    $submessage = spa_text('Enter a comma separated list of account names to disallow when a user registers');
    spa_paint_wide_textarea(spa_text('Blocked account names'), 'account-name', $sfoptions['account-name'], $submessage);
    $submessage = spa_text('Enter a comma separated list of display names to disallow for users');
    spa_paint_wide_textarea(spa_text('Blocked display names'), 'display-name', $sfoptions['display-name'], $submessage);
    $submessage = spa_text('Enter a comma separated list of guest names to disallow when a guest posts');
    spa_paint_wide_textarea(spa_text('Blocked guest posting names'), 'guest-name', $sfoptions['guest-name'], $submessage);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_options_members_right_panel');
    spa_paint_close_container();
    ?>
    	<div class="sfform-submit-bar">
            <input type="submit" class="button-primary" id="saveit" name="saveit" value="<?php 
    spa_etext('Update Member Options');
    ?>
" />
    	</div>
	</form>
<?php 
    spa_paint_close_tab();
}
function spa_profiles_avatars_form()
{
    global $spPaths;
    ?>
<script type="text/javascript">
    jQuery(document).ready(function() {
    	spjAjaxForm('sfavatarsform', 'sfreloadav');

    	jQuery("#sfavataroptions").sortable({
    		placeholder: 'sortable-placeholder',
    		update: function () {
    			jQuery("input#sfavataropts").val(jQuery("#sfavataroptions").sortable('serialize'));
    		}
    	});

    	var button = jQuery('#sf-upload-button'), interval;
    	new AjaxUpload(button,{
    		action: '<?php 
    echo SFUPLOADER;
    ?>
',
    		name: 'uploadfile',
    	    data: {
    		    saveloc : '<?php 
    echo addslashes(SF_STORE_DIR . "/" . $spPaths['avatar-pool'] . '/');
    ?>
'
    	    },
    		onSubmit : function(file, ext){
                /* check for valid extension */
    			if (! (ext && /^(jpg|png|jpeg|gif|JPG|PNG|JPEG|GIF)$/.test(ext))){
    				jQuery('#sf-upload-status').html('<p class="sf-upload-status-fail"><?php 
    echo esc_js(spa_text('Only JPG, PNG or GIF files are allowed!'));
    ?>
</p>');
    				return false;
    			}
    			/* change button text, when user selects file */
    			utext = '<?php 
    echo esc_js(spa_text('Uploading'));
    ?>
';
    			button.text(utext);
    			/* If you want to allow uploading only 1 file at time, you can disable upload button */
    			this.disable();
    			/* Uploding -> Uploading. -> Uploading... */
    			interval = window.setInterval(function(){
    				var text = button.text();
    				if (text.length < 13){
    					button.text(text + '.');
    				} else {
    					button.text(utext);
    				}
    			}, 200);
    		},
    		onComplete: function(file, response){
    			jQuery('#sf-upload-status').html('');
    			button.text('<?php 
    echo esc_js(spa_text('Browse'));
    ?>
');
    			window.clearInterval(interval);
    			/* re-enable upload button */
    			this.enable();
    			/* add file to the list */
    			if (response==="success"){
                    site = "<?php 
    echo SFHOMEURL;
    ?>
index.php?sp_ahah=profiles&amp;sfnonce=<?php 
    echo wp_create_nonce('forum-ahah');
    ?>
&amp;action=delavatar&amp;file=" + file;
    				jQuery('<table style="width:100%"></table>').appendTo('#sf-avatar-pool').html('<tr><td style="width:60%;text-align:center"><img class="sfavatarpool" src="<?php 
    echo SFAVATARPOOLURL;
    ?>
/' + file + '" alt="" /></td><td class="sflabel" style="text-align:center;width:30%">' + file + '</td><td class="sflabel" style="text-align:center;width:9%"><img src="<?php 
    echo SFCOMMONIMAGES;
    ?>
' + 'delete.png' + '" title="<?php 
    echo esc_js(spa_text('Delete Avatar'));
    ?>
" alt="" onclick="spjDelRowReload(\'' + site + '\', \'sfreloadav\');" /></td></tr>');
    				jQuery('#sf-upload-status').html('<p class="sf-upload-status-success"><?php 
    echo esc_js(spa_text('Avatar Uploaded!'));
    ?>
</p>');
    			} else if (response==="invalid"){
    				jQuery('#sf-upload-status').html('<p class="sf-upload-status-fail"><?php 
    echo esc_js(spa_text('Sorry, the file has an invalid format!'));
    ?>
</p>');
    			} else if (response==="exists") {
    				jQuery('#sf-upload-status').html('<p class="sf-upload-status-fail"><?php 
    echo esc_js(spa_text('Sorry, the file already exists!'));
    ?>
</p>');
    			} else {
    				jQuery('#sf-upload-status').html('<p class="sf-upload-status-fail"><?php 
    echo esc_js(spa_text('Error uploading file!!'));
    ?>
</p>');
    			}
    		}
    	});
    });
</script>
<?php 
    $sfoptions = spa_get_avatars_data();
    $ahahURL = SFHOMEURL . 'index.php?sp_ahah=profiles-loader&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;saveform=avatars';
    ?>
	<form action="<?php 
    echo $ahahURL;
    ?>
" method="post" id="sfavatarsform" name="sfavatars">
	<?php 
    echo sp_create_nonce('forum-adminform_avatars');
    spa_paint_options_init();
    #== PROFILE OPTIONS Tab ============================================================
    spa_paint_open_tab(spa_text('Profiles') . ' - ' . spa_text('Avatars'));
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Avatar Options'), true, 'avatar-options');
    spa_paint_checkbox(spa_text('Display avatars'), 'sfshowavatars', $sfoptions['sfshowavatars']);
    spa_paint_input(spa_text('Maximum avatar display width (pixels)'), 'sfavatarsize', $sfoptions['sfavatarsize'], false, false);
    spa_paint_checkbox(spa_text('Enable avatar uploading'), 'sfavataruploads', $sfoptions['sfavataruploads']);
    spa_paint_input(spa_text('Maximum avatar upload file size (bytes)'), 'sfavatarfilesize', $sfoptions['sfavatarfilesize'], false, false);
    spa_paint_checkbox(spa_text('Auo resize avatar uploads'), 'sfavatarresize', $sfoptions['sfavatarresize']);
    spa_paint_input(spa_text('Uploaded avatar resize quality (if resizing)'), 'sfavatarresizequality', $sfoptions['sfavatarresizequality'], false, false);
    spa_paint_checkbox(spa_text('Enable avatar pool selection'), 'sfavatarpool', $sfoptions['sfavatarpool']);
    spa_paint_checkbox(spa_text('Enable remote avatars'), 'sfavatarremote', $sfoptions['sfavatarremote']);
    $values = array(spa_text('G - Suitable for all'), spa_text('PG- Suitable for 13 and above'), spa_text('R - Suitable for 17 and above'), spa_text('X - Suitable for all adults'));
    spa_paint_radiogroup(spa_text('Gravatar max rating'), 'sfgmaxrating', $values, $sfoptions['sfgmaxrating'], false, true);
    spa_paint_checkbox(spa_text('Replace WP avatar with SP avatar'), 'sfavatarreplace', $sfoptions['sfavatarreplace']);
    echo '<br /><div class="sfoptionerror">';
    spa_etext('Warning: If you want to replace WP avatars with SP avatars, make sure you dont have WP avatars in your avatar priorities (have it below SP Default Avatars) or you will have a circular reference');
    echo '</div><br />';
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_profiles_avatar_left_panel');
    spa_paint_tab_right_cell();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Avatar Priorities'), true, 'avatar-priorities');
    spa_etext('Select the avatar dislay priority order by dragging and dropping the buttons below.  The top of the list is the highest priority order.  When an avatar is found for the current priority, it is used.  If none is found, the next priority is checked and so on.  An SP Default Avatar will always be found. Any avatar after the SP Default Avatar is essentially ignored');
    echo '<div>';
    echo '<ul id="sfavataroptions" class="menu">';
    $list = array(0 => spa_text('Gravatars'), 1 => spa_text('WP Avatars'), 2 => spa_text('Uploaded Avatar'), 3 => spa_text('SP Default Avatars'), 4 => spa_text('Avatar Pool'), 5 => spa_text('Remote Avatar'));
    if ($sfoptions['sfavatarpriority']) {
        foreach ($sfoptions['sfavatarpriority'] as $priority) {
            echo '<li id="aitem_' . $priority . '" class="menu-item menu-item-depth-0"><span class="item-name">' . $list[$priority] . '</span></li>';
        }
    }
    echo '</ul>';
    echo '<input type="text" class="inline_edit" size="70" id="sfavataropts" name="sfavataropts" />';
    echo '</div>';
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_close_container();
    spa_paint_close_tab();
    spa_paint_open_nohead_tab(false);
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Avatar Pool Upload'), true, 'avatar-pool-upload');
    $loc = SF_STORE_DIR . '/' . $spPaths['avatar-pool'] . '/';
    spa_paint_file(spa_text('Select avatar to upload'), 'newavatar', false, true, $loc);
    echo '<table><tr>';
    echo '<td class="sflabel"><small>';
    spa_etext('Please be advised that Admin uploaded avatars for the avatar pool are NOT subject to the user uploaded avatar size limits.  So use caution when picking avatars for your avatar pool');
    echo '</small></td>';
    echo '</tr></table>';
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    spa_paint_tab_right_cell();
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Avatar Pool'), true, 'avatar-pool');
    spa_paint_avatar_pool();
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_profiles_avatar_right_panel');
    spa_paint_close_container();
    ?>
    	<div class="sfform-submit-bar">
    	   <input type="submit" class="button-primary" id="saveit" name="saveit" value="<?php 
    spa_etext('Update Avatar Options');
    ?>
" />
    	</div>
<?php 
    spa_paint_close_tab();
    ?>
	</form>
<?php 
}
function spa_usergroups_map_users()
{
    ?>
<script type="text/javascript">
    jQuery(document).ready(function() {
    	jQuery('#sfmapsettingsform').ajaxForm({
    		target: '#sfmsgspot',
    		success: function() {
    			jQuery('#sfreloadmu').click();
    			jQuery('#sfmsgspot').fadeIn();
    			jQuery('#sfmsgspot').fadeOut(6000);
    		}
    	});
    	jQuery('#sfmapusersform').ajaxForm({
    		target: '#sfmsgspot',
    	});
    });
</script>
<?php 
    global $wp_roles;
    $sfoptions = spa_get_mapping_data();
    $ahahURL = SFHOMEURL . 'index.php?sp_ahah=usergroups-loader&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;saveform=mapsettings';
    ?>
	<form action="<?php 
    echo $ahahURL;
    ?>
" method="post" id="sfmapsettingsform" name="sfmapsettingsform">
	<?php 
    echo sp_create_nonce('forum-adminform_mapusers');
    spa_paint_options_init();
    spa_paint_open_tab(spa_text('User Groups') . ' - ' . spa_text('User Mapping Settings'), true);
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('User Memberships'), true, 'user-memberships');
    echo '<tr><td colspan="2"><br /><div class="sfoptionerror">';
    spa_etext('Warning: Use caution when setting the single usergroup membership option below. It should primarily be used in conjunction with a membership plugin (such as Wishlist) where strict usergroup membership is required.  Please note that auto usergroup membership by WP role or by forum rank may conflict or overwrite any manual usergroup memberships (such as moderator) you may set if you have single usergroup membership set');
    echo '</div><br />';
    echo '</td></tr>';
    spa_paint_checkbox(spa_text('Users are limited to single usergroup membership'), 'sfsinglemembership', $sfoptions['sfsinglemembership']);
    echo '<tr><td colspan="2"><p class="subhead">' . spa_text('Default usergroup membership') . ':</p></td></tr>';
    spa_paint_select_start(spa_text('Default usergroup for guests'), 'sfguestsgroup', 'sfguestsgroup');
    echo spa_create_usergroup_select($sfoptions['sfguestsgroup']);
    spa_paint_select_end();
    spa_paint_select_start(spa_text('Default usergroup for new members'), 'sfdefgroup', 'sfdefgroup');
    echo spa_create_usergroup_select($sfoptions['sfdefgroup']);
    spa_paint_select_end();
    $roles = array_keys($wp_roles->role_names);
    if ($roles) {
        echo '<tr><td colspan="2"><p class="subhead">' . spa_text('Usergroup memberships based on WP role') . ':</p></td></tr>';
        $sfoptions['role'] = array();
        foreach ($roles as $index => $role) {
            $value = sp_get_sfmeta('default usergroup', $role);
            if ($value) {
                $group = $value[0]['meta_value'];
            } else {
                $group = $sfoptions['sfdefgroup'];
            }
            echo '<input type="hidden" class="sfhiddeninput" name="sfoldrole[' . $index . ']" value="' . $group . '" />';
            spa_paint_select_start(spa_text('Default usergroup for') . ' ' . $role, "sfrole[{$index}]", 'sfguestsgroup');
            echo spa_create_usergroup_select($group);
            spa_paint_select_end();
        }
    }
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_usergroups_mapping_settings_panel');
    spa_paint_close_container();
    ?>
	<div class="sfform-submit-bar">
	<input type="submit" class="button-primary" id="saveit" name="saveit" value="<?php 
    spa_etext('Update Mapping Settings');
    ?>
" />
	</div>
	</form>
	<?php 
    spa_paint_close_tab();
    ?>

	<div class="sfform-panel-spacer"></div>
<?php 
    $ahahURL = SFHOMEURL . 'index.php?sp_ahah=usergroups-loader&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;saveform=mapusers';
    $uCount = spdb_count(SFMEMBERS);
    $url = SFHOMEURL . 'index.php?sp_ahah=usermapping&amp;sfnonce=' . wp_create_nonce('forum-ahah');
    $target = 'sfmsgspot';
    $smessage = esc_js(spa_text('Please Wait - Processing'));
    $emessage = $uCount . ' ' . esc_js(spa_text('Users mapped'));
    ?>
	<form action="<?php 
    echo $ahahURL;
    ?>
" method="post" id="sfmapusersform" name="sfmapusersform" onsubmit="spjBatch('sfmapusersform', '<?php 
    echo $url;
    ?>
', '<?php 
    echo $target;
    ?>
', '<?php 
    echo $smessage;
    ?>
', '<?php 
    echo $emessage;
    ?>
', 0, 500, <?php 
    echo $uCount;
    ?>
);">
<?php 
    echo sp_create_nonce('forum-adminform_mapusers');
    spa_paint_options_init();
    spa_paint_open_tab(spa_text('User Groups') . ' - ' . spa_text('Map Users'), true);
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Map Users'), true, 'map-users');
    echo '<tr><td colspan="2"><br /><div class="sfoptionerror">';
    spa_etext("Warning: Use caution when mapping users. This will adjust your user's memberships in User Groups. Choose the criteria and options carefully. The mapping cannot be undone except by remapping or manual process. Also, make sure you have saved your mapping settings above before mapping as they are two distinct actions.");
    echo '</div><br />';
    echo '</td></tr>';
    $values = array(spa_text('Add user membership based on WP role to existing memberships'), spa_text('Replace all user memberships with a single membership based on WP role'));
    spa_paint_radiogroup(spa_text('Select mapping criteria'), 'mapoption', $values, 2, false, true);
    spa_paint_checkbox(spa_text('Ignore current SP Moderators when mapping'), 'ignoremods', true);
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_usergroups_map_users_panel');
    spa_paint_close_container();
    ?>
    	<div class="sfform-submit-bar">
        	<span><input type="submit" class="button-primary" id="saveit2" name="saveit2" value="<?php 
    spa_etext('Map Users');
    ?>
" /> <span class="button sfhidden" id='onFinish'></span></span>
        	<br />
        	<div class="pbar" id="progressbar"></div>
    	</div>
	</form>
<?php 
    spa_paint_close_tab();
}