function sp_ProfileEditMobile($tabSlug = 'profile', $menuSlug = 'overview') { # is this edit for current user of admin edit of user global $spVars, $spThisUser; if (!empty($spVars['member'])) { $userid = (int) $spVars['member']; } else { $userid = $spThisUser->ID; } if (empty($userid) || $spThisUser->ID != $userid && !$spThisUser->admin) { sp_notify(SPFAILURE, sp_text('Invalid profile request')); $out = sp_render_queued_notification(); $out .= '<div class="spMessage">'; $out .= apply_filters('sph_ProfileErrorMsg', sp_text('Sorry, an invalid profile request was detected. Do you need to log in?')); $out .= '</div>'; echo $out; return; } # see if query args used to specify tab and/or menu if (isset($_GET['ptab'])) { $tabSlug = sp_esc_str($_GET['ptab']); } if (isset($_GET['pmenu'])) { $menuSlug = sp_esc_str($_GET['pmenu']); } # set up the profile data global $spProfileUser; sp_SetupUserProfileData($userid); do_action('sph_profile_edit_before'); do_action('sph_ProfileStart'); $tabs = sp_profile_get_tabs(); if (!empty($tabs)) { do_action('sph_profile_edit_before_tabs'); echo '<div id="spProfileAccordion">'; echo "<div class='spProfileAccordionTab'>\n"; $firstTab = $firstMenu = ''; $tabSlugExist = $menuSlugExist = false; foreach ($tabs as $tab) { # do we need an auth check? $authCheck = empty($tab['auth']) ? true : sp_get_auth($tab['auth'], '', $userid); # is this tab being displayed and does user have auth to see it? if ($authCheck && $tab['display']) { if ($tab['slug'] == $tabSlug) { $tabSlugExist = true; } if (empty($firstTab)) { $firstTab = $tab['slug']; } echo '<h2 id="spProfileTabTitle-' . esc_attr($tab['slug']) . '">' . sp_filter_title_display($tab['name']) . "</h2>\n"; echo "<div id='spProfileTab-" . esc_attr($tab['slug']) . "' class='spProfileAccordionPane'>\n"; if (!empty($tab['menus'])) { echo "<div class='spProfileAccordionTab'>\n"; 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? if ($authCheck && $menu['display']) { if ($menu['slug'] == $menuSlug) { $menuSlugExist = true; } if (empty($firstMenu)) { $firstMenu = $menu['slug']; } $thisSlug = $menu['slug']; # this variable is used in the form action url # special checking for displaying menus $spProfileOptions = sp_get_option('sfprofile'); $spAvatars = sp_get_option('sfavatars'); $noPhotos = $menu['slug'] == 'edit-photos' && $spProfileOptions['photosmax'] < 1; # dont display edit photos if disabled $noAvatars = $menu['slug'] == 'edit-avatars' && !$spAvatars['sfshowavatars']; # dont display edit avatars if disabled $hideMenu = $noPhotos || $noAvatars; $hideMenu = apply_filters('sph_ProfileMenuHide', $hideMenu, $tab, $menu, $userid); if (!$hideMenu) { echo '<h2 id="spProfileMenuTitle-' . esc_attr($menu['slug']) . '">' . sp_filter_title_display($menu['name']) . "</h2>\n"; echo "<div id='spProfileMenu-" . esc_attr($menu['slug']) . "' class='spProfileAccordionPane'>\n"; if (!empty($menu['form']) && file_exists($menu['form'])) { echo "<div class='spProfileAccordionForm'>\n"; include_once $menu['form']; echo "</div>\n"; } else { echo sp_text('Profile form could not be found') . ': [' . $menu['name'] . ']<br />'; echo sp_text('You might try the forum - toolbox - housekeeping admin form and reset the profile tabs and menus and see if that helps'); } echo "</div>\n"; # menu pane } } } echo "</div>\n"; # menu accordion } echo "</div>\n"; # tab pane } } echo "</div>\n"; # tab accordion echo '</div>'; # profile accordion do_action('sph_profile_edit_after_tabs'); # inline js to create profile tabs global $firstTab, $firstMenu; $firstTab = $tabSlugExist ? $tabSlug : $firstTab; # if selected tab does not exist, use first tab $firstMenu = $menuSlugExist ? $menuSlug : $firstMenu; # if selected tab does not exist, use first menu in first tab # are we forcing password change on first login? if (isset($spThisUser->sp_change_pw) && $spThisUser->sp_change_pw) { $firstTab = 'profile'; $firstMenu = 'account-settings'; } add_action('wp_footer', 'sp_ProfileEditFooterMobile'); } do_action('sph_profile_edit_after'); }
<?php die; } # check for tab press if (isset($_GET['tab'])) { # 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 = '';
function sp_process_profileshow_view() { global $spVars, $spThisUser; if (!empty($spVars['member'])) { $userid = (int) $spVars['member']; $userid = spdb_table(SFMEMBERS, "user_id={$userid}", 'user_id'); } else { $userid = $spThisUser->ID; } if (!sp_get_auth('view_profiles') || empty($userid) || $userid < 0) { sp_notify(SPFAILURE, sp_text('Invalid profile request')); return 'spDefault.php'; } else { global $spProfileUser; sp_SetupUserProfileData(); return 'spProfileShow.php'; } }