/**
  * Migrate data from old plugin.
  */
 public function Migrate()
 {
     global $wpdb;
     static $migTypes = array(3000 => 5006);
     // load data
     $sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'wordpress_auditlog_events';
     $events = array();
     foreach ($wpdb->get_results($sql, ARRAY_A) as $item) {
         $events[$item['EventID']] = $item;
     }
     $sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'wordpress_auditlog';
     $auditlog = $wpdb->get_results($sql, ARRAY_A);
     // migrate using db logger
     foreach ($auditlog as $entry) {
         $data = array('ClientIP' => $entry['UserIP'], 'UserAgent' => '', 'CurrentUserID' => $entry['UserID']);
         if ($entry['UserName']) {
             $data['Username'] = base64_decode($entry['UserName']);
         }
         $mesg = $events[$entry['EventID']]['EventDescription'];
         $date = strtotime($entry['EventDate']);
         $type = $entry['EventID'];
         if (isset($migTypes[$type])) {
             $type = $migTypes[$type];
         }
         // convert message from '<strong>%s</strong>' to '%Arg1%' format
         $c = 0;
         $n = '<strong>%s</strong>';
         $l = strlen($n);
         while (($pos = strpos($mesg, $n)) !== false) {
             $mesg = substr_replace($mesg, '%MigratedArg' . $c++ . '%', $pos, $l);
         }
         $data['MigratedMesg'] = $mesg;
         // generate new meta data args
         $temp = unserialize(base64_decode($entry['EventData']));
         foreach ((array) $temp as $i => $item) {
             $data['MigratedArg' . $i] = $item;
         }
         // send event data to logger!
         foreach ($this->alerts->GetLoggers() as $logger) {
             $logger->Log($type, $data, $date, $entry['BlogId'], true);
         }
     }
     // migrate settings
     $this->settings->SetAllowedPluginEditors(get_option('WPPH_PLUGIN_ALLOW_CHANGE'));
     $this->settings->SetAllowedPluginViewers(get_option('WPPH_PLUGIN_ALLOW_ACCESS'));
     $s = get_option('wpph_plugin_settings');
     //$this->settings->SetPruningDate(($s->daysToKeep ? $s->daysToKeep : 30) . ' days');
     //$this->settings->SetPruningLimit(min($s->eventsToKeep, 1));
     $this->settings->SetViewPerPage(max($s->showEventsViewList, 5));
     $this->settings->SetWidgetsEnabled(!!$s->showDW);
 }