/**
  * Step 6 - Import Votes
  * @param array $xml
  * @param string $file_name
  * @return bool
  */
 function step6($h, $xml, $file_name)
 {
     echo "<b>Table:</b> Votes...<br /><br />";
     $this_table = "postvotes";
     $h->db->query($h->db->prepare("TRUNCATE " . DB_PREFIX . 'postvotes'));
     $h->db->query($h->db->prepare("TRUNCATE " . DB_PREFIX . 'commentvotes'));
     echo "<i>Number of records added:</i> ";
     $count = 0;
     foreach ($xml->children() as $child) {
         // Skip all comment votes...
         if ($child->vote_type == 'links') {
             $count++;
             if ($child->vote_value > 0) {
                 $rating = $child->vote_value;
             } else {
                 $rating = -999;
                 // buried/flagged
             }
             $columns = "vote_post_id, vote_user_id, vote_user_ip, vote_date, vote_type, vote_rating, vote_reason, vote_updateby";
             $sql = "INSERT IGNORE " . DB_PREFIX . $this_table . " (" . $columns . ") VALUES(%d, %d, %s, %s, %s, %d, %d, %d)";
             $lks = new PliggImp2();
             $comms = new PliggImp3();
             $usr = new PliggImp5();
             // Insert into postvotes table
             $h->db->query($h->db->prepare($sql, $lks->get_new_link_id($h, $child->vote_link_id), $usr->get_new_user_id($h, $child->vote_user_id), $child->vote_ip, $child->vote_date, 'vote', $rating, 0, $h->currentUser->id));
         }
         // Now do comment votes...
         if ($child->vote_type == 'comments') {
             $count++;
             if ($child->vote_value > 0) {
                 $rating = 10;
             } else {
                 $rating = -10;
             }
             $columns = "cvote_post_id, cvote_comment_id, cvote_user_id, cvote_user_ip, cvote_date, cvote_rating, cvote_reason, cvote_updateby";
             $sql = "INSERT IGNORE " . DB_PREFIX . "commentvotes (" . $columns . ") VALUES(%d, %d, %d, %s, %s, %d, %d, %d)";
             // Insert into commentvotes table
             $h->db->query($h->db->prepare($sql, 0, $comms->get_new_comment_id($h, $child->vote_link_id), $usr->get_new_user_id($h, $child->vote_user_id), $child->vote_ip, $child->vote_date, $rating, 0, $h->currentUser->id));
         }
     }
     //Output the number of records added
     echo $count . " minus duplicate entries.<br /><br />";
     echo "<span style='color: green;'><b>Votes table imported successfully!</b></span><br /><br />";
     echo "<a class='pliggimp_next' href='" . BASEURL . "admin_index.php?page=plugin_settings&amp;plugin=pligg_importer&amp;step=7'>Continue</a>";
     return true;
 }
 /**
  * Import data into the database from an XML file
  *
  * @param int $step
  * @param str $file_name
  */
 public function process_file($h, $step = 0, $file_name = '')
 {
     $uploads_folder = PLUGINS . "pligg_importer/uploads/";
     $xml = simplexml_load_file($uploads_folder . $file_name);
     echo "<h2>Importing data from <i>" . $xml->getName() . "</i></h2>";
     switch ($step) {
         case 1:
             $this->create_temp_table($h);
             $cats = new PliggImp1();
             $cats->step1($h, $xml, $file_name);
             break;
         case 2:
             $links = new PliggImp2();
             $links->step2($h, $xml, $file_name);
             break;
         case 3:
             $comms = new PliggImp3();
             $comms->step3($h, $xml, $file_name);
             break;
         case 4:
             $tags = new PliggImp4();
             $tags->step4($h, $xml, $file_name);
             break;
         case 5:
             $users = new PliggImp5();
             $users->step5($h, $xml, $file_name);
             break;
         case 6:
             $votes = new PliggImp6();
             $votes->step6($h, $xml, $file_name);
             break;
         default:
             break;
     }
     echo "<br /><br />";
 }