Fix bug with invitation state retrieving in widget.php

This commit is contained in:
Dmitriy Simushev 2013-05-24 12:40:58 +00:00
parent 3fc6218332
commit 644cec05cb

View File

@ -20,7 +20,6 @@ require_once('libs/invitation.php');
require_once('libs/operator.php'); require_once('libs/operator.php');
require_once('libs/track.php'); require_once('libs/track.php');
$invited = FALSE;
$operator = array(); $operator = array();
$response = array(); $response = array();
if (Settings::get('enabletracking') == '1') { if (Settings::get('enabletracking') == '1') {
@ -33,7 +32,6 @@ if (Settings::get('enabletracking') == '1') {
if (isset($_SESSION['visitorid']) if (isset($_SESSION['visitorid'])
&& preg_match('/^[0-9]+$/', $_SESSION['visitorid'])) { && preg_match('/^[0-9]+$/', $_SESSION['visitorid'])) {
// Session started. Track visitor // Session started. Track visitor
$invitation_state = invitation_state($_SESSION['visitorid']);
$visitorid = track_visitor($_SESSION['visitorid'], $entry, $referer); $visitorid = track_visitor($_SESSION['visitorid'], $entry, $referer);
$visitor = track_get_visitor_by_id($visitorid); $visitor = track_get_visitor_by_id($visitorid);
} else { } else {
@ -42,7 +40,6 @@ if (Settings::get('enabletracking') == '1') {
// Session not started but visitor exist in database. // Session not started but visitor exist in database.
// Probably third-party cookies disabled by the browser. // Probably third-party cookies disabled by the browser.
// Use tracking by local cookie at target site // Use tracking by local cookie at target site
$invitation_state = invitation_state($visitor['visitorid']);
$visitorid = track_visitor($visitor['visitorid'], $entry, $referer); $visitorid = track_visitor($visitor['visitorid'], $entry, $referer);
} else { } else {
// Start tracking session // Start tracking session
@ -62,6 +59,9 @@ if (Settings::get('enabletracking') == '1') {
$response['data']['user']['id'] = $visitor['userid']; $response['data']['user']['id'] = $visitor['userid'];
} }
// Get invitation state
$invitation_state = invitation_state($visitorid);
// Check if invitation closed // Check if invitation closed
if (! $invitation_state['invited'] if (! $invitation_state['invited']
&& ! empty($_SESSION['invitation_threadid']) && ! empty($_SESSION['invitation_threadid'])
@ -102,7 +102,6 @@ if (Settings::get('enabletracking') == '1') {
} }
// Check if visitor reject invitation // Check if visitor reject invitation
$invitation_state = invitation_state($visitorid);
if ($invitation_state['invited'] && ! empty($_GET['invitation_rejected'])) { if ($invitation_state['invited'] && ! empty($_GET['invitation_rejected'])) {
invitation_reject($visitorid); invitation_reject($visitorid);
} }