/** * Show avg rating for multiple posts for same form id, * calls from shortcode or direct function call or from widget * * @param $option * @param int $show_title * @param int $show_form_id * @param int $show_text * @param int $show_star * @param int $show_single * @param int $text_label * * @return string */ public static function standalone_singlePost_rating_summary($option, $show_title = 0, $show_form_id = 0, $show_text = 0, $show_star = 1, $show_single = 0, $text_label = '') { CBRatingSystem::load_scripts_and_styles(); if ($option == NULL) { return ''; } $text_label = $text_label == '' ? __('Rating: ', 'cbratingsystem') : $text_label; $post_ids = !isset($option['post_id']) || !is_array($option['post_id']) || sizeof($option['post_id']) == 0 ? array(get_the_ID()) : $option['post_id']; $form_ids = !isset($option['form_id']) || !is_array($option['form_id']) || sizeof($option['form_id']) == 0 ? array(self::get_default_ratingFormId()) : $option['form_id']; //$post_ids = is_array($post_ids) $rating_smmary = array('post' => array()); $show = ''; /*echo '<pre>'; print_r($option); echo '</pre>';*/ //var_dump($form_ids); //var_dump($show_single); if ($show_single == 1 || sizeof($post_ids) == 1) { //if ( $show_single == 1 ) { //show only for first item $option['post_id'] = array($post_ids[0]); $option['form_id'] = array($form_ids[0]); $average_rating = CBRatingSystemData::get_ratings_summary($option); if (!sizeof($average_rating)) { $average_rating['form_id'] = $form_ids[0]; $average_rating['post_id'] = $post_ids[0]; $average_rating['post_title'] = get_the_title($post_ids[0]); $average_rating['per_post_rating_summary'] = 0; $average_rating['found'] = 0; } else { $average_rating = $average_rating[0]; //no rating found for this post and form id $average_rating['found'] = 1; } $show .= '<div class="cbratingavgratelist">'; if ($show_title == 1) { $show .= '<p>' . __('Post: ', 'cbratingsystem') . $average_rating['post_title'] . '</p>'; } if ($show_form_id == 1) { $show .= '<p>' . __('Form: ', 'cbratingsystem') . $average_rating['form_id'] . '</p>'; } if ($show_text == 1) { $show .= '<p>' . $text_label . number_format($average_rating['per_post_rating_summary'] / 100 * 5, 2) . '/5</p>'; } $clip_back = 120; $star_clip_amount = number_format($average_rating['per_post_rating_summary'] / 100 * 120, 2); if ($show_star == 1) { ?> <script> jQuery(document).ready(function ($) { $('.cbrp-alone-rated<?php echo $average_rating['post_id']; ?> ').raty({ half : true, path : '<?php echo CB_RATINGSYSTEM_PLUGIN_DIR_IMG; ?> ', score : <?php echo $average_rating['per_post_rating_summary'] / 100 * 5; ?> , readOnly: true, hintList: ['', '', '', '', ''] }); }); </script> <?php $show .= ' <div class="cbrp-alone-rated cbrp-alone-rated' . $average_rating['post_id'] . '" id="cbrp-alone-rated' . $average_rating['post_id'] . '" style="margin: 0;"></div>'; } $show .= '</div>'; // echo $show; } else { //var_dump('I am here'); //$show = ''; if (!empty($post_ids) && !empty($form_ids)) { //$position = 30; foreach ($post_ids as $post_id) { //$average_ratings = CBRatingSystemData::get_ratings($form_id,$post_id); //$option=array('post_id'=>$post_id,'form_id'=>$form_id); //unset( $whrOpt ); $option = array(); $option['form_id'] = $form_ids; $option['post_id'] = array($post_id); $average_rating = CBRatingSystemData::get_ratings_summary($option); if (!sizeof($average_rating)) { $average_rating['form_id'] = $form_ids[0]; $average_rating['post_id'] = $post_ids[0]; $average_rating['post_title'] = get_the_title($post_ids[0]); $average_rating['per_post_rating_summary'] = 0; $average_rating['found'] = 0; } else { $average_rating = $average_rating[0]; $average_rating['found'] = 1; } $show .= '<div class="cbratingavgratelist" style="position:relative;">'; if ($show_title == 1) { $show .= '<p>' . __('Post: ', 'cbratingsystem') . $average_rating['post_title'] . '</p>'; } if ($show_form_id == 1) { $show .= '<p>' . __('Form: ', 'cbratingsystem') . $average_rating['form_id'] . '<p>'; } if ($show_text == 1) { $show .= '<p>' . $text_label . '' . number_format($average_rating['per_post_rating_summary'] / 100 * 5, 2) . '/5<p>'; } $clip_back = 120; $star_clip_amount = number_format($average_rating['per_post_rating_summary'] / 100 * 120, 2); if ($show_star == 1) { ?> <script> jQuery(document).ready(function ($) { $('.cbrp-alone-rated<?php echo $post_id; ?> ').raty({ half : true, path : '<?php echo CB_RATINGSYSTEM_PLUGIN_DIR_IMG; ?> ', score : <?php echo $average_rating['per_post_rating_summary'] / 100 * 5; ?> , readOnly: true, hintList: ['', '', '', '', ''] }); }); </script> <?php $show .= ' <div class="cbrp-alone-rated cbrp-alone-rated' . $average_rating['post_id'] . '" id="cbrp-alone-rated' . $post_id . '" style="margin: 0;"></div>'; } $show .= '</div>'; //$position += 30; } //echo $show; } } return $show; }
/** * averageReportPageOutput */ public static function averageReportPageOutput() { global $wpdb; $path = admin_url('admin.php?page=rating_avg_reports'); $sort = isset($_GET['sort']) && $_GET['sort'] == 'asc' ? 'asc' : 'desc'; $sortby = (!empty($_GET['sortby']) and $sort) ? $_GET['sortby'] : 'form_id'; $summaryData = CBRatingSystemData::get_ratings_summary(array(), $sortby, $sort, true); ?> <div class="wrap columns-2"> <div class="icon32 icon32_cbrp_admin icon32-cbrp-rating-avg" id="icon32-cbrp-rating-avg"><br></div> <h2><?php _e("Codeboxr Rating System Rating Average", 'cbratingsystem'); ?> </h2> <div class="metabox-holder has-right-sidebar" id="poststuff"> <div id="message" </div> <div id="post-body" class="post-body"> <div id="stuff-box"> <!-- Starting of Average rating Listing --> <div class="cbrp-log-report-average"> <form method="post"> <div style="clear: both;"></div> <?php if ($summaryData) { ?> <?php foreach ($summaryData as $rowId => $rows) { if (!empty($rows->per_post_rating_count) and !empty($rows->per_post_rating_summary)) { ?> <?php $log_average = array(); $log_post_id = $rows->post_id; $log_post_title = $rows->post_title; $log_form_id = $rows->form_id; $log_average = $rows->per_post_rating_summary > 0 ? "<strong>" . number_format($rows->per_post_rating_summary / 100 * 5, 2) . " out of 5</strong>" : '-'; $userRoleLabels = CBRatingSystem::user_role_label(); $log_ratingCount = $rows->per_post_rating_count; $log_id = $rows->id; $table = CBRatingSystemData::get_user_ratings_table_name(); $sql = $wpdb->prepare("SELECT id FROM {$table} WHERE post_id=%d AND form_id=%d ", $log_post_id, $log_form_id); $results = $wpdb->get_results($sql, ARRAY_A); $results = maybe_unserialize($results[0]['id']); if (!empty($rows->per_criteria_rating_summary)) { $log_criteria_rating = '<ul>'; foreach ($rows->per_criteria_rating_summary as $cId => $criteria) { $log_criteria_rating .= "<li>" . $criteria['label'] . ": <strong>" . number_format($criteria['value'] / 100 * count($criteria['stars']), 2) . " out of " . count($criteria['stars']) . "</strong>"; } $log_criteria_rating .= '</ul>'; } else { $log_criteria_rating = '-'; } array_push(CBratinglogreportoutput::$cb_avg_comment_log_data, array('id_user_table' => $results, 'id' => $log_id, 'rating_count' => $log_ratingCount, 'criteria_rating' => $log_criteria_rating, 'post' => $log_post_id, 'posttitle' => $log_post_title, 'formid' => $log_form_id, 'avgrating' => $log_average)); ?> <?php } else { //echo "<td colspan='7' align='center'>No Results Found</td>"; } } ?> <?php } else { //echo "<td colspan='7' align='center'>No Results Found</td>"; ?> <?php } ?> </form> </div> <!-- Ending of Average rating Listing --> </div> </div> </div> </div> <?php $list_table = new Cbratingavglog(); $list_table->prepare_items(); ?> <form id="movies-filter" method="get"> <input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?> " /> <?php $list_table->display(); ?> </form> <?php }
/** * @param array $args * @param array $instance */ function widget($args, $instance) { global $wpdb; extract($args); CBRatingSystem::load_scripts_and_styles(); $whrOptn = array(); // echo '<pre>'; // print_r($instance); // echo '</pre>'; $type = $instance['type']; $date = $instance['day']; $limit = $instance['todisplay']; $form_id = $instance['form_id']; $order = $instance['order']; $whrOptn['order'] = $order; if ($date != 0) { $date = self::get_calculated_date($date); $whrOptn['post_date'] = $date; } $whrOptn['post_type'][] = $type; $whrOptn['form_id'][] = $form_id; //added from v3.2.20 // echo '<pre>'; // print_r($whrOptn); // echo '</pre>'; $data = CBRatingSystemData::get_ratings_summary($whrOptn, 'avg', $order, true, $limit); //cbxdump($data); $title = empty($options['widget_title']) ? __('Top Rated Posts', 'cbratingsystem') : $instance['widget_title']; $title = apply_filters('widget_title', $instance['title']); echo $before_widget; echo $before_title . $title . $after_title; ?> <ul id="cbrp-top-rated-wpanel" style="padding: 10px 0 10px 10px;"> <?php if (!empty($data)) { ?> <?php foreach ($data as $newdata) { ?> <li> <script> jQuery(document).ready(function ($) { $('#cbrp-top-rated<?php echo $newdata->post_id; ?> ').raty({ half : true, path : '<?php echo CB_RATINGSYSTEM_PLUGIN_DIR_IMG; ?> ', score : <?php echo $newdata->per_post_rating_summary / 100 * 5; ?> , readOnly: true, hintList: ['', '', '', '', ''] }); }); </script> <div id="cbrp-top-rated<?php echo $newdata->post_id; ?> " style="margin: 0;"></div> <?php echo "<strong>" . $newdata->per_post_rating_summary / 100 * 5 . "/5</strong> "; ?> <a href="<?php echo get_permalink($newdata->post_id); ?> "><?php echo $newdata->post_title; ?> </a> </li> <?php } ?> <?php } else { ?> <li><?php _e('No Results found', 'cbratingsystem'); ?> </li> <?php } ?> </ul> <?php echo $after_widget; }
/** * Ajax function for the review submission */ public static function cbRatingAjaxFunction() { global $wpdb; $user_id = get_current_user_id(); //returns 0 if guest $user_info = ''; if (isset($_POST['cbRatingData']) && !empty($_POST['cbRatingData'])) { $returnedData = $_POST['cbRatingData']; //var_dump($returnedData); if (wp_verify_nonce($returnedData['cbrp_nonce'], 'cb_ratingForm_front_form_nonce_field')) { if (!empty($returnedData['values'])) { list($insertArray['form_id'], $insertArray['post_id']) = explode('-', $returnedData['rp_id']); if ($user_id == 0) { $user_session = $_COOKIE[CB_RATINGSYSTEM_COOKIE_NAME]; //this is string $user_ip = CBRatingSystem::get_ipaddress(); } elseif ($user_id > 0) { $user_session = 'user-' . $user_id; //this is string $user_ip = CBRatingSystem::get_ipaddress(); $user_info = get_userdata($user_id); } $table_name1 = CBRatingSystemData::get_user_ratings_table_name(); $table_name2 = CBRatingSystemData::get_ratingForm_settings_table_name(); $sql_get_loggin = "SELECT logging_method FROM {$table_name2} where id=" . $insertArray['form_id']; //$sql_get_loggin = maybe_unserialize($sql_get_loggin[0]->logging_method); $query_result = $wpdb->get_results($sql_get_loggin); $query_result2 = maybe_unserialize($query_result[0]->logging_method); //getting the data according to the administrative settings using IP/Cookie for the last comment if (in_array("cookie", $query_result2) && !in_array("ip", $query_result2)) { $sql = $wpdb->prepare("SELECT COUNT(ur.id) AS count FROM {$table_name1} ur WHERE ur.form_id=%d AND ur.post_id=%d AND ur.user_id=%d AND ur.user_session = %s", $insertArray['form_id'], $insertArray['post_id'], $user_id, $user_session); $count = $wpdb->get_var($sql); } else { if (!in_array("cookie", $query_result2) && in_array("ip", $query_result2)) { $sql = $wpdb->prepare("SELECT COUNT(ur.id) AS count FROM {$table_name1} ur WHERE ur.form_id=%d AND ur.post_id=%d AND ur.user_id=%d AND ur.user_ip = %s", $insertArray['form_id'], $insertArray['post_id'], $user_id, $user_ip); $count = $wpdb->get_var($sql); } else { $sql = $wpdb->prepare("SELECT COUNT(ur.id) AS count FROM {$table_name1} ur WHERE ur.form_id=%d AND ur.post_id=%d AND ur.user_id=%d AND ur.user_ip = %s", $insertArray['form_id'], $insertArray['post_id'], $user_id, $user_ip); $count = $wpdb->get_var($sql); } } if ($count < 1) { // first time rating $insertArray['post_type'] = get_post_type($insertArray['post_id']); $insertArray['created'] = time(); $question = array(); if (!empty($returnedData['question'][$insertArray['form_id']]) && is_array($returnedData['question'][$insertArray['form_id']])) { foreach ($returnedData['question'][$insertArray['form_id']] as $qID => $qValue) { if (is_array($qValue) && !empty($qValue)) { foreach ($qValue as $key => $val) { $type = $qValue[$qID . '_type']; if (isset($qValue[$type . '-' . $qID]) && !empty($qValue[$type . '-' . $qID])) { $question[$qID] = $qValue[$type . '-' . $qID]; } elseif ($key != $qID . '_type' && $key != $type . '-' . $qID && !empty($val)) { $key = str_replace($qID . '_', '', $key); if (is_numeric($key)) { $question[$qID][$key] = $val; } } } } else { $question[$qID] = $qValue; } } } $insertArray['question'] = maybe_serialize($question); $comment = esc_html(sanitize_text_field($returnedData['comment'])); if (strlen($comment) <= $returnedData['comment_limit']) { $insertArray['comment'] = $comment; } elseif (strlen($comment) > $returnedData['comment_limit']) { $insertArray['comment'] = substr($comment, 0, intval($returnedData['comment_limit'])); } if (!is_user_logged_in()) { if (!empty($returnedData['user_name'])) { $insertArray['user_name'] = sanitize_text_field(trim($returnedData['user_name'])); } else { $encoded = json_encode(array('validation' => 1, 'errorMessage' => __('Name field can\'t be left blank.', 'cbratingsystem'))); echo $encoded; die; } if (!empty($returnedData['user_email']) and is_email(trim($returnedData['user_email']))) { $insertArray['user_email'] = sanitize_text_field(trim($returnedData['user_email'])); } else { $encoded = json_encode(array('validation' => 1, 'errorMessage' => __('Please enter a valid email address.', 'cbratingsystem'))); echo $encoded; die; } } /*else { //guest user $insertArray['user_name'] = ''; $insertArray['user_email'] = $returnedData['user_email']; $insertArray['user_ip'] = $user_ip; $insertArray['user_session'] = $user_session; }*/ $insertArray['user_name'] = $user_id > 0 ? $user_info->user_login : $returnedData['user_name']; $insertArray['user_email'] = $user_id > 0 ? $user_info->user_email : $returnedData['user_email']; $insertArray['user_ip'] = $user_ip; $insertArray['user_session'] = $user_session; /* * @example: * $returnedData['values'] = array( * 0 => 100 // label_id/criteria_id => ( (Score For this label / Star count) * 100) * ) */ $insertArray['rating'] = maybe_serialize($returnedData['values']); foreach ($returnedData['values'] as $key => $val) { if (is_numeric($key)) { $average[$key] = $val; } } $hash_comment = $insertArray['user_ip'] . $insertArray['user_session'] . $insertArray['user_email'] . time(); $hash_comment = md5($hash_comment); $insertArray['average'] = array_sum($average) / count($average); //$insertArray['user_ip'] = CBRatingSystem::get_ipaddress(); //$insertArray['user_session'] = ( $user_id != 0 ) ? 'user-' . $user_id : $_COOKIE[CB_RATINGSYSTEM_COOKIE_NAME]; $insertArray['user_id'] = $user_id; $insertArray['form_id'] = (int) $insertArray['form_id']; $insertArray['post_id'] = (int) $insertArray['post_id']; $insertArray['comment_status'] = $returnedData['comment_status']; $insertArray['comment_hash'] = $hash_comment; $insertArray['allow_user_to_hide'] = isset($returnedData["hide_this_user_name"]) ? $returnedData["hide_this_user_name"] : 0; $return = CBRatingSystemData::update_rating($insertArray); if ($insertArray['comment_status'] == 'unverified' && $insertArray['comment_hash'] != '' && $insertArray['user_email'] != '') { $cb_subject = __('Verify Your email', 'cbratingsystem'); $cb_message = get_site_url() . '?cbratingemailverify=' . $insertArray['comment_hash']; $from = get_option('admin_email'); //var_dump($from); wp_mail($insertArray['user_email'], $cb_subject, $cb_message); // mail($insertArray['user_email'],$cb_subject,$cb_message,"From: $from\n"); } // buddypress post added 29-10-14 codeboxr if (isset($returnedData["buddypress_post"]) && $returnedData["buddypress_post"] == '1' || is_user_logged_in()) { if (function_exists('bp_is_active')) { // buddy press active $buddy_post = array('id' => false, 'action' => bp_core_get_userlink(bp_loggedin_user_id()) . __(' has rated this post ', 'cbratingsystem') . get_permalink($insertArray['post_id']), 'content' => $insertArray['comment'], 'component' => 'ratingcomponent', 'type' => 'ratingcomponent_activity', 'primary_link' => '', 'user_id' => bp_loggedin_user_id(), 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false, 'is_spam' => false); do_action('cbratingsystem_buddypress_activity_post', $buddy_post); } //end checking if buddypress is installed } $lastcommentrt = $return; // storing the last commend id for safety if ($return) { //getting the criteria rating result $ratingAverage = self::viewPerCriteriaRatingResult($insertArray['form_id'], $insertArray['post_id'], $user_id); $ratingsCount = $ratingAverage['ratingsCount'][$insertArray['form_id'] . '-' . $insertArray['post_id']]; if (!empty($ratingsCount)) { $rating = array('form_id' => $insertArray['form_id'], 'post_id' => $insertArray['post_id'], 'post_type' => $insertArray['post_type'], 'per_post_rating_count' => $ratingsCount, 'per_post_rating_summary' => number_format($ratingAverage['perPost'][$insertArray['post_id']], 2), 'custom_user_rating_summary' => maybe_serialize($ratingAverage['customUser']), 'per_criteria_rating_summary' => maybe_serialize($ratingAverage['avgPerCriteria'])); foreach ($ratingAverage['avgPerCriteria'] as $cId => $criteria) { $cCriteria['readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-count'] = count($criteria['stars']); $cCriteria['readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-value'] = $criteria['value']; } if (!empty($ratingAverage['customUser']['perCriteria']['editor'])) { foreach ($ratingAverage['customUser']['perCriteria']['editor'] as $cId => $criteria) { $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-count'] = count($ratingAverage['avgPerCriteria'][$cId]['stars']); $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-value'] = $criteria['value']; } } else { foreach ($ratingAverage['avgPerCriteria'] as $cId => $criteria) { $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-count'] = count($ratingAverage['avgPerCriteria'][$cId]['stars']); $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-value'] = 0; } } $cCriteria['readonly-criteria-label-' . $insertArray['form_id'] . '-post-' . $insertArray['post_id'] . '-avgvalue'] = $rating['per_post_rating_summary']; if (!empty($ratingAverage['customUser']['perCriteria']['editor'])) { $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-post-' . $insertArray['post_id'] . '-avgvalue'] = $ratingAverage['customUser']['perPost']['editor']; } else { $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-post-' . $insertArray['post_id'] . '-avgvalue'] = 0; } $return = CBRatingSystemData::update_rating_summary($rating); $editorCount = isset($ratingAverage['customUser']['perPostRateCount']['editor']) ? (int) $ratingAverage['customUser']['perPostRateCount']['editor'] : 0; //review part here if (empty($ratingFormArray)) { $defaultFormId = get_option('cbratingsystem_defaultratingForm'); $ratingFormId = apply_filters('rating_form_array', $defaultFormId); //getting the rating form data from here. $ratingFormArray = CBRatingSystemData::get_ratingForm($insertArray['form_id']); } //get the theme for doing frontend UI works $theme_key = get_option('cbratingsystem_theme_key'); $reviewOptions['theme'] = $theme_key; $reviewOptions['comment_status'] = $insertArray['comment_status']; $reviewOptions["hide_this_user_name"] = isset($returnedData["hide_this_user_name"]) ? $returnedData["hide_this_user_name"] : 0; $lastcomment = is_numeric($lastcommentrt) ? self::build_user_rating_review_single($reviewOptions, $ratingFormArray, $lastcommentrt) : ''; //echo $lastcomment; if ($return) { $encoded = json_encode(array('img_path' => CB_RATINGSYSTEM_PLUGIN_DIR_IMG, 'hints' => json_encode($cCriteria), 'is_rated' => 1, 'ratingsCount' => $ratingsCount, 'editorRatingsCount' => $editorCount, 'lastcomment' => $lastcomment, 'theme_key' => $reviewOptions['theme'], 'firstcomment' => true, 'comment_status' => $insertArray['comment_status'])); echo $encoded; } } } } else { //at least one rating done $summary = CBRatingSystemData::get_ratings_summary(array('form_id' => array($insertArray['form_id']), 'post_id' => array($insertArray['post_id']))); if (!empty($summary[0])) { foreach ($summary[0]['per_criteria_rating_summary'] as $cId => $criteria) { $cCriteria['readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-count'] = count($criteria['stars']); $cCriteria['readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-value'] = $criteria['value']; } if (!empty($ratingAverage['customUser']['perCriteria']['editor'])) { foreach ($ratingAverage['customUser']['perCriteria']['editor'] as $cId => $criteria) { $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-count'] = count($ratingAverage['avgPerCriteria'][$cId]['stars']); $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-value'] = $criteria['value']; } } else { if (!empty($summary[0])) { foreach ($summary[0]['per_criteria_rating_summary'] as $cId => $criteria) { $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-count'] = count($ratingAverage['avgPerCriteria'][$cId]['stars']); $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-stars-' . $cId . '-value'] = 0; } } } $cCriteria['readonly-criteria-label-' . $insertArray['form_id'] . '-post-' . $insertArray['post_id'] . '-avgvalue'] = $rating['per_post_rating_summary']; if (!empty($ratingAverage['customUser']['perCriteria']['editor'])) { $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-post-' . $insertArray['post_id'] . '-avgvalue'] = $ratingAverage['customUser']['perPost']['editor']; } else { $cCriteria['editor-readonly-criteria-label-' . $insertArray['form_id'] . '-post-' . $insertArray['post_id'] . '-avgvalue'] = 0; } $encoded = json_encode(array('img_path' => CB_RATINGSYSTEM_PLUGIN_DIR_IMG, 'hints' => json_encode($cCriteria), 'is_rated' => 1, 'ratingsCount' => $summary[0]['per_post_rating_count'], 'errorMessage' => __('You have already rated this.', 'cbratingsystem'))); echo $encoded; } else { $encoded = json_encode(array('is_rated' => 1, 'errorMessage' => __('An error occurred while storing data. Please ensure that all data are resonable. If problem persist please contact the administrator.', 'cbratingsystem'))); echo $encoded; } } //end you already submitted your rating. } } } die; }