|
@@ -1,5 +1,8 @@
|
|
<?php
|
|
<?php
|
|
/* For license terms, see /license.txt */
|
|
/* For license terms, see /license.txt */
|
|
|
|
+
|
|
|
|
+use ChamiloSession as Session;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* This is the main script of the Card Game plugin.
|
|
* This is the main script of the Card Game plugin.
|
|
* It is loaded on every page through the inclusion of the plugin in the
|
|
* It is loaded on every page through the inclusion of the plugin in the
|
|
@@ -17,11 +20,8 @@ if (!api_is_anonymous()) {
|
|
|
|
|
|
$version = '?v=041';
|
|
$version = '?v=041';
|
|
$interface = 'localhost';
|
|
$interface = 'localhost';
|
|
-
|
|
|
|
$parsedUrl = parse_url($_SERVER['REQUEST_URI']);
|
|
$parsedUrl = parse_url($_SERVER['REQUEST_URI']);
|
|
-
|
|
|
|
$parsedUrlpath = $parsedUrl['path'];
|
|
$parsedUrlpath = $parsedUrl['path'];
|
|
-
|
|
|
|
$pluginPath = api_get_path(WEB_PLUGIN_PATH).'card_game/resources/';
|
|
$pluginPath = api_get_path(WEB_PLUGIN_PATH).'card_game/resources/';
|
|
|
|
|
|
$fh = '<script type="text/javascript" src="'.$pluginPath.'js/cardgame.js'.$version.'" ></script>';
|
|
$fh = '<script type="text/javascript" src="'.$pluginPath.'js/cardgame.js'.$version.'" ></script>';
|
|
@@ -36,7 +36,8 @@ if (!api_is_anonymous()) {
|
|
$user = api_get_user_info();
|
|
$user = api_get_user_info();
|
|
$userId = (int) $user['id'];
|
|
$userId = (int) $user['id'];
|
|
|
|
|
|
- if (!isset($_SESSION['cardgame'])) {
|
|
|
|
|
|
+ $cardGameSession = Session::read('cardgame');
|
|
|
|
+ if (!empty($cardGameSession)) {
|
|
if (isset($userId)) {
|
|
if (isset($userId)) {
|
|
$sqlCount = "SELECT access_date FROM plugin_card_game WHERE user_id = $userId";
|
|
$sqlCount = "SELECT access_date FROM plugin_card_game WHERE user_id = $userId";
|
|
$resultCount = Database::query($sqlCount)->rowCount();
|
|
$resultCount = Database::query($sqlCount)->rowCount();
|
|
@@ -46,7 +47,7 @@ if (!api_is_anonymous()) {
|
|
$sql = "INSERT INTO plugin_card_game (user_id, access_date, pan)
|
|
$sql = "INSERT INTO plugin_card_game (user_id, access_date, pan)
|
|
VALUES ($userId, DATE_ADD(CURDATE(), INTERVAL -1 DAY), 1);";
|
|
VALUES ($userId, DATE_ADD(CURDATE(), INTERVAL -1 DAY), 1);";
|
|
$resultInsert = Database::query($sql);
|
|
$resultInsert = Database::query($sql);
|
|
- $_SESSION['cardgame'] = 'havedeck';
|
|
|
|
|
|
+ Session::write('cardgame', 'havedeck');
|
|
} else {
|
|
} else {
|
|
// @todo change date call
|
|
// @todo change date call
|
|
$sqlDate = "SELECT access_date
|
|
$sqlDate = "SELECT access_date
|
|
@@ -56,15 +57,15 @@ if (!api_is_anonymous()) {
|
|
$resultDate = Database::query($sqlDate)->rowCount();
|
|
$resultDate = Database::query($sqlDate)->rowCount();
|
|
|
|
|
|
if ($resultDate == 0) {
|
|
if ($resultDate == 0) {
|
|
- $_SESSION['cardgame'] = 'havedeck';
|
|
|
|
|
|
+ Session::write('cardgame', 'havedeck');
|
|
$fh .= '<div id="havedeckcardgame" ></div>';
|
|
$fh .= '<div id="havedeckcardgame" ></div>';
|
|
} else {
|
|
} else {
|
|
- $_SESSION['cardgame'] = 'done';
|
|
|
|
|
|
+ Session::write('cardgame', 'done');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if ($_SESSION['cardgame'] == 'havedeck') {
|
|
|
|
|
|
+ if ($cardGameSession == 'havedeck') {
|
|
$fh .= '<div id="havedeckcardgame" ></div>';
|
|
$fh .= '<div id="havedeckcardgame" ></div>';
|
|
}
|
|
}
|
|
}
|
|
}
|