本文整理汇总了PHP中SessionManager::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::getInstance方法的具体用法?PHP SessionManager::getInstance怎么用?PHP SessionManager::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionManager
的用法示例。
在下文中一共展示了SessionManager::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
if (SessionManager::getInstance()->isAdmin()) {
$aid = SessionManager::getInstance()->getAdminID();
$admin = DBManager::getInstance()->getAdmin($aid);
$this->isGlobalAdmin = $admin['isGlobalAdmin'];
$this->adminGroups = DBManager::getInstance()->getAdminGroupsByAdminID($aid);
$this->servers = DBManager::getInstance()->getAdminGroupServersByAdminId($aid);
$this->perms = array();
foreach ($this->adminGroups as $group) {
foreach ($group['adminOnServers'] as $serverId) {
foreach ($group['perms'] as $perm => $value) {
if ($perm != 'serverID' && $perm != 'groupID') {
if (!isset($this->perms[$serverId])) {
$this->perms[$serverId] = array();
}
$this->perms[$serverId][$perm] = $value;
}
}
}
}
} else {
$this->isGlobalAdmin = false;
$this->perms = DBManager::$defaultAdminGroupPerms;
$this->servers = array();
}
}
示例2: showConnectedProfiles
private function showConnectedProfiles()
{
$output = '<div class="clearfix networks">';
$facebookLoginUrl = SessionManager::getInstance()->getFacebook()->getLoginUrl(array('redirect_uri' => APP_URL . '/' . Content::l() . '/login/facebookcallback/' . Content::l() . '/settings/', 'scope' => 'publish_stream'));
$linkedInLoginUrl = APP_URL . '/' . Content::l() . '/login/linkedin/' . Content::l() . '/settings/';
$twitterLoginUrl = APP_URL . '/' . Content::l() . '/login/twitter/' . Content::l() . '/settings/';
// Facebook
$output .= '<div class="clearfix">';
if ($this->userDetails['facebook_access_token']) {
$output .= '<a href="' . $facebookLoginUrl . '" id="loginFacebook" class="ir loggedIn">Facebook</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=Facebook" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'Facebook', Content::c()->settings->disconnect) . '</a>';
} else {
$output .= '<a href="' . $facebookLoginUrl . '" id="loginFacebook" class="ir">Facebook</a>' . '<a href="' . $facebookLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'Facebook', Content::c()->settings->connect) . '</a>';
}
// LinkedIn
$output .= '</div><div class="clearfix">';
if ($this->userDetails['linkedin_access_token']) {
$output .= '<a href="' . $linkedInLoginUrl . '" id="loginLinkedIn" class="ir loggedIn">LinkedIn</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=LinkedIn" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'LinkedIn', Content::c()->settings->disconnect) . '</a>';
} else {
$output .= '<a href="' . $linkedInLoginUrl . '" id="loginLinkedIn" class="ir">LinkedIn</a>' . '<a href="' . $linkedInLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'LinkedIn', Content::c()->settings->connect) . '</a>';
}
// Twitter
$output .= '</div><div class="clearfix">';
if ($this->userDetails['twitter_access_token']) {
$output .= '<a href="' . $twitterLoginUrl . '" id="loginTwitter" class="ir loggedIn">Twitter</a>' . '<a href="/' . Content::l() . '/ajax/disconnect/?network=Twitter" class="disconnect">' . str_replace('SOCIAL_NETWORK_NAME', 'Twitter', Content::c()->settings->disconnect) . '</a>';
} else {
$output .= '<a href="' . $twitterLoginUrl . '" id="loginTwitter" class="ir">Twitter</a>' . '<a href="' . $twitterLoginUrl . '" class="connect">' . str_replace('SOCIAL_NETWORK_NAME', 'Twitter', Content::c()->settings->connect) . '</a>';
}
$output .= '</div></div>';
return $output;
}
示例3: __construct
public function __construct()
{
session_start();
header('Content-type: text/json');
// Get the website user
$userId = SessionManager::getInstance()->getUserId();
// Make sure a user is logged in
if (empty($userId)) {
Debug::l('No user logged in');
$json['result'] = 'false';
echo json_encode($json);
exit;
}
// Validate input
if (empty($_POST['email']) || !filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)) {
Debug::l('Invalid email');
$json['result'] = 'false';
echo json_encode($json);
exit;
}
// Update email address
$db = Database::getInstance();
$sth = $db->prepare('UPDATE person SET email = :email WHERE id = :id');
$sth->execute(array(':email' => $_POST['email'], ':id' => $userId));
$json['result'] = 'true';
echo json_encode($json);
}
示例4: __construct
public function __construct()
{
// Delete the cached friends. The user might be logging out to try to refresh the friend list
$userId = SessionManager::getInstance()->getUserId();
if (isset($userId)) {
$db = Database::getInstance();
$sth = $db->prepare('DELETE FROM temp_friends WHERE facebook_id=(SELECT id FROM facebook WHERE person_id = :person_id) OR linkedin_id=(SELECT id FROM linkedin WHERE person_id = :person_id) OR twitter_id=(SELECT id FROM twitter WHERE person_id = :person_id)');
$sth->execute(array(':person_id' => $userId));
}
// Clear website session
setcookie('PHPSESSID', '', time() - 3600);
session_destroy();
}
示例5: loadProfiles
private function loadProfiles($person, $personIsUser)
{
$profiles = array();
if (!empty($person['facebook_access_token']) && (!$personIsUser || $this->mergeNetwork != 'Facebook')) {
try {
//$params = array('access_token' => $user['facebook_access_token']);
$facebookProfile = SessionManager::getInstance()->getFacebook()->api('/' . $person['facebook_id']);
} catch (FacebookApiException $e) {
Debug::l('Error loading Facebook profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e);
}
if (isset($facebookProfile)) {
$profiles[] = '<a href="' . $facebookProfile['link'] . '" target="_blank" class="profile"><img src="https://graph.facebook.com/' . $person['facebook_id'] . '/picture?type=square" /> ' . $facebookProfile['name'] . ' on Facebook</a>';
}
}
if (!empty($person['linkedin_access_token']) && (!$personIsUser || $this->mergeNetwork != 'LinkedIn')) {
$API_CONFIG = array('appKey' => LI_API_KEY, 'appSecret' => LI_SECRET, 'callbackUrl' => '');
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$OBJ_linkedin->setTokenAccess(unserialize($person['linkedin_access_token']));
try {
$linkedInProfile = $OBJ_linkedin->profile('id=' . $person['linkedin_id'] . ':(first-name,last-name,public-profile-url,picture-url)');
} catch (ErrorException $e) {
Debug::l('Error loading LinkedIn profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e);
}
if ($linkedInProfile['success'] === TRUE) {
$linkedInProfile['linkedin'] = new SimpleXMLElement($linkedInProfile['linkedin']);
if ($linkedInProfile['linkedin']->getName() == 'person') {
$li_pr = (string) $linkedInProfile['linkedin']->{'public-profile-url'};
$li_pi = (string) $linkedInProfile['linkedin']->{'picture-url'};
$li_fn = (string) $linkedInProfile['linkedin']->{'first-name'};
$li_ln = (string) $linkedInProfile['linkedin']->{'last-name'};
$profiles[] = '<a href="' . $li_pr . '" target="_blank" class="profile"><img src="' . $li_pi . '" /> ' . $li_fn . ' ' . $li_ln . ' on LinkedIn</a>';
}
}
}
if (!empty($person['twitter_access_token']) && ($personIsUser || $this->mergeNetwork != 'Twitter')) {
try {
$twitterAccessToken = unserialize($person['twitter_access_token']);
$twitter = new TwitterOAuth(TW_CONSUMER, TW_SECRET, $twitterAccessToken['oauth_token'], $twitterAccessToken['oauth_token_secret']);
$twitter->format = 'json';
$twitterProfile = $twitter->get('users/show', array('user_id' => $person['twitter_id']));
} catch (ErrorException $e) {
Debug::l('Error loading Twitter profile for ' . ($personIsUser ? 'current' : 'other') . ' user. ' . $e);
}
if (isset($twitterProfile)) {
$profiles[] = '<a href="http://twitter.com/' . $twitterProfile->screen_name . '" target="_blank" class="profile"><img src="' . $twitterProfile->profile_image_url . '" /> @' . $twitterProfile->screen_name . ' on Twitter</a>';
}
}
return $profiles;
}
示例6: hasAction
public function hasAction($ch_action)
{
$ch_modulo = strtolower(Zend_Controller_Front::getInstance()->getRequest()->getModuleName());
$ch_controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
$ch_action = $ch_action;
$session = SessionManager::getInstance();
$id_usuario = $session->get('id_usuario');
$usuario = new Usuario();
if (!$this->config->inProduction() && $usuario->isRoot($id_usuario)) {
$this->verificarAcao($ch_modulo, $ch_controller, $ch_action);
}
$action = new Action();
$permission = $action->getActionPermissao($ch_modulo, $ch_controller, $ch_action);
return $permission || $usuario->isRoot($id_usuario);
}
示例7: __construct
public function __construct()
{
$this->defaultLanguage = SettingsManager::getInstance()->getDefaultLanguage();
// get lang setting from URL param, session or use default
if (!empty($_GET['lang'])) {
$this->language = $_GET['lang'];
} elseif (($ses_lang = SessionManager::getInstance()->getLanguage()) != null) {
$this->language = $ses_lang;
} else {
$this->language = $this->defaultLanguage;
}
$txt = array();
// Parse Main lang file
eval(self::parseLanguageFile($this->language));
// Parse Section lang file
eval(self::parseLanguageFile($this->language, HelperFunctions::getActiveSection()));
// Parse Page lang file (if exists)
eval(self::parseLanguageFile($this->language, HelperFunctions::getActiveSection(), HelperFunctions::getActivePage()));
$this->text = $txt;
}
示例8: __construct
public function __construct()
{
session_start();
// Connect to the database
$this->db = Database::getInstance();
// Get the website user
$userId = SessionManager::getInstance()->getUserId();
if (empty($userId)) {
Debug::l('No user logged in');
header('Location: ' . APP_URL . '/' . Content::l() . '/');
exit;
}
// Get the introduction that hasn't been sent yet
$this->introductionQ = $this->db->prepare('SELECT id, introducee1_id, introducee2_id, introducee1_notified, introducee2_notified, link_password FROM introduction WHERE introducer_id = :id AND (introducee1_notified IS NULL OR introducee2_notified IS NULL) ORDER BY time DESC LIMIT 1');
$this->introductionQ->execute(array(':id' => $userId));
$this->introduction = $this->introductionQ->fetch(PDO::FETCH_ASSOC);
if (empty($this->introduction)) {
Debug::l('No unsent introductions found');
header('Location: ' . APP_URL . '/' . Content::l() . '/');
exit;
}
$introducee1 = new Person(array());
$introducee1->getDataFromId($this->introduction['introducee1_id']);
$introducee2 = new Person(array());
$introducee2->getDataFromId($this->introduction['introducee2_id']);
// Notify introducee 1
if (empty($this->introduction['introducee1_notified'])) {
$notifyManager = new NotifyManager($this->introduction['id'], $introducee1, $introducee2);
$updateQ = $this->db->prepare('UPDATE introduction SET introducee1_notified = :method WHERE id = :id');
$this->notifyPerson($notifyManager, $introducee1, $updateQ);
}
// Notify introducee 2
if (empty($this->introduction['introducee2_notified'])) {
$notifyManager = new NotifyManager($this->introduction['id'], $introducee2, $introducee1);
$updateQ = $this->db->prepare('UPDATE introduction SET introducee2_notified = :method WHERE id = :id');
$this->notifyPerson($notifyManager, $introducee2, $updateQ);
}
$base62 = BaseConvert::base10ToBase62($this->introduction['id']);
// Redirect to introduction page
header('Location: ' . APP_URL . '/' . Content::l() . '/A' . $this->introduction['link_password'] . $base62);
}
示例9: __construct
public function __construct()
{
session_start();
// Connect to the database
$this->db = Database::getInstance();
// Get the website user
$this->userId = SessionManager::getInstance()->getUserId();
if (!empty($this->userId)) {
$userDetailsQ = $this->db->prepare('SELECT f.id as facebook_id, f.access_token as facebook_access_token, l.id as linkedin_id, l.access_token as linkedin_access_token, t.id as twitter_id, t.access_token as twitter_access_token FROM person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE p.id = :id');
$userDetailsQ->execute(array(':id' => $this->userId));
$this->userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
}
$this->facebookLoginUrl = SessionManager::getInstance()->getFacebook()->getLoginUrl(array('redirect_uri' => APP_URL . '/' . Content::l() . '/login/facebookcallback/', 'scope' => 'publish_stream, offline_access'));
$top = new Top('', 'homePage');
echo $top->getOutput();
echo '<div id="preloaderFriends" style="display: none;">' . Content::c()->home->loading . '</div>' . '<div id="info">' . '<p>' . Content::c()->home->desc . '</p>' . '</div>' . '<div id="formLogin" class="clearfix">' . '<p>' . Content::c()->introduce->login . '</p>' . '<a href="' . $this->facebookLoginUrl . '" id="loginFacebook" class="ir' . (!empty($this->userDetails['facebook_access_token']) ? ' loggedIn' : '') . '">Facebook</a>' . '<a href="/' . Content::l() . '/login/linkedin/" id="loginLinkedIn" class="ir' . (!empty($this->userDetails['linkedin_access_token']) ? ' loggedIn' : '') . '">LinkedIn</a>' . '<a href="/' . Content::l() . '/login/twitter/" id="loginTwitter" class="ir' . (!empty($this->userDetails['twitter_access_token']) ? ' loggedIn' : '') . '">Twitter</a>' . '<p id="loginFirst">' . Content::c()->introduce->login_here_first . '</p>' . '</div>' . '<form id="formIntroduce" class="clearfix" novalidate="novalidate" autocomplete="off">' . '<div class="friendSelector introduceeInput1">' . '<label for="introducee1">' . Content::c()->introduce->introduce . '</label>' . '<input type="text" id="introducee1" placeholder="' . Content::c()->introduce->enter_name . '" />' . '<ul class="filteredFriends"></ul>' . '</div>' . '<div class="friendSelector introduceeInput2">' . '<label for="introducee2">' . Content::c()->introduce->with . '</label>' . '<input type="text" id="introducee2" placeholder="' . Content::c()->introduce->enter_name . '" />' . '<ul class="filteredFriends"></ul>' . '</div>' . '<label for="message">' . Content::c()->introduce->why . '</label>' . '<textarea id="message" placeholder="' . Content::c()->introduce->message . '"></textarea>' . '<input id="submitIntroduce" class="button" type="submit" value="' . Content::c()->introduce->submit . '" />' . '<a href="/' . Content::l() . '/about/" class="help">' . Content::c()->introduce->help . '</a>' . '</form>';
if (!empty($this->userId)) {
echo $this->previousIntroductions();
}
$script = '<script>' . 'var introduceme = (function (module) {' . 'module.content = module.content || {};' . 'module.content.loginFirst = "' . Content::c()->introduce->login_first . '";' . 'module.personId = ' . (!empty($this->userId) ? '"' . $this->userId . '"' : 'null') . ';' . 'module.facebookId = ' . (!empty($this->userDetails['facebook_access_token']) ? '"' . $this->userDetails['facebook_id'] . '"' : 'null') . ';' . 'module.linkedInId = ' . (!empty($this->userDetails['linkedin_access_token']) ? '"' . $this->userDetails['linkedin_id'] . '"' : 'null') . ';' . 'module.twitterId = ' . (!empty($this->userDetails['twitter_access_token']) ? '"' . $this->userDetails['twitter_id'] . '"' : 'null') . ';' . 'return module;' . '}(introduceme || {}));' . '</script>';
$bottom = new Bottom($script);
echo $bottom->getOutput();
}
示例10: __construct
public function __construct()
{
session_start();
// Get the website user
$userId = SessionManager::getInstance()->getUserId();
// Require logged in user
if (!isset($userId)) {
Debug::l('No user logged in');
header('Location: ' . APP_URL . '/' . Content::l() . '/settings/');
exit;
}
// Make sure the network param is valid
if (empty($_GET['network']) || !in_array($_GET['network'], array('Facebook', 'LinkedIn', 'Twitter'))) {
Debug::l('Bad network param');
header('Location: ' . APP_URL . '/' . Content::l() . '/settings/');
exit;
}
// Connect to the database
$db = Database::getInstance();
// Remove the network
switch ($_GET['network']) {
case 'Facebook':
$update = $db->prepare('UPDATE facebook SET access_token="" WHERE person_id = :person_id');
$update->execute(array(':person_id' => $userId));
break;
case 'LinkedIn':
$update = $db->prepare('UPDATE linkedin SET access_token="" WHERE person_id = :person_id');
$update->execute(array(':person_id' => $userId));
break;
case 'Twitter':
$update = $db->prepare('UPDATE twitter SET access_token="" WHERE person_id = :person_id');
$update->execute(array(':person_id' => $userId));
break;
}
header('Location: ' . APP_URL . '/' . Content::l() . '/settings/');
}
示例11:
<div id="menu">
<ul>
<?php
if (!SessionManager::getInstance()->isAdmin()) {
?>
<li<?php
if (HelperFunctions::getActivePage() == 'login') {
echo ' class="active"';
}
?>
>
<a href="./?page=login">Login</a>
</li>
<?php
} else {
HelperFunctions::echoMenuEntry('meta');
HelperFunctions::echoMenuEntry('server');
if (PermissionManager::getInstance()->serverCanEditAdmins()) {
HelperFunctions::echoMenuEntry('admins');
}
HelperFunctions::echoMenuEntry('logout');
?>
<li style="height:10px; font-size:10px; line-height:10px; margin-top:10px; border-bottom:black;">Back to…</li>
<?php
}
?>
<li><a href="../user/"><-- User</a></li>
</ul>
</div>
示例12: echoMenuEntry
<div id="topline">
<div id="menu">
<ul>
<?php
function echoMenuEntry($link, $textIndex)
{
echo '<li><a href="' . $link . '">' . tr($textIndex) . '</a></li>';
}
echoMenuEntry('./', 'home');
if (!SessionManager::getInstance()->isUser()) {
echoMenuEntry('./?page=login', 'login');
echoMenuEntry('./?page=register', 'register');
} else {
echoMenuEntry('./?page=profile', 'profile');
echoMenuEntry('./?page=logout', 'logout');
}
if (SettingsManager::getInstance()->isShowAdminLink()) {
echoMenuEntry('../admin/', 'admin_area');
}
?>
</ul>
</div>
<?php
if (isset($_SESSION['userid'])) {
printf(tr('welcome_user'), ServerInterface::getInstance()->getUserName($_SESSION['serverid'], $_SESSION['userid']));
} else {
echo tr('welcome_guest');
}
?>
</div>
示例13: error_reporting
require_once MUMPHPI_MAINDIR . '/classes/PermissionManager.php';
if (SettingsManager::getInstance()->isDebugMode()) {
error_reporting(E_ALL);
}
// Check for running Ice with Murmur
try {
ServerInterface::getInstance();
} catch (Ice_UnknownLocalException $ex) {
MessageManager::addError(tr('error_noIce'));
MessageManager::echoAll();
exit;
}
if (!SessionManager::getInstance()->isAdmin() && HelperFunctions::getActivePage() != 'login') {
header('Location: ?page=login');
exit;
} elseif (SessionManager::getInstance()->isAdmin() && isset($_GET['ajax'])) {
require_once MUMPHPI_MAINDIR . '/ajax/admin.ajax.php';
// TODO: this should probably have a check, whether the function exists
if (is_callable('Ajax_Admin::' . $_GET['ajax'])) {
eval('Ajax_Admin::' . $_GET['ajax'] . '();');
}
MessageManager::echoAll();
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title><?php
示例14: catch
<?php
$isLoggedIn = SessionManager::getInstance()->isAdmin();
if ($isLoggedIn) {
echo 'You are already logged in!';
echo 'Were you looking for <a href="./?page=logout">logout</a>?';
} else {
if (isset($_GET['action']) && $_GET['action'] == 'dologin') {
// parse and handle login form data
try {
SessionManager::getInstance()->loginAsAdmin($_POST['username'], $_POST['password']);
$isLoggedIn = true;
echo '<script type="text/javascript">location.replace("?page=meta")</script>';
echo 'Login successfull.<br/>
Go on to the <a href="?page=meta">Meta Page</a>.';
} catch (Exception $exc) {
echo '<div class="infobox infobox_error">Login failed.</div>';
}
}
if (!$isLoggedIn) {
// display login form
if (!DBManager::getInstance()->doesAdminExist()) {
echo '<div class="infobox infobox_info">';
echo 'No admin Account exists yet.<br/>';
echo 'To create an account, <b>just log in with your desired login-credentials</b>. The account will automatically created for you!<br/><br/>';
echo 'If you experience problems and the account is not created for you, please check that your webserver has write permissions to the data folder.';
echo '</div>';
}
?>
<form class="mpi_login_form" action="?page=login&action=dologin" method="post" onsubmit="
if (jQuery('#mpi_login_username').attr('value').length == 0) {alert('You did not enter a username!'); return false;}
示例15: __construct
public function __construct()
{
session_start();
$db = Database::getInstance();
if (empty($_SESSION['mergeOtherAccount']) || empty($_SESSION['mergeNetwork'])) {
Debug::l('Error merging account: missing session vars');
header('Location: ' . APP_URL . '/' . Content::l() . '/');
exit;
}
$mergeOtherAccount = $_SESSION['mergeOtherAccount'];
$mergeNetwork = $_SESSION['mergeNetwork'];
// Get the website user
$userId = SessionManager::getInstance()->getUserId();
// Require logged in user
if (empty($userId)) {
Debug::l('Error merging account: No logged in user');
header('Location: ' . APP_URL . '/' . Content::l() . '/');
exit;
}
// Get user details
$userDetailsQ = $db->prepare('SELECT p.email, f.id as facebook_id, f.access_token as facebook_access_token, l.id as linkedin_id, l.access_token as linkedin_access_token, t.id as twitter_id, t.access_token as twitter_access_token FROM person p LEFT JOIN facebook f ON p.id = f.person_id LEFT JOIN linkedin l ON p.id = l.person_id LEFT JOIN twitter t ON p.id = t.person_id WHERE p.id = :id');
$userDetailsQ->execute(array(':id' => $userId));
$userDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
// Get merging account details
$mergeId = $_SESSION['mergeOtherAccount'];
$userDetailsQ->execute(array(':id' => $mergeId));
$mergeDetails = $userDetailsQ->fetch(PDO::FETCH_ASSOC);
// Start the merge
$update = $db->prepare('UPDATE link SET person_id = :new_id WHERE person_id = :old_id');
$update->execute(array(':new_id' => $userId, ':old_id' => $mergeId));
$update = $db->prepare('UPDATE message SET writer_id = :new_id WHERE writer_id = :old_id');
$update->execute(array(':new_id' => $userId, ':old_id' => $mergeId));
$update = $db->prepare('UPDATE introduction SET introducer_id = :new_id WHERE introducer_id = :old_id');
$update->execute(array(':new_id' => $userId, ':old_id' => $mergeId));
$update = $db->prepare('UPDATE introduction SET introducee1_id = :new_id WHERE introducee1_id = :old_id');
$update->execute(array(':new_id' => $userId, ':old_id' => $mergeId));
$update = $db->prepare('UPDATE introduction SET introducee2_id = :new_id WHERE introducee2_id = :old_id');
$update->execute(array(':new_id' => $userId, ':old_id' => $mergeId));
if (empty($userDetails['email']) && !empty($mergeDetails['email'])) {
$update = $db->prepare('UPDATE person SET email = :email WHERE id = :id');
$update->execute(array(':id' => $userId, ':email' => $mergeDetails['email']));
}
if (empty($userDetails['facebook_access_token']) && !empty($mergeDetails['facebook_access_token']) || empty($userDetails['facebook_id']) && !empty($mergeDetails['facebook_id'])) {
// Copy the Facebook profile from the merge account, cascading down to the temp tables
$delete = $db->prepare('DELETE FROM facebook WHERE person_id = :new_id');
$delete->execute(array(':new_id' => $userId));
$update = $db->prepare('UPDATE facebook SET person_id = :new_id WHERE person_id = :old_id');
$update->execute(array(':new_id' => $userId, ':old_id' => $mergeId));
}
if (empty($userDetails['linkedin_access_token']) && !empty($mergeDetails['linkedin_access_token']) || empty($userDetails['linkedin_id']) && !empty($mergeDetails['linkedin_id'])) {
// Copy the LinkedIn profile from the merge account, cascading down to the temp tables
$delete = $db->prepare('DELETE FROM linkedin WHERE person_id = :new_id');
$delete->execute(array(':new_id' => $userId));
$update = $db->prepare('UPDATE linkedin SET person_id = :new_id WHERE person_id = :old_id');
$update->execute(array(':new_id' => $userId, ':old_id' => $mergeId));
}
if (empty($userDetails['twitter_access_token']) && !empty($mergeDetails['twitter_access_token']) || empty($userDetails['twitter_id']) && !empty($mergeDetails['twitter_id'])) {
// Copy the Twitter profile from the merge account, cascading down to the temp tables
$delete = $db->prepare('DELETE FROM twitter WHERE person_id = :new_id');
$delete->execute(array(':new_id' => $userId));
$update = $db->prepare('UPDATE twitter SET person_id = :new_id WHERE person_id = :old_id');
$update->execute(array(':new_id' => $userId, ':old_id' => $mergeId));
}
$delete = $db->prepare('DELETE FROM person WHERE id = :old_id');
$delete->execute(array(':old_id' => $mergeId));
unset($_SESSION['mergeOtherAccount']);
unset($_SESSION['mergeNetwork']);
// Redirect to home page
$_SESSION['connectedWithNewNetwork'] = $mergeNetwork;
header('Location: ' . APP_URL . '/' . Content::l() . '/');
}