Exemplo n.º 1
0
    /**
     * main routine to convert old school module data into new controller format
     * @global db the exponent database object
     * @param  $iloc
     * @param  $module
     * @param int $hc
     * @return
     */
    private function convert($iloc, $module, $hc = 0)
    {
        if (!array_key_exists($iloc->mod, $this->params['migrate'])) {
            return $module;
        }
        global $db;
        $old_db = $this->connect();
        $linked = false;
        $loc = null;
        switch ($iloc->mod) {
            case 'textmodule':
                @($module->view = 'showall');
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "text";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'textmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'textmodule';
                $textitems = $old_db->selectObjects('textitem', "location_data='" . serialize($iloc) . "'");
                if ($textitems) {
                    foreach ($textitems as $ti) {
                        $text = new text();
                        $loc = expUnserialize($ti->location_data);
                        $loc->mod = "text";
                        $text->location_data = serialize($loc);
                        $text->body = $ti->text;
                        $text->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'rotatormodule':
                $module->action = 'showRandom';
                $module->view = 'showRandom';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "text";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'rotatormodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'rotatormodule';
                $textitems = $old_db->selectObjects('rotator_item', "location_data='" . serialize($iloc) . "'");
                if ($textitems) {
                    foreach ($textitems as $ti) {
                        $text = new text();
                        $loc = expUnserialize($ti->location_data);
                        $loc->mod = "text";
                        $text->location_data = serialize($loc);
                        $text->body = $ti->text;
                        $text->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'snippetmodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "snippet";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'snippetmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'snippetmodule';
                $textitems = $old_db->selectObjects('textitem', "location_data='" . serialize($iloc) . "'");
                if ($textitems) {
                    foreach ($textitems as $ti) {
                        $text = new snippet();
                        $loc = expUnserialize($ti->location_data);
                        $loc->mod = "snippet";
                        $text->location_data = serialize($loc);
                        $text->body = $ti->text;
                        // if the item exists in the current db, we won't save it
                        $te = $text->find('first', "location_data='" . $text->location_data . "'");
                        if (empty($te)) {
                            $text->save();
                            @$this->msg['migrated'][$iloc->mod]['count']++;
                            @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                        }
                    }
                }
                break;
            case 'linklistmodule':
                switch ($module->view) {
                    case 'Quick Links':
                        @($module->view = "showall_quicklinks");
                        break;
                    default:
                        @($module->view = 'showall');
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "links";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'linklistmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'linklistmodule';
                $links = $old_db->selectArrays('linklist_link', "location_data='" . serialize($iloc) . "'");
                if ($links) {
                    foreach ($links as $link) {
                        $lnk = new links();
                        $loc = expUnserialize($link['location_data']);
                        $loc->mod = "links";
                        $lnk->title = !empty($link['name']) ? $link['name'] : 'Untitled';
                        $lnk->body = $link['description'];
                        $lnk->new_window = $link['opennew'];
                        $lnk->url = !empty($link['url']) ? $link['url'] : '#';
                        $lnk->rank = $link['rank'];
                        $lnk->poster = 1;
                        $lnk->editor = 1;
                        $lnk->location_data = serialize($loc);
                        $lnk->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'linkmodule':
                // user mod, not widely distributed
                switch ($module->view) {
                    case 'Summary':
                        @($module->view = "showall_quicklinks");
                        break;
                    default:
                        @($module->view = 'showall');
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "links";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'linkmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'linkmodule';
                $links = $old_db->selectArrays('link', "location_data='" . serialize($iloc) . "'");
                $oldconfig = $old_db->selectObject('linkmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($links) {
                    foreach ($links as $link) {
                        $lnk = new links();
                        $loc = expUnserialize($link['location_data']);
                        $loc->mod = "links";
                        $lnk->title = !empty($link['name']) ? $link['name'] : 'Untitled';
                        $lnk->body = $link['description'];
                        $lnk->new_window = $link['opennew'];
                        $lnk->url = !empty($link['url']) ? $link['url'] : '#';
                        $lnk->rank = $link['rank'];
                        $lnk->poster = 1;
                        $lnk->editor = 1;
                        $lnk->location_data = serialize($loc);
                        $lnk->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                    if ($oldconfig->enable_rss == 1) {
                        $config['enable_rss'] = true;
                        $config['feed_title'] = $oldconfig->feed_title;
                        $config['feed_desc'] = $oldconfig->feed_desc;
                        $config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newconfig = new expConfig();
                        $newconfig->config = $config;
                        $newconfig->location_data = $loc;
                        $newconfig->save();
                        $newrss = new expRss();
                        $newrss->module = $loc->mod;
                        $newrss->src = $loc->src;
                        $newrss->enable_rss = $oldconfig->enable_rss;
                        $newrss->feed_title = $oldconfig->feed_title;
                        $newrss->feed_desc = $oldconfig->feed_desc;
                        $newrss->rss_limit = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $newrss->rss_cachetime = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss->save();
                    }
                }
                break;
            case 'swfmodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "text";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'swfmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'swfmodule';
                $swfitems = $old_db->selectObjects('swfitem', "location_data='" . serialize($iloc) . "'");
                if ($swfitems) {
                    foreach ($swfitems as $ti) {
                        $text = new text();
                        $file = new expFile($ti->swf_id);
                        $loc = expUnserialize($ti->location_data);
                        $loc->mod = "text";
                        $text->location_data = serialize($loc);
                        $text->title = $ti->name;
                        $swfcode = '
							<p>
							 <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="' . $ti->height . '" width="' . $ti->width . '">
								 <param name="bgcolor" value="' . $ti->bgcolor . '" />
									' . ($ti->transparentbg ? "<param name=\"wmode\" value=\"transparent\" />" : "") . '
								 <param name="quality" value="high" />
								 <param name="movie" value="' . $file->path_relative . '" />
								 <embed bgcolor= "' . $ti->bgcolor . '" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="' . $file->path_relative . '" type="application/x-shockwave-flash" height="' . $ti->height . '" width="' . $ti->width . '"' . ($ti->transparentbg ? " wmode=\"transparent\"" : "") . '>
								 </embed>
							 </object>
							</p>
						';
                        $text->body = $swfcode;
                        $text->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'newsmodule':
                if ($module->view == 'Featured News') {
                    $only_featured = true;
                }
                switch ($module->view) {
                    case 'Headlines':
                        $module->view = 'showall_headlines';
                        break;
                    case 'Summary':
                        $module->view = 'showall_summary';
                        break;
                    default:
                        $module->view = 'showall';
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "news";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'newsmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'newsmodule';
                $newsitems = $old_db->selectArrays('newsitem', "location_data='" . serialize($iloc) . "'");
                $oldconfig = $old_db->selectObject('newsmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($newsitems) {
                    $files_attached = false;
                    foreach ($newsitems as $ni) {
                        unset($ni['id']);
                        $news = new news($ni);
                        $loc = expUnserialize($ni['location_data']);
                        $loc->mod = "news";
                        $news->location_data = serialize($loc);
                        $news->title = !empty($ni['title']) ? $ni['title'] : gt('Untitled');
                        $news->body = !empty($ni['body']) ? $ni['body'] : gt('(empty)');
                        $news->save();
                        // default is to create with current time
                        $news->created_at = $ni['posted'];
                        $news->edited_at = $ni['edited'];
                        $news->update();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                        if (!empty($ni['file_id'])) {
                            $file = new expFile($ni['file_id']);
                            $news->attachitem($file, '');
                            $files_attached = true;
                        }
                    }
                    $newconfig = new expConfig();
                    if ($files_attached) {
                        // fudge a config to get attached files to appear
                        $newconfig->config = 'a:14:{s:9:"feedmaker";s:0:"";s:11:"filedisplay";s:7:"Gallery";s:6:"ffloat";s:4:"Left";s:6:"fwidth";s:3:"120";s:7:"fmargin";s:1:"5";s:7:"piwidth";s:3:"100";s:5:"thumb";s:3:"100";s:7:"spacing";s:2:"10";s:10:"floatthumb";s:8:"No Float";s:6:"tclass";s:0:"";s:5:"limit";s:0:"";s:9:"pagelinks";s:14:"Top and Bottom";s:10:"feed_title";s:0:"";s:9:"feed_desc";s:0:"";}';
                    }
                    if ($oldconfig->enable_rss == 1) {
                        if ($newconfig->config != null) {
                            $config = expUnserialize($newconfig->config);
                        }
                        $config['enable_rss'] = true;
                        $config['feed_title'] = $oldconfig->feed_title;
                        $config['feed_desc'] = $oldconfig->feed_desc;
                        $config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newconfig->config = $config;
                        $newrss = new expRss();
                        $newrss->module = $loc->mod;
                        $newrss->src = $loc->src;
                        $newrss->enable_rss = $oldconfig->enable_rss;
                        $newrss->feed_title = $oldconfig->feed_title;
                        $newrss->feed_desc = $oldconfig->feed_desc;
                        $newrss->rss_limit = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $newrss->rss_cachetime = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss->save();
                    }
                    if ($only_featured) {
                        $newconfig->config['only_featured'] = true;
                    }
                    if ($newconfig != null) {
                        $newconfig->location_data = $loc;
                        $newconfig->save();
                    }
                }
                break;
            case 'resourcesmodule':
                switch ($module->view) {
                    case 'One Click Download - Descriptive':
                        $module->view = 'showall_quick_download_with_description';
                        break;
                    default:
                        $module->view = 'showall';
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "filedownload";
                if ($db->countObjects('filedownloads', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'resourcesmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'resourcesmodule';
                $resourceitems = $old_db->selectArrays('resourceitem', "location_data='" . serialize($iloc) . "'");
                $oldconfig = $old_db->selectObject('resourcesmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($resourceitems) {
                    foreach ($resourceitems as $ri) {
                        unset($ri['id']);
                        $filedownload = new filedownload($ri);
                        $loc = expUnserialize($ri['location_data']);
                        $loc->mod = "filedownload";
                        $filedownload->title = !empty($ri['name']) ? $ri['name'] : 'Untitled';
                        $filedownload->body = $ri['description'];
                        $filedownload->downloads = $ri['num_downloads'];
                        $filedownload->location_data = serialize($loc);
                        if (!empty($ri['file_id'])) {
                            $filedownload->save();
                            @$this->msg['migrated'][$iloc->mod]['count']++;
                            @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                            $file = new expFile($ri['file_id']);
                            $filedownload->attachitem($file, 'downloadable');
                            // default is to create with current time
                            $filedownload->created_at = $ri['posted'];
                            $filedownload->edited_at = $ri['edited'];
                            $filedownload->update();
                        }
                    }
                    if (isset($oldconfig->enable_rss)) {
                        $dorss = $oldconfig->enable_rss;
                    } elseif (isset($oldconfig->enable_podcasting)) {
                        $dorss = $oldconfig->enable_podcasting;
                    } else {
                        $dorss = false;
                    }
                    if ($dorss) {
                        $config['enable_rss'] = true;
                        $config['feed_title'] = $oldconfig->feed_title;
                        $config['feed_desc'] = $oldconfig->feed_desc;
                        $config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newconfig = new expConfig();
                        $newconfig->config = $config;
                        $newconfig->location_data = $loc;
                        $newconfig->save();
                        $newrss = new expRss();
                        $newrss->module = $loc->mod;
                        $newrss->src = $loc->src;
                        //						$newrss->enable_rss = $oldconfig->enable_rss;
                        $newrss->enable_rss = true;
                        $newrss->feed_title = $oldconfig->feed_title;
                        $newrss->feed_desc = $oldconfig->feed_desc;
                        $newrss->rss_limit = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $newrss->rss_cachetime = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss->save();
                    }
                }
                break;
            case 'imagegallerymodule':
                switch ($module->view) {
                    case 'Slideshow':
                        $module->action = 'slideshow';
                        $module->view = 'showall';
                        break;
                    default:
                        $module->view = 'showall';
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "photos";
                if ($db->countObjects('photo', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'imagegallerymodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'imagegallerymodule';
                $galleries = $old_db->selectArrays('imagegallery_gallery', "location_data='" . serialize($iloc) . "'");
                if ($galleries) {
                    foreach ($galleries as $gallery) {
                        $gis = $old_db->selectArrays('imagegallery_image', "gallery_id='" . $gallery['id'] . "'");
                        foreach ($gis as $gi) {
                            $photo = new photo();
                            $loc = expUnserialize($gallery['location_data']);
                            $loc->mod = "photos";
                            $photo->title = !empty($gi['name']) ? $gi['name'] : 'Untitled';
                            $photo->body = $gi['description'];
                            $photo->alt = $gi['alt'];
                            $photo->location_data = serialize($loc);
                            if (!empty($gi['file_id'])) {
                                $photo->save();
                                @$this->msg['migrated'][$iloc->mod]['count']++;
                                @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                                $file = new expFile($gi['file_id']);
                                $photo->attachitem($file, '');
                                $photo->created_at = $gi['posted'];
                                $photo->edited_at = $gi['posted'];
                                $photo->update(array("validate" => false));
                            }
                        }
                    }
                }
                break;
            case 'slideshowmodule':
                $module->action = 'slideshow';
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "photos";
                if ($db->countObjects('photo', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'slideshowmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'slideshowmodule';
                $galleries = $old_db->selectArrays('imagegallery_gallery', "location_data='" . serialize($iloc) . "'");
                if ($galleries) {
                    foreach ($galleries as $gallery) {
                        $gis = $old_db->selectArrays('imagegallery_image', "gallery_id='" . $gallery['id'] . "'");
                        foreach ($gis as $gi) {
                            $photo = new photo();
                            $loc = expUnserialize($gallery['location_data']);
                            $loc->mod = "photos";
                            $photo->title = !empty($gi['name']) ? $gi['name'] : 'Untitled';
                            $photo->body = $gi['description'];
                            $photo->alt = $gi['alt'];
                            $photo->location_data = serialize($loc);
                            $te = $photo->find('first', "location_data='" . $photo->location_data . "'");
                            if (empty($te)) {
                                if (!empty($gi['file_id'])) {
                                    $photo->save();
                                    @$this->msg['migrated'][$iloc->mod]['count']++;
                                    @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                                    $file = new expFile($gi['file_id']);
                                    $photo->attachitem($file, '');
                                    $photo->created_at = $gi['posted'];
                                    $photo->edited_at = $gi['posted'];
                                    $photo->update();
                                }
                            }
                        }
                    }
                }
                break;
            case 'headlinemodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "text";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'headlinemodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'headlinemodule';
                $headlines = $old_db->selectObjects('headline', "location_data='" . serialize($iloc) . "'");
                if ($headlines) {
                    foreach ($headlines as $hl) {
                        $headline = new text();
                        $loc = expUnserialize($hl->location_data);
                        $loc->mod = "text";
                        $headline->location_data = serialize($loc);
                        $headline->title = $hl->headline;
                        $headline->poster = 1;
                        //                        $headline->created_at = time();
                        //                        $headline->edited_at = time();
                        $headline->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'weblogmodule':
                switch ($module->view) {
                    case 'By Author':
                        $module->action = 'authors';
                        $module->view = 'authors';
                        break;
                    case 'By Tag':
                        $module->action = 'tags';
                        $module->view = 'tags_list';
                        break;
                    case 'Monthly':
                        $module->action = 'dates';
                        $module->view = 'dates';
                        break;
                    default:
                        $module->view = 'showall';
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "blog";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'weblogmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'weblogmodule';
                $blogitems = $old_db->selectArrays('weblog_post', "location_data='" . serialize($iloc) . "'");
                $oldconfig = $old_db->selectObject('weblogmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($blogitems) {
                    foreach ($blogitems as $bi) {
                        unset($bi['id']);
                        $post = new blog($bi);
                        $loc = expUnserialize($bi['location_data']);
                        $loc->mod = "blog";
                        $post->location_data = serialize($loc);
                        $post->title = !empty($bi['title']) ? $bi['title'] : gt('Untitled');
                        $post->body = !empty($bi['body']) ? $bi['body'] : gt('(empty)');
                        $post->save();
                        // default is to create with current time
                        $post->created_at = $bi['posted'];
                        $post->edited_at = $bi['edited'];
                        $post->update();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                        // this next section is moot since there are no attachments to blogs
                        // if (!empty($bi['file_id'])) {
                        // $file = new expFile($bi['file_id']);
                        // $post->attachitem($file,'downloadable');
                        // }
                        if (isset($oldconfig->enable_tags) && ($oldconfig->enable_tags = true)) {
                            $params = null;
                            $oldtags = expUnserialize($bi['tags']);
                            foreach ($oldtags as $oldtag) {
                                $tagtitle = strtolower(trim($old_db->selectValue('tags', 'name', 'id = ' . $oldtag)));
                                $tag = new expTag($tagtitle);
                                //								$tag->title = $old_db->selectValue('tags','name','id = '.$oldtag);
                                if (empty($tag->id)) {
                                    $tag->update(array('title' => $tagtitle));
                                }
                                $params['expTag'][] = $tag->id;
                            }
                            $post->update($params);
                        }
                        $comments = $old_db->selectArrays('weblog_comment', "parent_id='" . $post->id . "'");
                        foreach ($comments as $comment) {
                            unset($comment['id']);
                            $newcomment = new expComment($comment);
                            $newcomment->created_at = $comment['posted'];
                            $newcomment->edited_at = $comment['edited'];
                            $newcomment->update();
                            // attach the comment to the blog post it belongs to
                            $obj->content_type = 'blog';
                            $obj->content_id = $post->id;
                            $obj->expcomments_id = $newcomment->id;
                            if (isset($this->params['subtype'])) {
                                $obj->subtype = $this->params['subtype'];
                            }
                            $db->insertObject($obj, $newcomment->attachable_table);
                        }
                    }
                    $newconfig = new expConfig();
                    $config['add_source'] = '1';
                    if ($oldconfig->enable_rss == 1) {
                        $config['enable_rss'] = true;
                        $config['feed_title'] = $oldconfig->feed_title;
                        $config['feed_desc'] = $oldconfig->feed_desc;
                        $config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss = new expRss();
                        $newrss->module = $loc->mod;
                        $newrss->src = $loc->src;
                        $newrss->enable_rss = $oldconfig->enable_rss;
                        $newrss->feed_title = $oldconfig->feed_title;
                        $newrss->feed_desc = $oldconfig->feed_desc;
                        $newrss->rss_limit = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $newrss->rss_cachetime = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss->save();
                    }
                    $newconfig->config = $config;
                    $newconfig->location_data = $loc;
                    $newconfig->save();
                }
                break;
            case 'faqmodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "faq";
                if ($db->countObjects('faqs', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'faqmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'faqmodule';
                $faqs = $old_db->selectArrays('faq', "location_data='" . serialize($iloc) . "'");
                if ($faqs) {
                    foreach ($faqs as $fqi) {
                        unset($fqi['id']);
                        $faq = new faq($fqi);
                        $loc = expUnserialize($fqi['location_data']);
                        $loc->mod = "faq";
                        $faq->location_data = serialize($loc);
                        $faq->question = !empty($fqi['question']) ? $fqi['question'] : 'Untitled?';
                        $faq->answer = $fqi['answer'];
                        $faq->rank = $fqi['rank'];
                        $faq->include_in_faq = 1;
                        $faq->submitter_name = 'Unknown';
                        $faq->submitter_email = '*****@*****.**';
                        $faq->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'listingmodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "portfolio";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'listingmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'listingmodule';
                $listingitems = $old_db->selectArrays('listing', "location_data='" . serialize($iloc) . "'");
                if ($listingitems) {
                    $files_attached = false;
                    foreach ($listingitems as $li) {
                        unset($li['id']);
                        $listing = new portfolio($li);
                        $listing->title = !empty($li['name']) ? $li['name'] : 'Untitled?';
                        $loc = expUnserialize($li['location_data']);
                        $loc->mod = "portfolio";
                        $listing->location_data = serialize($loc);
                        $listing->featured = true;
                        $listing->poster = 1;
                        $listing->body = "<p>" . $li['summary'] . "</p>" . $li['body'];
                        $listing->save();
                        // default is to create with current time
                        $listing->created_at = time();
                        $listing->edited_at = time();
                        $listing->update();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                        if (!empty($li['file_id'])) {
                            $file = new expFile($li['file_id']);
                            $listing->attachitem($file, '');
                            $files_attached = true;
                        }
                    }
                    if ($files_attached) {
                        // fudge a config to get attached files to appear
                        $config = new expConfig();
                        $config->location_data = $loc;
                        $config->config = 'a:11:{s:11:"filedisplay";s:7:"Gallery";s:6:"ffloat";s:4:"Left";s:6:"fwidth";s:3:"120";s:7:"fmargin";s:1:"5";s:7:"piwidth";s:3:"100";s:5:"thumb";s:3:"100";s:7:"spacing";s:2:"10";s:10:"floatthumb";s:8:"No Float";s:6:"tclass";s:0:"";s:5:"limit";s:0:"";s:9:"pagelinks";s:14:"Top and Bottom";}';
                        $config->save();
                    }
                }
                break;
            case 'contactmodule':
                // convert to an old school form
                $module->view == "Default";
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "formmodule";
                if ($db->countObjects('formbuilder_form', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'contactmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'contactmodule';
                $contactform = $old_db->selectObject('contactmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($contactform) {
                    $loc = expUnserialize($contactform->location_data);
                    $loc->mod = 'formmodule';
                    $contactform->location_data = serialize($loc);
                    //				$replyto_address = $contactform->replyto_address;
                    unset($contactform->replyto_address);
                    //				$from_address = $contactform->from_address;
                    unset($contactform->from_address);
                    //				$from_name = $contactform->from_name;
                    unset($contactform->from_name);
                    unset($contactform->use_captcha);
                    $contactform->name = 'Send us an e-mail';
                    $contactform->description = '';
                    $contactform->response = $contactform->final_message;
                    unset($contactform->final_message);
                    $contactform->table_name = '';
                    $contactform->is_email = true;
                    $contactform->is_saved = false;
                    $contactform->submitbtn = 'Send Message';
                    $contactform->resetbtn = 'Reset';
                    unset($contactform->id);
                    $contactform->id = $db->insertObject($contactform, 'formbuilder_form');
                    $addresses = $old_db->selectObjects('contact_contact', "location_data='" . serialize($iloc) . "'");
                    foreach ($addresses as $address) {
                        unset($address->addressbook_contact_id);
                        unset($address->contact_info);
                        unset($address->location_data);
                        $address->form_id = $contactform->id;
                        $db->insertObject($address, 'formbuilder_address');
                    }
                    $report = null;
                    $report->name = $contactform->subject;
                    $report->location_data = $contactform->location_data;
                    $report->form_id = $contactform->id;
                    $db->insertObject($report, 'formbuilder_report');
                    // now add the controls to the form
                    $control = null;
                    $control->name = 'name';
                    $control->caption = 'Your Name';
                    $control->form_id = $contactform->id;
                    $control->data = 'O:11:"textcontrol":12:{s:4:"size";i:0;s:9:"maxlength";i:0;s:7:"caption";s:9:"Your Name";s:9:"accesskey";s:0:"";s:7:"default";s:0:"";s:8:"disabled";b:0;s:8:"required";b:1;s:8:"tabindex";i:-1;s:7:"inError";i:0;s:4:"type";s:4:"text";s:6:"filter";s:0:"";s:10:"identifier";s:4:"name";}';
                    $control->rank = 0;
                    $control->is_readonly = 0;
                    $control->is_static = 0;
                    $db->insertObject($control, 'formbuilder_control');
                    $control->name = 'email';
                    $control->caption = 'Your Email';
                    $control->data = 'O:11:"textcontrol":12:{s:4:"size";i:0;s:9:"maxlength";i:0;s:7:"caption";s:18:"Your Email Address";s:9:"accesskey";s:0:"";s:7:"default";s:0:"";s:8:"disabled";b:0;s:8:"required";b:1;s:8:"tabindex";i:-1;s:7:"inError";i:0;s:4:"type";s:4:"text";s:6:"filter";s:0:"";s:10:"identifier";s:5:"email";}';
                    $control->rank = 1;
                    $db->insertObject($control, 'formbuilder_control');
                    $control->name = 'subject';
                    $control->caption = 'Subject';
                    $control->data = 'O:11:"textcontrol":12:{s:4:"size";i:0;s:9:"maxlength";i:0;s:7:"caption";s:7:"Subject";s:9:"accesskey";s:0:"";s:7:"default";s:0:"";s:8:"disabled";b:0;s:8:"required";b:1;s:8:"tabindex";i:-1;s:7:"inError";i:0;s:4:"type";s:4:"text";s:6:"filter";s:0:"";s:10:"identifier";s:7:"subject";}';
                    $control->rank = 2;
                    $db->insertObject($control, 'formbuilder_control');
                    $control->name = 'message';
                    $control->caption = 'Message';
                    $control->data = 'O:17:"texteditorcontrol":12:{s:4:"cols";i:60;s:4:"rows";i:8;s:9:"accesskey";s:0:"";s:7:"default";s:0:"";s:8:"disabled";b:0;s:8:"required";b:0;s:8:"tabindex";i:-1;s:7:"inError";i:0;s:4:"type";s:4:"text";s:8:"maxchars";i:0;s:10:"identifier";s:7:"message";s:7:"caption";s:7:"Message";}';
                    $control->rank = 3;
                    $db->insertObject($control, 'formbuilder_control');
                    @$this->msg['migrated'][$iloc->mod]['count']++;
                    @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                }
                break;
            case 'youtubemodule':
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "youtube";
                if ($db->countObjects('youtube', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'youtubemodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'youtubemodule';
                $videos = $old_db->selectArrays('youtube', "location_data='" . serialize($iloc) . "'");
                if ($videos) {
                    foreach ($videos as $vi) {
                        unset($vi['id']);
                        $video = new youtube($vi);
                        $loc = expUnserialize($vi['location_data']);
                        $loc->mod = "youtube";
                        $video->title = $vi['name'];
                        if (empty($video->title)) {
                            $video->title = 'Untitled';
                        }
                        $video->location_data = serialize($loc);
                        $yt = explode("watch?v=", $vi['url']);
                        if (empty($yt[1])) {
                            break;
                        } else {
                            $ytid = $yt[1];
                        }
                        unset($video->url);
                        $video->embed_code = '<iframe title="YouTube video player" width="' . $vi['width'] . '" height="' . $vi['height'] . '" src="http://www.youtube.com/embed/' . $ytid . '" frameborder="0" allowfullscreen></iframe>';
                        $video->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'mediaplayermodule':
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "flowplayer";
                if ($db->countObjects('flowplayer', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'mediaplayermodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'mediaplayermodule';
                $movies = $old_db->selectArrays('mediaitem', "location_data='" . serialize($iloc) . "'");
                if ($movies) {
                    foreach ($movies as $mi) {
                        unset($mi['id']);
                        $movie = new flowplayer($mi);
                        $loc = expUnserialize($mi['location_data']);
                        $loc->mod = "flowplayer";
                        $movie->title = $mi['name'];
                        if (empty($movie->title)) {
                            $movie->title = 'Untitled';
                        }
                        unset($mi['bgcolor']);
                        unset($mi['alignment']);
                        unset($mi['loop_media']);
                        unset($mi['auto_rewind']);
                        unset($mi['autoplay']);
                        unset($mi['hide_controls']);
                        $movie->location_data = serialize($loc);
                        $movie->poster = 1;
                        $movie->rank = 1;
                        if (!empty($mi['media_id'])) {
                            $movie->save();
                            @$this->msg['migrated'][$iloc->mod]['count']++;
                            @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                            $file = new expFile($mi['media_id']);
                            $movie->attachitem($file, 'video');
                            if (!empty($mi['alt_image_id'])) {
                                $file = new expFile($mi['alt_image_id']);
                                $movie->attachitem($file, 'splash');
                            }
                        }
                    }
                }
                break;
            case 'bannermodule':
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "banner";
                if ($db->countObjects('banner', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'bannermodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'bannermodule';
                $banners = $old_db->selectArrays('banner_ad', "location_data='" . serialize($iloc) . "'");
                if ($banners) {
                    foreach ($banners as $bi) {
                        $oldclicks = $old_db->selectObjects('banner_click', "ad_id='" . $bi['id'] . "'");
                        $oldcompany = $old_db->selectObject('banner_affiliate', "id='" . $bi['affiliate_id'] . "'");
                        unset($bi['id']);
                        $banner = new banner($bi);
                        $loc = expUnserialize($bi['location_data']);
                        $loc->mod = "banner";
                        $banner->title = $bi['name'];
                        $banner->url = !empty($bi['url']) ? $bi['url'] : '#';
                        if (empty($banner->title)) {
                            $banner->title = 'Untitled';
                        }
                        $banner->location_data = serialize($loc);
                        $newcompany = $db->selectObject('companies', "title='" . $oldcompany->name . "'");
                        if ($newcompany == null) {
                            $newcompany = new company();
                            $newcompany->title = !empty($oldcompany->name) ? $oldcompany->name : 'Untitled';
                            $newcompany->body = $oldcompany->contact_info;
                            $newcompany->location_data = $banner->location_data;
                            $newcompany->save();
                        }
                        $banner->companies_id = $newcompany->id;
                        $banner->clicks = 0;
                        foreach ($oldclicks as $click) {
                            $banner->clicks += $click->clicks;
                        }
                        if (!empty($bi['file_id'])) {
                            $file = new expFile($bi['file_id']);
                            $banner->attachitem($file, '');
                        }
                        $banner->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'addressbookmodule':
                // user mod, not widely distributed
                @($module->view = 'myaddressbook');
                @($module->action = 'myaddressbook');
                //check to see if it's already pulled in (circumvent !is_original)
                // $ploc = $iloc;
                // $ploc->mod = "addresses";
                // if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'")) {
                // $iloc->mod = 'addressbookmodule';
                // $linked = true;
                // break;
                // }
                //                $iloc->mod = 'addressbookmodule';
                $addresses = $old_db->selectArrays('addressbook_contact', "location_data='" . serialize($iloc) . "'");
                if ($addresses) {
                    foreach ($addresses as $address) {
                        //						unset($address['id']);
                        $addr = new address();
                        $addr->user_id = 1;
                        $addr->is_default = 1;
                        $addr->is_billing = 1;
                        $addr->is_shipping = 1;
                        $addr->firstname = !empty($address['firstname']) ? $address['firstname'] : 'blank';
                        $addr->lastname = !empty($address['lastname']) ? $address['lastname'] : 'blank';
                        $addr->address1 = !empty($address['address1']) ? $address['address1'] : 'blank';
                        $addr->city = !empty($address['city']) ? $address['city'] : 'blank';
                        $address['state'] = !empty($address['state']) ? $address['state'] : 'CA';
                        $state = $db->selectObject('geo_region', 'code="' . strtoupper($address['state']) . '"');
                        $addr->state = $state->id;
                        $addr->zip = !empty($address['zip']) ? $address['zip'] : '99999';
                        $addr->phone = !empty($address['phone']) ? $address['phone'] : '800-555-1212';
                        $addr->email = !empty($address['email']) ? $address['email'] : '*****@*****.**';
                        $addr->organization = $address['business'];
                        $addr->phone2 = $address['cell'];
                        $addr->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'feedlistmodule':
                @($module->view = 'showall');
                $iloc->mod = 'feedlistmodule';
                $feedlist = $old_db->selectObject('feedlistmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($feedlist->enable_rss == 1) {
                    $loc = expUnserialize($feedlist->location_data);
                    $loc->mod = "rssController";
                    $config['enable_rss'] = true;
                    $config['feed_title'] = $feedlist->feed_title;
                    $config['feed_desc'] = $feedlist->feed_desc;
                    $config['rss_limit'] = isset($feedlist->rss_limit) ? $feedlist->rss_limit : 24;
                    $config['rss_cachetime'] = isset($feedlist->rss_cachetime) ? $feedlist->rss_cachetime : 1440;
                    $newconfig = new expConfig();
                    $newconfig->config = $config;
                    $newconfig->location_data = $loc;
                    $newconfig->save();
                    $newrss = new expRss();
                    $newrss->module = $loc->mod;
                    $newrss->src = $loc->src;
                    $newrss->enable_rss = $feedlist->enable_rss;
                    $newrss->feed_title = $feedlist->feed_title;
                    $newrss->feed_desc = $feedlist->feed_desc;
                    $newrss->rss_limit = isset($feedlist->rss_limit) ? $feedlist->rss_limit : 24;
                    $newrss->rss_cachetime = isset($feedlist->rss_cachetime) ? $feedlist->rss_cachetime : 1440;
                    $newrss->save();
                    @$this->msg['migrated'][$iloc->mod]['count']++;
                    @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                }
                break;
            default:
                @$this->msg['noconverter'][$iloc->mod]++;
                break;
        }
        // quick check for non hard coded modules
        // We add a container if they're not hard coded.
        !$hc ? $this->add_container($iloc, $module, $linked) : "";
        return $module;
    }