| Server IP : 64.202.187.69 / Your IP : 216.73.216.192 Web Server : Apache System : Linux 69.187.202.64.host.secureserver.net 3.10.0-1160.144.1.el7.tuxcare.els6.x86_64 #1 SMP Fri May 29 16:22:24 UTC 2026 x86_64 User : transmarket ( 1001) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/transmarket/translator/controllers/ |
Upload File : |
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
include 'connection.php';
$data = array();
$data['status'] = 300;
$offset = 0;
$user_id = $_SESSION['tm_id'];
//ini_set('display_errors',1);
//error_reporting(E_ALL);
require_once('functions.voting.php');
$voting_obj = new Voting();
require_once('functions.translators.php');
$translators_obj = new Translators();
require_once('functions.suggestions.php');
$suggestions_obj = new Suggestions();
if(isset($_POST['skip_id']) && $_POST['skip_id'] != '0') {
$skipped_sentence_id = base64_decode($_POST['skip_id']);
$skipped_reason_id = $_POST['skipped_reason_id'];
$suggested_text = $_POST['suggestion'];
//get user current level
$user_level = $translators_obj->getCurrentUserLevelByUserId( $user_id );
//insert skipped record in to skipped_sentence_suggestion_voting table
$voting_obj->saveSkippedSentenceSuggestionVoting($skipped_sentence_id,$user_id,$skipped_reason_id);
//save suggestion
$voting_obj->saveSentenceSuggestionMapAfterSkip($skipped_sentence_id,$user_id,$user_level,$suggested_text);
}
if (isset($_SESSION['tm_language_id']) && isset($_SESSION['tm_id'])) {
$category_id = $_SESSION['tm_language_id'];
if(isset($_POST['offset']))
$offset = $_POST['offset'];
// SQL for marking the voting failed if time more than 5 mins of submission
$voting_obj->makeVotingFailedMaxSubmitTimeOver();
//get user skipped voting sentence ids
$skipped_voting_sentence_ids = $voting_obj->getSkippedVotingSentenceIdsByUserID( $user_id );
//get sentence ids which has submitted 3 success suggestions
$success_sentence_ids = $voting_obj->getSuccessSuggestionsSentenceIds();
//Fetch sentence ids from tbl_sentence are ready to start for voting
$sentence_ids = $voting_obj->getSentenceIdsReadyToStartForVoting( $skipped_voting_sentence_ids, $success_sentence_ids, $category_id );
//checking currently assigned sentence for voting
$not_in_id_str = $voting_obj->getCurrentlyAssignedSentenceIdsForVoting( $global_max_voting_count );
//get user success suggestion sentence ids and whose voting are not closed yet [skip these sentence ids to vote]
$not_in_user_success_suggestion_sentence_ids = $suggestions_obj->getUserSuccessSuggestionsSentenceIdsByUserID( $user_id );
//Pick one sentence for voting
$result = $voting_obj->pickSentenceForVoting( $sentence_ids, $user_id, $not_in_id_str, $not_in_user_success_suggestion_sentence_ids );
if ($result->num_rows > 0) {
$data['status'] = 200;
while ($row = $result->fetch_object()) {
//get original message by id
$resultSentence = $voting_obj->getSentenceById( $row->sentence_id );
//get skipped sentence suggestion voting count which has skip reason
$skipped_sentence_suggestion_voting_count = $voting_obj->getSkippedSentenceSuggestionVotingReasonCount( $row->sentence_id );
if( $skipped_sentence_suggestion_voting_count >=3 ) {
//get skip vote and suggest, new translated suggestions by sentence id
$resultSuggestion = $voting_obj->getSkipVoteTranslatedNewSuggestionsBySentenceId( $row->sentence_id );
//process previous success voting to failed
$result_process_vote_failed = $voting_obj->processPreviousVotesToFailedBySentenceId( $row->sentence_id );
//process previous success suggestions to failed
$result_process_suggestions_failed = $voting_obj->processPreviousSuggestionsToFailedBySentenceId( $row->sentence_id );
//update suggestion pending started at date in tbl_sentence
$suggestions_obj->updateSentencePendingAtDate( $row->sentence_id );
//update voting started at date
$suggestions_obj->updateSentenceVotingStartedAtDate( $row->sentence_id );
} else {
// get original message's translation suggestions by sentence id
$resultSuggestion = $voting_obj->getTranslationSuggestionsBySentenceId( $row->sentence_id );
}
//get user empty vote count
$user_empty_vote_count = $voting_obj->get_user_empty_vote_count_by_sentence_id_and_user_id($row->sentence_id, $user_id);
//get remaining vote counts
//$get_remaining_vote_count = $voting_obj->getRemainingVotesCountBySentenceId($sentence_id,$global_max_voting_count);
//check user empty vote count
if( $user_empty_vote_count == 0 ) {
//Insert initial user vote entry into sentence_suggestion_voting_map table
$voting_obj->saveInitialUserVoteEntry( $row->sentence_id, $user_id, $global_voting_max_submit_time_mins );
}
$temp = array();
$data['suggestion'] = array();
$suggestion1 = array();
while ($rowSentence = $resultSentence->fetch_object()) {
$data['id'] = base64_encode($rowSentence->id);
$data['original_message'] = stripslashes($rowSentence->original_message);
}
while ($rowSuggestion = $resultSuggestion->fetch_object()) {
$suggestion = array();
$suggestion['suggestion_id'] = base64_encode($rowSuggestion->id);
$suggestion['translation_message'] = stripslashes($rowSuggestion->suggested_text);
array_push($data['suggestion'], $suggestion);
}
}
}
}
echo json_encode($data);