V0 : initial import
This commit is contained in:
34
ProserveAPI/htdocs/proserve/session/userleave.php
Normal file
34
ProserveAPI/htdocs/proserve/session/userleave.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// include database and object files
|
||||
include_once '../config/init.php'; // contains $db
|
||||
include_once '../config/error.php';
|
||||
include_once '../objects/db_participates.php';
|
||||
|
||||
// prepare user object
|
||||
$participation = new UserInGameSession($db);
|
||||
|
||||
// ensure sessionId and userId are passed in $_POST parameters
|
||||
if (isset($_POST['sessionId']))
|
||||
$participation->sessionId = $_POST['sessionId'];
|
||||
else trigger_error( missing_parameter_error("sessionId") );
|
||||
|
||||
if (isset($_POST['userId']))
|
||||
$participation->userId = $_POST['userId'];
|
||||
else trigger_error( missing_parameter_error("userId") );
|
||||
|
||||
if (isset($_POST['endStatus']))
|
||||
$participation->endStatus = $_POST['endStatus'];
|
||||
|
||||
// user leaves session
|
||||
if ($participation->userLeaves())
|
||||
{
|
||||
// update score and averages
|
||||
if ($participation->updateUserScores())
|
||||
{
|
||||
$participation_arr = $participation->getResultArray(true, "User_Left_OK");
|
||||
print_r(json_encode($participation_arr)); // OK
|
||||
}
|
||||
else trigger_error("Calculate_Score_Failed");
|
||||
}
|
||||
else trigger_error("Leave_Session_Failed");
|
||||
?>
|
||||
Reference in New Issue
Block a user