| 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';
require_once('functions.real_sentences_voting.php');
$real_sentences_voting_obj = new Real_sentences_voting();
//get max no. of voting count
$max_voting_count = $real_sentences_voting_obj->getMaxNoOfVotingCount();
if ( isset( $_POST['sentence_id_and_sugg_id'] ) ) {
$sentence_id_and_sugg_id = $_POST['sentence_id_and_sugg_id'];
$sentence_id_and_sugg_id_arr = explode( "_", $sentence_id_and_sugg_id );
$sentence_id = $sentence_id_and_sugg_id_arr[0];
$suggestion_id = $sentence_id_and_sugg_id_arr[1];
$user_id = $_SESSION['tm_id'];
if ( is_numeric($sentence_id) && $sentence_id > 0 && is_numeric($suggestion_id) && $suggestion_id > 0 ) {
//get success real sentence voting count for sentence
$success_voting_count = $real_sentences_voting_obj->get_success_rs_voting_count_by_sentence_id( $sentence_id );
//check success voting count less than maximum voting (11)
if ( $success_voting_count < $max_voting_count ) {
//get sentence count which user has not voted for sentence
$user_voting_count = $real_sentences_voting_obj->get_user_empty_vote_count_by_rs_sentence_id_and_user_id($sentence_id, $user_id);
//check if user not voted count is 1
if( $user_voting_count == 1 ) {
//apply user vote. update user vote for sentence suggestion to success
$resultUpdateS = $real_sentences_voting_obj->applySuccessUserVoteForRealSentenceSuggestion( $suggestion_id, $sentence_id, $user_id );
if ($resultUpdateS == true) {
//update voting started at date
$real_sentences_voting_obj->updateRealSentenceVotingStartedAtDate( $sentence_id );
//after submit again check success vote count for sentence
$success_voting_count2 = $real_sentences_voting_obj->get_success_rs_voting_count_by_sentence_id($sentence_id);
//get no. of success voting to single suggestion
$no_of_success_voting_to_single_suggestion = $real_sentences_voting_obj->getNoOfSuccessVotingToSingleSuggestion();
//get count - sentence has reached No. of Target Success Voting To a Particular Suggestion
$check_sentence_reached_no_of_success_voting_suggestion = $real_sentences_voting_obj->checkRealSentenceHasReachedNoOfSuccessVotesForSuggestion($sentence_id, $no_of_success_voting_to_single_suggestion);
//check count greater or equal to maximum voting count (11) or if any sentence suggestion got max no. of success voting (5) then return 1
if( $success_voting_count2 >= $max_voting_count || $check_sentence_reached_no_of_success_voting_suggestion >= 1 ) {
// Close Sentence for voting. Voting completed for sentence suggestion
$real_sentences_voting_obj->closeVotingForRealSentence( $sentence_id );
//get real sentences file id by sentence id
$real_sentences_file_id = $real_sentences_voting_obj->getRealSentencesFileId( $sentence_id );
if( $real_sentences_file_id > 0 ) {
//get total no. of sentences count by file id
$no_of_real_sentences_count = $real_sentences_voting_obj->getNoOfSentencesCountByFileId( $real_sentences_file_id );
//get total no. of closed sentences count by file id
$no_of_closed_real_sentences_count = $real_sentences_voting_obj->getNoOfClosedSentencesCountByFileId( $real_sentences_file_id );
//check total sentences and closed sentences count is equal
if( $no_of_real_sentences_count == $no_of_closed_real_sentences_count ) {
//update real sentences file is_closed status and update closed date and make file closed
$real_sentences_voting_obj->updateRealSentenceFileStatusToClose( $real_sentences_file_id );
}
}
}
$data['status'] = 200;
$data['msg'] = "Vote submitted successfully.";
} else {
$data['status'] = 300;
$data['msg'] = "Vote timed out took more than 5 mins";
}
} else {
$data['status'] = 300;
$data['msg'] = "You have already submitted vote for this suggestion.";
}
} else {
//make user vote failed.
$real_sentences_voting_obj->makeUserRealSentenceVoteFailedBySentenceIdAndUserId($sentence_id,$user_id);
$data['status'] = 300;
$data['msg'] = "This sentence has already reached " . $max_voting_count . " votes.<br> Please contribute on a new one.";
}
} else {
$data['status'] = 300;
$data['msg'] = "Something went wrong, Please try again.";
}
} else {
$data['status'] = 300;
$data['msg'] = "Something went wrong, Please try again.";
}
echo json_encode($data);