# profile edit, so only admin or logged in user can view if (empty($userid) || $spThisUser->ID != $userid && !$spThisUser->admin) { sp_notify(SPFAILURE, sp_text('Invalid profile request')); $out .= sp_render_queued_notification(); $out .= '<div class="sfmessagestrip">'; $out .= apply_filters('sph_ProfileErrorMsg', sp_text('Sorry, an invalid profile request was detected. Do you need to log in?')); $out .= '</div>'; return $out; } # set up profile for requested user sp_SetupUserProfileData($userid); # get pressed tab and menu (if pressed) $thisTab = sp_esc_str($_GET['tab']); $thisMenu = isset($_GET['menu']) ? sp_esc_str($_GET['menu']) : ''; # get all the tabs meta info $tabs = sp_profile_get_tabs(); if (!empty($tabs)) { foreach ($tabs as $tab) { # find the pressed tab in the list of tabs if ($tab['slug'] == $thisTab) { # now output the menu and content $first = true; $thisForm = ''; $thisName = ''; $thisSlug = ''; $out = ''; if (!empty($tab['menus'])) { foreach ($tab['menus'] as $menu) { # do we need an auth check? $authCheck = empty($menu['auth']) ? true : sp_get_auth($menu['auth'], '', $userid); # is this menu being displayed and does user have auth to see it?
function sp_ProfileEditFooter() { global $firstTab, $firstMenu, $spMobile; ?> <script type="text/javascript"> var spfProfileFirst = true; jQuery(document).ready(function() { /* set up the profile tabs */ jQuery("#spProfileTabs li a").click(function() { jQuery("#spProfileContent").html("<div><img src='<?php echo SFCOMMONIMAGES; ?> working.gif' alt='Loading' /></div>"); jQuery("#spProfileTabs li a").removeClass("current"); jQuery(this).addClass("current"); jQuery.ajax({async: <?php if (empty($firstMenu)) { echo 'true'; } else { echo 'false'; } ?> , url: this.href, success: function(html) { jQuery("#spProfileContent").html(html); } }); return false; }); <?php if (!empty($firstMenu)) { ?> jQuery('#spProfileTab-<?php echo $firstTab; ?> ').click(); jQuery("#spProfileMenu li a").unbind('click').click(function() { jQuery("#spProfileContent").html("<div><img src='<?php echo SFCOMMONIMAGES; ?> working.gif' alt='Loading' /></div>"); jQuery.ajax({async: false, url: this.href, success: function(html) { jQuery("#spProfileContent").html(html); } }); return false; }); jQuery('#spProfileMenu-<?php echo $firstMenu; ?> ').click(); jQuery("#spProfileMenu li a").unbind('click').click(function() { jQuery("#spProfileContent").html("<div><img src='<?php echo SFCOMMONIMAGES; ?> working.gif' alt='Loading' /></div>"); jQuery.ajax({async: true, url: this.href, success: function(html) { jQuery("#spProfileContent").html(html); } }); return false; }); <?php } else { if (!empty($firstTab)) { ?> jQuery('#spProfileTab-<?php echo $firstTab; ?> ').click(); <?php } else { ?> <?php $tabs = sp_profile_get_tabs(); ?> jQuery('#spProfileTab-<?php echo $tabs[0]['slug']; ?> ').click(); <?php } } ?> }) </script> <?php }
function sp_profile_delete_menu($tab, $name) { # sanitize before use $tab = sp_filter_title_save($tab); $name = sp_filter_title_save($name); # get the current tabs $tabs = sp_profile_get_tabs(); if (empty($tabs)) { return false; } # find the requested tab foreach ($tabs as &$thisTab) { if ($thisTab['name'] == $tab) { # make sure the menu doesnt already exist on this tab if ($thisTab['menus']) { foreach ($thisTab['menus'] as $index => $menu) { if ($menu['name'] == $name) { unset($thisTab['menus'][$index]); } } $thisTab['menus'] = array_values($thisTab['menus']); } } } # reorder tabs afer removal and save $newtabs = serialize(array_values($tabs)); $result = sp_add_sfmeta('profile', 'tabs', $tabs); return $result; }
function sp_profile_menu_active($menuslug) { # get the current tabs $tabs = sp_profile_get_tabs(); if (empty($tabs)) { return false; } # find the requested tab foreach ($tabs as &$thisTab) { if (!empty($thisTab['menus'])) { foreach ($thisTab['menus'] as $thisMenu) { if ($thisMenu['slug'] == $menuslug) { return $thisMenu['display']; } } } } return false; }
function spa_get_tabsmenus_data() { $tabs = sp_profile_get_tabs(); return $tabs; }
function spa_save_tabs_menus_data() { check_admin_referer('forum-adminform_tabsmenus', 'forum-adminform_tabsmenus'); if (!empty($_POST['spTabsOrder'])) { # grab the current tabs/menus and init new tabs array $newTabs = array(); $curTabs = sp_profile_get_tabs(); # need to cycle through all the tabs $tabList = explode('&', $_POST['spTabsOrder']); foreach ($tabList as $curTab => $tab) { $tab = sp_esc_str($tab); # extract the tab index from the jquery sortable mess $tabData = explode('=', $tab); $oldTab = $tabData[1]; # now move the tab stuff (except menus) to its new location $newTabs[$curTab]['name'] = sp_filter_title_save($_POST['tab-name-' . $oldTab]); $newTabs[$curTab]['slug'] = sp_filter_title_save($_POST['tab-slug-' . $oldTab]); $newTabs[$curTab]['auth'] = sp_filter_title_save($_POST['tab-auth-' . $oldTab]); $newTabs[$curTab]['display'] = isset($_POST['tab-display-' . $oldTab]) ? 1 : 0; # now update menus for this tab if (!empty($_POST['spMenusOrder' . $oldTab])) { $menuList = explode('&', $_POST['spMenusOrder' . $oldTab]); foreach ($menuList as $curMenu => $menu) { $menu = sp_esc_str($menu); # extract the menu index from the jquery sortable mess $menuData = explode('=', $menu); $thisMenu = $menuData[1]; # extract the tab the menu came from (what a pain!) $junk = explode('tab', $menuData[0]); $stop = strpos($junk[1], '['); $oldMenuTab = substr($junk[1], 0, $stop); # copy over the menu from old location to new location $newTabs[$curTab]['menus'][$curMenu]['name'] = sp_filter_title_save($_POST['menu-name-' . $oldMenuTab . '-' . $thisMenu]); $newTabs[$curTab]['menus'][$curMenu]['slug'] = sp_filter_title_save($_POST['menu-slug-' . $oldMenuTab . '-' . $thisMenu]); $newTabs[$curTab]['menus'][$curMenu]['auth'] = sp_filter_title_save($_POST['menu-auth-' . $oldMenuTab . '-' . $thisMenu]); $newTabs[$curTab]['menus'][$curMenu]['display'] = isset($_POST['menu-display-' . $oldMenuTab . '-' . $thisMenu]) ? 1 : 0; $form = str_replace('\\', '/', $_POST['menu-form-' . $oldMenuTab . '-' . $thisMenu]); # sanitize for Win32 installs $form = preg_replace('|/+|', '/', $form); # remove any duplicate slash $newTabs[$curTab]['menus'][$curMenu]['form'] = sp_esc_str($form); } } else { $newTabs[$curTab]['menus'] = array(); } } $mess = spa_text('Profile Tabs and Menus Updated!'); sp_add_sfmeta('profile', 'tabs', $newTabs); } else { $mess = spa_text('No Changes to profile tabs and menus'); } return $mess; }