Exemplo n.º 1
0
 function save_vote($id, $user, $ip, $ua, $vote, $comment_id = 0)
 {
     global $wpdb, $table_prefix;
     $ua = str_replace("'", "''", $ua);
     $ua = substr($ua, 0, 250);
     $sql = sprintf("SELECT * FROM %sgdsr_data_article WHERE post_id = %s", $table_prefix, $id);
     $post_data = $wpdb->get_row($sql);
     if (count($post_data) == 0) {
         GDSRDatabase::add_default_vote($id);
         $post_data = $wpdb->get_row($sql);
     }
     if ($post_data->moderate_articles == "" || $post_data->moderate_articles == "N" || $post_data->moderate_articles == "V" && $user > 0 || $post_data->moderate_articles == "U" && $user == 0) {
         gdsrBlgDB::add_vote($id, $user, $ip, $ua, $vote, $comment_id);
     } else {
         $modsql = sprintf("INSERT INTO %sgdsr_moderate (id, vote_type, user_id, vote, voted, ip, user_agent, comment_id) VALUES (%s, 'article', %s, %s, '%s', '%s', '%s', %s)", $table_prefix, $id, $user, $vote, str_replace("'", "''", current_time('mysql')), $ip, $ua, $comment_id);
         $wpdb->query($modsql);
     }
 }
Exemplo n.º 2
0
 function moderation_approve($ids, $ids_array)
 {
     global $wpdb, $table_prefix;
     $sql = sprintf("select * from %s where record_id in %s", $table_prefix . "gdsr_moderate", $ids);
     $rows = $wpdb->get_results($sql);
     foreach ($rows as $row) {
         if ($row->vote_type == "article") {
             gdsrBlgDB::add_vote($row->id, $row->user_id, $row->ip, $row->user_agent, $row->vote);
         }
         if ($row->vote_type == "comment") {
             gdsrBlgDB::add_vote_comment($row->id, $row->user_id, $row->ip, $row->user_agent, $row->vote);
         }
     }
     gdsrAdmDB::moderation_delete($ids);
 }