function __construct($id = 0, $is_view_results = "no", $question_sort = "poll_order", $question_sort_rule = "ASC", $answer_sort = "question_order", $answer_sort_rule = "ASC") { if ($id instanceof YOP_POLL_Abstract_Model) { $this->init($id->data, $is_view_results, $question_sort, $question_sort_rule, $answer_sort, $answer_sort_rule); return; } elseif (is_object($id)) { $this->init($id, $is_view_results, $question_sort, $question_sort_rule, $answer_sort, $answer_sort_rule); return; } if (!empty($id) && !is_numeric($id)) { $id = 0; } if ($id == "-3") { $filters = array(); $filters[] = array('field' => 'poll_type', 'value' => 'poll', 'operator' => '='); $filters[] = array('field' => 'poll_start_date', 'value' => current_time('mysql'), 'operator' => '<='); $args = array('return_fields' => 'ID ', 'filters' => $filters, 'search' => array(), 'orderby' => "poll_start_date", 'order' => 'DESC'); $total_polls = Yop_Poll_Model::get_polls_filter_search($args); $ok = 0; $current_date = yop_poll_get_mysql_curent_date(); if (count($total_polls) > 1) { while ($ok == 0) { $id = rand(1, count($total_polls)); $poll = new YOP_POLL_Poll_Model($id); if ($current_date <= convert_date($poll->poll_end_date, 'Y-m-d H:i:s')) { $ok = 1; } } } else { $id = rand(1, count($total_polls)); } } if ($id == "-2") { $filters = array(); $filters[] = array('field' => 'poll_type', 'value' => 'poll', 'operator' => '='); $filters[] = array('field' => 'poll_start_date', 'value' => current_time('mysql'), 'operator' => '<='); $args = array('return_fields' => 'ID ', 'filters' => $filters, 'search' => array(), 'orderby' => "poll_date", 'order' => 'ASC'); $total_polls = Yop_Poll_Model::get_polls_filter_search($args); $id = $total_polls[count($total_polls) - 1]['ID']; } if ($id == "-1") { $poll = self::get_current_active_poll(); $id = $poll['ID']; } $data = self::get_data_by('id', $id); if ($data) { $this->init($data, $is_view_results, $question_sort, $question_sort_rule, $answer_sort, $answer_sort_rule); } else { $this->default_init(); } $this->poll_start_date = convert_date($this->poll_start_date, "Y-m-d H:i:s"); $this->poll_end_date = convert_date($this->poll_end_date, "Y-m-d H:i:s"); }
private function view_results() { wp_enqueue_script('yop-poll-results-votes-js', YOP_POLL_URL . '/js/polls/yop-poll-results-votes.js', array('jquery', 'jquery-ui-resizable'), YOP_POLL_VERSION, true); //self::yop_poll_get_percentages_for_age_gender_charts(); $index = 1; $data['title'] = __yop_poll("Results"); $data['poll_id'] = isset($_GET['id']) ? intval($_GET['id']) : 0; $data['results_order_by'] = isset($_GET['results_order_by']) ? $_GET['results_order_by'] : 'id'; $data['results_order'] = isset($_GET['results_order']) ? $_GET['results_order'] : 'ASC'; $data['soav'] = isset($_GET['soav']) ? $_GET['soav'] : 'no'; $data['a'] = isset($_GET['a']) ? $_GET['a'] : 'no'; $current_poll = new YOP_POLL_Poll_Model($data['poll_id'], $is_view_results = "no", $question_sort = "poll_order", $question_sort_rule = "ASC", $answer_sort = $data['results_order_by'], $answer_sort_rule = $data['results_order']); $data['poll_details'] = array('name' => $current_poll->poll_title, 'question' => $current_poll->questions); if ('yes' == $data['soav']) { $data['display_other_answers_values'] = true; } else { $data['display_other_answers_values'] = false; } $percentages = array(); $total_votes = array(); $i = 0; foreach ($current_poll->questions as $question) { $total_votes[$i] = 0; foreach ($question->answers as $answer) { $total_votes[$i] += floatval($answer->votes); } $i++; } $i = 0; foreach ($current_poll->questions as $question) { foreach ($question->answers as $answer) { if ($answer->votes > 0) { $answer->status = round($answer->votes * 100 / $total_votes[$i], 1); } else { $percentages[$i][] = 0; $answer->status = 0; } } $i++; } $data['cf_sdate'] = isset($_GET['cf_sdate']) ? $_GET['cf_sdate'] : ''; $data['cf_edate'] = isset($_GET['cf_edate']) ? $_GET['cf_edate'] : ''; $data['title'] = "Results"; $data['custom_fields'] = array(); foreach ($current_poll->questions as $question) { $data['cf_per_page'] = isset($_REQUEST['cf_per_page']) ? intval($_REQUEST['cf_per_page']) : 100; $data['cf_page_no'] = isset($_REQUEST['cf_page_no']) ? (int) $_REQUEST['cf_page_no'] : 1; $poll_custom_fields = self::get_poll_customfields($data['poll_id'], $question->ID); $custom_fields_logs = self::get_poll_customfields_logs($data['poll_id'], $question->ID, 'vote_id', 'asc', ($data['cf_page_no'] - 1) * $data['cf_per_page'], $data['cf_per_page'], $data['cf_sdate'], $data['cf_edate']); unset($column_custom_fields_ids); foreach ($poll_custom_fields as $custom_field) { $column_custom_fields_ids[] = $custom_field['ID']; } if (count($custom_fields_logs) > 0) { foreach ($custom_fields_logs as &$logs) { foreach ($column_custom_fields_ids as $custom_field_id) { $vote_log_values = array(); $vote_logs = explode('<#!,>', $logs['vote_log']); if (count($vote_logs) > 0) { foreach ($vote_logs as $vote_log) { $temp = explode('<#!->', $vote_log); $vote_log_values[$temp[1]] = stripslashes($temp[0]); } } } $custom_fields_logs_details[] = array('vote_id' => $logs['vote_id'], "tr_id" => $logs['tr_id'], "vote_date" => $logs['vote_date'], "custom_fields_value" => $vote_log_values, 'column_custom_fields_ids' => $column_custom_fields_ids); } } $data['total_custom_fields_logs'] = self::get_poll_total_customfields_logs($data['poll_id'], $question->ID, $data['cf_sdate'], $data['cf_edate']); $data['total_custom_fields_logs_pages'] = ceil($data['total_custom_fields_logs'] / $data['cf_per_page']); $data['column_custom_fields_ids'] = array(); if (intval($data['cf_page_no']) > intval($data['total_custom_fields_logs_pages'])) { $data['cf_page_no'] = 1; } $data['cf_args'] = array('base' => remove_query_arg('cf_page_no', $_SERVER['REQUEST_URI']) . '%_%', 'format' => '&cf_page_no=%#%', 'total' => $data['total_custom_fields_logs_pages'], 'current' => max(1, $data['cf_page_no']), 'prev_next' => true, 'prev_text' => __yop_poll('« Previous'), 'next_text' => __yop_poll('Next »')); $data['cf_pagination'] = paginate_links($data['cf_args']); $chart_answer[$index][0][] = "Answer"; $i = 1; $chart_answer[$index][0][] = "Votes"; foreach ($question->answers as $answer) { if ($answer->type == "other" && $data['display_other_answers_values'] == 1 || $answer->type != "other") { if ($answer->description == "") { $chart_answer[$index][$i][0] = $answer->answer; } else { $chart_answer[$index][$i][0] = $answer->description; } $chart_answer[$index][$i][1] = (int) $answer->votes; $i++; } } $question_detail[] = array('other_answer' => $question->other_answers_label, 'name' => $question->question, 'answers' => $question->answers, 'custom_fields' => self::get_poll_customfields($data['poll_id'], $question->ID), 'custom_fields_logs_details' => $custom_fields_logs_details, 'q_id' => $question->ID, 'total_custom_fields_logs' => $data['total_custom_fields_logs'], 'cf_pagination' => $data['cf_pagination']); //yop_poll_dump($question_detail); $data['questions_details'] = $question_detail; unset($custom_fields_logs_details); unset($column_custom_fields_ids); $index++; } wp_localize_script('yop-poll-results-votes-js', 'charts_answer', $chart_answer); $data['total_logs_other_answers'] = 0; foreach ($current_poll->questions as $question) { foreach ($question->answers as $other_answer) { if ($other_answer->type == 'other') { $data['total_logs_other_answers']++; } } } $countries = self::yop_poll_get_country_date_by_ip($data['poll_id']); $vote_dates = self::yop_poll_get_results_vote_date_by_poll_id($data['poll_id']); $chart_country[0][0] = "Country"; $i = 1; $chart_country[0][1] = "Voters"; foreach ($countries as $country) { $chart_country[$i][0] = $country['country']; $chart_country[$i][1] = (int) $country['no_country']; $i++; } $chart_evolution[0][0] = "Date"; $i = 1; $chart_evolution[0][1] = "Voters"; foreach ($vote_dates as $vote_date) { $chart_evolution[$i][0] = convert_date($vote_date['v_data'], 'm-d-Y'); $chart_evolution[$i][1] = (int) $vote_date['no_votes']; $i++; } if (!isset($chart_evolution[$i][0])) { $chart_evolution[1][0] = convert_date(yop_poll_get_mysql_curent_date(), 'm-d-Y'); } if (!isset($chart_evolution[1][1])) { $chart_evolution[$i][1] = 0; } wp_localize_script('yop-poll-results-votes-js', 'charts_evolution', $chart_evolution); wp_localize_script('yop-poll-results-votes-js', 'charts_country', $chart_country); $this->display('results.html', $data); }
public function register_vote($request) { global $current_user; $poll_id = $this->id; $unique_id = strip_tags(xss_clean($this->unique_id)); $location = strip_tags(xss_clean($request['location'])); $vote_id = uniqid('vote_id_'); $vote_type = $request['vote_type']; $SuperCookie = strip_tags(xss_clean($request['supercookie'])); $tr_id = strip_tags(xss_clean($request['yop_poll_tr_id'])); $votes = 0; $user_id = 0; $user_type = 'default'; $user_details = ''; if (wp_verify_nonce($request['yop-poll-nonce-' . $poll_id . $unique_id], 'yop_poll-' . $this->ID . $unique_id . '-user-actions')) { switch ($vote_type) { default: $user_id = $current_user->ID != null ? $current_user->ID : 0; $user_type = 'default'; break; case 'wordpress': $user_id = $current_user->ID; $user_type = 'wordpress'; break; case 'anonymous': $user_type = 'anonymous'; break; } $log_to_add = array('poll_id' => $this->ID, 'vote_id' => $vote_id, 'ip' => yop_poll_get_ip(), 'user_id' => $user_id, 'user_type' => $user_type, 'user_details' => json_encode($user_details), 'tr_id' => $tr_id); } else { $this->error = __yop_poll('Bad Request!'); $log_to_add['message'] = __yop_poll('Bad request'); insert_log_in_db($log_to_add); return false; } if (wp_verify_nonce($request['yop-poll-nonce-' . $this->ID . $unique_id], 'yop_poll-' . $this->ID . $unique_id . '-user-actions')) { $tr_id = $request['yop_poll_tr_id']; $super_perm = true; if (in_array("supercookie", $this->blocking_voters)) { $super_perm = $this->is_voted_supercookie($SuperCookie); } if ($super_perm == true) { $current_date = yop_poll_get_mysql_curent_date(); if ($this->is_allowed_to_vote($vote_type)) { if ($current_date >= convert_date($this->poll_start_date, 'Y-m-d H:i:s')) { if ($current_date <= convert_date($this->poll_end_date, 'Y-m-d H:i:s')) { if ('closed' == $this->status) { $this->error = __yop_poll('This poll is closed!'); $log_to_add['message'] = __yop_poll('Poll Closed'); insert_log_in_db($log_to_add); return false; } else { if (!$this->is_voted($vote_type, $facebook_user_details, $google_user_details, true, $SuperCookie)) { $voter = array(); $voter['poll_id'] = $poll_id; $voter['user_id'] = $current_user->ID; $voter['user_type'] = $vote_type; if ($this->user_have_votes_to_vote($voter, $SuperCookie)) { $i = 1; $cookie = ''; $log = array(); foreach ($this->questions as &$question) { $answers = array(); if (isset($request['yop_poll_answer'][$question->ID])) { if ('yes' == $question->allow_multiple_answers) { if (count($request['yop_poll_answer'][$question->ID]) <= intval($question->allow_multiple_answers_number)) { if (count($request['yop_poll_answer'][$question->ID]) >= intval($question->allow_multiple_answers_min_number)) { $answers = array(); foreach ($request['yop_poll_answer'][$question->ID] as $answer) { $new_answer = array(); $new_answer['answer_id'] = $answer; $new_answer['type'] = 'default'; if ('other' == $answer) { $a = new YOP_POLL_Answer_Model(); if (isset($request['yop_poll_other_answer'][$question->ID]) && '' != strip_tags(trim($request['yop_poll_other_answer'][$question->ID]))) { $a->type = 'other'; $a->poll_id = $poll_id; $a->question_id = $question->ID; $a->answer = strip_tags(trim($request['yop_poll_other_answer'][$question->ID])); $a->answer_date = current_time('mysql'); $a->answer_modified = current_time('mysql'); $a->status = 'active'; $a->question_order = $question->countanswers() + 1; $a->answer_author = $current_user->ID; $a->save(); if (!$a->id) { $this->error = __yop_poll('Other answer for question ') . $i . __yop_poll(' could not be inserted!'); $log_to_add['message'] = __yop_poll('Other answer for question ') . $i . __yop_poll(' could not be inserted'); insert_log_in_db($log_to_add); return false; } } else { $this->error = __yop_poll('Other answer from question ') . $i . __yop_poll(' is empty'); $log_to_add['message'] = __yop_poll('Other answer from question ') . $i . __yop_poll(' is empty'); insert_log_in_db($log_to_add); return false; } $question->addAnswer($a); $new_answer['answer_id'] = $a->id; $new_answer['type'] = 'other'; unset($a); } $new_answer['poll_id'] = $poll_id; $new_answer['vote_id'] = $vote_id; $new_answer['ip'] = yop_poll_get_ip(); $new_answer['user_id'] = $current_user->ID; $new_answer['user_type'] = 'default'; if ($vote_type == 'anonymous' || $vote_type == 'wordpress') { $new_answer['user_type'] = $vote_type; } $new_answer['http_referer'] = $_SERVER['HTTP_REFERER']; $new_answer['tr_id'] = $tr_id; $new_answer['host'] = esc_attr(@gethostbyaddr(yop_poll_get_ip())); $new_answer['other_answer_value'] = ''; $answers[] = $new_answer; } } else { $this->error = __yop_poll("Too few answers selected for question ") . $i . __yop_poll("! Only more than ") . $question->allow_multiple_answers_min_number . __yop_poll(" answers allowed!"); $log_to_add['message'] = __yop_poll("Too few answers selected for question ") . $i; insert_log_in_db($log_to_add); return false; } } else { $this->error = __yop_poll("Too many answers selected for question ") . $i . __yop_poll("! Only ") . $question->allow_multiple_answers_number . __yop_poll(" answers allowed!"); $log_to_add['message'] = __yop_poll("Too many answers selected for question ") . $i; insert_log_in_db($log_to_add); return false; } } else { $new_answer = array(); $new_answer['answer_id'] = $request['yop_poll_answer'][$question->ID]; $new_answer['type'] = 'default'; if ('other' == $request['yop_poll_answer'][$question->ID]) { $a = new YOP_POLL_Answer_Model(); if (isset($request['yop_poll_other_answer'][$question->ID]) && '' != strip_tags(trim($request['yop_poll_other_answer'][$question->ID]))) { $a->type = 'other'; $a->poll_id = $poll_id; $a->question_id = $question->ID; $a->answer = strip_tags(trim($request['yop_poll_other_answer'][$question->ID])); $a->answer_date = current_time('mysql'); $a->question_order = $question->countanswers(); $a->answer_author = $current_user->ID; $a->votes = 0; $a->save(); if (!$a->id) { $this->error = __yop_poll("Other answer for question ") . $i . __yop_poll(" could not be inserted!"); $log_to_add['message'] = __yop_poll("Other answer for question ") . $i . __yop_poll(" could not be inserted"); insert_log_in_db($log_to_add); return false; } } else { $this->error = __yop_poll("Other answer from question ") . $i . ' ' . __yop_poll('is empty'); $log_to_add['message'] = __yop_poll("Other answer from question ") . $i . ' ' . __yop_poll('empty'); insert_log_in_db($log_to_add); return false; } $question->addAnswer($a); $new_answer['answer_id'] = $a->id; $new_answer['type'] = 'other'; unset($a); } $new_answer['poll_id'] = $poll_id; $new_answer['vote_id'] = $vote_id; $new_answer['ip'] = yop_poll_get_ip(); $new_answer['user_id'] = $current_user->ID; $new_answer['user_type'] = 'default'; $new_answer['http_referer'] = $_SERVER['HTTP_REFERER']; $new_answer['tr_id'] = $tr_id; $new_answer['host'] = esc_attr(@gethostbyaddr(yop_poll_get_ip())); $new_answer['other_answer_value'] = ''; $answers[] = $new_answer; } if (count($answers) > 0) { $custom_fields = array(); $poll_custom_fields = $question->custom_fields; if (count($poll_custom_fields) > 0) { if (isset($request['yop_poll_customfield'][$question->ID])) { foreach ($poll_custom_fields as $custom_field) { if (isset($request['yop_poll_customfield'][$question->ID][$custom_field->ID])) { if ('' == trim(strip_tags($request['yop_poll_customfield'][$question->ID][$custom_field->ID])) && 'yes' == $custom_field->required) { $this->error = __yop_poll("Custom field ") . $custom_field->custom_field . __yop_poll(" from question ") . $i . ' ' . __yop_poll("is required") . "!"; $log_to_add['message'] = __yop_poll("Custom field ") . $custom_field->custom_field . __yop_poll(" from question ") . $i . ' ' . __yop_poll("required"); insert_log_in_db($log_to_add); return false; } else { if (trim(strip_tags($request['yop_poll_customfield'][$question->ID][$custom_field->ID])) != '') { $new_custom_field = array(); $new_custom_field['poll_id'] = $poll_id; $new_custom_field['question_id'] = $question->ID; $new_custom_field['vote_id'] = $vote_id; $new_custom_field['custom_field_id'] = $custom_field->ID; $new_custom_field['user_id'] = $current_user->ID; $new_custom_field['user_type'] = 'default'; if ($vote_type == 'wordpress' || $vote_type == 'anonymous') { $new_custom_field['user_type'] = $vote_type; } $new_custom_field['custom_field_value'] = strip_tags(trim($request['yop_poll_customfield'][$question->ID][$custom_field->ID])); $custom_fields[] = $new_custom_field; } } } else { $this->error = __yop_poll("Custom field ") . '"' . $custom_field->custom_field . '"' . __yop_poll(" from question ") . $i . ' ' . __yop_poll("is missing ") . '!'; $log_to_add['message'] = __yop_poll("Custom field ") . '"' . $custom_field->custom_field . '"' . __yop_poll(" from question ") . $i . ' ' . __yop_poll("missing"); insert_log_in_db($log_to_add); return false; } } } else { $this->error = __yop_poll("Custom fields from question ") . $i . ' ' . __yop_poll("are missing") . '!'; $log_to_add['message'] = __yop_poll("Custom fields from question ") . $i . ' ' . __yop_poll("missing") . '!'; insert_log_in_db($log_to_add); return false; } } if ('yes' == $this->use_captcha) { require_once YOP_POLL_INC . '/securimage.php'; $img = new Yop_Poll_Securimage(); $img->namespace = 'yop_poll_' . $poll_id . $unique_id; if ($img->check($_REQUEST['yop_poll_captcha_input'][$poll_id])) { $mail_notifications_answers[$question->ID] = array(); $add_to_log = $this->update_votes($question, $answers, $votes, $mail_notifications_answers[$question->ID], $facebook_user_details['id'], $google_user_details['id']); $log["q-" . $question->ID]['question'] = $question->question; $log["q-" . $question->ID]['a'] = $add_to_log['a']; $log["q-" . $question->ID]['answers'] = $add_to_log['answers']; $mail_notifications_answers[$question->ID] = trim($mail_notifications_answers[$question->ID], '<br>'); $mail_notifications_custom_fields[$question->ID] = ''; foreach ($custom_fields as $custom_field) { if ('anonymous' == $vote_type) { $custom_field['user_id'] = 0; } $custom_field['tr_id'] = $tr_id; self::insert_vote_custom_field_in_database($custom_field); $cf = $question->getCustomFieldById($custom_field['custom_field_id']); $mail_notifications_custom_fields[$question->ID][$cf->custom_field] = $custom_field['custom_field_value']; } if ('yes' == $this->number_of_votes_per_user) { $this->success = str_replace('%USER-VOTES-LEFT%', intval($this->number_of_votes_per_user) - $this->get_voter_number_of_votes($voter), $poll_options['message_after_vote']); } else { $this->success = str_replace('%USER-VOTES-LEFT%', '', $this->message_after_vote); } } else { $this->error = __yop_poll("Incorrect security code entered!"); $log_to_add['message'] = __yop_poll("Incorrect security code entered"); insert_log_in_db($log_to_add); return false; } } else { $mail_notifications_answers[$question->ID] = array(); $add_to_log = $this->update_votes($question, $answers, $votes, $mail_notifications_answers[$question->ID], $vote_type, $facebook_user_details['id'], $google_user_details['id']); $log["q-" . $question->ID]['question'] = $question->question; $log["q-" . $question->ID]['id'] = $question->ID; $log["q-" . $question->ID]['a'] = $add_to_log['a']; $log["q-" . $question->ID]['answers'] = $add_to_log['answers']; $mail_notifications_custom_fields[$question->ID] = array(); $add_to_log = array(); foreach ($custom_fields as $custom_field) { if ('google' == $vote_type) { $custom_field['user_id'] = $google_user_details['id']; } if ('anonymous' == $vote_type) { $custom_field['user_id'] = 0; } $custom_field['tr_id'] = $tr_id; $cf_id = self::insert_vote_custom_field_in_database($custom_field); $add_to_log[] = $cf_id; $cf = $question->getCustomFieldById($custom_field['custom_field_id']); $mail_notifications_custom_fields[$question->ID][$cf->custom_field] = $custom_field['custom_field_value']; } $log["q-" . $question->ID]['cf'] = $add_to_log; if ('yes' == $this->number_of_votes_per_user) { $this->success = str_replace('%USER-VOTES-LEFT%', intval($this->number_of_votes_per_user) - $this->get_voter_number_of_votes($voter), $this->message_after_vote); } else { $this->success = str_replace('%USER-VOTES-LEFT%', '', $this->message_after_vote); } } } else { $this->error = __yop_poll("No vote registered!"); $log_to_add['message'] = __yop_poll("No vote registered"); insert_log_in_db($log_to_add); return false; } } else { $this->error = __yop_poll("No answer selected for question ") . $i; $log_to_add['message'] = __yop_poll("No answer selected for question ") . $i; insert_log_in_db($log_to_add); return false; } $i++; } } else { $this->error = __yop_poll("You have run out of votes!"); $log_to_add['message'] = __yop_poll("Run out of votes"); insert_log_in_db($log_to_add); return false; } } else { $this->error = __yop_poll("You Already voted!"); $log_to_add['message'] = __yop_poll("Already Voted"); insert_log_in_db($log_to_add); return false; } } } else { $this->error = __yop_poll("This poll is closed!"); $log_to_add['message'] = __yop_poll("Poll Closed"); insert_log_in_db($log_to_add); return false; } } else { $this->error = __yop_poll("You can vote once the poll starts!"); $log_to_add['message'] = __yop_poll("Poll not started"); insert_log_in_db($log_to_add); return false; } } else { $this->error = __yop_poll("You are not allowed to vote!"); $log_to_add['message'] = __yop_poll("Not allowed to vote"); insert_log_in_db($log_to_add); return false; } } else { $this->error = __yop_poll("You are not allowed to vote!"); return false; } } else { $this->error = __yop_poll("Bad Request!"); $log_to_add['message'] = __yop_poll("Bad request"); insert_log_in_db($log_to_add); return false; } if ($this->send_email_notifications == "yes") { $this->sendMail($mail_notifications_answers, $mail_notifications_custom_fields, $vote_id); } $this->update_poll_total_votes(1); $log_to_add['message'] = __yop_poll('Success'); $log_to_add['vote_details'] = json_encode($log); insert_log_in_db($log_to_add); $ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $log_to_add['ip'])); $log_to_add['country'] = $ip_data->geoplugin_countryName; insert_result_in_db($log_to_add); $this->set_vote_cookie(json_encode($log), $vote_type, $facebook_user_details, $google_user_details); $this->vote = true; $this->poll_total_votes += 1; return do_shortcode($this->return_poll_html(array('tr_id' => $tr_id, 'location' => $location))); }