function check_merge(&$useraccount, &$mylogins, $tolink) { global $qa_cached_logged_in_user, $qa_logged_in_userid_checked; $userid = $findid = $useraccount['userid']; $findemail = $useraccount['oemail']; // considering this is an openid user, so use the openid email if (empty($findemail)) { $findemail = $useraccount['email']; // fallback } if ($tolink) { // user is logged in with $userid but wants to merge $findid $findemail = null; $findid = $tolink['userid']; } else { if (qa_get('confirm') == 2 || qa_post_text('confirm') == 2) { // bogus confirm page, stop right here qa_redirect('logins'); } } // find other un-linked accounts with the same email $otherlogins = qa_db_user_login_find_other__open($findid, $findemail, $userid); if (qa_clicked('domerge') && !empty($otherlogins)) { // if cancel was requested, just redirect if ($_POST['domerge'] == 0) { $tourl = qa_post_text('to'); if (!empty($tourl)) { qa_redirect($tourl); } else { qa_redirect($tolink ? 'logins' : ''); } } // a request to merge (link) multiple accounts was made require_once QA_INCLUDE_DIR . 'qa-app-users-edit.php'; $recompute = false; $email = null; $baseid = $_POST["base{$_POST['domerge']}"]; // POST[base1] or POST[base2] // see which account was selected, if any if ($baseid != 0) { // just in case foreach ($otherlogins as $login) { // see if this is the currently logged in account $loginid = $login['details']['userid']; $is_current = $loginid == $userid; // see if this user was selected for merge if (isset($_POST["user_{$loginid}"]) || $is_current) { if ($baseid != $loginid) { // this account should be deleted as it's different from the selected base id if (!empty($login['logins'])) { // update all associated logins qa_db_user_login_sync(true); qa_db_user_login_replace_userid__open($loginid, $baseid); qa_db_user_login_sync(false); } // delete old user but keep the email qa_delete_user($loginid); $recompute = true; if (empty($email)) { $email = $login['details']['email']; } if (empty($email)) { $email = $login['details']['oemail']; } } } } } // recompute the stats, if needed if ($recompute) { require_once QA_INCLUDE_DIR . 'qa-db-points.php'; qa_db_userpointscount_update(); // check if the current account has been deleted if ($userid != $baseid) { $oldsrc = $useraccount['sessionsource']; qa_set_logged_in_user($baseid, $useraccount['handle'], false, $oldsrc); $useraccount = qa_db_user_find_by_id__open($baseid); $userid = $baseid; // clear some cached data qa_db_flush_pending_result('loggedinuser'); $qa_logged_in_userid_checked = false; unset($qa_cached_logged_in_user); } // also check the email address on the remaining user account if (empty($useraccount['email']) && !empty($email)) { // update the account if the email address is not used anymore $emailusers = qa_db_user_find_by_email($email); if (count($emailusers) == 0) { qa_db_user_set($userid, 'email', $email); $useraccount['email'] = $email; // to show on the page } } } $conf = qa_post_text('confirm'); $tourl = qa_post_text('to'); if ($conf) { $tourl = qa_post_text('to'); if (!empty($tourl)) { qa_redirect($tourl); } else { qa_redirect($tolink ? 'logins' : ''); } } // update the arrays $otherlogins = qa_db_user_login_find_other__open($userid, $findemail); $mylogins = qa_db_user_login_find_mine__open($userid); } // remove the current user id unset($otherlogins[$userid]); return $otherlogins; }
$searchmodules = qa_load_modules_with('search', 'index_page'); foreach ($searchmodules as $searchmodule) { $searchmodule->index_page($pageid, $inslug, $inheading, $incontent, 'html', $indextext); } } qa_db_page_move($pageid, substr($inposition, 0, 1), substr($inposition, 1)); $editpage = null; $reloadpages = true; } } if (qa_clicked('dosaveview') && empty($errors) && !$isexternal) { qa_redirect($inslug); } } if ($reloadpages) { qa_db_flush_pending_result('navpages'); $pages = qa_db_select_with_pending(qa_db_pages_selectspec()); } } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/pages_title'); $qa_content['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error(); if (isset($editpage)) { $positionoptions = array(); if (!$isexternal) { $positionoptions['_' . max(1, @$editpage['position'])] = qa_lang_html('admin/no_link'); } $navlangkey = array('B' => 'admin/before_main_menu', 'M' => 'admin/after_main_menu', 'O' => 'admin/opposite_main_menu', 'F' => 'admin/after_footer'); foreach ($navlangkey as $nav => $langkey) {